Bug 1469027: Add a --wasm-force-cranelift flag to the shell; r=luke
authorBenjamin Bouvier <benj@benj.me>
Fri, 07 Sep 2018 13:42:16 +0200
changeset 435485 9347f5a5365daceb7330b32735107adfde7fa017
parent 435484 7417cc0ef0f7aa459680ba8fdf3ed1baccdde391
child 435486 b7954f9562599fa21aab3ec05d89b0b13802e284
push id34613
push userapavel@mozilla.com
push dateMon, 10 Sep 2018 21:53:50 +0000
treeherdermozilla-central@b0bf04a1cbbf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1469027
milestone64.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 1469027: Add a --wasm-force-cranelift flag to the shell; r=luke
js/moz.configure
js/src/builtin/TestingFunctions.cpp
js/src/jsapi.h
js/src/shell/js.cpp
--- a/js/moz.configure
+++ b/js/moz.configure
@@ -486,10 +486,10 @@ set_config('JS_BUILD_BINAST', enable_bui
 js_option('--enable-cranelift',
           help='Enable Cranelift code generator for wasm')
 
 @depends('--enable-cranelift')
 def enable_cranelift(value):
     if value:
         return True
 
-set_config('MOZ_WASM_CRANELIFT', enable_cranelift)
-set_define('MOZ_WASM_CRANELIFT', enable_cranelift)
+set_config('ENABLE_WASM_CRANELIFT', enable_cranelift)
+set_define('ENABLE_WASM_CRANELIFT', enable_cranelift)
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -595,16 +595,20 @@ WasmDebuggingIsSupported(JSContext* cx, 
 }
 
 static bool
 WasmThreadsSupported(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 #ifdef ENABLE_WASM_THREAD_OPS
     bool isSupported = wasm::HasSupport(cx);
+# ifdef ENABLE_WASM_CRANELIFT
+    if (cx->options().wasmForceCranelift())
+        isSupported = false;
+# endif
 #else
     bool isSupported = false;
 #endif
     args.rval().setBoolean(isSupported);
     return true;
 }
 
 static bool
@@ -621,29 +625,37 @@ WasmSaturatingTruncationSupported(JSCont
 }
 
 static bool
 WasmBulkMemSupported(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 #ifdef ENABLE_WASM_BULKMEM_OPS
     bool isSupported = true;
+# ifdef ENABLE_WASM_CRANELIFT
+    if (cx->options().wasmForceCranelift())
+        isSupported = false;
+# endif
 #else
     bool isSupported = false;
 #endif
     args.rval().setBoolean(isSupported);
     return true;
 }
 
 static bool
 WasmGcEnabled(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 #ifdef ENABLE_WASM_GC
     bool isSupported = cx->options().wasmBaseline() && cx->options().wasmGc();
+# ifdef ENABLE_WASM_CRANELIFT
+    if (cx->options().wasmForceCranelift())
+        isSupported = false;
+# endif
 #else
     bool isSupported = false;
 #endif
     args.rval().setBoolean(isSupported);
     return true;
 }
 
 static bool
@@ -5842,17 +5854,17 @@ gc::ZealModeHelpText),
 "  Get the caller's global (or null). See JS::GetScriptedCallerGlobal.\n"),
 
     JS_FN_HELP("objectGlobal", ObjectGlobal, 1, 0,
 "objectGlobal(obj)",
 "  Returns the object's global object or null if the object is a wrapper.\n"),
 
     JS_FN_HELP("assertCorrectRealm", AssertCorrectRealm, 0, 0,
 "assertCorrectRealm()",
-"  Asserts cx->realm matches callee->raelm.\n"),
+"  Asserts cx->realm matches callee->realm.\n"),
 
     JS_FN_HELP("baselineCompile", BaselineCompile, 2, 0,
 "baselineCompile([fun/code], forceDebugInstrumentation=false)",
 "  Baseline-compiles the given JS function or script.\n"
 "  Without arguments, baseline-compiles the caller's script; but note\n"
 "  that extra boilerplate is needed afterwards to cause the VM to start\n"
 "  running the jitcode rather than staying in the interpreter:\n"
 "    baselineCompile();  for (var i=0; i<1; i++) {} ...\n"
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -483,16 +483,19 @@ class JS_PUBLIC_API(ContextOptions) {
   public:
     ContextOptions()
       : baseline_(true),
         ion_(true),
         asmJS_(true),
         wasm_(true),
         wasmBaseline_(true),
         wasmIon_(true),
+#ifdef ENABLE_WASM_CRANELIFT
+        wasmForceCranelift_(false),
+#endif
 #ifdef ENABLE_WASM_GC
         wasmGc_(false),
 #endif
         testWasmAwaitTier2_(false),
         throwOnAsmJSValidationFailure_(false),
         nativeRegExp_(true),
         asyncStack_(true),
         throwOnDebuggeeWouldRun_(true),
@@ -572,16 +575,28 @@ class JS_PUBLIC_API(ContextOptions) {
         wasmIon_ = flag;
         return *this;
     }
     ContextOptions& toggleWasmIon() {
         wasmIon_ = !wasmIon_;
         return *this;
     }
 
+#ifdef ENABLE_WASM_CRANELIFT
+    bool wasmForceCranelift() const { return wasmForceCranelift_; }
+    ContextOptions& setWasmForceCranelift(bool flag) {
+        wasmForceCranelift_ = flag;
+        return *this;
+    }
+    ContextOptions& toggleWasmForceCranelift() {
+        wasmForceCranelift_ = !wasmForceCranelift_;
+        return *this;
+    }
+#endif
+
     bool testWasmAwaitTier2() const { return testWasmAwaitTier2_; }
     ContextOptions& setTestWasmAwaitTier2(bool flag) {
         testWasmAwaitTier2_ = flag;
         return *this;
     }
     ContextOptions& toggleTestWasmAwaitTier2() {
         testWasmAwaitTier2_ = !testWasmAwaitTier2_;
         return *this;
@@ -682,16 +697,19 @@ class JS_PUBLIC_API(ContextOptions) {
 
   private:
     bool baseline_ : 1;
     bool ion_ : 1;
     bool asmJS_ : 1;
     bool wasm_ : 1;
     bool wasmBaseline_ : 1;
     bool wasmIon_ : 1;
+#ifdef ENABLE_WASM_CRANELIFT
+    bool wasmForceCranelift_ : 1;
+#endif
 #ifdef ENABLE_WASM_GC
     bool wasmGc_ : 1;
 #endif
     bool testWasmAwaitTier2_ : 1;
     bool throwOnAsmJSValidationFailure_ : 1;
     bool nativeRegExp_ : 1;
     bool asyncStack_ : 1;
     bool throwOnDebuggeeWouldRun_ : 1;
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -505,16 +505,19 @@ static bool offthreadCompilation = false
 static bool enableBaseline = false;
 static bool enableIon = false;
 static bool enableAsmJS = false;
 static bool enableWasm = false;
 static bool enableNativeRegExp = false;
 static bool enableSharedMemory = SHARED_MEMORY_DEFAULT;
 static bool enableWasmBaseline = false;
 static bool enableWasmIon = false;
+#ifdef ENABLE_WASM_CRANELIFT
+static bool wasmForceCranelift = false;
+#endif
 #ifdef ENABLE_WASM_GC
 static bool enableWasmGc = false;
 #endif
 static bool enableTestWasmAwaitTier2 = false;
 static bool enableAsyncStacks = false;
 static bool enableStreams = false;
 #ifdef JS_GC_ZEAL
 static uint32_t gZealBits = 0;
@@ -9134,29 +9137,38 @@ SetContextOptions(JSContext* cx, const O
 {
     enableBaseline = !op.getBoolOption("no-baseline");
     enableIon = !op.getBoolOption("no-ion");
     enableAsmJS = !op.getBoolOption("no-asmjs");
     enableWasm = !op.getBoolOption("no-wasm");
     enableNativeRegExp = !op.getBoolOption("no-native-regexp");
     enableWasmBaseline = !op.getBoolOption("no-wasm-baseline");
     enableWasmIon = !op.getBoolOption("no-wasm-ion");
+#ifdef ENABLE_WASM_CRANELIFT
+    wasmForceCranelift = op.getBoolOption("wasm-force-cranelift");
+#endif
 #ifdef ENABLE_WASM_GC
     enableWasmGc = op.getBoolOption("wasm-gc");
+# ifdef ENABLE_WASM_CRANELIFT
+    enableWasmGc = false;
+# endif
 #endif
     enableTestWasmAwaitTier2 = op.getBoolOption("test-wasm-await-tier2");
     enableAsyncStacks = !op.getBoolOption("no-async-stacks");
     enableStreams = op.getBoolOption("enable-streams");
 
     JS::ContextOptionsRef(cx).setBaseline(enableBaseline)
                              .setIon(enableIon)
                              .setAsmJS(enableAsmJS)
                              .setWasm(enableWasm)
                              .setWasmBaseline(enableWasmBaseline)
                              .setWasmIon(enableWasmIon)
+#ifdef ENABLE_WASM_CRANELIFT
+                             .setWasmForceCranelift(wasmForceCranelift)
+#endif
 #ifdef ENABLE_WASM_GC
                              .setWasmGc(enableWasmGc)
 #endif
                              .setTestWasmAwaitTier2(enableTestWasmAwaitTier2)
                              .setNativeRegExp(enableNativeRegExp)
                              .setAsyncStack(enableAsyncStacks)
                              .setStreams(enableStreams);
 
@@ -9440,16 +9452,19 @@ SetWorkerContextOptions(JSContext* cx)
 {
     // Copy option values from the main thread.
     JS::ContextOptionsRef(cx).setBaseline(enableBaseline)
                              .setIon(enableIon)
                              .setAsmJS(enableAsmJS)
                              .setWasm(enableWasm)
                              .setWasmBaseline(enableWasmBaseline)
                              .setWasmIon(enableWasmIon)
+#ifdef ENABLE_WASM_CRANELIFT
+                             .setWasmForceCranelift(wasmForceCranelift)
+#endif
 #ifdef ENABLE_WASM_GC
                              .setWasmGc(enableWasmGc)
 #endif
                              .setTestWasmAwaitTier2(enableTestWasmAwaitTier2)
                              .setNativeRegExp(enableNativeRegExp)
                              .setStreams(enableStreams);
 
     cx->runtime()->setOffthreadIonCompilationEnabled(offthreadCompilation);
@@ -9690,16 +9705,19 @@ main(int argc, char** argv, char** envp)
                             -1)
         || !op.addIntOption('\0', "thread-count", "COUNT", "Alias for --cpu-count.", -1)
         || !op.addBoolOption('\0', "ion", "Enable IonMonkey (default)")
         || !op.addBoolOption('\0', "no-ion", "Disable IonMonkey")
         || !op.addBoolOption('\0', "no-asmjs", "Disable asm.js compilation")
         || !op.addBoolOption('\0', "no-wasm", "Disable WebAssembly compilation")
         || !op.addBoolOption('\0', "no-wasm-baseline", "Disable wasm baseline compiler")
         || !op.addBoolOption('\0', "no-wasm-ion", "Disable wasm ion compiler")
+#ifdef ENABLE_WASM_CRANELIFT
+        || !op.addBoolOption('\0', "wasm-force-cranelift", "Enable wasm Cranelift compiler")
+#endif
         || !op.addBoolOption('\0', "test-wasm-await-tier2", "Forcibly activate tiering and block "
                                    "instantiation on completion of tier2")
 #ifdef ENABLE_WASM_GC
         || !op.addBoolOption('\0', "wasm-gc", "Enable wasm GC features")
 #else
         || !op.addBoolOption('\0', "wasm-gc", "No-op")
 #endif
         || !op.addBoolOption('\0', "no-native-regexp", "Disable native regexp compilation")