[JAEGER] Bug 582039: deoptimize globals if the initial var object is not the global object, r=dvander
authorDavid Mandelin <dmandelin@mozilla.com>
Mon, 26 Jul 2010 14:36:32 -0700
changeset 53198 40d061956e16aeb7c424610e185a9ae8f375bb2b
parent 53197 db9353572da87559a5fbe2319ae517566b502c4a
child 53199 c8f319f0f749e319ab58f19dc44d2a22f2bdc9a4
push id15660
push userrsayre@mozilla.com
push dateSat, 11 Sep 2010 19:16:24 +0000
treeherdermozilla-central@f1bd314e64ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs582039
milestone2.0b2pre
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
[JAEGER] Bug 582039: deoptimize globals if the initial var object is not the global object, r=dvander
js/src/jsemit.cpp
js/src/jsparse.cpp
--- a/js/src/jsemit.cpp
+++ b/js/src/jsemit.cpp
@@ -2109,17 +2109,17 @@ BindNameToSlot(JSContext *cx, JSCodeGene
             JS_ASSERT(cg->staticLevel >= fun->u.i.script->staticLevel);
             unsigned skip = cg->staticLevel - fun->u.i.script->staticLevel;
             if (cg->skipSpansGenerator(skip))
                 return JS_TRUE;
 
             return MakeUpvarForEval(pn, cg);
         }
 
-        if (cg->compileAndGo()) { 
+        if (cg->compileAndGo() && cg->compiler()->globalScope->globalObj) { 
             switch (op) {
               case JSOP_NAME:     op = JSOP_GETGNAME; break;
               case JSOP_SETNAME:  op = JSOP_SETGNAME; break;
               case JSOP_INCNAME:  op = JSOP_INCGNAME; break;
               case JSOP_NAMEINC:  op = JSOP_GNAMEINC; break;
               case JSOP_DECNAME:  op = JSOP_DECGNAME; break;
               case JSOP_NAMEDEC:  op = JSOP_GNAMEDEC; break;
               case JSOP_SETCONST:
--- a/js/src/jsparse.cpp
+++ b/js/src/jsparse.cpp
@@ -754,17 +754,20 @@ Compiler::compileScript(JSContext *cx, J
     TokenStream &tokenStream = parser.tokenStream;
 
     JSCodeGenerator cg(&parser, &codePool, &notePool, tokenStream.getLineno());
     if (!cg.init())
         return NULL;
 
     MUST_FLOW_THROUGH("out");
 
-    JSObject *globalObj = scopeChain ? scopeChain->getGlobal() : NULL;
+    // We can specialize a bit for the given scope chain if that scope chain is the global object.
+    JSObject *globalObj = scopeChain && scopeChain == scopeChain->getGlobal()
+                        ? scopeChain->getGlobal()
+                        : NULL;
     js::GlobalScope globalScope(cx, globalObj, &cg);
     if (globalObj) {
         JS_ASSERT(globalObj->isNative());
         JS_ASSERT((globalObj->getClass()->flags & JSCLASS_GLOBAL_FLAGS) == JSCLASS_GLOBAL_FLAGS);
         globalScope.globalFreeSlot = globalObj->scope()->freeslot;
     }
 
     /* Null script early in case of error, to reduce our code footprint. */