From d9f2bd79638a4629b1e5a93b0a57155186c80015 Mon Sep 17 00:00:00 2001 From: Igor Yakovlev Date: Mon, 8 Nov 2021 13:49:46 +0100 Subject: [PATCH] Revert "[Wasm][Temporary] Stubs for typeOf and ::class constructs" This reverts commit 8dc81b6c5786c0fdf3c1cc9e2ddc07f57686a772. --- .../jetbrains/kotlin/backend/wasm/WasmSymbols.kt | 5 ----- .../kotlin/backend/wasm/ir2wasm/BodyGenerator.kt | 16 ---------------- .../varSpilling/fakeInlinerVariables.kt | 2 ++ .../callableReferencesProperCompletion.kt | 1 + .../box/properties/lateinit/local/kt23260.kt | 3 +++ .../local/uninitializedCapturedMemberAccess.kt | 3 +++ .../lateinit/local/uninitializedCapturedRead.kt | 3 +++ .../lateinit/local/uninitializedMemberAccess.kt | 3 +++ .../lateinit/local/uninitializedRead.kt | 3 +++ .../lateinit/topLevel/accessorException.kt | 2 ++ .../topLevel/uninitializedMemberAccess.kt | 3 +++ .../lateinit/topLevel/uninitializedRead.kt | 3 +++ .../codegen/box/ranges/safeCallRangeTo.kt | 2 ++ 13 files changed, 28 insertions(+), 21 deletions(-) diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmSymbols.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmSymbols.kt index 14941b21531..5febd359d4c 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmSymbols.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmSymbols.kt @@ -45,11 +45,6 @@ class WasmSymbols( private val kotlinTestPackage: PackageViewDescriptor = context.module.getPackage(FqName("kotlin.test")) - private val kotlinReflectPackage: PackageViewDescriptor = - context.module.getPackage(FqName("kotlin.reflect")) - - val typeOf = getFunction("typeOf", kotlinReflectPackage) - override val throwNullPointerException = getInternalFunction("THROW_NPE") override val throwISE = getInternalFunction("THROW_ISE") override val throwTypeCastException = getInternalFunction("THROW_CCE") diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt index eb752128e43..6cbef3c7236 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt @@ -64,17 +64,6 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV error("Unexpected element of type ${element::class}") } - override fun visitClassReference(expression: IrClassReference) { - body.buildCall(context.referenceFunction(wasmSymbols.throwISE)) - body.buildUnreachable() - } - - override fun visitGetClass(expression: IrGetClass) { - body.buildCall(context.referenceFunction(wasmSymbols.throwISE)) - body.buildUnreachable() - } - - override fun visitThrow(expression: IrThrow) { generateExpression(expression.value) body.buildThrow(context.tagIdx) @@ -345,11 +334,6 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV } when (function.symbol) { - wasmSymbols.typeOf -> { - body.buildCall(context.referenceFunction(wasmSymbols.throwISE)) - body.buildGetUnit() - } - wasmSymbols.wasmClassId -> { val klass = call.getTypeArgument(0)!!.getClass() ?: error("No class given for wasmClassId intrinsic") diff --git a/compiler/testData/codegen/box/coroutines/varSpilling/fakeInlinerVariables.kt b/compiler/testData/codegen/box/coroutines/varSpilling/fakeInlinerVariables.kt index eafd0f0613e..287a3961d18 100644 --- a/compiler/testData/codegen/box/coroutines/varSpilling/fakeInlinerVariables.kt +++ b/compiler/testData/codegen/box/coroutines/varSpilling/fakeInlinerVariables.kt @@ -1,3 +1,5 @@ +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: CLASS_REFERENCES // WITH_RUNTIME // WITH_COROUTINES import kotlin.coroutines.* diff --git a/compiler/testData/codegen/box/inference/builderInference/callableReferencesProperCompletion.kt b/compiler/testData/codegen/box/inference/builderInference/callableReferencesProperCompletion.kt index 74e29a552b4..b4423ab99cb 100644 --- a/compiler/testData/codegen/box/inference/builderInference/callableReferencesProperCompletion.kt +++ b/compiler/testData/codegen/box/inference/builderInference/callableReferencesProperCompletion.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: WASM // WITH_RUNTIME fun nonGenericId(x: Any?) = x diff --git a/compiler/testData/codegen/box/properties/lateinit/local/kt23260.kt b/compiler/testData/codegen/box/properties/lateinit/local/kt23260.kt index 422a501ba6d..0ea211d1679 100644 --- a/compiler/testData/codegen/box/properties/lateinit/local/kt23260.kt +++ b/compiler/testData/codegen/box/properties/lateinit/local/kt23260.kt @@ -1,5 +1,8 @@ // WITH_RUNTIME +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: REFLECTION + fun box(): String { lateinit var str: String try { diff --git a/compiler/testData/codegen/box/properties/lateinit/local/uninitializedCapturedMemberAccess.kt b/compiler/testData/codegen/box/properties/lateinit/local/uninitializedCapturedMemberAccess.kt index 8735a8ec7e2..41999e6b919 100644 --- a/compiler/testData/codegen/box/properties/lateinit/local/uninitializedCapturedMemberAccess.kt +++ b/compiler/testData/codegen/box/properties/lateinit/local/uninitializedCapturedMemberAccess.kt @@ -1,5 +1,8 @@ // WITH_RUNTIME +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: REFLECTION + import kotlin.UninitializedPropertyAccessException fun runNoInline(f: () -> Unit) = f() diff --git a/compiler/testData/codegen/box/properties/lateinit/local/uninitializedCapturedRead.kt b/compiler/testData/codegen/box/properties/lateinit/local/uninitializedCapturedRead.kt index fed7824d7d5..baafb4cbf4d 100644 --- a/compiler/testData/codegen/box/properties/lateinit/local/uninitializedCapturedRead.kt +++ b/compiler/testData/codegen/box/properties/lateinit/local/uninitializedCapturedRead.kt @@ -1,5 +1,8 @@ // WITH_RUNTIME +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: REFLECTION + import kotlin.UninitializedPropertyAccessException fun runNoInline(f: () -> Unit) = f() diff --git a/compiler/testData/codegen/box/properties/lateinit/local/uninitializedMemberAccess.kt b/compiler/testData/codegen/box/properties/lateinit/local/uninitializedMemberAccess.kt index d3d8acc31e5..f8d260ebc7e 100644 --- a/compiler/testData/codegen/box/properties/lateinit/local/uninitializedMemberAccess.kt +++ b/compiler/testData/codegen/box/properties/lateinit/local/uninitializedMemberAccess.kt @@ -1,5 +1,8 @@ // WITH_RUNTIME +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: REFLECTION + import kotlin.UninitializedPropertyAccessException fun box(): String { diff --git a/compiler/testData/codegen/box/properties/lateinit/local/uninitializedRead.kt b/compiler/testData/codegen/box/properties/lateinit/local/uninitializedRead.kt index 9a58e3280b3..aa2888302ef 100644 --- a/compiler/testData/codegen/box/properties/lateinit/local/uninitializedRead.kt +++ b/compiler/testData/codegen/box/properties/lateinit/local/uninitializedRead.kt @@ -1,5 +1,8 @@ // WITH_RUNTIME +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: REFLECTION + import kotlin.UninitializedPropertyAccessException fun box(): String { diff --git a/compiler/testData/codegen/box/properties/lateinit/topLevel/accessorException.kt b/compiler/testData/codegen/box/properties/lateinit/topLevel/accessorException.kt index 949145290af..d4b30d811eb 100644 --- a/compiler/testData/codegen/box/properties/lateinit/topLevel/accessorException.kt +++ b/compiler/testData/codegen/box/properties/lateinit/topLevel/accessorException.kt @@ -1,4 +1,6 @@ // WITH_RUNTIME +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: REFLECTION // FILE: lateinit.kt diff --git a/compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedMemberAccess.kt b/compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedMemberAccess.kt index ac24a14335f..7a33dda8bf9 100644 --- a/compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedMemberAccess.kt +++ b/compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedMemberAccess.kt @@ -1,5 +1,8 @@ // WITH_RUNTIME +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: REFLECTION + import kotlin.UninitializedPropertyAccessException lateinit var str: String diff --git a/compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedRead.kt b/compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedRead.kt index 9cc162d805c..9f4c900259e 100644 --- a/compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedRead.kt +++ b/compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedRead.kt @@ -1,5 +1,8 @@ // WITH_RUNTIME +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: REFLECTION + import kotlin.UninitializedPropertyAccessException lateinit var str: String diff --git a/compiler/testData/codegen/box/ranges/safeCallRangeTo.kt b/compiler/testData/codegen/box/ranges/safeCallRangeTo.kt index 524f5d21000..3b07ad86aa0 100644 --- a/compiler/testData/codegen/box/ranges/safeCallRangeTo.kt +++ b/compiler/testData/codegen/box/ranges/safeCallRangeTo.kt @@ -1,3 +1,5 @@ +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: IGNORED_IN_JS // IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JS_IR_ES6 // TODO: muted automatically, investigate should it be ran for JS or not