mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
use also ref.cast
for every cast.
This commit is contained in:
parent
0a21fd9de9
commit
c1e8191ee0
@ -1435,6 +1435,11 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
case NEW_WITH_RTT:
|
||||
opCode = STRUCT_NEW_DEFAULT;
|
||||
break;
|
||||
case CAST:
|
||||
codeStream.writeOpCode( REF_CAST );
|
||||
codeStream.writeValueType( options.types.valueOf( "java/lang/Object" ) );
|
||||
codeStream.writeValueType( type );
|
||||
return;
|
||||
default:
|
||||
throw new Error( "Unknown operator: " + op );
|
||||
}
|
||||
|
@ -513,4 +513,6 @@ interface InstructionOpcodes {
|
||||
static final int ARRAY_LEN = 0xFB17;
|
||||
|
||||
static final int RTT_CANON = 0xFB30;
|
||||
|
||||
static final int REF_CAST = 0xFB41;
|
||||
}
|
||||
|
@ -228,6 +228,10 @@ class WasmStructInstruction extends WasmInstruction {
|
||||
writer.writeConst( idx, ValueType.i32 );
|
||||
}
|
||||
writer.writeFunctionCall( functionName, null );
|
||||
if( op == StructOperator.CAST && options.useGC() ) {
|
||||
writer.writeStructOperator( StructOperator.RTT_CANON, type, null, -1 );
|
||||
writer.writeStructOperator( op, type, null, -1 );
|
||||
}
|
||||
} else {
|
||||
writer.writeStructOperator( op, type, fieldName, idx );
|
||||
}
|
||||
|
@ -915,6 +915,9 @@ public class TextModuleWriter extends ModuleWriter {
|
||||
case NEW_WITH_RTT:
|
||||
operation = "struct.new_with_rtt";
|
||||
break;
|
||||
case CAST:
|
||||
operation = "ref.cast $java/lang/Object";
|
||||
break;
|
||||
default:
|
||||
throw new Error( "Unknown operator: " + op );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user