• Seth Brenith's avatar
    Improve Script reuse in isolate compilation cache, part 1 · 25072178
    Seth Brenith authored
    Once the root SharedFunctionInfo for any Script gets its bytecode
    flushed, the Isolate's compilation cache currently evicts that entry, to
    reduce memory usage. However, the associated Script is likely still
    alive, since scripts often declare functions which outlive the initial
    evaluation of the script. If an identical script is loaded later, a
    duplicate Script is created for it, which can waste memory.
    
    In this change, I propose that the compilation cache keys can refer
    weakly to the Script. When the root SharedFunctionInfo gets old, instead
    of deleting the cache entry entirely, we can just drop the strong
    reference to the SharedFunctionInfo. A subsequent lookup in the cache
    will retrieve the Script instead of the root SharedFunctionInfo,
    indicating an opportunity to save some memory by reusing the existing
    Script.
    
    Eventually, all callers to CompilationCache::LookupScript should reuse
    the Script if possible. This change implements only the easy case of
    reusing the Script for synchronous parsing. Follow-up changes will be
    required for the TODO comments left by this change.
    
    Bug: v8:12808
    Change-Id: Ia8b0389441a682de9a43e73329049fd2e7835d3d
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3597106Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
    Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
    Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#80472}
    25072178
Name
Last commit
Last update
..
heap-tester.h Loading commit data...
heap-utils.cc Loading commit data...
heap-utils.h Loading commit data...
test-alloc.cc Loading commit data...
test-array-buffer-tracker.cc Loading commit data...
test-compaction.cc Loading commit data...
test-concurrent-allocation.cc Loading commit data...
test-concurrent-marking.cc Loading commit data...
test-external-string-tracker.cc Loading commit data...
test-heap.cc Loading commit data...
test-incremental-marking.cc Loading commit data...
test-invalidated-slots.cc Loading commit data...
test-iterators.cc Loading commit data...
test-mark-compact.cc Loading commit data...
test-memory-measurement.cc Loading commit data...
test-page-promotion.cc Loading commit data...
test-shared-heap.cc Loading commit data...
test-spaces.cc Loading commit data...
test-unmapper.cc Loading commit data...
test-weak-references.cc Loading commit data...
test-write-barrier.cc Loading commit data...