From 6432388778ba46b5a5678652836ff91e1d273389 Mon Sep 17 00:00:00 2001 From: Igor Laevsky Date: Thu, 16 Sep 2021 15:50:36 +0300 Subject: [PATCH] [WASM] Don't handle ref.cast of nulls. Spec was updated a while ago --- .../wasm/lower/WasmTypeOperatorLowering.kt | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/lower/WasmTypeOperatorLowering.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/lower/WasmTypeOperatorLowering.kt index 30977e4ed8e..272e4ab7159 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/lower/WasmTypeOperatorLowering.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/lower/WasmTypeOperatorLowering.kt @@ -212,24 +212,6 @@ class WasmBaseTypeOperatorTransformer(val context: WasmBackendContext) : IrEleme return value } - - // Ref casts traps on null (https://github.com/WebAssembly/gc/issues/152) - // Handling null manually - if (toType.isNullable() && fromType.isNullable()) { - return builder.irComposite { - val cachedValue = cacheValue(value) - +builder.irIfNull( - type = toType, - subject = cachedValue(), - thenPart = builder.irNull(toType), - elsePart = builder.irCall(symbols.wasmRefCast, type = toType).apply { - putTypeArgument(0, toType) - putValueArgument(0, cachedValue()) - } - ) - } - } - return builder.irCall(symbols.wasmRefCast, type = toType).apply { putTypeArgument(0, toType) putValueArgument(0, value)