summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/wtf/HashTable.h
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-02-02 14:57:50 +0000
committerSteve Block <steveblock@google.com>2010-02-04 15:06:55 +0000
commitd0825bca7fe65beaee391d30da42e937db621564 (patch)
tree7461c49eb5844ffd1f35d1ba2c8b7584c1620823 /JavaScriptCore/wtf/HashTable.h
parent3db770bd97c5a59b6c7574ca80a39e5a51c1defd (diff)
downloadexternal_webkit-d0825bca7fe65beaee391d30da42e937db621564.zip
external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.gz
external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.bz2
Merge webkit.org at r54127 : Initial merge by git
Change-Id: Ib661abb595522f50ea406f72d3a0ce17f7193c82
Diffstat (limited to 'JavaScriptCore/wtf/HashTable.h')
-rw-r--r--JavaScriptCore/wtf/HashTable.h38
1 files changed, 24 insertions, 14 deletions
diff --git a/JavaScriptCore/wtf/HashTable.h b/JavaScriptCore/wtf/HashTable.h
index 3b283f8..f1473e3 100644
--- a/JavaScriptCore/wtf/HashTable.h
+++ b/JavaScriptCore/wtf/HashTable.h
@@ -30,6 +30,7 @@
namespace WTF {
#define DUMP_HASHTABLE_STATS 0
+// Enables internal WTF consistency checks that are invoked automatically. Non-WTF callers can call checkTableConsistency() even if internal checks are disabled.
#define CHECK_HASHTABLE_CONSISTENCY 0
#ifdef NDEBUG
@@ -197,7 +198,7 @@ namespace WTF {
void checkValidity(const const_iterator& other) const
{
ASSERT(m_table);
- ASSERT(other.m_table);
+ ASSERT_UNUSED(other, other.m_table);
ASSERT(m_table == other.m_table);
}
#else
@@ -340,11 +341,18 @@ namespace WTF {
ValueType* lookup(const Key& key) { return lookup<Key, IdentityTranslatorType>(key); }
template<typename T, typename HashTranslator> ValueType* lookup(const T&);
-#if CHECK_HASHTABLE_CONSISTENCY
+#if !ASSERT_DISABLED
void checkTableConsistency() const;
#else
static void checkTableConsistency() { }
#endif
+#if CHECK_HASHTABLE_CONSISTENCY
+ void internalCheckTableConsistency() const { checkTableConsistency(); }
+ void internalCheckTableConsistencyExceptSize() const { checkTableConsistencyExceptSize(); }
+#else
+ static void internalCheckTableConsistencyExceptSize() { }
+ static void internalCheckTableConsistency() { }
+#endif
private:
static ValueType* allocateTable(int size);
@@ -383,7 +391,7 @@ namespace WTF {
iterator makeKnownGoodIterator(ValueType* pos) { return iterator(this, pos, m_table + m_tableSize, HashItemKnownGood); }
const_iterator makeKnownGoodConstIterator(ValueType* pos) const { return const_iterator(this, pos, m_table + m_tableSize, HashItemKnownGood); }
-#if CHECK_HASHTABLE_CONSISTENCY
+#if !ASSERT_DISABLED
void checkTableConsistencyExceptSize() const;
#else
static void checkTableConsistencyExceptSize() { }
@@ -624,7 +632,7 @@ namespace WTF {
if (!m_table)
expand();
- checkTableConsistency();
+ internalCheckTableConsistency();
ASSERT(m_table);
@@ -693,7 +701,7 @@ namespace WTF {
return p;
}
- checkTableConsistency();
+ internalCheckTableConsistency();
return std::make_pair(makeKnownGoodIterator(entry), true);
}
@@ -709,7 +717,7 @@ namespace WTF {
if (!m_table)
expand();
- checkTableConsistency();
+ internalCheckTableConsistency();
FullLookupType lookupResult = fullLookupForWriting<T, HashTranslator>(key);
@@ -738,7 +746,7 @@ namespace WTF {
return p;
}
- checkTableConsistency();
+ internalCheckTableConsistency();
return std::make_pair(makeKnownGoodIterator(entry), true);
}
@@ -805,7 +813,7 @@ namespace WTF {
void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::removeAndInvalidate(ValueType* pos)
{
invalidateIterators();
- checkTableConsistency();
+ internalCheckTableConsistency();
remove(pos);
}
@@ -823,7 +831,7 @@ namespace WTF {
if (shouldShrink())
shrink();
- checkTableConsistency();
+ internalCheckTableConsistency();
}
template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
@@ -892,7 +900,7 @@ namespace WTF {
template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::rehash(int newTableSize)
{
- checkTableConsistencyExceptSize();
+ internalCheckTableConsistencyExceptSize();
int oldTableSize = m_tableSize;
ValueType* oldTable = m_table;
@@ -914,7 +922,7 @@ namespace WTF {
deallocateTable(oldTable, oldTableSize);
- checkTableConsistency();
+ internalCheckTableConsistency();
}
template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
@@ -981,13 +989,13 @@ namespace WTF {
return *this;
}
-#if CHECK_HASHTABLE_CONSISTENCY
+#if !ASSERT_DISABLED
template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::checkTableConsistency() const
{
checkTableConsistencyExceptSize();
- ASSERT(!shouldExpand());
+ ASSERT(!m_table || !shouldExpand());
ASSERT(!shouldShrink());
}
@@ -1012,6 +1020,8 @@ namespace WTF {
const_iterator it = find(Extractor::extract(*entry));
ASSERT(entry == it.m_position);
++count;
+
+ KeyTraits::checkValueConsistency(it->first);
}
ASSERT(count == m_keyCount);
@@ -1021,7 +1031,7 @@ namespace WTF {
ASSERT(m_tableSize == m_tableSizeMask + 1);
}
-#endif // CHECK_HASHTABLE_CONSISTENCY
+#endif // ASSERT_DISABLED
#if CHECK_HASHTABLE_ITERATORS