5 // LLVM generates a call to this to allocate more stack space in a functiono
6 // prolog when we run out.
8 #if defined(__APPLE__) || defined(_WIN32)
9 #define RUST_NEW_STACK2 _rust_new_stack2
10 #define RUST_DEL_STACK _rust_del_stack
11 #define RUST_DEL_STACK _rust_del_stack
12 #define UPCALL_CALL_C _upcall_call_shim_on_c_stack
13 #define MORESTACK ___morestack
15 #define RUST_NEW_STACK2 rust_new_stack2
16 #define RUST_DEL_STACK rust_del_stack
17 #define RUST_DEL_STACK rust_del_stack
18 #define UPCALL_CALL_C upcall_call_shim_on_c_stack
19 #define MORESTACK __morestack
22 // Naturally, nobody can agree as to
23 // which arguments should go in which
35 .globl RUST_NEW_STACK2
40 // FIXME: What about _WIN32?
41 #if defined(__linux__)
44 #if defined(__APPLE__)
45 .private_extern MORESTACK
50 .type MORESTACK,@function
53 #if defined(__linux__)
57 # Set up a normal backtrace
59 .cfi_def_cfa_offset 16
62 .cfi_def_cfa_register %rbp
64 // FIXME: libgcc also saves rax. not sure if we need to
66 // Save argument registers
74 // Calculate the address of the stack arguments.
75 // We have the base pointer, __morestack's return address,
76 // and __morestack's caller's return address to skip
78 addq $24, %rcx // Base pointer, return address x2
80 pushq %r11 // Size of stack arguments
81 pushq %rcx // Address of stack arguments
82 pushq %r10 // The amount of stack needed
84 leaq RUST_NEW_STACK2@PLT(%rip), %rsi
86 call UPCALL_CALL_C@PLT
88 // Pop the new_stack_args struct
91 // Pop the saved arguments
99 movq 8(%rbp),%r10 // Grab the return pointer.
100 incq %r10 // Skip past the `ret` in our parent frame
101 movq %rax,%rsp // Switch to the new stack.
103 call *%r10 // Reenter the caller function
105 // Switch back to the rust stack
108 // Align the stack again
111 leaq RUST_DEL_STACK@PLT(%rip), %rsi
113 call UPCALL_CALL_C@PLT