[debug] collect coverage for functions on the stack when enabling.
BUG=v8:5808 Change-Id: I7bb3c3655e17271b44de881416e150ef51811154 Reviewed-on: https://chromium-review.googlesource.com/457336 Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#43939}
This commit is contained in:
parent
721e226bd8
commit
64754cf2f5
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "src/base/hashmap.h"
|
#include "src/base/hashmap.h"
|
||||||
#include "src/deoptimizer.h"
|
#include "src/deoptimizer.h"
|
||||||
|
#include "src/frames-inl.h"
|
||||||
#include "src/isolate.h"
|
#include "src/isolate.h"
|
||||||
#include "src/objects-inl.h"
|
#include "src/objects-inl.h"
|
||||||
#include "src/objects.h"
|
#include "src/objects.h"
|
||||||
@ -148,6 +149,13 @@ void Coverage::TogglePrecise(Isolate* isolate, bool enable) {
|
|||||||
ArrayList::New(isolate, static_cast<int>(vectors.size()));
|
ArrayList::New(isolate, static_cast<int>(vectors.size()));
|
||||||
for (const auto& vector : vectors) list = ArrayList::Add(list, vector);
|
for (const auto& vector : vectors) list = ArrayList::Add(list, vector);
|
||||||
isolate->SetCodeCoverageList(*list);
|
isolate->SetCodeCoverageList(*list);
|
||||||
|
// Increment count for functions currently on the stack. We won't observe
|
||||||
|
// entry of these functions, but we know they have coverage.
|
||||||
|
for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
|
||||||
|
JSFunction* function = it.frame()->function();
|
||||||
|
if (!function->shared()->IsSubjectToDebugging()) continue;
|
||||||
|
function->feedback_vector()->increment_invocation_count();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
isolate->SetCodeCoverageList(isolate->heap()->undefined_value());
|
isolate->SetCodeCoverageList(isolate->heap()->undefined_value());
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,11 @@ int FeedbackVector::invocation_count() const {
|
|||||||
return Smi::cast(get(kInvocationCountIndex))->value();
|
return Smi::cast(get(kInvocationCountIndex))->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FeedbackVector::increment_invocation_count() {
|
||||||
|
int count = invocation_count() + 1;
|
||||||
|
if (Smi::IsValid(count)) set(kInvocationCountIndex, Smi::FromInt(count));
|
||||||
|
}
|
||||||
|
|
||||||
void FeedbackVector::clear_invocation_count() {
|
void FeedbackVector::clear_invocation_count() {
|
||||||
set(kInvocationCountIndex, Smi::kZero);
|
set(kInvocationCountIndex, Smi::kZero);
|
||||||
}
|
}
|
||||||
|
@ -299,6 +299,7 @@ class FeedbackVector : public FixedArray {
|
|||||||
inline FeedbackMetadata* metadata() const;
|
inline FeedbackMetadata* metadata() const;
|
||||||
inline SharedFunctionInfo* shared_function_info() const;
|
inline SharedFunctionInfo* shared_function_info() const;
|
||||||
inline int invocation_count() const;
|
inline int invocation_count() const;
|
||||||
|
inline void increment_invocation_count();
|
||||||
inline void clear_invocation_count();
|
inline void clear_invocation_count();
|
||||||
|
|
||||||
// Conversion from a slot to an integer index to the underlying array.
|
// Conversion from a slot to an integer index to the underlying array.
|
||||||
|
@ -347,3 +347,82 @@ Running test: testBestEffortCoveragePrecise
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Running test: testEnablePreciseCoverageAtPause
|
||||||
|
{
|
||||||
|
id : <messageId>
|
||||||
|
result : {
|
||||||
|
result : {
|
||||||
|
type : undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
id : <messageId>
|
||||||
|
result : {
|
||||||
|
result : [
|
||||||
|
[0] : {
|
||||||
|
functions : [
|
||||||
|
[0] : {
|
||||||
|
functionName :
|
||||||
|
ranges : [
|
||||||
|
[0] : {
|
||||||
|
count : 1
|
||||||
|
endOffset : 114
|
||||||
|
startOffset : 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
[1] : {
|
||||||
|
functionName : g
|
||||||
|
ranges : [
|
||||||
|
[0] : {
|
||||||
|
count : 1
|
||||||
|
endOffset : 29
|
||||||
|
startOffset : 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
[2] : {
|
||||||
|
functionName : f
|
||||||
|
ranges : [
|
||||||
|
[0] : {
|
||||||
|
count : 4
|
||||||
|
endOffset : 83
|
||||||
|
startOffset : 30
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
[3] : {
|
||||||
|
functionName : h
|
||||||
|
ranges : [
|
||||||
|
[0] : {
|
||||||
|
count : 0
|
||||||
|
endOffset : 107
|
||||||
|
startOffset : 84
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
scriptId : <scriptId>
|
||||||
|
url : 5
|
||||||
|
}
|
||||||
|
[1] : {
|
||||||
|
functions : [
|
||||||
|
[0] : {
|
||||||
|
functionName :
|
||||||
|
ranges : [
|
||||||
|
[0] : {
|
||||||
|
count : 1
|
||||||
|
endOffset : 11
|
||||||
|
startOffset : 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
scriptId : <scriptId>
|
||||||
|
url :
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -14,6 +14,21 @@ function fib(x) {
|
|||||||
fib(5);
|
fib(5);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
var break_source =
|
||||||
|
`
|
||||||
|
function g() {
|
||||||
|
debugger;
|
||||||
|
}
|
||||||
|
function f(x) {
|
||||||
|
if (x == 0) g();
|
||||||
|
else f(x - 1);
|
||||||
|
}
|
||||||
|
function h() {
|
||||||
|
g();
|
||||||
|
}
|
||||||
|
f(3);
|
||||||
|
`;
|
||||||
|
|
||||||
InspectorTest.log("Test collecting code coverage data with Profiler.collectCoverage.");
|
InspectorTest.log("Test collecting code coverage data with Profiler.collectCoverage.");
|
||||||
|
|
||||||
function ClearAndGC() {
|
function ClearAndGC() {
|
||||||
@ -118,4 +133,25 @@ InspectorTest.runTestSuite([
|
|||||||
.then(Protocol.Runtime.disable)
|
.then(Protocol.Runtime.disable)
|
||||||
.then(next);
|
.then(next);
|
||||||
},
|
},
|
||||||
|
function testEnablePreciseCoverageAtPause(next)
|
||||||
|
{
|
||||||
|
function handleDebuggerPause() {
|
||||||
|
Protocol.Profiler.enable()
|
||||||
|
.then(Protocol.Profiler.startPreciseCoverage)
|
||||||
|
.then(Protocol.Debugger.resume)
|
||||||
|
}
|
||||||
|
Protocol.Debugger.enable();
|
||||||
|
Protocol.Debugger.oncePaused().then(handleDebuggerPause);
|
||||||
|
Protocol.Runtime.enable()
|
||||||
|
.then(() => Protocol.Runtime.compileScript({ expression: break_source, sourceURL: "5", persistScript: true }))
|
||||||
|
.then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
|
||||||
|
.then(InspectorTest.logMessage)
|
||||||
|
.then(ClearAndGC)
|
||||||
|
.then(Protocol.Profiler.takePreciseCoverage)
|
||||||
|
.then(LogSorted)
|
||||||
|
.then(Protocol.Profiler.stopPreciseCoverage)
|
||||||
|
.then(Protocol.Profiler.disable)
|
||||||
|
.then(Protocol.Runtime.disable)
|
||||||
|
.then(next);
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user