aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-08-10 13:26:00 -0700
committerGraydon Hoare <[email protected]>2010-08-10 13:26:00 -0700
commitdbe8760af3b50bfa14d39406fe0eca2f2b82d8ec (patch)
treec5f89fa72e9c28ced0a533a498d64eee30f26f3f /src/rt/rust_task.cpp
parentFix a deque size bookkeeping bug. (diff)
parentAdd names to tasks and domains. These can either be an explicit literal string (diff)
downloadrust-dbe8760af3b50bfa14d39406fe0eca2f2b82d8ec.tar.xz
rust-dbe8760af3b50bfa14d39406fe0eca2f2b82d8ec.zip
Merge commit 'jyasskin/work'
Conflicts: src/rt/rust_dom.cpp src/rt/rust_upcall.cpp
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index f52db868..aca8bca7 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -52,7 +52,7 @@ align_down(uintptr_t sp)
}
-rust_task::rust_task(rust_dom *dom, rust_task *spawner) :
+rust_task::rust_task(rust_dom *dom, rust_task *spawner, const char *name) :
maybe_proxy<rust_task>(this),
stk(new_stk(dom, 0)),
runtime_sp(0),
@@ -60,6 +60,7 @@ rust_task::rust_task(rust_dom *dom, rust_task *spawner) :
gc_alloc_chain(0),
dom(dom),
cache(NULL),
+ name(name),
state(&dom->running_tasks),
cond(NULL),
supervisor(spawner),
@@ -77,8 +78,8 @@ rust_task::rust_task(rust_dom *dom, rust_task *spawner) :
rust_task::~rust_task()
{
dom->log(rust_log::MEM|rust_log::TASK,
- "~rust_task 0x%" PRIxPTR ", refcnt=%d",
- (uintptr_t)this, ref_count);
+ "~rust_task %s @0x%" PRIxPTR ", refcnt=%d",
+ name, (uintptr_t)this, ref_count);
/*
for (uintptr_t fp = get_fp(); fp; fp = get_previous_fp(fp)) {
@@ -311,7 +312,7 @@ void
rust_task::yield(size_t nargs)
{
log(rust_log::TASK,
- "task 0x%" PRIxPTR " yielding", this);
+ "task %s @0x%" PRIxPTR " yielding", name, this);
run_after_return(nargs, dom->root_crate->get_yield_glue());
}
@@ -331,7 +332,7 @@ rust_task::kill() {
// Note the distinction here: kill() is when you're in an upcall
// from task A and want to force-fail task B, you do B->kill().
// If you want to fail yourself you do self->fail(upcall_nargs).
- log(rust_log::TASK, "killing task 0x%" PRIxPTR, this);
+ log(rust_log::TASK, "killing task %s @0x%" PRIxPTR, name, this);
// Unblock the task so it can unwind.
unblock();
@@ -345,7 +346,7 @@ rust_task::kill() {
void
rust_task::fail(size_t nargs) {
// See note in ::kill() regarding who should call this.
- dom->log(rust_log::TASK, "task 0x%" PRIxPTR " failing", this);
+ dom->log(rust_log::TASK, "task %s @0x%" PRIxPTR " failing", name, this);
// Unblock the task so it can unwind.
unblock();
if (this == dom->root_task)
@@ -353,9 +354,9 @@ rust_task::fail(size_t nargs) {
run_after_return(nargs, dom->root_crate->get_unwind_glue());
if (supervisor) {
dom->log(rust_log::TASK,
- "task 0x%" PRIxPTR
- " propagating failure to supervisor 0x%" PRIxPTR,
- this, supervisor);
+ "task %s @0x%" PRIxPTR
+ " propagating failure to supervisor %s @0x%" PRIxPTR,
+ name, this, supervisor->name, supervisor);
supervisor->kill();
}
}
@@ -364,7 +365,7 @@ void
rust_task::gc(size_t nargs)
{
dom->log(rust_log::TASK|rust_log::MEM,
- "task 0x%" PRIxPTR " garbage collecting", this);
+ "task %s @0x%" PRIxPTR " garbage collecting", name, this);
run_after_return(nargs, dom->root_crate->get_gc_glue());
}
@@ -372,8 +373,9 @@ void
rust_task::unsupervise()
{
dom->log(rust_log::TASK,
- "task 0x%" PRIxPTR " disconnecting from supervisor 0x%" PRIxPTR,
- this, supervisor);
+ "task %s @0x%" PRIxPTR
+ " disconnecting from supervisor %s @0x%" PRIxPTR,
+ name, this, supervisor->name, supervisor);
supervisor = NULL;
}
@@ -474,8 +476,9 @@ rust_task::malloc(size_t sz, type_desc *td)
if (td) {
gc_alloc *gcm = (gc_alloc*) mem;
dom->log(rust_log::TASK|rust_log::MEM|rust_log::GC,
- "task 0x%" PRIxPTR " allocated %d GC bytes = 0x%" PRIxPTR,
- (uintptr_t)this, sz, gcm);
+ "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;
@@ -494,8 +497,9 @@ rust_task::realloc(void *data, size_t sz, bool is_gc)
sz += sizeof(gc_alloc);
gcm = (gc_alloc*) dom->realloc((void*)gcm, sz);
dom->log(rust_log::TASK|rust_log::MEM|rust_log::GC,
- "task 0x%" PRIxPTR " reallocated %d GC bytes = 0x%" PRIxPTR,
- (uintptr_t)this, sz, gcm);
+ "task %s @0x%" PRIxPTR
+ " reallocated %d GC bytes = 0x%" PRIxPTR,
+ name, (uintptr_t)this, sz, gcm);
if (!gcm)
return gcm;
link_gc(gcm);
@@ -513,8 +517,8 @@ rust_task::free(void *p, bool is_gc)
gc_alloc *gcm = (gc_alloc*)(((char *)p) - sizeof(gc_alloc));
unlink_gc(gcm);
dom->log(rust_log::TASK|rust_log::MEM|rust_log::GC,
- "task 0x%" PRIxPTR " freeing GC memory = 0x%" PRIxPTR,
- (uintptr_t)this, gcm);
+ "task %s @0x%" PRIxPTR " freeing GC memory = 0x%" PRIxPTR,
+ name, (uintptr_t)this, gcm);
dom->free(gcm);
} else {
dom->free(p);
@@ -531,7 +535,8 @@ rust_task::transition(ptr_vec<rust_task> *src, ptr_vec<rust_task> *dst)
{
I(dom, state == src);
dom->log(rust_log::TASK,
- "task 0x%" PRIxPTR " state change '%s' -> '%s'",
+ "task %s @0x%" PRIxPTR " state change '%s' -> '%s'",
+ name,
(uintptr_t)this,
dom->state_vec_name(src),
dom->state_vec_name(dst));