Bug 1299359 - Odin: split out separate JitOptions.asmJSAtomicsEnable (rs=lth)
authorLuke Wagner <luke@mozilla.com>
Fri, 16 Sep 2016 10:06:17 -0500
changeset 342810 98d2d447a7a1b5ebfd777cea34e20c8ed4778735
parent 342809 fece9aa991e6eeafadc019dee673fbfae0ee46d3
child 342811 0e42b1a442c466a7e1574e3b92c7bbf7e3b07dc5
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-esr52@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1299359
milestone51.0a1
Bug 1299359 - Odin: split out separate JitOptions.asmJSAtomicsEnable (rs=lth) MozReview-Commit-ID: CIzSy3lTcNN
js/src/asmjs/AsmJS.cpp
js/src/jit-test/tests/asm.js/gating.js
js/src/jit-test/tests/asm.js/sta-transition.js
js/src/jit-test/tests/asm.js/testAtomic-effect.js
js/src/jit-test/tests/asm.js/testAtomics.js
js/src/jit-test/tests/asm.js/testBug1155176.js
js/src/jit-test/tests/asm.js/testBug1164391.js
js/src/jit-test/tests/asm.js/testBug1302407.js
js/src/jit/JitOptions.cpp
js/src/jit/JitOptions.h
js/src/jsapi.cpp
js/src/jsapi.h
js/src/vm/SharedArrayObject.cpp
--- a/js/src/asmjs/AsmJS.cpp
+++ b/js/src/asmjs/AsmJS.cpp
@@ -1983,17 +1983,17 @@ class MOZ_STACK_CLASS ModuleValidator
         AsmJSGlobal g(AsmJSGlobal::Constant, Move(fieldChars));
         g.pod.u.constant.value_ = constant;
         g.pod.u.constant.kind_ = AsmJSGlobal::GlobalConstant;
         return asmJSMetadata_->asmJSGlobals.append(Move(g));
     }
     bool addAtomicsBuiltinFunction(PropertyName* var, AsmJSAtomicsBuiltinFunction func,
                                    PropertyName* field)
     {
-        if (!JitOptions.wasmTestMode)
+        if (!JitOptions.asmJSAtomicsEnable)
             return failCurrentOffset("asm.js Atomics only enabled in wasm test mode");
 
         atomicsPresent_ = true;
 
         UniqueChars fieldChars = StringToNewUTF8CharsZ(cx_, *field);
         if (!fieldChars)
             return false;
 
--- a/js/src/jit-test/tests/asm.js/gating.js
+++ b/js/src/jit-test/tests/asm.js/gating.js
@@ -13,17 +13,17 @@
 // values that are not the expected built-in values and the link will
 // fail as desired.
 
 load(libdir + "asm.js");
 
 if (!isAsmJSCompilationAvailable())
     quit(0);
 
-setJitCompilerOption('wasm.test-mode', 1);
+setJitCompilerOption('asmjs.atomics.enable', 1);
 
 if (!this.Atomics) {
     this.Atomics = { load: function (x, y) { return 0 },
 		     store: function (x, y, z) { return 0 },
 		     exchange: function (x, y, z) { return 0 },
 		     add: function (x, y, z) { return 0 },
 		     sub: function (x, y, z) { return 0 },
 		     and: function (x, y, z) { return 0 },
--- a/js/src/jit-test/tests/asm.js/sta-transition.js
+++ b/js/src/jit-test/tests/asm.js/sta-transition.js
@@ -2,17 +2,17 @@
 //
 // These should not be run with --no-asmjs, the guard below checks this.
 
 load(libdir + "asm.js");
 
 if (!this.SharedArrayBuffer || !isAsmJSCompilationAvailable())
     quit(0);
 
-setJitCompilerOption('wasm.test-mode', 1);
+setJitCompilerOption('asmjs.atomics.enable', 1);
 
 //////////////////////////////////////////////////////////////////////
 //
 // Int8Array can be used on SharedArrayBuffer, if atomics are present
 
 var m1 = asmCompile("stdlib", "ffi", "heap", `
     "use asm";
 
--- a/js/src/jit-test/tests/asm.js/testAtomic-effect.js
+++ b/js/src/jit-test/tests/asm.js/testAtomic-effect.js
@@ -1,14 +1,14 @@
 // |jit-test| test-also-noasmjs
 if (!this.Atomics)
     quit();
 
 load(libdir + "asm.js");
-setJitCompilerOption('wasm.test-mode', 1);
+setJitCompilerOption('asmjs.atomics.enable', 1);
 
 var code = `
     "use asm";
 
     var HEAP32 = new stdlib.Int32Array(heap);
     var add = stdlib.Atomics.add;
     var load = stdlib.Atomics.load;
     var _emscripten_asm_const_int=ffi._emscripten_asm_const_int;
--- a/js/src/jit-test/tests/asm.js/testAtomics.js
+++ b/js/src/jit-test/tests/asm.js/testAtomics.js
@@ -4,17 +4,17 @@ if (!this.SharedArrayBuffer || !this.Ato
     quit();
 
 // The code duplication below is very far from elegant but provides
 // flexibility that comes in handy several places.
 
 load(libdir + "asm.js");
 load(libdir + "asserts.js");
 
-setJitCompilerOption('wasm.test-mode', 1);
+setJitCompilerOption('asmjs.atomics.enable', 1);
 
 var loadModule_int32_code =
     USE_ASM + `
     var atomic_load = stdlib.Atomics.load;
     var atomic_store = stdlib.Atomics.store;
     var atomic_cmpxchg = stdlib.Atomics.compareExchange;
     var atomic_exchange = stdlib.Atomics.exchange;
     var atomic_add = stdlib.Atomics.add;
--- a/js/src/jit-test/tests/asm.js/testBug1155176.js
+++ b/js/src/jit-test/tests/asm.js/testBug1155176.js
@@ -1,13 +1,13 @@
 if (!this.SharedArrayBuffer || !isAsmJSCompilationAvailable())
     quit(0);
 
 load(libdir + "asm.js");
-setJitCompilerOption('wasm.test-mode', 1);
+setJitCompilerOption('asmjs.atomics.enable', 1);
 
 // The way this is constructed, either the first module does not
 // verify as asm.js (if the >>>0 is left off, which was legal prior to
 // bug 1155176), or the results of the two modules have to be equal.
 
 var m = asmCompile("stdlib", "ffi", "heap", `
     "use asm";
 
--- a/js/src/jit-test/tests/asm.js/testBug1164391.js
+++ b/js/src/jit-test/tests/asm.js/testBug1164391.js
@@ -1,14 +1,14 @@
 if (!this.SharedArrayBuffer)
     quit(0);
 
 load(libdir + "asm.js");
 load(libdir + "asserts.js");
-setJitCompilerOption('wasm.test-mode', 1);
+setJitCompilerOption('asmjs.atomics.enable', 1);
 
 var m = asmCompile("stdlib", "ffi", "heap", `
     "use asm";
     var HEAP32 = new stdlib.Int32Array(heap);
     var add = stdlib.Atomics.add;
     var load = stdlib.Atomics.load;
     function add_sharedEv(i1) {
         i1 = i1 | 0;
--- a/js/src/jit-test/tests/asm.js/testBug1302407.js
+++ b/js/src/jit-test/tests/asm.js/testBug1302407.js
@@ -1,6 +1,6 @@
 if (!this['SharedArrayBuffer'])
     quit();
 
-setJitCompilerOption('wasm.test-mode', 1);
+setJitCompilerOption('asmjs.atomics.enable', 1);
 new SharedArrayBuffer(65536);
-setJitCompilerOption('wasm.test-mode', 0)
+setJitCompilerOption('asmjs.atomics.enable', 0)
--- a/js/src/jit/JitOptions.cpp
+++ b/js/src/jit/JitOptions.cpp
@@ -216,16 +216,19 @@ DefaultJitOptions::DefaultJitOptions()
         forcedRegisterAllocator = LookupRegisterAllocator(env);
         if (!forcedRegisterAllocator.isSome())
             Warn(forcedRegisterAllocatorEnv, env);
     }
 
     // Toggles whether unboxed plain objects can be created by the VM.
     SET_DEFAULT(disableUnboxedObjects, false);
 
+    // Test whether Atomics are allowed in asm.js code.
+    SET_DEFAULT(asmJSAtomicsEnable, false);
+
     // Test whether wasm int64 / double NaN bits testing is enabled.
     SET_DEFAULT(wasmTestMode, false);
 
     // Toggles the optimization whereby offsets are folded into loads and not
     // included in the bounds check.
     SET_DEFAULT(wasmFoldOffsets, true);
 
     // Determines whether we suppress using signal handlers
--- a/js/src/jit/JitOptions.h
+++ b/js/src/jit/JitOptions.h
@@ -64,16 +64,17 @@ struct DefaultJitOptions
     bool disableCacheIR;
     bool disableSharedStubs;
     bool disableSincos;
     bool disableSink;
     bool eagerCompilation;
     bool forceInlineCaches;
     bool limitScriptSize;
     bool osr;
+    bool asmJSAtomicsEnable;
     bool wasmTestMode;
     bool wasmFoldOffsets;
     bool ionInterruptWithoutSignals;
     uint32_t baselineWarmUpThreshold;
     uint32_t exceptionBailoutThreshold;
     uint32_t frequentBailoutThreshold;
     uint32_t maxStackArgs;
     uint32_t osrPcMismatchesBeforeRecompile;
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -6205,16 +6205,19 @@ JS_SetGlobalJitCompilerOption(JSContext*
         break;
       case JSJITCOMPILER_JUMP_THRESHOLD:
         if (value == uint32_t(-1)) {
             jit::DefaultJitOptions defaultValues;
             value = defaultValues.jumpThreshold;
         }
         jit::JitOptions.jumpThreshold = value;
         break;
+      case JSJITCOMPILER_ASMJS_ATOMICS_ENABLE:
+        jit::JitOptions.asmJSAtomicsEnable = !!value;
+        break;
       case JSJITCOMPILER_WASM_TEST_MODE:
         jit::JitOptions.wasmTestMode = !!value;
         break;
       case JSJITCOMPILER_WASM_FOLD_OFFSETS:
         jit::JitOptions.wasmFoldOffsets = !!value;
         break;
       case JSJITCOMPILER_ION_INTERRUPT_WITHOUT_SIGNAL:
         jit::JitOptions.ionInterruptWithoutSignals = !!value;
@@ -6239,16 +6242,19 @@ JS_GetGlobalJitCompilerOption(JSContext*
       case JSJITCOMPILER_ION_FORCE_IC:
         return jit::JitOptions.forceInlineCaches;
       case JSJITCOMPILER_ION_ENABLE:
         return JS::ContextOptionsRef(cx).ion();
       case JSJITCOMPILER_BASELINE_ENABLE:
         return JS::ContextOptionsRef(cx).baseline();
       case JSJITCOMPILER_OFFTHREAD_COMPILATION_ENABLE:
         return rt->canUseOffthreadIonCompilation();
+      case JSJITCOMPILER_ASMJS_ATOMICS_ENABLE:
+        return jit::JitOptions.asmJSAtomicsEnable ? 1 : 0;
+        break;
       case JSJITCOMPILER_WASM_TEST_MODE:
         return jit::JitOptions.wasmTestMode ? 1 : 0;
       case JSJITCOMPILER_WASM_FOLD_OFFSETS:
         return jit::JitOptions.wasmFoldOffsets ? 1 : 0;
       case JSJITCOMPILER_ION_INTERRUPT_WITHOUT_SIGNAL:
         return jit::JitOptions.ionInterruptWithoutSignals ? 1 : 0;
       default:
         break;
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -5631,16 +5631,17 @@ JS_SetOffthreadIonCompilationEnabled(JSC
     Register(ION_WARMUP_TRIGGER, "ion.warmup.trigger")                     \
     Register(ION_GVN_ENABLE, "ion.gvn.enable")                             \
     Register(ION_FORCE_IC, "ion.forceinlineCaches")                        \
     Register(ION_ENABLE, "ion.enable")                                     \
     Register(ION_INTERRUPT_WITHOUT_SIGNAL, "ion.interrupt-without-signals") \
     Register(BASELINE_ENABLE, "baseline.enable")                           \
     Register(OFFTHREAD_COMPILATION_ENABLE, "offthread-compilation.enable") \
     Register(JUMP_THRESHOLD, "jump-threshold")                             \
+    Register(ASMJS_ATOMICS_ENABLE, "asmjs.atomics.enable")                 \
     Register(WASM_TEST_MODE, "wasm.test-mode")                             \
     Register(WASM_FOLD_OFFSETS, "wasm.fold-offsets")
 
 typedef enum JSJitCompilerOption {
 #define JIT_COMPILER_DECLARE(key, str) \
     JSJITCOMPILER_ ## key,
 
     JIT_COMPILER_OPTIONS(JIT_COMPILER_DECLARE)
--- a/js/src/vm/SharedArrayObject.cpp
+++ b/js/src/vm/SharedArrayObject.cpp
@@ -111,17 +111,17 @@ SharedArrayRawBuffer::New(JSContext* cx,
     // so guard against it on principle.
     MOZ_ASSERT(length != (uint32_t)-1);
 
     // Add a page for the header and round to a page boundary.
     uint32_t allocSize = SharedArrayAllocSize(length);
     if (allocSize <= length)
         return nullptr;
 
-    bool preparedForAsmJS = jit::JitOptions.wasmTestMode && IsValidAsmJSHeapLength(length);
+    bool preparedForAsmJS = jit::JitOptions.asmJSAtomicsEnable && IsValidAsmJSHeapLength(length);
 
     void* p = nullptr;
     if (preparedForAsmJS) {
         // Test >= to guard against the case where multiple extant runtimes
         // race to allocate.
         if (++numLive >= maxLive) {
             JSRuntime* rt = cx->runtime();
             if (rt->largeAllocationFailureCallback)