Bug 704478 - Fix single-threaded runtime assertions in shell workers (r=jorendorff)
authorLuke Wagner <luke@mozilla.com>
Tue, 22 Nov 2011 11:37:57 -0800
changeset 84347 04f576b81e1a94f874eb4b1d1989506ef41d826d
parent 84346 9a5144c8f69f0e131f435620102ccc17b20a48c0
child 84348 5c3c5e4db3ad622a5d9ca6f8b7185fd48ea24d3d
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs704478
milestone11.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 704478 - Fix single-threaded runtime assertions in shell workers (r=jorendorff)
js/src/shell/jsworkers.cpp
--- a/js/src/shell/jsworkers.cpp
+++ b/js/src/shell/jsworkers.cpp
@@ -1132,54 +1132,54 @@ Worker::processOneEvent()
     {
         AutoLock hold1(lock);
         if (lockedCheckTermination() || events.empty())
             return;
 
         event = current = events.pop();
     }
 
+    JS_SetRuntimeThread(runtime);
     JS_SetContextThread(context);
     JS_SetNativeStackQuota(context, gMaxStackSize);
 
     Event::Result result;
     {
-        JSAutoSetRuntimeThread asrt(JS_GetRuntime(context));
         JSAutoRequest ar(context);
         result = event->process(context);
     }
 
     // Note: we have to leave the above request before calling parent->post or
     // checkTermination, both of which acquire locks.
     if (result == Event::forwardToParent) {
         event->setChildAndRecipient(this, parent);
         if (parent->post(event)) {
             event = NULL;  // to prevent it from being deleted below
         } else {
             JS_ReportOutOfMemory(context);
             result = Event::fail;
         }
     }
     if (result == Event::fail && !checkTermination()) {
-        JSAutoSetRuntimeThread asrt(JS_GetRuntime(context));
         JSAutoRequest ar(context);
         Event *err = ErrorEvent::create(context, this);
         if (err && !parent->post(err)) {
             JS_ReportOutOfMemory(context);
             err->destroy(context);
             err = NULL;
         }
         if (!err) {
             // FIXME - out of memory, probably should panic
         }
     }
 
     if (event)
         event->destroy(context);
     JS_ClearContextThread(context);
+    JS_ClearRuntimeThread(runtime);
 
     {
         AutoLock hold2(lock);
         current = NULL;
         if (!lockedCheckTermination() && !events.empty()) {
             // Re-enqueue this worker. OOM here effectively kills the worker.
             if (!threadPool->getWorkerQueue()->post(this))
                 JS_ReportOutOfMemory(context);