Changeset 36124 in webkit for trunk/JavaScriptCore
- Timestamp:
- Sep 5, 2008, 9:58:40 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r36122 r36124 1 2008-09-05 Darin Adler <[email protected]> 2 3 Reviewed by Geoff Garen. 4 5 - fix https://bugs.webkit.org/show_bug.cgi?id=20673 6 single-character strings are churning in the Identifier table 7 8 1.007x as fast on SunSpider overall 9 1.167x as fast on SunSpider string/fasta 10 11 * JavaScriptCore.exp: Updated. 12 * kjs/SmallStrings.cpp: 13 (KJS::SmallStrings::singleCharacterStringRep): Added. 14 * kjs/SmallStrings.h: Added singleCharacterStringRep for clients that 15 need just a UString, not a JSString. 16 * kjs/identifier.cpp: 17 (KJS::Identifier::add): Added special cases for single character strings 18 so that the UString::Rep that ends up in the identifier table is the one 19 from the single-character string optimization; otherwise we end up having 20 to look it up in the identifier table over and over again. 21 (KJS::Identifier::addSlowCase): Ditto. 22 (KJS::Identifier::checkSameIdentifierTable): Made this function an empty 23 inline in release builds so that callers don't have to put #ifndef NDEBUG 24 at each call site. 25 * kjs/identifier.h: 26 (KJS::Identifier::add): Removed #ifndef NDEBUG around the calls to 27 checkSameIdentifierTable. 28 (KJS::Identifier::checkSameIdentifierTable): Added. Empty inline version 29 for NDEBUG builds. 30 1 31 2008-09-05 Mark Rowe <[email protected]> 2 32 -
trunk/JavaScriptCore/JavaScriptCore.exp
r36068 r36124 87 87 __ZN3KJS10Identifier11addSlowCaseEPNS_12JSGlobalDataEPNS_7UString3RepE 88 88 __ZN3KJS10Identifier11addSlowCaseEPNS_9ExecStateEPNS_7UString3RepE 89 __ZN3KJS10Identifier24checkSameIdentifierTableEPNS_12JSGlobalDataEPNS_7UString3RepE90 __ZN3KJS10Identifier24checkSameIdentifierTableEPNS_9ExecStateEPNS_7UString3RepE91 89 __ZN3KJS10Identifier3addEPNS_9ExecStateEPKc 92 90 __ZN3KJS10Identifier5equalEPKNS_7UString3RepEPKc -
trunk/JavaScriptCore/kjs/SmallStrings.cpp
r36006 r36124 102 102 } 103 103 104 UString::Rep* SmallStrings::singleCharacterStringRep(unsigned char character) 105 { 106 if (!m_storage) 107 m_storage.set(new SmallStringsStorage); 108 return m_storage->rep(character); 104 109 } 110 111 } -
trunk/JavaScriptCore/kjs/SmallStrings.h
r36006 r36124 27 27 #define SmallStrings_h 28 28 29 #include "ustring.h" 29 30 #include <wtf/OwnPtr.h> 30 31 … … 53 54 return m_singleCharacterStrings[character]; 54 55 } 56 57 UString::Rep* singleCharacterStringRep(unsigned char character); 55 58 56 59 void mark(); -
trunk/JavaScriptCore/kjs/identifier.cpp
r35898 r36124 130 130 return &UString::Rep::null; 131 131 } 132 133 132 if (!c[0]) { 134 133 UString::Rep::empty.hash(); 135 134 return &UString::Rep::empty; 136 135 } 136 if (!c[1]) 137 return add(globalData, globalData->smallStrings.singleCharacterStringRep(static_cast<unsigned char>(c[0]))); 137 138 138 139 IdentifierTable& identifierTable = *globalData->identifierTable; … … 187 188 PassRefPtr<UString::Rep> Identifier::add(JSGlobalData* globalData, const UChar* s, int length) 188 189 { 190 if (length == 1) { 191 UChar c = s[0]; 192 if (c <= 0xFF) 193 return add(globalData, globalData->smallStrings.singleCharacterStringRep(c)); 194 } 189 195 if (!length) { 190 196 UString::Rep::empty.hash(); 191 197 return &UString::Rep::empty; 192 198 } 193 194 199 UCharBuffer buf = {s, length}; 195 200 return *globalData->identifierTable->add<UCharBuffer, UCharBufferTranslator>(buf).first; … … 204 209 { 205 210 ASSERT(!r->identifierTable()); 206 207 if (r->len == 0) { 211 if (r->len == 1) { 212 UChar c = r->data()[0]; 213 if (c <= 0xFF) 214 r = globalData->smallStrings.singleCharacterStringRep(c); 215 if (r->identifierTable()) { 216 checkSameIdentifierTable(globalData, r); 217 return r; 218 } 219 } 220 if (!r->len) { 208 221 UString::Rep::empty.hash(); 209 222 return &UString::Rep::empty; 210 223 } 211 212 224 return *globalData->identifierTable->add(r).first; 213 225 } … … 224 236 225 237 #ifndef NDEBUG 238 226 239 void Identifier::checkSameIdentifierTable(ExecState* exec, UString::Rep* rep) 227 240 { … … 233 246 ASSERT(rep->identifierTable() == globalData->identifierTable); 234 247 } 235 #else 236 void Identifier::checkSameIdentifierTable(ExecState*, UString::Rep*) 237 { 238 } 239 240 void Identifier::checkSameIdentifierTable(JSGlobalData*, UString::Rep*) 241 { 242 } 248 243 249 #endif 244 250 -
trunk/JavaScriptCore/kjs/identifier.h
r35776 r36124 93 93 { 94 94 if (r->identifierTable()) { 95 #ifndef NDEBUG96 95 checkSameIdentifierTable(exec, r); 97 #endif98 96 return r; 99 97 } … … 103 101 { 104 102 if (r->identifierTable()) { 105 #ifndef NDEBUG106 103 checkSameIdentifierTable(globalData, r); 107 #endif108 104 return r; 109 105 } … … 136 132 void deleteIdentifierTable(IdentifierTable*); 137 133 134 #ifdef NDEBUG 135 inline void Identifier::checkSameIdentifierTable(ExecState*, UString::Rep*) { } 136 inline void Identifier::checkSameIdentifierTable(JSGlobalData*, UString::Rep*) { } 137 #endif 138 138 139 } // namespace KJS 139 140
Note:
See TracChangeset
for help on using the changeset viewer.