mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
switch from anyref to eqref for GC code
This commit is contained in:
parent
4cd43a4d65
commit
1d3db1135b
@ -1394,7 +1394,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
break;
|
break;
|
||||||
case NULL:
|
case NULL:
|
||||||
opCode = REF_NULL;
|
opCode = REF_NULL;
|
||||||
type = options.useGC() ? ValueType.anyref : ValueType.externref;
|
type = options.useGC() ? ValueType.eqref : ValueType.externref;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error( "Unknown operator: " + op );
|
throw new Error( "Unknown operator: " + op );
|
||||||
|
@ -55,8 +55,8 @@ class StructTypeEntry extends TypeEntry {
|
|||||||
void writeSectionEntryDetails( WasmOutputStream stream ) throws IOException {
|
void writeSectionEntryDetails( WasmOutputStream stream ) throws IOException {
|
||||||
stream.writeVaruint32( this.fields.size() );
|
stream.writeVaruint32( this.fields.size() );
|
||||||
for( NamedStorageType field : this.fields ) {
|
for( NamedStorageType field : this.fields ) {
|
||||||
stream.writeVarint( 1 ); // 0 - immutable; 1 - mutable
|
|
||||||
stream.writeRefValueType( field.getType() );
|
stream.writeRefValueType( field.getType() );
|
||||||
|
stream.writeVarint( 1 ); // 0 - immutable; 1 - mutable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class WasmOutputStream extends LittleEndianOutputStream {
|
|||||||
if( type.isRefType() ) {
|
if( type.isRefType() ) {
|
||||||
if( options.useGC() ) {
|
if( options.useGC() ) {
|
||||||
//TODO writeValueType( ValueType.ref_type );
|
//TODO writeValueType( ValueType.ref_type );
|
||||||
type = ValueType.anyref;
|
type = ValueType.eqref;
|
||||||
} else {
|
} else {
|
||||||
type = ValueType.externref;
|
type = ValueType.externref;
|
||||||
}
|
}
|
||||||
|
@ -783,7 +783,7 @@ public class TypeManager {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isSubTypeOf( AnyType type ) {
|
public boolean isSubTypeOf( AnyType type ) {
|
||||||
//TODO if type is StructType (class or interface)
|
//TODO if type is StructType (class or interface)
|
||||||
return type == this || type == ValueType.externref || type == ValueType.anyref;
|
return type == this || type == ValueType.externref || type == ValueType.anyref || type == ValueType.eqref;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,7 +203,7 @@ class WasmStructInstruction extends WasmInstruction {
|
|||||||
AnyType getPushValueType() {
|
AnyType getPushValueType() {
|
||||||
switch( op ) {
|
switch( op ) {
|
||||||
case NULL:
|
case NULL:
|
||||||
return options.useGC() ? ValueType.anyref : ValueType.externref;
|
return options.useGC() ? ValueType.eqref : ValueType.externref;
|
||||||
case NEW:
|
case NEW:
|
||||||
case NEW_DEFAULT:
|
case NEW_DEFAULT:
|
||||||
case CAST:
|
case CAST:
|
||||||
|
@ -316,7 +316,7 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
if( !type.isRefType() ) {
|
if( !type.isRefType() ) {
|
||||||
output.append( type.toString() );
|
output.append( type.toString() );
|
||||||
} else if( options.useGC() ) {
|
} else if( options.useGC() ) {
|
||||||
output.append( ValueType.anyref.toString() );
|
output.append( ValueType.eqref.toString() );
|
||||||
//TODO output.append( "(optref " ).append( normalizeName( type.toString() ) ).append( ')' );
|
//TODO output.append( "(optref " ).append( normalizeName( type.toString() ) ).append( ')' );
|
||||||
} else {
|
} else {
|
||||||
output.append( ValueType.externref.toString() );
|
output.append( ValueType.externref.toString() );
|
||||||
@ -859,7 +859,7 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
operation = "struct.set";
|
operation = "struct.set";
|
||||||
break;
|
break;
|
||||||
case NULL:
|
case NULL:
|
||||||
operation = options.useGC() ? "ref.null any" : "ref.null extern";
|
operation = options.useGC() ? "ref.null eq" : "ref.null extern";
|
||||||
type = null;
|
type = null;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -24,12 +24,14 @@ public enum ValueType implements AnyType {
|
|||||||
f32(-0x03),
|
f32(-0x03),
|
||||||
f64(-0x04),
|
f64(-0x04),
|
||||||
v128(-0x05),
|
v128(-0x05),
|
||||||
i8(-0x06), //TODO dummy value for https://github.com/WebAssembly/gc
|
i8(-0x06),
|
||||||
i16(-0x07), //TODO dummy value for https://github.com/WebAssembly/gc
|
i16(-0x07),
|
||||||
funcref(-0x10),
|
funcref(-0x10),
|
||||||
externref(-0x11),
|
externref(-0x11),
|
||||||
anyref(-0x12),
|
anyref(-0x12),
|
||||||
ref_type(-0x13 ), // 0x6D https://github.com/lars-t-hansen/moz-gc-experiments/blob/master/version2.md
|
eqref(-0x13),
|
||||||
|
optref(-0x14),
|
||||||
|
ref(-0x15),
|
||||||
exnref(-0x18), // https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md
|
exnref(-0x18), // https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md
|
||||||
func(-0x20),
|
func(-0x20),
|
||||||
struct(-0x21),
|
struct(-0x21),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user