Bug 906387 - Rehash hash tables if necessary when rekeying during minor GC r=terrence

This commit is contained in:
Jon Coppeard 2013-08-29 10:27:50 +01:00
parent 6ea2c170b1
commit 2ef0dc9b58

View File

@ -253,7 +253,7 @@ class HashMap
void rekey(const Lookup &old_key, const Key &new_key) { void rekey(const Lookup &old_key, const Key &new_key) {
if (old_key != new_key) { if (old_key != new_key) {
if (Ptr p = lookup(old_key)) if (Ptr p = lookup(old_key))
impl.rekey(p, new_key, new_key); impl.rekeyAndMaybeRehash(p, new_key, new_key);
} }
} }
@ -452,7 +452,7 @@ class HashSet
void rekey(const Lookup &old_key, const T &new_key) { void rekey(const Lookup &old_key, const T &new_key) {
if (old_key != new_key) { if (old_key != new_key) {
if (Ptr p = lookup(old_key)) if (Ptr p = lookup(old_key))
impl.rekey(p, new_key, new_key); impl.rekeyAndMaybeRehash(p, new_key, new_key);
} }
} }
@ -814,7 +814,7 @@ class HashTable : private AllocPolicy
// a new key at the new Lookup position. |front()| is invalid after // a new key at the new Lookup position. |front()| is invalid after
// this operation until the next call to |popFront()|. // this operation until the next call to |popFront()|.
void rekeyFront(const Lookup &l, const Key &k) { void rekeyFront(const Lookup &l, const Key &k) {
table.rekey(*this->cur, l, k); table.rekeyWithoutRehash(*this->cur, l, k);
rekeyed = true; rekeyed = true;
this->validEntry = false; this->validEntry = false;
} }
@ -1462,7 +1462,7 @@ class HashTable : private AllocPolicy
checkUnderloaded(); checkUnderloaded();
} }
void rekey(Ptr p, const Lookup &l, const Key &k) void rekeyWithoutRehash(Ptr p, const Lookup &l, const Key &k)
{ {
JS_ASSERT(table); JS_ASSERT(table);
mozilla::ReentrancyGuard g(*this); mozilla::ReentrancyGuard g(*this);
@ -1473,6 +1473,12 @@ class HashTable : private AllocPolicy
putNewInfallible(l, mozilla::Move(t)); putNewInfallible(l, mozilla::Move(t));
} }
void rekeyAndMaybeRehash(Ptr p, const Lookup &l, const Key &k)
{
rekeyWithoutRehash(p, l, k);
checkOverRemoved();
}
#undef METER #undef METER
}; };