• 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...
cctest Loading commit data...
common Loading commit data...
debugger Loading commit data...
fuzzer Loading commit data...
inspector Loading commit data...
intl Loading commit data...
js-perf-test Loading commit data...
memory Loading commit data...
message Loading commit data...
mjsunit Loading commit data...
mkgrokdump Loading commit data...
mozilla Loading commit data...
preparser Loading commit data...
promises-aplus Loading commit data...
test262 Loading commit data...
unittests Loading commit data...
wasm-spec-tests Loading commit data...
webkit Loading commit data...
BUILD.gn Loading commit data...
bot_default.gyp Loading commit data...
bot_default.isolate Loading commit data...
default.gyp Loading commit data...
default.isolate Loading commit data...
optimize_for_size.gyp Loading commit data...
optimize_for_size.isolate Loading commit data...
perf.gyp Loading commit data...
perf.isolate Loading commit data...