From 3ae4dcd41e72d197e3882835253745f79588b04a Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Mon, 18 Jul 2011 12:02:26 -0700 Subject: 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. --- src/rt/rust_kernel.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/rt/rust_kernel.cpp') diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index 6a8114e6f52..d15d52ba431 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -8,7 +8,7 @@ } while (0) rust_kernel::rust_kernel(rust_srv *srv) : - _region(&srv->local_region), + _region(srv, true), _log(srv, NULL), _srv(srv), _interrupt_kernel_loop(FALSE) @@ -20,10 +20,11 @@ rust_scheduler * rust_kernel::create_scheduler(const char *name) { _kernel_lock.lock(); rust_message_queue *message_queue = - new (this) rust_message_queue(_srv, this); + new (this, "rust_message_queue") rust_message_queue(_srv, this); rust_srv *srv = _srv->clone(); rust_scheduler *sched = - new (this) rust_scheduler(this, message_queue, srv, name); + new (this, "rust_scheduler") + rust_scheduler(this, message_queue, srv, name); rust_handle *handle = internal_get_sched_handle(sched); message_queue->associate(handle); message_queues.append(message_queue); @@ -51,10 +52,8 @@ rust_handle * rust_kernel::internal_get_sched_handle(rust_scheduler *sched) { rust_handle *handle = NULL; if (_sched_handles.get(sched, &handle) == false) { - handle = - new (this) rust_handle(this, - sched->message_queue, - sched); + handle = new (this, "rust_handle(this, sched->message_queue, sched); _sched_handles.put(sched, handle); } return handle; @@ -74,9 +73,8 @@ rust_kernel::get_task_handle(rust_task *task) { rust_handle *handle = NULL; if (_task_handles.get(task, &handle) == false) { handle = - new (this) rust_handle(this, - task->sched->message_queue, - task); + new (this, "rust_handle") + rust_handle(this, task->sched->message_queue, task); _task_handles.put(task, handle); } _kernel_lock.unlock(); @@ -88,7 +86,7 @@ rust_kernel::get_port_handle(rust_port *port) { _kernel_lock.lock(); rust_handle *handle = NULL; if (_port_handles.get(port, &handle) == false) { - handle = new (this) + handle = new (this, "rust_handle") rust_handle(this, port->task->sched->message_queue, port); @@ -202,17 +200,17 @@ rust_kernel::~rust_kernel() { } void * -rust_kernel::malloc(size_t size) { - return _region->malloc(size); +rust_kernel::malloc(size_t size, const char *tag) { + return _region.malloc(size, tag); } void * rust_kernel::realloc(void *mem, size_t size) { - return _region->realloc(mem, size); + return _region.realloc(mem, size); } void rust_kernel::free(void *mem) { - _region->free(mem); + _region.free(mem); } template void -- cgit 1.4.1-3-g733a5