Ignore:
Timestamp:
May 22, 2019, 2:52:58 PM (6 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling out r245634.
https://bugs.webkit.org/show_bug.cgi?id=198140

'This patch makes JSC crash on launch in debug builds'
(Requested by tadeuzagallo on #webkit).

Reverted changeset:

"[ESNext] Implement support for Numeric Separators"
https://bugs.webkit.org/show_bug.cgi?id=196351
https://trac.webkit.org/changeset/245634

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r245634 r245648  
    814814}
    815815
    816 template<typename CharacterType>
    817 static inline bool isASCIIDigitOrSeparator(CharacterType character)
    818 {
    819     return isASCIIDigit(character) || character == '_';
    820 }
    821 
    822 template<typename CharacterType>
    823 static inline bool isASCIIHexDigitOrSeparator(CharacterType character)
    824 {
    825     return isASCIIHexDigit(character) || character == '_';
    826 }
    827 
    828 template<typename CharacterType>
    829 static inline bool isASCIIBinaryDigitOrSeparator(CharacterType character)
    830 {
    831     return isASCIIBinaryDigit(character) || character == '_';
    832 }
    833 
    834 template<typename CharacterType>
    835 static inline bool isASCIIOctalDigitOrSeparator(CharacterType character)
    836 {
    837     return isASCIIOctalDigit(character) || character == '_';
    838 }
    839 
    840816static inline LChar singleEscape(int c)
    841817{
     
    15151491
    15161492template <typename T>
    1517 ALWAYS_INLINE auto Lexer<T>::parseHex() -> Optional<NumberParseResult>
    1518 {
    1519     ASSERT(isASCIIHexDigit(m_current));
    1520 
     1493ALWAYS_INLINE auto Lexer<T>::parseHex() -> NumberParseResult
     1494{
    15211495    // Optimization: most hexadecimal values fit into 4 bytes.
    15221496    uint32_t hexValue = 0;
     
    15241498
    15251499    do {
    1526         if (m_current == '_') {
    1527             if (UNLIKELY(!isASCIIHexDigit(peek(1))))
    1528                 return WTF::nullopt;
    1529 
    1530             shift();
    1531         }
    1532 
    15331500        hexValue = (hexValue << 4) + toASCIIHexValue(m_current);
    15341501        shift();
    15351502        --maximumDigits;
    1536     } while (isASCIIHexDigitOrSeparator(m_current) && maximumDigits >= 0);
     1503    } while (isASCIIHexDigit(m_current) && maximumDigits >= 0);
    15371504
    15381505    if (LIKELY(maximumDigits >= 0 && m_current != 'n'))
    1539         return NumberParseResult { hexValue };
     1506        return hexValue;
    15401507
    15411508    // No more place in the hexValue buffer.
     
    15501517    }
    15511518
    1552     while (isASCIIHexDigitOrSeparator(m_current)) {
    1553         if (m_current == '_') {
    1554             if (UNLIKELY(!isASCIIHexDigit(peek(1))))
    1555                 return WTF::nullopt;
    1556 
    1557             shift();
    1558         }
    1559 
     1519    while (isASCIIHexDigit(m_current)) {
    15601520        record8(m_current);
    15611521        shift();
     
    15631523
    15641524    if (UNLIKELY(Options::useBigInt() && m_current == 'n'))
    1565         return NumberParseResult { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
     1525        return makeIdentifier(m_buffer8.data(), m_buffer8.size());
    15661526   
    1567     return NumberParseResult { parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 16) };
     1527    return parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 16);
    15681528}
    15691529
     
    15711531ALWAYS_INLINE auto Lexer<T>::parseBinary() -> Optional<NumberParseResult>
    15721532{
    1573     ASSERT(isASCIIBinaryDigit(m_current));
    1574 
    15751533    // Optimization: most binary values fit into 4 bytes.
    15761534    uint32_t binaryValue = 0;
     
    15821540
    15831541    do {
    1584         if (m_current == '_') {
    1585             if (UNLIKELY(!isASCIIBinaryDigit(peek(1))))
    1586                 return WTF::nullopt;
    1587 
    1588             shift();
    1589         }
    1590 
    15911542        binaryValue = (binaryValue << 1) + (m_current - '0');
    15921543        digits[digit] = m_current;
    15931544        shift();
    15941545        --digit;
    1595     } while (isASCIIBinaryDigitOrSeparator(m_current) && digit >= 0);
    1596 
    1597     if (LIKELY(!isASCIIDigitOrSeparator(m_current) && digit >= 0 && m_current != 'n'))
    1598         return NumberParseResult { binaryValue };
     1546    } while (isASCIIBinaryDigit(m_current) && digit >= 0);
     1547
     1548    if (LIKELY(!isASCIIDigit(m_current) && digit >= 0 && m_current != 'n'))
     1549        return Variant<double, const Identifier*> { binaryValue };
    15991550
    16001551    for (int i = maximumDigits - 1; i > digit; --i)
    16011552        record8(digits[i]);
    16021553
    1603     while (isASCIIBinaryDigitOrSeparator(m_current)) {
    1604         if (m_current == '_') {
    1605             if (UNLIKELY(!isASCIIBinaryDigit(peek(1))))
    1606                 return WTF::nullopt;
    1607 
    1608             shift();
    1609         }
    1610 
     1554    while (isASCIIBinaryDigit(m_current)) {
    16111555        record8(m_current);
    16121556        shift();
     
    16141558
    16151559    if (UNLIKELY(Options::useBigInt() && m_current == 'n'))
    1616         return NumberParseResult { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
     1560        return Variant<double, const Identifier*> { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
    16171561
    16181562    if (isASCIIDigit(m_current))
    16191563        return WTF::nullopt;
    16201564
    1621     return NumberParseResult { parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 2) };
     1565    return Variant<double, const Identifier*> { parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 2) };
    16221566}
    16231567
     
    16251569ALWAYS_INLINE auto Lexer<T>::parseOctal() -> Optional<NumberParseResult>
    16261570{
    1627     ASSERT(isASCIIOctalDigit(m_current));
    1628 
    16291571    // Optimization: most octal values fit into 4 bytes.
    16301572    uint32_t octalValue = 0;
     
    16361578
    16371579    do {
    1638         if (m_current == '_') {
    1639             if (UNLIKELY(!isASCIIOctalDigit(peek(1))))
    1640                 return WTF::nullopt;
    1641 
    1642             shift();
    1643         }
    1644 
    16451580        octalValue = octalValue * 8 + (m_current - '0');
    16461581        digits[digit] = m_current;
    16471582        shift();
    16481583        --digit;
    1649     } while (isASCIIOctalDigitOrSeparator(m_current) && digit >= 0);
    1650 
    1651     if (LIKELY(!isASCIIDigitOrSeparator(m_current) && digit >= 0 && m_current != 'n'))
    1652         return NumberParseResult { octalValue };
     1584    } while (isASCIIOctalDigit(m_current) && digit >= 0);
     1585
     1586    if (LIKELY(!isASCIIDigit(m_current) && digit >= 0 && m_current != 'n'))
     1587        return Variant<double, const Identifier*> { octalValue };
     1588
    16531589
    16541590    for (int i = maximumDigits - 1; i > digit; --i)
    16551591         record8(digits[i]);
    16561592
    1657     while (isASCIIOctalDigitOrSeparator(m_current)) {
    1658         if (m_current == '_') {
    1659             if (UNLIKELY(!isASCIIOctalDigit(peek(1))))
    1660                 return WTF::nullopt;
    1661 
    1662             shift();
    1663         }
    1664 
     1593    while (isASCIIOctalDigit(m_current)) {
    16651594        record8(m_current);
    16661595        shift();
     
    16681597
    16691598    if (UNLIKELY(Options::useBigInt() && m_current == 'n'))
    1670         return NumberParseResult { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
     1599        return Variant<double, const Identifier*> { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
    16711600
    16721601    if (isASCIIDigit(m_current))
    16731602        return WTF::nullopt;
    16741603
    1675     return NumberParseResult { parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 8) };
     1604    return Variant<double, const Identifier*> { parseIntOverflow(m_buffer8.data(), m_buffer8.size(), 8) };
    16761605}
    16771606
     
    16791608ALWAYS_INLINE auto Lexer<T>::parseDecimal() -> Optional<NumberParseResult>
    16801609{
    1681     ASSERT(isASCIIDigit(m_current));
    1682 
    16831610    // Optimization: most decimal values fit into 4 bytes.
    16841611    uint32_t decimalValue = 0;
     
    16941621
    16951622        do {
    1696             if (m_current == '_') {
    1697                 if (UNLIKELY(!isASCIIDigit(peek(1))))
    1698                     return WTF::nullopt;
    1699 
    1700                 shift();
    1701             }
    1702 
    17031623            decimalValue = decimalValue * 10 + (m_current - '0');
    17041624            digits[digit] = m_current;
    17051625            shift();
    17061626            --digit;
    1707         } while (isASCIIDigitOrSeparator(m_current) && digit >= 0);
     1627        } while (isASCIIDigit(m_current) && digit >= 0);
    17081628
    17091629        if (digit >= 0 && m_current != '.' && !isASCIIAlphaCaselessEqual(m_current, 'e') && m_current != 'n')
    1710             return NumberParseResult { decimalValue };
     1630            return Variant<double, const Identifier*> { decimalValue };
    17111631
    17121632        for (int i = maximumDigits - 1; i > digit; --i)
     
    17141634    }
    17151635
    1716     while (isASCIIDigitOrSeparator(m_current)) {
    1717         if (m_current == '_') {
    1718             if (UNLIKELY(!isASCIIDigit(peek(1))))
    1719                 return WTF::nullopt;
    1720 
    1721             shift();
    1722         }
    1723 
     1636    while (isASCIIDigit(m_current)) {
    17241637        record8(m_current);
    17251638        shift();
     
    17271640   
    17281641    if (UNLIKELY(Options::useBigInt() && m_current == 'n'))
    1729         return NumberParseResult { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
     1642        return Variant<double, const Identifier*> { makeIdentifier(m_buffer8.data(), m_buffer8.size()) };
    17301643
    17311644    return WTF::nullopt;
     
    17331646
    17341647template <typename T>
    1735 ALWAYS_INLINE bool Lexer<T>::parseNumberAfterDecimalPoint()
    1736 {
    1737     ASSERT(isASCIIDigit(m_current));
     1648ALWAYS_INLINE void Lexer<T>::parseNumberAfterDecimalPoint()
     1649{
    17381650    record8('.');
    1739 
    1740     do {
    1741         if (m_current == '_') {
    1742             if (UNLIKELY(!isASCIIDigit(peek(1))))
    1743                 return false;
    1744 
    1745             shift();
    1746         }
    1747 
     1651    while (isASCIIDigit(m_current)) {
    17481652        record8(m_current);
    17491653        shift();
    1750     } while (isASCIIDigitOrSeparator(m_current));
    1751 
    1752     return true;
     1654    }
    17531655}
    17541656
     
    17671669
    17681670    do {
    1769         if (m_current == '_') {
    1770             if (UNLIKELY(!isASCIIDigit(peek(1))))
    1771                 return false;
    1772 
    1773             shift();
    1774         }
    1775 
    17761671        record8(m_current);
    17771672        shift();
    1778     } while (isASCIIDigitOrSeparator(m_current));
    1779 
     1673    } while (isASCIIDigit(m_current));
    17801674    return true;
    17811675}
     
    21972091            break;
    21982092        }
    2199         if (UNLIKELY(!parseNumberAfterDecimalPoint())) {
    2200             m_lexErrorMessage = "Non-number found after decimal point"_s;
    2201             token = INVALID_NUMERIC_LITERAL_ERRORTOK;
    2202             goto returnError;
    2203         }
     2093        parseNumberAfterDecimalPoint();
    22042094        token = DOUBLE;
    22052095        if (isASCIIAlphaCaselessEqual(m_current, 'e')) {
     
    22352125
    22362126            auto parseNumberResult = parseHex();
    2237             if (!parseNumberResult)
    2238                 tokenData->doubleValue = 0;
    2239             else if (WTF::holds_alternative<double>(*parseNumberResult))
    2240                 tokenData->doubleValue = WTF::get<double>(*parseNumberResult);
     2127            if (WTF::holds_alternative<double>(parseNumberResult))
     2128                tokenData->doubleValue = WTF::get<double>(parseNumberResult);
    22412129            else {
    22422130                token = BIGINT;
    22432131                shift();
    2244                 tokenData->bigIntString = WTF::get<const Identifier*>(*parseNumberResult);
     2132                tokenData->bigIntString = WTF::get<const Identifier*>(parseNumberResult);
    22452133                tokenData->radix = 16;
    22462134            }
     
    23202208            m_buffer8.shrink(0);
    23212209            break;
    2322         }
    2323 
    2324         if (UNLIKELY(m_current == '_')) {
    2325             m_lexErrorMessage = "Numeric literals may not begin with 0_"_s;
    2326             token = UNTERMINATED_OCTAL_NUMBER_ERRORTOK;
    2327             goto returnError;
    23282210        }
    23292211
     
    23592241                    if (m_current == '.') {
    23602242                        shift();
    2361                         if (UNLIKELY(isASCIIDigit(m_current) && !parseNumberAfterDecimalPoint())) {
    2362                             m_lexErrorMessage = "Non-number found after decimal point"_s;
    2363                             token = INVALID_NUMERIC_LITERAL_ERRORTOK;
    2364                             goto returnError;
    2365                         }
     2243                        parseNumberAfterDecimalPoint();
    23662244                        token = DOUBLE;
    23672245                    }
Note: See TracChangeset for help on using the changeset viewer.