summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-08-12 16:36:17 -0700
committerEric Holk <eholk@mozilla.com>2011-08-15 09:26:51 -0700
commitb9f1f77622c7a52b0eba39eb05c7841f5407f938 (patch)
tree685923e8a2fa4e2796a54280a878b540b0ab169e /src/rt/rust_builtin.cpp
parent2f23405a6079745663b9a4462410aa509f281aa1 (diff)
downloadrust-b9f1f77622c7a52b0eba39eb05c7841f5407f938.tar.gz
rust-b9f1f77622c7a52b0eba39eb05c7841f5407f938.zip
Fixed memory accounting and task stack creation bugs.
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index d330fbff590..77a4e8d2b09 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -289,7 +289,7 @@ task_yield(rust_task *task) {
 extern "C" CDECL intptr_t
 task_join(rust_task *task, rust_task_id tid) {
     // If the other task is already dying, we don't have to wait for it.
-    smart_ptr<rust_task> join_task = task->kernel->get_task_by_id(tid);
+    rust_task *join_task = task->kernel->get_task_by_id(tid);
     // FIXME: find task exit status and return that.
     if(!join_task) return 0;
     join_task->lock.lock();
@@ -720,10 +720,11 @@ new_task(rust_task *task) {
 
 extern "C" CDECL registers_t *
 get_task_context(rust_task *task, rust_task_id id) {
-    registers_t *regs = &task->kernel->get_task_by_id(id)->ctx.regs;
+    rust_task *target = task->kernel->get_task_by_id(id);
+    registers_t *regs = &target->ctx.regs;
     // This next line is a little dangerous.. It means we can only safely call
     // this when starting a task.
-    regs->esp = task->rust_sp;
+    regs->esp = target->rust_sp;
     return regs;
 }
 
@@ -746,6 +747,20 @@ get_task_trampoline(rust_task *task) {
     return &task_trampoline;
 }
 
+extern "C" CDECL void
+migrate_alloc(rust_task *task, void *alloc, rust_task_id tid) {
+    if(!alloc) return;
+    rust_task *target = task->kernel->get_task_by_id(tid);
+    if(target) {
+        task->local_region.release_alloc(alloc);
+        target->local_region.claim_alloc(alloc);
+    }
+    else {
+        // We couldn't find the target. Maybe we should just free?
+        task->fail();
+    }
+}
+
 extern "C" CDECL rust_chan *
 clone_chan(rust_task *task, rust_chan *chan) {
     return chan->clone(task);