Bug 1372875 - Add more assertions for hash table pointer generation and mutation count r=luke
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 16 Jun 2017 10:05:55 +0100
changeset 415516 f71a1645c218f0fa89306a50786afe6d9ebd1f0f
parent 415515 370bb186e98f3fe5503efaa452a5689a052f8f86
child 415517 de7215f52f9b3fedec694f1d0ade87cb968cb5d5
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1372875
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1372875 - Add more assertions for hash table pointer generation and mutation count r=luke
js/public/HashTable.h
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -1608,16 +1608,17 @@ class HashTable : private AllocPolicy
     // a second table.  We do this by recycling the collision bits to tell us if
     // the element is already inserted or still waiting to be inserted.  Since
     // already-inserted elements win any conflicts, we get the same table as we
     // would have gotten through random insertion order.
     void rehashTableInPlace()
     {
         METER(stats.rehashes++);
         removedCount = 0;
+        gen++;
         for (size_t i = 0; i < capacity(); ++i)
             table[i].unsetCollision();
 
         for (size_t i = 0; i < capacity();) {
             Entry* src = &table[i];
 
             if (!src->isLive() || src->hasCollision()) {
                 ++i;
@@ -1792,16 +1793,19 @@ class HashTable : private AllocPolicy
         MOZ_ASSERT_IF(p.isValid(), p.table_ == this);
         MOZ_ASSERT(!p.found());
         MOZ_ASSERT(!(p.keyHash & sCollisionBit));
 
         // Check for error from ensureHash() here.
         if (!p.isValid())
             return false;
 
+        MOZ_ASSERT(p.generation == generation());
+        MOZ_ASSERT(p.mutationCount == mutationCount);
+
         // Changing an entry from removed to live does not affect whether we
         // are overloaded and can be handled separately.
         if (p.entry_->isRemoved()) {
             if (!this->checkSimulatedOOM())
                 return false;
             METER(stats.addOverRemoved++);
             removedCount--;
             p.keyHash |= sCollisionBit;
@@ -1875,25 +1879,27 @@ class HashTable : private AllocPolicy
         return p.found() || add(p, mozilla::Forward<Args>(args)...);
     }
 
     void remove(Ptr p)
     {
         MOZ_ASSERT(table);
         mozilla::ReentrancyGuard g(*this);
         MOZ_ASSERT(p.found());
+        MOZ_ASSERT(p.generation == generation());
         remove(*p.entry_);
         checkUnderloaded();
     }
 
     void rekeyWithoutRehash(Ptr p, const Lookup& l, const Key& k)
     {
         MOZ_ASSERT(table);
         mozilla::ReentrancyGuard g(*this);
         MOZ_ASSERT(p.found());
+        MOZ_ASSERT(p.generation == generation());
         typename HashTableEntry<T>::NonConstT t(mozilla::Move(*p));
         HashPolicy::setKey(t, const_cast<Key&>(k));
         remove(*p.entry_);
         putNewInfallibleInternal(l, mozilla::Move(t));
     }
 
     void rekeyAndMaybeRehash(Ptr p, const Lookup& l, const Key& k)
     {