about summary refs log tree commit diff
path: root/src/rt/rust_task.h
diff options
context:
space:
mode:
authorBen Blum <bblum@andrew.cmu.edu>2012-06-27 13:07:00 -0400
committerBen Blum <bblum@andrew.cmu.edu>2012-06-28 00:10:03 -0400
commit1ba3028d8b7acb0c97859ea438f2beb4ccd364f9 (patch)
tree6fa4930844a1c0bd20f27b3347a1a905b81e4eaa /src/rt/rust_task.h
parente56ba156e223e24025a743247610283cca49b30a (diff)
downloadrust-1ba3028d8b7acb0c97859ea438f2beb4ccd364f9.tar.gz
rust-1ba3028d8b7acb0c97859ea438f2beb4ccd364f9.zip
rt: Add task_local_data and related builtin calls (Closes #2680)
Diffstat (limited to 'src/rt/rust_task.h')
-rw-r--r--src/rt/rust_task.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h
index e46b624c936..8e6a53892ec 100644
--- a/src/rt/rust_task.h
+++ b/src/rt/rust_task.h
@@ -163,6 +163,10 @@ rust_task : public kernel_owned<rust_task>, rust_cond
     // The amount of stack we're using, excluding red zones
     size_t total_stack_sz;
 
+    // Used by rust task management routines in libcore/task.rs.
+    void *task_local_data;
+    void (*task_local_data_cleanup)(void *data);
+
 private:
 
     // Protects state, cond, cond_name
@@ -375,6 +379,10 @@ rust_task::call_on_c_stack(void *args, void *fn_ptr) {
     // Too expensive to check
     // assert(on_rust_stack());
 
+    // The shim functions generated by rustc contain the morestack prologue, so
+    // we need to let them know they have enough stack.
+    record_sp_limit(0);
+
     uintptr_t prev_rust_sp = next_rust_sp;
     next_rust_sp = get_sp();
 
@@ -398,12 +406,19 @@ rust_task::call_on_c_stack(void *args, void *fn_ptr) {
     }
 
     next_rust_sp = prev_rust_sp;
+
+    record_stack_limit();
 }
 
 inline void
 rust_task::call_on_rust_stack(void *args, void *fn_ptr) {
     // Too expensive to check
     // assert(!on_rust_stack());
+
+    // Because of the hack in the other function that disables the stack limit
+    // when entering the C stack, here we restore the stack limit again.
+    record_stack_limit();
+
     assert(get_sp_limit() != 0 && "Stack must be configured");
     assert(next_rust_sp);
 
@@ -427,6 +442,8 @@ rust_task::call_on_rust_stack(void *args, void *fn_ptr) {
         scoped_lock with(kill_lock);
         reentered_rust_stack = had_reentered_rust_stack;
     }
+
+    record_sp_limit(0);
 }
 
 inline void