Changeset 38859 in webkit for trunk/JavaScriptCore/wtf/HashTable.h
- Timestamp:
- Dec 1, 2008, 6:19:35 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/HashTable.h
r35900 r38859 1 1 /* 2 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2008 David Levin <[email protected]> 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 25 26 #include "HashTraits.h" 26 27 #include <wtf/Assertions.h> 28 #include <wtf/Threading.h> 27 29 28 30 namespace WTF { … … 43 45 struct HashTableStats { 44 46 ~HashTableStats(); 47 // All of the variables are accessed in ~HashTableStats when the static struct is destroyed. 48 49 // The following variables are all atomically incremented when modified. 45 50 static int numAccesses; 46 static int numCollisions;47 static int collisionGraph[4096];48 static int maxCollisions;49 51 static int numRehashes; 50 52 static int numRemoves; 51 53 static int numReinserts; 54 55 // The following variables are only modified in the recordCollisionAtCount method within a mutex. 56 static int maxCollisions; 57 static int numCollisions; 58 static int collisionGraph[4096]; 59 52 60 static void recordCollisionAtCount(int count); 53 61 }; … … 202 210 #if CHECK_HASHTABLE_ITERATORS 203 211 public: 212 // Any modifications of the m_next or m_previous of an iterator that is in a linked list of a HashTable::m_iterator, 213 // should be guarded with m_table->m_mutex. 204 214 mutable const HashTableType* m_table; 205 215 mutable const_iterator* m_next; … … 398 408 #if CHECK_HASHTABLE_ITERATORS 399 409 public: 410 // All access to m_iterators should be guarded with m_mutex. 400 411 mutable const_iterator* m_iterators; 412 mutable Mutex m_mutex; 401 413 #endif 402 414 }; … … 467 479 468 480 #if DUMP_HASHTABLE_STATS 469 ++HashTableStats::numAccesses;481 atomicIncrement(&HashTableStats::numAccesses); 470 482 int probeCount = 0; 471 483 #endif … … 512 524 513 525 #if DUMP_HASHTABLE_STATS 514 ++HashTableStats::numAccesses;526 atomicIncrement(&HashTableStats::numAccesses); 515 527 int probeCount = 0; 516 528 #endif … … 564 576 565 577 #if DUMP_HASHTABLE_STATS 566 ++HashTableStats::numAccesses;578 atomicIncrement(&HashTableStats::numAccesses); 567 579 int probeCount = 0; 568 580 #endif … … 624 636 625 637 #if DUMP_HASHTABLE_STATS 626 ++HashTableStats::numAccesses;638 atomicIncrement(&HashTableStats::numAccesses); 627 639 int probeCount = 0; 628 640 #endif … … 739 751 ASSERT(!isDeletedBucket(*(lookupForWriting(Extractor::extract(entry)).first))); 740 752 #if DUMP_HASHTABLE_STATS 741 ++HashTableStats::numReinserts;753 atomicIncrement(&HashTableStats::numReinserts); 742 754 #endif 743 755 … … 802 814 { 803 815 #if DUMP_HASHTABLE_STATS 804 ++HashTableStats::numRemoves;816 atomicIncrement(&HashTableStats::numRemoves); 805 817 #endif 806 818 … … 888 900 #if DUMP_HASHTABLE_STATS 889 901 if (oldTableSize != 0) 890 ++HashTableStats::numRehashes;902 atomicIncrement(&HashTableStats::numRehashes); 891 903 #endif 892 904 … … 1017 1029 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::invalidateIterators() 1018 1030 { 1031 MutexLocker lock(m_mutex); 1019 1032 const_iterator* next; 1020 1033 for (const_iterator* p = m_iterators; p; p = next) { … … 1038 1051 it->m_next = 0; 1039 1052 } else { 1053 MutexLocker lock(table->m_mutex); 1040 1054 ASSERT(table->m_iterators != it); 1041 1055 it->m_next = table->m_iterators; … … 1059 1073 ASSERT(!it->m_previous); 1060 1074 } else { 1075 MutexLocker lock(it->m_table->m_mutex); 1061 1076 if (it->m_next) { 1062 1077 ASSERT(it->m_next->m_previous == it);
Note:
See TracChangeset
for help on using the changeset viewer.