mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 18:44:47 +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 );
|
||||
instructions.add( numeric );
|
||||
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;
|
||||
}
|
||||
|
@ -515,8 +515,8 @@ public class TextModuleWriter extends ModuleWriter {
|
||||
*/
|
||||
@Override
|
||||
protected void writeNumericOperator( NumericOperator numOp, @Nullable ValueType valueType ) throws IOException {
|
||||
newline( methodOutput );
|
||||
String op = numOp.toString();
|
||||
boolean negate = false;
|
||||
String op = valueType.toString() + '.' + numOp.toString();
|
||||
switch( valueType ) {
|
||||
case i32:
|
||||
case i64:
|
||||
@ -530,25 +530,33 @@ public class TextModuleWriter extends ModuleWriter {
|
||||
op += "_s";
|
||||
break;
|
||||
case ifnonnull:
|
||||
methodOutput.append( "ref.is_null" );
|
||||
writeNumericOperator( NumericOperator.eqz, ValueType.i32 );
|
||||
return;
|
||||
op = "ref.is_null";
|
||||
negate = true;
|
||||
break;
|
||||
case ifnull:
|
||||
methodOutput.append( "ref.is_null" );
|
||||
return;
|
||||
op = "ref.is_null";
|
||||
break;
|
||||
case ref_ne:
|
||||
methodOutput.append( "ref.eq" );
|
||||
writeNumericOperator( NumericOperator.eqz, ValueType.i32 );
|
||||
return;
|
||||
op = options.useGC() ? "ref.eq" : null;
|
||||
negate = true;
|
||||
break;
|
||||
case ref_eq:
|
||||
methodOutput.append( "ref.eq" );
|
||||
return;
|
||||
op = options.useGC() ? "ref.eq" : null;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
break;
|
||||
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 de.inetsoftware.jwebassembly.JWebAssembly;
|
||||
import de.inetsoftware.jwebassembly.module.FunctionName;
|
||||
|
||||
/**
|
||||
* The option/properties for the behavior of the compiler.
|
||||
@ -30,6 +31,11 @@ public class WasmOptions {
|
||||
|
||||
private final boolean useGC;
|
||||
|
||||
/**
|
||||
* NonGC function for ref_eq polyfill.
|
||||
*/
|
||||
public FunctionName ref_eq;
|
||||
|
||||
/**
|
||||
* Create a new instance of options
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user