Bug 906001 - Improve tests and asserts around starting off thread parses while GC is active in the atoms zone, r=billm.

This commit is contained in:
Brian Hackett 2013-08-17 21:24:59 -06:00
Родитель d546e19260
Коммит 58194c732e
6 изменённых файлов: 25 добавлений и 17 удалений

Просмотреть файл

@ -76,6 +76,7 @@ Zone::setNeedsBarrier(bool needs, ShouldUpdateIon updateIon)
if (needs && runtimeFromMainThread()->isAtomsZone(this))
JS_ASSERT(!runtimeFromMainThread()->exclusiveThreadsPresent());
JS_ASSERT_IF(needs, canCollect());
needsBarrier_ = needs;
}

Просмотреть файл

@ -189,20 +189,16 @@ struct Zone : private JS::shadow::Zone,
void setGCState(CompartmentGCState state) {
JS_ASSERT(runtimeFromMainThread()->isHeapBusy());
JS_ASSERT_IF(state != NoGC, canCollect());
gcState = state;
}
void scheduleGC() {
JSRuntime *rt = runtimeFromMainThread();
JS_ASSERT(!rt->isHeapBusy());
JS_ASSERT(!runtimeFromMainThread()->isHeapBusy());
/* Note: zones cannot be collected while in use by other threads. */
if (usedByExclusiveThread)
return;
if (rt->isAtomsZone(this) && rt->exclusiveThreadsPresent())
return;
gcScheduled = true;
// Ignore attempts to schedule GCs on zones which can't be collected.
if (canCollect())
gcScheduled = true;
}
void unscheduleGC() {
@ -217,6 +213,16 @@ struct Zone : private JS::shadow::Zone,
gcPreserveCode = preserving;
}
bool canCollect() {
// Zones cannot be collected while in use by other threads.
if (usedByExclusiveThread)
return false;
JSRuntime *rt = runtimeFromMainThread();
if (rt->isAtomsZone(this) && rt->exclusiveThreadsPresent())
return false;
return true;
}
bool wasGCStarted() const {
return gcState != NoGC;
}

Просмотреть файл

@ -4847,7 +4847,7 @@ JS::CanCompileOffThread(JSContext *cx, const CompileOptions &options)
// atoms compartment, to avoid triggering barriers. Outside the atoms
// compartment, the compilation will use a new zone which doesn't require
// barriers itself.
if (cx->runtime()->atomsZoneNeedsBarrier())
if (cx->runtime()->activeGCInAtomsZone())
return false;
// Blacklist filenames which cause mysterious assertion failures in

Просмотреть файл

@ -401,12 +401,6 @@ JSRuntime::isAtomsZone(JS::Zone *zone)
return zone == atomsCompartment_->zone();
}
inline bool
JSRuntime::atomsZoneNeedsBarrier()
{
return atomsCompartment_->zone()->needsBarrier();
}
// For use when changing the debug mode flag on one or more compartments.
// Do not run scripts in any compartment that is scheduled for GC using this
// object. See comment in updateForDebugMode.

Просмотреть файл

@ -716,6 +716,13 @@ JSRuntime::onOutOfMemory(void *p, size_t nbytes, JSContext *cx)
return NULL;
}
bool
JSRuntime::activeGCInAtomsZone()
{
Zone *zone = atomsCompartment_->zone();
return zone->needsBarrier() || zone->isGCScheduled() || zone->wasGCStarted();
}
#ifdef JS_THREADSAFE
void

Просмотреть файл

@ -1415,7 +1415,7 @@ struct JSRuntime : public JS::shadow::Runtime,
// The atoms compartment is the only one in its zone.
inline bool isAtomsZone(JS::Zone *zone);
inline bool atomsZoneNeedsBarrier();
bool activeGCInAtomsZone();
union {
/*