[Wasm] Revert ref cast and test instructions to be compatible with Binaryen
This commit is contained in:
@@ -146,8 +146,11 @@ internal fun externRefToAny(ref: ExternalInterfaceType): Any? {
|
||||
// }
|
||||
// If ref is an instance of kotlin class -- return it casted to Any
|
||||
val refAsAnyref = ref.externAsWasmAnyref()
|
||||
if (wasm_ref_test_null<Any>(refAsAnyref)) {
|
||||
return wasm_ref_cast_null<Any>(refAsAnyref)
|
||||
if (wasm_ref_is_data_deprecated(refAsAnyref)) {
|
||||
val refAsDataRef = wasm_ref_as_data_deprecated(refAsAnyref)
|
||||
if (wasm_ref_test_deprecated<Any>(refAsDataRef)) {
|
||||
return wasm_ref_cast_deprecated<Any>(refAsDataRef)
|
||||
}
|
||||
}
|
||||
|
||||
// If we have Null in notNullRef -- return null
|
||||
|
||||
@@ -20,16 +20,11 @@ internal fun wasm_unreachable(): Nothing =
|
||||
implementedAsIntrinsic
|
||||
|
||||
@Suppress("REIFIED_TYPE_PARAMETER_NO_INLINE")
|
||||
internal fun <reified To> wasm_ref_cast_null(a: Any?): To =
|
||||
internal fun <reified To> wasm_ref_cast_deprecated(a: Any?): To =
|
||||
implementedAsIntrinsic
|
||||
|
||||
@Suppress("REIFIED_TYPE_PARAMETER_NO_INLINE")
|
||||
internal fun <reified To> wasm_ref_test(a: Any?): Boolean =
|
||||
implementedAsIntrinsic
|
||||
|
||||
@Suppress("REIFIED_TYPE_PARAMETER_NO_INLINE")
|
||||
@WasmOp(WasmOp.REF_TEST_NULL)
|
||||
internal fun <reified To> wasm_ref_test_null(a: Any?): Boolean =
|
||||
internal fun <reified To> wasm_ref_test_deprecated(a: Any?): Boolean =
|
||||
implementedAsIntrinsic
|
||||
|
||||
internal fun <T> wasm_array_copy(destination: T, destinationIndex: Int, source: T, sourceIndex: Int, length: Int): Unit =
|
||||
@@ -392,3 +387,9 @@ internal external fun wasm_i64_ctz(a: Long): Long
|
||||
|
||||
@WasmOp(WasmOp.REF_IS_NULL)
|
||||
internal external fun wasm_externref_is_null(a: ExternalInterfaceType?): Boolean
|
||||
|
||||
@WasmOp(WasmOp.REF_AS_DATA_DEPRECATED)
|
||||
internal external fun wasm_ref_as_data_deprecated(x: anyref): dataref
|
||||
|
||||
@WasmOp(WasmOp.REF_IS_DATA_DEPRECATED)
|
||||
internal external fun wasm_ref_is_data_deprecated(x: anyref): Boolean
|
||||
|
||||
@@ -259,13 +259,13 @@ internal annotation class WasmOp(val name: String) {
|
||||
const val I31_GET_S = "I31_GET_S"
|
||||
const val I31_GET_U = "I31_GET_U"
|
||||
const val REF_EQ = "REF_EQ"
|
||||
const val REF_TEST = "REF_TEST"
|
||||
const val REF_TEST_NULL = "REF_TEST_NULL"
|
||||
const val REF_CAST = "REF_CAST"
|
||||
const val REF_CAST_NULL = "REF_CAST_NULL"
|
||||
const val BR_ON_CAST_FAIL = "BR_ON_CAST_FAIL"
|
||||
const val EXTERN_INTERNALIZE = "EXTERN_INTERNALIZE"
|
||||
const val EXTERN_EXTERNALIZE = "EXTERN_EXTERNALIZE"
|
||||
const val REF_TEST_DEPRECATED = "REF_TEST_DEPRECATED"
|
||||
const val REF_CAST_DEPRECATED = "REF_CAST_DEPRECATED"
|
||||
const val REF_IS_DATA_DEPRECATED = "REF_IS_DATA_DEPRECATED"
|
||||
const val REF_AS_DATA_DEPRECATED = "REF_AS_DATA_DEPRECATED"
|
||||
const val BR_ON_CAST_FAIL_DEPRECATED = "BR_ON_CAST_FAIL_DEPRECATED"
|
||||
const val GET_UNIT = "GET_UNIT"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user