about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-09-06 14:03:20 -0700
committerBrian Anderson <banderson@mozilla.com>2011-09-07 10:32:58 -0700
commit25ae3d655cef63041d405a45f4797d21f8904502 (patch)
tree6a6dc9c15050df636670e36709a1a3ed7f2a8759 /src/rt/rust_builtin.cpp
parent1bd627039ed6979c59d25aee67548091522c6ff9 (diff)
downloadrust-25ae3d655cef63041d405a45f4797d21f8904502.tar.gz
rust-25ae3d655cef63041d405a45f4797d21f8904502.zip
Rewrite spawn yet again
The motivation here is that the bottom of each stack needs to contain a C++
try/catch block so that we can unwind. This is already the case for main, but
not spawned tasks.

Issue #236
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index f8fc85a0fe1..7614269a122 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -440,18 +440,24 @@ get_task_pointer(rust_task *task, rust_task_id id) {
     return task->kernel->get_task_by_id(id);
 }
 
-extern "C" CDECL void
-start_task(rust_task *task, rust_task_id id) {
-    rust_task * target = task->kernel->get_task_by_id(id);
-    target->start();
-    target->deref();
+// FIXME: Transitional. Remove
+extern "C" CDECL void **
+get_task_trampoline(rust_task *task) {
+    return NULL;
 }
 
-extern "C" void *task_trampoline asm("task_trampoline");
+struct fn_env_pair {
+    intptr_t f;
+    intptr_t env;
+};
+
+extern "C" CDECL uintptr_t get_spawn_wrapper();
 
-extern "C" CDECL void **
-get_task_trampoline(rust_task *task) {
-    return &task_trampoline;
+extern "C" CDECL void
+start_task(rust_task *task, rust_task_id id, fn_env_pair *f) {
+    rust_task *target = task->kernel->get_task_by_id(id);
+    target->start(get_spawn_wrapper(), f->f, f->env);
+    target->deref();
 }
 
 extern "C" CDECL void