[Wasm] Revert ref cast and test instructions to be compatible with Binaryen

This commit is contained in:
Zalim Bashorov
2022-11-17 19:19:41 +01:00
parent 5f140dac21
commit 7f8f7aa050
7 changed files with 41 additions and 26 deletions
@@ -179,8 +179,8 @@ class WasmSymbols(
val refEq = getInternalFunction("wasm_ref_eq")
val refIsNull = getInternalFunction("wasm_ref_is_null")
val externRefIsNull = getInternalFunction("wasm_externref_is_null")
val refTest = getInternalFunction("wasm_ref_test")
val refCastNull = getInternalFunction("wasm_ref_cast_null")
val refTest = getInternalFunction("wasm_ref_test_deprecated")
val refCastNull = getInternalFunction("wasm_ref_cast_deprecated")
val wasmArrayCopy = getInternalFunction("wasm_array_copy")
val wasmArrayNewData0 = getInternalFunction("array_new_data0")
@@ -492,7 +492,7 @@ class BodyGenerator(
body.buildBlock("isInterface", WasmRefNullType(WasmHeapType.Simple.Data)) { innerLabel ->
body.buildGetLocal(parameterLocal)
body.buildStructGet(context.referenceGcType(irBuiltIns.anyClass), WasmSymbol(1))
body.buildBrInstr(WasmOp.BR_ON_CAST_FAIL, innerLabel, classITable)
body.buildBrInstr(WasmOp.BR_ON_CAST_FAIL_DEPRECATED, innerLabel, classITable)
body.buildStructGet(classITable, context.referenceClassITableInterfaceSlot(irInterface.symbol))
body.buildInstr(WasmOp.REF_IS_NULL)
body.buildInstr(WasmOp.I32_EQZ)