From 2e2951305d66feea833ec2b05af8102b1b5affa9 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 13 Jul 2011 13:43:35 -0700 Subject: [PATCH] Remove obsolete nargs counts from runtime. --- src/rt/rust_builtin.cpp | 34 +++++++++++++++++----------------- src/rt/rust_task.cpp | 15 ++++++--------- src/rt/rust_task.h | 8 ++++---- src/rt/rust_upcall.cpp | 12 ++++++------ 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index aa4b7473c67..5d4644cf588 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -29,7 +29,7 @@ last_os_error(rust_task *task) { char cbuf[BUF_BYTES]; char *buf = strerror_r(errno, cbuf, sizeof(cbuf)); if (!buf) { - task->fail(1); + task->fail(); return NULL; } #else @@ -44,7 +44,7 @@ last_os_error(rust_task *task) { size_t alloc = next_power_of_two(sizeof(rust_str) + fill); void *mem = task->malloc(alloc); if (!mem) { - task->fail(1); + task->fail(); return NULL; } rust_str *st = new (mem) rust_str(sched, alloc, fill, @@ -68,7 +68,7 @@ rust_getcwd(rust_task *task) { #else if (!getcwd(cbuf, sizeof(cbuf))) { #endif - task->fail(1); + task->fail(); return NULL; } @@ -76,7 +76,7 @@ rust_getcwd(rust_task *task) { size_t alloc = next_power_of_two(sizeof(rust_str) + fill); void *mem = task->malloc(alloc); if (!mem) { - task->fail(1); + task->fail(); return NULL; } @@ -114,7 +114,7 @@ refcount(rust_task *task, type_desc *t, intptr_t *v) { extern "C" CDECL void do_gc(rust_task *task) { - task->gc(1); + task->gc(); } extern "C" CDECL void @@ -132,7 +132,7 @@ vec_alloc(rust_task *task, type_desc *t, type_desc *elem_t, size_t n_elts) size_t alloc = next_power_of_two(sizeof(rust_vec) + fill); void *mem = task->malloc(alloc, t->is_stateful ? t : NULL); if (!mem) { - task->fail(4); + task->fail(); return NULL; } rust_vec *vec = new (mem) rust_vec(sched, alloc, 0, NULL); @@ -230,7 +230,7 @@ str_alloc(rust_task *task, size_t n_bytes) 1, 1, (void*)""); if (!st) { - task->fail(2); + task->fail(); return NULL; } return st; @@ -244,7 +244,7 @@ str_push_byte(rust_task* task, rust_str* v, size_t byte) if (v->ref_count > 1 || v->alloc < alloc) { v = vec_alloc_with_data(task, fill + 1, fill, 1, (void*)&v->data[0]); if (!v) { - task->fail(2); + task->fail(); return NULL; } } @@ -268,7 +268,7 @@ str_slice(rust_task* task, rust_str* v, size_t begin, size_t end) 1, len ? v->data + begin : NULL); if (!st) { - task->fail(2); + task->fail(); return NULL; } st->data[st->fill++] = '\0'; @@ -301,7 +301,7 @@ str_vec(rust_task *task, rust_str *s) 1, (s->fill - 1) ? (void*)s->data : NULL); if (!v) { - task->fail(2); + task->fail(); return NULL; } return v; @@ -326,7 +326,7 @@ str_from_ivec(rust_task *task, rust_ivec *v) 1, fill ? data : NULL); if (!st) { - task->fail(2); + task->fail(); return NULL; } st->data[st->fill++] = '\0'; @@ -343,7 +343,7 @@ str_from_vec(rust_task *task, rust_vec *v) 1, v->fill ? (void*)v->data : NULL); if (!st) { - task->fail(2); + task->fail(); return NULL; } st->data[st->fill++] = '\0'; @@ -356,7 +356,7 @@ str_from_cstr(rust_task *task, char *sbuf) size_t len = strlen(sbuf) + 1; rust_str *st = vec_alloc_with_data(task, len, len, 1, sbuf); if (!st) { - task->fail(2); + task->fail(); return NULL; } return st; @@ -366,7 +366,7 @@ extern "C" CDECL rust_str * str_from_buf(rust_task *task, char *buf, unsigned int len) { rust_str *st = vec_alloc_with_data(task, len + 1, len, 1, buf); if (!st) { - task->fail(2); + task->fail(); return NULL; } st->data[st->fill++] = '\0'; @@ -379,7 +379,7 @@ rand_new(rust_task *task) rust_scheduler *sched = task->sched; randctx *rctx = (randctx *) task->malloc(sizeof(randctx)); if (!rctx) { - task->fail(1); + task->fail(); return NULL; } isaac_init(sched, rctx); @@ -777,7 +777,7 @@ ivec_copy_from_buf(rust_task *task, type_desc *ty, rust_ivec *v, void *ptr, { size_t old_size = get_ivec_size(v); if (old_size) { - task->fail(1); + task->fail(); return; } @@ -806,7 +806,7 @@ ivec_copy_from_buf_shared(rust_task *task, type_desc *ty, rust_ivec *v, { size_t old_size = get_ivec_size(v); if (old_size) { - task->fail(1); + task->fail(); return; } diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index b8fa6bd72eb..a358b4a6ed3 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -177,17 +177,15 @@ rust_task::grow(size_t n_frame_bytes) } void -rust_task::yield(size_t nargs) { - yield(nargs, 0); +rust_task::yield() { + yield(0); } void -rust_task::yield(size_t nargs, size_t time_in_us) { +rust_task::yield(size_t time_in_us) { LOG(this, task, "task %s @0x%" PRIxPTR " yielding for %d us", name, this, time_in_us); - // FIXME: what is nargs for, and is it safe to ignore? - yield_timer.reset_us(time_in_us); // Return to the scheduler. @@ -203,7 +201,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). + // If you want to fail yourself you do self->fail(). LOG(this, task, "killing task %s @0x%" PRIxPTR, name, this); // Unblock the task so it can unwind. unblock(); @@ -216,7 +214,7 @@ rust_task::kill() { } void -rust_task::fail(size_t nargs) { +rust_task::fail() { // See note in ::kill() regarding who should call this. DLOG(sched, task, "task %s @0x%" PRIxPTR " failing", name, this); backtrace(); @@ -224,7 +222,6 @@ rust_task::fail(size_t nargs) { unblock(); if (this == sched->root_task) sched->fail(); - // run_after_return(nargs, rust_unwind_glue); if (supervisor) { DLOG(sched, task, "task %s @0x%" PRIxPTR @@ -237,7 +234,7 @@ rust_task::fail(size_t nargs) { } void -rust_task::gc(size_t nargs) +rust_task::gc() { // FIXME: not presently implemented; was broken by rustc. DLOG(sched, task, diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h index c20eae7ece8..4983fd8d00d 100644 --- a/src/rt/rust_task.h +++ b/src/rt/rust_task.h @@ -127,19 +127,19 @@ rust_task : public maybe_proxy, void backtrace(); // Save callee-saved registers and return to the main loop. - void yield(size_t nargs); + void yield(); // Yields for a specified duration of time. - void yield(size_t nargs, size_t time_in_ms); + void yield(size_t time_in_ms); // Fail this task (assuming caller-on-stack is different task). void kill(); // Fail self, assuming caller-on-stack is this task. - void fail(size_t nargs); + void fail(); // Run the gc glue on the task stack. - void gc(size_t nargs); + void gc(); // Disconnect from our supervisor. void unsupervise(); diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index ec3e1856ea4..4d34ca78d25 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -173,7 +173,7 @@ upcall_sleep(rust_task *task, size_t time_in_us) { LOG(task, task, "elapsed %" PRIu64 " us", task->yield_timer.elapsed_us()); LOG(task, task, "sleep %d us", time_in_us); - task->yield(2, time_in_us); + task->yield(time_in_us); } /** @@ -221,7 +221,7 @@ upcall_fail(rust_task *task, size_t line) { LOG_UPCALL_ENTRY(task); LOG_ERR(task, upcall, "upcall fail '%s', %s:%" PRIdPTR, expr, file, line); - task->fail(4); + task->fail(); } /** @@ -338,7 +338,7 @@ 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); if (!mem) { - task->fail(3); + task->fail(); return NULL; } rust_str *st = new (mem) rust_str(sched, alloc, fill, @@ -372,7 +372,7 @@ upcall_new_vec(rust_task *task, size_t fill, type_desc *td) { size_t alloc = next_power_of_two(sizeof(rust_vec) + fill); void *mem = task->malloc(alloc, td); if (!mem) { - task->fail(3); + task->fail(); return NULL; } rust_vec *v = new (mem) rust_vec(sched, alloc, 0, NULL); @@ -410,7 +410,7 @@ vec_grow(rust_task *task, LOG(task, mem, "realloc path"); v = (rust_vec*) task->realloc(v, alloc, td->is_stateful); if (!v) { - task->fail(4); + task->fail(); return NULL; } v->alloc = alloc; @@ -432,7 +432,7 @@ vec_grow(rust_task *task, LOG(task, mem, "new vec path"); void *mem = task->malloc(alloc, td); if (!mem) { - task->fail(4); + task->fail(); return NULL; }