Changeset 185437 in webkit


Ignore:
Timestamp:
Jun 10, 2015 4:43:20 PM (9 years ago)
Author:
Yusuke Suzuki
Message:

JavaScript: Drop the “escaped reserved words as identifiers” compatibility measure
https://bugs.webkit.org/show_bug.cgi?id=90678

Reviewed by Darin Adler.

After ES6, escaped reserved words in identifiers are prohibited.
After parsing Identifier, we should perform m_buffer16.shrink(0).

  • parser/Lexer.cpp:

(JSC::Lexer<CharacterType>::parseIdentifierSlowCase):

  • tests/mozilla/ecma_3/Unicode/uc-003.js:

(test): Deleted.

  • tests/stress/reserved-word-with-escape.js: Added.

(testSyntax):
(testSyntaxError):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r185432 r185437  
     12015-06-10  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        JavaScript: Drop the “escaped reserved words as identifiers” compatibility measure
     4        https://bugs.webkit.org/show_bug.cgi?id=90678
     5
     6        Reviewed by Darin Adler.
     7
     8        After ES6, escaped reserved words in identifiers are prohibited.
     9        After parsing Identifier, we should perform `m_buffer16.shrink(0)`.
     10
     11        * parser/Lexer.cpp:
     12        (JSC::Lexer<CharacterType>::parseIdentifierSlowCase):
     13        * tests/mozilla/ecma_3/Unicode/uc-003.js:
     14        (test): Deleted.
     15        * tests/stress/reserved-word-with-escape.js: Added.
     16        (testSyntax):
     17        (testSyntaxError):
     18
    1192015-06-10  Jordan Harband  <ljharb@gmail.com>
    220
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r185419 r185437  
    10411041template<typename CharacterType> template<bool shouldCreateIdentifier> JSTokenType Lexer<CharacterType>::parseIdentifierSlowCase(JSTokenData* tokenData, unsigned lexerFlags, bool strictMode)
    10421042{
    1043     const ptrdiff_t remaining = m_codeEnd - m_code;
    10441043    auto identifierStart = currentSourcePtr();
    10451044    bool bufferRequired = false;
     
    10871086        tokenData->ident = nullptr;
    10881087
    1089     if (LIKELY(!bufferRequired && !(lexerFlags & LexerFlagsIgnoreReservedWords))) {
     1088    m_buffer16.shrink(0);
     1089
     1090    if (LIKELY(!(lexerFlags & LexerFlagsIgnoreReservedWords))) {
    10901091        ASSERT(shouldCreateIdentifier);
    1091         // Keywords must not be recognized if there was an \uXXXX in the identifier.
    1092         if (remaining < maxTokenLength) {
    1093             const HashTableValue* entry = m_vm->keywords->getKeyword(*ident);
    1094             ASSERT((remaining < maxTokenLength) || !entry);
    1095             if (!entry)
    1096                 return IDENT;
    1097             JSTokenType token = static_cast<JSTokenType>(entry->lexerValue());
    1098             return (token != RESERVED_IF_STRICT) || strictMode ? token : IDENT;
    1099         }
    1100         return IDENT;
    1101     }
    1102 
    1103     m_buffer16.shrink(0);
     1092        const HashTableValue* entry = m_vm->keywords->getKeyword(*ident);
     1093        if (!entry)
     1094            return IDENT;
     1095        JSTokenType token = static_cast<JSTokenType>(entry->lexerValue());
     1096        return (token != RESERVED_IF_STRICT) || strictMode ? token : IDENT;
     1097    }
     1098
    11041099    return IDENT;
    11051100}
  • trunk/Source/JavaScriptCore/tests/mozilla/ecma_3/Unicode/uc-003.js

    r11995 r185437  
    3131    var \u0041 = 5;
    3232    var A\u03B2 = 15;
    33     var c\u0061se = 25;
    3433
    3534    printStatus ("Escapes in identifiers test.");
     
    4544    reportCompare (16, eval("++A\u03B2"),
    4645                   "Escaped non-ASCII Identifier test");
    47     reportCompare (25, eval("c\\u00" + "61se"),
    48                    "Escaped keyword Identifier test");
    49     reportCompare (26, eval("++c\\u00" + "61se"),
    50                    "Escaped keyword Identifier test");
    5146   
    5247    exitFunc ("test");
Note: See TracChangeset for help on using the changeset viewer.