Lots of work on memory tracking and channels.

We're trying to get closer to doing correct move semantics for channel
operations. This involves a lot of cleanup (such as removing the
unused sched parameter from rust_vec constructor) and making
circular_buffer kernel_owned.

Added tagging for memory allocations. This means we give a string tag
to everything we allocate. If we leak something and TRACK_ALLOCATIONS
is enabled, then it's much easier now to tell exactly what is leaking.
This commit is contained in:
Eric Holk
2011-07-18 12:02:26 -07:00
committed by Brian Anderson
parent a44fb04d57
commit 3ae4dcd41e
24 changed files with 313 additions and 240 deletions

View File

@@ -34,7 +34,7 @@ new_stk(rust_task *task, size_t minsz)
if (minsz < min_stk_bytes)
minsz = min_stk_bytes;
size_t sz = sizeof(stk_seg) + minsz;
stk_seg *stk = (stk_seg *)task->malloc(sz);
stk_seg *stk = (stk_seg *)task->malloc(sz, "stack");
LOGPTR(task->sched, "new stk", (uintptr_t)stk);
memset(stk, 0, sizeof(stk_seg));
stk->limit = (uintptr_t) &stk->data[minsz];
@@ -326,7 +326,7 @@ rust_task::unlink_gc(gc_alloc *gcm) {
}
void *
rust_task::malloc(size_t sz, type_desc *td)
rust_task::malloc(size_t sz, const char *tag, type_desc *td)
{
// FIXME: GC is disabled for now.
// GC-memory classification is all wrong.
@@ -335,7 +335,8 @@ rust_task::malloc(size_t sz, type_desc *td)
if (td) {
sz += sizeof(gc_alloc);
}
void *mem = local_region.malloc(sz);
void *mem = local_region.malloc(sz, tag);
if (!mem)
return mem;
if (td) {
@@ -488,8 +489,8 @@ bool rust_task::can_schedule(int id)
}
void *
rust_task::calloc(size_t size) {
return local_region.calloc(size);
rust_task::calloc(size_t size, const char *tag) {
return local_region.calloc(size, tag);
}
void rust_task::pin() {