Bug 1429140 - Make signal handling work for --disable-ion builds. r=luke
authorLars T Hansen <lhansen@mozilla.com>
Thu, 11 Jan 2018 17:32:00 +0100
changeset 453212 16740cf93a77c1f8ba6d39cf5748e0180e7e95dc
parent 453211 2dab1647f93321a1bb6f418495f55260f2eacc28
child 453213 2ed6a8d139a3bf4d764243be060248811ca420fa
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1429140
milestone59.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 1429140 - Make signal handling work for --disable-ion builds. r=luke Signal handling is improperly ifdeffed on JS_CODEGEN_NONE; the appropriate conditions are whether the signal handling machinery knows how to grab the machine state, and that is not JIT-dependent. (The Atomics machinery has the same constraint.) So change the ifdefs accordingly. Also fix a bug in jsfun.cpp where it calls into the JIT even if the JIT is not present; this causes crashes.
js/src/jsfun.cpp
js/src/wasm/WasmSignalHandlers.cpp
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -188,21 +188,23 @@ ArgumentsGetterImpl(JSContext* cx, const
         args.rval().setNull();
         return true;
     }
 
     Rooted<ArgumentsObject*> argsobj(cx, ArgumentsObject::createUnexpected(cx, iter));
     if (!argsobj)
         return false;
 
+#ifndef JS_CODEGEN_NONE
     // Disabling compiling of this script in IonMonkey.  IonMonkey doesn't
     // guarantee |f.arguments| can be fully recovered, so we try to mitigate
     // observing this behavior by detecting its use early.
     JSScript* script = iter.script();
     jit::ForbidCompilation(cx, script);
+#endif
 
     args.rval().setObject(*argsobj);
     return true;
 }
 
 static bool
 ArgumentsGetter(JSContext* cx, unsigned argc, Value* vp)
 {
--- a/js/src/wasm/WasmSignalHandlers.cpp
+++ b/js/src/wasm/WasmSignalHandlers.cpp
@@ -416,51 +416,55 @@ struct macos_arm_context {
 # define LR_sig(p) RLR_sig(p)
 #elif defined(__mips__)
 # define PC_sig(p) EPC_sig(p)
 # define FP_sig(p) RFP_sig(p)
 # define SP_sig(p) RSP_sig(p)
 # define LR_sig(p) R31_sig(p)
 #endif
 
+#if defined(FP_sig) && defined(SP_sig) && defined(SP_sig)
+# define KNOWS_MACHINE_STATE
+#endif
+
 static uint8_t**
 ContextToPC(CONTEXT* context)
 {
-#ifdef JS_CODEGEN_NONE
+#ifdef KNOWS_MACHINE_STATE
+    return reinterpret_cast<uint8_t**>(&PC_sig(context));
+#else
     MOZ_CRASH();
-#else
-    return reinterpret_cast<uint8_t**>(&PC_sig(context));
 #endif
 }
 
 static uint8_t*
 ContextToFP(CONTEXT* context)
 {
-#ifdef JS_CODEGEN_NONE
+#ifdef KNOWS_MACHINE_STATE
+    return reinterpret_cast<uint8_t*>(FP_sig(context));
+#else
     MOZ_CRASH();
-#else
-    return reinterpret_cast<uint8_t*>(FP_sig(context));
 #endif
 }
 
-#ifndef JS_CODEGEN_NONE
+#ifdef KNOWS_MACHINE_STATE
 static uint8_t*
 ContextToSP(CONTEXT* context)
 {
     return reinterpret_cast<uint8_t*>(SP_sig(context));
 }
 
 # if defined(__arm__) || defined(__aarch64__) || defined(__mips__)
 static uint8_t*
 ContextToLR(CONTEXT* context)
 {
     return reinterpret_cast<uint8_t*>(LR_sig(context));
 }
 # endif
-#endif // JS_CODEGEN_NONE
+#endif // KNOWS_MACHINE_STATE
 
 #if defined(XP_DARWIN)
 
 static uint8_t**
 ContextToPC(EMULATOR_CONTEXT* context)
 {
 # if defined(__x86_64__)
     static_assert(sizeof(context->thread.__rip) == sizeof(void*),
@@ -527,27 +531,27 @@ ToRegisterState(EMULATOR_CONTEXT* contex
 # endif
     return state;
 }
 #endif // XP_DARWIN
 
 static JS::ProfilingFrameIterator::RegisterState
 ToRegisterState(CONTEXT* context)
 {
-#ifdef JS_CODEGEN_NONE
-    MOZ_CRASH();
-#else
+#ifdef KNOWS_MACHINE_STATE
     JS::ProfilingFrameIterator::RegisterState state;
     state.fp = ContextToFP(context);
     state.pc = *ContextToPC(context);
     state.sp = ContextToSP(context);
 # if defined(__arm__) || defined(__aarch64__) || defined(__mips__)
     state.lr = ContextToLR(context);
 # endif
     return state;
+#else
+    MOZ_CRASH();
 #endif
 }
 
 #if defined(WASM_HUGE_MEMORY)
 MOZ_COLD static void
 SetFPRegToNaN(size_t size, void* fp_reg)
 {
     MOZ_RELEASE_ASSERT(size <= Simd128DataSize);