Bug 855088 - Watch for 'arguments' variables declared within 'with' blocks, r=luke.
authorBrian Hackett <bhackett1024@gmail.com>
Thu, 11 Apr 2013 16:19:10 -0600
changeset 128509 e329fecc259f3faee932f5efb0fa30c6cce880ca
parent 128508 9688317ad779f024e8b0eb436ffc2d6cc87a4bb4
child 128510 1d30583cd42f1fa48ac45cfc0b7f8ae0422b4244
push id26350
push userbhackett@mozilla.com
push dateThu, 11 Apr 2013 22:19:20 +0000
treeherdermozilla-inbound@e329fecc259f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs855088
milestone23.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 855088 - Watch for 'arguments' variables declared within 'with' blocks, r=luke.
js/src/frontend/Parser.cpp
js/src/jit-test/tests/basic/bug855088.js
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -2488,18 +2488,30 @@ Parser<FullParseHandler>::bindVarOrConst
 
     if (!parser->checkStrictBinding(name, pn))
         return false;
 
     StmtInfoPC *stmt = LexicalLookup(pc, name, NULL, (StmtInfoPC *)NULL);
 
     if (stmt && stmt->type == STMT_WITH) {
         pn->pn_dflags |= PND_DEOPTIMIZED;
-        if (pc->sc->isFunctionBox())
-            pc->sc->asFunctionBox()->setMightAliasLocals();
+        if (pc->sc->isFunctionBox()) {
+            FunctionBox *funbox = pc->sc->asFunctionBox();
+            funbox->setMightAliasLocals();
+
+            /*
+             * This definition isn't being added to the parse context's
+             * declarations, so make sure to indicate the need to deoptimize
+             * the script's arguments object.
+             */
+            if (name == cx->names().arguments) {
+                funbox->setArgumentsHasLocalBinding();
+                funbox->setDefinitelyNeedsArgsObj();
+            }
+        }
         return true;
     }
 
     DefinitionList::Range defs = pc->decls().lookupMulti(name);
     JS_ASSERT_IF(stmt, !defs.empty());
 
     if (defs.empty())
         return pc->define(cx, name, pn, isConstDecl ? Definition::CONST : Definition::VAR);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug855088.js
@@ -0,0 +1,5 @@
+
+(function (y) {
+    arguments.y = 2;
+    with (0) var arguments=5;    
+})(1);