зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1588300 - Use IterateScripts API when generating code coverage data r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D49111 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a19c705a8b
Коммит
760c3aea6d
|
@ -29,8 +29,6 @@
|
|||
|
||||
#include "frontend/BytecodeCompiler.h"
|
||||
#include "frontend/SourceNotes.h"
|
||||
#include "gc/FreeOp.h"
|
||||
#include "gc/GCInternals.h"
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/Printf.h"
|
||||
#include "js/Symbol.h"
|
||||
|
@ -2862,14 +2860,30 @@ JS_FRIEND_API JSString* js::GetPCCountScriptContents(JSContext* cx,
|
|||
return NewStringCopyZ<CanGC>(cx, sp.string());
|
||||
}
|
||||
|
||||
struct CollectedScripts {
|
||||
MutableHandle<ScriptVector> scripts;
|
||||
bool ok = true;
|
||||
|
||||
explicit CollectedScripts(MutableHandle<ScriptVector> scripts)
|
||||
: scripts(scripts) {}
|
||||
|
||||
static void consider(JSRuntime* rt, void* data, JSScript* script,
|
||||
const JS::AutoRequireNoGC& nogc) {
|
||||
auto self = static_cast<CollectedScripts*>(data);
|
||||
if (!script->filename()) {
|
||||
return;
|
||||
}
|
||||
if (!self->scripts.append(script)) {
|
||||
self->ok = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static bool GenerateLcovInfo(JSContext* cx, JS::Realm* realm,
|
||||
GenericPrinter& out) {
|
||||
JSRuntime* rt = cx->runtime();
|
||||
|
||||
AutoRealmUnchecked ar(cx, realm);
|
||||
|
||||
// Collect the list of scripts which are part of the current realm.
|
||||
{ js::gc::AutoPrepareForTracing apft(cx); }
|
||||
|
||||
// Hold the scripts that we have already flushed, to avoid flushing them
|
||||
// twice.
|
||||
|
@ -2877,16 +2891,12 @@ static bool GenerateLcovInfo(JSContext* cx, JS::Realm* realm,
|
|||
Rooted<JSScriptSet> scriptsDone(cx, JSScriptSet(cx));
|
||||
|
||||
Rooted<ScriptVector> queue(cx, ScriptVector(cx));
|
||||
for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
|
||||
for (auto script = zone->cellIter<JSScript>(); !script.done();
|
||||
script.next()) {
|
||||
if (script->realm() != realm || !script->filename()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!queue.append(script)) {
|
||||
return false;
|
||||
}
|
||||
{
|
||||
CollectedScripts result(&queue);
|
||||
IterateScripts(cx, realm, &result, &CollectedScripts::consider);
|
||||
if (!result.ok) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче