rt: Add an on-the-side GC chain
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
#ifndef RUST_TASK_H
|
#ifndef RUST_TASK_H
|
||||||
#define RUST_TASK_H
|
#define RUST_TASK_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "util/array_list.h"
|
#include "util/array_list.h"
|
||||||
|
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
@@ -113,6 +115,8 @@ rust_task : public kernel_owned<rust_task>, rust_cond
|
|||||||
|
|
||||||
rust_obstack dynastack;
|
rust_obstack dynastack;
|
||||||
|
|
||||||
|
std::map<void *,type_desc *> local_allocs;
|
||||||
|
|
||||||
// Only a pointer to 'name' is kept, so it must live as long as this task.
|
// Only a pointer to 'name' is kept, so it must live as long as this task.
|
||||||
rust_task(rust_scheduler *sched,
|
rust_task(rust_scheduler *sched,
|
||||||
rust_task_list *state,
|
rust_task_list *state,
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ upcall_malloc(rust_task *task, size_t nbytes, type_desc *td) {
|
|||||||
|
|
||||||
void *p = task->malloc(nbytes, "tdesc", td);
|
void *p = task->malloc(nbytes, "tdesc", td);
|
||||||
|
|
||||||
|
task->local_allocs[p] = td;
|
||||||
|
|
||||||
LOG(task, mem,
|
LOG(task, mem,
|
||||||
"upcall malloc(%" PRIdPTR ", 0x%" PRIxPTR ") = 0x%" PRIxPTR,
|
"upcall malloc(%" PRIdPTR ", 0x%" PRIxPTR ") = 0x%" PRIxPTR,
|
||||||
nbytes, td, (uintptr_t)p);
|
nbytes, td, (uintptr_t)p);
|
||||||
@@ -84,6 +86,8 @@ upcall_free(rust_task *task, void* ptr, uintptr_t is_gc) {
|
|||||||
DLOG(sched, mem,
|
DLOG(sched, mem,
|
||||||
"upcall free(0x%" PRIxPTR ", is_gc=%" PRIdPTR ")",
|
"upcall free(0x%" PRIxPTR ", is_gc=%" PRIdPTR ")",
|
||||||
(uintptr_t)ptr, is_gc);
|
(uintptr_t)ptr, is_gc);
|
||||||
|
|
||||||
|
task->local_allocs.erase(ptr);
|
||||||
task->free(ptr, (bool) is_gc);
|
task->free(ptr, (bool) is_gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user