Bug 900816 (part 4) - Always use |goto out| in non-error cases in getTokenInternal(). r=till.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 04 Aug 2013 15:29:15 -0700
changeset 153619 9fe517199cd2fcadacede758158b95c4d4d9a539
parent 153618 9a09387c82fc534a4f14dfaaa51278d3ec178e8a
child 153620 359fe5d08d5409d6139bee772c625efd83a44978
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs900816
milestone25.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 900816 (part 4) - Always use |goto out| in non-error cases in getTokenInternal(). r=till.
js/src/frontend/TokenStream.cpp
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -1460,98 +1460,98 @@ TokenStream::getTokenInternal(Modifier m
         if (c == '.') {
             if (matchChar('.')) {
                 tt = TOK_TRIPLEDOT;
                 goto out;
             }
         }
         ungetCharIgnoreEOL(c);
         tt = TOK_DOT;
-        break;
+        goto out;
 
       case '=':
         if (matchChar('='))
             tt = matchChar('=') ? TOK_STRICTEQ : TOK_EQ;
         else if (matchChar('>'))
             tt = TOK_ARROW;
         else
             tt = TOK_ASSIGN;
-        break;
+        goto out;
 
       case '+':
         if (matchChar('+'))
             tt = TOK_INC;
         else
             tt = matchChar('=') ? TOK_ADDASSIGN : TOK_PLUS;
-        break;
+        goto out;
 
       case '\\':
         hadUnicodeEscape = matchUnicodeEscapeIdStart(&qc);
         if (hadUnicodeEscape) {
             identStart = userbuf.addressOfNextRawChar() - 6;
             goto identifier;
         }
         goto badchar;
 
       case '|':
         if (matchChar('|'))
             tt = TOK_OR;
         else
             tt = matchChar('=') ? TOK_BITORASSIGN : TOK_BITOR;
-        break;
+        goto out;
 
       case '^':
         tt = matchChar('=') ? TOK_BITXORASSIGN : TOK_BITXOR;
-        break;
+        goto out;
 
       case '&':
         if (matchChar('&'))
             tt = TOK_AND;
         else
             tt = matchChar('=') ? TOK_BITANDASSIGN : TOK_BITAND;
-        break;
+        goto out;
 
       case '!':
         if (matchChar('='))
             tt = matchChar('=') ? TOK_STRICTNE : TOK_NE;
         else
             tt = TOK_NOT;
-        break;
+        goto out;
 
       case '<':
         /* NB: treat HTML begin-comment as comment-till-end-of-line */
         if (matchChar('!')) {
             if (matchChar('-')) {
                 if (matchChar('-'))
                     goto skipline;
                 ungetChar('-');
             }
             ungetChar('!');
         }
         if (matchChar('<')) {
             tt = matchChar('=') ? TOK_LSHASSIGN : TOK_LSH;
         } else {
             tt = matchChar('=') ? TOK_LE : TOK_LT;
         }
-        break;
+        goto out;
 
       case '>':
         if (matchChar('>')) {
             if (matchChar('>'))
                 tt = matchChar('=') ? TOK_URSHASSIGN : TOK_URSH;
             else
                 tt = matchChar('=') ? TOK_RSHASSIGN : TOK_RSH;
         } else {
             tt = matchChar('=') ? TOK_GE : TOK_GT;
         }
-        break;
+        goto out;
 
       case '*':
         tt = matchChar('=') ? TOK_MULASSIGN : TOK_STAR;
-        break;
+        goto out;
 
       case '/':
         /*
          * Look for a single-line comment.
          */
         if (matchChar('/')) {
             c = peekChar();
             if (c == '@' || c == '#') {
@@ -1643,42 +1643,44 @@ TokenStream::getTokenInternal(Modifier m
                 tp->pos.begin += length + 1;
                 buf[0] = char(c);
                 reportError(JSMSG_BAD_REGEXP_FLAG, buf);
                 (void) getChar();
                 goto error;
             }
             tp->setRegExpFlags(reflags);
             tt = TOK_REGEXP;
-            break;
+            goto out;
         }
 
         tt = matchChar('=') ? TOK_DIVASSIGN : TOK_DIV;
-        break;
+        goto out;
 
       case '%':
         tt = matchChar('=') ? TOK_MODASSIGN : TOK_MOD;
-        break;
+        goto out;
 
       case '-':
         if (matchChar('-')) {
             if (peekChar() == '>' && !flags.isDirtyLine)
                 goto skipline;
             tt = TOK_DEC;
         } else {
             tt = matchChar('=') ? TOK_SUBASSIGN : TOK_MINUS;
         }
-        break;
+        goto out;
 
       badchar:
       default:
         reportError(JSMSG_ILLEGAL_CHARACTER);
         goto error;
     }
 
+    MOZ_ASSUME_UNREACHABLE("should have jumped to |out| or |error|");
+
   out:
     flags.isDirtyLine = true;
     tp->pos.end = userbuf.addressOfNextRawChar() - userbuf.base();
     tp->type = tt;
     JS_ASSERT(IsTokenSane(tp));
     return tt;
 
   error: