Bug 1137050 - Don't SetThreadContext if the context didn't change. r=luke, a=lizzard
authorDavid Major <dmajor@mozilla.com>
Thu, 26 Feb 2015 20:37:00 -0500
changeset 250156 5334c7c0b2ce
parent 250155 70787b6f48c3
child 250157 082769bdd62a
push id4515
push userryanvm@gmail.com
push date2015-03-02 23:33 +0000
treeherdermozilla-beta@082769bdd62a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke, lizzard
bugs1137050
milestone37.0
Bug 1137050 - Don't SetThreadContext if the context didn't change. r=luke, a=lizzard
js/src/asmjs/AsmJSSignalHandlers.cpp
--- a/js/src/asmjs/AsmJSSignalHandlers.cpp
+++ b/js/src/asmjs/AsmJSSignalHandlers.cpp
@@ -937,17 +937,17 @@ RedirectIonBackedgesToInterruptCheck(JSR
         // thus not in a JIT iloop. We assume that the interrupt flag will be
         // checked at least once before entering JIT code (if not, no big deal;
         // the browser will just request another interrupt in a second).
         if (!jitRuntime->mutatingBackedgeList())
             jitRuntime->patchIonBackedges(rt, jit::JitRuntime::BackedgeInterruptCheck);
     }
 }
 
-static void
+static bool
 RedirectJitCodeToInterruptCheck(JSRuntime *rt, CONTEXT *context)
 {
     RedirectIonBackedgesToInterruptCheck(rt);
 
     if (AsmJSActivation *activation = rt->mainThread.asmJSActivationStack()) {
         const AsmJSModule &module = activation->module();
 
 #if defined(JS_ARM_SIMULATOR) || defined(JS_MIPS_SIMULATOR)
@@ -955,18 +955,21 @@ RedirectJitCodeToInterruptCheck(JSRuntim
             rt->mainThread.simulator()->set_resume_pc(int32_t(module.interruptExit()));
 #endif
 
         uint8_t **ppc = ContextToPC(context);
         uint8_t *pc = *ppc;
         if (module.containsFunctionPC(pc)) {
             activation->setResumePC(pc);
             *ppc = module.interruptExit();
+            return true;
         }
     }
+
+    return false;
 }
 
 #if !defined(XP_WIN)
 // For the interrupt signal, pick a signal number that:
 //  - is not otherwise used by mozilla or standard libraries
 //  - defaults to nostop and noprint on gdb/lldb so that noone is bothered
 // SIGVTALRM a relative of SIGALRM, so intended for user code, but, unlike
 // SIGALRM, not used anywhere else in Mozilla.
@@ -1094,18 +1097,18 @@ js::InterruptRunningJitCode(JSRuntime *r
     // its context from this thread. SuspendThread can sporadically fail if the
     // thread is in the middle of a syscall. Rather than retrying in a loop,
     // just wait for the next request for interrupt.
     HANDLE thread = (HANDLE)rt->ownerThreadNative();
     if (SuspendThread(thread) != -1) {
         CONTEXT context;
         context.ContextFlags = CONTEXT_CONTROL;
         if (GetThreadContext(thread, &context)) {
-            RedirectJitCodeToInterruptCheck(rt, &context);
-            SetThreadContext(thread, &context);
+            if (RedirectJitCodeToInterruptCheck(rt, &context))
+                SetThreadContext(thread, &context);
         }
         ResumeThread(thread);
     }
 #else
     // On Unix, we instead deliver an async signal to the main thread which
     // halts the thread and callers our JitInterruptHandler (which has already
     // been installed by EnsureSignalHandlersInstalled).
     pthread_t thread = (pthread_t)rt->ownerThreadNative();