[Wasm] Rename dateref to structref
This commit is contained in:
committed by
Space Team
parent
1e0be4e0af
commit
1749bafc30
@@ -289,8 +289,8 @@ class WasmSymbols(
|
||||
}
|
||||
}
|
||||
|
||||
private val wasmDataRefClass = getIrClass(FqName("kotlin.wasm.internal.reftypes.dataref"))
|
||||
val wasmDataRefType by lazy { wasmDataRefClass.defaultType }
|
||||
private val wasmStructRefClass = getIrClass(FqName("kotlin.wasm.internal.reftypes.structref"))
|
||||
val wasmStructRefType by lazy { wasmStructRefClass.defaultType }
|
||||
|
||||
val wasmAnyRefClass = getIrClass(FqName("kotlin.wasm.internal.reftypes.anyref"))
|
||||
|
||||
|
||||
+2
-2
@@ -314,7 +314,7 @@ class BodyGenerator(
|
||||
if (klassSymbol.owner.hasInterfaceSuperClass()) {
|
||||
body.buildGetGlobal(context.referenceGlobalClassITable(klassSymbol), location)
|
||||
} else {
|
||||
body.buildRefNull(WasmHeapType.Simple.Data, location)
|
||||
body.buildRefNull(WasmHeapType.Simple.Struct, location)
|
||||
}
|
||||
|
||||
body.buildConstI32Symbol(context.referenceTypeId(klassSymbol), location)
|
||||
@@ -543,7 +543,7 @@ class BodyGenerator(
|
||||
val parameterLocal = functionContext.referenceLocal(SyntheticLocalType.IS_INTERFACE_PARAMETER)
|
||||
body.buildSetLocal(parameterLocal, location)
|
||||
body.buildBlock("isInterface", WasmI32) { outerLabel ->
|
||||
body.buildBlock("isInterface", WasmRefNullType(WasmHeapType.Simple.Data)) { innerLabel ->
|
||||
body.buildBlock("isInterface", WasmRefNullType(WasmHeapType.Simple.Struct)) { innerLabel ->
|
||||
body.buildGetLocal(parameterLocal, location)
|
||||
body.buildStructGet(context.referenceGcType(irBuiltIns.anyClass), WasmSymbol(1), location)
|
||||
|
||||
|
||||
+1
-1
@@ -364,7 +364,7 @@ class DeclarationGenerator(
|
||||
createClassITable(metadata)
|
||||
|
||||
val vtableRefGcType = WasmRefType(WasmHeapType.Type(context.referenceVTableGcType(symbol)))
|
||||
val classITableRefGcType = WasmRefNullType(WasmHeapType.Simple.Data)
|
||||
val classITableRefGcType = WasmRefNullType(WasmHeapType.Simple.Struct)
|
||||
val fields = mutableListOf<WasmStructFieldDeclaration>()
|
||||
fields.add(WasmStructFieldDeclaration("vtable", vtableRefGcType, false))
|
||||
fields.add(WasmStructFieldDeclaration("itable", classITableRefGcType, false))
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ class WasmTypeTransformer(
|
||||
when (val name = klass.name.identifier) {
|
||||
"anyref" -> WasmAnyRef
|
||||
"eqref" -> WasmEqRef
|
||||
"dataref" -> WasmRefNullType(WasmHeapType.Simple.Data)
|
||||
"structref" -> WasmRefNullType(WasmHeapType.Simple.Struct)
|
||||
"i31ref" -> WasmI31Ref
|
||||
"funcref" -> WasmRefNullType(WasmHeapType.Simple.Func)
|
||||
else -> error("Unknown reference type $name")
|
||||
|
||||
+9
-9
@@ -282,7 +282,7 @@ class JsInteropFunctionsLowering(val context: WasmBackendContext) : DeclarationT
|
||||
// Thus, we export helper "caller" method that JavaScript will use to call kotlin closures:
|
||||
//
|
||||
// @JsExport
|
||||
// fun __callFunction_<signatureString>(f: dataref, p1: JsType1, p2: JsType2, ...): JsTypeRes {
|
||||
// fun __callFunction_<signatureString>(f: structref, p1: JsType1, p2: JsType2, ...): JsTypeRes {
|
||||
// return adapt(
|
||||
// cast<FunctionN>(f).invoke(
|
||||
// adapt(p1),
|
||||
@@ -302,7 +302,7 @@ class JsInteropFunctionsLowering(val context: WasmBackendContext) : DeclarationT
|
||||
// @JsFun("""(f) => {
|
||||
// (p1, p2, ...) => <wasm-exports>.__callFunction_<signatureString>(f, p1, p2, ...)
|
||||
// }""")
|
||||
// external fun __convertKotlinClosureToJsClosure_<signatureString>(f: dataref): ExternalRef
|
||||
// external fun __convertKotlinClosureToJsClosure_<signatureString>(f: structref): ExternalRef
|
||||
//
|
||||
val kotlinToJsClosureConvertor = context.kotlinClosureToJsConverters.getOrPut(functionTypeInfo.signatureString) {
|
||||
createKotlinToJsClosureConvertor(functionTypeInfo)
|
||||
@@ -436,7 +436,7 @@ class JsInteropFunctionsLowering(val context: WasmBackendContext) : DeclarationT
|
||||
result.parent = currentParent
|
||||
result.addValueParameter {
|
||||
name = Name.identifier("f")
|
||||
type = context.wasmSymbols.wasmDataRefType
|
||||
type = context.wasmSymbols.wasmStructRefType
|
||||
}
|
||||
var count = 0
|
||||
info.adaptedParameterTypes.forEach { type ->
|
||||
@@ -476,7 +476,7 @@ class JsInteropFunctionsLowering(val context: WasmBackendContext) : DeclarationT
|
||||
result.parent = currentParent
|
||||
result.addValueParameter {
|
||||
name = Name.identifier("f")
|
||||
type = context.wasmSymbols.wasmDataRefType
|
||||
type = context.wasmSymbols.wasmStructRefType
|
||||
}
|
||||
val builder = context.createIrBuilder(result.symbol)
|
||||
// TODO: Cache created JS closures
|
||||
@@ -722,24 +722,24 @@ class JsInteropFunctionsLowering(val context: WasmBackendContext) : DeclarationT
|
||||
}
|
||||
|
||||
/**
|
||||
* Current V8 Wasm GC mandates dataref type instead of structs and arrays
|
||||
* Current V8 Wasm GC mandates structref type instead of structs and arrays
|
||||
*/
|
||||
inner class SendKotlinObjectToJsAdapter(
|
||||
override val fromType: IrType
|
||||
) : InteropTypeAdapter {
|
||||
override val toType: IrType = context.wasmSymbols.wasmDataRefType
|
||||
override val toType: IrType = context.wasmSymbols.wasmStructRefType
|
||||
override fun adapt(expression: IrExpression, builder: IrBuilderWithScope): IrExpression {
|
||||
return builder.irReinterpretCast(expression, toType)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Current V8 Wasm GC mandates dataref type instead of structs and arrays
|
||||
* Current V8 Wasm GC mandates structref type instead of structs and arrays
|
||||
*/
|
||||
inner class ReceivingKotlinObjectFromJsAdapter(
|
||||
override val toType: IrType
|
||||
) : InteropTypeAdapter {
|
||||
override val fromType: IrType = context.wasmSymbols.wasmDataRefType
|
||||
override val fromType: IrType = context.wasmSymbols.wasmStructRefType
|
||||
override fun adapt(expression: IrExpression, builder: IrBuilderWithScope): IrExpression {
|
||||
val call = builder.irCall(context.wasmSymbols.refCastNull)
|
||||
call.putValueArgument(0, expression)
|
||||
@@ -749,7 +749,7 @@ class JsInteropFunctionsLowering(val context: WasmBackendContext) : DeclarationT
|
||||
}
|
||||
|
||||
/**
|
||||
* Current V8 Wasm GC mandates dataref type instead of structs and arrays
|
||||
* Current V8 Wasm GC mandates structref type instead of structs and arrays
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user