Skip to content

Commit 59e2a0a

Browse files
committed
add shim upcall func
1 parent 4fc34e2 commit 59e2a0a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/rt/arch/x86_64/ccall.S

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,19 @@ upcall_call_c_stack_float:
5656
pop %rbp
5757
ret
5858

59+
#if defined(__APPLE__) || defined(_WIN32)
60+
.globl _upcall_call_c_stack_shim
61+
_upcall_call_c_stack_shim:
62+
#else
63+
.globl upcall_call_c_stack_shim
64+
upcall_call_c_stack_shim
65+
#endif
66+
push %rbp
67+
mov %rsp,%rbp // save rsp
68+
mov ARG1,%rsp // switch stack
69+
mov ARG0,%r11 // Remember target address
70+
mov ARG1,ARG0 // setup the parameter shim expects
71+
call *%r11
72+
mov %rbp,%rsp
73+
pop %rbp
74+
ret

0 commit comments

Comments
 (0)