Ignore:
Timestamp:
Oct 9, 2017, 10:53:12 PM (8 years ago)
Author:
Yusuke Suzuki
Message:

async should be able to be used as an imported binding name
https://bugs.webkit.org/show_bug.cgi?id=176573

Reviewed by Saam Barati.

JSTests:

  • modules/import-default-async.js: Added.
  • modules/import-named-async-as.js: Added.
  • modules/import-named-async.js: Added.
  • modules/import-named-async/target.js: Added.
  • modules/import-namespace-async.js: Added.
  • test262.yaml:

Source/JavaScriptCore:

Previously, we have ASYNC keyword in the parser. This is introduced only for performance,
and ECMA262 spec does not categorize "async" to keyword. This makes parser code complicated,
since ASYNC should be handled as IDENT. If we missed this ASYNC keyword, we cause a bug.
For example, import declaration failed to bind imported binding to the name "async" because
the parser considered ASYNC as keyword.

This patch removes ASYNC keyword from the parser. By carefully handling ASYNC, we can keep
the current performance without using this ASYNC keyword.

We also add escaped field to token data since contextual keyword is valid only if it does
not contain any escape sequences. We fix bunch of contextual keyword use with this fix too
e.g. of in for-of. This improves test262 score.

  • parser/Keywords.table:
  • parser/Lexer.cpp:

(JSC::Lexer<LChar>::parseIdentifier):
(JSC::Lexer<UChar>::parseIdentifier):
(JSC::Lexer<CharacterType>::parseIdentifierSlowCase):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseStatementListItem):
(JSC::Parser<LexerType>::parseForStatement):
(JSC::Parser<LexerType>::parseStatement):
(JSC::Parser<LexerType>::maybeParseAsyncFunctionDeclarationStatement):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseExportDeclaration):
(JSC::Parser<LexerType>::parseAssignmentExpression):
(JSC::Parser<LexerType>::parseProperty):
(JSC::Parser<LexerType>::parsePrimaryExpression):
(JSC::Parser<LexerType>::parseMemberExpression):
(JSC::Parser<LexerType>::printUnexpectedTokenText):

  • parser/Parser.h:

(JSC::Parser::matchContextualKeyword):

  • parser/ParserTokens.h:
  • runtime/CommonIdentifiers.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r221849 r223124  
    13711371    ALWAYS_INLINE bool matchContextualKeyword(const Identifier& identifier)
    13721372    {
    1373         return m_token.m_type == IDENT && *m_token.m_data.ident == identifier;
     1373        return m_token.m_type == IDENT && *m_token.m_data.ident == identifier && !m_token.m_data.escaped;
    13741374    }
    13751375
Note: See TracChangeset for help on using the changeset viewer.