Bug 524564 - "Assertion failure: 0, at ../jsopcode.cpp" with uneval, yield, do...while. r=dvander.
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 30 Oct 2009 14:56:10 -0500
changeset 34559 bd1b0c451b85d1e177ce0a775cc491fe7e35ad12
parent 34558 d7195659a30a9890c56574a907b4271d1c32299e
child 34560 8a8573ae1227452f1d6989b3b838b7156378f3bb
push idunknown
push userunknown
push dateunknown
reviewersdvander
bugs524564
milestone1.9.3a1pre
Bug 524564 - "Assertion failure: 0, at ../jsopcode.cpp" with uneval, yield, do...while. r=dvander.
js/src/jsopcode.cpp
js/src/tests/js1_8_1/regress/jstests.list
js/src/tests/js1_8_1/regress/regress-524264.js
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -4964,36 +4964,44 @@ js_DecompileFunction(JSPrinter *jp)
 
     if (!FUN_INTERPRETED(fun)) {
         js_printf(jp, ") {\n");
         jp->indent += 4;
         js_printf(jp, native_code_str);
         jp->indent -= 4;
         js_printf(jp, "\t}");
     } else {
+        JSScript *script = fun->u.i.script;
 #if JS_HAS_DESTRUCTURING
         SprintStack ss;
         void *mark;
 #endif
 
         /* Print the parameters. */
-        pc = fun->u.i.script->main;
-        endpc = pc + fun->u.i.script->length;
+        pc = script->main;
+        endpc = pc + script->length;
         ok = JS_TRUE;
 
+        /* Skip trace hint if it appears here. */
+#if JS_HAS_GENERATORS
+        if (js_GetOpcode(jp->sprinter.context, script, script->code) != JSOP_GENERATOR)
+#endif
+        {
+            JSOp op = js_GetOpcode(jp->sprinter.context, script, pc);
+            if (op == JSOP_TRACE || op == JSOP_NOP) {
+                JS_STATIC_ASSERT(JSOP_TRACE_LENGTH == JSOP_NOP_LENGTH);
+                pc += JSOP_TRACE_LENGTH;
+            } else {
+                JS_ASSERT(op == JSOP_STOP);  /* empty script singleton */
+            }
+        }
+
 #if JS_HAS_DESTRUCTURING
-        /* Skip trace hint if it appears here. */
-        JSOp op = js_GetOpcode(jp->sprinter.context, fun->u.i.script, pc);
-        if (op == JSOP_TRACE || op == JSOP_NOP) {
-            JS_STATIC_ASSERT(JSOP_TRACE_LENGTH == JSOP_NOP_LENGTH);
-            pc += JSOP_TRACE_LENGTH;
-        }
-
         ss.printer = NULL;
-        jp->script = fun->u.i.script;
+        jp->script = script;
         mark = JS_ARENA_MARK(&jp->sprinter.context->tempPool);
 #endif
 
         for (i = 0; i < fun->nargs; i++) {
             if (i > 0)
                 js_puts(jp, ", ");
 
             param = GetArgOrVarAtom(jp, i);
@@ -5004,18 +5012,17 @@ js_DecompileFunction(JSPrinter *jp)
             if (!param) {
                 ptrdiff_t todo;
                 const char *lval;
 
                 LOCAL_ASSERT(*pc == JSOP_GETARG);
                 pc += JSOP_GETARG_LENGTH;
                 LOCAL_ASSERT(*pc == JSOP_DUP);
                 if (!ss.printer) {
-                    ok = InitSprintStack(jp->sprinter.context, &ss, jp,
-                                         StackDepth(fun->u.i.script));
+                    ok = InitSprintStack(jp->sprinter.context, &ss, jp, StackDepth(script));
                     if (!ok)
                         break;
                 }
                 pc = DecompileDestructuring(&ss, pc, endpc);
                 if (!pc) {
                     ok = JS_FALSE;
                     break;
                 }
@@ -5047,18 +5054,18 @@ js_DecompileFunction(JSPrinter *jp)
             return JS_FALSE;
         if (fun->flags & JSFUN_EXPR_CLOSURE) {
             js_printf(jp, ") ");
         } else {
             js_printf(jp, ") {\n");
             jp->indent += 4;
         }
 
-        len = fun->u.i.script->code + fun->u.i.script->length - pc;
-        ok = DecompileCode(jp, fun->u.i.script, pc, (uintN)len, 0);
+        len = script->code + script->length - pc;
+        ok = DecompileCode(jp, script, pc, (uintN)len, 0);
         if (!ok)
             return JS_FALSE;
 
         if (!(fun->flags & JSFUN_EXPR_CLOSURE)) {
             jp->indent -= 4;
             js_printf(jp, "\t}");
         }
     }
--- a/js/src/tests/js1_8_1/regress/jstests.list
+++ b/js/src/tests/js1_8_1/regress/jstests.list
@@ -76,8 +76,9 @@ script regress-479430-05.js
 script regress-495773.js
 script regress-495907.js
 script regress-496922.js
 script regress-507053.js
 script regress-507295.js
 script regress-507424.js
 script regress-515885.js
 skip-if(isDebugBuild&&!xulRuntime.shell)  script regress-524743.js # hang
+script regress-524264.js
new file mode 100644
--- /dev/null
+++ b/js/src/tests/js1_8_1/regress/regress-524264.js
@@ -0,0 +1,8 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ * Contributor: Jason Orendorff
+ */
+gTestfile = 'regress-524264';
+uneval(function () { do yield; while (0); });
+reportCompare("no assertion failure", "no assertion failure", "bug 524264");