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-20 10:29:40 -0800
committerBrian Anderson <banderson@mozilla.com>2011-12-20 10:29:40 -0800
commit56ec9cb2789a7ece225cf224a2713618e2078172 (patch)
tree0e1d41f71642779aed5ad87965f9bb7f0472b781 /src/rt/rust_task.cpp
parent28b825d8469c5b6f92f367cb4aae2ea2607bc886 (diff)
downloadrust-56ec9cb2789a7ece225cf224a2713618e2078172.tar.gz
rust-56ec9cb2789a7ece225cf224a2713618e2078172.zip
rt: Run yet more task_start_wrapper cleanup on the C stack
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp50
1 files changed, 33 insertions, 17 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 70f3ce41796..23bd6647a04 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -268,25 +268,18 @@ struct rust_closure_env {
     type_desc *td;
 };
 
-// This runs on the Rust stack
-extern "C" CDECL
-void task_start_wrapper(spawn_args *a)
-{
-    rust_task *task = a->task;
-    int rval = 42;
+struct cleanup_args {
+    spawn_args *spargs;
+    bool failed;
+};
 
-    bool failed = false;
-    try {
-        a->f(&rval, a->a3, a->a4);
-    } catch (rust_task *ex) {
-        A(task->sched, ex == task,
-          "Expected this task to be thrown for unwinding");
-        failed = true;
-    }
+void
+cleanup_task(cleanup_args *args) {
+    spawn_args *a = args->spargs;
+    bool failed = args->failed;
+    rust_task *task = a->task;
 
-    // We're on the Rust stack and the cycle collector may recurse arbitrarily
-    // deep, so switch to the C stack
-    task->sched->c_context.call_shim_on_c_stack(task, (void*)cc::do_cc);
+    cc::do_cc(task);
 
     rust_closure_env* env = (rust_closure_env*)a->a3;
     if(env) {
@@ -313,6 +306,29 @@ void task_start_wrapper(spawn_args *a)
         A(task->sched, false, "Shouldn't happen");
 #endif
     }
+}
+
+// This runs on the Rust stack
+extern "C" CDECL
+void task_start_wrapper(spawn_args *a)
+{
+    rust_task *task = a->task;
+    int rval = 42;
+
+    bool failed = false;
+    try {
+        a->f(&rval, a->a3, a->a4);
+    } catch (rust_task *ex) {
+        A(task->sched, ex == task,
+          "Expected this task to be thrown for unwinding");
+        failed = true;
+    }
+
+    cleanup_args ca = {a, failed};
+
+    // The cleanup work needs lots of stack
+    task->sched->c_context.call_shim_on_c_stack(&ca, (void*)cleanup_task);
+
     task->ctx.next->swap(task->ctx);
 }