• 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
..
api Loading commit data...
asmjs Loading commit data...
ast Loading commit data...
base Loading commit data...
builtins Loading commit data...
codegen Loading commit data...
common Loading commit data...
compiler Loading commit data...
compiler-dispatcher Loading commit data...
d8 Loading commit data...
date Loading commit data...
debug Loading commit data...
deoptimizer Loading commit data...
diagnostics Loading commit data...
execution Loading commit data...
extensions Loading commit data...
flags Loading commit data...
handles Loading commit data...
heap Loading commit data...
ic Loading commit data...
init Loading commit data...
inspector Loading commit data...
interpreter Loading commit data...
json Loading commit data...
libplatform Loading commit data...
libsampler Loading commit data...
logging Loading commit data...
numbers Loading commit data...
objects Loading commit data...
parsing Loading commit data...
profiler Loading commit data...
protobuf Loading commit data...
regexp Loading commit data...
roots Loading commit data...
runtime Loading commit data...
sanitizer Loading commit data...
snapshot Loading commit data...
strings Loading commit data...
tasks Loading commit data...
third_party Loading commit data...
torque Loading commit data...
tracing Loading commit data...
trap-handler Loading commit data...
utils Loading commit data...
wasm Loading commit data...
zone Loading commit data...
DEPS Loading commit data...
OWNERS Loading commit data...