Bug 1458878 - Assert no GC in IterateScriptCallback. r=jonco

This commit is contained in:
Tooru Fujisawa 2018-05-15 10:08:05 +09:00
Родитель 1ff93ba361
Коммит 025cba2c23
4 изменённых файлов: 10 добавлений и 7 удалений

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

@ -111,7 +111,8 @@ IterateHeapUnbarrieredForZone(JSContext* cx, JS::Zone* zone, void* data,
extern void
IterateChunks(JSContext* cx, void* data, IterateChunkCallback chunkCallback);
typedef void (*IterateScriptCallback)(JSRuntime* rt, void* data, JSScript* script);
typedef void (*IterateScriptCallback)(JSRuntime* rt, void* data, JSScript* script,
const JS::AutoRequireNoGC& nogc);
/*
* Invoke scriptCallback on every in-use script for

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

@ -86,17 +86,18 @@ js::IterateScripts(JSContext* cx, JSCompartment* compartment,
MOZ_ASSERT(!cx->suppressGC);
AutoEmptyNursery empty(cx);
AutoPrepareForTracing prep(cx);
JS::AutoSuppressGCAnalysis nogc;
if (compartment) {
Zone* zone = compartment->zone();
for (auto script = zone->cellIter<JSScript>(empty); !script.done(); script.next()) {
if (script->compartment() == compartment)
scriptCallback(cx->runtime(), data, script);
scriptCallback(cx->runtime(), data, script, nogc);
}
} else {
for (ZonesIter zone(cx->runtime(), SkipAtoms); !zone.done(); zone.next()) {
for (auto script = zone->cellIter<JSScript>(empty); !script.done(); script.next())
scriptCallback(cx->runtime(), data, script);
scriptCallback(cx->runtime(), data, script, nogc);
}
}
}

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

@ -10,7 +10,7 @@
using namespace JS;
static void
ScriptCallback(JSRuntime* rt, void* data, JSScript* script)
ScriptCallback(JSRuntime* rt, void* data, JSScript* script, const JS::AutoRequireNoGC& nogc)
{
unsigned& count = *static_cast<unsigned*>(data);
if (script->hasIonScript())

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

@ -4589,9 +4589,10 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery
return true;
}
static void considerScript(JSRuntime* rt, void* data, JSScript* script) {
static void considerScript(JSRuntime* rt, void* data, JSScript* script,
const JS::AutoRequireNoGC& nogc) {
ScriptQuery* self = static_cast<ScriptQuery*>(data);
self->consider(script);
self->consider(script, nogc);
}
/*
@ -4599,7 +4600,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery
* |innermostForCompartment|, as appropriate. Set |oom| if an out of memory
* condition occurred.
*/
void consider(JSScript* script) {
void consider(JSScript* script, const JS::AutoRequireNoGC& nogc) {
// We check for presence of script->code() because it is possible that
// the script was created and thus exposed to GC, but *not* fully
// initialized from fullyInit{FromEmitter,Trivial} due to errors.