Title: [117311] trunk/Source/WTF
- Revision
- 117311
- Author
- simon.fra...@apple.com
- Date
- 2012-05-16 11:31:12 -0700 (Wed, 16 May 2012)
Log Message
Make things build with DUMP_HASHTABLE_STATS=1
https://bugs.webkit.org/show_bug.cgi?id=86571
Reviewed by Geoffrey Garen.
DUMP_HASHTABLE_STATS bitrotted after the WTF separation. This patch
makes it build.
Added WTF_EXPORTDATA to the global data, and WTF_EXPORT_PRIVATE to
the static HashTableStats methods. Added a dumpStats() method
that is not yet called anywhere; we can no longer rely on destroying
a global object to dump the stats because global destructors are
disallowed.
* wtf/HashTable.cpp:
(WTF):
(WTF::HashTableStats::recordCollisionAtCount):
(WTF::HashTableStats::dumpStats):
* wtf/HashTable.h:
(HashTableStats):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (117310 => 117311)
--- trunk/Source/WTF/ChangeLog 2012-05-16 18:30:09 UTC (rev 117310)
+++ trunk/Source/WTF/ChangeLog 2012-05-16 18:31:12 UTC (rev 117311)
@@ -1,3 +1,26 @@
+2012-05-16 Simon Fraser <simon.fra...@apple.com>
+
+ Make things build with DUMP_HASHTABLE_STATS=1
+ https://bugs.webkit.org/show_bug.cgi?id=86571
+
+ Reviewed by Geoffrey Garen.
+
+ DUMP_HASHTABLE_STATS bitrotted after the WTF separation. This patch
+ makes it build.
+
+ Added WTF_EXPORTDATA to the global data, and WTF_EXPORT_PRIVATE to
+ the static HashTableStats methods. Added a dumpStats() method
+ that is not yet called anywhere; we can no longer rely on destroying
+ a global object to dump the stats because global destructors are
+ disallowed.
+
+ * wtf/HashTable.cpp:
+ (WTF):
+ (WTF::HashTableStats::recordCollisionAtCount):
+ (WTF::HashTableStats::dumpStats):
+ * wtf/HashTable.h:
+ (HashTableStats):
+
2012-05-15 Filip Pizlo <fpi...@apple.com>
shrinkToFit() is often not called for Vectors in CodeBlock
Modified: trunk/Source/WTF/wtf/HashTable.cpp (117310 => 117311)
--- trunk/Source/WTF/wtf/HashTable.cpp 2012-05-16 18:30:09 UTC (rev 117310)
+++ trunk/Source/WTF/wtf/HashTable.cpp 2012-05-16 18:31:12 UTC (rev 117311)
@@ -33,18 +33,25 @@
int HashTableStats::numRemoves;
int HashTableStats::numReinserts;
-static HashTableStats logger;
-
static Mutex& hashTableStatsMutex()
{
AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
return mutex;
}
-HashTableStats::~HashTableStats()
+void HashTableStats::recordCollisionAtCount(int count)
{
- // Don't lock hashTableStatsMutex here because it can cause deadlocks at shutdown
- // if any thread was killed while holding the mutex.
+ MutexLocker lock(hashTableStatsMutex());
+ if (count > maxCollisions)
+ maxCollisions = count;
+ numCollisions++;
+ collisionGraph[count]++;
+}
+
+void HashTableStats::dumpStats()
+{
+ MutexLocker lock(hashTableStatsMutex());
+
dataLog("\nWTF::HashTable statistics\n\n");
dataLog("%d accesses\n", numAccesses);
dataLog("%d total collisions, average %.2f probes per access\n", numCollisions, 1.0 * (numAccesses + numCollisions) / numAccesses);
@@ -56,15 +63,6 @@
dataLog("%d reinserts\n", numReinserts);
}
-void HashTableStats::recordCollisionAtCount(int count)
-{
- MutexLocker lock(hashTableStatsMutex());
- if (count > maxCollisions)
- maxCollisions = count;
- numCollisions++;
- collisionGraph[count]++;
-}
-
#endif
} // namespace WTF
Modified: trunk/Source/WTF/wtf/HashTable.h (117310 => 117311)
--- trunk/Source/WTF/wtf/HashTable.h 2012-05-16 18:30:09 UTC (rev 117310)
+++ trunk/Source/WTF/wtf/HashTable.h 2012-05-16 18:31:12 UTC (rev 117311)
@@ -54,21 +54,21 @@
#if DUMP_HASHTABLE_STATS
struct HashTableStats {
- ~HashTableStats();
// All of the variables are accessed in ~HashTableStats when the static struct is destroyed.
// The following variables are all atomically incremented when modified.
- static int numAccesses;
- static int numRehashes;
- static int numRemoves;
- static int numReinserts;
+ WTF_EXPORTDATA static int numAccesses;
+ WTF_EXPORTDATA static int numRehashes;
+ WTF_EXPORTDATA static int numRemoves;
+ WTF_EXPORTDATA static int numReinserts;
// The following variables are only modified in the recordCollisionAtCount method within a mutex.
- static int maxCollisions;
- static int numCollisions;
- static int collisionGraph[4096];
+ WTF_EXPORTDATA static int maxCollisions;
+ WTF_EXPORTDATA static int numCollisions;
+ WTF_EXPORTDATA static int collisionGraph[4096];
- static void recordCollisionAtCount(int count);
+ WTF_EXPORT_PRIVATE static void recordCollisionAtCount(int count);
+ WTF_EXPORT_PRIVATE static void dumpStats();
};
#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes