|
[coverage] Block coverage with support for IfStatements
This CL implements general infrastructure for block coverage together with
initial support for if-statements.
Coverage output can be generated in lcov format by d8 as follows:
$ d8 --block-coverage --lcov=$(echo ~/simple-if.lcov) ~/simple-if.js
$ genhtml ~/simple-if.lcov -o ~/simple-if
$ chrome ~/simple-if/index.html
A high level overview of the implementation follows:
The parser now collects source ranges unconditionally for relevant AST nodes.
Memory overhead is very low and this seemed like the cleanest and simplest
alternative.
Bytecode generation uses these ranges to allocate coverage slots and insert
IncBlockCounter instructions (e.g. at the beginning of then- and else blocks
for if-statements). The slot-range mapping is generated here and passed on
through CompilationInfo, and is later accessible through the
SharedFunctionInfo.
The IncBlockCounter bytecode fetches the slot-range mapping (called
CoverageInfo) from the shared function info and simply increments the counter.
We don't collect native-context-specific counts as they are irrelevant to our
use-cases.
Coverage information is finally generated on-demand through Coverage::Collect.
The only current consumer is a d8 front-end with lcov-style output, but the
short-term goal is to expose this through the inspector protocol.
BUG= v8:6000
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_rel_ng
Review-Url: https://codereview.chromium.org/2882973002
Cr-Commit-Position: refs/heads/master@{#45737}
Committed: https://chromium.googlesource.com/v8/v8/+/b42415402f0d251ab879bb168b386bcd71fdc35d
Total comments: 25
Total comments: 1
Total comments: 9
Total comments: 6
Total comments: 12
Total comments: 15
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+707 lines, -72 lines) |
Patch |
|
M |
src/api.cc
|
View
|
1
2
3
4
5
6
7
8
|
2 chunks |
+13 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/ast/ast.h
|
View
|
1
2
3
4
5
6
7
8
|
5 chunks |
+21 lines, -8 lines |
0 comments
|
Download
|
|
M |
src/compilation-info.h
|
View
|
1
2
3
4
5
6
7
8
|
5 chunks |
+18 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/compilation-info.cc
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+5 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/compiler.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
1 chunk |
+7 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/compiler/bytecode-graph-builder.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
1 chunk |
+12 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/compiler/linkage.cc
|
View
|
1
2
3
4
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
src/d8.cc
|
View
|
1
2
3
4
5
6
7
8
|
3 chunks |
+61 lines, -26 lines |
0 comments
|
Download
|
|
M |
src/debug/debug.h
|
View
|
1
2
3
4
5
6
7
8
9
10
|
2 chunks |
+8 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/debug/debug.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
4 chunks |
+41 lines, -14 lines |
0 comments
|
Download
|
|
M |
src/debug/debug-coverage.h
|
View
|
1
2
3
4
5
|
2 chunks |
+9 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/debug/debug-coverage.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
6 chunks |
+44 lines, -1 line |
0 comments
|
Download
|
|
M |
src/debug/debug-interface.h
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
3 chunks |
+23 lines, -2 lines |
0 comments
|
Download
|
|
M |
src/factory.h
|
View
|
1
2
3
4
|
2 chunks |
+4 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/factory.cc
|
View
|
1
2
3
4
5
|
1 chunk |
+16 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/flag-definitions.h
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
src/interpreter/bytecode-array-builder.h
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
1 chunk |
+3 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/interpreter/bytecode-array-builder.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
1 chunk |
+6 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/interpreter/bytecode-generator.h
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
3 chunks |
+5 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/interpreter/bytecode-generator.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
6 chunks |
+65 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/interpreter/bytecodes.h
|
View
|
1
2
3
4
|
1 chunk |
+3 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/interpreter/interpreter-generator.cc
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+14 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/isolate.h
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+4 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/objects.h
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
src/objects.cc
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+8 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/objects-inl.h
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
src/objects-printer.cc
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
src/objects/debug-objects.h
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
3 chunks |
+47 lines, -1 line |
0 comments
|
Download
|
|
M |
src/objects/debug-objects.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
2 chunks |
+61 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/objects/debug-objects-inl.h
|
View
|
1
2
3
4
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/objects/shared-function-info.h
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+4 lines, -0 lines |
0 comments
|
Download
|
|
M |
src/parsing/parser-base.h
|
View
|
1
2
3
4
5
6
7
8
|
2 chunks |
+45 lines, -2 lines |
0 comments
|
Download
|
|
M |
src/parsing/preparser.h
|
View
|
1
2
3
4
|
1 chunk |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
src/runtime/runtime.h
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
1 chunk |
+3 lines, -1 line |
0 comments
|
Download
|
|
M |
src/runtime/runtime-debug.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
4 chunks |
+61 lines, -15 lines |
0 comments
|
Download
|
|
A |
test/mjsunit/code-coverage-block.js
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+83 lines, -0 lines |
0 comments
|
Download
|
|
M |
test/unittests/interpreter/bytecode-array-builder-unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
1 chunk |
+3 lines, -0 lines |
0 comments
|
Download
|
Total messages: 85 (62 generated)
|