mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
use experimental Sign-extension operators
This commit is contained in:
parent
ec10240c52
commit
a27733234f
@ -654,6 +654,12 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
case d2f:
|
||||
op = F32_DEMOTE_F64;
|
||||
break;
|
||||
case i2b:
|
||||
op = I32_EXTEND8_S;
|
||||
break;
|
||||
case i2s:
|
||||
op = I32_EXTEND16_S;
|
||||
break;
|
||||
default:
|
||||
throw new Error( "Unknown cast: " + cast );
|
||||
}
|
||||
|
@ -335,7 +335,19 @@ interface InstructionOpcodes {
|
||||
|
||||
static final int F64_PROMOTE_F32 = 0xBB;
|
||||
|
||||
// === numerical operations ======
|
||||
// === Sign-extension operators ====== https://github.com/WebAssembly/design/issues/1178
|
||||
|
||||
static final int I32_EXTEND8_S = 0xC0;
|
||||
|
||||
static final int I32_EXTEND16_S = 0xC1;
|
||||
|
||||
static final int I64_EXTEND8_S = 0xC2;
|
||||
|
||||
static final int I64_EXTEND16_S = 0xC3;
|
||||
|
||||
static final int I64_EXTEND32_S = 0xC4;
|
||||
|
||||
// === ref values ====== https://github.com/WebAssembly/design/issues/1203
|
||||
|
||||
static final int REF_NULL = 0xD0;
|
||||
|
||||
|
@ -603,20 +603,14 @@ public class ModuleGenerator {
|
||||
instr = new WasmConvertInstruction( ValueTypeConvertion.d2f, codePos );
|
||||
break;
|
||||
case 145: // i2b
|
||||
instructions.add( new WasmConstInstruction( 24, codePos ) );
|
||||
instructions.add( new WasmNumericInstruction( NumericOperator.shl, ValueType.i32, codePos ) );
|
||||
instructions.add( new WasmConstInstruction( 24, codePos ) );
|
||||
instr = new WasmNumericInstruction( NumericOperator.shr_s, ValueType.i32, codePos );
|
||||
instr = new WasmConvertInstruction( ValueTypeConvertion.i2b, codePos );
|
||||
break;
|
||||
case 146: // i2c
|
||||
instructions.add( new WasmConstInstruction( 0xFFFF, codePos ) );
|
||||
instr = new WasmNumericInstruction( NumericOperator.and, ValueType.i32, codePos );
|
||||
break;
|
||||
case 147: // i2s
|
||||
instructions.add( new WasmConstInstruction( 16, codePos ) );
|
||||
instructions.add( new WasmNumericInstruction( NumericOperator.shl, ValueType.i32, codePos ) );
|
||||
instructions.add( new WasmConstInstruction( 16, codePos ) );
|
||||
instr = new WasmNumericInstruction( NumericOperator.shr_s, ValueType.i32, codePos );
|
||||
instr = new WasmConvertInstruction( ValueTypeConvertion.i2s, codePos );
|
||||
break;
|
||||
case 148: // lcmp
|
||||
opCompare( ValueType.i64, byteCode, codePos );
|
||||
|
@ -15,8 +15,6 @@
|
||||
*/
|
||||
package de.inetsoftware.jwebassembly.module;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Cast operations for converting one data type to another
|
||||
*
|
||||
@ -36,4 +34,7 @@ public enum ValueTypeConvertion {
|
||||
d2i,
|
||||
d2l,
|
||||
d2f,
|
||||
i2b,
|
||||
i2c,
|
||||
i2s,
|
||||
}
|
@ -232,6 +232,12 @@ public class TextModuleWriter extends ModuleWriter {
|
||||
case d2f:
|
||||
op = "f32.demote/f64";
|
||||
break;
|
||||
case i2b:
|
||||
op = "i32.extend8_s";
|
||||
break;
|
||||
case i2s:
|
||||
op = "i32.extend16_s";
|
||||
break;
|
||||
default:
|
||||
throw new Error( "Unknown cast: " + cast );
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ public class WasmRule extends TemporaryFolder {
|
||||
private ProcessBuilder nodeJsCommand() {
|
||||
String command = System.getProperty( "node.dir" );
|
||||
command = command == null ? "node" : command + "/node";
|
||||
return new ProcessBuilder( command, nodeScript.getAbsolutePath() );
|
||||
return new ProcessBuilder( command, "--experimental-wasm-se", nodeScript.getAbsolutePath() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user