Skip to content

Commit d01948c

Browse files
author
Eric Holk
committed
Called the new_task upcall. There are refcount issues though.
1 parent 41b3979 commit d01948c

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src/comp/back/upcall.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn declare_upcalls(type_names tn, ModuleRef llmod) -> @upcalls {
122122
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
123123
T_size_t(), T_ptr(T_ptr(T_tydesc(tn)))],
124124
T_ptr(T_tydesc(tn))),
125-
new_task=d("new_task", [T_ptr(T_i8())], T_taskptr(tn)),
125+
new_task=d("new_task", [T_ptr(T_str())], T_taskptr(tn)),
126126
start_task=d("start_task", [T_taskptr(tn), T_int(), T_int(),
127127
T_int(), T_size_t()],
128128
T_taskptr(tn)),

src/comp/middle/trans.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5903,7 +5903,8 @@ fn trans_spawn(&@block_ctxt cx,
59035903
};
59045904

59055905
// dump a bunch of information
5906-
log_err "Spawn";
5906+
log_err "Translating Spawn " +
5907+
"(The compiled program is not actually running yet, don't worry!";
59075908
log_err #fmt("task name: %s", tname);
59085909

59095910
// Generate code
@@ -5920,6 +5921,8 @@ fn trans_spawn(&@block_ctxt cx,
59205921
//
59215922
// 4. Pass a pointer to the spawnee function and the argument tuple to
59225923
// upcall_start_task.
5924+
//
5925+
// 5. Oh yeah, we have to create the task before we start it...
59235926

59245927
// Translate the arguments, remembering their types and where the values
59255928
// ended up.
@@ -5961,6 +5964,23 @@ fn trans_spawn(&@block_ctxt cx,
59615964

59625965
// Now we're ready to do the upcall.
59635966

5967+
// But first, we'll create a task.
5968+
let ValueRef lltname = C_str(bcx.fcx.lcx.ccx, tname);
5969+
log_err #fmt("ty(new_task) = %s",
5970+
val_str(bcx.fcx.lcx.ccx.tn,
5971+
bcx.fcx.lcx.ccx.upcalls.new_task));
5972+
log_err #fmt("ty(lltaskptr) = %s",
5973+
val_str(bcx.fcx.lcx.ccx.tn,
5974+
bcx.fcx.lltaskptr));
5975+
log_err #fmt("ty(lltname) = %s",
5976+
val_str(bcx.fcx.lcx.ccx.tn,
5977+
lltname));
5978+
5979+
log_err "Building upcall_new_task";
5980+
auto new_task = bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.new_task,
5981+
[bcx.fcx.lltaskptr, lltname]);
5982+
log_err "Done";
5983+
59645984
alt(dom) {
59655985
case(ast::dom_implicit) {
59665986
// TODO
@@ -5975,6 +5995,8 @@ fn trans_spawn(&@block_ctxt cx,
59755995
fail;
59765996
}
59775997
}
5998+
5999+
ret res(bcx, new_task);
59786000
}
59796001

59806002
fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,

src/rt/rust_upcall.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,11 @@ upcall_get_type_desc(rust_task *task,
538538
}
539539

540540
extern "C" CDECL rust_task *
541-
upcall_new_task(rust_task *spawner, const char *name) {
541+
upcall_new_task(rust_task *spawner, rust_vec *name) {
542+
// name is a rust string structure.
542543
LOG_UPCALL_ENTRY(spawner);
543544
rust_dom *dom = spawner->dom;
544-
rust_task *task = dom->create_task(spawner, name);
545+
rust_task *task = dom->create_task(spawner, (const char *)name->data);
545546
return task;
546547
}
547548

0 commit comments

Comments
 (0)