Bug 986673: Tests; r=luke
☠☠ backed out by c65ea1add688 ☠ ☠
authorBenjamin Bouvier <benj@benj.me>
Fri, 18 Jul 2014 12:14:51 +0200
changeset 216787 d78533837dfd70481c217044320ae82888cf9445
parent 216786 41f10856b94d82da771c9257517bd77a7733b587
child 216788 6412347e62955edd8bd841ff361872fd83940c9b
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs986673
milestone33.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 986673: Tests; r=luke
js/src/jit-test/tests/asm.js/testHeapAccess.js
js/src/jit-test/tests/asm.js/testTimeout-deactivate-reactivate-signals.js
js/src/jit-test/tests/asm.js/testTimeout1-nosignals.js
js/src/jit-test/tests/asm.js/testTimeout2-nosignals.js
js/src/jit-test/tests/asm.js/testTimeout3-nosignals.js
js/src/jit-test/tests/asm.js/testTimeout4-nosignals.js
js/src/jit-test/tests/ion/iloop-nosignaling.js
js/src/jsapi.cpp
js/src/jsapi.h
js/src/vm/Runtime.h
--- a/js/src/jit-test/tests/asm.js/testHeapAccess.js
+++ b/js/src/jit-test/tests/asm.js/testHeapAccess.js
@@ -17,16 +17,43 @@ assertEq(f(0), 0);
 
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return i8[0]|0}; return f');
 var f = asmLink(code, this, null, new ArrayBuffer(4096));
 assertEq(f(0),0);
 assertEq(f(0x7f),0x7f);
 assertEq(f(0xff),-1);
 assertEq(f(0x100),0);
 
+// Test signal handlers deactivation
+(function() {
+    var jco = getJitCompilerOptions();
+    var signalHandlersBefore = jco["signals.enable"];
+    if (signalHandlersBefore == 1) {
+        setJitCompilerOption("signals.enable", 0);
+
+        if (isCachingEnabled()) {
+            // Cloned modules should fail on linking if the initial module has
+            // been compiled with signals but signals are deactivated.
+            var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return i8[0]|0}; return f');
+            assertAsmLinkFail(code, this, null, new ArrayBuffer(4096));
+        }
+
+        var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + '/* not a clone */ function f(i) {i=i|0; i32[0] = i; return i8[0]|0}; return f');
+        var f = asmLink(code, this, null, new ArrayBuffer(4096));
+        assertEq(f(0),0);
+        assertEq(f(0x7f),0x7f);
+        assertEq(f(0xff),-1);
+        assertEq(f(0x100),0);
+        setJitCompilerOption("signals.enable", 1);
+    }
+    jco = getJitCompilerOptions();
+    var signalHandlersAfter = jco["signals.enable"];
+    assertEq(signalHandlersBefore, signalHandlersAfter);
+})();
+
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return u8[0]|0}; return f');
 var f = asmLink(code, this, null, new ArrayBuffer(4096));
 assertEq(f(0),0);
 assertEq(f(0x7f),0x7f);
 assertEq(f(0xff),0xff);
 assertEq(f(0x100),0);
 
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i32[0] = i; return i16[0]|0}; return f');
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/asm.js/testTimeout-deactivate-reactivate-signals.js
@@ -0,0 +1,28 @@
+// |jit-test| exitstatus: 6;
+
+load(libdir + "asm.js");
+
+var jco = getJitCompilerOptions();
+if (jco["signals.enable"] === 0 || !isCachingEnabled())
+    quit(6);
+
+// Modules compiled without signal handlers should still work even if signal
+// handlers have been reactivated.
+setJitCompilerOption("signals.enable", 0);
+
+var code = USE_ASM + "function f() {} function g() { while(1) { f() } } return g";
+
+var m = asmCompile(code);
+assertEq(isAsmJSModule(m), true);
+assertEq(isAsmJSModuleLoadedFromCache(m), false);
+
+setJitCompilerOption("signals.enable", 1);
+
+var m = asmCompile(code);
+assertEq(isAsmJSModule(m), true);
+assertEq(isAsmJSModuleLoadedFromCache(m), true);
+
+var g = asmLink(m);
+timeout(1);
+g();
+assertEq(true, false);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/asm.js/testTimeout1-nosignals.js
@@ -0,0 +1,9 @@
+// |jit-test| exitstatus: 6;
+
+load(libdir + "asm.js");
+
+setJitCompilerOption("signals.enable", 0);
+var g = asmLink(asmCompile(USE_ASM + "function f() {} function g() { while(1) { f() } } return g"));
+timeout(1);
+g();
+assertEq(true, false);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/asm.js/testTimeout2-nosignals.js
@@ -0,0 +1,9 @@
+// |jit-test| exitstatus: 6;
+
+load(libdir + "asm.js");
+
+setJitCompilerOption("signals.enable", 0);
+var g = asmLink(asmCompile(USE_ASM + "function g() { while(1) {} } return g"));
+timeout(1);
+g();
+assertEq(true, false);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/asm.js/testTimeout3-nosignals.js
@@ -0,0 +1,9 @@
+// |jit-test| exitstatus: 6;
+
+load(libdir + "asm.js");
+
+setJitCompilerOption("signals.enable", 0);
+var f = asmLink(asmCompile(USE_ASM + "function f(i) { i=i|0; if (!i) return; f((i-1)|0); f((i-1)|0); f((i-1)|0); f((i-1)|0); f((i-1)|0); } return f"));
+timeout(1);
+f(100);
+assertEq(true, false);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/asm.js/testTimeout4-nosignals.js
@@ -0,0 +1,9 @@
+// |jit-test| exitstatus: 6;
+
+load(libdir + "asm.js");
+
+setJitCompilerOption("signals.enable", 0);
+var g = asmLink(asmCompile(USE_ASM + "function f(d) { d=+d; d=d*.1; d=d/.4; return +d } function g() { while(1) { +f(1.1) } } return g"));
+timeout(1);
+g();
+assertEq(true, false);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/iloop-nosignaling.js
@@ -0,0 +1,5 @@
+// |jit-test| exitstatus: 6;
+
+setJitCompilerOption('signals.enable', 0);
+timeout(1);
+for(;;);
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -6304,16 +6304,25 @@ JS_SetGlobalJitCompilerOption(JSRuntime 
         if (value == 1) {
             rt->setOffthreadIonCompilationEnabled(true);
             IonSpew(js::jit::IonSpew_Scripts, "Enable offthread compilation");
         } else if (value == 0) {
             rt->setOffthreadIonCompilationEnabled(false);
             IonSpew(js::jit::IonSpew_Scripts, "Disable offthread compilation");
         }
         break;
+      case JSJITCOMPILER_SIGNALS_ENABLE:
+        if (value == 1) {
+            rt->setCanUseSignalHandlers(true);
+            IonSpew(js::jit::IonSpew_Scripts, "Enable signals");
+        } else if (value == 0) {
+            rt->setCanUseSignalHandlers(false);
+            IonSpew(js::jit::IonSpew_Scripts, "Disable signals");
+        }
+        break;
       default:
         break;
     }
 #endif
 }
 
 JS_PUBLIC_API(int)
 JS_GetGlobalJitCompilerOption(JSRuntime *rt, JSJitCompilerOption opt)
@@ -6325,16 +6334,18 @@ JS_GetGlobalJitCompilerOption(JSRuntime 
       case JSJITCOMPILER_ION_USECOUNT_TRIGGER:
         return jit::js_JitOptions.forcedDefaultIonUsesBeforeCompile;
       case JSJITCOMPILER_ION_ENABLE:
         return JS::RuntimeOptionsRef(rt).ion();
       case JSJITCOMPILER_BASELINE_ENABLE:
         return JS::RuntimeOptionsRef(rt).baseline();
       case JSJITCOMPILER_OFFTHREAD_COMPILATION_ENABLE:
         return rt->canUseOffthreadIonCompilation();
+      case JSJITCOMPILER_SIGNALS_ENABLE:
+        return rt->canUseSignalHandlers();
       default:
         break;
     }
 #endif
     return 0;
 }
 
 /************************************************************************/
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4921,17 +4921,18 @@ JS_SetParallelParsingEnabled(JSRuntime *
 extern JS_PUBLIC_API(void)
 JS_SetOffthreadIonCompilationEnabled(JSRuntime *rt, bool enabled);
 
 #define JIT_COMPILER_OPTIONS(Register)                                  \
     Register(BASELINE_USECOUNT_TRIGGER, "baseline.usecount.trigger")    \
     Register(ION_USECOUNT_TRIGGER, "ion.usecount.trigger")              \
     Register(ION_ENABLE, "ion.enable")                                  \
     Register(BASELINE_ENABLE, "baseline.enable")                        \
-    Register(OFFTHREAD_COMPILATION_ENABLE, "offthread-compilation.enable")
+    Register(OFFTHREAD_COMPILATION_ENABLE, "offthread-compilation.enable") \
+    Register(SIGNALS_ENABLE, "signals.enable")
 
 typedef enum JSJitCompilerOption {
 #define JIT_COMPILER_DECLARE(key, str) \
     JSJITCOMPILER_ ## key,
 
     JIT_COMPILER_OPTIONS(JIT_COMPILER_DECLARE)
 #undef JIT_COMPILER_DECLARE
 
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -1081,16 +1081,19 @@ struct JSRuntime : public JS::shadow::Ru
     bool canUseSignalHandlers_;
   public:
     bool signalHandlersInstalled() const {
         return signalHandlersInstalled_;
     }
     bool canUseSignalHandlers() const {
         return canUseSignalHandlers_;
     }
+    void setCanUseSignalHandlers(bool enable) {
+        canUseSignalHandlers_ = signalHandlersInstalled_ && enable;
+    }
 
   private:
     js::FreeOp          defaultFreeOp_;
 
   public:
     js::FreeOp *defaultFreeOp() {
         return &defaultFreeOp_;
     }