Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: third_party/WebKit/Source/platform/wtf/HashTable.h

Issue 2778993002: HashTable check
Patch Set: fix Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/wtf/Vector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/wtf/HashTable.h
diff --git a/third_party/WebKit/Source/platform/wtf/HashTable.h b/third_party/WebKit/Source/platform/wtf/HashTable.h
index 041cdcec3b0daabbabdbf43362909d2b788bb195..c05985b57f873d45a9c4c09dd4aa0b3633b90402 100644
--- a/third_party/WebKit/Source/platform/wtf/HashTable.h
+++ b/third_party/WebKit/Source/platform/wtf/HashTable.h
@@ -792,6 +792,10 @@ class HashTable final
void leaveAccessForbiddenScope() { m_accessForbidden = false; }
bool accessForbidden() const { return m_accessForbidden; }
int64_t modifications() const { return m_modifications; }
+ void checkCreationThread() const {
+ DCHECK(!Allocator::isGarbageCollected ||
+ m_creationThread == currentThread());
+ }
void registerModification() { m_modifications++; }
// HashTable and collections that build on it do not support modifications
// while there is an iterator in use. The exception is ListHashSet, which
@@ -894,6 +898,7 @@ class HashTable final
unsigned m_queueFlag : 1;
unsigned m_accessForbidden : 1;
unsigned m_modifications;
+ ThreadIdentifier m_creationThread;
#else
unsigned m_deletedCount : 31;
unsigned m_queueFlag : 1;
@@ -949,6 +954,10 @@ inline HashTable<Key,
m_stats(nullptr)
#endif
{
+#if DCHECK_IS_ON()
+ if (Allocator::isGarbageCollected)
+ m_creationThread = currentThread();
+#endif
static_assert(Allocator::isGarbageCollected ||
(!IsPointerToGarbageCollectedType<Key>::value &&
!IsPointerToGarbageCollectedType<Value>::value),
@@ -1230,6 +1239,7 @@ typename HashTable<Key,
Allocator>::AddResult
HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::
add(T&& key, Extra&& extra) {
+ checkCreationThread();
DCHECK(!accessForbidden());
DCHECK(Allocator::isAllocationAllowed());
if (!m_table)
@@ -1827,6 +1837,10 @@ HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::
m_stats(HashTableStatsPtr<Allocator>::copy(other.m_stats))
#endif
{
+#if DCHECK_IS_ON()
+ if (Allocator::isGarbageCollected)
+ m_creationThread = currentThread();
+#endif
if (other.size())
reserveCapacityForSize(other.size());
// Copy the hash table the dumb way, by adding each element to the new
@@ -1860,6 +1874,10 @@ HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::
m_stats(HashTableStatsPtr<Allocator>::copy(other.m_stats))
#endif
{
+#if DCHECK_IS_ON()
+ if (Allocator::isGarbageCollected)
+ m_creationThread = currentThread();
+#endif
swap(other);
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/wtf/Vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698