Skip to content

Commit 5bdbd02

Browse files
author
Eric Holk
committed
---
yaml --- r: 4223 b: refs/heads/master c: a5fe66e h: refs/heads/master i: 4221: bdd2fd1 4219: b507ed2 4215: ce808d0 4207: 915d979 4191: 302ec53 4159: 72678da 4095: 1cb4a68 v: v3
1 parent 7b474db commit 5bdbd02

File tree

7 files changed

+43
-4
lines changed

7 files changed

+43
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 5302cde188bba80dd38c58eaafa792d621b0818c
2+
refs/heads/master: a5fe66e7065c0e91064f3a818ea901ecfb499b70

trunk/src/comp/back/upcall.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ type upcalls =
5757
vec_append: ValueRef,
5858
get_type_desc: ValueRef,
5959
new_task: ValueRef,
60+
take_task: ValueRef,
61+
drop_task: ValueRef,
6062
start_task: ValueRef,
6163
ivec_resize: ValueRef,
6264
ivec_spill: ValueRef,
@@ -129,6 +131,8 @@ fn declare_upcalls(tn: type_names, tydesc_type: TypeRef,
129131
~[T_ptr(T_nil()), T_size_t(), T_size_t(), T_size_t(),
130132
T_ptr(T_ptr(tydesc_type))], T_ptr(tydesc_type)),
131133
new_task: d("new_task", ~[T_ptr(T_str())], taskptr_type),
134+
take_task: dv("take_task", ~[taskptr_type]),
135+
drop_task: dv("drop_task", ~[taskptr_type]),
132136
start_task:
133137
d("start_task", ~[taskptr_type, T_int(), T_int(), T_size_t()],
134138
taskptr_type),

trunk/src/comp/middle/trans.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,13 @@ fn make_copy_glue(cx: &@block_ctxt, v: ValueRef, t: &ty::t) {
12211221
// NB: v is an *alias* of type t here, not a direct value.
12221222

12231223
let bcx;
1224-
if ty::type_is_boxed(bcx_tcx(cx), t) {
1224+
1225+
if ty::type_is_task(bcx_tcx(cx), t) {
1226+
let task_ptr = cx.build.Load(v);
1227+
cx.build.Call(bcx_ccx(cx).upcalls.take_task,
1228+
~[cx.fcx.lltaskptr, task_ptr]);
1229+
bcx = cx;
1230+
} else if ty::type_is_boxed(bcx_tcx(cx), t) {
12251231
bcx = incr_refcnt_of_boxed(cx, cx.build.Load(v)).bcx;
12261232
} else if (ty::type_is_structural(bcx_tcx(cx), t)) {
12271233
bcx = duplicate_heap_parts_if_necessary(cx, v, t).bcx;
@@ -1381,7 +1387,12 @@ fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) {
13811387
ty::ty_box(_) { decr_refcnt_maybe_free(cx, v0, v0, t) }
13821388
ty::ty_port(_) { decr_refcnt_maybe_free(cx, v0, v0, t) }
13831389
ty::ty_chan(_) { decr_refcnt_maybe_free(cx, v0, v0, t) }
1384-
ty::ty_task. { decr_refcnt_maybe_free(cx, v0, v0, t) }
1390+
ty::ty_task. {
1391+
let task_ptr = cx.build.Load(v0);
1392+
{bcx: cx,
1393+
val: cx.build.Call(bcx_ccx(cx).upcalls.drop_task,
1394+
~[cx.fcx.lltaskptr, task_ptr])}
1395+
}
13851396
ty::ty_obj(_) {
13861397
let box_cell =
13871398
cx.build.GEP(v0, ~[C_int(0), C_int(abi::obj_field_box)]);

trunk/src/comp/middle/ty.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export type_is_bot;
162162
export type_is_box;
163163
export type_is_boxed;
164164
export type_is_chan;
165+
export type_is_task;
165166
export type_is_fp;
166167
export type_is_integral;
167168
export type_is_native;
@@ -842,6 +843,10 @@ fn type_is_chan(cx: &ctxt, ty: &t) -> bool {
842843
alt struct(cx, ty) { ty_chan(_) { ret true; } _ { ret false; } }
843844
}
844845

846+
fn type_is_task(cx: &ctxt, ty: &t) -> bool {
847+
alt struct(cx, ty) { ty_task. { ret true; } _ { ret false; } }
848+
}
849+
845850
fn type_is_structural(cx: &ctxt, ty: &t) -> bool {
846851
alt struct(cx, ty) {
847852
ty_rec(_) { ret true; }

trunk/src/rt/rust_upcall.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,23 @@ upcall_new_task(rust_task *spawner, rust_vec *name) {
547547
return task;
548548
}
549549

550+
extern "C" CDECL void
551+
upcall_take_task(rust_task *task, rust_task *target) {
552+
LOG_UPCALL_ENTRY(task);
553+
if(target) {
554+
target->ref();
555+
}
556+
}
557+
558+
extern "C" CDECL void
559+
upcall_drop_task(rust_task *task, rust_task *target) {
560+
LOG_UPCALL_ENTRY(task);
561+
if(target) {
562+
//target->deref();
563+
--target->ref_count;
564+
}
565+
}
566+
550567
extern "C" CDECL rust_task *
551568
upcall_start_task(rust_task *spawner,
552569
rust_task *task,

trunk/src/rt/rustrt.def.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ upcall_chan_target_task
5959
upcall_clone_chan
6060
upcall_del_chan
6161
upcall_del_port
62+
upcall_drop_task
6263
upcall_dup_str
6364
upcall_exit
6465
upcall_fail
@@ -87,6 +88,7 @@ upcall_shared_malloc
8788
upcall_shared_free
8889
upcall_sleep
8990
upcall_start_task
91+
upcall_take_task
9092
upcall_trace_str
9193
upcall_trace_word
9294
upcall_vec_append

trunk/src/rt/sync/lock_and_signal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "lock_and_signal.h"
1111

1212
#if defined(__WIN32__)
13-
lock_and_signal::lock_and_signal()
13+
lock_and_signal::lock_and_signal()
1414
: alive(true)
1515
{
1616
// FIXME: In order to match the behavior of pthread_cond_broadcast on

0 commit comments

Comments
 (0)