Bug 887334 - Move faulty JSAutoRequest in initSelfHosting. r=luke
authorBobby Holley <bobbyholley@gmail.com>
Wed, 17 Jul 2013 11:53:51 -0700
changeset 138954 957a80f3ddab52d2cd0a792e1988c930d8281037
parent 138953 8dc4e544f514c30a84620bc9cb3b925b32d964f6
child 138955 31d4bde6b786ebd637b8b93c3c48440630be449e
push id24977
push userryanvm@gmail.com
push dateFri, 19 Jul 2013 00:35:38 +0000
treeherdermozilla-central@0d0263a58f06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs887334
milestone25.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 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
@@ -679,18 +679,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;