Bug 670784 - Add src note to break statements of switches, r=dvander
authorHannes Verschore <hverschore@mozilla.com>
Wed, 13 Jul 2011 16:12:05 -0700
changeset 72791 1d8cd6c280937369a49849ba01a0aafe0fc8b3a5
parent 72790 abe8569eca76967edcb33f65ea2c8077411beb02
child 72792 b0e78342786e31debe7f5fc0046a50c8c5aa1a05
push id20772
push usereakhgari@mozilla.com
push dateThu, 14 Jul 2011 16:20:50 +0000
treeherdermozilla-central@89b5fccb0514 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs670784
milestone8.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 670784 - Add src note to break statements of switches, r=dvander
js/src/jsemit.cpp
js/src/jsemit.h
js/src/shell/js.cpp
--- a/js/src/jsemit.cpp
+++ b/js/src/jsemit.cpp
@@ -5362,17 +5362,17 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
 
             while (stmt->type != STMT_LABEL || stmt->label != atom)
                 stmt = stmt->down;
             noteType = SRC_BREAK2LABEL;
         } else {
             labelIndex = INVALID_ATOMID;
             while (!STMT_IS_LOOP(stmt) && stmt->type != STMT_SWITCH)
                 stmt = stmt->down;
-            noteType = (stmt->type == STMT_SWITCH) ? SRC_NULL : SRC_BREAK;
+            noteType = (stmt->type == STMT_SWITCH) ? SRC_SWITCHBREAK : SRC_BREAK;
         }
 
         if (EmitGoto(cx, cg, stmt, &stmt->breaks, labelIndex, noteType) < 0)
             return JS_FALSE;
         break;
       }
 
       case TOK_CONTINUE: {
--- a/js/src/jsemit.h
+++ b/js/src/jsemit.h
@@ -974,16 +974,17 @@ typedef enum JSSrcNoteType {
                                    bytecode -- always a backward delta */
     SRC_LABEL       = 13,       /* JSOP_NOP for label: with atomid immediate */
     SRC_LABELBRACE  = 14,       /* JSOP_NOP for label: {...} begin brace */
     SRC_ENDBRACE    = 15,       /* JSOP_NOP for label: {...} end brace */
     SRC_BREAK2LABEL = 16,       /* JSOP_GOTO for 'break label' with atomid */
     SRC_CONT2LABEL  = 17,       /* JSOP_GOTO for 'continue label' with atomid */
     SRC_SWITCH      = 18,       /* JSOP_*SWITCH with offset to end of switch,
                                    2nd off to first JSOP_CASE if condswitch */
+    SRC_SWITCHBREAK = 18,       /* JSOP_GOTO is a break in a switch */
     SRC_FUNCDEF     = 19,       /* JSOP_NOP for function f() with atomid */
     SRC_CATCH       = 20,       /* catch block has guard */
     SRC_EXTENDED    = 21,       /* extended source note, 32-159, in next byte */
     SRC_NEWLINE     = 22,       /* bytecode follows a source newline */
     SRC_SETLINE     = 23,       /* a file-absolute source line number note */
     SRC_XDELTA      = 24        /* 24-31 are for extended delta notes */
 } JSSrcNoteType;
 
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2208,16 +2208,18 @@ SrcNotes(JSContext *cx, JSScript *script
             str = JS_DecompileFunction(cx, fun, JS_DONT_PRETTY_PRINT);
             JSAutoByteString bytes;
             if (!str || !bytes.encode(cx, str))
                 ReportException(cx);
             Sprint(sp, " function %u (%s)", index, !!bytes ? bytes.ptr() : "N/A");
             break;
           }
           case SRC_SWITCH:
+            if (js_GetOpcode(cx, script, script->code + offset) == JSOP_GOTO)
+                break;
             Sprint(sp, " length %u", uintN(js_GetSrcNoteOffset(sn, 0)));
             caseOff = (uintN) js_GetSrcNoteOffset(sn, 1);
             if (caseOff)
                 Sprint(sp, " first case offset %u", caseOff);
             UpdateSwitchTableBounds(cx, script, offset,
                                     &switchTableStart, &switchTableEnd);
             break;
           case SRC_CATCH: