Bug 470758 - Don't generate upvars on the left side of a for-in loop. r=brendan
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 23 Dec 2008 15:45:44 -0800
changeset 23121 09997a70e4fbfea8cd3e7abcf98846605b62b244
parent 23120 88d865ffd0a9b394d429c9092aa588777ce7712d
child 23122 edd031c8937cbac552518b9e8c7b13b4e2fbfa12
push id4346
push userrsayre@mozilla.com
push dateFri, 26 Dec 2008 01:26:36 +0000
treeherdermozilla-central@8eb5a5b83a93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbrendan
bugs470758
milestone1.9.2a1pre
Bug 470758 - Don't generate upvars on the left side of a for-in loop. r=brendan
js/src/jsemit.cpp
--- a/js/src/jsemit.cpp
+++ b/js/src/jsemit.cpp
@@ -1871,17 +1871,18 @@ BindNameToSlot(JSContext *cx, JSCodeGene
     /*
      * We can't optimize if var and closure (a local function not in a larger
      * expression and not at top-level within another's body) collide.
      * XXX suboptimal: keep track of colliding names and deoptimize only those
      */
     if (tc->flags & TCF_FUN_CLOSURE_VS_VAR)
         return JS_TRUE;
 
-    if (!(tc->flags & TCF_IN_FUNCTION)) {
+    /* Don't generate upvars on the left side of a for loop. See bug 470758. */
+    if (!(tc->flags & (TCF_IN_FUNCTION | TCF_IN_FOR_INIT))) {
         JSStackFrame *caller;
 
         caller = tc->parseContext->callerFrame;
         if (caller) {
             JS_ASSERT(tc->flags & TCF_COMPILE_N_GO);
             JS_ASSERT(caller->script);
             if (!caller->fun || caller->varobj != tc->u.scopeChain)
                 return JS_TRUE;