Bug 1332601 - Add some release asserts to type sweeping code. r=jonco

This commit is contained in:
Jan de Mooij 2017-01-20 16:52:22 +01:00
Родитель 4d6ebaaa07
Коммит 20febcb2bd
3 изменённых файлов: 32 добавлений и 10 удалений

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

@ -293,7 +293,7 @@ struct AutoEnterAnalysis
gc::AutoSuppressGC suppressGC;
// Allow clearing inference info on OOM during incremental sweeping.
AutoClearTypeInferenceStateOnOOM oom;
mozilla::Maybe<AutoClearTypeInferenceStateOnOOM> oom;
// Pending recompilations to perform before execution of JIT code can resume.
RecompileInfoVector pendingRecompiles;
@ -305,14 +305,14 @@ struct AutoEnterAnalysis
Zone* zone;
explicit AutoEnterAnalysis(ExclusiveContext* cx)
: suppressGC(cx), oom(cx->zone()), suppressMetadata(cx)
: suppressGC(cx), suppressMetadata(cx)
{
init(cx->defaultFreeOp(), cx->zone());
}
AutoEnterAnalysis(FreeOp* fop, Zone* zone)
: suppressGC(zone->runtimeFromMainThread()->contextFromMainThread()),
oom(zone), suppressMetadata(zone)
suppressMetadata(zone)
{
init(fop, zone);
}
@ -333,8 +333,10 @@ struct AutoEnterAnalysis
this->freeOp = fop;
this->zone = zone;
if (!zone->types.activeAnalysis)
if (!zone->types.activeAnalysis) {
MOZ_RELEASE_ASSERT(!zone->types.sweepingTypes);
zone->types.activeAnalysis = this;
}
}
};

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

@ -4250,8 +4250,10 @@ EnsureHasAutoClearTypeInferenceStateOnOOM(AutoClearTypeInferenceStateOnOOM*& oom
Maybe<AutoClearTypeInferenceStateOnOOM>& fallback)
{
if (!oom) {
if (zone->types.activeAnalysis) {
oom = &zone->types.activeAnalysis->oom;
if (AutoEnterAnalysis* analysis = zone->types.activeAnalysis) {
if (analysis->oom.isNothing())
analysis->oom.emplace(zone);
oom = analysis->oom.ptr();
} else {
fallback.emplace(zone);
oom = &fallback.ref();
@ -4444,6 +4446,7 @@ TypeZone::TypeZone(Zone* zone)
sweepTypeLifoAlloc(TYPE_LIFO_ALLOC_PRIMARY_CHUNK_SIZE),
sweepCompilerOutputs(nullptr),
sweepReleaseTypes(false),
sweepingTypes(false),
activeAnalysis(nullptr)
{
}
@ -4452,6 +4455,7 @@ TypeZone::~TypeZone()
{
js_delete(compilerOutputs);
js_delete(sweepCompilerOutputs);
MOZ_RELEASE_ASSERT(!sweepingTypes);
}
void
@ -4525,8 +4529,17 @@ TypeZone::clearAllNewScriptsOnOOM()
}
}
AutoClearTypeInferenceStateOnOOM::AutoClearTypeInferenceStateOnOOM(Zone* zone)
: zone(zone), oom(false)
{
MOZ_RELEASE_ASSERT(CurrentThreadCanAccessZone(zone));
zone->types.setSweepingTypes(true);
}
AutoClearTypeInferenceStateOnOOM::~AutoClearTypeInferenceStateOnOOM()
{
zone->types.setSweepingTypes(false);
if (oom) {
JSRuntime* rt = zone->runtimeFromMainThread();
js::CancelOffThreadIonCompile(rt);

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

@ -588,11 +588,11 @@ class AutoClearTypeInferenceStateOnOOM
Zone* zone;
bool oom;
public:
explicit AutoClearTypeInferenceStateOnOOM(Zone* zone)
: zone(zone), oom(false)
{}
AutoClearTypeInferenceStateOnOOM(const AutoClearTypeInferenceStateOnOOM&) = delete;
void operator=(const AutoClearTypeInferenceStateOnOOM&) = delete;
public:
explicit AutoClearTypeInferenceStateOnOOM(Zone* zone);
~AutoClearTypeInferenceStateOnOOM();
void setOOM() {
@ -1266,6 +1266,8 @@ struct TypeZone
// information attached to scripts.
bool sweepReleaseTypes;
bool sweepingTypes;
// The topmost AutoEnterAnalysis on the stack, if there is one.
AutoEnterAnalysis* activeAnalysis;
@ -1283,6 +1285,11 @@ struct TypeZone
void addPendingRecompile(JSContext* cx, JSScript* script);
void processPendingRecompiles(FreeOp* fop, RecompileInfoVector& recompiles);
void setSweepingTypes(bool sweeping) {
MOZ_RELEASE_ASSERT(sweepingTypes != sweeping);
sweepingTypes = sweeping;
}
};
enum SpewChannel {