зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1620495 - Remove type-overloads using LazyScript r=mgaudet
Cleanup up code in the Debugger and in PublicIterators that only used the LazyScript for overload resolution. This changes are largely mechanical and there is room to improve implementations in future Differential Revision: https://phabricator.services.mozilla.com/D66848 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e2b33d2821
Коммит
1035ab8f71
|
@ -5148,8 +5148,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery : public Debugger::QueryBase {
|
|||
static void considerLazyScript(JSRuntime* rt, void* data, BaseScript* script,
|
||||
const JS::AutoRequireNoGC& nogc) {
|
||||
ScriptQuery* self = static_cast<ScriptQuery*>(data);
|
||||
LazyScript* lazy = static_cast<LazyScript*>(script);
|
||||
self->consider(lazy, nogc);
|
||||
self->considerLazy(script, nogc);
|
||||
}
|
||||
|
||||
bool needsDelazifyBeforeQuery() const {
|
||||
|
@ -5257,7 +5256,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery : public Debugger::QueryBase {
|
|||
}
|
||||
}
|
||||
|
||||
void consider(LazyScript* lazyScript, const JS::AutoRequireNoGC& nogc) {
|
||||
void considerLazy(BaseScript* lazyScript, const JS::AutoRequireNoGC& nogc) {
|
||||
MOZ_ASSERT(!needsDelazifyBeforeQuery());
|
||||
|
||||
if (oom) {
|
||||
|
@ -5413,8 +5412,7 @@ class MOZ_STACK_CLASS Debugger::SourceQuery : public Debugger::QueryBase {
|
|||
static void considerLazyScript(JSRuntime* rt, void* data, BaseScript* script,
|
||||
const JS::AutoRequireNoGC& nogc) {
|
||||
SourceQuery* self = static_cast<SourceQuery*>(data);
|
||||
LazyScript* lazy = static_cast<LazyScript*>(script);
|
||||
self->consider(lazy, nogc);
|
||||
self->considerLazy(script, nogc);
|
||||
}
|
||||
|
||||
void consider(JSScript* script, const JS::AutoRequireNoGC& nogc) {
|
||||
|
@ -5437,7 +5435,7 @@ class MOZ_STACK_CLASS Debugger::SourceQuery : public Debugger::QueryBase {
|
|||
}
|
||||
}
|
||||
|
||||
void consider(LazyScript* lazyScript, const JS::AutoRequireNoGC& nogc) {
|
||||
void considerLazy(BaseScript* lazyScript, const JS::AutoRequireNoGC& nogc) {
|
||||
if (oom) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -111,38 +111,38 @@ static void TraverseInnerLazyScriptsForLazyScript(
|
|||
}
|
||||
|
||||
static inline void DoScriptCallback(JSContext* cx, void* data,
|
||||
LazyScript* lazyScript,
|
||||
IterateScriptCallback lazyScriptCallback,
|
||||
BaseScript* script,
|
||||
IterateScriptCallback callback,
|
||||
const JS::AutoRequireNoGC& nogc) {
|
||||
// We call the callback only for the LazyScript that:
|
||||
// (a) its enclosing script has ever been fully compiled and
|
||||
// itself is delazifyable (handled in this function)
|
||||
// (b) it is contained in the (a)'s inner function tree
|
||||
// (handled in TraverseInnerLazyScriptsForLazyScript)
|
||||
if (!lazyScript->enclosingScriptHasEverBeenCompiled()) {
|
||||
return;
|
||||
if (script->isLazyScript()) {
|
||||
// We call the callback only for the LazyScript that:
|
||||
// (a) its enclosing script has ever been fully compiled and
|
||||
// itself is delazifyable (handled in this function)
|
||||
// (b) it is contained in the (a)'s inner function tree
|
||||
// (handled in TraverseInnerLazyScriptsForLazyScript)
|
||||
if (!script->enclosingScriptHasEverBeenCompiled()) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// We check for presence of script->isUncompleted() because it is possible
|
||||
// that the script was created and thus exposed to GC, but *not* fully
|
||||
// initialized from fullyInitFromStencil due to errors.
|
||||
if (static_cast<JSScript*>(script)->isUncompleted()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
lazyScriptCallback(cx->runtime(), data, lazyScript, nogc);
|
||||
// Invoke callback.
|
||||
callback(cx->runtime(), data, script, nogc);
|
||||
|
||||
TraverseInnerLazyScriptsForLazyScript(cx, data, lazyScript,
|
||||
lazyScriptCallback, nogc);
|
||||
}
|
||||
|
||||
static inline void DoScriptCallback(JSContext* cx, void* data, JSScript* script,
|
||||
IterateScriptCallback scriptCallback,
|
||||
const JS::AutoRequireNoGC& nogc) {
|
||||
// We check for presence of script->isUncompleted() 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.
|
||||
if (script->isUncompleted()) {
|
||||
return;
|
||||
// Recursively visit inner lazy scripts. See the filter above for
|
||||
// enclosingScriptHasEverBeenCompiled.
|
||||
if (script->isLazyScript()) {
|
||||
TraverseInnerLazyScriptsForLazyScript(cx, data, script, callback, nogc);
|
||||
}
|
||||
|
||||
scriptCallback(cx->runtime(), data, script, nogc);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <bool MatchLazy>
|
||||
static void IterateScriptsImpl(JSContext* cx, Realm* realm, void* data,
|
||||
IterateScriptCallback scriptCallback) {
|
||||
MOZ_ASSERT(!cx->suppressGC);
|
||||
|
@ -153,24 +153,22 @@ static void IterateScriptsImpl(JSContext* cx, Realm* realm, void* data,
|
|||
Zone* zone = realm->zone();
|
||||
for (auto iter = zone->cellIter<BaseScript>(prep); !iter.done();
|
||||
iter.next()) {
|
||||
if (mozilla::IsSame<T, LazyScript>::value != iter->isLazyScript()) {
|
||||
if (MatchLazy != iter->isLazyScript()) {
|
||||
continue;
|
||||
}
|
||||
T* script = static_cast<T*>(iter.get());
|
||||
if (script->realm() != realm) {
|
||||
if (iter->realm() != realm) {
|
||||
continue;
|
||||
}
|
||||
DoScriptCallback(cx, data, script, scriptCallback, nogc);
|
||||
DoScriptCallback(cx, data, iter.get(), scriptCallback, nogc);
|
||||
}
|
||||
} else {
|
||||
for (ZonesIter zone(cx->runtime(), SkipAtoms); !zone.done(); zone.next()) {
|
||||
for (auto iter = zone->cellIter<BaseScript>(prep); !iter.done();
|
||||
iter.next()) {
|
||||
if (mozilla::IsSame<T, LazyScript>::value != iter->isLazyScript()) {
|
||||
if (MatchLazy != iter->isLazyScript()) {
|
||||
continue;
|
||||
}
|
||||
T* script = static_cast<T*>(iter.get());
|
||||
DoScriptCallback(cx, data, script, scriptCallback, nogc);
|
||||
DoScriptCallback(cx, data, iter.get(), scriptCallback, nogc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,12 +176,12 @@ static void IterateScriptsImpl(JSContext* cx, Realm* realm, void* data,
|
|||
|
||||
void js::IterateScripts(JSContext* cx, Realm* realm, void* data,
|
||||
IterateScriptCallback scriptCallback) {
|
||||
IterateScriptsImpl<JSScript>(cx, realm, data, scriptCallback);
|
||||
IterateScriptsImpl</* MatchLazy = */ false>(cx, realm, data, scriptCallback);
|
||||
}
|
||||
|
||||
void js::IterateLazyScripts(JSContext* cx, Realm* realm, void* data,
|
||||
IterateScriptCallback scriptCallback) {
|
||||
IterateScriptsImpl<LazyScript>(cx, realm, data, scriptCallback);
|
||||
IterateScriptsImpl</* MatchLazy = */ true>(cx, realm, data, scriptCallback);
|
||||
}
|
||||
|
||||
static void IterateGrayObjects(Zone* zone, GCThingCallback cellCallback,
|
||||
|
|
Загрузка…
Ссылка в новой задаче