Changeset 52856 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Jan 6, 2010, 11:33:29 AM (15 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/Completion.cpp
r48905 r52856 37 37 { 38 38 JSLock lock(exec); 39 ASSERT(exec->globalData().identifierTable == currentIdentifierTable()); 39 40 40 41 RefPtr<ProgramExecutable> program = ProgramExecutable::create(exec, source); … … 49 50 { 50 51 JSLock lock(exec); 52 ASSERT(exec->globalData().identifierTable == currentIdentifierTable()); 51 53 52 54 RefPtr<ProgramExecutable> program = ProgramExecutable::create(exec, source); -
trunk/JavaScriptCore/runtime/Identifier.cpp
r52762 r52856 29 29 #include <wtf/HashSet.h> 30 30 31 using WTF::ThreadSpecific; 32 31 33 namespace JSC { 32 34 … … 39 41 HashSet<UString::Rep*>::iterator end = m_table.end(); 40 42 for (HashSet<UString::Rep*>::iterator iter = m_table.begin(); iter != end; ++iter) 41 (*iter)->setI dentifierTable(0);43 (*iter)->setIsIdentifier(false); 42 44 } 43 45 … … 45 47 { 46 48 std::pair<HashSet<UString::Rep*>::iterator, bool> result = m_table.add(value); 47 (*result.first)->setI dentifierTable(this);49 (*result.first)->setIsIdentifier(true); 48 50 return result; 49 51 } … … 53 55 { 54 56 std::pair<HashSet<UString::Rep*>::iterator, bool> result = m_table.add<U, V>(value); 55 (*result.first)->setI dentifierTable(this);57 (*result.first)->setIsIdentifier(true); 56 58 return result; 57 59 } … … 239 241 void Identifier::remove(UString::Rep* r) 240 242 { 241 r->identifierTable()->remove(r);243 currentIdentifierTable()->remove(r); 242 244 } 243 245 244 246 #ifndef NDEBUG 245 247 246 void Identifier::checkSameIdentifierTable(ExecState* exec, UString::Rep* rep)247 { 248 ASSERT( rep->identifierTable() == exec->globalData().identifierTable);249 } 250 251 void Identifier::checkSameIdentifierTable(JSGlobalData* globalData, UString::Rep* rep)252 { 253 ASSERT( rep->identifierTable() == globalData->identifierTable);248 void Identifier::checkSameIdentifierTable(ExecState* exec, UString::Rep*) 249 { 250 ASSERT(exec->globalData().identifierTable == currentIdentifierTable()); 251 } 252 253 void Identifier::checkSameIdentifierTable(JSGlobalData* globalData, UString::Rep*) 254 { 255 ASSERT(globalData->identifierTable == currentIdentifierTable()); 254 256 } 255 257 … … 266 268 #endif 267 269 270 ThreadSpecific<ThreadIdentifierTableData>* g_identifierTableSpecific = 0; 271 272 #if ENABLE(JSC_MULTIPLE_THREADS) 273 274 pthread_once_t createIdentifierTableSpecificOnce = PTHREAD_ONCE_INIT; 275 void createIdentifierTableSpecificCallback() 276 { 277 ASSERT(!g_identifierTableSpecific); 278 g_identifierTableSpecific = new ThreadSpecific<ThreadIdentifierTableData>(); 279 } 280 void createIdentifierTableSpecific() 281 { 282 pthread_once(&createIdentifierTableSpecificOnce, createIdentifierTableSpecificCallback); 283 ASSERT(g_identifierTableSpecific); 284 } 285 286 #else 287 288 void createDefaultDataSpecific() 289 { 290 ASSERT(!g_identifierTableSpecific); 291 g_identifierTableSpecific = new ThreadSpecific<ThreadIdentifierTableData>(); 292 } 293 294 #endif 295 268 296 } // namespace JSC -
trunk/JavaScriptCore/runtime/Identifier.h
r52762 r52856 23 23 24 24 #include "JSGlobalData.h" 25 #include "ThreadSpecific.h" 25 26 #include "UString.h" 26 27 … … 142 143 void deleteIdentifierTable(IdentifierTable*); 143 144 145 struct ThreadIdentifierTableData { 146 ThreadIdentifierTableData() 147 : defaultIdentifierTable(0) 148 , currentIdentifierTable(0) 149 { 150 } 151 152 IdentifierTable* defaultIdentifierTable; 153 IdentifierTable* currentIdentifierTable; 154 }; 155 156 extern WTF::ThreadSpecific<ThreadIdentifierTableData>* g_identifierTableSpecific; 157 void createIdentifierTableSpecific(); 158 159 inline IdentifierTable* defaultIdentifierTable() 160 { 161 if (!g_identifierTableSpecific) 162 createIdentifierTableSpecific(); 163 ThreadIdentifierTableData& data = **g_identifierTableSpecific; 164 165 return data.defaultIdentifierTable; 166 } 167 168 inline void setDefaultIdentifierTable(IdentifierTable* identifierTable) 169 { 170 if (!g_identifierTableSpecific) 171 createIdentifierTableSpecific(); 172 ThreadIdentifierTableData& data = **g_identifierTableSpecific; 173 174 data.defaultIdentifierTable = identifierTable; 175 } 176 177 inline IdentifierTable* currentIdentifierTable() 178 { 179 if (!g_identifierTableSpecific) 180 createIdentifierTableSpecific(); 181 ThreadIdentifierTableData& data = **g_identifierTableSpecific; 182 183 return data.currentIdentifierTable; 184 } 185 186 inline IdentifierTable* setCurrentIdentifierTable(IdentifierTable* identifierTable) 187 { 188 if (!g_identifierTableSpecific) 189 createIdentifierTableSpecific(); 190 ThreadIdentifierTableData& data = **g_identifierTableSpecific; 191 192 IdentifierTable* oldIdentifierTable = data.currentIdentifierTable; 193 data.currentIdentifierTable = identifierTable; 194 return oldIdentifierTable; 195 } 196 197 inline void resetCurrentIdentifierTable() 198 { 199 if (!g_identifierTableSpecific) 200 createIdentifierTableSpecific(); 201 ThreadIdentifierTableData& data = **g_identifierTableSpecific; 202 203 data.currentIdentifierTable = data.defaultIdentifierTable; 204 } 205 144 206 } // namespace JSC 145 207 -
trunk/JavaScriptCore/runtime/JSGlobalData.cpp
r52082 r52856 46 46 #include "JSPropertyNameIterator.h" 47 47 #include "JSStaticScopeObject.h" 48 #include "Parser.h"49 48 #include "Lexer.h" 50 49 #include "Lookup.h" 51 50 #include "Nodes.h" 51 #include "Parser.h" 52 52 53 53 #if ENABLE(JSC_MULTIPLE_THREADS) … … 203 203 } 204 204 205 PassRefPtr<JSGlobalData> JSGlobalData::create(bool isShared) 206 { 207 return adoptRef(new JSGlobalData(isShared, VPtrSet())); 205 PassRefPtr<JSGlobalData> JSGlobalData::createNonDefault() 206 { 207 return adoptRef(new JSGlobalData(false, VPtrSet())); 208 } 209 210 PassRefPtr<JSGlobalData> JSGlobalData::create() 211 { 212 JSGlobalData* globalData = new JSGlobalData(false, VPtrSet()); 213 setDefaultIdentifierTable(globalData->identifierTable); 214 setCurrentIdentifierTable(globalData->identifierTable); 215 return adoptRef(globalData); 208 216 } 209 217 … … 225 233 JSGlobalData*& instance = sharedInstanceInternal(); 226 234 if (!instance) { 227 instance = create(true).releaseRef();235 instance = new JSGlobalData(true, VPtrSet()); 228 236 #if ENABLE(JSC_MULTIPLE_THREADS) 229 237 instance->makeUsableFromMultipleThreads(); -
trunk/JavaScriptCore/runtime/JSGlobalData.h
r52082 r52856 94 94 static JSGlobalData& sharedInstance(); 95 95 96 static PassRefPtr<JSGlobalData> create( bool isShared = false);96 static PassRefPtr<JSGlobalData> create(); 97 97 static PassRefPtr<JSGlobalData> createLeaked(); 98 static PassRefPtr<JSGlobalData> createNonDefault(); 98 99 ~JSGlobalData(); 99 100 -
trunk/JavaScriptCore/runtime/UStringImpl.cpp
r52776 r52856 65 65 checkConsistency(); 66 66 67 if (i dentifierTable())67 if (isIdentifier()) 68 68 Identifier::remove(this); 69 69 -
trunk/JavaScriptCore/runtime/UStringImpl.h
r52776 r52856 138 138 unsigned computedHash() const { ASSERT(m_hash); return m_hash; } // fast path for Identifiers 139 139 void setHash(unsigned hash) { ASSERT(hash == computeHash(data(), m_length)); m_hash = hash; } // fast path for Identifiers 140 bool isIdentifier() const { return m_identifierTable; } 141 IdentifierTable* identifierTable() const { return m_identifierTable; } 142 void setIdentifierTable(IdentifierTable* table) { ASSERT(!isStatic()); m_identifierTable = table; } 140 bool isIdentifier() const { return m_isIdentifier; } 141 void setIsIdentifier(bool isIdentifier) { m_isIdentifier = isIdentifier; } 143 142 144 143 UStringImpl* ref() { m_refCount += s_refCountIncrement; return this; } … … 174 173 ASSERT(bufferOwnerString()->bufferOwnership() != BufferSubstring); 175 174 // Static strings cannot be put in identifier tables, because they are globally shared. 176 ASSERT(!isStatic() || !i dentifierTable());175 ASSERT(!isStatic() || !isIdentifier()); 177 176 } 178 177 … … 194 193 , m_refCount(s_refCountIncrement) 195 194 , m_hash(0) 196 , m_i dentifierTable(0)195 , m_isIdentifier(false) 197 196 , m_dataBuffer(0, ownership) 198 197 { … … 210 209 , m_refCount(s_staticRefCountInitialValue) 211 210 , m_hash(0) 212 , m_i dentifierTable(0)211 , m_isIdentifier(false) 213 212 , m_dataBuffer(0, BufferOwned) 214 213 { … … 222 221 , m_refCount(s_refCountIncrement) 223 222 , m_hash(0) 224 , m_i dentifierTable(0)223 , m_isIdentifier(false) 225 224 , m_dataBuffer(base.releaseRef(), BufferSubstring) 226 225 { … … 239 238 , m_refCount(s_refCountIncrement) 240 239 , m_hash(0) 241 , m_i dentifierTable(0)240 , m_isIdentifier(false) 242 241 , m_dataBuffer(sharedBuffer.releaseRef(), BufferShared) 243 242 { … … 269 268 int m_length; 270 269 unsigned m_refCount; 271 mutable unsigned m_hash ;272 IdentifierTable* m_identifierTable;270 mutable unsigned m_hash : 31; 271 mutable unsigned m_isIdentifier : 1; 273 272 UntypedPtrAndBitfield m_dataBuffer; 274 273
Note:
See TracChangeset
for help on using the changeset viewer.