⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244028 in webkit


Ignore:
Timestamp:
Apr 8, 2019, 11:01:42 AM (7 years ago)
Author:
Ryan Haddad
Message:

Unreviewed, rolling out r243948.

Caused inspector/runtime/parse.html to fail

Reverted changeset:

"SIGSEGV in JSC::BytecodeGenerator::addStringConstant"
https://bugs.webkit.org/show_bug.cgi?id=196486
https://trac.webkit.org/changeset/243948

Location:
trunk
Files:
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r244020 r244028  
     12019-04-08  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r243948.
     4
     5        Caused inspector/runtime/parse.html to fail
     6
     7        Reverted changeset:
     8
     9        "SIGSEGV in JSC::BytecodeGenerator::addStringConstant"
     10        https://bugs.webkit.org/show_bug.cgi?id=196486
     11        https://trac.webkit.org/changeset/243948
     12
    1132019-04-08  Ryan Haddad  <ryanhaddad@apple.com>
    214
  • trunk/Source/JavaScriptCore/ChangeLog

    r244020 r244028  
     12019-04-08  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r243948.
     4
     5        Caused inspector/runtime/parse.html to fail
     6
     7        Reverted changeset:
     8
     9        "SIGSEGV in JSC::BytecodeGenerator::addStringConstant"
     10        https://bugs.webkit.org/show_bug.cgi?id=196486
     11        https://trac.webkit.org/changeset/243948
     12
    1132019-04-08  Ryan Haddad  <ryanhaddad@apple.com>
    214
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r243948 r244028  
    242242    ExpressionNode* createString(const JSTokenLocation& location, const Identifier* string)
    243243    {
    244         ASSERT(string);
    245244        incConstants();
    246245        return new (m_parserArena) StringNode(location, *string);
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r243948 r244028  
    16921692        if (isLineTerminator(m_current)) {
    16931693            shiftLineTerminator();
    1694             m_hasLineTerminatorBeforeToken = true;
     1694            m_terminator = true;
    16951695        } else
    16961696            shift();
     
    17711771
    17721772template <typename T>
    1773 JSTokenType Lexer<T>::lexWithoutClearingLineTerminator(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)
     1773JSTokenType Lexer<T>::lex(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)
    17741774{
    17751775    JSTokenData* tokenData = &tokenRecord->m_data;
     
    17821782
    17831783    JSTokenType token = ERRORTOK;
     1784    m_terminator = false;
    17841785
    17851786start:
    17861787    skipWhitespace();
    17871788
     1789    if (atEnd())
     1790        return EOFTOK;
     1791   
    17881792    tokenLocation->startOffset = currentOffset();
    17891793    ASSERT(currentOffset() >= currentLineStartOffset());
    17901794    tokenRecord->m_startPosition = currentPosition();
    1791 
    1792     if (atEnd()) {
    1793         token = EOFTOK;
    1794         goto returnToken;
    1795     }
    17961795
    17971796    CharacterType type;
     
    19041903        if (m_current == '+') {
    19051904            shift();
    1906             token = (!m_hasLineTerminatorBeforeToken) ? PLUSPLUS : AUTOPLUSPLUS;
     1905            token = (!m_terminator) ? PLUSPLUS : AUTOPLUSPLUS;
    19071906            break;
    19081907        }
     
    19181917        if (m_current == '-') {
    19191918            shift();
    1920             if ((m_atLineStart || m_hasLineTerminatorBeforeToken) && m_current == '>') {
     1919            if ((m_atLineStart || m_terminator) && m_current == '>') {
    19211920                if (m_scriptMode == JSParserScriptMode::Classic) {
    19221921                    shift();
     
    19241923                }
    19251924            }
    1926             token = (!m_hasLineTerminatorBeforeToken) ? MINUSMINUS : AUTOMINUSMINUS;
     1925            token = (!m_terminator) ? MINUSMINUS : AUTOMINUSMINUS;
    19271926            break;
    19281927        }
     
    22952294        shiftLineTerminator();
    22962295        m_atLineStart = true;
    2297         m_hasLineTerminatorBeforeToken = true;
     2296        m_terminator = true;
    22982297        m_lineStart = m_code;
    22992298        goto start;
     
    23352334
    23362335        while (!isLineTerminator(m_current)) {
    2337             if (atEnd()) {
    2338                 token = EOFTOK;
    2339                 fillTokenInfo(tokenRecord, token, lineNumber, endOffset, lineStartOffset, endPosition);
    2340                 return token;
    2341             }
     2336            if (atEnd())
     2337                return EOFTOK;
    23422338            shift();
    23432339        }
    23442340        shiftLineTerminator();
    23452341        m_atLineStart = true;
    2346         m_hasLineTerminatorBeforeToken = true;
     2342        m_terminator = true;
    23472343        m_lineStart = m_code;
    23482344        if (!lastTokenWasRestrKeyword())
  • trunk/Source/JavaScriptCore/parser/Lexer.h

    r243948 r244028  
    6666
    6767    JSTokenType lex(JSToken*, unsigned, bool strictMode);
    68     JSTokenType lexWithoutClearingLineTerminator(JSToken*, unsigned, bool strictMode);
    6968    bool nextTokenIsColon();
    7069    int lineNumber() const { return m_lineNumber; }
     
    7978    void setLastLineNumber(int lastLineNumber) { m_lastLineNumber = lastLineNumber; }
    8079    int lastLineNumber() const { return m_lastLineNumber; }
    81     bool hasLineTerminatorBeforeToken() const { return m_hasLineTerminatorBeforeToken; }
     80    bool prevTerminator() const { return m_terminator; }
    8281    JSTokenType scanRegExp(JSToken*, UChar patternPrefix = 0);
    8382    enum class RawStringsBuildMode { BuildRawStrings, DontBuildRawStrings };
     
    112111        m_lineNumber = line;
    113112    }
    114     void setHasLineTerminatorBeforeToken(bool terminator)
     113    void setTerminator(bool terminator)
    115114    {
    116         m_hasLineTerminatorBeforeToken = terminator;
     115        m_terminator = terminator;
    117116    }
    118117
     
    204203    Vector<UChar> m_buffer16;
    205204    Vector<UChar> m_bufferForRawTemplateString16;
    206     bool m_hasLineTerminatorBeforeToken;
     205    bool m_terminator;
    207206    int m_lastToken;
    208207
     
    405404}
    406405
    407 template <typename T>
    408 ALWAYS_INLINE JSTokenType Lexer<T>::lex(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)
    409 {
    410     m_hasLineTerminatorBeforeToken = false;
    411     return lexWithoutClearingLineTerminator(tokenRecord, lexerFlags, strictMode);
    412 }
    413 
    414406} // namespace JSC
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r243948 r244028  
    346346bool Parser<LexerType>::allowAutomaticSemicolon()
    347347{
    348     return match(CLOSEBRACE) || match(EOFTOK) || m_lexer->hasLineTerminatorBeforeToken();
     348    return match(CLOSEBRACE) || match(EOFTOK) || m_lexer->prevTerminator();
    349349}
    350350
     
    626626        if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) {
    627627            next();
    628             failIfFalse(match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken(), "Cannot parse the async function");
     628            failIfFalse(match(FUNCTION) && !m_lexer->prevTerminator(), "Cannot parse the async function");
    629629            statement = parseAsyncFunctionDeclaration(context, ExportType::NotExported, DeclarationDefaultContext::Standard, functionConstructorParametersEndPosition);
    630630            break;
     
    697697            SavePoint savePoint = createSavePoint();
    698698            next();
    699             if (UNLIKELY(match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken())) {
     699            if (UNLIKELY(match(FUNCTION) && !m_lexer->prevTerminator())) {
    700700                result = parseAsyncFunctionDeclaration(context);
    701701                break;
     
    20272027    SavePoint savePoint = createSavePoint();
    20282028    next();
    2029     if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken()) {
     2029    if (match(FUNCTION) && !m_lexer->prevTerminator()) {
    20302030        const bool isAsync = true;
    20312031        result = parseFunctionDeclarationStatement(context, isAsync, parentAllowsFunctionDeclarationAsStatement);
     
    24222422        matchOrFail(ARROWFUNCTION, "Expected a '=>' after arrow function parameter declaration");
    24232423
    2424         if (m_lexer->hasLineTerminatorBeforeToken())
     2424        if (m_lexer->prevTerminator())
    24252425            failDueToUnexpectedToken();
    24262426
     
    26132613        newInfo = SourceProviderCacheItem::create(parameters);
    26142614    }
    2615 
    2616     bool functionScopeWasStrictMode = functionScope->strictMode();
    26172615   
    26182616    popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo);
     
    26212619        matchOrFail(CLOSEBRACE, "Expected a closing '}' after a ", stringForFunctionMode(mode), " body");
    26222620        next();
    2623     } else {
    2624         // We need to lex the last token again because the last token is lexed under the different context because of the following possibilities.
    2625         // 1. which may have different strict mode.
    2626         // 2. which may not build strings for tokens.
    2627         // But (1) is not possible because we do not recognize the string literal in ArrowFunctionBodyExpression as directive and this is correct in terms of the spec (`value => "use strict"`).
    2628         // So we only check TreeBuilder's type here.
    2629         ASSERT_UNUSED(functionScopeWasStrictMode, functionScopeWasStrictMode == currentScope()->strictMode());
    2630         if (!std::is_same<TreeBuilder, SyntaxChecker>::value)
    2631             lexCurrentTokenAgainUnderCurrentContext();
    26322621    }
    26332622
     
    28882877                    ident = m_token.m_data.ident;
    28892878                    next();
    2890                     if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer->hasLineTerminatorBeforeToken())
     2879                    if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer->prevTerminator())
    28912880                        break;
    28922881                    if (UNLIKELY(consume(TIMES)))
     
    34083397            SavePoint savePoint = createSavePoint();
    34093398            next();
    3410             if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken()) {
     3399            if (match(FUNCTION) && !m_lexer->prevTerminator()) {
    34113400                next();
    34123401                if (match(IDENT))
     
    35533542            if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) {
    35543543                next();
    3555                 semanticFailIfFalse(match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken(), "Expected 'function' keyword following 'async' keyword with no preceding line terminator");
     3544                semanticFailIfFalse(match(FUNCTION) && !m_lexer->prevTerminator(), "Expected 'function' keyword following 'async' keyword with no preceding line terminator");
    35563545                DepthManager statementDepth(&m_statementDepth);
    35573546                m_statementDepth = 1;
     
    36713660                if (matchContextualKeyword(m_vm->propertyNames->async)) {
    36723661                    next();
    3673                     isAsyncArrow = !m_lexer->hasLineTerminatorBeforeToken();
     3662                    isAsyncArrow = !m_lexer->prevTerminator();
    36743663                }
    36753664            }
     
    37883777    SavePoint savePoint = createSavePoint();
    37893778    next();
    3790     if (m_lexer->hasLineTerminatorBeforeToken())
     3779    if (m_lexer->prevTerminator())
    37913780        return context.createYield(location);
    37923781
     
    39483937                }
    39493938
    3950                 failIfTrue(m_lexer->hasLineTerminatorBeforeToken(), "Expected a property name following keyword 'async'");
     3939                failIfTrue(m_lexer->prevTerminator(), "Expected a property name following keyword 'async'");
    39513940                if (UNLIKELY(consume(TIMES)))
    39523941                    parseMode = SourceParseMode::AsyncGeneratorWrapperMethodMode;
     
    44974486            JSTokenLocation location(tokenLocation());
    44984487            next();
    4499             if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken())
     4488            if (match(FUNCTION) && !m_lexer->prevTerminator())
    45004489                return parseAsyncFunctionExpression(context);
    45014490
     
    47634752        base = parsePrimaryExpression(context);
    47644753        failIfFalse(base, "Cannot parse base expression");
    4765         if (UNLIKELY(isAsync && context.isResolve(base) && !m_lexer->hasLineTerminatorBeforeToken())) {
     4754        if (UNLIKELY(isAsync && context.isResolve(base) && !m_lexer->prevTerminator())) {
    47664755            if (matchSpecIdentifier()) {
    47674756                // AsyncArrowFunction
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r243948 r244028  
    13641364    }
    13651365
    1366     ALWAYS_INLINE void nextWithoutClearingLineTerminator(unsigned lexerFlags = 0)
    1367     {
    1368         int lastLine = m_token.m_location.line;
    1369         int lastTokenEnd = m_token.m_location.endOffset;
    1370         int lastTokenLineStart = m_token.m_location.lineStartOffset;
    1371         m_lastTokenEndPosition = JSTextPosition(lastLine, lastTokenEnd, lastTokenLineStart);
    1372         m_lexer->setLastLineNumber(lastLine);
    1373         m_token.m_type = m_lexer->lexWithoutClearingLineTerminator(&m_token, lexerFlags, strictMode());
    1374     }
    1375 
    13761366    ALWAYS_INLINE void nextExpectIdentifier(unsigned lexerFlags = 0)
    13771367    {
     
    13821372        m_lexer->setLastLineNumber(lastLine);
    13831373        m_token.m_type = m_lexer->lexExpectIdentifier(&m_token, lexerFlags, strictMode());
    1384     }
    1385 
    1386     ALWAYS_INLINE void lexCurrentTokenAgainUnderCurrentContext()
    1387     {
    1388         auto savePoint = createSavePoint();
    1389         restoreSavePoint(savePoint);
    13901374    }
    13911375
     
    17791763        unsigned oldLastLineNumber;
    17801764        unsigned oldLineNumber;
    1781         bool hasLineTerminatorBeforeToken;
    17821765    };
    17831766
     
    17931776        result.oldLastLineNumber = m_lexer->lastLineNumber();
    17941777        result.oldLineNumber = m_lexer->lineNumber();
    1795         result.hasLineTerminatorBeforeToken = m_lexer->hasLineTerminatorBeforeToken();
    17961778        ASSERT(static_cast<unsigned>(result.startOffset) >= result.oldLineStartOffset);
    17971779        return result;
     
    18031785        m_lexer->setOffset(lexerState.startOffset, lexerState.oldLineStartOffset);
    18041786        m_lexer->setLineNumber(lexerState.oldLineNumber);
    1805         m_lexer->setHasLineTerminatorBeforeToken(lexerState.hasLineTerminatorBeforeToken);
    1806         nextWithoutClearingLineTerminator();
     1787        next();
    18071788        m_lexer->setLastLineNumber(lexerState.oldLastLineNumber);
    18081789    }
Note: See TracChangeset for help on using the changeset viewer.