Changeset 244028 in webkit
- Timestamp:
- Apr 8, 2019, 11:01:42 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 7 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/arrow-function-and-use-strict-directive.js (deleted)
-
JSTests/stress/arrow-function-syntax.js (deleted)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/parser/ASTBuilder.h (modified) (1 diff)
-
Source/JavaScriptCore/parser/Lexer.cpp (modified) (8 diffs)
-
Source/JavaScriptCore/parser/Lexer.h (modified) (5 diffs)
-
Source/JavaScriptCore/parser/Parser.cpp (modified) (15 diffs)
-
Source/JavaScriptCore/parser/Parser.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r244020 r244028 1 2019-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 1 13 2019-04-08 Ryan Haddad <ryanhaddad@apple.com> 2 14 -
trunk/Source/JavaScriptCore/ChangeLog
r244020 r244028 1 2019-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 1 13 2019-04-08 Ryan Haddad <ryanhaddad@apple.com> 2 14 -
trunk/Source/JavaScriptCore/parser/ASTBuilder.h
r243948 r244028 242 242 ExpressionNode* createString(const JSTokenLocation& location, const Identifier* string) 243 243 { 244 ASSERT(string);245 244 incConstants(); 246 245 return new (m_parserArena) StringNode(location, *string); -
trunk/Source/JavaScriptCore/parser/Lexer.cpp
r243948 r244028 1692 1692 if (isLineTerminator(m_current)) { 1693 1693 shiftLineTerminator(); 1694 m_ hasLineTerminatorBeforeToken= true;1694 m_terminator = true; 1695 1695 } else 1696 1696 shift(); … … 1771 1771 1772 1772 template <typename T> 1773 JSTokenType Lexer<T>::lex WithoutClearingLineTerminator(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)1773 JSTokenType Lexer<T>::lex(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode) 1774 1774 { 1775 1775 JSTokenData* tokenData = &tokenRecord->m_data; … … 1782 1782 1783 1783 JSTokenType token = ERRORTOK; 1784 m_terminator = false; 1784 1785 1785 1786 start: 1786 1787 skipWhitespace(); 1787 1788 1789 if (atEnd()) 1790 return EOFTOK; 1791 1788 1792 tokenLocation->startOffset = currentOffset(); 1789 1793 ASSERT(currentOffset() >= currentLineStartOffset()); 1790 1794 tokenRecord->m_startPosition = currentPosition(); 1791 1792 if (atEnd()) {1793 token = EOFTOK;1794 goto returnToken;1795 }1796 1795 1797 1796 CharacterType type; … … 1904 1903 if (m_current == '+') { 1905 1904 shift(); 1906 token = (!m_ hasLineTerminatorBeforeToken) ? PLUSPLUS : AUTOPLUSPLUS;1905 token = (!m_terminator) ? PLUSPLUS : AUTOPLUSPLUS; 1907 1906 break; 1908 1907 } … … 1918 1917 if (m_current == '-') { 1919 1918 shift(); 1920 if ((m_atLineStart || m_ hasLineTerminatorBeforeToken) && m_current == '>') {1919 if ((m_atLineStart || m_terminator) && m_current == '>') { 1921 1920 if (m_scriptMode == JSParserScriptMode::Classic) { 1922 1921 shift(); … … 1924 1923 } 1925 1924 } 1926 token = (!m_ hasLineTerminatorBeforeToken) ? MINUSMINUS : AUTOMINUSMINUS;1925 token = (!m_terminator) ? MINUSMINUS : AUTOMINUSMINUS; 1927 1926 break; 1928 1927 } … … 2295 2294 shiftLineTerminator(); 2296 2295 m_atLineStart = true; 2297 m_ hasLineTerminatorBeforeToken= true;2296 m_terminator = true; 2298 2297 m_lineStart = m_code; 2299 2298 goto start; … … 2335 2334 2336 2335 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; 2342 2338 shift(); 2343 2339 } 2344 2340 shiftLineTerminator(); 2345 2341 m_atLineStart = true; 2346 m_ hasLineTerminatorBeforeToken= true;2342 m_terminator = true; 2347 2343 m_lineStart = m_code; 2348 2344 if (!lastTokenWasRestrKeyword()) -
trunk/Source/JavaScriptCore/parser/Lexer.h
r243948 r244028 66 66 67 67 JSTokenType lex(JSToken*, unsigned, bool strictMode); 68 JSTokenType lexWithoutClearingLineTerminator(JSToken*, unsigned, bool strictMode);69 68 bool nextTokenIsColon(); 70 69 int lineNumber() const { return m_lineNumber; } … … 79 78 void setLastLineNumber(int lastLineNumber) { m_lastLineNumber = lastLineNumber; } 80 79 int lastLineNumber() const { return m_lastLineNumber; } 81 bool hasLineTerminatorBeforeToken() const { return m_hasLineTerminatorBeforeToken; }80 bool prevTerminator() const { return m_terminator; } 82 81 JSTokenType scanRegExp(JSToken*, UChar patternPrefix = 0); 83 82 enum class RawStringsBuildMode { BuildRawStrings, DontBuildRawStrings }; … … 112 111 m_lineNumber = line; 113 112 } 114 void set HasLineTerminatorBeforeToken(bool terminator)113 void setTerminator(bool terminator) 115 114 { 116 m_ hasLineTerminatorBeforeToken= terminator;115 m_terminator = terminator; 117 116 } 118 117 … … 204 203 Vector<UChar> m_buffer16; 205 204 Vector<UChar> m_bufferForRawTemplateString16; 206 bool m_ hasLineTerminatorBeforeToken;205 bool m_terminator; 207 206 int m_lastToken; 208 207 … … 405 404 } 406 405 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 414 406 } // namespace JSC -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r243948 r244028 346 346 bool Parser<LexerType>::allowAutomaticSemicolon() 347 347 { 348 return match(CLOSEBRACE) || match(EOFTOK) || m_lexer-> hasLineTerminatorBeforeToken();348 return match(CLOSEBRACE) || match(EOFTOK) || m_lexer->prevTerminator(); 349 349 } 350 350 … … 626 626 if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) { 627 627 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"); 629 629 statement = parseAsyncFunctionDeclaration(context, ExportType::NotExported, DeclarationDefaultContext::Standard, functionConstructorParametersEndPosition); 630 630 break; … … 697 697 SavePoint savePoint = createSavePoint(); 698 698 next(); 699 if (UNLIKELY(match(FUNCTION) && !m_lexer-> hasLineTerminatorBeforeToken())) {699 if (UNLIKELY(match(FUNCTION) && !m_lexer->prevTerminator())) { 700 700 result = parseAsyncFunctionDeclaration(context); 701 701 break; … … 2027 2027 SavePoint savePoint = createSavePoint(); 2028 2028 next(); 2029 if (match(FUNCTION) && !m_lexer-> hasLineTerminatorBeforeToken()) {2029 if (match(FUNCTION) && !m_lexer->prevTerminator()) { 2030 2030 const bool isAsync = true; 2031 2031 result = parseFunctionDeclarationStatement(context, isAsync, parentAllowsFunctionDeclarationAsStatement); … … 2422 2422 matchOrFail(ARROWFUNCTION, "Expected a '=>' after arrow function parameter declaration"); 2423 2423 2424 if (m_lexer-> hasLineTerminatorBeforeToken())2424 if (m_lexer->prevTerminator()) 2425 2425 failDueToUnexpectedToken(); 2426 2426 … … 2613 2613 newInfo = SourceProviderCacheItem::create(parameters); 2614 2614 } 2615 2616 bool functionScopeWasStrictMode = functionScope->strictMode();2617 2615 2618 2616 popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo); … … 2621 2619 matchOrFail(CLOSEBRACE, "Expected a closing '}' after a ", stringForFunctionMode(mode), " body"); 2622 2620 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();2632 2621 } 2633 2622 … … 2888 2877 ident = m_token.m_data.ident; 2889 2878 next(); 2890 if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer-> hasLineTerminatorBeforeToken())2879 if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer->prevTerminator()) 2891 2880 break; 2892 2881 if (UNLIKELY(consume(TIMES))) … … 3408 3397 SavePoint savePoint = createSavePoint(); 3409 3398 next(); 3410 if (match(FUNCTION) && !m_lexer-> hasLineTerminatorBeforeToken()) {3399 if (match(FUNCTION) && !m_lexer->prevTerminator()) { 3411 3400 next(); 3412 3401 if (match(IDENT)) … … 3553 3542 if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) { 3554 3543 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"); 3556 3545 DepthManager statementDepth(&m_statementDepth); 3557 3546 m_statementDepth = 1; … … 3671 3660 if (matchContextualKeyword(m_vm->propertyNames->async)) { 3672 3661 next(); 3673 isAsyncArrow = !m_lexer-> hasLineTerminatorBeforeToken();3662 isAsyncArrow = !m_lexer->prevTerminator(); 3674 3663 } 3675 3664 } … … 3788 3777 SavePoint savePoint = createSavePoint(); 3789 3778 next(); 3790 if (m_lexer-> hasLineTerminatorBeforeToken())3779 if (m_lexer->prevTerminator()) 3791 3780 return context.createYield(location); 3792 3781 … … 3948 3937 } 3949 3938 3950 failIfTrue(m_lexer-> hasLineTerminatorBeforeToken(), "Expected a property name following keyword 'async'");3939 failIfTrue(m_lexer->prevTerminator(), "Expected a property name following keyword 'async'"); 3951 3940 if (UNLIKELY(consume(TIMES))) 3952 3941 parseMode = SourceParseMode::AsyncGeneratorWrapperMethodMode; … … 4497 4486 JSTokenLocation location(tokenLocation()); 4498 4487 next(); 4499 if (match(FUNCTION) && !m_lexer-> hasLineTerminatorBeforeToken())4488 if (match(FUNCTION) && !m_lexer->prevTerminator()) 4500 4489 return parseAsyncFunctionExpression(context); 4501 4490 … … 4763 4752 base = parsePrimaryExpression(context); 4764 4753 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())) { 4766 4755 if (matchSpecIdentifier()) { 4767 4756 // AsyncArrowFunction -
trunk/Source/JavaScriptCore/parser/Parser.h
r243948 r244028 1364 1364 } 1365 1365 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 1376 1366 ALWAYS_INLINE void nextExpectIdentifier(unsigned lexerFlags = 0) 1377 1367 { … … 1382 1372 m_lexer->setLastLineNumber(lastLine); 1383 1373 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);1390 1374 } 1391 1375 … … 1779 1763 unsigned oldLastLineNumber; 1780 1764 unsigned oldLineNumber; 1781 bool hasLineTerminatorBeforeToken;1782 1765 }; 1783 1766 … … 1793 1776 result.oldLastLineNumber = m_lexer->lastLineNumber(); 1794 1777 result.oldLineNumber = m_lexer->lineNumber(); 1795 result.hasLineTerminatorBeforeToken = m_lexer->hasLineTerminatorBeforeToken();1796 1778 ASSERT(static_cast<unsigned>(result.startOffset) >= result.oldLineStartOffset); 1797 1779 return result; … … 1803 1785 m_lexer->setOffset(lexerState.startOffset, lexerState.oldLineStartOffset); 1804 1786 m_lexer->setLineNumber(lexerState.oldLineNumber); 1805 m_lexer->setHasLineTerminatorBeforeToken(lexerState.hasLineTerminatorBeforeToken); 1806 nextWithoutClearingLineTerminator(); 1787 next(); 1807 1788 m_lexer->setLastLineNumber(lexerState.oldLastLineNumber); 1808 1789 }
Note:
See TracChangeset
for help on using the changeset viewer.