[Wasm] Boolean boxed instances are the same
Fixed #KT-65411
This commit is contained in:
committed by
Space Team
parent
a171f774be
commit
a5ef668e3c
+6
@@ -2489,6 +2489,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/boxingOptimization"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedBooleanIdentity.kt")
|
||||
public void testBoxedBooleanIdentity() {
|
||||
runTest("compiler/testData/codegen/box/boxingOptimization/boxedBooleanIdentity.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedIntegersCmp.kt")
|
||||
public void testBoxedIntegersCmp() {
|
||||
|
||||
+6
@@ -2489,6 +2489,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/boxingOptimization"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedBooleanIdentity.kt")
|
||||
public void testBoxedBooleanIdentity() {
|
||||
runTest("compiler/testData/codegen/box/boxingOptimization/boxedBooleanIdentity.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedIntegersCmp.kt")
|
||||
public void testBoxedIntegersCmp() {
|
||||
|
||||
+6
@@ -2489,6 +2489,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/boxingOptimization"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedBooleanIdentity.kt")
|
||||
public void testBoxedBooleanIdentity() {
|
||||
runTest("compiler/testData/codegen/box/boxingOptimization/boxedBooleanIdentity.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedIntegersCmp.kt")
|
||||
public void testBoxedIntegersCmp() {
|
||||
|
||||
@@ -224,6 +224,8 @@ class WasmSymbols(
|
||||
symbolTable.descriptorExtension.referenceSimpleFunction(it)
|
||||
}
|
||||
|
||||
val getBoxedBoolean: IrSimpleFunctionSymbol = getInternalFunction("getBoxedBoolean")
|
||||
val boxBoolean: IrSimpleFunctionSymbol = getInternalFunction("boxBoolean")
|
||||
val boxIntrinsic: IrSimpleFunctionSymbol = getInternalFunction("boxIntrinsic")
|
||||
val unboxIntrinsic: IrSimpleFunctionSymbol = getInternalFunction("unboxIntrinsic")
|
||||
|
||||
|
||||
+13
-2
@@ -78,12 +78,23 @@ internal class WasmUsefulDeclarationProcessor(
|
||||
context.wasmSymbols.wasmTypeId,
|
||||
context.wasmSymbols.refCastNull,
|
||||
context.wasmSymbols.refTest,
|
||||
context.wasmSymbols.boxIntrinsic,
|
||||
context.wasmSymbols.wasmArrayCopy -> {
|
||||
call.getTypeArgument(0)?.enqueueRuntimeClassOrAny(from, "intrinsic ${call.symbol.owner.name}")
|
||||
true
|
||||
}
|
||||
|
||||
context.wasmSymbols.boxIntrinsic -> {
|
||||
val type = call.getTypeArgument(0)!!
|
||||
if (type == context.irBuiltIns.booleanType) {
|
||||
context.wasmSymbols.getBoxedBoolean.owner.enqueue(from, "intrinsic boxIntrinsic")
|
||||
} else {
|
||||
type.enqueueRuntimeClassOrAny(from, "intrinsic boxIntrinsic")
|
||||
}
|
||||
true
|
||||
}
|
||||
context.wasmSymbols.boxBoolean -> {
|
||||
context.irBuiltIns.booleanType.enqueueRuntimeClassOrAny(from, "intrinsic boxBoolean")
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -377,8 +377,18 @@ class BodyGenerator(
|
||||
|
||||
// Box intrinsic has an additional klass ID argument.
|
||||
// Processing it separately
|
||||
if (call.symbol == wasmSymbols.boxBoolean) {
|
||||
generateBox(call.getValueArgument(0)!!, irBuiltIns.booleanType)
|
||||
return
|
||||
}
|
||||
if (call.symbol == wasmSymbols.boxIntrinsic) {
|
||||
generateBox(call.getValueArgument(0)!!, call.getTypeArgument(0)!!)
|
||||
val type = call.getTypeArgument(0)!!
|
||||
if (type == irBuiltIns.booleanType) {
|
||||
generateExpression(call.getValueArgument(0)!!)
|
||||
body.buildCall(context.referenceFunction(context.backendContext.wasmSymbols.getBoxedBoolean), location)
|
||||
} else {
|
||||
generateBox(call.getValueArgument(0)!!, type)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fun boxBoolean(b: Boolean): Any = b
|
||||
|
||||
fun box(): String {
|
||||
if (boxBoolean(true) !== boxBoolean(true)) return "FAIL1"
|
||||
if (boxBoolean(false) !== boxBoolean(false)) return "FAIL2"
|
||||
if (boxBoolean(true) === boxBoolean(false)) return "FAIL3"
|
||||
if (boxBoolean(false) === boxBoolean(true)) return "FAIL4"
|
||||
if (boxBoolean(true) != boxBoolean(true)) return "FAIL5"
|
||||
if (boxBoolean(false) != boxBoolean(false)) return "FAIL6"
|
||||
if (boxBoolean(true) == boxBoolean(false)) return "FAIL7"
|
||||
if (boxBoolean(false) == boxBoolean(true)) return "FAIL8"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
-2
@@ -1,5 +1,3 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
fun box(): String {
|
||||
fun a(a: Any) = a === 1.1 is Double
|
||||
return if (a(true)) "OK" else "Fail"
|
||||
|
||||
+12
-2
@@ -39,9 +39,19 @@ fun f(block: () -> Unit) {
|
||||
|
||||
// EXPECTATIONS WASM
|
||||
// test.kt:1 $box
|
||||
// test.kt:4 $box (12, 4)
|
||||
// test.kt:4 $box (12, 12, 4)
|
||||
// Runtime.kt:70 $kotlin.wasm.internal.getBoxedBoolean (8, 8)
|
||||
// Runtime.kt:73 $kotlin.wasm.internal.getBoxedBoolean (8, 35)
|
||||
// Standard.kt:71 $kotlin.wasm.internal.getBoxedBoolean (0, 0, 0, 0)
|
||||
// Standard.kt:95 $kotlin.wasm.internal.getBoxedBoolean (4, 4)
|
||||
// Standard.kt:98 $kotlin.wasm.internal.getBoxedBoolean (4, 10, 4, 4, 10, 4)
|
||||
// Standard.kt:74 $kotlin.wasm.internal.getBoxedBoolean (15, 7)
|
||||
// Standard.kt:99 $kotlin.wasm.internal.getBoxedBoolean (11, 4, 11, 4)
|
||||
// Runtime.kt:74 $kotlin.wasm.internal.getBoxedBoolean (5, 5)
|
||||
// test.kt:5 $box (6, 6, 4)
|
||||
// test.kt:11 $f
|
||||
// test.kt:6 $box$lambda.invoke (8, 12, 12, 12, 12, 8, 16)
|
||||
// test.kt:6 $box$lambda.invoke (8, 12, 8, 16)
|
||||
// Runtime.kt:71 $kotlin.wasm.internal.getBoxedBoolean (8, 33)
|
||||
// Standard.kt:68 $kotlin.wasm.internal.getBoxedBoolean (25, 25, 25, 25, 45, 38)
|
||||
// test.kt:12 $f
|
||||
// test.kt:8 $box
|
||||
|
||||
+6
@@ -2489,6 +2489,12 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/boxingOptimization"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedBooleanIdentity.kt")
|
||||
public void testBoxedBooleanIdentity() {
|
||||
runTest("compiler/testData/codegen/box/boxingOptimization/boxedBooleanIdentity.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedIntegersCmp.kt")
|
||||
public void testBoxedIntegersCmp() {
|
||||
|
||||
+6
@@ -2297,6 +2297,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/boxingOptimization"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedBooleanIdentity.kt")
|
||||
public void testBoxedBooleanIdentity() {
|
||||
runTest("compiler/testData/codegen/box/boxingOptimization/boxedBooleanIdentity.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedIntegersCmp.kt")
|
||||
public void testBoxedIntegersCmp() {
|
||||
|
||||
+6
@@ -2489,6 +2489,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/boxingOptimization"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedBooleanIdentity.kt")
|
||||
public void testBoxedBooleanIdentity() {
|
||||
runTest("compiler/testData/codegen/box/boxingOptimization/boxedBooleanIdentity.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedIntegersCmp.kt")
|
||||
public void testBoxedIntegersCmp() {
|
||||
|
||||
+6
@@ -2489,6 +2489,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/boxingOptimization"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedBooleanIdentity.kt")
|
||||
public void testBoxedBooleanIdentity() {
|
||||
runTest("compiler/testData/codegen/box/boxingOptimization/boxedBooleanIdentity.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedIntegersCmp.kt")
|
||||
public void testBoxedIntegersCmp() {
|
||||
|
||||
+6
@@ -2489,6 +2489,12 @@ public class FirBlackBoxCodegenTestWithInlineScopesGenerated extends AbstractFir
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/boxingOptimization"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedBooleanIdentity.kt")
|
||||
public void testBoxedBooleanIdentity() {
|
||||
runTest("compiler/testData/codegen/box/boxingOptimization/boxedBooleanIdentity.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxedIntegersCmp.kt")
|
||||
public void testBoxedIntegersCmp() {
|
||||
|
||||
+5
@@ -2186,6 +2186,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/boxingOptimization"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedBooleanIdentity.kt")
|
||||
public void testBoxedBooleanIdentity() {
|
||||
runTest("compiler/testData/codegen/box/boxingOptimization/boxedBooleanIdentity.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boxedIntegersCmp.kt")
|
||||
public void testBoxedIntegersCmp() {
|
||||
runTest("compiler/testData/codegen/box/boxingOptimization/boxedIntegersCmp.kt");
|
||||
|
||||
Reference in New Issue
Block a user