From 9bbc82bb6dfd93da2f2aca2440a34c4cf18b97f9 Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Sat, 4 Apr 2020 11:40:35 +0200 Subject: [PATCH] Remove all special handling for SpiderMonkey. It is compatible now. --- .../binary/BinaryModuleWriter.java | 8 --- .../jwebassembly/text/TextModuleWriter.java | 7 +-- .../inetsoftware/jwebassembly/WasmRule.java | 62 +++++++++---------- 3 files changed, 30 insertions(+), 47 deletions(-) diff --git a/src/de/inetsoftware/jwebassembly/binary/BinaryModuleWriter.java b/src/de/inetsoftware/jwebassembly/binary/BinaryModuleWriter.java index bd76487..28882bc 100644 --- a/src/de/inetsoftware/jwebassembly/binary/BinaryModuleWriter.java +++ b/src/de/inetsoftware/jwebassembly/binary/BinaryModuleWriter.java @@ -119,14 +119,6 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod wasm.write( WASM_BINARY_MAGIC ); wasm.writeInt32( WASM_BINARY_VERSION ); - if( options.useGC() && Boolean.getBoolean( "SpiderMonkey" ) ) { - // Section 42, enable GcFeatureOptIn for SpiderMonkey https://github.com/lars-t-hansen/moz-gc-experiments/blob/master/version2.md - wasm.writeVaruint32( 42 ); - wasm.writeVaruint32( 1 ); - wasm.write( 3 ); // version of GcFeatureOptIn - // End Section 42 - } - writeSection( SectionType.Type, functionTypes ); writeSection( SectionType.Import, imports.values() ); writeSection( SectionType.Function, functions.values() ); diff --git a/src/de/inetsoftware/jwebassembly/text/TextModuleWriter.java b/src/de/inetsoftware/jwebassembly/text/TextModuleWriter.java index 40ecd4a..e54576f 100644 --- a/src/de/inetsoftware/jwebassembly/text/TextModuleWriter.java +++ b/src/de/inetsoftware/jwebassembly/text/TextModuleWriter.java @@ -54,8 +54,6 @@ import de.inetsoftware.jwebassembly.wasm.WasmBlockOperator; */ public class TextModuleWriter extends ModuleWriter { - private final boolean spiderMonkey = Boolean.getBoolean( "SpiderMonkey" ); - private final WasmTarget target; private final StringBuilder output = new StringBuilder(); @@ -109,9 +107,6 @@ public class TextModuleWriter extends ModuleWriter { public void close() throws IOException { Appendable textOutput = target.getTextOutput(); textOutput.append( "(module" ); - if( spiderMonkey && options.useGC() ) { - textOutput.append( " (gc_feature_opt_in 3)" ); // enable GcFeatureOptIn for SpiderMonkey https://github.com/lars-t-hansen/moz-gc-experiments/blob/master/version2.md - } for( int i = 0; i < types.size(); i++ ) { newline( textOutput ); @@ -318,7 +313,7 @@ public class TextModuleWriter extends ModuleWriter { if( type instanceof ValueType ) { output.append( type.toString() ); } else if( options.useGC() ) { - output.append( "(ref " ).append( normalizeName( type.toString() ) ).append( ')' ); + output.append( "(optref " ).append( normalizeName( type.toString() ) ).append( ')' ); } else { output.append( ValueType.anyref.toString() ); } diff --git a/test/de/inetsoftware/jwebassembly/WasmRule.java b/test/de/inetsoftware/jwebassembly/WasmRule.java index 67c854f..dc9c2ff 100644 --- a/test/de/inetsoftware/jwebassembly/WasmRule.java +++ b/test/de/inetsoftware/jwebassembly/WasmRule.java @@ -535,44 +535,40 @@ public class WasmRule extends TemporaryFolder { */ private ProcessBuilder spiderMonkeyCommand( boolean binary, boolean gc ) throws IOException { File script; - try { - System.setProperty( "SpiderMonkey", "true" ); - if( gc ) { - if( binary ) { - if( spiderMonkeyScriptGC == null ) { - File file = newFile( "spiderMonkeyGC.wasm" ); - compiler.compileToBinary( file ); - spiderMonkeyScriptGC = createScript( "SpiderMonkeyTest.js", "{test.wasm}", file.getName() ); - } - script = spiderMonkeyScriptGC; - } else { - if( spiderMonkeyScriptWatGC == null ) { - File file = newFile( "spiderMonkeyGC.wat" ); - compiler.compileToText( file ); - spiderMonkeyScriptWatGC = createScript( "SpiderMonkeyWatTest.js", "{test}", "spiderMonkeyGC" ); - } - script = spiderMonkeyScriptWatGC; + if( gc ) { + if( binary ) { + if( spiderMonkeyScriptGC == null ) { + File file = newFile( "spiderMonkeyGC.wasm" ); + compiler.compileToBinary( file ); + spiderMonkeyScriptGC = createScript( "SpiderMonkeyTest.js", "{test.wasm}", file.getName() ); } + script = spiderMonkeyScriptGC; } else { - if( binary ) { - if( spiderMonkeyScript == null ) { - File file = newFile( "spiderMonkey.wasm" ); - compiler.compileToBinary( file ); - spiderMonkeyScript = createScript( "SpiderMonkeyTest.js", "{test.wasm}", file.getName() ); - } - script = spiderMonkeyScript; - } else { - if( spiderMonkeyWatScript == null ) { - File file = newFile( "spiderMonkey.wat" ); - compiler.compileToText( file ); - spiderMonkeyWatScript = createScript( "SpiderMonkeyWatTest.js", "{test}", "spiderMonkey" ); - } - script = spiderMonkeyWatScript; + if( spiderMonkeyScriptWatGC == null ) { + File file = newFile( "spiderMonkeyGC.wat" ); + compiler.compileToText( file ); + spiderMonkeyScriptWatGC = createScript( "SpiderMonkeyWatTest.js", "{test}", "spiderMonkeyGC" ); } + script = spiderMonkeyScriptWatGC; + } + } else { + if( binary ) { + if( spiderMonkeyScript == null ) { + File file = newFile( "spiderMonkey.wasm" ); + compiler.compileToBinary( file ); + spiderMonkeyScript = createScript( "SpiderMonkeyTest.js", "{test.wasm}", file.getName() ); + } + script = spiderMonkeyScript; + } else { + if( spiderMonkeyWatScript == null ) { + File file = newFile( "spiderMonkey.wat" ); + compiler.compileToText( file ); + spiderMonkeyWatScript = createScript( "SpiderMonkeyWatTest.js", "{test}", "spiderMonkey" ); + } + script = spiderMonkeyWatScript; } - } finally { - System.clearProperty( "SpiderMonkey" ); } + ProcessBuilder process = new ProcessBuilder( spiderMonkey.getCommand(), script.getAbsolutePath() ); if( gc ) { process.command().add( 1, "--wasm-gc" );