Changeset 87838 in webkit
- Timestamp:
- Jun 1, 2011 1:09:04 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r87826 r87838 1 2011-06-01 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 Add single character lookup cache to IdentifierArena 6 https://bugs.webkit.org/show_bug.cgi?id=61879 7 8 Add a simple lookup cache for single ascii character 9 identifiers. Produces around a 2% improvement in parse 10 time for my adhoc parser test. 11 12 * parser/ParserArena.h: 13 (JSC::IdentifierArena::IdentifierArena): 14 (JSC::IdentifierArena::clear): 15 (JSC::IdentifierArena::makeIdentifier): 16 1 17 2011-05-31 Oliver Hunt <oliver@apple.com> 2 18 -
trunk/Source/JavaScriptCore/parser/ParserArena.h
r76248 r87838 38 38 WTF_MAKE_FAST_ALLOCATED; 39 39 public: 40 IdentifierArena() 41 { 42 clear(); 43 } 44 40 45 ALWAYS_INLINE const Identifier& makeIdentifier(JSGlobalData*, const UChar* characters, size_t length); 41 46 const Identifier& makeNumericIdentifier(JSGlobalData*, double number); 42 47 43 void clear() { m_identifiers.clear(); } 48 void clear() 49 { 50 m_identifiers.clear(); 51 for (unsigned i = 0; i < 128; i++) 52 m_shortIdentifiers[i] = 0; 53 } 44 54 bool isEmpty() const { return m_identifiers.isEmpty(); } 45 55 46 56 private: 57 static const int MaximumCachableCharacter = 128; 47 58 typedef SegmentedVector<Identifier, 64> IdentifierVector; 48 59 IdentifierVector m_identifiers; 60 FixedArray<Identifier*, MaximumCachableCharacter> m_shortIdentifiers; 49 61 }; 50 62 51 63 ALWAYS_INLINE const Identifier& IdentifierArena::makeIdentifier(JSGlobalData* globalData, const UChar* characters, size_t length) 52 64 { 65 if (length == 1 && characters[0] < MaximumCachableCharacter) { 66 if (Identifier* ident = m_shortIdentifiers[characters[0]]) 67 return *ident; 68 m_identifiers.append(Identifier(globalData, characters, length)); 69 m_shortIdentifiers[characters[0]] = &m_identifiers.last(); 70 return m_identifiers.last(); 71 } 53 72 m_identifiers.append(Identifier(globalData, characters, length)); 54 73 return m_identifiers.last();
Note: See TracChangeset
for help on using the changeset viewer.