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/ChangeLog

    r223123 r223124  
     12017-10-09  Yusuke Suzuki  <[email protected]>
     2
     3        `async` should be able to be used as an imported binding name
     4        https://bugs.webkit.org/show_bug.cgi?id=176573
     5
     6        Reviewed by Saam Barati.
     7
     8        Previously, we have ASYNC keyword in the parser. This is introduced only for performance,
     9        and ECMA262 spec does not categorize "async" to keyword. This makes parser code complicated,
     10        since ASYNC should be handled as IDENT. If we missed this ASYNC keyword, we cause a bug.
     11        For example, import declaration failed to bind imported binding to the name "async" because
     12        the parser considered ASYNC as keyword.
     13
     14        This patch removes ASYNC keyword from the parser. By carefully handling ASYNC, we can keep
     15        the current performance without using this ASYNC keyword.
     16
     17        We also add `escaped` field to token data since contextual keyword is valid only if it does
     18        not contain any escape sequences. We fix bunch of contextual keyword use with this fix too
     19        e.g. `of in for-of`. This improves test262 score.
     20
     21        * parser/Keywords.table:
     22        * parser/Lexer.cpp:
     23        (JSC::Lexer<LChar>::parseIdentifier):
     24        (JSC::Lexer<UChar>::parseIdentifier):
     25        (JSC::Lexer<CharacterType>::parseIdentifierSlowCase):
     26        * parser/Parser.cpp:
     27        (JSC::Parser<LexerType>::parseStatementListItem):
     28        (JSC::Parser<LexerType>::parseForStatement):
     29        (JSC::Parser<LexerType>::parseStatement):
     30        (JSC::Parser<LexerType>::maybeParseAsyncFunctionDeclarationStatement):
     31        (JSC::Parser<LexerType>::parseClass):
     32        (JSC::Parser<LexerType>::parseExportDeclaration):
     33        (JSC::Parser<LexerType>::parseAssignmentExpression):
     34        (JSC::Parser<LexerType>::parseProperty):
     35        (JSC::Parser<LexerType>::parsePrimaryExpression):
     36        (JSC::Parser<LexerType>::parseMemberExpression):
     37        (JSC::Parser<LexerType>::printUnexpectedTokenText):
     38        * parser/Parser.h:
     39        (JSC::Parser::matchContextualKeyword):
     40        * parser/ParserTokens.h:
     41        * runtime/CommonIdentifiers.h:
     42
    1432017-10-09  Saam Barati  <[email protected]>
    244
Note: See TracChangeset for help on using the changeset viewer.