Bug 684489 - Fix a strict direct eval bug affecting Google Maps. r=Waldo, a=akeybl.
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 27 Oct 2011 08:58:33 -0500
changeset 79153 6db605a34b15345ac6738ce8db2048782e184640
parent 79152 3c039628db9b12b064e82855fd0c67d7c227801d
child 79154 fde58d9f353986268bf62ddc4f46868a89b40c43
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo, akeybl
bugs684489
milestone9.0a2
Bug 684489 - Fix a strict direct eval bug affecting Google Maps. r=Waldo, a=akeybl.
js/src/jit-test/tests/closures/bug684489.js
js/src/jsparse.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/closures/bug684489.js
@@ -0,0 +1,2 @@
+"use strict";
+eval("var x = {}; ({p: function() { x.m; }}).p();");
--- a/js/src/jsparse.cpp
+++ b/js/src/jsparse.cpp
@@ -2455,17 +2455,27 @@ Parser::setFunctionKinds(JSFunctionBox *
         }
 
         JSFunction *fun = funbox->function();
 
         JS_ASSERT(fun->kind() == JSFUN_INTERPRETED);
 
         if (funbox->tcflags & TCF_FUN_HEAVYWEIGHT) {
             /* nothing to do */
-        } else if (funbox->inAnyDynamicScope()) {
+        } else if (callerFrame || funbox->inAnyDynamicScope()) {
+            /*
+             * Either we are in a with-block or a function scope that is
+             * subject to direct eval; or we are compiling strict direct eval
+             * code.
+             *
+             * In either case, fun may reference names that are not bound but
+             * are not necessarily global either. (In the strict direct eval
+             * case, we could bind them, but currently do not bother; see
+             * the comment about strict mode code in BindTopLevelVar.)
+             */
             JS_ASSERT(!fun->isNullClosure());
         } else {
             bool hasUpvars = false;
             bool canFlatten = true;
 
             if (pn->isKind(TOK_UPVARS)) {
                 AtomDefnMapPtr upvars = pn->pn_names;
                 JS_ASSERT(!upvars->empty());