bug 486713 - fixing flag propagation to generator expression function. r=brendan
authorIgor Bukanov <igor@mir2.org>
Fri, 10 Apr 2009 20:50:47 +0200
changeset 24905 49234f4a69fb2cfeeea88c3d0c04d3cabca80771
parent 24904 f72986ddc68d249ba4f4d1e627b98a85ea26b2b6
child 24906 ff2552207e39e4bc3fe3110d79fce961c3834fc3
push id1267
push userrsayre@mozilla.com
push dateSun, 19 Apr 2009 02:47:24 +0000
reviewersbrendan
bugs486713
milestone1.9.1b4pre
bug 486713 - fixing flag propagation to generator expression function. r=brendan
js/src/jsemit.h
js/src/jsparse.cpp
--- a/js/src/jsemit.h
+++ b/js/src/jsemit.h
@@ -258,17 +258,17 @@ struct JSTreeContext {              /* t
 #define TCF_COMPILE_N_GO      0x2000 /* compiler-and-go mode of script, can
                                         optimize name references based on scope
                                         chain */
 #define TCF_NO_SCRIPT_RVAL    0x4000 /* API caller does not want result value
                                         from global script */
 #define TCF_HAS_SHARPS        0x8000 /* source contains sharp defs or uses */
 
 /*
- * Flags to propagate from FunctionBody.
+ * Sticky deoptimization flags to propagate from FunctionBody.
  */
 #define TCF_FUN_FLAGS           (TCF_FUN_SETS_OUTER_NAME |                    \
                                  TCF_FUN_USES_ARGUMENTS  |                    \
                                  TCF_FUN_PARAM_ARGUMENTS |                    \
                                  TCF_FUN_HEAVYWEIGHT     |                    \
                                  TCF_FUN_IS_GENERATOR    |                    \
                                  TCF_FUN_IS_FUNARG       |                    \
                                  TCF_HAS_SHARPS)
--- a/js/src/jsparse.cpp
+++ b/js/src/jsparse.cpp
@@ -6400,19 +6400,25 @@ GeneratorExpr(JSParseNode *pn, JSParseNo
 
     {
         JSTreeContext gentc(tc->compiler);
 
         JSFunctionBox *funbox = EnterFunction(genfn, tc, &gentc);
         if (!funbox)
             return NULL;
 
-        gentc.flags |= TCF_FUN_IS_GENERATOR | TCF_GENEXP_LAMBDA;
-        if (tc->flags & TCF_HAS_SHARPS)
-            gentc.flags |= TCF_HAS_SHARPS;
+        /*
+         * We assume conservatively that any deoptimization flag in tc->flags
+         * besides TCF_FUN_PARAM_ARGUMENTS can come from the kid. So we
+         * propagate these flags into genfn. For code simplicity we also do
+         * not detect if the flags were only set in the kid and could be
+         * removed from tc->flags.
+         */
+        gentc.flags |= TCF_FUN_IS_GENERATOR | TCF_GENEXP_LAMBDA |
+                       (tc->flags & (TCF_FUN_FLAGS & ~TCF_FUN_PARAM_ARGUMENTS));
         funbox->tcflags |= gentc.flags;
         genfn->pn_funbox = funbox;
         genfn->pn_blockid = gentc.bodyid;
 
         JSParseNode *body = ComprehensionTail(pn, tc->blockid(), &gentc);
         if (!body)
             return NULL;
         JS_ASSERT(!genfn->pn_body);