Bug 887334 - Move faulty JSAutoRequest in initSelfHosting. r=luke
☠☠ backed out by 659b0d61fbc6 ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Thu, 25 Jul 2013 11:29:22 -0700
changeset 148058 e9d11a42124671d71ccc0a624b7e0825487e2768
parent 148057 c7e4cd12068a2047c6bb734437c35ab0f385f7ce
child 148059 2aa3a1f91a7db6c439c2d11abfacc5be829df2a3
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)
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.
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -645,18 +645,18 @@ const JSFunctionSpec intrinsic_functions
 JSRuntime::initSelfHosting(JSContext *cx)
     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;