about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-12-04 20:40:34 -0800
committerBrian Anderson <banderson@mozilla.com>2011-12-04 20:40:34 -0800
commit52d7dc5e0a218f1495da2057ac064811853a4c9c (patch)
treefb814a8fa135a66f49957813ab3b279aa5c6a4c6 /src/rt/rust_task.cpp
parenta69eab16ec3435bd505a7dafcb9a82b5eace49a2 (diff)
downloadrust-52d7dc5e0a218f1495da2057ac064811853a4c9c.tar.gz
rust-52d7dc5e0a218f1495da2057ac064811853a4c9c.zip
rt: Update 32-bit __morestack for recent LLVM changes
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 965fc2a65c0..f0ab8c57c35 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -598,10 +598,17 @@ rust_task::del_stack() {
 
 void
 rust_task::record_stack_limit() {
-    // FIXME: Future LLVM patches expect us to add an additional 256 bytes
-    // here so that, if the frame size is < 256 it can generate the
-    // comparison against esp directly, instead of some offset from esp
-    record_sp(stk->data + RED_ZONE_SIZE);
+    // The function prolog compares the amount of stack needed to the end of
+    // the stack. As an optimization, when the frame size is less than 256
+    // bytes, it will simply compare %esp to to the stack limit instead of
+    // subtracting the frame size. As a result we need our stack limit to
+    // account for those 256 bytes.
+    const unsigned LIMIT_OFFSET = 256;
+    A(sched,
+      (uintptr_t)stk->limit - RED_ZONE_SIZE
+      - (uintptr_t)stk->data >= LIMIT_OFFSET,
+      "Stack size must be greater than LIMIT_OFFSET");
+    record_sp(stk->data + LIMIT_OFFSET + RED_ZONE_SIZE);
 }
 //
 // Local Variables: