зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1546934 - Change LCov code coverage machinery to use a process-wide flag. r=nbp
This will simplify the Baseline Interpreter work. Differential Revision: https://phabricator.services.mozilla.com/D28813 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
7dab664a8c
Коммит
cae806b2c7
|
@ -417,7 +417,7 @@ bool BytecodeCompiler::canLazilyParse() const {
|
|||
return options.canLazilyParse &&
|
||||
!cx->realm()->behaviors().disableLazyParsing() &&
|
||||
!cx->realm()->behaviors().discardSource() && !options.sourceIsLazy &&
|
||||
!cx->lcovEnabled() &&
|
||||
!coverage::IsLCovEnabled() &&
|
||||
// Disabled during record/replay. The replay debugger requires
|
||||
// scripts to be constructed in a consistent order, which might not
|
||||
// happen with lazy parsing.
|
||||
|
|
|
@ -8175,7 +8175,7 @@ void GCRuntime::mergeRealms(Realm* source, Realm* target) {
|
|||
atomMarking.adoptMarkedAtoms(target->zone(), source->zone());
|
||||
|
||||
// Merge script name maps in the target realm's map.
|
||||
if (rt->lcovOutput().isEnabled() && source->scriptNameMap) {
|
||||
if (coverage::IsLCovEnabled() && source->scriptNameMap) {
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
|
||||
if (!target->scriptNameMap) {
|
||||
|
|
|
@ -10542,7 +10542,6 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
|
|||
reportWarnings = op.getBoolOption('w');
|
||||
compileOnly = op.getBoolOption('c');
|
||||
printTiming = op.getBoolOption('b');
|
||||
enableCodeCoverage = op.getBoolOption("code-coverage");
|
||||
enableDisassemblyDumps = op.getBoolOption('D');
|
||||
cx->runtime()->profilingScripts =
|
||||
enableCodeCoverage || enableDisassemblyDumps;
|
||||
|
@ -11228,6 +11227,11 @@ int main(int argc, char** argv, char** envp) {
|
|||
js::DisableExtraThreads();
|
||||
}
|
||||
|
||||
enableCodeCoverage = op.getBoolOption("code-coverage");
|
||||
if (enableCodeCoverage) {
|
||||
coverage::EnableLCov();
|
||||
}
|
||||
|
||||
AutoLibraryLoader loader;
|
||||
MultiStringRange dllPaths = op.getMultiStringOption("dll");
|
||||
while (!dllPaths.empty()) {
|
||||
|
|
|
@ -599,6 +599,21 @@ bool LCovRealm::writeRealmName(JS::Realm* realm) {
|
|||
return !outTN_.hadOutOfMemory();
|
||||
}
|
||||
|
||||
bool gLCovIsEnabled = false;
|
||||
|
||||
void InitLCov() {
|
||||
const char* outDir = getenv("JS_CODE_COVERAGE_OUTPUT_DIR");
|
||||
if (outDir && *outDir != 0) {
|
||||
EnableLCov();
|
||||
}
|
||||
}
|
||||
|
||||
void EnableLCov() {
|
||||
MOZ_ASSERT(!JSRuntime::hasLiveRuntimes(),
|
||||
"EnableLCov must not be called after creating a runtime!");
|
||||
gLCovIsEnabled = true;
|
||||
}
|
||||
|
||||
LCovRuntime::LCovRuntime() : out_(), pid_(getpid()), isEmpty_(true) {}
|
||||
|
||||
LCovRuntime::~LCovRuntime() {
|
||||
|
|
|
@ -125,15 +125,6 @@ class LCovRuntime {
|
|||
// all the scripts executed in the current JSRuntime.
|
||||
void init();
|
||||
|
||||
// Check if we should collect code coverage information.
|
||||
bool isEnabled() const {
|
||||
static bool isEnabled_ = ([]() {
|
||||
const char* outDir = getenv("JS_CODE_COVERAGE_OUTPUT_DIR");
|
||||
return outDir && *outDir != 0;
|
||||
})();
|
||||
return isEnabled_;
|
||||
}
|
||||
|
||||
// Write the aggregated result of the code coverage of a realm
|
||||
// into a file.
|
||||
void writeLCovResult(LCovRealm& realm);
|
||||
|
@ -166,6 +157,15 @@ class LCovRuntime {
|
|||
bool isEmpty_;
|
||||
};
|
||||
|
||||
extern void InitLCov();
|
||||
|
||||
extern void EnableLCov();
|
||||
|
||||
inline bool IsLCovEnabled() {
|
||||
extern bool gLCovIsEnabled;
|
||||
return gLCovIsEnabled;
|
||||
}
|
||||
|
||||
} // namespace coverage
|
||||
} // namespace js
|
||||
|
||||
|
|
|
@ -114,6 +114,8 @@ JS_PUBLIC_API const char* JS::detail::InitWithFailureDiagnostic(
|
|||
|
||||
js::gc::InitMemorySubsystem(); // Ensure gc::SystemPageSize() works.
|
||||
|
||||
js::coverage::InitLCov();
|
||||
|
||||
RETURN_IF_FAIL(js::jit::InitProcessExecutableMemory());
|
||||
|
||||
RETURN_IF_FAIL(js::MemoryProtectionExceptionHandler::install());
|
||||
|
|
|
@ -287,7 +287,6 @@ struct JSContext : public JS::RootingContext,
|
|||
return runtime_->jitSupportsUnalignedAccesses;
|
||||
}
|
||||
bool jitSupportsSimd() const { return runtime_->jitSupportsSimd; }
|
||||
bool lcovEnabled() const { return runtime_->lcovOutput().isEnabled(); }
|
||||
|
||||
/*
|
||||
* "Entering" a realm changes cx->realm (which changes cx->global). Note
|
||||
|
|
|
@ -3361,7 +3361,7 @@ JSScript* JSScript::Create(JSContext* cx, const ReadOnlyCompileOptions& options,
|
|||
script->setFlag(MutableFlags::TrackRecordReplayProgress,
|
||||
ShouldTrackRecordReplayProgress(script));
|
||||
|
||||
if (cx->runtime()->lcovOutput().isEnabled()) {
|
||||
if (coverage::IsLCovEnabled()) {
|
||||
if (!script->initScriptName(cx)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -3714,8 +3714,8 @@ void JSScript::finalize(FreeOp* fop) {
|
|||
|
||||
// Collect code coverage information for this script and all its inner
|
||||
// scripts, and store the aggregated information on the realm.
|
||||
MOZ_ASSERT_IF(hasScriptName(), fop->runtime()->lcovOutput().isEnabled());
|
||||
if (fop->runtime()->lcovOutput().isEnabled() && hasScriptName()) {
|
||||
MOZ_ASSERT_IF(hasScriptName(), coverage::IsLCovEnabled());
|
||||
if (coverage::IsLCovEnabled() && hasScriptName()) {
|
||||
realm()->lcovOutput.collectCodeCoverageInfo(realm(), this, getScriptName());
|
||||
destroyScriptName();
|
||||
}
|
||||
|
|
|
@ -62,9 +62,8 @@ Realm::~Realm() {
|
|||
MOZ_ASSERT(!hasBeenEnteredIgnoringJit());
|
||||
|
||||
// Write the code coverage information in a file.
|
||||
JSRuntime* rt = runtimeFromMainThread();
|
||||
if (rt->lcovOutput().isEnabled()) {
|
||||
rt->lcovOutput().writeLCovResult(lcovOutput);
|
||||
if (coverage::IsLCovEnabled()) {
|
||||
runtime_->lcovOutput().writeLCovResult(lcovOutput);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(runtime_->numRealms > 0);
|
||||
|
@ -826,9 +825,7 @@ bool Realm::collectCoverageForPGO() const {
|
|||
}
|
||||
|
||||
bool Realm::collectCoverageForDebug() const {
|
||||
return debuggerObservesCoverage() ||
|
||||
runtimeFromAnyThread()->profilingScripts ||
|
||||
runtimeFromAnyThread()->lcovOutput().isEnabled();
|
||||
return debuggerObservesCoverage() || coverage::IsLCovEnabled();
|
||||
}
|
||||
|
||||
void Realm::clearScriptCounts() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче