Translated start_task, but it fails on spp == align_down(spp)

This commit is contained in:
Eric Holk 2011-05-20 16:45:51 -07:00
parent d01948cd07
commit 0de27ce8bd
3 changed files with 58 additions and 7 deletions

View File

@ -123,8 +123,8 @@ fn declare_upcalls(type_names tn, ModuleRef llmod) -> @upcalls {
T_size_t(), T_ptr(T_ptr(T_tydesc(tn)))],
T_ptr(T_tydesc(tn))),
new_task=d("new_task", [T_ptr(T_str())], T_taskptr(tn)),
start_task=d("start_task", [T_taskptr(tn), T_int(), T_int(),
T_int(), T_size_t()],
start_task=d("start_task", [T_taskptr(tn),
T_int(), T_int(), T_size_t()],
T_taskptr(tn)),
new_thread=d("new_thread", [T_ptr(T_i8())], T_taskptr(tn)),
start_thread=d("start_thread", [T_taskptr(tn), T_int(), T_int(),
@ -133,3 +133,13 @@ fn declare_upcalls(type_names tn, ModuleRef llmod) -> @upcalls {
);
}
//
// Local Variables:
// mode: C++
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:
//

View File

@ -5981,6 +5981,47 @@ fn trans_spawn(&@block_ctxt cx,
[bcx.fcx.lltaskptr, lltname]);
log_err "Done";
// Okay, start the task.
// First we find the function
auto fnptr = trans_lval(bcx, func).res;
bcx = fnptr.bcx;
auto num_args = vec::len[@ast::expr](args);
auto llfnptr = bcx.build.GEP(fnptr.val,
[C_int(0), C_int(0)]);
log_err "Casting llfnptr";
auto llfnptr_i = bcx.build.PointerCast(llfnptr,
T_int());
log_err "Cassting llargs";
auto llargs_i = bcx.build.PointerCast(llargs.val,
T_int());
log_err "Building call to start_task";
log_err #fmt("ty(start_task) = %s",
val_str(bcx.fcx.lcx.ccx.tn,
bcx.fcx.lcx.ccx.upcalls.start_task));
log_err #fmt("ty(lltaskptr) = %s",
val_str(bcx.fcx.lcx.ccx.tn,
bcx.fcx.lltaskptr));
log_err #fmt("ty(new_task) = %s",
val_str(bcx.fcx.lcx.ccx.tn,
new_task));
log_err #fmt("ty(llfnptr) = %s",
val_str(bcx.fcx.lcx.ccx.tn,
llfnptr_i));
log_err #fmt("ty(llargs) = %s",
val_str(bcx.fcx.lcx.ccx.tn,
llargs_i));
log_err #fmt("ty(num_args) = %s",
val_str(bcx.fcx.lcx.ccx.tn,
C_int(num_args as int)));
bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.start_task,
[bcx.fcx.lltaskptr, new_task,
llfnptr_i, llargs_i, C_int(num_args as int)]);
log_err "Done";
/*
alt(dom) {
case(ast::dom_implicit) {
// TODO
@ -5995,6 +6036,7 @@ fn trans_spawn(&@block_ctxt cx,
fail;
}
}
*/
ret res(bcx, new_task);
}

View File

@ -549,20 +549,19 @@ upcall_new_task(rust_task *spawner, rust_vec *name) {
extern "C" CDECL rust_task *
upcall_start_task(rust_task *spawner,
rust_task *task,
uintptr_t exit_task_glue,
uintptr_t spawnee_fn,
uintptr_t args,
size_t callsz) {
LOG_UPCALL_ENTRY(spawner);
rust_dom *dom = spawner->dom;
DLOG(dom, task,
"upcall start_task(task %s @0x%" PRIxPTR
" exit_task_glue 0x%" PRIxPTR
", spawnee 0x%" PRIxPTR
", callsz %" PRIdPTR ")", task->name, task, exit_task_glue,
", callsz %" PRIdPTR ")", task->name, task,
spawnee_fn, callsz);
task->start(exit_task_glue, spawnee_fn,
spawner->rust_sp, callsz);
task->start((uintptr_t)rust_new_exit_task_glue, spawnee_fn,
args, callsz);
return task;
}