• Seth Brenith's avatar
    Fix rehashing of script compilation cache · 2df4d58a
    Seth Brenith authored
    The script compilation cache contains weak pointers to Script objects as
    its keys. When doing a rehashing operation, any hash table needs the
    ability to get the hash code for every entry in the table. However, if
    the weak pointer was cleared from a key, there is no longer any way to
    get the hash code for that entry.
    
    In https://crrev.com/c/3597106 , I attempted to solve this problem by
    deleting all entries whose keys contain cleared weak pointers prior to
    rehashing, but the implementation has a bug: when resizing, the new
    table is allocated after deleting the entries with cleared keys, so if
    that allocation triggers a GC, the table can once again have entries
    with cleared keys.
    
    This could be solved in a variety of ways, such as:
    
    1. Iterate the entries again and delete those with cleared keys, after
       allocating the new table but before calling Rehash() to copy data
       into that new table. This means we can't directly use
       HashTable::EnsureCapacity, which normally does both the allocation
       and the rehashing.
    2. Return a bogus hash code for entries whose keys contain cleared weak
       pointers. This is simple but risks poor distribution of data after
       rehashing.
    3. Implement custom rehashing which can avoid copying entries with
       cleared keys, rather than reusing the rehashing implementation from
       HashTable.
    4. Include the hash value in every key, so a consistent hash value is
       available even after the weak Script pointer has been cleared.
    
    The fourth option sounds like the lowest risk to me, so this change
    implements that option.
    
    Bug: v8:12808
    Change-Id: I6b19b9c8af67dcfc31b74842ba581dd141e18845
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3654413Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
    Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
    Cr-Commit-Position: refs/heads/main@{#80637}
    2df4d58a
Name
Last commit
Last update
.github Loading commit data...
bazel Loading commit data...
build_overrides Loading commit data...
custom_deps Loading commit data...
docs Loading commit data...
gni 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...
.bazelrc Loading commit data...
.clang-format Loading commit data...
.clang-tidy Loading commit data...
.editorconfig Loading commit data...
.flake8 Loading commit data...
.git-blame-ignore-revs Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.mailmap Loading commit data...
.style.yapf Loading commit data...
.vpython Loading commit data...
.vpython3 Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.bazel Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
COMMON_OWNERS Loading commit data...
DEPS Loading commit data...
DIR_METADATA Loading commit data...
ENG_REVIEW_OWNERS Loading commit data...
INFRA_OWNERS Loading commit data...
INTL_OWNERS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LOONG_OWNERS Loading commit data...
MIPS_OWNERS Loading commit data...
OWNERS Loading commit data...
PPC_OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
RISCV_OWNERS Loading commit data...
S390_OWNERS Loading commit data...
WATCHLISTS Loading commit data...
WORKSPACE Loading commit data...
codereview.settings Loading commit data...