mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 15:37:52 +01:00
add support for objects equals/not equals (if_acmpeq,if_acmpne)
This commit is contained in:
parent
9ba680848a
commit
6196648cc0
@ -635,6 +635,13 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
codeStream.writeOpCode( REF_ISNULL );
|
codeStream.writeOpCode( REF_ISNULL );
|
||||||
op = I32_EQZ;
|
op = I32_EQZ;
|
||||||
break;
|
break;
|
||||||
|
case ref_eq:
|
||||||
|
op = REF_EQ;
|
||||||
|
break;
|
||||||
|
case ref_ne:
|
||||||
|
codeStream.writeOpCode( REF_EQ );
|
||||||
|
op = I32_EQZ;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if( op == 0 ) {
|
if( op == 0 ) {
|
||||||
throw new Error( valueType + "." + numOp );
|
throw new Error( valueType + "." + numOp );
|
||||||
|
@ -379,6 +379,8 @@ interface InstructionOpcodes {
|
|||||||
|
|
||||||
static final int REF_ISNULL = 0xD1;
|
static final int REF_ISNULL = 0xD1;
|
||||||
|
|
||||||
|
static final int REF_EQ = 0xD2;
|
||||||
|
|
||||||
// === Non-trapping float-to-int conversions ====== https://github.com/WebAssembly/design/issues/1143
|
// === Non-trapping float-to-int conversions ====== https://github.com/WebAssembly/design/issues/1143
|
||||||
|
|
||||||
static final int I32_TRUNC_S_SAT_F32 = 0xFC00;
|
static final int I32_TRUNC_S_SAT_F32 = 0xFC00;
|
||||||
|
@ -702,6 +702,12 @@ class BranchManger {
|
|||||||
case ifnonnull:
|
case ifnonnull:
|
||||||
newOp = NumericOperator.ifnull;
|
newOp = NumericOperator.ifnull;
|
||||||
break;
|
break;
|
||||||
|
case ref_eq:
|
||||||
|
newOp = NumericOperator.ref_ne;
|
||||||
|
break;
|
||||||
|
case ref_ne:
|
||||||
|
newOp = NumericOperator.ref_eq;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new WasmException( "Not a compare operation: " + instr.numOp, null, null, lineNumber );
|
throw new WasmException( "Not a compare operation: " + instr.numOp, null, null, lineNumber );
|
||||||
}
|
}
|
||||||
|
@ -480,8 +480,12 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
|
|||||||
case 164: // if_icmple
|
case 164: // if_icmple
|
||||||
opIfCompareCondition( NumericOperator.le, byteCode, codePos );
|
opIfCompareCondition( NumericOperator.le, byteCode, codePos );
|
||||||
break;
|
break;
|
||||||
//TODO case 165: // if_acmpeq
|
case 165: // if_acmpeq
|
||||||
//TODO case 166: // if_acmpne
|
opIfCompareCondition( NumericOperator.ref_eq, byteCode, codePos );
|
||||||
|
break;
|
||||||
|
case 166: // if_acmpne
|
||||||
|
opIfCompareCondition( NumericOperator.ref_ne, byteCode, codePos );
|
||||||
|
break;
|
||||||
case 167: // goto
|
case 167: // goto
|
||||||
int offset = byteCode.readShort();
|
int offset = byteCode.readShort();
|
||||||
branchManager.addGotoOperator( codePos, offset, byteCode.getLineNumber() );
|
branchManager.addGotoOperator( codePos, offset, byteCode.getLineNumber() );
|
||||||
|
@ -217,6 +217,13 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
case ifnull:
|
case ifnull:
|
||||||
methodOutput.append( "ref.isnull" );
|
methodOutput.append( "ref.isnull" );
|
||||||
return;
|
return;
|
||||||
|
case ref_ne:
|
||||||
|
methodOutput.append( "ref.eq" );
|
||||||
|
writeNumericOperator( NumericOperator.eqz, ValueType.i32 );
|
||||||
|
return;
|
||||||
|
case ref_eq:
|
||||||
|
methodOutput.append( "ref.eq" );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -41,4 +41,6 @@ public enum NumericOperator {
|
|||||||
max,
|
max,
|
||||||
ifnull,
|
ifnull,
|
||||||
ifnonnull,
|
ifnonnull,
|
||||||
|
ref_eq,
|
||||||
|
ref_ne,
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,8 @@ public class Structs extends AbstractBaseTest {
|
|||||||
ScriptEngine script = val[0];
|
ScriptEngine script = val[0];
|
||||||
addParam( list, script, "isNull" );
|
addParam( list, script, "isNull" );
|
||||||
addParam( list, script, "isNotNull" );
|
addParam( list, script, "isNotNull" );
|
||||||
|
addParam( list, script, "isSame" );
|
||||||
|
addParam( list, script, "isNotSame" );
|
||||||
addParam( list, script, "simple" );
|
addParam( list, script, "simple" );
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@ -68,6 +70,20 @@ public class Structs extends AbstractBaseTest {
|
|||||||
return val != null;
|
return val != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Export
|
||||||
|
static boolean isSame() {
|
||||||
|
Object val1 = null;
|
||||||
|
Object val2 = null;
|
||||||
|
return val1 == val2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Export
|
||||||
|
static boolean isNotSame() {
|
||||||
|
Object val1 = null;
|
||||||
|
Object val2 = null;
|
||||||
|
return val1 != val2;
|
||||||
|
}
|
||||||
|
|
||||||
@Export
|
@Export
|
||||||
static int simple() {
|
static int simple() {
|
||||||
Object val = new Abc();
|
Object val = new Abc();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user