rt: Remove rustboot's GC infrastructure
This commit is contained in:
parent
8fa86672ab
commit
d0171913aa
@ -118,7 +118,7 @@ refcount(rust_task *task, type_desc *t, intptr_t *v) {
|
||||
|
||||
extern "C" CDECL void
|
||||
do_gc(rust_task *task) {
|
||||
task->gc();
|
||||
// TODO
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
|
@ -137,6 +137,7 @@ gc::mark(std::vector<root> &roots) {
|
||||
shape::log log(task, ri->tydesc->shape, params,
|
||||
ri->tydesc->shape_tables, ri->data, std::cerr);
|
||||
log.walk(true);
|
||||
DPRINT("\n");
|
||||
|
||||
++ri;
|
||||
}
|
||||
|
@ -258,14 +258,6 @@ rust_task::fail() {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
void
|
||||
rust_task::gc()
|
||||
{
|
||||
// FIXME: not presently implemented; was broken by rustc.
|
||||
DLOG(sched, task,
|
||||
"task %s @0x%" PRIxPTR " garbage collecting", name, this);
|
||||
}
|
||||
|
||||
void
|
||||
rust_task::unsupervise()
|
||||
{
|
||||
@ -320,99 +312,22 @@ rust_task::dead()
|
||||
return state == &sched->dead_tasks;
|
||||
}
|
||||
|
||||
void
|
||||
rust_task::link_gc(gc_alloc *gcm) {
|
||||
I(sched, gcm->prev == NULL);
|
||||
I(sched, gcm->next == NULL);
|
||||
gcm->prev = NULL;
|
||||
gcm->next = gc_alloc_chain;
|
||||
gc_alloc_chain = gcm;
|
||||
if (gcm->next)
|
||||
gcm->next->prev = gcm;
|
||||
}
|
||||
|
||||
void
|
||||
rust_task::unlink_gc(gc_alloc *gcm) {
|
||||
if (gcm->prev)
|
||||
gcm->prev->next = gcm->next;
|
||||
if (gcm->next)
|
||||
gcm->next->prev = gcm->prev;
|
||||
if (gc_alloc_chain == gcm)
|
||||
gc_alloc_chain = gcm->next;
|
||||
gcm->prev = NULL;
|
||||
gcm->next = NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
rust_task::malloc(size_t sz, const char *tag, type_desc *td)
|
||||
{
|
||||
// FIXME: GC is disabled for now.
|
||||
// GC-memory classification is all wrong.
|
||||
td = NULL;
|
||||
|
||||
if (td) {
|
||||
sz += sizeof(gc_alloc);
|
||||
}
|
||||
|
||||
void *mem = local_region.malloc(sz, tag);
|
||||
if (!mem)
|
||||
return mem;
|
||||
if (td) {
|
||||
gc_alloc *gcm = (gc_alloc*) mem;
|
||||
DLOG(sched, task, "task %s @0x%" PRIxPTR
|
||||
" allocated %d GC bytes = 0x%" PRIxPTR,
|
||||
name, (uintptr_t)this, sz, gcm);
|
||||
memset((void*) gcm, 0, sizeof(gc_alloc));
|
||||
link_gc(gcm);
|
||||
gcm->ctrl_word = (uintptr_t)td;
|
||||
gc_alloc_accum += sz;
|
||||
mem = (void*) &(gcm->data);
|
||||
}
|
||||
return mem;;
|
||||
return local_region.malloc(sz, tag);
|
||||
}
|
||||
|
||||
void *
|
||||
rust_task::realloc(void *data, size_t sz, bool is_gc)
|
||||
{
|
||||
// FIXME: GC is disabled for now.
|
||||
// Effects, GC-memory classification is all wrong.
|
||||
is_gc = false;
|
||||
if (is_gc) {
|
||||
gc_alloc *gcm = (gc_alloc*)(((char *)data) - sizeof(gc_alloc));
|
||||
unlink_gc(gcm);
|
||||
sz += sizeof(gc_alloc);
|
||||
gcm = (gc_alloc*) local_region.realloc((void*)gcm, sz);
|
||||
DLOG(sched, task, "task %s @0x%" PRIxPTR
|
||||
" reallocated %d GC bytes = 0x%" PRIxPTR,
|
||||
name, (uintptr_t)this, sz, gcm);
|
||||
if (!gcm)
|
||||
return gcm;
|
||||
link_gc(gcm);
|
||||
data = (void*) &(gcm->data);
|
||||
} else {
|
||||
data = local_region.realloc(data, sz);
|
||||
}
|
||||
return data;
|
||||
return local_region.realloc(data, sz);
|
||||
}
|
||||
|
||||
void
|
||||
rust_task::free(void *p, bool is_gc)
|
||||
{
|
||||
// FIXME: GC is disabled for now.
|
||||
// GC-memory classification is all wrong.
|
||||
is_gc = false;
|
||||
if (is_gc) {
|
||||
gc_alloc *gcm = (gc_alloc*)(((char *)p) - sizeof(gc_alloc));
|
||||
unlink_gc(gcm);
|
||||
DLOG(sched, mem,
|
||||
"task %s @0x%" PRIxPTR " freeing GC memory = 0x%" PRIxPTR,
|
||||
name, (uintptr_t)this, gcm);
|
||||
DLOG(sched, mem, "rust_task::free(0x%" PRIxPTR ")", gcm);
|
||||
local_region.free(gcm);
|
||||
} else {
|
||||
DLOG(sched, mem, "rust_task::free(0x%" PRIxPTR ")", p);
|
||||
local_region.free(p);
|
||||
}
|
||||
local_region.free(p);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -22,19 +22,6 @@ struct frame_glue_fns {
|
||||
uintptr_t reloc_glue_off;
|
||||
};
|
||||
|
||||
struct gc_alloc {
|
||||
gc_alloc *prev;
|
||||
gc_alloc *next;
|
||||
uintptr_t ctrl_word;
|
||||
uint8_t data[];
|
||||
bool mark() {
|
||||
if (ctrl_word & 1)
|
||||
return false;
|
||||
ctrl_word |= 1;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// portions of the task structure that are accessible from the standard
|
||||
// library. This struct must agree with the std::task::rust_task record.
|
||||
struct rust_task_user {
|
||||
@ -69,7 +56,7 @@ rust_task : public kernel_owned<rust_task>, rust_cond
|
||||
// Fields known to the compiler.
|
||||
stk_seg *stk;
|
||||
uintptr_t runtime_sp; // Runtime sp while task running.
|
||||
gc_alloc *gc_alloc_chain; // Linked list of GC allocations.
|
||||
void *gc_alloc_chain; // Linked list of GC allocations.
|
||||
rust_scheduler *sched;
|
||||
rust_crate_cache *cache;
|
||||
|
||||
@ -81,8 +68,6 @@ rust_task : public kernel_owned<rust_task>, rust_cond
|
||||
const char *cond_name;
|
||||
rust_task *supervisor; // Parent-link for failure propagation.
|
||||
int32_t list_index;
|
||||
size_t gc_alloc_thresh;
|
||||
size_t gc_alloc_accum;
|
||||
|
||||
rust_port_id next_port_id;
|
||||
|
||||
@ -141,8 +126,6 @@ rust_task : public kernel_owned<rust_task>, rust_cond
|
||||
bool blocked_on(rust_cond *cond);
|
||||
bool dead();
|
||||
|
||||
void link_gc(gc_alloc *gcm);
|
||||
void unlink_gc(gc_alloc *gcm);
|
||||
void *malloc(size_t sz, const char *tag, type_desc *td=0);
|
||||
void *realloc(void *data, size_t sz, bool gc_mem=false);
|
||||
void free(void *p, bool gc_mem=false);
|
||||
@ -169,9 +152,6 @@ rust_task : public kernel_owned<rust_task>, rust_cond
|
||||
// Fail self, assuming caller-on-stack is this task.
|
||||
void fail();
|
||||
|
||||
// Run the gc glue on the task stack.
|
||||
void gc();
|
||||
|
||||
// Disconnect from our supervisor.
|
||||
void unsupervise();
|
||||
|
||||
|
@ -189,21 +189,6 @@ upcall_shared_free(rust_task *task, void* ptr) {
|
||||
task->kernel->free(ptr);
|
||||
}
|
||||
|
||||
extern "C" CDECL uintptr_t
|
||||
upcall_mark(rust_task *task, void* ptr) {
|
||||
LOG_UPCALL_ENTRY(task);
|
||||
|
||||
rust_scheduler *sched = task->sched;
|
||||
if (ptr) {
|
||||
gc_alloc *gcm = (gc_alloc*) (((char*)ptr) - sizeof(gc_alloc));
|
||||
uintptr_t marked = (uintptr_t) gcm->mark();
|
||||
DLOG(sched, gc, "upcall mark(0x%" PRIxPTR ") = %" PRIdPTR,
|
||||
(uintptr_t)gcm, marked);
|
||||
return marked;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
rust_str *make_str(rust_task *task, char const *s, size_t fill) {
|
||||
size_t alloc = next_power_of_two(sizeof(rust_str) + fill);
|
||||
void *mem = task->malloc(alloc, "rust_str (make_str)");
|
||||
|
@ -97,7 +97,6 @@ upcall_log_istr
|
||||
upcall_log_str
|
||||
upcall_log_type
|
||||
upcall_malloc
|
||||
upcall_mark
|
||||
upcall_new_str
|
||||
upcall_shared_malloc
|
||||
upcall_shared_free
|
||||
|
Loading…
Reference in New Issue
Block a user