about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-09-26 15:06:26 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-09-26 16:59:15 -0700
commitad19ab4c6fdf3ea74ac0ff3688d040a852f30760 (patch)
treea4f501f24bc3867388b3d6aac3af5120d39c0205 /src/rt
parent47e5ab093a89fbe240e67be6a59c901f32d5ce4f (diff)
rt: Make the logic that moves environments between tasks update the GC alloc chain correctly
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_builtin.cpp4
-rw-r--r--src/rt/rust_cc.cpp14
-rw-r--r--src/rt/rust_task.cpp31
-rw-r--r--src/rt/rust_task.h5
4 files changed, 48 insertions, 6 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 3d89aa918ce..7226171e9f1 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -456,8 +456,8 @@ 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);
+        const type_desc *tydesc = task->release_alloc(alloc);
+        target->claim_alloc(alloc, tydesc);
         target->deref();
     }
     else {
diff --git a/src/rt/rust_cc.cpp b/src/rt/rust_cc.cpp
index 9d6c4992b17..c53ec1aa51c 100644
--- a/src/rt/rust_cc.cpp
+++ b/src/rt/rust_cc.cpp
@@ -178,16 +178,22 @@ irc::compute_ircs(rust_task *task, irc_map &ircs) {
         shape::arena arena;
         shape::type_param *params =
             shape::type_param::from_tydesc_and_data(tydesc, p, arena);
-        irc irc(task, true, tydesc->shape, params, tydesc->shape_tables,
-                p + sizeof(uintptr_t), ircs);
-        irc.walk();
 
 #if 0
+        shape::print print(task, true, tydesc->shape, params,
+                           tydesc->shape_tables);
+        print.walk();
+
         shape::log log(task, true, tydesc->shape, params,
-                       tydesc->shape_tables, p, std::cerr);
+                       tydesc->shape_tables, p + sizeof(uintptr_t),
+                       std::cerr);
         log.walk();
 #endif
 
+        irc irc(task, true, tydesc->shape, params, tydesc->shape_tables,
+                p + sizeof(uintptr_t), ircs);
+        irc.walk();
+
         ++begin;
     }
 }
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index ca85411e9d5..f2c866263cf 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -152,6 +152,8 @@ void task_start_wrapper(spawn_args *a)
         failed = true;
     }
 
+    cc::do_cc(task);
+
     rust_closure_env* env = (rust_closure_env*)a->a3;
     if(env) {
         // free the environment.
@@ -551,6 +553,35 @@ rust_chan *rust_task::get_chan_by_handle(chan_handle *handle) {
     return NULL;
 }
 
+// Temporary routine to allow boxes on one task's shared heap to be reparented
+// to another.
+const type_desc *
+rust_task::release_alloc(void *alloc) {
+    lock.lock();
+
+    assert(local_allocs.find(alloc) != local_allocs.end());
+    const type_desc *tydesc = local_allocs[alloc];
+    local_allocs.erase(alloc);
+
+    local_region.release_alloc(alloc);
+
+    lock.unlock();
+    return tydesc;
+}
+
+// Temporary routine to allow boxes from one task's shared heap to be
+// reparented to this one.
+void
+rust_task::claim_alloc(void *alloc, const type_desc *tydesc) {
+    lock.lock();
+
+    assert(local_allocs.find(alloc) == local_allocs.end());
+    local_allocs[alloc] = tydesc;
+    local_region.claim_alloc(alloc);
+
+    lock.unlock();
+}
+
 //
 // Local Variables:
 // mode: C++
diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h
index 76b828af58f..f364d2a67f7 100644
--- a/src/rt/rust_task.h
+++ b/src/rt/rust_task.h
@@ -204,6 +204,11 @@ rust_task : public kernel_owned<rust_task>, rust_cond
     intptr_t get_ref_count() const { return ref_count; }
 
     rust_chan *get_chan_by_handle(chan_handle *handle);
+
+    // FIXME: These functions only exist to get the tasking system off the
+    // ground. We should never be migrating shared boxes between tasks.
+    const type_desc *release_alloc(void *alloc);
+    void claim_alloc(void *alloc, const type_desc *tydesc);
 };
 
 //