Modified: trunk/Source/_javascript_Core/ChangeLog (131955 => 131956)
--- trunk/Source/_javascript_Core/ChangeLog 2012-10-19 23:21:40 UTC (rev 131955)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-10-19 23:23:34 UTC (rev 131956)
@@ -1,3 +1,22 @@
+2012-10-19 Michael Saboff <msab...@apple.com>
+
+ 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):
+
2012-10-19 Mark Lam <mark....@apple.com>
Added WTF::StackStats mechanism.
Modified: trunk/Source/_javascript_Core/parser/Lexer.cpp (131955 => 131956)
--- trunk/Source/_javascript_Core/parser/Lexer.cpp 2012-10-19 23:21:40 UTC (rev 131955)
+++ trunk/Source/_javascript_Core/parser/Lexer.cpp 2012-10-19 23:23:34 UTC (rev 131956)
@@ -1617,7 +1617,7 @@
}
}
- pattern = makeIdentifier(m_buffer16.data(), m_buffer16.size());
+ pattern = makeIdentifierSameType(m_buffer16.data(), m_buffer16.size());
m_buffer16.resize(0);
while (isIdentPart(m_current)) {
@@ -1625,7 +1625,7 @@
shift();
}
- flags = makeIdentifier(m_buffer16.data(), m_buffer16.size());
+ flags = makeIdentifierSameType(m_buffer16.data(), m_buffer16.size());
m_buffer16.resize(0);
return true;
Modified: trunk/Source/_javascript_Core/parser/Lexer.h (131955 => 131956)
--- trunk/Source/_javascript_Core/parser/Lexer.h 2012-10-19 23:21:40 UTC (rev 131955)
+++ trunk/Source/_javascript_Core/parser/Lexer.h 2012-10-19 23:23:34 UTC (rev 131956)
@@ -146,6 +146,9 @@
ALWAYS_INLINE const Identifier* makeIdentifier(const LChar* characters, size_t length);
ALWAYS_INLINE const Identifier* makeIdentifier(const UChar* characters, size_t length);
+ ALWAYS_INLINE const Identifier* makeLCharIdentifier(const LChar* characters, size_t length);
+ ALWAYS_INLINE const Identifier* makeLCharIdentifier(const UChar* characters, size_t length);
+ ALWAYS_INLINE const Identifier* makeIdentifierSameType(const UChar* characters, size_t length);
ALWAYS_INLINE const Identifier* makeIdentifierLCharFromUChar(const UChar* characters, size_t length);
ALWAYS_INLINE bool lastTokenWasRestrKeyword() const;
@@ -239,6 +242,18 @@
}
template <>
+ALWAYS_INLINE const Identifier* Lexer<LChar>::makeIdentifierSameType(const UChar* characters, size_t length)
+{
+ return &m_arena->makeIdentifierLCharFromUChar(m_globalData, characters, length);
+}
+
+template <>
+ALWAYS_INLINE const Identifier* Lexer<UChar>::makeIdentifierSameType(const UChar* characters, size_t length)
+{
+ return &m_arena->makeIdentifier(m_globalData, characters, length);
+}
+
+template <>
ALWAYS_INLINE void Lexer<LChar>::setCodeStart(const StringImpl* sourceString)
{
ASSERT(sourceString->is8Bit());
@@ -259,6 +274,18 @@
}
template <typename T>
+ALWAYS_INLINE const Identifier* Lexer<T>::makeLCharIdentifier(const LChar* characters, size_t length)
+{
+ return &m_arena->makeIdentifier(m_globalData, characters, length);
+}
+
+template <typename T>
+ALWAYS_INLINE const Identifier* Lexer<T>::makeLCharIdentifier(const UChar* characters, size_t length)
+{
+ return &m_arena->makeIdentifierLCharFromUChar(m_globalData, characters, length);
+}
+
+template <typename T>
ALWAYS_INLINE JSTokenType Lexer<T>::lexExpectIdentifier(JSTokenData* tokenData, JSTokenLocation* tokenLocation, unsigned lexerFlags, bool strictMode)
{
ASSERT((lexerFlags & LexerFlagsIgnoreReservedWords));
@@ -293,7 +320,7 @@
if (lexerFlags & LexexFlagsDontBuildKeywords)
tokenData->ident = 0;
else
- tokenData->ident = makeIdentifier(start, ptr - start);
+ tokenData->ident = makeLCharIdentifier(start, ptr - start);
tokenLocation->line = m_lineNumber;
tokenLocation->startOffset = start - m_codeStart;
tokenLocation->endOffset = currentOffset();