Changeset 245412 in webkit
- Timestamp:
- May 16, 2019, 3:48:03 PM (7 years ago)
- Location:
- branches/safari-607.2.1.2-branch
- 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
-
branches/safari-607.2.1.2-branch/JSTests/ChangeLog
r245411 r245412 1 2019-05-15 Alan Coon <alancoon@apple.com>2 3 Cherry-pick r243948. rdar://problem/507549724 5 SIGSEGV in JSC::BytecodeGenerator::addStringConstant6 https://bugs.webkit.org/show_bug.cgi?id=1964867 8 Reviewed by Saam Barati.9 10 JSTests:11 12 * stress/arrow-function-and-use-strict-directive.js: Added.13 * stress/arrow-function-syntax.js: Added. Checking EOF token handling.14 (checkSyntax):15 (checkSyntaxError): Currently not using it. But it is useful for testing more things related to arrow function syntax.16 17 Source/JavaScriptCore:18 19 When parsing a FunctionExpression / FunctionDeclaration etc., we use SyntaxChecker for the body of the function because we do not have any interest on the nodes of the body at that time.20 The nodes will be parsed with the ASTBuilder when the function itself is parsed for code generation. This works well previously because all the function ends with "}" previously.21 SyntaxChecker lexes this "}" token, and parser restores the context back to ASTBuilder and continues parsing.22 23 But now, we have ArrowFunctionExpression without braces `arrow => expr`. Let's consider the following code.24 25 arrow => expr26 "string!"27 28 We parse arrow function's body with SyntaxChecker. At that time, we lex "string!" token under the SyntaxChecker context. But this means that we may not build string content for this token29 since SyntaxChecker may not have interest on string content itself in certain case. After the parser is back to ASTBuilder, we parse "string!" as ExpressionStatement with string constant,30 generate StringNode with non-built identifier (nullptr), and we accidentally create StringNode with nullptr.31 32 This patch fixes this problem. The root cause of this problem is that the last token lexed in the previous context is used. We add lexCurrentTokenAgainUnderCurrentContext which will re-lex33 the current token under the current context (may be ASTBuilder). This should be done only when the caller's context is different from SyntaxChecker, which avoids unnecessary lexing.34 We leverage existing SavePoint mechanism to implement lexCurrentTokenAgainUnderCurrentContext cleanly.35 36 And we also fix the bug in the existing SavePoint mechanism, which is shown in the attached test script. When we save LexerState, we do not save line terminator status. This patch also introduces37 lexWithoutClearingLineTerminator, which lex the token without clearing line terminator status.38 39 * parser/ASTBuilder.h:40 (JSC::ASTBuilder::createString):41 * parser/Lexer.cpp:42 (JSC::Lexer<T>::parseMultilineComment):43 (JSC::Lexer<T>::lexWithoutClearingLineTerminator): EOF token also should record offset information. This offset information is correctly handled in Lexer::setOffset too.44 (JSC::Lexer<T>::lex): Deleted.45 * parser/Lexer.h:46 (JSC::Lexer::hasLineTerminatorBeforeToken const):47 (JSC::Lexer::setHasLineTerminatorBeforeToken):48 (JSC::Lexer<T>::lex):49 (JSC::Lexer::prevTerminator const): Deleted.50 (JSC::Lexer::setTerminator): Deleted.51 * parser/Parser.cpp:52 (JSC::Parser<LexerType>::allowAutomaticSemicolon):53 (JSC::Parser<LexerType>::parseSingleFunction):54 (JSC::Parser<LexerType>::parseStatementListItem):55 (JSC::Parser<LexerType>::maybeParseAsyncFunctionDeclarationStatement):56 (JSC::Parser<LexerType>::parseFunctionInfo):57 (JSC::Parser<LexerType>::parseClass):58 (JSC::Parser<LexerType>::parseExportDeclaration):59 (JSC::Parser<LexerType>::parseAssignmentExpression):60 (JSC::Parser<LexerType>::parseYieldExpression):61 (JSC::Parser<LexerType>::parseProperty):62 (JSC::Parser<LexerType>::parsePrimaryExpression):63 (JSC::Parser<LexerType>::parseMemberExpression):64 * parser/Parser.h:65 (JSC::Parser::nextWithoutClearingLineTerminator):66 (JSC::Parser::lexCurrentTokenAgainUnderCurrentContext):67 (JSC::Parser::internalSaveLexerState):68 (JSC::Parser::restoreLexerState):69 70 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243948 268f45cc-cd09-0410-ab3c-d52691b4dbfc71 72 2019-04-05 Yusuke Suzuki <ysuzuki@apple.com>73 74 SIGSEGV in JSC::BytecodeGenerator::addStringConstant75 https://bugs.webkit.org/show_bug.cgi?id=19648676 77 Reviewed by Saam Barati.78 79 * stress/arrow-function-and-use-strict-directive.js: Added.80 * stress/arrow-function-syntax.js: Added. Checking EOF token handling.81 (checkSyntax):82 (checkSyntaxError): Currently not using it. But it is useful for testing more things related to arrow function syntax.83 84 1 2019-02-20 Alan Coon <alancoon@apple.com> 85 2 -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/ChangeLog
r245411 r245412 1 2019-05-15 Alan Coon <alancoon@apple.com>2 3 Cherry-pick r243948. rdar://problem/507549724 5 SIGSEGV in JSC::BytecodeGenerator::addStringConstant6 https://bugs.webkit.org/show_bug.cgi?id=1964867 8 Reviewed by Saam Barati.9 10 JSTests:11 12 * stress/arrow-function-and-use-strict-directive.js: Added.13 * stress/arrow-function-syntax.js: Added. Checking EOF token handling.14 (checkSyntax):15 (checkSyntaxError): Currently not using it. But it is useful for testing more things related to arrow function syntax.16 17 Source/JavaScriptCore:18 19 When parsing a FunctionExpression / FunctionDeclaration etc., we use SyntaxChecker for the body of the function because we do not have any interest on the nodes of the body at that time.20 The nodes will be parsed with the ASTBuilder when the function itself is parsed for code generation. This works well previously because all the function ends with "}" previously.21 SyntaxChecker lexes this "}" token, and parser restores the context back to ASTBuilder and continues parsing.22 23 But now, we have ArrowFunctionExpression without braces `arrow => expr`. Let's consider the following code.24 25 arrow => expr26 "string!"27 28 We parse arrow function's body with SyntaxChecker. At that time, we lex "string!" token under the SyntaxChecker context. But this means that we may not build string content for this token29 since SyntaxChecker may not have interest on string content itself in certain case. After the parser is back to ASTBuilder, we parse "string!" as ExpressionStatement with string constant,30 generate StringNode with non-built identifier (nullptr), and we accidentally create StringNode with nullptr.31 32 This patch fixes this problem. The root cause of this problem is that the last token lexed in the previous context is used. We add lexCurrentTokenAgainUnderCurrentContext which will re-lex33 the current token under the current context (may be ASTBuilder). This should be done only when the caller's context is different from SyntaxChecker, which avoids unnecessary lexing.34 We leverage existing SavePoint mechanism to implement lexCurrentTokenAgainUnderCurrentContext cleanly.35 36 And we also fix the bug in the existing SavePoint mechanism, which is shown in the attached test script. When we save LexerState, we do not save line terminator status. This patch also introduces37 lexWithoutClearingLineTerminator, which lex the token without clearing line terminator status.38 39 * parser/ASTBuilder.h:40 (JSC::ASTBuilder::createString):41 * parser/Lexer.cpp:42 (JSC::Lexer<T>::parseMultilineComment):43 (JSC::Lexer<T>::lexWithoutClearingLineTerminator): EOF token also should record offset information. This offset information is correctly handled in Lexer::setOffset too.44 (JSC::Lexer<T>::lex): Deleted.45 * parser/Lexer.h:46 (JSC::Lexer::hasLineTerminatorBeforeToken const):47 (JSC::Lexer::setHasLineTerminatorBeforeToken):48 (JSC::Lexer<T>::lex):49 (JSC::Lexer::prevTerminator const): Deleted.50 (JSC::Lexer::setTerminator): Deleted.51 * parser/Parser.cpp:52 (JSC::Parser<LexerType>::allowAutomaticSemicolon):53 (JSC::Parser<LexerType>::parseSingleFunction):54 (JSC::Parser<LexerType>::parseStatementListItem):55 (JSC::Parser<LexerType>::maybeParseAsyncFunctionDeclarationStatement):56 (JSC::Parser<LexerType>::parseFunctionInfo):57 (JSC::Parser<LexerType>::parseClass):58 (JSC::Parser<LexerType>::parseExportDeclaration):59 (JSC::Parser<LexerType>::parseAssignmentExpression):60 (JSC::Parser<LexerType>::parseYieldExpression):61 (JSC::Parser<LexerType>::parseProperty):62 (JSC::Parser<LexerType>::parsePrimaryExpression):63 (JSC::Parser<LexerType>::parseMemberExpression):64 * parser/Parser.h:65 (JSC::Parser::nextWithoutClearingLineTerminator):66 (JSC::Parser::lexCurrentTokenAgainUnderCurrentContext):67 (JSC::Parser::internalSaveLexerState):68 (JSC::Parser::restoreLexerState):69 70 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243948 268f45cc-cd09-0410-ab3c-d52691b4dbfc71 72 2019-04-05 Yusuke Suzuki <ysuzuki@apple.com>73 74 SIGSEGV in JSC::BytecodeGenerator::addStringConstant75 https://bugs.webkit.org/show_bug.cgi?id=19648676 77 Reviewed by Saam Barati.78 79 When parsing a FunctionExpression / FunctionDeclaration etc., we use SyntaxChecker for the body of the function because we do not have any interest on the nodes of the body at that time.80 The nodes will be parsed with the ASTBuilder when the function itself is parsed for code generation. This works well previously because all the function ends with "}" previously.81 SyntaxChecker lexes this "}" token, and parser restores the context back to ASTBuilder and continues parsing.82 83 But now, we have ArrowFunctionExpression without braces `arrow => expr`. Let's consider the following code.84 85 arrow => expr86 "string!"87 88 We parse arrow function's body with SyntaxChecker. At that time, we lex "string!" token under the SyntaxChecker context. But this means that we may not build string content for this token89 since SyntaxChecker may not have interest on string content itself in certain case. After the parser is back to ASTBuilder, we parse "string!" as ExpressionStatement with string constant,90 generate StringNode with non-built identifier (nullptr), and we accidentally create StringNode with nullptr.91 92 This patch fixes this problem. The root cause of this problem is that the last token lexed in the previous context is used. We add lexCurrentTokenAgainUnderCurrentContext which will re-lex93 the current token under the current context (may be ASTBuilder). This should be done only when the caller's context is different from SyntaxChecker, which avoids unnecessary lexing.94 We leverage existing SavePoint mechanism to implement lexCurrentTokenAgainUnderCurrentContext cleanly.95 96 And we also fix the bug in the existing SavePoint mechanism, which is shown in the attached test script. When we save LexerState, we do not save line terminator status. This patch also introduces97 lexWithoutClearingLineTerminator, which lex the token without clearing line terminator status.98 99 * parser/ASTBuilder.h:100 (JSC::ASTBuilder::createString):101 * parser/Lexer.cpp:102 (JSC::Lexer<T>::parseMultilineComment):103 (JSC::Lexer<T>::lexWithoutClearingLineTerminator): EOF token also should record offset information. This offset information is correctly handled in Lexer::setOffset too.104 (JSC::Lexer<T>::lex): Deleted.105 * parser/Lexer.h:106 (JSC::Lexer::hasLineTerminatorBeforeToken const):107 (JSC::Lexer::setHasLineTerminatorBeforeToken):108 (JSC::Lexer<T>::lex):109 (JSC::Lexer::prevTerminator const): Deleted.110 (JSC::Lexer::setTerminator): Deleted.111 * parser/Parser.cpp:112 (JSC::Parser<LexerType>::allowAutomaticSemicolon):113 (JSC::Parser<LexerType>::parseSingleFunction):114 (JSC::Parser<LexerType>::parseStatementListItem):115 (JSC::Parser<LexerType>::maybeParseAsyncFunctionDeclarationStatement):116 (JSC::Parser<LexerType>::parseFunctionInfo):117 (JSC::Parser<LexerType>::parseClass):118 (JSC::Parser<LexerType>::parseExportDeclaration):119 (JSC::Parser<LexerType>::parseAssignmentExpression):120 (JSC::Parser<LexerType>::parseYieldExpression):121 (JSC::Parser<LexerType>::parseProperty):122 (JSC::Parser<LexerType>::parsePrimaryExpression):123 (JSC::Parser<LexerType>::parseMemberExpression):124 * parser/Parser.h:125 (JSC::Parser::nextWithoutClearingLineTerminator):126 (JSC::Parser::lexCurrentTokenAgainUnderCurrentContext):127 (JSC::Parser::internalSaveLexerState):128 (JSC::Parser::restoreLexerState):129 130 1 2019-02-28 Alan Coon <alancoon@apple.com> 131 2 -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/parser/ASTBuilder.h
r245331 r245412 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); -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/parser/Lexer.cpp
r245331 r245412 1706 1706 if (isLineTerminator(m_current)) { 1707 1707 shiftLineTerminator(); 1708 m_ hasLineTerminatorBeforeToken= true;1708 m_terminator = true; 1709 1709 } else 1710 1710 shift(); … … 1785 1785 1786 1786 template <typename T> 1787 JSTokenType Lexer<T>::lex WithoutClearingLineTerminator(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)1787 JSTokenType Lexer<T>::lex(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode) 1788 1788 { 1789 1789 JSTokenData* tokenData = &tokenRecord->m_data; … … 1796 1796 1797 1797 JSTokenType token = ERRORTOK; 1798 m_terminator = false; 1798 1799 1799 1800 start: 1800 1801 skipWhitespace(); 1801 1802 1803 if (atEnd()) 1804 return EOFTOK; 1805 1802 1806 tokenLocation->startOffset = currentOffset(); 1803 1807 ASSERT(currentOffset() >= currentLineStartOffset()); 1804 1808 tokenRecord->m_startPosition = currentPosition(); 1805 1806 if (atEnd()) {1807 token = EOFTOK;1808 goto returnToken;1809 }1810 1809 1811 1810 CharacterType type; … … 1918 1917 if (m_current == '+') { 1919 1918 shift(); 1920 token = (!m_ hasLineTerminatorBeforeToken) ? PLUSPLUS : AUTOPLUSPLUS;1919 token = (!m_terminator) ? PLUSPLUS : AUTOPLUSPLUS; 1921 1920 break; 1922 1921 } … … 1932 1931 if (m_current == '-') { 1933 1932 shift(); 1934 if ((m_atLineStart || m_ hasLineTerminatorBeforeToken) && m_current == '>') {1933 if ((m_atLineStart || m_terminator) && m_current == '>') { 1935 1934 if (m_scriptMode == JSParserScriptMode::Classic) { 1936 1935 shift(); … … 1938 1937 } 1939 1938 } 1940 token = (!m_ hasLineTerminatorBeforeToken) ? MINUSMINUS : AUTOMINUSMINUS;1939 token = (!m_terminator) ? MINUSMINUS : AUTOMINUSMINUS; 1941 1940 break; 1942 1941 } … … 2309 2308 shiftLineTerminator(); 2310 2309 m_atLineStart = true; 2311 m_ hasLineTerminatorBeforeToken= true;2310 m_terminator = true; 2312 2311 m_lineStart = m_code; 2313 2312 goto start; … … 2349 2348 2350 2349 while (!isLineTerminator(m_current)) { 2351 if (atEnd()) { 2352 token = EOFTOK; 2353 fillTokenInfo(tokenRecord, token, lineNumber, endOffset, lineStartOffset, endPosition); 2354 return token; 2355 } 2350 if (atEnd()) 2351 return EOFTOK; 2356 2352 shift(); 2357 2353 } 2358 2354 shiftLineTerminator(); 2359 2355 m_atLineStart = true; 2360 m_ hasLineTerminatorBeforeToken= true;2356 m_terminator = true; 2361 2357 m_lineStart = m_code; 2362 2358 if (!lastTokenWasRestrKeyword()) -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/parser/Lexer.h
r245331 r245412 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 -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/parser/Parser.cpp
r245331 r245412 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 … … 2614 2614 newInfo = SourceProviderCacheItem::create(parameters); 2615 2615 } 2616 2617 bool functionScopeWasStrictMode = functionScope->strictMode();2618 2616 2619 2617 popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo); … … 2622 2620 matchOrFail(CLOSEBRACE, "Expected a closing '}' after a ", stringForFunctionMode(mode), " body"); 2623 2621 next(); 2624 } else {2625 // We need to lex the last token again because the last token is lexed under the different context because of the following possibilities.2626 // 1. which may have different strict mode.2627 // 2. which may not build strings for tokens.2628 // 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"`).2629 // So we only check TreeBuilder's type here.2630 ASSERT_UNUSED(functionScopeWasStrictMode, functionScopeWasStrictMode == currentScope()->strictMode());2631 if (!std::is_same<TreeBuilder, SyntaxChecker>::value)2632 lexCurrentTokenAgainUnderCurrentContext();2633 2622 } 2634 2623 … … 2889 2878 ident = m_token.m_data.ident; 2890 2879 next(); 2891 if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer-> hasLineTerminatorBeforeToken())2880 if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer->prevTerminator()) 2892 2881 break; 2893 2882 if (UNLIKELY(consume(TIMES))) … … 3414 3403 SavePoint savePoint = createSavePoint(); 3415 3404 next(); 3416 if (match(FUNCTION) && !m_lexer-> hasLineTerminatorBeforeToken()) {3405 if (match(FUNCTION) && !m_lexer->prevTerminator()) { 3417 3406 next(); 3418 3407 if (match(IDENT)) … … 3559 3548 if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) { 3560 3549 next(); 3561 semanticFailIfFalse(match(FUNCTION) && !m_lexer-> hasLineTerminatorBeforeToken(), "Expected 'function' keyword following 'async' keyword with no preceding line terminator");3550 semanticFailIfFalse(match(FUNCTION) && !m_lexer->prevTerminator(), "Expected 'function' keyword following 'async' keyword with no preceding line terminator"); 3562 3551 DepthManager statementDepth(&m_statementDepth); 3563 3552 m_statementDepth = 1; … … 3677 3666 if (matchContextualKeyword(m_vm->propertyNames->async)) { 3678 3667 next(); 3679 isAsyncArrow = !m_lexer-> hasLineTerminatorBeforeToken();3668 isAsyncArrow = !m_lexer->prevTerminator(); 3680 3669 } 3681 3670 } … … 3794 3783 SavePoint savePoint = createSavePoint(); 3795 3784 next(); 3796 if (m_lexer-> hasLineTerminatorBeforeToken())3785 if (m_lexer->prevTerminator()) 3797 3786 return context.createYield(location); 3798 3787 … … 3954 3943 } 3955 3944 3956 failIfTrue(m_lexer-> hasLineTerminatorBeforeToken(), "Expected a property name following keyword 'async'");3945 failIfTrue(m_lexer->prevTerminator(), "Expected a property name following keyword 'async'"); 3957 3946 if (UNLIKELY(consume(TIMES))) 3958 3947 parseMode = SourceParseMode::AsyncGeneratorWrapperMethodMode; … … 4506 4495 JSTokenLocation location(tokenLocation()); 4507 4496 next(); 4508 if (match(FUNCTION) && !m_lexer-> hasLineTerminatorBeforeToken())4497 if (match(FUNCTION) && !m_lexer->prevTerminator()) 4509 4498 return parseAsyncFunctionExpression(context); 4510 4499 … … 4771 4760 base = parsePrimaryExpression(context); 4772 4761 failIfFalse(base, "Cannot parse base expression"); 4773 if (UNLIKELY(isAsync && context.isResolve(base) && !m_lexer-> hasLineTerminatorBeforeToken())) {4762 if (UNLIKELY(isAsync && context.isResolve(base) && !m_lexer->prevTerminator())) { 4774 4763 if (matchSpecIdentifier()) { 4775 4764 // AsyncArrowFunction -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/parser/Parser.h
r245331 r245412 1365 1365 } 1366 1366 1367 ALWAYS_INLINE void nextWithoutClearingLineTerminator(unsigned lexerFlags = 0)1368 {1369 int lastLine = m_token.m_location.line;1370 int lastTokenEnd = m_token.m_location.endOffset;1371 int lastTokenLineStart = m_token.m_location.lineStartOffset;1372 m_lastTokenEndPosition = JSTextPosition(lastLine, lastTokenEnd, lastTokenLineStart);1373 m_lexer->setLastLineNumber(lastLine);1374 m_token.m_type = m_lexer->lexWithoutClearingLineTerminator(&m_token, lexerFlags, strictMode());1375 }1376 1377 1367 ALWAYS_INLINE void nextExpectIdentifier(unsigned lexerFlags = 0) 1378 1368 { … … 1383 1373 m_lexer->setLastLineNumber(lastLine); 1384 1374 m_token.m_type = m_lexer->lexExpectIdentifier(&m_token, lexerFlags, strictMode()); 1385 }1386 1387 ALWAYS_INLINE void lexCurrentTokenAgainUnderCurrentContext()1388 {1389 auto savePoint = createSavePoint();1390 restoreSavePoint(savePoint);1391 1375 } 1392 1376 … … 1780 1764 unsigned oldLastLineNumber; 1781 1765 unsigned oldLineNumber; 1782 bool hasLineTerminatorBeforeToken;1783 1766 }; 1784 1767 … … 1794 1777 result.oldLastLineNumber = m_lexer->lastLineNumber(); 1795 1778 result.oldLineNumber = m_lexer->lineNumber(); 1796 result.hasLineTerminatorBeforeToken = m_lexer->hasLineTerminatorBeforeToken();1797 1779 ASSERT(static_cast<unsigned>(result.startOffset) >= result.oldLineStartOffset); 1798 1780 return result; … … 1804 1786 m_lexer->setOffset(lexerState.startOffset, lexerState.oldLineStartOffset); 1805 1787 m_lexer->setLineNumber(lexerState.oldLineNumber); 1806 m_lexer->setHasLineTerminatorBeforeToken(lexerState.hasLineTerminatorBeforeToken); 1807 nextWithoutClearingLineTerminator(); 1788 next(); 1808 1789 m_lexer->setLastLineNumber(lexerState.oldLastLineNumber); 1809 1790 }
Note:
See TracChangeset
for help on using the changeset viewer.