1
- .text
1
+ #include "regs.h"
2
+
3
+ #define ARG0 RUSTRT_ARG0_S
4
+ #define ARG1 RUSTRT_ARG1_S
5
+
6
+ .text
2
7
3
8
// upcall_call_c_stack(void (*fn)(), void *new_esp)
4
9
//
@@ -21,8 +26,32 @@ upcall_call_c_stack_float:
21
26
#endif
22
27
push %rbp
23
28
mov %rsp ,%rbp // save rsp
24
- mov %rsi ,%rsp // switch stack
25
- call *%rdi
29
+ mov ARG1,%rsp // switch stack
30
+
31
+ // Hack: the arguments to the function are sitting
32
+ // on the stack right now, as in i386 calling
33
+ // convention. We need them in registers.
34
+ // For now, we just load them into registers.
35
+ //
36
+ // This is a total hack because it does not consider
37
+ // the actual arguments of the target function.
38
+ // It fails if there are non-INTEGER class arguments,
39
+ // which would get pushed on the stack, or if there are
40
+ // additional arguments beyond those that will get
41
+ // passed in registers.
42
+ mov ARG0,%r11 // Remember target address
43
+ mov 0 (%rsp ),RUSTRT_ARG0_S
44
+ mov 8 (%rsp ),RUSTRT_ARG1_S
45
+ mov 16 (%rsp ),RUSTRT_ARG2_S
46
+ mov 24 (%rsp ),RUSTRT_ARG3_S
47
+ # ifdef RUSTRT_ARG4_S
48
+ mov 32 (%rsp ),RUSTRT_ARG4_S
49
+ # endif
50
+ # ifdef RUSTRT_ARG5_S
51
+ mov 40 (%rsp ),RUSTRT_ARG5_S
52
+ # endif
53
+
54
+ call *%r11
26
55
mov %rbp ,%rsp // would like to use "leave" but it's slower
27
56
pop %rbp
28
57
ret
0 commit comments