about summary refs log tree commit diff
path: root/src/rt/arch
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-10-31 13:31:04 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-10-31 14:20:56 -0700
commitc9003d301f602cb44d8cc3fd464c95b09e08548e (patch)
tree26b07c6d9da42436b7c2cfebbf08ad7404bb059e /src/rt/arch
parent799ba7b1226cda3cf167cbe1c7e8aaf2f78c82f9 (diff)
Stub a __morestack implementation and stack segment allocation. Untested.
Diffstat (limited to 'src/rt/arch')
-rw-r--r--src/rt/arch/i386/morestack.S38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S
new file mode 100644
index 00000000000..23492637fdb
--- /dev/null
+++ b/src/rt/arch/i386/morestack.S
@@ -0,0 +1,38 @@
+    .text
+
+// __morestack
+//
+// LLVM generates a call to this to allocate more stack space in a functiono
+// prolog when we run out.
+
+#if defined(__APPLE__) || defined(_WIN32)
+#define RUST_NEW_STACK      _rust_new_stack
+#define RUST_DEL_STACK      _rust_del_stack
+#else
+#define RUST_NEW_STACK      rust_new_stack
+#define RUST_DEL_STACK      rust_del_stack
+#endif
+
+.globl RUST_NEW_STACK
+.globl RUST_DEL_STACK
+
+.globl __morestack
+
+__morestack:
+    pushl %edx              // param 2: size of arguments
+    leal 8(%esp),%eax
+    pushl %eax              // param 1: starting addr of arguments
+    pushl %ecx              // param 0: amount of space needed
+    calll RUST_NEW_STACK
+
+    movl (%esp),%edx        // Grab the return pointer.
+    incl %edx               // Skip past the `ret`.
+    movl %eax,%esp          // Switch to the new stack.
+    calll *%edx             // Enter the new function.
+
+    // Now the function that called us has returned, so we need to delete the
+    // old stack space.
+    calll RUST_DEL_STACK
+    movl %eax,%esp          // Switch back to the old stack.
+    retl
+