[coverage] Provide option to prevent triggered updates
Coverage updates are sent as deltas, and this means that it is very important that the consumer gets /all/ updates; otherwise, the coverage information will be wrong. Previously, we introduces the ability into the back-end to send triggered updates, i.e. updates that are triggered by the back-end at interesting points in time. These updates are delivered via an event, and any consumer must process these events. This CL introduces a flag to startPreciseCoverage that controls whether the back-end is allowed to send such triggered updates on its own initiative. The default is `false` to maintain backwards compatibility with consumers that don't yet handle the events. Bug: chromium:1022031 Change-Id: Ie36a92a3b627b19ea4041f1b8da1ec66c6b9b771 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2043798 Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Dmitry Gozman <dgozman@chromium.org> Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Cr-Commit-Position: refs/heads/master@{#66232}
This commit is contained in:
parent
04c868c1ac
commit
117520e219
@ -831,6 +831,8 @@ domain Profiler
|
||||
optional boolean callCount
|
||||
# Collect block-based coverage.
|
||||
optional boolean detailed
|
||||
# Allow the backend to send updates on its own initiative
|
||||
optional boolean allowTriggeredUpdates
|
||||
returns
|
||||
# Monotonically increasing time (in seconds) when the coverage update was taken in the backend.
|
||||
number timestamp
|
||||
|
@ -27,8 +27,10 @@ static const char profilerEnabled[] = "profilerEnabled";
|
||||
static const char preciseCoverageStarted[] = "preciseCoverageStarted";
|
||||
static const char preciseCoverageCallCount[] = "preciseCoverageCallCount";
|
||||
static const char preciseCoverageDetailed[] = "preciseCoverageDetailed";
|
||||
static const char preciseCoverageAllowTriggeredUpdates[] =
|
||||
"preciseCoverageAllowTriggeredUpdates";
|
||||
static const char typeProfileStarted[] = "typeProfileStarted";
|
||||
}
|
||||
} // namespace ProfilerAgentState
|
||||
|
||||
namespace {
|
||||
|
||||
@ -261,9 +263,11 @@ void V8ProfilerAgentImpl::restore() {
|
||||
ProfilerAgentState::preciseCoverageCallCount, false);
|
||||
bool detailed = m_state->booleanProperty(
|
||||
ProfilerAgentState::preciseCoverageDetailed, false);
|
||||
bool updatesAllowed = m_state->booleanProperty(
|
||||
ProfilerAgentState::preciseCoverageAllowTriggeredUpdates, false);
|
||||
double timestamp;
|
||||
startPreciseCoverage(Maybe<bool>(callCount), Maybe<bool>(detailed),
|
||||
×tamp);
|
||||
Maybe<bool>(updatesAllowed), ×tamp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,19 +298,22 @@ Response V8ProfilerAgentImpl::stop(
|
||||
return Response::OK();
|
||||
}
|
||||
|
||||
Response V8ProfilerAgentImpl::startPreciseCoverage(Maybe<bool> callCount,
|
||||
Maybe<bool> detailed,
|
||||
double* out_timestamp) {
|
||||
Response V8ProfilerAgentImpl::startPreciseCoverage(
|
||||
Maybe<bool> callCount, Maybe<bool> detailed,
|
||||
Maybe<bool> allowTriggeredUpdates, double* out_timestamp) {
|
||||
if (!m_enabled) return Response::Error("Profiler is not enabled");
|
||||
*out_timestamp =
|
||||
v8::base::TimeTicks::HighResolutionNow().since_origin().InSecondsF();
|
||||
bool callCountValue = callCount.fromMaybe(false);
|
||||
bool detailedValue = detailed.fromMaybe(false);
|
||||
bool allowTriggeredUpdatesValue = allowTriggeredUpdates.fromMaybe(false);
|
||||
m_state->setBoolean(ProfilerAgentState::preciseCoverageStarted, true);
|
||||
m_state->setBoolean(ProfilerAgentState::preciseCoverageCallCount,
|
||||
callCountValue);
|
||||
m_state->setBoolean(ProfilerAgentState::preciseCoverageDetailed,
|
||||
detailedValue);
|
||||
m_state->setBoolean(ProfilerAgentState::preciseCoverageAllowTriggeredUpdates,
|
||||
allowTriggeredUpdatesValue);
|
||||
// BlockCount is a superset of PreciseCount. It includes block-granularity
|
||||
// coverage data if it exists (at the time of writing, that's the case for
|
||||
// each function recompiled after the BlockCount mode has been set); and
|
||||
@ -420,6 +427,10 @@ void V8ProfilerAgentImpl::triggerPreciseCoverageDeltaUpdate(
|
||||
false)) {
|
||||
return;
|
||||
}
|
||||
if (!m_state->booleanProperty(
|
||||
ProfilerAgentState::preciseCoverageAllowTriggeredUpdates, false)) {
|
||||
return;
|
||||
}
|
||||
v8::HandleScope handle_scope(m_isolate);
|
||||
v8::debug::Coverage coverage = v8::debug::Coverage::CollectPrecise(m_isolate);
|
||||
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>
|
||||
|
@ -40,6 +40,7 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend {
|
||||
Response stop(std::unique_ptr<protocol::Profiler::Profile>*) override;
|
||||
|
||||
Response startPreciseCoverage(Maybe<bool> binary, Maybe<bool> detailed,
|
||||
Maybe<bool> allow_triggered_updates,
|
||||
double* out_timestamp) override;
|
||||
Response stopPreciseCoverage() override;
|
||||
Response takePreciseCoverage(
|
||||
|
Loading…
Reference in New Issue
Block a user