[Wasm] Migrate to the new GC M6 instructions
This commit is contained in:
@@ -138,13 +138,16 @@ private fun Any.asWasmExternRef(): ExternalInterfaceType =
|
||||
internal external fun isNullish(ref: ExternalInterfaceType?): Boolean
|
||||
|
||||
internal fun externRefToAny(ref: ExternalInterfaceType): Any? {
|
||||
// If ref is an instance of kotlin class -- return it cased to Any
|
||||
// TODO rewrite it so to get something like:
|
||||
// block {
|
||||
// refAsAnyref
|
||||
// br_on_cast_fail 0 $kotlin.Any
|
||||
// return
|
||||
// }
|
||||
// If ref is an instance of kotlin class -- return it casted to Any
|
||||
val refAsAnyref = ref.externAsWasmAnyref()
|
||||
if (wasm_ref_is_data(refAsAnyref)) {
|
||||
val refAsDataRef = wasm_ref_as_data(refAsAnyref)
|
||||
if (wasm_ref_test<Any>(refAsDataRef)) {
|
||||
return wasm_ref_cast<Any>(refAsDataRef)
|
||||
}
|
||||
if (wasm_ref_test<Any>(refAsAnyref)) {
|
||||
return wasm_ref_cast<Any>(refAsAnyref)
|
||||
}
|
||||
|
||||
// If we have Null in notNullRef -- return null
|
||||
|
||||
@@ -378,17 +378,5 @@ public external fun wasm_i64_ctz(a: Long): Long
|
||||
|
||||
// Reference type operators
|
||||
|
||||
@WasmOp(WasmOp.REF_IS_DATA)
|
||||
internal external fun wasm_ref_is_data(x: anyref): Boolean
|
||||
|
||||
@WasmOp(WasmOp.REF_IS_I31)
|
||||
internal external fun wasm_ref_is_i31(x: anyref): Boolean
|
||||
|
||||
@WasmOp(WasmOp.REF_AS_DATA)
|
||||
internal external fun wasm_ref_as_data(x: anyref): dataref
|
||||
|
||||
@WasmOp(WasmOp.REF_AS_I31)
|
||||
internal external fun wasm_ref_as_i31(x: anyref): i31ref
|
||||
|
||||
@WasmOp(WasmOp.REF_IS_NULL)
|
||||
internal external fun wasm_externref_is_null(a: ExternalInterfaceType?): Boolean
|
||||
internal external fun wasm_externref_is_null(a: ExternalInterfaceType?): Boolean
|
||||
|
||||
@@ -254,21 +254,16 @@ internal annotation class WasmOp(val name: String) {
|
||||
const val ARRAY_COPY = "ARRAY_COPY"
|
||||
const val ARRAY_NEW_DATA = "ARRAY_NEW_DATA"
|
||||
const val ARRAY_NEW_FIXED = "ARRAY_NEW_FIXED"
|
||||
const val ARRAY_NEW_ELEM = "ARRAY_NEW_ELEM"
|
||||
const val I31_NEW = "I31_NEW"
|
||||
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 REF_IS_DATA = "REF_IS_DATA"
|
||||
const val REF_IS_I31 = "REF_IS_I31"
|
||||
const val REF_AS_DATA = "REF_AS_DATA"
|
||||
const val REF_AS_I31 = "REF_AS_I31"
|
||||
const val BR_ON_DATA = "BR_ON_DATA"
|
||||
const val BR_ON_I31 = "BR_ON_I31"
|
||||
const val BR_ON_NON_DATA = "BR_ON_NON_DATA"
|
||||
const val BR_ON_NON_I31 = "BR_ON_NON_I31"
|
||||
const val EXTERN_INTERNALIZE = "EXTERN_INTERNALIZE"
|
||||
const val EXTERN_EXTERNALIZE = "EXTERN_EXTERNALIZE"
|
||||
const val GET_UNIT = "GET_UNIT"
|
||||
|
||||
Reference in New Issue
Block a user