Changeset 131956 in webkit for trunk/Source/JavaScriptCore/parser


Ignore:
Timestamp:
Oct 19, 2012, 4:23:34 PM (13 years ago)
Author:
[email protected]
Message:

Lexer should create 8 bit Identifiers for RegularExpressions and ASCII identifiers
https://bugs.webkit.org/show_bug.cgi?id=99855

Reviewed by Filip Pizlo.

Added makeIdentifier helpers that will always make an 8 bit Identifier or make an
Identifier that is the same size as the template parameter. Used the first in the fast
path when looking for a JS identifier and the second when scanning regular expressions.

  • parser/Lexer.cpp:

(JSC::::scanRegExp):

  • parser/Lexer.h:

(Lexer):
(JSC::::makeIdentifierSameType):
(JSC::::makeLCharIdentifier):
(JSC::::lexExpectIdentifier):

Location:
trunk/Source/JavaScriptCore/parser
Files:
2 edited

Legend:

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

    r128542 r131956  
    16181618    }
    16191619
    1620     pattern = makeIdentifier(m_buffer16.data(), m_buffer16.size());
     1620    pattern = makeIdentifierSameType(m_buffer16.data(), m_buffer16.size());
    16211621    m_buffer16.resize(0);
    16221622
     
    16261626    }
    16271627
    1628     flags = makeIdentifier(m_buffer16.data(), m_buffer16.size());
     1628    flags = makeIdentifierSameType(m_buffer16.data(), m_buffer16.size());
    16291629    m_buffer16.resize(0);
    16301630
  • trunk/Source/JavaScriptCore/parser/Lexer.h

    r127191 r131956  
    147147    ALWAYS_INLINE const Identifier* makeIdentifier(const LChar* characters, size_t length);
    148148    ALWAYS_INLINE const Identifier* makeIdentifier(const UChar* characters, size_t length);
     149    ALWAYS_INLINE const Identifier* makeLCharIdentifier(const LChar* characters, size_t length);
     150    ALWAYS_INLINE const Identifier* makeLCharIdentifier(const UChar* characters, size_t length);
     151    ALWAYS_INLINE const Identifier* makeIdentifierSameType(const UChar* characters, size_t length);
    149152    ALWAYS_INLINE const Identifier* makeIdentifierLCharFromUChar(const UChar* characters, size_t length);
    150153
     
    240243
    241244template <>
     245ALWAYS_INLINE const Identifier* Lexer<LChar>::makeIdentifierSameType(const UChar* characters, size_t length)
     246{
     247    return &m_arena->makeIdentifierLCharFromUChar(m_globalData, characters, length);
     248}
     249
     250template <>
     251ALWAYS_INLINE const Identifier* Lexer<UChar>::makeIdentifierSameType(const UChar* characters, size_t length)
     252{
     253    return &m_arena->makeIdentifier(m_globalData, characters, length);
     254}
     255
     256template <>
    242257ALWAYS_INLINE void Lexer<LChar>::setCodeStart(const StringImpl* sourceString)
    243258{
     
    255270template <typename T>
    256271ALWAYS_INLINE const Identifier* Lexer<T>::makeIdentifierLCharFromUChar(const UChar* characters, size_t length)
     272{
     273    return &m_arena->makeIdentifierLCharFromUChar(m_globalData, characters, length);
     274}
     275
     276template <typename T>
     277ALWAYS_INLINE const Identifier* Lexer<T>::makeLCharIdentifier(const LChar* characters, size_t length)
     278{
     279    return &m_arena->makeIdentifier(m_globalData, characters, length);
     280}
     281
     282template <typename T>
     283ALWAYS_INLINE const Identifier* Lexer<T>::makeLCharIdentifier(const UChar* characters, size_t length)
    257284{
    258285    return &m_arena->makeIdentifierLCharFromUChar(m_globalData, characters, length);
     
    294321        tokenData->ident = 0;
    295322    else
    296         tokenData->ident = makeIdentifier(start, ptr - start);
     323        tokenData->ident = makeLCharIdentifier(start, ptr - start);
    297324    tokenLocation->line = m_lineNumber;
    298325    tokenLocation->startOffset = start - m_codeStart;
Note: See TracChangeset for help on using the changeset viewer.