Skip to content

Commit a88af90

Browse files
author
Eric Holk
committed
Programs using spawn terminate
1 parent dad4264 commit a88af90

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/comp/middle/trans.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,9 @@ fn type_of_inner(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef {
760760
case (ty::ty_chan(?t)) {
761761
llty = T_ptr(T_chan(type_of_inner(cx, sp, t)));
762762
}
763+
case (ty::ty_task) {
764+
llty = T_taskptr(cx.tn);
765+
}
763766
case (ty::ty_tup(?elts)) {
764767
let vec[TypeRef] tys = [];
765768
for (ty::mt elt in elts) {
@@ -2014,6 +2017,11 @@ fn make_free_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
20142017
rslt = res(cx, C_int(0));
20152018
}
20162019

2020+
case (ty::ty_task) {
2021+
// TODO: call upcall_kill
2022+
rslt = res(cx, C_nil());
2023+
}
2024+
20172025
case (ty::ty_obj(_)) {
20182026

20192027
auto box_cell =
@@ -2107,6 +2115,10 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
21072115
rslt = decr_refcnt_maybe_free(cx, v0, v0, t);
21082116
}
21092117

2118+
case (ty::ty_task) {
2119+
rslt = decr_refcnt_maybe_free(cx, v0, v0, t);
2120+
}
2121+
21102122
case (ty::ty_obj(_)) {
21112123
auto box_cell =
21122124
cx.build.GEP(v0,
@@ -5984,6 +5996,10 @@ fn trans_spawn(&@block_ctxt cx,
59845996
}
59855997
*/
59865998

5999+
auto task_ty = node_ann_type(bcx.fcx.lcx.ccx, ann);
6000+
auto dropref = clean(bind drop_ty(_, new_task, task_ty));
6001+
find_scope_cx(bcx).cleanups += [dropref];
6002+
59876003
ret res(bcx, new_task);
59886004
}
59896005

src/comp/middle/ty.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ fn type_is_boxed(&ctxt cx, &t ty) -> bool {
951951
case (ty_box(_)) { ret true; }
952952
case (ty_port(_)) { ret true; }
953953
case (ty_chan(_)) { ret true; }
954+
case (ty_task) { ret true; }
954955
case (_) { ret false; }
955956
}
956957
fail;

src/test/run-pass/spawn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// -*- rust -*-
55

66
fn main() {
7-
spawn child(10);
7+
auto t = spawn child(10);
88
}
99

1010
fn child(int i) {

0 commit comments

Comments
 (0)