X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/b37bf2e156556c589aea3e1f58a377f2b1189665..fb8617cde5834786bd4e4afd579883e4acf5666e:/wtf/HashTable.cpp diff --git a/wtf/HashTable.cpp b/wtf/HashTable.cpp index ba45aee..71d3f86 100644 --- a/wtf/HashTable.cpp +++ b/wtf/HashTable.cpp @@ -1,7 +1,5 @@ /* - This file is part of the KDE libraries - - Copyright (C) 2005 Apple Computer + Copyright (C) 2005 Apple Inc. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -36,9 +34,17 @@ int HashTableStats::numReinserts; static HashTableStats logger; +static Mutex& hashTableStatsMutex() +{ + AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); + return mutex; +} + HashTableStats::~HashTableStats() { - printf("\nkhtml::HashTable statistics\n\n"); + // Don't lock hashTableStatsMutex here because it can cause deadlocks at shutdown + // if any thread was killed while holding the mutex. + printf("\nWTF::HashTable statistics\n\n"); printf("%d accesses\n", numAccesses); printf("%d total collisions, average %.2f probes per access\n", numCollisions, 1.0 * (numAccesses + numCollisions) / numAccesses); printf("longest collision chain: %d\n", maxCollisions); @@ -51,6 +57,7 @@ HashTableStats::~HashTableStats() void HashTableStats::recordCollisionAtCount(int count) { + MutexLocker lock(hashTableStatsMutex()); if (count > maxCollisions) maxCollisions = count; numCollisions++;