Title: [244028] trunk
Revision
244028
Author
ryanhad...@apple.com
Date
2019-04-08 11:01:42 -0700 (Mon, 08 Apr 2019)

Log 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

Modified Paths

Removed Paths

Diff

Modified: trunk/JSTests/ChangeLog (244027 => 244028)


--- trunk/JSTests/ChangeLog	2019-04-08 17:29:51 UTC (rev 244027)
+++ trunk/JSTests/ChangeLog	2019-04-08 18:01:42 UTC (rev 244028)
@@ -1,5 +1,17 @@
 2019-04-08  Ryan Haddad  <ryanhad...@apple.com>
 
+        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
+
+2019-04-08  Ryan Haddad  <ryanhad...@apple.com>
+
         Unreviewed, rolling out r243943.
 
         Caused test262 failures.

Deleted: trunk/JSTests/stress/arrow-function-and-use-strict-directive.js (244027 => 244028)


--- trunk/JSTests/stress/arrow-function-and-use-strict-directive.js	2019-04-08 17:29:51 UTC (rev 244027)
+++ trunk/JSTests/stress/arrow-function-and-use-strict-directive.js	2019-04-08 18:01:42 UTC (rev 244028)
@@ -1,18 +0,0 @@
-// This test should not crash.
-
-dispatch => accessible.children()
-"use strict";
-
-dispatch2 => accessible.children()
-"use strict"
-
-var protected = 42;
-
-dispatch3 => "use strict"
-protected;
-
-async dispatch4 => hey
-"use strict";
-
-async dispatch4 => "use strict"
-protected;

Deleted: trunk/JSTests/stress/arrow-function-syntax.js (244027 => 244028)


--- trunk/JSTests/stress/arrow-function-syntax.js	2019-04-08 17:29:51 UTC (rev 244027)
+++ trunk/JSTests/stress/arrow-function-syntax.js	2019-04-08 18:01:42 UTC (rev 244028)
@@ -1,27 +0,0 @@
-function checkSyntax(src) {
-    try {
-        eval(src);
-    } catch (error) {
-        if (error instanceof SyntaxError)
-            throw new Error("Syntax Error: " + String(error) + "\n script: `" + src + "`");
-    }
-}
-
-function checkSyntaxError(src, message) {
-    var bError = false;
-    try {
-        eval(src);
-    } catch (error) {
-        bError = error instanceof SyntaxError && (String(error) === message || typeof message === 'undefined');
-    }
-    if (!bError) {
-        throw new Error("Expected syntax Error: " + message + "\n in script: `" + src + "`");
-    }
-}
-
-checkSyntax(`()=>42`);
-checkSyntax(`()=>42
-`);
-checkSyntax(`()=>42//Hello`);
-checkSyntax(`()=>42//Hello
-`);

Modified: trunk/Source/_javascript_Core/ChangeLog (244027 => 244028)


--- trunk/Source/_javascript_Core/ChangeLog	2019-04-08 17:29:51 UTC (rev 244027)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-04-08 18:01:42 UTC (rev 244028)
@@ -1,5 +1,17 @@
 2019-04-08  Ryan Haddad  <ryanhad...@apple.com>
 
+        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
+
+2019-04-08  Ryan Haddad  <ryanhad...@apple.com>
+
         Unreviewed, rolling out r243943.
 
         Caused test262 failures.

Modified: trunk/Source/_javascript_Core/parser/ASTBuilder.h (244027 => 244028)


--- trunk/Source/_javascript_Core/parser/ASTBuilder.h	2019-04-08 17:29:51 UTC (rev 244027)
+++ trunk/Source/_javascript_Core/parser/ASTBuilder.h	2019-04-08 18:01:42 UTC (rev 244028)
@@ -241,7 +241,6 @@
 
     ExpressionNode* createString(const JSTokenLocation& location, const Identifier* string)
     {
-        ASSERT(string);
         incConstants();
         return new (m_parserArena) StringNode(location, *string);
     }

Modified: trunk/Source/_javascript_Core/parser/Lexer.cpp (244027 => 244028)


--- trunk/Source/_javascript_Core/parser/Lexer.cpp	2019-04-08 17:29:51 UTC (rev 244027)
+++ trunk/Source/_javascript_Core/parser/Lexer.cpp	2019-04-08 18:01:42 UTC (rev 244028)
@@ -1691,7 +1691,7 @@
 
         if (isLineTerminator(m_current)) {
             shiftLineTerminator();
-            m_hasLineTerminatorBeforeToken = true;
+            m_terminator = true;
         } else
             shift();
     }
@@ -1770,7 +1770,7 @@
 }
 
 template <typename T>
-JSTokenType Lexer<T>::lexWithoutClearingLineTerminator(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)
+JSTokenType Lexer<T>::lex(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)
 {
     JSTokenData* tokenData = &tokenRecord->m_data;
     JSTokenLocation* tokenLocation = &tokenRecord->m_location;
@@ -1781,19 +1781,18 @@
     ASSERT(m_buffer16.isEmpty());
 
     JSTokenType token = ERRORTOK;
+    m_terminator = false;
 
 start:
     skipWhitespace();
 
+    if (atEnd())
+        return EOFTOK;
+    
     tokenLocation->startOffset = currentOffset();
     ASSERT(currentOffset() >= currentLineStartOffset());
     tokenRecord->m_startPosition = currentPosition();
 
-    if (atEnd()) {
-        token = EOFTOK;
-        goto returnToken;
-    }
-
     CharacterType type;
     if (LIKELY(isLatin1(m_current)))
         type = static_cast<CharacterType>(typesOfLatin1Characters[m_current]);
@@ -1903,7 +1902,7 @@
         shift();
         if (m_current == '+') {
             shift();
-            token = (!m_hasLineTerminatorBeforeToken) ? PLUSPLUS : AUTOPLUSPLUS;
+            token = (!m_terminator) ? PLUSPLUS : AUTOPLUSPLUS;
             break;
         }
         if (m_current == '=') {
@@ -1917,13 +1916,13 @@
         shift();
         if (m_current == '-') {
             shift();
-            if ((m_atLineStart || m_hasLineTerminatorBeforeToken) && m_current == '>') {
+            if ((m_atLineStart || m_terminator) && m_current == '>') {
                 if (m_scriptMode == JSParserScriptMode::Classic) {
                     shift();
                     goto inSingleLineComment;
                 }
             }
-            token = (!m_hasLineTerminatorBeforeToken) ? MINUSMINUS : AUTOMINUSMINUS;
+            token = (!m_terminator) ? MINUSMINUS : AUTOMINUSMINUS;
             break;
         }
         if (m_current == '=') {
@@ -2294,7 +2293,7 @@
         ASSERT(isLineTerminator(m_current));
         shiftLineTerminator();
         m_atLineStart = true;
-        m_hasLineTerminatorBeforeToken = true;
+        m_terminator = true;
         m_lineStart = m_code;
         goto start;
     case CharacterPrivateIdentifierStart:
@@ -2334,16 +2333,13 @@
         auto endPosition = currentPosition();
 
         while (!isLineTerminator(m_current)) {
-            if (atEnd()) {
-                token = EOFTOK;
-                fillTokenInfo(tokenRecord, token, lineNumber, endOffset, lineStartOffset, endPosition);
-                return token;
-            }
+            if (atEnd())
+                return EOFTOK;
             shift();
         }
         shiftLineTerminator();
         m_atLineStart = true;
-        m_hasLineTerminatorBeforeToken = true;
+        m_terminator = true;
         m_lineStart = m_code;
         if (!lastTokenWasRestrKeyword())
             goto start;

Modified: trunk/Source/_javascript_Core/parser/Lexer.h (244027 => 244028)


--- trunk/Source/_javascript_Core/parser/Lexer.h	2019-04-08 17:29:51 UTC (rev 244027)
+++ trunk/Source/_javascript_Core/parser/Lexer.h	2019-04-08 18:01:42 UTC (rev 244028)
@@ -65,7 +65,6 @@
     bool isReparsingFunction() const { return m_isReparsingFunction; }
 
     JSTokenType lex(JSToken*, unsigned, bool strictMode);
-    JSTokenType lexWithoutClearingLineTerminator(JSToken*, unsigned, bool strictMode);
     bool nextTokenIsColon();
     int lineNumber() const { return m_lineNumber; }
     ALWAYS_INLINE int currentOffset() const { return offsetFromSourcePtr(m_code); }
@@ -78,7 +77,7 @@
     JSTokenLocation lastTokenLocation() const { return m_lastTokenLocation; }
     void setLastLineNumber(int lastLineNumber) { m_lastLineNumber = lastLineNumber; }
     int lastLineNumber() const { return m_lastLineNumber; }
-    bool hasLineTerminatorBeforeToken() const { return m_hasLineTerminatorBeforeToken; }
+    bool prevTerminator() const { return m_terminator; }
     JSTokenType scanRegExp(JSToken*, UChar patternPrefix = 0);
     enum class RawStringsBuildMode { BuildRawStrings, DontBuildRawStrings };
     JSTokenType scanTemplateString(JSToken*, RawStringsBuildMode);
@@ -111,9 +110,9 @@
     {
         m_lineNumber = line;
     }
-    void setHasLineTerminatorBeforeToken(bool terminator)
+    void setTerminator(bool terminator)
     {
-        m_hasLineTerminatorBeforeToken = terminator;
+        m_terminator = terminator;
     }
 
     JSTokenType lexExpectIdentifier(JSToken*, unsigned, bool strictMode);
@@ -203,7 +202,7 @@
     Vector<LChar> m_buffer8;
     Vector<UChar> m_buffer16;
     Vector<UChar> m_bufferForRawTemplateString16;
-    bool m_hasLineTerminatorBeforeToken;
+    bool m_terminator;
     int m_lastToken;
 
     const SourceCode* m_source;
@@ -404,11 +403,4 @@
     return lex(tokenRecord, lexerFlags, strictMode);
 }
 
-template <typename T>
-ALWAYS_INLINE JSTokenType Lexer<T>::lex(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)
-{
-    m_hasLineTerminatorBeforeToken = false;
-    return lexWithoutClearingLineTerminator(tokenRecord, lexerFlags, strictMode);
-}
-
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (244027 => 244028)


--- trunk/Source/_javascript_Core/parser/Parser.cpp	2019-04-08 17:29:51 UTC (rev 244027)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp	2019-04-08 18:01:42 UTC (rev 244028)
@@ -345,7 +345,7 @@
 template <typename LexerType>
 bool Parser<LexerType>::allowAutomaticSemicolon()
 {
-    return match(CLOSEBRACE) || match(EOFTOK) || m_lexer->hasLineTerminatorBeforeToken();
+    return match(CLOSEBRACE) || match(EOFTOK) || m_lexer->prevTerminator();
 }
 
 template <typename LexerType>
@@ -625,7 +625,7 @@
     case IDENT:
         if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) {
             next();
-            failIfFalse(match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken(), "Cannot parse the async function");
+            failIfFalse(match(FUNCTION) && !m_lexer->prevTerminator(), "Cannot parse the async function");
             statement = parseAsyncFunctionDeclaration(context, ExportType::NotExported, DeclarationDefaultContext::Standard, functionConstructorParametersEndPosition);
             break;
         }
@@ -696,7 +696,7 @@
             // but could be mistakenly parsed as an AsyncFunctionExpression.
             SavePoint savePoint = createSavePoint();
             next();
-            if (UNLIKELY(match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken())) {
+            if (UNLIKELY(match(FUNCTION) && !m_lexer->prevTerminator())) {
                 result = parseAsyncFunctionDeclaration(context);
                 break;
             }
@@ -2026,7 +2026,7 @@
     ASSERT(matchContextualKeyword(m_vm->propertyNames->async));
     SavePoint savePoint = createSavePoint();
     next();
-    if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken()) {
+    if (match(FUNCTION) && !m_lexer->prevTerminator()) {
         const bool isAsync = true;
         result = parseFunctionDeclarationStatement(context, isAsync, parentAllowsFunctionDeclarationAsStatement);
         return true;
@@ -2421,7 +2421,7 @@
 
         matchOrFail(ARROWFUNCTION, "Expected a '=>' after arrow function parameter declaration");
 
-        if (m_lexer->hasLineTerminatorBeforeToken())
+        if (m_lexer->prevTerminator())
             failDueToUnexpectedToken();
 
         ASSERT(constructorKind == ConstructorKind::None);
@@ -2612,8 +2612,6 @@
         functionScope->fillParametersForSourceProviderCache(parameters, nonLocalCapturesFromParameterExpressions);
         newInfo = SourceProviderCacheItem::create(parameters);
     }
-
-    bool functionScopeWasStrictMode = functionScope->strictMode();
     
     popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo);
     
@@ -2620,15 +2618,6 @@
     if (functionBodyType != ArrowFunctionBodyExpression) {
         matchOrFail(CLOSEBRACE, "Expected a closing '}' after a ", stringForFunctionMode(mode), " body");
         next();
-    } else {
-        // We need to lex the last token again because the last token is lexed under the different context because of the following possibilities.
-        // 1. which may have different strict mode.
-        // 2. which may not build strings for tokens.
-        // 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"`).
-        // So we only check TreeBuilder's type here.
-        ASSERT_UNUSED(functionScopeWasStrictMode, functionScopeWasStrictMode == currentScope()->strictMode());
-        if (!std::is_same<TreeBuilder, SyntaxChecker>::value)
-            lexCurrentTokenAgainUnderCurrentContext();
     }
 
     if (newInfo)
@@ -2887,7 +2876,7 @@
                 if (!isGeneratorMethodParseMode(parseMode) && !isAsyncMethodParseMode(parseMode)) {
                     ident = m_token.m_data.ident;
                     next();
-                    if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer->hasLineTerminatorBeforeToken())
+                    if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer->prevTerminator())
                         break;
                     if (UNLIKELY(consume(TIMES)))
                         parseMode = SourceParseMode::AsyncGeneratorWrapperMethodMode;
@@ -3407,7 +3396,7 @@
         } else if (matchContextualKeyword(m_vm->propertyNames->async)) {
             SavePoint savePoint = createSavePoint();
             next();
-            if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken()) {
+            if (match(FUNCTION) && !m_lexer->prevTerminator()) {
                 next();
                 if (match(IDENT))
                     localName = m_token.m_data.ident;
@@ -3552,7 +3541,7 @@
         case IDENT:
             if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) {
                 next();
-                semanticFailIfFalse(match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken(), "Expected 'function' keyword following 'async' keyword with no preceding line terminator");
+                semanticFailIfFalse(match(FUNCTION) && !m_lexer->prevTerminator(), "Expected 'function' keyword following 'async' keyword with no preceding line terminator");
                 DepthManager statementDepth(&m_statementDepth);
                 m_statementDepth = 1;
                 result = parseAsyncFunctionDeclaration(context, ExportType::Exported);
@@ -3670,7 +3659,7 @@
             if (UNLIKELY(classifier.indicatesPossibleAsyncArrowFunction())) {
                 if (matchContextualKeyword(m_vm->propertyNames->async)) {
                     next();
-                    isAsyncArrow = !m_lexer->hasLineTerminatorBeforeToken();
+                    isAsyncArrow = !m_lexer->prevTerminator();
                 }
             }
             if (isArrowFunctionParameters()) {
@@ -3787,7 +3776,7 @@
     ASSERT(match(YIELD));
     SavePoint savePoint = createSavePoint();
     next();
-    if (m_lexer->hasLineTerminatorBeforeToken())
+    if (m_lexer->prevTerminator())
         return context.createYield(location);
 
     bool delegate = consume(TIMES);
@@ -3947,7 +3936,7 @@
                     goto namedProperty;
                 }
 
-                failIfTrue(m_lexer->hasLineTerminatorBeforeToken(), "Expected a property name following keyword 'async'");
+                failIfTrue(m_lexer->prevTerminator(), "Expected a property name following keyword 'async'");
                 if (UNLIKELY(consume(TIMES)))
                     parseMode = SourceParseMode::AsyncGeneratorWrapperMethodMode;
                 else
@@ -4496,7 +4485,7 @@
             const Identifier* ident = m_token.m_data.ident;
             JSTokenLocation location(tokenLocation());
             next();
-            if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken())
+            if (match(FUNCTION) && !m_lexer->prevTerminator())
                 return parseAsyncFunctionExpression(context);
 
             // Avoid using variable if it is an arrow function parameter
@@ -4762,7 +4751,7 @@
 
         base = parsePrimaryExpression(context);
         failIfFalse(base, "Cannot parse base _expression_");
-        if (UNLIKELY(isAsync && context.isResolve(base) && !m_lexer->hasLineTerminatorBeforeToken())) {
+        if (UNLIKELY(isAsync && context.isResolve(base) && !m_lexer->prevTerminator())) {
             if (matchSpecIdentifier()) {
                 // AsyncArrowFunction
                 forceClassifyExpressionError(ErrorIndicatesAsyncArrowFunction);

Modified: trunk/Source/_javascript_Core/parser/Parser.h (244027 => 244028)


--- trunk/Source/_javascript_Core/parser/Parser.h	2019-04-08 17:29:51 UTC (rev 244027)
+++ trunk/Source/_javascript_Core/parser/Parser.h	2019-04-08 18:01:42 UTC (rev 244028)
@@ -1363,16 +1363,6 @@
         m_token.m_type = m_lexer->lex(&m_token, lexerFlags, strictMode());
     }
 
-    ALWAYS_INLINE void nextWithoutClearingLineTerminator(unsigned lexerFlags = 0)
-    {
-        int lastLine = m_token.m_location.line;
-        int lastTokenEnd = m_token.m_location.endOffset;
-        int lastTokenLineStart = m_token.m_location.lineStartOffset;
-        m_lastTokenEndPosition = JSTextPosition(lastLine, lastTokenEnd, lastTokenLineStart);
-        m_lexer->setLastLineNumber(lastLine);
-        m_token.m_type = m_lexer->lexWithoutClearingLineTerminator(&m_token, lexerFlags, strictMode());
-    }
-
     ALWAYS_INLINE void nextExpectIdentifier(unsigned lexerFlags = 0)
     {
         int lastLine = m_token.m_location.line;
@@ -1383,12 +1373,6 @@
         m_token.m_type = m_lexer->lexExpectIdentifier(&m_token, lexerFlags, strictMode());
     }
 
-    ALWAYS_INLINE void lexCurrentTokenAgainUnderCurrentContext()
-    {
-        auto savePoint = createSavePoint();
-        restoreSavePoint(savePoint);
-    }
-
     ALWAYS_INLINE bool nextTokenIsColon()
     {
         return m_lexer->nextTokenIsColon();
@@ -1778,7 +1762,6 @@
         unsigned oldLineStartOffset;
         unsigned oldLastLineNumber;
         unsigned oldLineNumber;
-        bool hasLineTerminatorBeforeToken;
     };
 
     // If you're using this directly, you probably should be using
@@ -1792,7 +1775,6 @@
         result.oldLineStartOffset = m_token.m_location.lineStartOffset;
         result.oldLastLineNumber = m_lexer->lastLineNumber();
         result.oldLineNumber = m_lexer->lineNumber();
-        result.hasLineTerminatorBeforeToken = m_lexer->hasLineTerminatorBeforeToken();
         ASSERT(static_cast<unsigned>(result.startOffset) >= result.oldLineStartOffset);
         return result;
     }
@@ -1802,8 +1784,7 @@
         // setOffset clears lexer errors.
         m_lexer->setOffset(lexerState.startOffset, lexerState.oldLineStartOffset);
         m_lexer->setLineNumber(lexerState.oldLineNumber);
-        m_lexer->setHasLineTerminatorBeforeToken(lexerState.hasLineTerminatorBeforeToken);
-        nextWithoutClearingLineTerminator();
+        next();
         m_lexer->setLastLineNumber(lexerState.oldLastLineNumber);
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to