Bug 488050 - upvar2: incorrect optimization of delete function_name (r=igor).
authorBrendan Eich <brendan@mozilla.org>
Mon, 13 Apr 2009 17:13:21 -0700
changeset 24914 658bca06045609e889f21f469ad3cacaeae3cbf3
parent 24913 4fd30c64c5ed13c68dcf3b86544f7d3ac8b477a4
child 24915 52f12b8b7d5ff8d224d9265994f96f2a58490faa
push id1267
push userrsayre@mozilla.com
push dateSun, 19 Apr 2009 02:47:24 +0000
reviewersigor
bugs488050
milestone1.9.1b4pre
Bug 488050 - upvar2: incorrect optimization of delete function_name (r=igor).
js/src/jsemit.cpp
--- a/js/src/jsemit.cpp
+++ b/js/src/jsemit.cpp
@@ -2219,42 +2219,44 @@ BindNameToSlot(JSContext *cx, JSCodeGene
           case JSOP_DELNAME:  op = JSOP_FALSE; break;
           default: JS_NOT_REACHED("arg");
         }
         JS_ASSERT(!pn->isConst());
         break;
 
       case JSDefinition::VAR:
         if (PN_OP(dn) == JSOP_CALLEE) {
-            JS_ASSERT(cg->fun->flags & JSFUN_LAMBDA && atom == cg->fun->atom);
+            JS_ASSERT(op != JSOP_CALLEE);
+            JS_ASSERT((cg->fun->flags & JSFUN_LAMBDA) && atom == cg->fun->atom);
+
             switch (op) {
-              case JSOP_NAME:
+              case JSOP_DELNAME:
+                if (!(cg->flags & TCF_FUN_HEAVYWEIGHT))
+                    op = JSOP_FALSE;
+                break;
+              default:
                 /*
                  * Leave pn->pn_op == JSOP_NAME if cg->fun is heavyweight, as
                  * we cannot be sure cg->fun is not something of the form:
                  *
                  *   var ff = (function f(s) { eval(s); return f; });
                  *
                  * where a caller invokes ff("var f = 42"). The result returned
                  * for such an invocation must be 42, since the callee name is
                  * lexically bound in an outer declarative environment from the
                  * function's activation. See jsfun.cpp:call_resolve.
                  */
-                if (!(cg->flags & TCF_FUN_HEAVYWEIGHT))
+                if (!(cg->flags & TCF_FUN_HEAVYWEIGHT)) {
                     op = JSOP_CALLEE;
-                break;
-              case JSOP_DELNAME:
-                op = JSOP_FALSE;
-                break;
-              default:
-                op = JSOP_CALLEE;
+                    pn->pn_dflags |= PND_CONST;
+                }
                 break;
             }
             pn->pn_op = op;
-            pn->pn_dflags |= PND_BOUND | PND_CONST;
+            pn->pn_dflags |= PND_BOUND;
             return JS_TRUE;
         }
         /* FALL THROUGH */
 
       default:
         JS_ASSERT_IF(dn_kind != JSDefinition::FUNCTION,
                      dn_kind == JSDefinition::VAR ||
                      dn_kind == JSDefinition::CONST);