• 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
..
code-cache-inl.h Loading commit data...
code-cache.h Loading commit data...
compilation-cache-inl.h Loading commit data...
compilation-cache.h Loading commit data...
debug-objects-inl.h Loading commit data...
debug-objects.cc Loading commit data...
debug-objects.h Loading commit data...
descriptor-array.h Loading commit data...
dictionary.h Loading commit data...
frame-array-inl.h Loading commit data...
frame-array.h Loading commit data...
hash-table.h Loading commit data...
intl-objects.cc Loading commit data...
intl-objects.h Loading commit data...
literal-objects.cc Loading commit data...
literal-objects.h Loading commit data...
map-inl.h Loading commit data...
map.h Loading commit data...
module-info.h Loading commit data...
object-macros-undef.h Loading commit data...
object-macros.h Loading commit data...
regexp-match-info.h Loading commit data...
scope-info.cc Loading commit data...
scope-info.h Loading commit data...
script-inl.h Loading commit data...
script.h Loading commit data...
shared-function-info-inl.h Loading commit data...
shared-function-info.h Loading commit data...
string-table.h Loading commit data...