mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
fix type handling for NUL values with GC support
This commit is contained in:
parent
77d81e3f13
commit
856194dbce
@ -1395,7 +1395,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
break;
|
break;
|
||||||
case NULL:
|
case NULL:
|
||||||
opCode = REF_NULL;
|
opCode = REF_NULL;
|
||||||
type = options.useGC() ? ValueType.eqref : ValueType.externref;
|
type = options.useGC() ? type : ValueType.externref;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error( "Unknown operator: " + op );
|
throw new Error( "Unknown operator: " + op );
|
||||||
|
@ -98,8 +98,7 @@ class WasmOutputStream extends LittleEndianOutputStream {
|
|||||||
public void writeRefValueType( AnyType type ) throws IOException {
|
public void writeRefValueType( AnyType type ) throws IOException {
|
||||||
if( type.isRefType() ) {
|
if( type.isRefType() ) {
|
||||||
if( options.useGC() ) {
|
if( options.useGC() ) {
|
||||||
//TODO writeValueType( ValueType.ref_type );
|
writeValueType( ValueType.optref );
|
||||||
type = ValueType.eqref;
|
|
||||||
} else {
|
} else {
|
||||||
type = ValueType.externref;
|
type = ValueType.externref;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
|
|||||||
case 0: // nop
|
case 0: // nop
|
||||||
break;
|
break;
|
||||||
case 1: // aconst_null
|
case 1: // aconst_null
|
||||||
addStructInstruction( StructOperator.NULL, null, null, codePos, lineNumber );
|
addStructInstruction( StructOperator.NULL, "java/lang/Object", null, codePos, lineNumber );
|
||||||
break;
|
break;
|
||||||
case 2: // iconst_m1
|
case 2: // iconst_m1
|
||||||
case 3: // iconst_0
|
case 3: // iconst_0
|
||||||
|
@ -64,10 +64,10 @@ class WasmStructInstruction extends WasmInstruction {
|
|||||||
* @param types
|
* @param types
|
||||||
* the type manager
|
* the type manager
|
||||||
*/
|
*/
|
||||||
WasmStructInstruction( @Nullable StructOperator op, @Nullable String typeName, @Nullable NamedStorageType fieldName, int javaCodePos, int lineNumber, TypeManager types ) {
|
WasmStructInstruction( @Nullable StructOperator op, @Nonnull String typeName, @Nullable NamedStorageType fieldName, int javaCodePos, int lineNumber, TypeManager types ) {
|
||||||
super( javaCodePos, lineNumber );
|
super( javaCodePos, lineNumber );
|
||||||
this.op = op;
|
this.op = op;
|
||||||
this.type = typeName == null ? null : types.valueOf( typeName );
|
this.type = types.valueOf( typeName );
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
if( type != null && fieldName != null ) {
|
if( type != null && fieldName != null ) {
|
||||||
type.useFieldName( fieldName );
|
type.useFieldName( fieldName );
|
||||||
|
@ -861,8 +861,12 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
operation = "struct.set";
|
operation = "struct.set";
|
||||||
break;
|
break;
|
||||||
case NULL:
|
case NULL:
|
||||||
operation = options.useGC() ? "ref.null eq" : "ref.null extern";
|
if( options.useGC() ) {
|
||||||
type = null;
|
operation = "ref.null";
|
||||||
|
} else {
|
||||||
|
operation = "ref.null extern";
|
||||||
|
type = null;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error( "Unknown operator: " + op );
|
throw new Error( "Unknown operator: " + op );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user