• Peter Marshall's avatar
    [cpu-profiler] Add source positions for inlined function calls · af0428ac
    Peter Marshall authored
    Currently in both kCallerLineNumbers and kLeafNodeLineNumbers modes, we
    correctly capture inline stacks. In leaf number mode, this is simple as
    we simply add the path onto the existing tree. For caller line numbers
    mode this is more complex, because each path through various inlined
    function should be represented in the tree, even when there are
    multiple callsites to the same function inlined.
    
    Currently we don't correctly show line numbers for inlined functions.
    We do actually have this information though, which is generated by
    turbofan and stored in the source_position_table data structure on the
    code object.
    
    This also changes the behavior of the SourcePositionTable class. A
    problem we uncovered is that the PC that the sampler provides for every
    frame except the leaf is the return address of the calling frame. This
    address is *after* the call has already happened. It can be attributed
    to the next line of the function, rather than the calling line, which
    is wrong. We fix that here by using lower_bound in GetSourceLineNumber.
    
    The same problem happens in GetInlineStack - the PC of the caller is
    actually the instruction after the call. The information turbofan
    generates assumes that the instruction after the call is not part of
    the call (fair enough). To fix this we do the same thing as above - use
    lower_bound and then iterate back by one.
    
    TBR=alph@chromium.org
    
    Bug: v8:8575, v8:8606
    Change-Id: Idc4bd4bdc8fb70b70ecc1a77a1e3744a86f83483
    Reviewed-on: https://chromium-review.googlesource.com/c/1374290
    Commit-Queue: Peter Marshall <petermarshall@chromium.org>
    Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
    Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#58545}
    af0428ac
source-position.h 3.78 KB