Changeset 34412 in webkit for trunk/JavaScriptCore/kjs/identifier.cpp
- Timestamp:
- Jun 6, 2008, 11:03:24 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/identifier.cpp
r34361 r34412 29 29 #include <wtf/FastMalloc.h> 30 30 #include <wtf/HashSet.h> 31 #if USE(MULTIPLE_THREADS)32 #include <wtf/ThreadSpecific.h>33 using namespace WTF;34 #endif35 31 36 32 namespace KJS { 33 34 typedef HashMap<const char*, RefPtr<UString::Rep>, PtrHash<const char*> > LiteralIdentifierTable; 37 35 38 36 class IdentifierTable { … … 62 60 void remove(UString::Rep* r) { m_table.remove(r); } 63 61 62 LiteralIdentifierTable& literalTable() { return m_literalTable; } 63 64 64 private: 65 65 HashSet<UString::Rep*> m_table; 66 }; 67 68 typedef HashMap<const char*, RefPtr<UString::Rep>, PtrHash<const char*> > LiteralIdentifierTable; 69 70 static inline IdentifierTable& identifierTable() 71 { 72 #if USE(MULTIPLE_THREADS) 73 static ThreadSpecific<IdentifierTable> table; 74 return *table; 75 #else 76 static IdentifierTable table; 77 return table; 78 #endif 79 } 80 81 static inline LiteralIdentifierTable& literalIdentifierTable() 82 { 83 #if USE(MULTIPLE_THREADS) 84 static ThreadSpecific<LiteralIdentifierTable> table; 85 return *table; 86 #else 87 static LiteralIdentifierTable table; 88 return table; 89 #endif 90 } 91 92 void Identifier::initializeIdentifierThreading() 93 { 94 identifierTable(); 95 literalIdentifierTable(); 66 LiteralIdentifierTable m_literalTable; 67 }; 68 69 IdentifierTable* createIdentifierTable() 70 { 71 return new IdentifierTable; 72 } 73 74 void deleteIdentifierTable(IdentifierTable* table) 75 { 76 delete table; 96 77 } 97 78 … … 156 137 } 157 138 158 LiteralIdentifierTable& literalTableLocalRef = literalIdentifierTable(); 159 160 const LiteralIdentifierTable::iterator& iter = literalTableLocalRef.find(c); 161 if (iter != literalTableLocalRef.end()) 139 IdentifierTable& identifierTable = *JSGlobalData::threadInstance().identifierTable; 140 LiteralIdentifierTable& literalIdentifierTable = identifierTable.literalTable(); 141 142 const LiteralIdentifierTable::iterator& iter = literalIdentifierTable.find(c); 143 if (iter != literalIdentifierTable.end()) 162 144 return iter->second; 163 145 164 UString::Rep* addedString = *identifierTable().add<const char*, CStringTranslator>(c).first; 165 literalTableLocalRef.add(c, addedString); 146 UString::Rep* addedString = *identifierTable.add<const char*, CStringTranslator>(c).first; 147 literalIdentifierTable.add(c, addedString); 148 149 return addedString; 150 } 151 152 PassRefPtr<UString::Rep> Identifier::add(JSGlobalData* globalData, const char* c) 153 { 154 if (!c) { 155 UString::Rep::null.hash(); 156 return &UString::Rep::null; 157 } 158 159 if (!c[0]) { 160 UString::Rep::empty.hash(); 161 return &UString::Rep::empty; 162 } 163 164 IdentifierTable& identifierTable = *globalData->identifierTable; 165 LiteralIdentifierTable& literalIdentifierTable = identifierTable.literalTable(); 166 167 const LiteralIdentifierTable::iterator& iter = literalIdentifierTable.find(c); 168 if (iter != literalIdentifierTable.end()) 169 return iter->second; 170 171 UString::Rep* addedString = *identifierTable.add<const char*, CStringTranslator>(c).first; 172 literalIdentifierTable.add(c, addedString); 166 173 167 174 return addedString; … … 207 214 208 215 UCharBuffer buf = {s, length}; 209 return * identifierTable().add<UCharBuffer, UCharBufferTranslator>(buf).first;216 return *JSGlobalData::threadInstance().identifierTable->add<UCharBuffer, UCharBufferTranslator>(buf).first; 210 217 } 211 218 … … 219 226 } 220 227 221 return * identifierTable().add(r).first;228 return *JSGlobalData::threadInstance().identifierTable->add(r).first; 222 229 } 223 230
Note:
See TracChangeset
for help on using the changeset viewer.