Bug 900598 - Make sure not to collect the atoms compartment when exclusive threads are present (r=bhackett)

This commit is contained in:
Bill McCloskey 2013-08-01 16:45:11 -07:00
parent d5c2e9336d
commit c6a58bf7a5
2 changed files with 19 additions and 0 deletions

View File

@ -2773,6 +2773,15 @@ BeginMarkPhase(JSRuntime *rt)
for (ThreadDataIter iter(rt); !iter.done(); iter.next())
keepAtoms |= iter->gcKeepAtoms;
/*
* We don't scan the stacks of exclusive threads, so we need to avoid
* collecting their objects in another way. The only GC thing pointers they
* have are to their exclusive compartment (which is not collected) or to
* the atoms compartment. Therefore, we avoid collecting the atoms
* compartment when exclusive threads are running.
*/
keepAtoms |= rt->exclusiveThreadsPresent();
if (atomsZone->isGCScheduled() && rt->gcIsFull && !keepAtoms) {
JS_ASSERT(!atomsZone->isCollecting());
atomsZone->setGCState(Zone::Mark);
@ -4352,6 +4361,8 @@ gc::IsIncrementalGCSafe(JSRuntime *rt)
for (ThreadDataIter iter(rt); !iter.done(); iter.next())
keepAtoms |= iter->gcKeepAtoms;
keepAtoms |= rt->exclusiveThreadsPresent();
if (keepAtoms)
return IncrementalSafety::Unsafe("gcKeepAtoms set");

View File

@ -765,6 +765,14 @@ struct JSRuntime : public JS::shadow::Runtime,
#endif
}
bool exclusiveThreadsPresent() const {
#ifdef JS_THREADSAFE
return numExclusiveThreads > 0;
#else
return false;
#endif
}
/* Default compartment. */
JSCompartment *atomsCompartment;