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 UPCALL_CALL_C _upcall_call_shim_on_c_stack
12 #define MORESTACK ___morestack
14 #define RUST_NEW_STACK2 rust_new_stack2
15 #define RUST_DEL_STACK rust_del_stack
16 #define UPCALL_CALL_C upcall_call_shim_on_c_stack
17 #define MORESTACK __morestack
20 // Naturally, nobody can agree as to
21 // which arguments should go in which
33 .globl RUST_NEW_STACK2
38 // FIXME: What about _WIN32?
39 #if defined(__linux__)
42 #if defined(__APPLE__)
43 .private_extern MORESTACK
48 .type MORESTACK,@function
54 # Set up a normal backtrace
56 .cfi_def_cfa_offset 16
59 .cfi_def_cfa_register %rbp
61 // Save argument registers
69 // Calculate the address of the stack arguments
71 addq $16, %rcx // Add the saved %rbp, and return address
72 addq %r11, %rcx // Add the size of stack arguments
74 pushq %r10 // The amount of stack needed
75 pushq %rcx // Address of stack arguments
76 pushq %r11 // Size of stack arguments
77 pushq %rbp // Save the Rust stack pointer
79 // FIXME: Don't understand why I have to use the PLT here
80 lea RUST_NEW_STACK2@PLT(%rip), %rsi
82 call UPCALL_CALL_C@PLT
84 mov (%rsp),%rdx // Grab the return pointer.
85 inc %rdx // Skip past the `ret`.
86 mov %rax,%rsp // Switch to the new stack.
87 call *%rdx // Enter the new function.