Skip to content

Commit 61a55bc

Browse files
authored
Fix CFG helper calling convention and simplify flow of call target address. (#678)
1 parent aeb78bb commit 61a55bc

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

fast_fwd/arm64/thunks.asm

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
NESTED_ENTRY InvokeForwarder
1212

1313
; Save enregistered args
14-
PROLOG_SAVE_REG_PAIR fp, lr, #-64!
15-
PROLOG_SAVE_REG_PAIR x19, x20, #16
16-
PROLOG_NOP stp x0, x1, [sp, #32]
17-
PROLOG_NOP stp x2, x3, [sp, #48]
14+
PROLOG_SAVE_REG_PAIR fp, lr, #-48!
15+
PROLOG_NOP stp x0, x1, [sp, #16]
16+
PROLOG_NOP stp x2, x3, [sp, #32]
1817

1918
; Replace forwarder abi with owner abi
2019
ldr x1, [x0, #8]
@@ -26,23 +25,20 @@
2625

2726
; Get method address from owner abi vtable
2827
ldr x0, [x1]
29-
ldr x19, [x0, x12, lsl #3]
30-
mov x0, x19
28+
ldr x15, [x0, x12, lsl #3]
3129
3230
; Verify indirect call target
3331
adrp x12, __guard_check_icall_fptr
3432
ldr x12, [x12, __guard_check_icall_fptr]
3533
blr x12
3634

37-
; Restore method address, return address, and args
38-
mov x12, x19
39-
EPILOG_NOP ldp x2, x3, [sp, #48]
40-
EPILOG_NOP ldp x0, x1, [sp, #32]
41-
EPILOG_RESTORE_REG_PAIR x19, x20, #16
42-
EPILOG_RESTORE_REG_PAIR fp, lr, #64!
35+
; Restore return address, and args
36+
EPILOG_NOP ldp x2, x3, [sp, #32]
37+
EPILOG_NOP ldp x0, x1, [sp, #16]
38+
EPILOG_RESTORE_REG_PAIR fp, lr, #48!
4339

4440
; Jump to method
45-
EPILOG_NOP br x12
41+
EPILOG_NOP br x15
4642

4743
NESTED_END InvokeForwarder
4844

0 commit comments

Comments
 (0)