Bug 1459384 - Explicitly pass to FinishToken the two non-|this| captures it currently has. r=arai
authorJeff Walden <jwalden@mit.edu>
Thu, 03 May 2018 22:02:32 -0700
changeset 417666 6393d31a33bc86770b6f6a0d6d2673f139a7ed71
parent 417665 db1d9e0147f70f7acd06869fe409e3726e1cc95e
child 417667 a959c06847baa3194ab9d9af0bcbc93a283feaf8
push id33977
push userncsoregi@mozilla.com
push dateThu, 10 May 2018 16:43:24 +0000
treeherdermozilla-central@17db33b6a124 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1459384
milestone62.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 1459384 - Explicitly pass to FinishToken the two non-|this| captures it currently has. r=arai
js/src/frontend/TokenStream.cpp
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -1641,22 +1641,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
 template<typename CharT, class AnyCharsAccess>
 MOZ_MUST_USE bool
 TokenStreamSpecific<CharT, AnyCharsAccess>::getTokenInternal(TokenKind* const ttp,
                                                              const Modifier modifier)
 {
     // Assume we'll fail.  Success cases will overwrite this in |FinishToken|.
     MOZ_MAKE_MEM_UNDEFINED(ttp, sizeof(*ttp));
 
-    auto FinishToken = [this,
-#ifdef DEBUG
-                        &modifier,
-#endif
-                        ttp](Token* tp)
-    {
+    auto FinishToken = [this](TokenKind* ttp, Modifier modifier, Token* tp) {
         this->anyCharsAccess().flags.isDirtyLine = true;
         tp->pos.end = this->sourceUnits.offset();
 #ifdef DEBUG
         // Save the modifier used to get this token, so that if an ungetToken()
         // occurs and then the token is re-gotten (or peeked, etc.), we can assert
         // that both gets have used the same modifiers.
         tp->modifier = modifier;
         tp->modifierException = NoException;
@@ -1667,29 +1662,29 @@ TokenStreamSpecific<CharT, AnyCharsAcces
 
     // Check if in the middle of a template string. Have to get this out of
     // the way first.
     if (MOZ_UNLIKELY(modifier == TemplateTail)) {
         Token* tp;
         if (!getStringOrTemplateToken('`', &tp))
             return false;
 
-        FinishToken(tp);
+        FinishToken(ttp, modifier, tp);
         return true;
     }
 
     // This loop runs more than once only when whitespace or comments are
     // encountered.
     do {
         if (MOZ_UNLIKELY(!sourceUnits.hasRawChars())) {
             TokenStart start(sourceUnits, 0);
             Token* tp = newToken(start);
             tp->type = TokenKind::Eof;
             anyCharsAccess().flags.isEOF = true;
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
         }
 
         int c = sourceUnits.getCodeUnit();
         MOZ_ASSERT(c != EOF);
 
         // Chars not in the range 0..127 are rare.  Getting them out of the way
         // early allows subsequent checking to be faster.
@@ -1722,29 +1717,29 @@ TokenStreamSpecific<CharT, AnyCharsAcces
             static_assert('_' < 128,
                           "IdentifierStart contains '_', but as "
                           "!IsUnicodeIDStart('_'), ensure that '_' is never "
                           "handled here");
             if (unicode::IsUnicodeIDStart(char16_t(c))) {
                 if (!identifierName(tp, identStart, IdentifierEscapes::None))
                     return false;
 
-                FinishToken(tp);
+                FinishToken(ttp, modifier, tp);
                 return true;
             }
 
             uint32_t codePoint = c;
             if (!matchMultiUnitCodePoint(c, &codePoint))
                 return badToken();
 
             if (codePoint && unicode::IsUnicodeIDStart(codePoint)) {
                 if (!identifierName(tp, identStart, IdentifierEscapes::None))
                     return false;
 
-                FinishToken(tp);
+                FinishToken(ttp, modifier, tp);
                 return true;
             }
 
             ungetCodePointIgnoreEOL(codePoint);
             error(JSMSG_ILLEGAL_CHARACTER);
             return badToken();
         }
 
@@ -1770,17 +1765,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
         FirstCharKind c1kind = FirstCharKind(firstCharKinds[c]);
 
         // Look for an unambiguous single-char token.
         //
         if (c1kind <= OneChar_Max) {
             TokenStart start(sourceUnits, -1);
             Token* tp = newToken(start);
             tp->type = TokenKind(c1kind);
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
         }
 
         // Skip over non-EOL whitespace chars.
         //
         if (c1kind == Space)
             continue;
 
@@ -1791,42 +1786,42 @@ TokenStreamSpecific<CharT, AnyCharsAcces
             Token* tp = newToken(start);
 
             if (!identifierName(tp, sourceUnits.addressOfNextCodeUnit() - 1,
                                 IdentifierEscapes::None))
             {
                 return false;
             }
 
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
         }
 
         // Look for a decimal number.
         //
         if (c1kind == Dec) {
             TokenStart start(sourceUnits, -1);
             Token* tp = newToken(start);
 
             const CharT* numStart = sourceUnits.addressOfNextCodeUnit() - 1;
             if (!decimalNumber(c, tp, numStart))
                 return false;
 
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
         }
 
         // Look for a string or a template string.
         //
         if (c1kind == String) {
             Token* tp;
             if (!getStringOrTemplateToken(static_cast<char>(c), &tp))
                 return false;
 
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
         }
 
         // Skip over EOL chars, updating line state along the way.
         //
         if (c1kind == EOL) {
             // If it's a \r\n sequence: consume it and treat itas a single EOL.
             if (c == '\r' && sourceUnits.hasRawChars())
@@ -1910,30 +1905,30 @@ TokenStreamSpecific<CharT, AnyCharsAcces
                     if (c >= '8') {
                         if (!warning(JSMSG_BAD_OCTAL, c == '8' ? "08" : "09"))
                             return badToken();
 
                         // Use the decimal scanner for the rest of the number.
                         if (!decimalNumber(c, tp, numStart))
                             return false;
 
-                        FinishToken(tp);
+                        FinishToken(ttp, modifier, tp);
                         return true;
                     }
 
                     c = getCharIgnoreEOL();
                 } while (IsAsciiDigit(c));
             } else {
                 // '0' not followed by [XxBbOo0-9];  scan as a decimal number.
                 numStart = sourceUnits.addressOfNextCodeUnit() - 1;
 
                 if (!decimalNumber(c, tp, numStart))
                     return false;
 
-                FinishToken(tp);
+                FinishToken(ttp, modifier, tp);
                 return true;
             }
             ungetCharIgnoreEOL(c);
 
             if (c != EOF) {
                 if (unicode::IsIdentifierStart(char16_t(c))) {
                     error(JSMSG_IDSTART_AFTER_NUMBER);
                     return badToken();
@@ -1967,17 +1962,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
             if (!GetPrefixInteger(anyCharsAccess().cx, numStart,
                                   sourceUnits.addressOfNextCodeUnit(), radix, &dummy, &dval))
             {
                 return badToken();
             }
 
             tp->type = TokenKind::Number;
             tp->setNumber(dval, NoDecimal);
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
         }
 
         // This handles everything else.
         //
         MOZ_ASSERT(c1kind == Other);
         TokenStart start(sourceUnits, -1);
         Token* tp = newToken(start);
@@ -1985,60 +1980,60 @@ TokenStreamSpecific<CharT, AnyCharsAcces
           case '.':
             c = getCharIgnoreEOL();
             if (IsAsciiDigit(c)) {
                 const CharT* numStart = sourceUnits.addressOfNextCodeUnit() - 2;
 
                 if (!decimalNumber('.', tp, numStart))
                     return false;
 
-                FinishToken(tp);
+                FinishToken(ttp, modifier, tp);
                 return true;
             }
 
             if (c == '.') {
                 if (matchChar('.')) {
                     tp->type = TokenKind::TripleDot;
-                    FinishToken(tp);
+                    FinishToken(ttp, modifier, tp);
                     return true;
                 }
             }
             ungetCharIgnoreEOL(c);
             tp->type = TokenKind::Dot;
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '=':
             if (matchChar('='))
                 tp->type = matchChar('=') ? TokenKind::StrictEq : TokenKind::Eq;
             else if (matchChar('>'))
                 tp->type = TokenKind::Arrow;
             else
                 tp->type = TokenKind::Assign;
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '+':
             if (matchChar('+'))
                 tp->type = TokenKind::Inc;
             else
                 tp->type = matchChar('=') ? TokenKind::AddAssign : TokenKind::Add;
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '\\': {
             uint32_t qc;
             if (uint32_t escapeLength = matchUnicodeEscapeIdStart(&qc)) {
                 if (!identifierName(tp, sourceUnits.addressOfNextCodeUnit() - escapeLength - 1,
                                     IdentifierEscapes::SawUnicodeEscape))
                 {
                     return false;
                 }
 
-                FinishToken(tp);
+                FinishToken(ttp, modifier, tp);
                 return true;
             }
 
             // We could point "into" a mistyped escape, e.g. for "\u{41H}" we
             // could point at the 'H'.  But we don't do that now, so the
             // character after the '\' isn't necessarily bad, so just point at
             // the start of the actually-invalid escape.
             ungetCharIgnoreEOL('\\');
@@ -2050,38 +2045,38 @@ TokenStreamSpecific<CharT, AnyCharsAcces
             if (matchChar('|'))
                 tp->type = TokenKind::Or;
 #ifdef ENABLE_PIPELINE_OPERATOR
             else if (matchChar('>'))
                 tp->type = TokenKind::Pipeline;
 #endif
             else
                 tp->type = matchChar('=') ? TokenKind::BitOrAssign : TokenKind::BitOr;
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '^':
             tp->type = matchChar('=') ? TokenKind::BitXorAssign : TokenKind::BitXor;
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '&':
             if (matchChar('&'))
                 tp->type = TokenKind::And;
             else
                 tp->type = matchChar('=') ? TokenKind::BitAndAssign : TokenKind::BitAnd;
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '!':
             if (matchChar('='))
                 tp->type = matchChar('=') ? TokenKind::StrictNe : TokenKind::Ne;
             else
                 tp->type = TokenKind::Not;
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '<':
             if (anyCharsAccess().options().allowHTMLComments) {
                 // Treat HTML begin-comment as comment-till-end-of-line.
                 if (matchChar('!')) {
                     if (matchChar('-')) {
                         if (matchChar('-')) {
@@ -2093,37 +2088,37 @@ TokenStreamSpecific<CharT, AnyCharsAcces
                     ungetCharIgnoreEOL('!');
                 }
             }
             if (matchChar('<')) {
                 tp->type = matchChar('=') ? TokenKind::LshAssign : TokenKind::Lsh;
             } else {
                 tp->type = matchChar('=') ? TokenKind::Le : TokenKind::Lt;
             }
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '>':
             if (matchChar('>')) {
                 if (matchChar('>'))
                     tp->type = matchChar('=') ? TokenKind::UrshAssign : TokenKind::Ursh;
                 else
                     tp->type = matchChar('=') ? TokenKind::RshAssign : TokenKind::Rsh;
             } else {
                 tp->type = matchChar('=') ? TokenKind::Ge : TokenKind::Gt;
             }
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '*':
             if (matchChar('*'))
                 tp->type = matchChar('=') ? TokenKind::PowAssign : TokenKind::Pow;
             else
                 tp->type = matchChar('=') ? TokenKind::MulAssign : TokenKind::Mul;
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '/':
             // Look for a single-line comment.
             if (matchChar('/')) {
                 c = getCharIgnoreEOL();
                 if (c == '@' || c == '#') {
                     bool shouldWarn = c == '@';
@@ -2228,27 +2223,27 @@ TokenStreamSpecific<CharT, AnyCharsAcces
                     }
 
                     reflags = RegExpFlag(reflags | flag);
                 }
                 ungetCharIgnoreEOL(c);
 
                 tp->type = TokenKind::RegExp;
                 tp->setRegExpFlags(reflags);
-                FinishToken(tp);
+                FinishToken(ttp, modifier, tp);
                 return true;
             }
 
             tp->type = matchChar('=') ? TokenKind::DivAssign : TokenKind::Div;
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '%':
             tp->type = matchChar('=') ? TokenKind::ModAssign : TokenKind::Mod;
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           case '-':
             if (matchChar('-')) {
                 if (anyCharsAccess().options().allowHTMLComments &&
                     !anyCharsAccess().flags.isDirtyLine)
                 {
                     if (matchChar('>')) {
@@ -2256,17 +2251,17 @@ TokenStreamSpecific<CharT, AnyCharsAcces
                         continue;
                     }
                 }
 
                 tp->type = TokenKind::Dec;
             } else {
                 tp->type = matchChar('=') ? TokenKind::SubAssign : TokenKind::Sub;
             }
-            FinishToken(tp);
+            FinishToken(ttp, modifier, tp);
             return true;
 
           default:
             // We consumed a bad character/code point.  Put it back so the
             // error location is the bad character.
             ungetCodePointIgnoreEOL(c);
             error(JSMSG_ILLEGAL_CHARACTER);
             return badToken();