Skip to content

Commit bb4c7a9

Browse files
author
Eric Holk
committed
Arguments seem to be correctly passed to child processes now.
1 parent 21efd07 commit bb4c7a9

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/comp/middle/trans.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5867,7 +5867,9 @@ fn trans_spawn(&@block_ctxt cx,
58675867

58685868
// Translate the arguments, remembering their types and where the values
58695869
// ended up.
5870-
let vec[ty::t] arg_tys = [];
5870+
5871+
// There are 3 integers, for magic.
5872+
let vec[ty::t] arg_tys = [ty::idx_int, ty::idx_int, ty::idx_int];
58715873
let vec[ValueRef] arg_vals = [];
58725874
for(@ast::expr e in args) {
58735875
auto arg = trans_expr(bcx, e);
@@ -5881,14 +5883,15 @@ fn trans_spawn(&@block_ctxt cx,
58815883
}
58825884

58835885
// Make the tuple. We have to reverse the types first though.
5884-
vec::reverse[ty::t](arg_tys);
5885-
vec::reverse[ValueRef](arg_vals);
5886+
//vec::reverse[ty::t](arg_tys);
5887+
//vec::reverse[ValueRef](arg_vals);
58865888
auto args_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, arg_tys);
58875889

58885890
// Allocate and fill the tuple.
58895891
auto llargs = alloc_ty(bcx, args_ty);
58905892

5891-
auto i = vec::len[ValueRef](arg_vals) - 1u;
5893+
// 3 to skip all the magic
5894+
auto i = 3u;
58925895
for(ValueRef v in arg_vals) {
58935896
// log_err #fmt("ty(llargs) = %s",
58945897
// val_str(bcx.fcx.lcx.ccx.tn, llargs.val));
@@ -5900,7 +5903,7 @@ fn trans_spawn(&@block_ctxt cx,
59005903

59015904
bcx.build.Store(v, target);
59025905

5903-
i -= 1u;
5906+
i += 1u;
59045907
}
59055908

59065909
// Now we're ready to do the upcall.
@@ -5927,8 +5930,6 @@ fn trans_spawn(&@block_ctxt cx,
59275930
auto fnptr = trans_lval(bcx, func).res;
59285931
bcx = fnptr.bcx;
59295932

5930-
auto num_args = vec::len[@ast::expr](args);
5931-
59325933
auto llfnptr = bcx.build.GEP(fnptr.val,
59335934
[C_int(0), C_int(0)]);
59345935
log_err "Casting llfnptr";
@@ -5942,6 +5943,8 @@ fn trans_spawn(&@block_ctxt cx,
59425943
auto llargs_i = bcx.build.PointerCast(llargs.val,
59435944
T_int());
59445945

5946+
auto args_size = size_of(bcx, args_ty).val;
5947+
59455948
log_err "Building call to start_task";
59465949
log_err #fmt("ty(start_task) = %s",
59475950
val_str(bcx.fcx.lcx.ccx.tn,
@@ -5958,12 +5961,12 @@ fn trans_spawn(&@block_ctxt cx,
59585961
log_err #fmt("ty(llargs) = %s",
59595962
val_str(bcx.fcx.lcx.ccx.tn,
59605963
llargs_i));
5961-
log_err #fmt("ty(num_args) = %s",
5964+
log_err #fmt("ty(args_size) = %s",
59625965
val_str(bcx.fcx.lcx.ccx.tn,
5963-
C_int(num_args as int)));
5966+
args_size));
59645967
bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.start_task,
59655968
[bcx.fcx.lltaskptr, new_task,
5966-
llfnptr_i, llargs_i, C_int(num_args as int)]);
5969+
llfnptr_i, llargs_i, args_size]);
59675970
log_err "Done";
59685971

59695972
/*

src/test/run-pass/spawn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ fn main() {
88
}
99

1010
fn child(int i) {
11-
log i;
11+
log_err i;
1212
}
1313

0 commit comments

Comments
 (0)