Bug 475396 - Disable upvar optimizations under JS_EvaluateUCInStackFrame because we can't vouch for the display being right. r=brendan
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 03 Feb 2009 13:20:19 -0800
changeset 24609 bab1a858464d75dd2faf8b8fc6231d36e4d2469e
parent 24608 8d1c9cd07f916f3e290a6630a350947f3ec5a1bf
child 24610 ca733f2cc2377e3ca8f81ba22fe42caf2385c0e7
child 24615 bd2f9063a8a29f5d8d5283b20a1bd39453b2fc8f
push id5132
push userrsayre@mozilla.com
push dateWed, 04 Feb 2009 20:48:09 +0000
treeherdermozilla-central@76ca30e94e5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbrendan
bugs475396
milestone1.9.2a1pre
Bug 475396 - Disable upvar optimizations under JS_EvaluateUCInStackFrame because we can't vouch for the display being right. r=brendan
js/src/jsdbgapi.cpp
js/src/jsemit.cpp
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -1237,46 +1237,39 @@ JS_SetDestroyScriptHook(JSRuntime *rt, J
 
 JS_PUBLIC_API(JSBool)
 JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp,
                           const jschar *chars, uintN length,
                           const char *filename, uintN lineno,
                           jsval *rval)
 {
     JSObject *scobj;
-    JSScript *script, *oldscript;
-    JSStackFrame **disp, *displaySave;
+    JSScript *script;
     JSBool ok;
 
     scobj = JS_GetFrameScopeChain(cx, fp);
     if (!scobj)
         return JS_FALSE;
 
-    oldscript = fp->script;
+    /*
+     * NB: This function breaks the assumption that the compiler can see all
+     * calls and properly compute a static depth. In order to get around this,
+     * we use a static depth that will cause us not to attempt to optimize
+     * variable references made by this frame.
+     */
     script = js_CompileScript(cx, scobj, fp, JS_StackFramePrincipals(cx, fp),
                               TCF_COMPILE_N_GO |
-                              TCF_PUT_STATIC_DEPTH(oldscript->staticDepth + 1),
+                              TCF_PUT_STATIC_DEPTH(JS_DISPLAY_SIZE),
                               chars, length, NULL,
                               filename, lineno);
     if (!script)
         return JS_FALSE;
 
-    /* Ensure that the display is up to date for this particular stack frame. */
-    if (oldscript->staticDepth < JS_DISPLAY_SIZE) {
-        disp = &cx->display[oldscript->staticDepth];
-        displaySave = *disp;
-        *disp = fp;
-    } else {
-        disp = NULL;
-        displaySave = NULL;
-    }
     ok = js_Execute(cx, scobj, script, fp, JSFRAME_DEBUGGER | JSFRAME_EVAL,
                     rval);
-    if (disp)
-        *disp = displaySave;
     js_DestroyScript(cx, script);
     return ok;
 }
 
 JS_PUBLIC_API(JSBool)
 JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp,
                         const char *bytes, uintN length,
                         const char *filename, uintN lineno,
--- a/js/src/jsemit.cpp
+++ b/js/src/jsemit.cpp
@@ -1887,17 +1887,17 @@ BindNameToSlot(JSContext *cx, JSCodeGene
                 return JS_TRUE;
 
             /*
              * We are compiling eval or debug script inside a function frame
              * and the scope chain matches function's variable object.
              * Optimize access to function's arguments and variable and the
              * arguments object.
              */
-            if (PN_OP(pn) != JSOP_NAME || cg->staticDepth > JS_DISPLAY_SIZE)
+            if (PN_OP(pn) != JSOP_NAME || cg->staticDepth >= JS_DISPLAY_SIZE)
                 goto arguments_check;
             localKind = js_LookupLocal(cx, caller->fun, atom, &index);
             if (localKind == JSLOCAL_NONE)
                 goto arguments_check;
 
             /*
              * Don't generate upvars on the left side of a for loop. See
              * bug 470758.