Changeset 88094 in webkit
- Timestamp:
- Jun 3, 2011 11:15:43 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r88093 r88094 1 2011-06-03 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Lexer needs to provide Identifier for reserved words 6 https://bugs.webkit.org/show_bug.cgi?id=62086 7 8 Alas it is necessary to provide an Identifier reference for keywords 9 so that we can do the right thing when they're used in object literals. 10 We now keep Identifiers for all reserved words in the CommonIdentifiers 11 structure so that we can access them without a hash lookup. 12 13 * KeywordLookupGenerator.py: 14 * parser/Lexer.cpp: 15 (JSC::Lexer::parseIdentifier): 16 * parser/Lexer.h: 17 * runtime/CommonIdentifiers.cpp: 18 (JSC::CommonIdentifiers::CommonIdentifiers): 19 * runtime/CommonIdentifiers.h: 20 1 21 2011-06-03 Gavin Barraclough <barraclough@apple.com> 2 22 -
trunk/Source/JavaScriptCore/KeywordLookupGenerator.py
r88083 r88094 128 128 print(str + "if (!isIdentPart(code[%d])) {" % (len(self.fullPrefix))) 129 129 print(str + " internalShift<%d, DoNotBoundsCheck>();" % len(self.fullPrefix)) 130 print(str + " if (shouldCreateIdentifier)") 131 print(str + (" data->ident = &m_globalData->propertyNames->%sKeyword;" % self.fullPrefix)) 130 132 print(str + " return " + self.value + ";") 131 133 print(str + "}") … … 167 169 # max length + 1 so we don't need to do any bounds checking at all 168 170 print("static const int maxTokenLength = %d;" % (self.maxLength() + 1)) 169 print(" ALWAYS_INLINE JSTokenType Lexer::parseKeyword() {")171 print("template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer::parseKeyword(JSTokenData* data) {") 170 172 print(" ASSERT(m_codeEnd - m_code >= maxTokenLength);") 171 173 print(" const UChar* code = m_code;") -
trunk/Source/JavaScriptCore/parser/Lexer.cpp
r88083 r88094 415 415 const ptrdiff_t remaining = m_codeEnd - m_code; 416 416 if ((remaining >= maxTokenLength) && !(lexType & IgnoreReservedWords)) { 417 JSTokenType keyword = parseKeyword(); 418 if (keyword != IDENT) 417 JSTokenType keyword = parseKeyword<shouldCreateIdentifier>(lvalp); 418 if (keyword != IDENT) { 419 ASSERT((!shouldCreateIdentifier) || lvalp->ident); 419 420 return keyword; 421 } 420 422 } 421 423 const UChar* identifierStart = currentCharacter(); -
trunk/Source/JavaScriptCore/parser/Lexer.h
r88084 r88094 116 116 enum ShiftType { DoBoundsCheck, DoNotBoundsCheck }; 117 117 template <int shiftAmount, ShiftType shouldBoundsCheck> void internalShift(); 118 ALWAYS_INLINE JSTokenType parseKeyword();118 template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType parseKeyword(JSTokenData*); 119 119 template <bool shouldBuildIdentifiers> ALWAYS_INLINE JSTokenType parseIdentifier(JSTokenData*, unsigned); 120 120 template <bool shouldBuildStrings> ALWAYS_INLINE bool parseString(JSTokenData* lvalp, bool strictMode); -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp
r69516 r88094 27 27 28 28 #define INITIALIZE_PROPERTY_NAME(name) , name(globalData, #name) 29 #define INITIALIZE_KEYWORD(name) , name##Keyword(globalData, #name) 29 30 30 31 CommonIdentifiers::CommonIdentifiers(JSGlobalData* globalData) … … 34 35 , thisIdentifier(globalData, "this") 35 36 , useStrictIdentifier(globalData, "use strict") 37 JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(INITIALIZE_KEYWORD) 36 38 JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_PROPERTY_NAME) 37 39 { -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r80378 r88094 76 76 macro(displayName) 77 77 78 #define JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(macro) \ 79 macro(null) \ 80 macro(true) \ 81 macro(false) \ 82 macro(break) \ 83 macro(case) \ 84 macro(catch) \ 85 macro(const) \ 86 macro(default) \ 87 macro(finally) \ 88 macro(for) \ 89 macro(instanceof) \ 90 macro(new) \ 91 macro(var) \ 92 macro(continue) \ 93 macro(function) \ 94 macro(return) \ 95 macro(void) \ 96 macro(delete) \ 97 macro(if) \ 98 macro(this) \ 99 macro(do) \ 100 macro(while) \ 101 macro(else) \ 102 macro(in) \ 103 macro(switch) \ 104 macro(throw) \ 105 macro(try) \ 106 macro(typeof) \ 107 macro(with) \ 108 macro(debugger) \ 109 macro(class) \ 110 macro(enum) \ 111 macro(export) \ 112 macro(extends) \ 113 macro(import) \ 114 macro(super) 115 78 116 namespace JSC { 79 117 … … 91 129 const Identifier useStrictIdentifier; 92 130 131 132 #define JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL(name) const Identifier name##Keyword; 133 JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL) 134 #undef JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL 135 93 136 #define JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) const Identifier name; 94 137 JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
Note: See TracChangeset
for help on using the changeset viewer.