Bug 887334 - Move faulty JSAutoRequest in initSelfHosting. r=luke
☠☠ backed out by b3d0c2498b42 ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Fri, 26 Jul 2013 18:56:55 -0700
changeset 148096 101e407d040a669532f57eab945df6bbdb95bdf3
parent 148095 cd2f2d2299eef5157a5dcae14f3bd3879f439e1c
child 148097 0d59888536b54999cd4d9a6284a2c08c39873af2
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs887334
milestone24.0a2
Bug 887334 - Move faulty JSAutoRequest in initSelfHosting. r=luke The call to JS_SetGlobalObject causes cx->compartment_ to be set to the self- hosting global, which means that the JSAutoCompartment picks up that compartment as the 'previous' compartment. So despite the attempt to restore things with JS_SetGlobalObject at the end of the function, the JSAutoCompartment destructor actually ends up leaving cx in the self-hosting global's compartment at the end of this function. Moving the JSAutoCompartment construction above the call to JS_SetGlobalObject fixes the problem.
js/src/vm/SelfHosting.cpp
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -645,18 +645,18 @@ const JSFunctionSpec intrinsic_functions
 
 bool
 JSRuntime::initSelfHosting(JSContext *cx)
 {
     JS_ASSERT(!selfHostingGlobal_);
     RootedObject savedGlobal(cx, js::GetDefaultGlobalForContext(cx));
     if (!(selfHostingGlobal_ = JS_NewGlobalObject(cx, &self_hosting_global_class, NULL)))
         return false;
+    JSAutoCompartment ac(cx, selfHostingGlobal_);
     JS_SetGlobalObject(cx, selfHostingGlobal_);
-    JSAutoCompartment ac(cx, cx->global());
     Rooted<GlobalObject*> shg(cx, &selfHostingGlobal_->as<GlobalObject>());
     /*
      * During initialization of standard classes for the self-hosting global,
      * all self-hosted functions are ignored. Thus, we don't create cyclic
      * dependencies in the order of initialization.
      */
     if (!GlobalObject::initStandardClasses(cx, shg))
         return false;