mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
call ref_eq polyfill in non gc mode
This commit is contained in:
parent
50f10f1f47
commit
b2f1fbc195
@ -262,7 +262,7 @@ public abstract class WasmCodeBuilder {
|
|||||||
WasmNumericInstruction numeric = new WasmNumericInstruction( numOp, valueType, javaCodePos, lineNumber );
|
WasmNumericInstruction numeric = new WasmNumericInstruction( numOp, valueType, javaCodePos, lineNumber );
|
||||||
instructions.add( numeric );
|
instructions.add( numeric );
|
||||||
if( !options.useGC() && numOp == NumericOperator.ref_eq ) {
|
if( !options.useGC() && numOp == NumericOperator.ref_eq ) {
|
||||||
functions.markAsNeeded( getNonGC( "ref_eq", lineNumber ), true );
|
functions.markAsNeeded( options.ref_eq = getNonGC( "ref_eq", lineNumber ), true );
|
||||||
}
|
}
|
||||||
return numeric;
|
return numeric;
|
||||||
}
|
}
|
||||||
|
@ -515,8 +515,8 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void writeNumericOperator( NumericOperator numOp, @Nullable ValueType valueType ) throws IOException {
|
protected void writeNumericOperator( NumericOperator numOp, @Nullable ValueType valueType ) throws IOException {
|
||||||
newline( methodOutput );
|
boolean negate = false;
|
||||||
String op = numOp.toString();
|
String op = valueType.toString() + '.' + numOp.toString();
|
||||||
switch( valueType ) {
|
switch( valueType ) {
|
||||||
case i32:
|
case i32:
|
||||||
case i64:
|
case i64:
|
||||||
@ -530,25 +530,33 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
op += "_s";
|
op += "_s";
|
||||||
break;
|
break;
|
||||||
case ifnonnull:
|
case ifnonnull:
|
||||||
methodOutput.append( "ref.is_null" );
|
op = "ref.is_null";
|
||||||
writeNumericOperator( NumericOperator.eqz, ValueType.i32 );
|
negate = true;
|
||||||
return;
|
break;
|
||||||
case ifnull:
|
case ifnull:
|
||||||
methodOutput.append( "ref.is_null" );
|
op = "ref.is_null";
|
||||||
return;
|
break;
|
||||||
case ref_ne:
|
case ref_ne:
|
||||||
methodOutput.append( "ref.eq" );
|
op = options.useGC() ? "ref.eq" : null;
|
||||||
writeNumericOperator( NumericOperator.eqz, ValueType.i32 );
|
negate = true;
|
||||||
return;
|
break;
|
||||||
case ref_eq:
|
case ref_eq:
|
||||||
methodOutput.append( "ref.eq" );
|
op = options.useGC() ? "ref.eq" : null;
|
||||||
return;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
methodOutput.append( valueType ).append( '.' ).append( op );
|
if( op != null ) {
|
||||||
|
newline( methodOutput );
|
||||||
|
methodOutput.append( op );
|
||||||
|
} else {
|
||||||
|
writeFunctionCall( options.ref_eq );
|
||||||
|
}
|
||||||
|
if( negate ) {
|
||||||
|
writeNumericOperator( NumericOperator.eqz, ValueType.i32 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,7 @@ package de.inetsoftware.jwebassembly.wasm;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import de.inetsoftware.jwebassembly.JWebAssembly;
|
import de.inetsoftware.jwebassembly.JWebAssembly;
|
||||||
|
import de.inetsoftware.jwebassembly.module.FunctionName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The option/properties for the behavior of the compiler.
|
* The option/properties for the behavior of the compiler.
|
||||||
@ -30,6 +31,11 @@ public class WasmOptions {
|
|||||||
|
|
||||||
private final boolean useGC;
|
private final boolean useGC;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NonGC function for ref_eq polyfill.
|
||||||
|
*/
|
||||||
|
public FunctionName ref_eq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of options
|
* Create a new instance of options
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user