Ignore:
Timestamp:
Jan 31, 2014, 5:37:59 PM (12 years ago)
Author:
[email protected]
Message:

2014-01-31 Oliver Hunt <[email protected]>

Rollout r163195 and related patches

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r163195 r163225  
    2626#include "Lexer.h"
    2727
    28 #include "CommonIdentifiers.h"
     28#include "JSFunctionInlines.h"
     29
     30#include "JSGlobalObjectFunctions.h"
    2931#include "Identifier.h"
    30 #include "JSFunctionInlines.h"
    31 #include "JSGlobalObjectFunctions.h"
    3232#include "NodeInfo.h"
    3333#include "Nodes.h"
     
    9191    // Other types (only one so far)
    9292    CharacterWhiteSpace,
    93     CharacterPrivateIdentifierStart
    9493};
    9594
     
    160159/*  62 - >                  */ CharacterGreater,
    161160/*  63 - ?                  */ CharacterQuestion,
    162 /*  64 - @                  */ CharacterPrivateIdentifierStart,
     161/*  64 - @                  */ CharacterInvalid,
    163162/*  65 - A                  */ CharacterIdentifierStart,
    164163/*  66 - B                  */ CharacterIdentifierStart,
     
    488487
    489488template <typename T>
    490 Lexer<T>::Lexer(VM* vm, JSParserStrictness strictness)
     489Lexer<T>::Lexer(VM* vm)
    491490    : m_isReparsing(false)
    492491    , m_vm(vm)
    493     , m_parsingBuiltinFunction(strictness == JSParseBuiltin)
    494492{
    495493}
     
    756754    m_buffer16.append(static_cast<UChar>(c));
    757755}
    758    
    759 #if !ASSERT_DISABLED
    760 bool isSafeIdentifier(VM& vm, const Identifier* ident)
    761 {
    762     if (!ident)
    763         return true;
    764     /* Just block any use of suspicious identifiers.  This is intended to
    765      * be used as a safety net while implementing builtins.
    766      */
    767     if (*ident == vm.propertyNames->call)
    768         return false;
    769     if (*ident == vm.propertyNames->apply)
    770         return false;
    771     if (*ident == vm.propertyNames->eval)
    772         return false;
    773     if (*ident == vm.propertyNames->Function)
    774         return false;
    775     return true;
    776 }
    777 #endif
    778    
     756
    779757template <>
    780758template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer<LChar>::parseIdentifier(JSTokenData* tokenData, unsigned lexerFlags, bool strictMode)
     
    788766        }
    789767    }
    790    
    791     bool isPrivateName = m_current == '@' && m_parsingBuiltinFunction;
    792     if (isPrivateName)
    793         shift();
    794    
     768
    795769    const LChar* identifierStart = currentSourcePtr();
    796770    unsigned identifierLineStart = currentLineStartOffset();
     
    806780    const Identifier* ident = 0;
    807781   
    808     if (shouldCreateIdentifier || m_parsingBuiltinFunction) {
     782    if (shouldCreateIdentifier) {
    809783        int identifierLength = currentSourcePtr() - identifierStart;
    810784        ident = makeIdentifier(identifierStart, identifierLength);
    811         if (m_parsingBuiltinFunction) {
    812             if (!isSafeIdentifier(*m_vm, ident) && !isPrivateName) {
    813                 m_lexErrorMessage = makeString("The use of '", ident->string(), "' is disallowed in builtin functions.");
    814                 return ERRORTOK;
    815             }
    816             if (isPrivateName)
    817                 ident = m_vm->propertyNames->getPrivateName(*ident);
    818             else if (*ident == m_vm->propertyNames->undefinedKeyword)
    819                 tokenData->ident = &m_vm->propertyNames->undefinedKeywordPrivateName;
    820             if (!ident)
    821                 return INVALID_PRIVATE_NAME_ERRORTOK;
    822         }
     785
    823786        tokenData->ident = ident;
    824787    } else
    825788        tokenData->ident = 0;
    826789
    827     if (UNLIKELY((remaining < maxTokenLength) && !(lexerFlags & LexerFlagsIgnoreReservedWords)) && !isPrivateName) {
     790    if (UNLIKELY((remaining < maxTokenLength) && !(lexerFlags & LexerFlagsIgnoreReservedWords))) {
    828791        ASSERT(shouldCreateIdentifier);
    829792        if (remaining < maxTokenLength) {
     
    852815        }
    853816    }
    854    
    855     bool isPrivateName = m_current == '@' && m_parsingBuiltinFunction;
    856     if (isPrivateName)
    857         shift();
    858817
    859818    const UChar* identifierStart = currentSourcePtr();
     
    868827   
    869828    if (UNLIKELY(m_current == '\\')) {
    870         ASSERT(!isPrivateName);
    871829        setOffsetFromSourcePtr(identifierStart, identifierLineStart);
    872830        return parseIdentifierSlowCase<shouldCreateIdentifier>(tokenData, lexerFlags, strictMode);
     
    880838    const Identifier* ident = 0;
    881839   
    882     if (shouldCreateIdentifier || m_parsingBuiltinFunction) {
     840    if (shouldCreateIdentifier) {
    883841        int identifierLength = currentSourcePtr() - identifierStart;
    884842        if (isAll8Bit)
     
    886844        else
    887845            ident = makeIdentifier(identifierStart, identifierLength);
    888         if (m_parsingBuiltinFunction) {
    889             if (!isSafeIdentifier(*m_vm, ident) && !isPrivateName) {
    890                 m_lexErrorMessage = makeString("The use of '", ident->string(), "' is disallowed in builtin functions.");
    891                 return ERRORTOK;
    892             }
    893             if (isPrivateName)
    894                 ident = m_vm->propertyNames->getPrivateName(*ident);
    895             else if (*ident == m_vm->propertyNames->undefinedKeyword)
    896                 tokenData->ident = &m_vm->propertyNames->undefinedKeywordPrivateName;
    897             if (!ident)
    898                 return INVALID_PRIVATE_NAME_ERRORTOK;
    899         }
     846       
    900847        tokenData->ident = ident;
    901848    } else
    902849        tokenData->ident = 0;
    903850   
    904     if (UNLIKELY((remaining < maxTokenLength) && !(lexerFlags & LexerFlagsIgnoreReservedWords)) && !isPrivateName) {
     851    if (UNLIKELY((remaining < maxTokenLength) && !(lexerFlags & LexerFlagsIgnoreReservedWords))) {
    905852        ASSERT(shouldCreateIdentifier);
    906853        if (remaining < maxTokenLength) {
     
    17121659        FALLTHROUGH;
    17131660    case CharacterBackSlash:
    1714         parseIdent:
    17151661        if (lexerFlags & LexexFlagsDontBuildKeywords)
    17161662            token = parseIdentifier<false>(tokenData, lexerFlags, strictMode);
     
    17251671        m_lineStart = m_code;
    17261672        goto start;
    1727     case CharacterPrivateIdentifierStart:
    1728         if (m_parsingBuiltinFunction)
    1729             goto parseIdent;
    1730 
    1731         FALLTHROUGH;
    17321673    case CharacterInvalid:
    17331674        m_lexErrorMessage = invalidCharacterMessage();
Note: See TracChangeset for help on using the changeset viewer.