From 31166438063236e6d2ad021cf2169fce2b3839b4 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 1 Feb 2012 18:50:19 -0800 Subject: Revert "make boxes self-describing (fixes #1493)" until a new snapshot is prepared. --- src/rt/rust_task.cpp | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) (limited to 'src/rt/rust_task.cpp') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 4acef16a209..86dfb3b666f 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -14,7 +14,6 @@ #include #include "globals.h" -#include "rust_upcall.h" // The amount of extra space at the end of each stack segment, available // to the rt, compiler and dynamic linker for running small functions @@ -247,7 +246,6 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state, running_on(-1), pinned_on(-1), local_region(&sched->srv->local_region), - boxed(&local_region), unwinding(false), killed(false), propagate_failure(true), @@ -297,7 +295,7 @@ rust_task::~rust_task() struct spawn_args { rust_task *task; spawn_fn f; - rust_opaque_box *envptr; + rust_opaque_closure *envptr; void *argptr; }; @@ -332,6 +330,8 @@ cleanup_task(cleanup_args *args) { } } +extern "C" void upcall_shared_free(void* ptr); + // This runs on the Rust stack extern "C" CDECL void task_start_wrapper(spawn_args *a) @@ -349,13 +349,12 @@ void task_start_wrapper(spawn_args *a) threw_exception = true; } - rust_opaque_box* env = a->envptr; + rust_opaque_closure* env = a->envptr; if(env) { - // free the environment (which should be a unique closure). + // free the environment. const type_desc *td = env->td; LOG(task, task, "Freeing env %p with td %p", env, td); - td->drop_glue(NULL, NULL, td->first_param, box_body(env)); - upcall_free_shared_type_desc(env->td); + td->drop_glue(NULL, NULL, td->first_param, env); upcall_shared_free(env); } @@ -368,7 +367,7 @@ void task_start_wrapper(spawn_args *a) void rust_task::start(spawn_fn spawnee_fn, - rust_opaque_box *envptr, + rust_opaque_closure *envptr, void *argptr) { LOG(this, task, "starting task from fn 0x%" PRIxPTR @@ -679,6 +678,38 @@ rust_port *rust_task::get_port_by_id(rust_port_id id) { return port; } + +// 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) { + I(sched, !lock.lock_held_by_current_thread()); + 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) { + I(sched, !lock.lock_held_by_current_thread()); + lock.lock(); + + assert(local_allocs.find(alloc) == local_allocs.end()); + local_allocs[alloc] = tydesc; + local_region.claim_alloc(alloc); + + lock.unlock(); +} + void rust_task::notify(bool success) { // FIXME (1078) Do this in rust code -- cgit 1.4.1-3-g733a5