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 RUST_GET_PREV_STACK _rust_get_prev_stack
13 #define UPCALL_CALL_C _upcall_call_shim_on_c_stack
14 #define MORESTACK ___morestack
16 #define RUST_NEW_STACK2 rust_new_stack2
17 #define RUST_DEL_STACK rust_del_stack
18 #define RUST_DEL_STACK rust_del_stack
19 #define RUST_GET_PREV_STACK rust_get_prev_stack
20 #define UPCALL_CALL_C upcall_call_shim_on_c_stack
21 #define MORESTACK __morestack
24 // Naturally, nobody can agree as to
25 // which arguments should go in which
37 .globl RUST_NEW_STACK2
42 // FIXME: What about _WIN32?
43 #if defined(__linux__)
46 #if defined(__APPLE__)
47 .private_extern MORESTACK
52 .type MORESTACK,@function
59 # Set up a normal backtrace
61 .cfi_def_cfa_offset 16
64 .cfi_def_cfa_register %rbp
69 // FIXME: libgcc also saves rax. not sure if we need to
71 // Save argument registers
79 // Calculate the address of the stack arguments
81 addq $16, %rcx // Add the saved %rbp, and return address
82 addq %r11, %rcx // Add the size of stack arguments
84 pushq %rbp // Save the Rust stack pointer
85 pushq %r11 // Size of stack arguments
86 pushq %rcx // Address of stack arguments
87 pushq %r10 // The amount of stack needed
89 leaq RUST_NEW_STACK2@PLT(%rip), %rsi
91 call UPCALL_CALL_C@PLT
93 // Pop the new_stack_args struct
96 // Pop the saved arguments
104 movq 8(%rbp),%r10 // Grab the return pointer.
105 incq %r10 // Skip past the `ret` in our parent frame
106 movq %rax,%rsp // Switch to the new stack.
108 call *%r10 // Reenter the caller function
110 leaq RUST_GET_PREV_STACK@PLT(%rip), %rsi
112 call UPCALL_CALL_C@PLT
114 // Switch back to the rust stack, positioned
115 // where we pushed %ebp
118 // Align the stack again
121 leaq RUST_DEL_STACK@PLT(%rip), %rsi
123 call UPCALL_CALL_C@PLT