File tree Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 2bfa72ea42493c3337737cd35c5cd366502031c3
2
+ refs/heads/master: 0982c7f78c26766e8b13a8dea700b03d86f376f3
Original file line number Diff line number Diff line change
1
+ .text
2
+
3
+ // __morestack
4
+ //
5
+ // LLVM generates a call to this to allocate more stack space in a functiono
6
+ // prolog when we run out.
7
+
8
+ #if defined(__APPLE__) || defined(_WIN32)
9
+ #define RUST_NEW_STACK _rust_new_stack
10
+ #define RUST_DEL_STACK _rust_del_stack
11
+ #else
12
+ #define RUST_NEW_STACK rust_new_stack
13
+ #define RUST_DEL_STACK rust_del_stack
14
+ #endif
15
+
16
+ // Naturally, nobody can agree as to
17
+ // which arguments should go in which
18
+ // registers:
19
+ #if defined(_WIN32)
20
+ # define ARG0 %rcx
21
+ # define ARG1 %rdx
22
+ # define ARG2 %r8
23
+ #else
24
+ # define ARG0 %rdi
25
+ # define ARG1 %rsi
26
+ # define ARG2 %rdx
27
+ #endif
28
+
29
+ .globl RUST_NEW_STACK
30
+ .globl RUST_DEL_STACK
31
+
32
+ .globl __morestack
33
+
34
+ __morestack:
35
+ // Hastily and probably incorrectly ported from i386 version.
36
+ // Actually this calling convention doens't make so much sense
37
+ // for x86_64...
38
+ mov %rcx , ARG0 // param 0: amount of space needed
39
+ mov %rdx , ARG2 // param 2: size of arguments
40
+ lea 8 (%rsp ),ARG1
41
+ call RUST_NEW_STACK
42
+
43
+ mov (%rsp ),%rdx // Grab the return pointer.
44
+ inc %rdx // Skip past the `ret`.
45
+ mov %rax ,%rsp // Switch to the new stack.
46
+ call *%rdx // Enter the new function.
47
+
48
+ // Now the function that called us has returned, so we need to delete the
49
+ // old stack space.
50
+ call RUST_DEL_STACK
51
+ mov %rax ,%rsp // Switch back to the old stack.
52
+ ret
You can’t perform that action at this time.
0 commit comments