[WASM] Remove deprecated wasm instructions
This commit is contained in:
+7
-33
@@ -43,56 +43,30 @@ internal class WasmUsefulDeclarationProcessor(
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
context.wasmSymbols.wasmClassId,
|
||||
context.wasmSymbols.wasmInterfaceId,
|
||||
context.wasmSymbols.refCast,
|
||||
context.wasmSymbols.refTest -> {
|
||||
call.getTypeArgument(0)?.getClass()?.enqueue(from, "generic intrinsic ${call.symbol.owner.name}")
|
||||
context.wasmSymbols.refTest,
|
||||
context.wasmSymbols.boxIntrinsic -> {
|
||||
call.getTypeArgument(0)?.enqueueRuntimeClassOrAny(from, "intrinsic ${call.symbol.owner.name}")
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
|
||||
private fun tryToProcessWasmOpIntrinsicCall(from: IrDeclaration, call: IrCall, function: IrFunction): Boolean {
|
||||
if (function.hasWasmNoOpCastAnnotation()) {
|
||||
return true
|
||||
}
|
||||
|
||||
val opString = function.getWasmOpAnnotation()
|
||||
if (opString != null) {
|
||||
val op = WasmOp.valueOf(opString)
|
||||
when (op.immediates.size) {
|
||||
0 -> {
|
||||
if (op == WasmOp.REF_TEST || op == WasmOp.REF_TEST_STATIC) {
|
||||
call.getTypeArgument(0)?.enqueueRuntimeClassOrAny(from, "REF_TEST/REF_TEST_STATIC")
|
||||
}
|
||||
}
|
||||
1 -> {
|
||||
if (op.immediates.firstOrNull() == WasmImmediateKind.STRUCT_TYPE_IDX) {
|
||||
function.dispatchReceiverParameter?.type?.classOrNull?.owner?.enqueue(from, "STRUCT_TYPE_IDX")
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun visitCall(expression: IrCall, data: IrDeclaration) {
|
||||
super.visitCall(expression, data)
|
||||
|
||||
if (expression.symbol == context.wasmSymbols.boxIntrinsic) {
|
||||
expression.getTypeArgument(0)?.enqueueRuntimeClassOrAny(data, "boxIntrinsic")
|
||||
return
|
||||
}
|
||||
|
||||
val function: IrFunction = expression.symbol.owner.realOverrideTarget
|
||||
if (function.returnType == context.irBuiltIns.unitType) {
|
||||
unitGetInstance.enqueue(data, "function Unit return type")
|
||||
}
|
||||
|
||||
if (tryToProcessIntrinsicCall(data, expression)) return
|
||||
if (tryToProcessWasmOpIntrinsicCall(data, expression, function)) return
|
||||
if (function.hasWasmNoOpCastAnnotation()) return
|
||||
if (function.getWasmOpAnnotation() != null) return
|
||||
|
||||
val isSuperCall = expression.superQualifierSymbol != null
|
||||
if (function is IrSimpleFunction && function.isOverridable && !isSuperCall) {
|
||||
|
||||
+11
-15
@@ -197,9 +197,8 @@ class BodyGenerator(
|
||||
if (klass.getWasmArrayAnnotation() != null) {
|
||||
require(expression.valueArgumentsCount == 1) { "@WasmArrayOf constructs must have exactly one argument" }
|
||||
generateExpression(expression.getValueArgument(0)!!)
|
||||
body.buildRttCanon(wasmGcType)
|
||||
body.buildInstr(
|
||||
WasmOp.ARRAY_NEW_DEFAULT_WITH_RTT,
|
||||
WasmOp.ARRAY_NEW_DEFAULT,
|
||||
WasmImmediate.GcType(wasmGcType)
|
||||
)
|
||||
return
|
||||
@@ -383,7 +382,7 @@ class BodyGenerator(
|
||||
call: IrFunctionAccessExpression,
|
||||
function: IrFunction
|
||||
): Boolean {
|
||||
if (tryToGenerateWasmOpIntrinsicCall(call, function)) {
|
||||
if (tryToGenerateWasmOpIntrinsicCall(function)) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -436,6 +435,13 @@ class BodyGenerator(
|
||||
)
|
||||
}
|
||||
|
||||
wasmSymbols.refTest -> {
|
||||
generateRefTest(
|
||||
fromType = call.getValueArgument(0)!!.type,
|
||||
toType = call.getTypeArgument(0)!!
|
||||
)
|
||||
}
|
||||
|
||||
wasmSymbols.unboxIntrinsic -> {
|
||||
val fromType = call.getTypeArgument(0)!!
|
||||
|
||||
@@ -625,7 +631,7 @@ class BodyGenerator(
|
||||
}
|
||||
|
||||
// Return true if function is recognized as intrinsic.
|
||||
private fun tryToGenerateWasmOpIntrinsicCall(call: IrFunctionAccessExpression, function: IrFunction): Boolean {
|
||||
private fun tryToGenerateWasmOpIntrinsicCall(function: IrFunction): Boolean {
|
||||
if (function.hasWasmNoOpCastAnnotation()) {
|
||||
return true
|
||||
}
|
||||
@@ -635,17 +641,7 @@ class BodyGenerator(
|
||||
val op = WasmOp.valueOf(opString)
|
||||
when (op.immediates.size) {
|
||||
0 -> {
|
||||
when (op) {
|
||||
WasmOp.REF_TEST, WasmOp.REF_TEST_STATIC -> {
|
||||
generateRefTest(
|
||||
fromType = call.getValueArgument(0)!!.type,
|
||||
toType = call.getTypeArgument(0)!!
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
body.buildInstr(op)
|
||||
}
|
||||
}
|
||||
body.buildInstr(op)
|
||||
}
|
||||
1 -> {
|
||||
val immediates = arrayOf(
|
||||
|
||||
Reference in New Issue
Block a user