Bug 1631228 - wasm ion simd, part 1: enablement + test directives. r=bbouvier,perftest-reviewers
authorLars T Hansen <lhansen@mozilla.com>
Wed, 20 May 2020 07:01:38 +0000
changeset 530961 ae9d7bc02ca4e966bfab2a6a5624c4a74519df13
parent 530960 53f7064dc0dee9dc33d26364fed4866fbe21c621
child 530962 9aacd7b8b25246a69c2adbe855b630fe3d21bdbd
push id37435
push userapavel@mozilla.com
push dateWed, 20 May 2020 15:28:23 +0000
treeherdermozilla-central@5415da14ec9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier, perftest-reviewers
bugs1631228
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1631228 - wasm ion simd, part 1: enablement + test directives. r=bbouvier,perftest-reviewers Change --wasm-simd to --no-wasm-simd and flip the default for both this switch and for the about:config flag. Add testing directives so that we test baseline, ion, and --no-wasm-simd. Differential Revision: https://phabricator.services.mozilla.com/D71819
js/moz.configure
js/src/jit-test/tests/wasm/simd/directives.txt
js/src/jit-test/tests/wasm/simd/spec/directives.txt
js/src/jit/LIR.h
js/src/shell/js.cpp
js/src/wasm/WasmJS.cpp
modules/libpref/init/all.js
testing/raptor/raptor/tests/benchmarks/raptor-wasm-godot-cranelift.ini
testing/raptor/raptor/tests/benchmarks/raptor-wasm-misc-cranelift.ini
--- a/js/moz.configure
+++ b/js/moz.configure
@@ -640,10 +640,21 @@ def default_wasm_simd(jit_enabled, simul
     # Good grief.
     if milestone.is_nightly and target.cpu == 'x86_64':
         return True
 
 js_option('--enable-wasm-simd',
           default=default_wasm_simd,
           help='{Enable|Disable} WebAssembly SIMD')
 
-set_config('ENABLE_WASM_SIMD', depends_if('--enable-wasm-simd')(lambda x: True))
-set_define('ENABLE_WASM_SIMD', depends_if('--enable-wasm-simd')(lambda x: True))
+@depends('--enable-wasm-simd', '--enable-jit', '--enable-simulator', target)
+def wasm_simd(value, jit_enabled, simulator, target):
+    if not value:
+        return
+
+    if jit_enabled and not simulator:
+        if target.cpu == 'x86_64':
+            return True
+
+    die('--enable-wasm-simd only possible when targeting the x86_64 jit')
+
+set_config('ENABLE_WASM_SIMD', wasm_simd)
+set_define('ENABLE_WASM_SIMD', wasm_simd)
--- a/js/src/jit-test/tests/wasm/simd/directives.txt
+++ b/js/src/jit-test/tests/wasm/simd/directives.txt
@@ -1,1 +1,1 @@
-// |jit-test| test-also=--wasm-simd; test-also=--wasm-compiler=baseline; test-also=--wasm-compiler=ion; skip-if: !wasmSimdSupported(); include:wasm.js
+|jit-test| test-also=--no-wasm-simd; test-also=--wasm-compiler=baseline; test-also=--wasm-compiler=ion; skip-if: !wasmSimdSupported(); include:wasm.js
--- a/js/src/jit-test/tests/wasm/simd/spec/directives.txt
+++ b/js/src/jit-test/tests/wasm/simd/spec/directives.txt
@@ -1,1 +1,1 @@
-|jit-test| test-also=--wasm-simd; skip-if: !wasmSimdSupported()
+|jit-test| test-also=--wasm-compiler=baseline; test-also=--wasm-compiler=ion; test-also=--no-wasm-simd; skip-if: !wasmSimdSupported()
--- a/js/src/jit/LIR.h
+++ b/js/src/jit/LIR.h
@@ -501,17 +501,17 @@ class LDefinition {
 #endif
   };
 
   void set(uint32_t index, Type type, Policy policy) {
     static_assert(MAX_VIRTUAL_REGISTERS <= VREG_MASK);
     bits_ =
         (index << VREG_SHIFT) | (policy << POLICY_SHIFT) | (type << TYPE_SHIFT);
 #ifndef ENABLE_WASM_SIMD
-    MOZ_ASSERT(type() != SIMD128);
+    MOZ_ASSERT(this->type() != SIMD128);
 #endif
   }
 
  public:
   LDefinition(uint32_t index, Type type, Policy policy = REGISTER) {
     set(index, type, policy);
   }
 
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -493,17 +493,17 @@ bool shell::enableWasmCranelift = false;
 bool shell::enableWasmReftypes = true;
 #ifdef ENABLE_WASM_GC
 bool shell::enableWasmGc = false;
 #endif
 #ifdef ENABLE_WASM_MULTI_VALUE
 bool shell::enableWasmMultiValue = true;
 #endif
 #ifdef ENABLE_WASM_SIMD
-bool shell::enableWasmSimd = false;
+bool shell::enableWasmSimd = true;
 #endif
 bool shell::enableWasmVerbose = false;
 bool shell::enableTestWasmAwaitTier2 = false;
 bool shell::enableSourcePragmas = true;
 bool shell::enableAsyncStacks = false;
 bool shell::enableStreams = false;
 bool shell::enableReadableByteStreams = false;
 bool shell::enableBYOBStreamReaders = false;
@@ -10238,17 +10238,17 @@ static bool SetContextOptions(JSContext*
   enableWasmReftypes = !op.getBoolOption("no-wasm-reftypes");
 #ifdef ENABLE_WASM_GC
   enableWasmGc = op.getBoolOption("wasm-gc");
 #endif
 #ifdef ENABLE_WASM_MULTI_VALUE
   enableWasmMultiValue = !op.getBoolOption("no-wasm-multi-value");
 #endif
 #ifdef ENABLE_WASM_SIMD
-  enableWasmSimd = op.getBoolOption("wasm-simd");
+  enableWasmSimd = !op.getBoolOption("no-wasm-simd");
 #endif
   enableWasmVerbose = op.getBoolOption("wasm-verbose");
   enableTestWasmAwaitTier2 = op.getBoolOption("test-wasm-await-tier2");
   enableSourcePragmas = !op.getBoolOption("no-source-pragmas");
   enableAsyncStacks = !op.getBoolOption("no-async-stacks");
   enableStreams = !op.getBoolOption("no-streams");
   enableReadableByteStreams = op.getBoolOption("enable-readable-byte-streams");
   enableBYOBStreamReaders = op.getBoolOption("enable-byob-stream-readers");
@@ -11082,20 +11082,20 @@ int main(int argc, char** argv, char** e
 #endif
 #ifdef ENABLE_WASM_MULTI_VALUE
       !op.addBoolOption('\0', "no-wasm-multi-value",
                         "Disable wasm multi-value features") ||
 #else
       !op.addBoolOption('\0', "no-wasm-multi-value", "No-op") ||
 #endif
 #ifdef ENABLE_WASM_SIMD
-      !op.addBoolOption('\0', "wasm-simd",
-                        "Enable experimental wasm SIMD features") ||
+      !op.addBoolOption('\0', "no-wasm-simd",
+                        "Disable experimental wasm SIMD features") ||
 #else
-      !op.addBoolOption('\0', "wasm-simd", "No-op") ||
+      !op.addBoolOption('\0', "no-wasm-simd", "No-op") ||
 #endif
       !op.addBoolOption('\0', "no-native-regexp",
                         "Disable native regexp compilation") ||
 #ifdef ENABLE_NEW_REGEXP
       !op.addIntOption(
           '\0', "regexp-warmup-threshold", "COUNT",
           "Wait for COUNT invocations before compiling regexps to native code "
           "(default 10)",
--- a/js/src/wasm/WasmJS.cpp
+++ b/js/src/wasm/WasmJS.cpp
@@ -127,33 +127,29 @@ static inline bool Append(JSStringBuilde
     return false;
   }
   *sep = ',';
   return true;
 }
 
 bool wasm::IonDisabledByFeatures(JSContext* cx, bool* isDisabled,
                                  JSStringBuilder* reason) {
-  // Ion has no debugging support, no gc support, no simd support.
+  // Ion has no debugging support, no gc support.
   bool debug = cx->realm() && cx->realm()->debuggerObservesAsmJS();
   bool gc = cx->options().wasmGc();
-  bool simd = WasmSimdFlag(cx);
   if (reason) {
     char sep = 0;
     if (debug && !Append(reason, "debug", &sep)) {
       return false;
     }
     if (gc && !Append(reason, "gc", &sep)) {
       return false;
     }
-    if (simd && !Append(reason, "simd", &sep)) {
-      return false;
-    }
-  }
-  *isDisabled = debug || gc || simd;
+  }
+  *isDisabled = debug || gc;
   return true;
 }
 
 bool wasm::CraneliftAvailable(JSContext* cx) {
   if (!cx->options().wasmCranelift() || !CraneliftPlatformSupport()) {
     return false;
   }
   bool isDisabled = false;
@@ -227,18 +223,18 @@ bool wasm::GcTypesAvailable(JSContext* c
 }
 
 bool wasm::MultiValuesAvailable(JSContext* cx) {
   // Cranelift does not support multi-value.
   return WasmMultiValueFlag(cx) && (BaselineAvailable(cx) || IonAvailable(cx));
 }
 
 bool wasm::SimdAvailable(JSContext* cx) {
-  // Cranelift and Ion do not support SIMD.
-  return WasmSimdFlag(cx) && BaselineAvailable(cx);
+  // Cranelift does not support SIMD.
+  return WasmSimdFlag(cx) && (BaselineAvailable(cx) || IonAvailable(cx));
 }
 
 bool wasm::ThreadsAvailable(JSContext* cx) {
   // Cranelift does not support atomics.
   return cx->realm() &&
          cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled() &&
          (BaselineAvailable(cx) || IonAvailable(cx));
 }
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1124,17 +1124,17 @@ pref("javascript.options.wasm_reftypes",
 #endif
 #ifdef ENABLE_WASM_REFTYPES
   pref("javascript.options.wasm_gc",              false);
 #endif
 #ifdef ENABLE_WASM_MULTI_VALUE
   pref("javascript.options.wasm_multi_value",     true);
 #endif
 #ifdef ENABLE_WASM_SIMD
-  pref("javascript.options.wasm_simd",            false);
+  pref("javascript.options.wasm_simd",            true);
 #endif
 pref("javascript.options.native_regexp",    true);
 pref("javascript.options.parallel_parsing", true);
 pref("javascript.options.source_pragmas",    true);
 // Async stacks instrumentation adds overhead that is only
 // advisable for developers, so we limit it to Nightly and DevEdition
 #if defined(ANDROID) || defined(XP_IOS)
   pref("javascript.options.asyncstack",       false);
--- a/testing/raptor/raptor/tests/benchmarks/raptor-wasm-godot-cranelift.ini
+++ b/testing/raptor/raptor/tests/benchmarks/raptor-wasm-godot-cranelift.ini
@@ -18,9 +18,10 @@ gecko_profile_entries = 8000000
 
 [raptor-wasm-godot-cranelift-firefox]
 apps = firefox
 preferences = {"javascript.options.wasm_baselinejit": false,
                "javascript.options.wasm_ionjit": false,
                "javascript.options.shared_memory": false,
                "javascript.options.wasm_multi_value": false,
                "javascript.options.wasm_reftypes": false,
+               "javascript.options.wasm_simd": false,
                "javascript.options.wasm_cranelift": true}
--- a/testing/raptor/raptor/tests/benchmarks/raptor-wasm-misc-cranelift.ini
+++ b/testing/raptor/raptor/tests/benchmarks/raptor-wasm-misc-cranelift.ini
@@ -16,9 +16,10 @@ fetch_task = wasm-misc
 
 [raptor-wasm-misc-cranelift-firefox]
 apps = firefox
 preferences = {"javascript.options.wasm_baselinejit": false,
                "javascript.options.wasm_ionjit": false,
                "javascript.options.shared_memory": false,
                "javascript.options.wasm_multi_value": false,
                "javascript.options.wasm_reftypes": false,
+               "javascript.options.wasm_simd": false,
                "javascript.options.wasm_cranelift": true}