Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized unresolved static/special glue on X86-64 #4249

Merged
merged 1 commit into from
Jan 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions runtime/compiler/x/runtime/X86Unresolveds.nasm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; Copyright (c) 2000, 2018 IBM Corp. and others
; Copyright (c) 2000, 2019 IBM Corp. and others
;
; This program and the accompanying materials are made available under
; the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -1241,29 +1241,26 @@ interpreterUnresolvedStaticGlue:
;
mov rax, qword [rsp] ; p1) rax = RA in mainline code
mov rsi, qword [rdi+12] ; p2) rsi = cpAddr
; 12 = 5 + 5 (call update) + 2 (DW)
; 12 = 5 + 5 (call update) + 2 (DW)
mov edx, dword [rdi+20] ; p3) rdx = cpIndex
; 20 = 5 + 5 (call update) + 2 (DW) + 8 (cpAddr)
CallHelperUseReg jitResolveStaticMethod,rax
; 20 = 5 + 5 (call update) + 2 (DW) + 8 (cpAddr)
call jitResolveStaticMethod
lea rsi, [rdi+5] ; Adjust the return address to "call updateInterpreterDispatchGlueSite"
push rsi ; The RET will mispredict anyway so we can get away with pushing
; the adjusted RA back on the stack.

; The interpreter may low-tag the result to avoid populating the constant pool--whack it.
;
and rax, -2

mergeInterpreterUnresolvedDispatch:
; Load the resolved RAM method into RDI so that the caller doesn't have to re-run patched code
mov rdi, rax

; Patch the call that brought us here into a load of the resolved RAM method into RDI.
;
lea rdi, [rdi-5] ; Adjust the return address to re-run the patched
push rdi ; instruction. The RET will mispredict anyway so we
; can get away with pushing the adjusted RA back on
; the stack.
rol rax, 16
mov ax, 0bf48h ; REX+MOV bytes

mov qword [rdi], rax
ret

shl rax, 16
xor rax, 0bf48h ; REX+MOV bytes
mov qword [rsi-10], rax
ret


Expand All @@ -1275,12 +1272,22 @@ interpreterUnresolvedSpecialGlue:
;
mov rax, qword [rsp] ; p1) rax = RA in mainline code
mov rsi, qword [rdi+12] ; p2) rsi = cpAddr
; 12 = 5 + 5 (call update) + 2 (DW)
; 12 = 5 + 5 (call update) + 2 (DW)
mov edx, dword [rdi+20] ; p3) rdx = cpIndex
; 20 = 5 + 5 (call update) + 2 (DW) + 8 (cpAddr)
CallHelperUseReg jitResolveSpecialMethod,rax
jmp mergeInterpreterUnresolvedDispatch
; 20 = 5 + 5 (call update) + 2 (DW) + 8 (cpAddr)
call jitResolveSpecialMethod
lea rsi, [rdi+5] ; Adjust the return address to "call updateInterpreterDispatchGlueSite"
push rsi ; The RET will mispredict anyway so we can get away with pushing
; the adjusted RA back on the stack.

; Load the resolved RAM method into RDI so that the caller doesn't have to re-run patched code
mov rdi, rax

; Patch the call that brought us here into a load of the resolved RAM method into RDI.
;
shl rax, 16
xor rax, 0bf48h ; REX+MOV bytes
mov qword [rsi-10], rax
ret


Expand Down