mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 15:26:07 +00:00
Bug 841065 - Do not call pre-barrier on finalized objects when finalizing Map and SetObjects; r=billm
--HG-- extra : rebase_source : db2bbca3687ec396454645a8b60455356a4de453
This commit is contained in:
parent
a532bb8b0c
commit
447ade58cb
@ -229,8 +229,18 @@ class OrderedHashTable
|
||||
* The effect on live Ranges is the same as removing all entries; in
|
||||
* particular, those Ranges are still live and will see any entries added
|
||||
* after a successful clear().
|
||||
*
|
||||
* The DoNotCallDestructors specialization is for use during a GC when the
|
||||
* OrderedHashTable contains pointers to GC things in other arenas. Since
|
||||
* it is invalid to touch objects in other arenas during sweeping, we need
|
||||
* to not trigger destructors on the pointers contained in the table in
|
||||
* this case.
|
||||
*/
|
||||
bool clear() {
|
||||
enum CallDestructors {
|
||||
DoNotCallDtors = false,
|
||||
DoCallDtors = true
|
||||
};
|
||||
bool clear(CallDestructors callDestructors = DoCallDtors) {
|
||||
if (dataLength != 0) {
|
||||
Data **oldHashTable = hashTable;
|
||||
Data *oldData = data;
|
||||
@ -244,7 +254,9 @@ class OrderedHashTable
|
||||
}
|
||||
|
||||
alloc.free_(oldHashTable);
|
||||
freeData(oldData, oldDataLength);
|
||||
if (callDestructors)
|
||||
destroyData(oldData, oldDataLength);
|
||||
alloc.free_(oldData);
|
||||
for (Range *r = ranges; r; r = r->next)
|
||||
r->onClear();
|
||||
}
|
||||
@ -690,7 +702,8 @@ class OrderedHashMap
|
||||
Entry *get(const Key &key) { return impl.get(key); }
|
||||
bool put(const Key &key, const Value &value) { return impl.put(Entry(key, value)); }
|
||||
bool remove(const Key &key, bool *foundp) { return impl.remove(key, foundp); }
|
||||
bool clear() { return impl.clear(); }
|
||||
bool clear() { return impl.clear(Impl::DoCallDtors); }
|
||||
bool clearWithoutCallingDestructors() { return impl.clear(Impl::DoNotCallDtors); }
|
||||
};
|
||||
|
||||
template <class T, class OrderedHashPolicy, class AllocPolicy>
|
||||
@ -717,7 +730,8 @@ class OrderedHashSet
|
||||
Range all() { return impl.all(); }
|
||||
bool put(const T &value) { return impl.put(value); }
|
||||
bool remove(const T &value, bool *foundp) { return impl.remove(value, foundp); }
|
||||
bool clear() { return impl.clear(); }
|
||||
bool clear() { return impl.clear(Impl::DoCallDtors); }
|
||||
bool clearWithoutCallingDestructors() { return impl.clear(Impl::DoNotCallDtors); }
|
||||
};
|
||||
|
||||
} // namespace js
|
||||
@ -1059,8 +1073,10 @@ MapObject::mark(JSTracer *trc, RawObject obj)
|
||||
void
|
||||
MapObject::finalize(FreeOp *fop, RawObject obj)
|
||||
{
|
||||
if (ValueMap *map = obj->asMap().getData())
|
||||
if (ValueMap *map = obj->asMap().getData()) {
|
||||
map->clearWithoutCallingDestructors();
|
||||
fop->delete_(map);
|
||||
}
|
||||
}
|
||||
|
||||
JSBool
|
||||
@ -1511,8 +1527,10 @@ void
|
||||
SetObject::finalize(FreeOp *fop, RawObject obj)
|
||||
{
|
||||
SetObject *setobj = static_cast<SetObject *>(obj);
|
||||
if (ValueSet *set = setobj->getData())
|
||||
if (ValueSet *set = setobj->getData()) {
|
||||
set->clearWithoutCallingDestructors();
|
||||
fop->delete_(set);
|
||||
}
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
Loading…
x
Reference in New Issue
Block a user