[coverage] Add event for coverage reporting
This CL adds a new event that enables the back-end to send coverage updates on its own initiative. This event can be triggered via the C++ method `triggerPreciseCoverageDeltaUpdate` on the agent in a way that causes coverage data to be immediatelly collected. This is useful in the back-end to collect coverage at a certain point in time, i.e. when a lifecycle event such as first contentful paint occurs. The previous interface could not support this, because it could not reasonably be triggered from C++, and if triggered through the protocol, dispatching messages added delay that invalidated the data (i.e. data might have been taken too late to be accurate). TBR=yangguo@chromium.org Change-Id: I0f7201412a8d64866e6e314e5bc850354c13a9da Bug: chromium:1022031 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1992437 Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Cr-Commit-Position: refs/heads/master@{#65864}
This commit is contained in:
parent
add4aa587f
commit
ee8602d334
@ -888,6 +888,19 @@ domain Profiler
|
|||||||
# Profile title passed as an argument to console.profile().
|
# Profile title passed as an argument to console.profile().
|
||||||
optional string title
|
optional string title
|
||||||
|
|
||||||
|
# Reports coverage delta since the last poll (either from an event like this, or from
|
||||||
|
# `takePreciseCoverage` for the current isolate. May only be sent if precise code
|
||||||
|
# coverage has been started. This event can be trigged by the embedder to, for example,
|
||||||
|
# trigger collection of coverage data immediatelly at a certain point in time.
|
||||||
|
experimental event preciseCoverageDeltaUpdate
|
||||||
|
parameters
|
||||||
|
# Monotonically increasing time (in seconds) when the coverage update was taken in the backend.
|
||||||
|
number timestamp
|
||||||
|
# Identifier for distinguishing coverage events.
|
||||||
|
string occassion
|
||||||
|
# Coverage data for the current isolate.
|
||||||
|
array of ScriptCoverage result
|
||||||
|
|
||||||
# Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects.
|
# Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects.
|
||||||
# Evaluation results are returned as mirror object that expose object type, string representation
|
# Evaluation results are returned as mirror object that expose object type, string representation
|
||||||
# and unique identifier that can be used for further object reference. Original objects are
|
# and unique identifier that can be used for further object reference. Original objects are
|
||||||
|
@ -161,6 +161,8 @@ class V8_EXPORT V8InspectorSession {
|
|||||||
v8::Local<v8::Context>*,
|
v8::Local<v8::Context>*,
|
||||||
std::unique_ptr<StringBuffer>* objectGroup) = 0;
|
std::unique_ptr<StringBuffer>* objectGroup) = 0;
|
||||||
virtual void releaseObjectGroup(const StringView&) = 0;
|
virtual void releaseObjectGroup(const StringView&) = 0;
|
||||||
|
virtual void triggerPreciseCoverageDeltaUpdate(
|
||||||
|
const StringView& occassion) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class V8_EXPORT V8InspectorClient {
|
class V8_EXPORT V8InspectorClient {
|
||||||
|
@ -464,4 +464,9 @@ V8InspectorSessionImpl::searchInTextByLines(const StringView& text,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V8InspectorSessionImpl::triggerPreciseCoverageDeltaUpdate(
|
||||||
|
const StringView& occassion) {
|
||||||
|
m_profilerAgent->triggerPreciseCoverageDeltaUpdate(toString16(occassion));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace v8_inspector
|
} // namespace v8_inspector
|
||||||
|
@ -92,6 +92,8 @@ class V8InspectorSessionImpl : public V8InspectorSession,
|
|||||||
V8InspectorSession::Inspectable* inspectedObject(unsigned num);
|
V8InspectorSession::Inspectable* inspectedObject(unsigned num);
|
||||||
static const unsigned kInspectedObjectBufferSize = 5;
|
static const unsigned kInspectedObjectBufferSize = 5;
|
||||||
|
|
||||||
|
void triggerPreciseCoverageDeltaUpdate(const StringView& occassion) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
V8InspectorSessionImpl(V8InspectorImpl*, int contextGroupId, int sessionId,
|
V8InspectorSessionImpl(V8InspectorImpl*, int contextGroupId, int sessionId,
|
||||||
V8Inspector::Channel*, const StringView& state);
|
V8Inspector::Channel*, const StringView& state);
|
||||||
|
@ -414,6 +414,22 @@ Response V8ProfilerAgentImpl::takePreciseCoverage(
|
|||||||
return coverageToProtocol(m_session->inspector(), coverage, out_result);
|
return coverageToProtocol(m_session->inspector(), coverage, out_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V8ProfilerAgentImpl::triggerPreciseCoverageDeltaUpdate(
|
||||||
|
const String16& occassion) {
|
||||||
|
if (!m_state->booleanProperty(ProfilerAgentState::preciseCoverageStarted,
|
||||||
|
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>>
|
||||||
|
out_result;
|
||||||
|
coverageToProtocol(m_session->inspector(), coverage, &out_result);
|
||||||
|
double now =
|
||||||
|
v8::base::TimeTicks::HighResolutionNow().since_origin().InSecondsF();
|
||||||
|
m_frontend.preciseCoverageDeltaUpdate(now, occassion, std::move(out_result));
|
||||||
|
}
|
||||||
|
|
||||||
Response V8ProfilerAgentImpl::getBestEffortCoverage(
|
Response V8ProfilerAgentImpl::getBestEffortCoverage(
|
||||||
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>*
|
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>*
|
||||||
out_result) {
|
out_result) {
|
||||||
|
@ -65,6 +65,8 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend {
|
|||||||
void consoleProfile(const String16& title);
|
void consoleProfile(const String16& title);
|
||||||
void consoleProfileEnd(const String16& title);
|
void consoleProfileEnd(const String16& title);
|
||||||
|
|
||||||
|
void triggerPreciseCoverageDeltaUpdate(const String16& occassion);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String16 nextProfileId();
|
String16 nextProfileId();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user