rt: Make the logic that moves environments between tasks update the GC alloc chain correctly
This commit is contained in:
parent
47e5ab093a
commit
ad19ab4c6f
4 changed files with 50 additions and 8 deletions
|
@ -456,8 +456,8 @@ migrate_alloc(rust_task *task, void *alloc, rust_task_id tid) {
|
||||||
if(!alloc) return;
|
if(!alloc) return;
|
||||||
rust_task *target = task->kernel->get_task_by_id(tid);
|
rust_task *target = task->kernel->get_task_by_id(tid);
|
||||||
if(target) {
|
if(target) {
|
||||||
task->local_region.release_alloc(alloc);
|
const type_desc *tydesc = task->release_alloc(alloc);
|
||||||
target->local_region.claim_alloc(alloc);
|
target->claim_alloc(alloc, tydesc);
|
||||||
target->deref();
|
target->deref();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -178,16 +178,22 @@ irc::compute_ircs(rust_task *task, irc_map &ircs) {
|
||||||
shape::arena arena;
|
shape::arena arena;
|
||||||
shape::type_param *params =
|
shape::type_param *params =
|
||||||
shape::type_param::from_tydesc_and_data(tydesc, p, arena);
|
shape::type_param::from_tydesc_and_data(tydesc, p, arena);
|
||||||
|
|
||||||
|
#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 + sizeof(uintptr_t),
|
||||||
|
std::cerr);
|
||||||
|
log.walk();
|
||||||
|
#endif
|
||||||
|
|
||||||
irc irc(task, true, tydesc->shape, params, tydesc->shape_tables,
|
irc irc(task, true, tydesc->shape, params, tydesc->shape_tables,
|
||||||
p + sizeof(uintptr_t), ircs);
|
p + sizeof(uintptr_t), ircs);
|
||||||
irc.walk();
|
irc.walk();
|
||||||
|
|
||||||
#if 0
|
|
||||||
shape::log log(task, true, tydesc->shape, params,
|
|
||||||
tydesc->shape_tables, p, std::cerr);
|
|
||||||
log.walk();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
++begin;
|
++begin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,6 +152,8 @@ void task_start_wrapper(spawn_args *a)
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc::do_cc(task);
|
||||||
|
|
||||||
rust_closure_env* env = (rust_closure_env*)a->a3;
|
rust_closure_env* env = (rust_closure_env*)a->a3;
|
||||||
if(env) {
|
if(env) {
|
||||||
// free the environment.
|
// free the environment.
|
||||||
|
@ -551,6 +553,35 @@ rust_chan *rust_task::get_chan_by_handle(chan_handle *handle) {
|
||||||
return NULL;
|
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:
|
// Local Variables:
|
||||||
// mode: C++
|
// mode: C++
|
||||||
|
|
|
@ -204,6 +204,11 @@ rust_task : public kernel_owned<rust_task>, rust_cond
|
||||||
intptr_t get_ref_count() const { return ref_count; }
|
intptr_t get_ref_count() const { return ref_count; }
|
||||||
|
|
||||||
rust_chan *get_chan_by_handle(chan_handle *handle);
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue