Bug 842411 - Fire operation callback before time is up so we can test the non-aborting case (r=terrence)
authorLuke Wagner <luke@mozilla.com>
Tue, 19 Feb 2013 13:17:39 -0800
changeset 122367 408ad90d68dcc3b4968fc92d7e54861f2ff9369b
parent 122366 5b56d8a519a57503d1f934da2ce30260dd2cae90
child 122368 27652a4eddb470d29d1850e02be5d73727385803
push id24336
push userryanvm@gmail.com
push dateWed, 20 Feb 2013 12:07:46 +0000
treeherdermozilla-central@1bcc3c56b011 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs842411
milestone22.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 842411 - Fire operation callback before time is up so we can test the non-aborting case (r=terrence)
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2835,36 +2835,44 @@ static void
 WatchdogMain(void *arg)
 {
     PR_SetCurrentThreadName("JS Watchdog");
 
     JSRuntime *rt = (JSRuntime *) arg;
 
     PR_Lock(gWatchdogLock);
     while (gWatchdogThread) {
-         int64_t now = PRMJ_Now();
-         if (gWatchdogHasTimeout && !IsBefore(now, gWatchdogTimeout)) {
-             /*
-              * The timeout has just expired. Trigger the operation callback
-              * outside the lock.
-              */
-             gWatchdogHasTimeout = false;
-             PR_Unlock(gWatchdogLock);
-             CancelExecution(rt);
-             PR_Lock(gWatchdogLock);
-
-             /* Wake up any threads doing sleep. */
-             PR_NotifyAllCondVar(gSleepWakeup);
+        int64_t now = PRMJ_Now();
+        if (gWatchdogHasTimeout && !IsBefore(now, gWatchdogTimeout)) {
+            /*
+             * The timeout has just expired. Trigger the operation callback
+             * outside the lock.
+             */
+            gWatchdogHasTimeout = false;
+            PR_Unlock(gWatchdogLock);
+            CancelExecution(rt);
+            PR_Lock(gWatchdogLock);
+
+            /* Wake up any threads doing sleep. */
+            PR_NotifyAllCondVar(gSleepWakeup);
         } else {
-             uint64_t sleepDuration = PR_INTERVAL_NO_TIMEOUT;
-             if (gWatchdogHasTimeout)
-                 sleepDuration = (gWatchdogTimeout - now) / PRMJ_USEC_PER_SEC * PR_TicksPerSecond();
-             mozilla::DebugOnly<PRStatus> status =
-               PR_WaitCondVar(gWatchdogWakeup, sleepDuration);
-             JS_ASSERT(status == PR_SUCCESS);
+            if (gWatchdogHasTimeout) {
+                /*
+                 * Time hasn't expired yet. Simulate an operation callback
+                 * which doesn't abort execution.
+                 */
+                JS_TriggerOperationCallback(rt);
+            }
+
+            uint64_t sleepDuration = PR_INTERVAL_NO_TIMEOUT;
+            if (gWatchdogHasTimeout)
+                sleepDuration = PR_TicksPerSecond() / 10;
+            mozilla::DebugOnly<PRStatus> status =
+              PR_WaitCondVar(gWatchdogWakeup, sleepDuration);
+            JS_ASSERT(status == PR_SUCCESS);
         }
     }
     PR_Unlock(gWatchdogLock);
 }
 
 static bool
 ScheduleWatchdog(JSRuntime *rt, double t)
 {