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
39 .type MORESTACK,@function
45 # Set up a normal backtrace
47 .cfi_def_cfa_offset 16
50 .cfi_def_cfa_register %rbp
52 // Save argument registers
60 // Calculate the address of the stack arguments
62 addq $16, %rcx // Add the saved %rbp, and return address
63 addq %r11, %rcx // Add the size of stack arguments
65 pushq %r10 // The amount of stack needed
66 pushq %rcx // Address of stack arguments
67 pushq %r11 // Size of stack arguments
68 pushq %rbp // Save the Rust stack pointer
70 // FIXME: Don't understand why I have to use the PLT here
71 lea RUST_NEW_STACK2@PLT(%rip), %rsi
73 call UPCALL_CALL_C@PLT
75 mov (%rsp),%rdx // Grab the return pointer.
76 inc %rdx // Skip past the `ret`.
77 mov %rax,%rsp // Switch to the new stack.
78 call *%rdx // Enter the new function.