diff --git a/src/comp/back/upcall.rs b/src/comp/back/upcall.rs index b1b533c84d6a..df7b4a4a2d02 100644 --- a/src/comp/back/upcall.rs +++ b/src/comp/back/upcall.rs @@ -122,7 +122,7 @@ fn declare_upcalls(type_names tn, ModuleRef llmod) -> @upcalls { [T_ptr(T_crate(tn)), T_size_t(), T_size_t(), T_size_t(), T_ptr(T_ptr(T_tydesc(tn)))], T_ptr(T_tydesc(tn))), - new_task=d("new_task", [T_ptr(T_i8())], T_taskptr(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()], T_taskptr(tn)), diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 054e6114a717..8552aa4e6fe4 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -5903,7 +5903,8 @@ fn trans_spawn(&@block_ctxt cx, }; // dump a bunch of information - log_err "Spawn"; + log_err "Translating Spawn " + + "(The compiled program is not actually running yet, don't worry!"; log_err #fmt("task name: %s", tname); // Generate code @@ -5920,6 +5921,8 @@ fn trans_spawn(&@block_ctxt cx, // // 4. Pass a pointer to the spawnee function and the argument tuple to // upcall_start_task. + // + // 5. Oh yeah, we have to create the task before we start it... // Translate the arguments, remembering their types and where the values // ended up. @@ -5961,6 +5964,23 @@ fn trans_spawn(&@block_ctxt cx, // Now we're ready to do the upcall. + // But first, we'll create a task. + let ValueRef lltname = C_str(bcx.fcx.lcx.ccx, tname); + log_err #fmt("ty(new_task) = %s", + val_str(bcx.fcx.lcx.ccx.tn, + bcx.fcx.lcx.ccx.upcalls.new_task)); + log_err #fmt("ty(lltaskptr) = %s", + val_str(bcx.fcx.lcx.ccx.tn, + bcx.fcx.lltaskptr)); + log_err #fmt("ty(lltname) = %s", + val_str(bcx.fcx.lcx.ccx.tn, + lltname)); + + log_err "Building upcall_new_task"; + auto new_task = bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.new_task, + [bcx.fcx.lltaskptr, lltname]); + log_err "Done"; + alt(dom) { case(ast::dom_implicit) { // TODO @@ -5975,6 +5995,8 @@ fn trans_spawn(&@block_ctxt cx, fail; } } + + ret res(bcx, new_task); } fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs, diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 6bdfaef96e13..f95a6e3ebeeb 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -538,10 +538,11 @@ upcall_get_type_desc(rust_task *task, } extern "C" CDECL rust_task * -upcall_new_task(rust_task *spawner, const char *name) { +upcall_new_task(rust_task *spawner, rust_vec *name) { + // name is a rust string structure. LOG_UPCALL_ENTRY(spawner); rust_dom *dom = spawner->dom; - rust_task *task = dom->create_task(spawner, name); + rust_task *task = dom->create_task(spawner, (const char *)name->data); return task; }