Bug 760337 - Add JS_ASSERT(table) where appropriate in HashTable.h. r=luke.

--HG--
extra : rebase_source : ab85f7061f79605afe54a6341612cededef35558
This commit is contained in:
Nicholas Nethercote 2012-06-04 00:00:24 -07:00
parent c7a3ba74b1
commit ad056ade92

View File

@ -508,8 +508,9 @@ class HashTable : private AllocPolicy
*/
Entry &findFreeEntry(HashNumber keyHash)
{
METER(stats.searches++);
JS_ASSERT(!(keyHash & sCollisionBit));
JS_ASSERT(table);
METER(stats.searches++);
/* N.B. the |keyHash| has already been distributed. */
@ -577,6 +578,8 @@ class HashTable : private AllocPolicy
void add(const Lookup &l, const Entry &e)
{
JS_ASSERT(table);
HashNumber keyHash = prepareHash(l);
Entry &entry = lookup(l, keyHash, sCollisionBit);
@ -612,7 +615,9 @@ class HashTable : private AllocPolicy
void remove(Entry &e)
{
JS_ASSERT(table);
METER(stats.removes++);
if (e.hasCollision()) {
e.setRemoved();
removedCount++;
@ -663,22 +668,27 @@ class HashTable : private AllocPolicy
}
Range all() const {
JS_ASSERT(table);
return Range(table, table + capacity());
}
bool empty() const {
JS_ASSERT(table);
return !entryCount;
}
uint32_t count() const {
JS_ASSERT(table);
return entryCount;
}
uint32_t capacity() const {
JS_ASSERT(table);
return JS_BIT(sHashBits - hashShift);
}
uint32_t generation() const {
JS_ASSERT(table);
return gen;
}
@ -766,6 +776,7 @@ class HashTable : private AllocPolicy
void remove(Ptr p)
{
JS_ASSERT(table);
ReentrancyGuard g(*this);
JS_ASSERT(p.found());
remove(*p.entry);