• jgruber's avatar
    [coverage] Block coverage with support for IfStatements · b4241540
    jgruber authored
    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}
    b4241540
Name
Last commit
Last update
benchmarks Loading commit data...
build_overrides Loading commit data...
docs Loading commit data...
gni Loading commit data...
gypfiles Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.clang-format Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
ChangeLog Loading commit data...
DEPS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
Makefile Loading commit data...
Makefile.android Loading commit data...
OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...
snapshot_toolchain.gni Loading commit data...