about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-02-14 11:58:27 -0800
committerBrian Anderson <banderson@mozilla.com>2012-02-14 13:51:15 -0800
commita53a08e1b980e5cf5f9707ef1d1f27b89ff7ed99 (patch)
tree800bacf4c4d90d28f2b0cabee538115255508bdb /src/rt
parent44d4889bc24a09259cf8a7fbf89ded78ab1e64bc (diff)
downloadrust-a53a08e1b980e5cf5f9707ef1d1f27b89ff7ed99.tar.gz
rust-a53a08e1b980e5cf5f9707ef1d1f27b89ff7ed99.zip
rt: Don't allocate a C stack for tasks that already have one
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_task.h1
-rw-r--r--src/rt/rust_task_thread.cpp6
-rw-r--r--src/rt/rust_task_thread.h2
3 files changed, 5 insertions, 4 deletions
diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h
index 0a1b02037a2..7594e677bb0 100644
--- a/src/rt/rust_task.h
+++ b/src/rt/rust_task.h
@@ -205,6 +205,7 @@ public:
 
     void call_on_c_stack(void *args, void *fn_ptr);
     void call_on_rust_stack(void *args, void *fn_ptr);
+    bool have_c_stack() { return c_stack != NULL; }
 };
 
 // This stuff is on the stack-switching fast path
diff --git a/src/rt/rust_task_thread.cpp b/src/rt/rust_task_thread.cpp
index fbcd164707f..dde16ad70bd 100644
--- a/src/rt/rust_task_thread.cpp
+++ b/src/rt/rust_task_thread.cpp
@@ -70,7 +70,7 @@ rust_task_thread::activate(rust_task *task) {
     task->ctx.next = &c_context;
     DLOG(this, task, "descheduling...");
     lock.unlock();
-    prepare_c_stack();
+    prepare_c_stack(task);
     task->ctx.swap(c_context);
     unprepare_c_stack();
     lock.lock();
@@ -367,9 +367,9 @@ rust_task_thread::exit() {
 // stack), because once we're on the Rust stack we won't have enough
 // room to do the allocation
 void
-rust_task_thread::prepare_c_stack() {
+rust_task_thread::prepare_c_stack(rust_task *task) {
     I(this, !extra_c_stack);
-    if (!cached_c_stack) {
+    if (!cached_c_stack && !task->have_c_stack()) {
         cached_c_stack = create_stack(kernel, C_STACK_SIZE);
         prepare_valgrind_stack(cached_c_stack);
     }
diff --git a/src/rt/rust_task_thread.h b/src/rt/rust_task_thread.h
index b1a56dfa68c..58ae8aa12f5 100644
--- a/src/rt/rust_task_thread.h
+++ b/src/rt/rust_task_thread.h
@@ -98,7 +98,7 @@ private:
     stk_seg *cached_c_stack;
     stk_seg *extra_c_stack;
 
-    void prepare_c_stack();
+    void prepare_c_stack(rust_task *task);
     void unprepare_c_stack();
 
 public: