Skip to content

Commit 54be5b0

Browse files
author
Eric Holk
committed
Fixing (or at least improving) translation of move semantics for send and receive. This let's us run all of the task-comm tests.
1 parent 75ee817 commit 54be5b0

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/comp/middle/trans_comm.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,14 @@ fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
216216
auto data_tmp = move_val_if_temp(bcx, INIT, data_alloc.val,
217217
data, unit_ty);
218218
bcx = data_tmp.bcx;
219-
add_clean_temp(bcx, data_alloc.val, unit_ty);
220219
auto llchanval = bcx.build.PointerCast(chn.val, T_opaque_chan_ptr());
221220
auto lldataptr = bcx.build.PointerCast(data_alloc.val, T_ptr(T_i8()));
222221
bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.send,
223222
~[bcx.fcx.lltaskptr, llchanval, lldataptr]);
223+
224+
// Deinit the stuff we sent.
225+
bcx = zero_alloca(bcx, data_alloc.val, unit_ty).bcx;
226+
224227
ret rslt(bcx, chn.val);
225228
auto unit_ty;
226229
}
@@ -231,7 +234,6 @@ fn trans_recv(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
231234
auto data = trans_lval(bcx, rhs);
232235
assert (data.is_mem);
233236
bcx = data.res.bcx;
234-
auto unit_ty = node_id_type(bcx.fcx.lcx.ccx, id);
235237
// FIXME: calculate copy init-ness in typestate.
236238

237239
auto prt = trans_expr(bcx, lhs);
@@ -241,13 +243,8 @@ fn trans_recv(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
241243
auto llportptr = bcx.build.PointerCast(prt.val, T_opaque_port_ptr());
242244
bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.recv,
243245
~[bcx.fcx.lltaskptr, lldataptr, llportptr]);
244-
auto data_load = load_if_immediate(bcx, data.res.val, unit_ty);
245-
//auto cp = copy_val(bcx, DROP_EXISTING,
246-
// data.res.val, data_load, unit_ty);
247-
//bcx = cp.bcx;
248246

249-
add_clean_temp(cx, data_load, unit_ty);
250-
ret rslt(bcx, data_load);
247+
ret rslt(bcx, data.res.val);
251248
}
252249

253250
// Does a deep copy of a value. This is needed for passing arguments to child

src/test/run-pass/task-comm-10.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ fn main() {
2323

2424
p = port();
2525
child = spawn start(chan(p));
26+
auto c;
2627

2728
p |> c;
2829
c <| "A";
2930
c <| "B";
3031
task::yield();
31-
32-
auto c;
3332
}

src/test/run-pass/task-comm-11.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// xfail-stage0
2-
// xfail-stage1
3-
// xfail-stage2
42
// xfail-stage3
53

64
fn start(chan[chan[str]] c) {

0 commit comments

Comments
 (0)