• Ulan Degenbaev's avatar
    [heap] Instrument mark-compact to track retaining paths for debugging. · 40c34606
    Ulan Degenbaev authored
    This patch adds a new intrinsic: %DebugTrackRetainingPath(object).
    Calling the intrinsic in JS code saves a weak reference to the given
    object in GC internal table of tracked objects.
    
    Each subsequent full GC prints to stdout the retaining path for each
    tracked object (if it is still alive). The retaining path is the real
    path that the marker took from the root set to the tracked object.
    
    This is useful for investigating of memory leaks:
    1) Add %DebugTrackRetainingPath(leaking_object) in JS code.
    For example:
      function foo() {
        let x = { bar: "bar"};
        %DebugTrackRetainingPath(x);
        return () => { return x; }
      }
    
      let closure = foo();
      gc();
    
    2) Run d8 with --allow-natives-syntax --track-retaining-path --expose-gc.
    
    3) Check the retaining path in stdout.
    
    For more detailed inspection, run d8 in gdb and set breakpoint in
    
    v8: :internal::Heap::PrintRetainingPath.
    Change-Id: I01a0faac1e009bc6c321fa75613900b49d2b036f
    Reviewed-on: https://chromium-review.googlesource.com/575972
    Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
    Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#46766}
    40c34606
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...