From b303ecda68fc1812e6f5460b21442b3e231a992f Mon Sep 17 00:00:00 2001 From: Terrence Cole Date: Tue, 10 Dec 2013 15:26:05 -0800 Subject: [PATCH] Backout changeset 70e76314c8a7 for build bustage on a CLOSED TREE. --HG-- extra : rebase_source : 83e1e8a5a4802ef0b7b1d6f7dc0df6595bc9f00f --- js/public/HashTable.h | 117 ++++++++---------------------------------- mfbt/DebugOnly.h | 1 - 2 files changed, 20 insertions(+), 98 deletions(-) diff --git a/js/public/HashTable.h b/js/public/HashTable.h index 1b80aadcb92b..b3374d7e26df 100644 --- a/js/public/HashTable.h +++ b/js/public/HashTable.h @@ -756,19 +756,9 @@ class HashTable : private AllocPolicy void nonNull() {} Entry *entry_; -#ifdef DEBUG - const HashTable *table_; - uint32_t generation; -#endif protected: - Ptr(Entry &entry, const HashTable &table) - : entry_(&entry) -#ifdef DEBUG - , table_(&table) - , generation(table.generation()) -#endif - {} + Ptr(Entry &entry) : entry_(&entry) {} public: // Leaves Ptr uninitialized. @@ -778,34 +768,13 @@ class HashTable : private AllocPolicy #endif } - bool found() const { - JS_ASSERT(generation == table_->generation()); - return entry_->isLive(); - } + bool found() const { return entry_->isLive(); } + operator ConvertibleToBool() const { return found() ? &Ptr::nonNull : 0; } + bool operator==(const Ptr &rhs) const { JS_ASSERT(found() && rhs.found()); return entry_ == rhs.entry_; } + bool operator!=(const Ptr &rhs) const { return !(*this == rhs); } - operator ConvertibleToBool() const { - return found() ? &Ptr::nonNull : 0; - } - - bool operator==(const Ptr &rhs) const { - JS_ASSERT(found() && rhs.found()); - return entry_ == rhs.entry_; - } - - bool operator!=(const Ptr &rhs) const { - JS_ASSERT(generation == table_->generation()); - return !(*this == rhs); - } - - T &operator*() const { - JS_ASSERT(generation == table_->generation()); - return entry_->get(); - } - - T *operator->() const { - JS_ASSERT(generation == table_->generation()); - return &entry_->get(); - } + T &operator*() const { return entry_->get(); } + T *operator->() const { return &entry_->get(); } }; // A Ptr that can be used to add a key after a failed lookup. @@ -815,10 +784,7 @@ class HashTable : private AllocPolicy HashNumber keyHash; mozilla::DebugOnly mutationCount; - AddPtr(Entry &entry, const HashTable &table, HashNumber hn) - : Ptr(entry, table), keyHash(hn), mutationCount(table.mutationCount) - {} - + AddPtr(Entry &entry, HashNumber hn) : Ptr(entry), keyHash(hn) {} public: // Leaves AddPtr uninitialized. AddPtr() {} @@ -833,63 +799,32 @@ class HashTable : private AllocPolicy protected: friend class HashTable; - Range(const HashTable &table, Entry *c, Entry *e) - : cur(c) - , end(e) -#ifdef DEBUG - , table(&table) - , mutationCount(table.mutationCount) - , generation(table.generation()) - , validEntry(true) -#endif - { + Range(Entry *c, Entry *e) : cur(c), end(e), validEntry(true) { while (cur < end && !cur->isLive()) ++cur; } Entry *cur, *end; -#ifdef DEBUG - const HashTable *table; - uint64_t mutationCount; - uint32_t generation; - bool validEntry; -#endif + mozilla::DebugOnly validEntry; public: - Range() - : cur(nullptr) - , end(nullptr) -#ifdef DEBUG - , table(nullptr) - , mutationCount(0) - , generation(0) - , validEntry(false) -#endif - {} + Range() : cur(nullptr), end(nullptr), validEntry(false) {} bool empty() const { - JS_ASSERT(generation == table->generation()); - JS_ASSERT(mutationCount == table->mutationCount); return cur == end; } T &front() const { JS_ASSERT(validEntry); JS_ASSERT(!empty()); - JS_ASSERT(generation == table->generation()); - JS_ASSERT(mutationCount == table->mutationCount); return cur->get(); } void popFront() { JS_ASSERT(!empty()); - JS_ASSERT(generation == table->generation()); - JS_ASSERT(mutationCount == table->mutationCount); while (++cur < end && !cur->isLive()) continue; -#ifdef DEBUG validEntry = true; -#endif } }; @@ -907,8 +842,8 @@ class HashTable : private AllocPolicy bool removed; /* Not copyable. */ - Enum(const Enum &) MOZ_DELETE; - void operator=(const Enum &) MOZ_DELETE; + Enum(const Enum &); + void operator=(const Enum &); public: template explicit @@ -924,23 +859,16 @@ class HashTable : private AllocPolicy void removeFront() { table.remove(*this->cur); removed = true; -#ifdef DEBUG this->validEntry = false; - this->mutationCount = table.mutationCount; -#endif } // Removes the |front()| element and re-inserts it into the table with // a new key at the new Lookup position. |front()| is invalid after // this operation until the next call to |popFront()|. void rekeyFront(const Lookup &l, const Key &k) { - Ptr p(*this->cur, table); - table.rekeyWithoutRehash(p, l, k); + table.rekeyWithoutRehash(*this->cur, l, k); rekeyed = true; -#ifdef DEBUG this->validEntry = false; - this->mutationCount = table.mutationCount; -#endif } void rekeyFront(const Key &k) { @@ -1464,7 +1392,7 @@ class HashTable : private AllocPolicy Range all() const { JS_ASSERT(table); - return Range(*this, table, table + capacity()); + return Range(table, table + capacity()); } bool empty() const @@ -1505,13 +1433,13 @@ class HashTable : private AllocPolicy { mozilla::ReentrancyGuard g(*this); HashNumber keyHash = prepareHash(l); - return Ptr(lookup(l, keyHash, 0), *this); + return Ptr(lookup(l, keyHash, 0)); } Ptr readonlyThreadsafeLookup(const Lookup &l) const { HashNumber keyHash = prepareHash(l); - return Ptr(lookup(l, keyHash, 0), *this); + return Ptr(lookup(l, keyHash, 0)); } AddPtr lookupForAdd(const Lookup &l) const @@ -1519,7 +1447,8 @@ class HashTable : private AllocPolicy mozilla::ReentrancyGuard g(*this); HashNumber keyHash = prepareHash(l); Entry &entry = lookup(l, keyHash, sCollisionBit); - AddPtr p(entry, *this, keyHash); + AddPtr p(entry, keyHash); + p.mutationCount = mutationCount; return p; } @@ -1527,6 +1456,7 @@ class HashTable : private AllocPolicy bool add(AddPtr &p, U &&u) { mozilla::ReentrancyGuard g(*this); + JS_ASSERT(mutationCount == p.mutationCount); JS_ASSERT(table); JS_ASSERT(!p.found()); JS_ASSERT(!(p.keyHash & sCollisionBit)); @@ -1549,10 +1479,6 @@ class HashTable : private AllocPolicy p.entry_->setLive(p.keyHash, mozilla::Forward(u)); entryCount++; mutationCount++; -#ifdef DEBUG - p.generation = generation(); - p.mutationCount = mutationCount; -#endif return true; } @@ -1594,10 +1520,7 @@ class HashTable : private AllocPolicy template bool relookupOrAdd(AddPtr& p, const Lookup &l, U &&u) { -#ifdef DEBUG - p.generation = generation(); p.mutationCount = mutationCount; -#endif { mozilla::ReentrancyGuard g(*this); JS_ASSERT(prepareHash(l) == p.keyHash); // l has not been destroyed diff --git a/mfbt/DebugOnly.h b/mfbt/DebugOnly.h index b1a53b62c67a..e5f0d729b51f 100644 --- a/mfbt/DebugOnly.h +++ b/mfbt/DebugOnly.h @@ -55,7 +55,6 @@ class DebugOnly operator const T&() const { return value; } T& operator->() { return value; } - const T& operator->() const { return value; } #else DebugOnly() { }