Don't optimize variable names in with statements. bug 448595, r=brendan
authorBlake Kaplan <mrbkap@gmail.com>
Mon, 04 Aug 2008 10:07:06 -0700
changeset 16359 e77eb4c403ce52a8c48eb8f6c7ecc3ee4b5e250f
parent 16358 f01bfd3595951b5e9e4a607ab56a71621e3e3cf0
child 16360 cba48512577ad9273ba603f3fd5b9e85c94b826e
push idunknown
push userunknown
push dateunknown
reviewersbrendan
bugs448595
milestone1.9.1a2pre
Don't optimize variable names in with statements. bug 448595, r=brendan
js/src/jsemit.cpp
--- a/js/src/jsemit.cpp
+++ b/js/src/jsemit.cpp
@@ -1838,18 +1838,17 @@ BindNameToSlot(JSContext *cx, JSCodeGene
     /*
      * We can't optimize if we are compiling a with statement and its body,
      * or we're in a catch block whose exception variable has the same name
      * as this node.  FIXME: we should be able to optimize catch vars to be
      * block-locals.
      */
     tc = &cg->treeContext;
     atom = pn->pn_atom;
-    if (declType != VAR_DECL &&
-        (stmt = js_LexicalLookup(tc, atom, &slot, declType))) {
+    if ((stmt = js_LexicalLookup(tc, atom, &slot, declType))) {
         if (stmt->type == STMT_WITH)
             return JS_TRUE;
 
         JS_ASSERT(stmt->flags & SIF_SCOPE);
         JS_ASSERT(slot >= 0);
         op = PN_OP(pn);
         switch (op) {
           case JSOP_NAME:     op = JSOP_GETLOCAL; break;
@@ -1880,24 +1879,17 @@ BindNameToSlot(JSContext *cx, JSCodeGene
     if (tc->flags & TCF_FUN_CLOSURE_VS_VAR)
         return JS_TRUE;
 
     if (!(tc->flags & TCF_IN_FUNCTION) &&
         !((cx->fp->flags & JSFRAME_SPECIAL) && cx->fp->fun)) {
         /*
          * We are compiling a script or eval, and eval is not inside a function
          * activation.
-         *
-         * We can't optimize if this name use is within a with statement in
-         * the same compilation unit, or if the compiler was invoked by eval
-         * called inside a with statement in its caller.
          */
-        if (js_InWithStatement(tc))
-            return JS_TRUE;
-
         fp = cx->fp;
         if (fp->scopeChain != fp->varobj)
             return JS_TRUE;
 
         /*
          * A Script object can be used to split an eval into a compile step
          * done at construction time, and an execute step done separately,
          * possibly in a different scope altogether.  We therefore cannot do