• jgruber's avatar
    [builtins,x64] pc-relative builtin-to-builtin calls · e5630ea9
    jgruber authored
    This addresses one of the major remaining slowdowns with embedded
    builtins on x64.
    
    When generating code for a call to a builtin callee from a builtin
    caller, we'd look up the Code target object from the builtins constant
    list, calculate the location of the first instruction, and jump to it.
    Note that for embedded builtin callees, the Code object is itself only
    a trampoline to the off-heap code and thus an additional indirection.
    An example of the call sequence in pseudo-asm:
    
    // Load from the constants list.
    mov reg, [kRootPointer, kBuiltinsConstantListOffset]
    mov reg, [reg, offset_of_the_code_constant]
    // Calculate first instruction and call it.
    add reg, Code::kHeaderOffset
    call reg
    // The trampoline forwards to the off-heap area.
    mov kOffHeapTrampolineRegister, <off-heap instruction_start>
    jmp kOffHeapTrampolineRegister
    
    This CL changes calls to embedded builtin targets to use pc-relative
    addressing. This reduces the above instruction sequence to:
    
    call <pc-relative offset to target instruction_start>
    
    Embedded-to-embedded calls jump directly to the embedded instruction
    stream, bypassing the trampoline. Heap-to-embedded calls (and all
    calls to heap-builtins) use pc-relative addressing targeting the
    on-heap Code object.
    
    Other relevant platforms (arm,arm64,mips,mips64) do not use pc-relative
    calls. For these, we'll need a different solution, e.g. a table of
    embedded builtin addresses reachable from the root pointer, similar to
    the external reference table.
    
    Bug: v8:6666
    Change-Id: Ic0317d454e2da37d74eaecebcdfcbc0d5f5041ad
    Reviewed-on: https://chromium-review.googlesource.com/1068732
    Commit-Queue: Jakob Gruber <jgruber@chromium.org>
    Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#53349}
    e5630ea9
constants-table-builder.cc 4.03 KB