• Jakob Gruber's avatar
    [compiler] Widen optimization for external reference loads · 33e1a6e9
    Jakob Gruber authored
    Turbofan applies the following optimization to external reference
    loads on arm64 and x64: if the root-relative offset to an external
    reference's address is known to be constant (and the root register has
    been initialized), calculate the external reference as |kRootRegister
    + <offset>| instead of loading it from the external reference table.
    
    There are two main cases to consider:
    
    1. External references to arbitrary addresses in the native address
    space, e.g. libc_memcpy. These kinds of external references have a
    fixed address within the same running process, but may (and likely
    will) change between processes (e.g.: mksnapshot and later chromium),
    and the root-relative offset is different for each Isolate within the
    same process.
    
    These kinds of external references can be optimized as above when
    *not* generating code which will later be serialized, and *not*
    generating isolate-independent code.
    
    2. External references to addresses within the fixed-size region of
    the Isolate (essentially: within IsolateData). Since these move with
    the Isolate, their root-relative offset is guaranteed to be constant
    at all times.
    
    The optimization can always be applied to these cases as long as the
    root register has been initialized.
    
    Prior to this CL, we only recognized and optimized for case 1. This CL
    additionally adds support for 2.
    
    An example of improved code generated due to this CL:
    
    Before:
    // r13 is the kRootRegister on x64.
    // 0x3010 is the root-relative offset to Isolate::context_address.
    leaq rdx, [r13+0x3010]
    movq r8, [rdx]
    
    After:
    movq rdx, [r13+0x3010]
    
    Bug: v8:9534
    Change-Id: Idfcca751e98a56c0e5ead2c701c12a677df75399
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1748727
    Commit-Queue: Jakob Gruber <jgruber@chromium.org>
    Auto-Submit: Jakob Gruber <jgruber@chromium.org>
    Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#63158}
    33e1a6e9
Name
Last commit
Last update
benchmarks 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...
.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...
.vpython 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...
COMMON_OWNERS Loading commit data...
ChangeLog Loading commit data...
DEPS 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...
LICENSE.valgrind 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...
S390_OWNERS Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...