Skip to content

Commit c4ff203

Browse files
committed
---
yaml --- r: 22470 b: refs/heads/master c: 5724c64 h: refs/heads/master v: v3
1 parent 672ff39 commit c4ff203

File tree

7 files changed

+24
-60
lines changed

7 files changed

+24
-60
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1c62f5ff74e8c6d434001d4571e5f28ae2705ed9
2+
refs/heads/master: 5724c6454950617c292daba89cdb9a3b4c862430
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/task.rs

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -591,21 +591,16 @@ class taskgroup {
591591
let my_pos: uint;
592592
// let parent_group: taskgroup_arc; // TODO(bblum)
593593
// TODO XXX bblum: add a list of empty slots to get runtime back
594-
// Indicates whether this is the main (root) taskgroup. If so, failure
595-
// here should take down the entire runtime.
596-
let is_main: bool;
597-
new(-tasks: taskgroup_arc, me: *rust_task, my_pos: uint, is_main: bool) {
598-
self.tasks = tasks;
599-
self.me = me;
600-
self.my_pos = my_pos;
601-
self.is_main = is_main;
594+
let mut failed: bool;
595+
new(-tasks: taskgroup_arc, me: *rust_task, my_pos: uint) {
596+
self.tasks = tasks; self.me = me; self.my_pos = my_pos;
597+
self.failed = true; // This will get un-set on successful exit.
602598
}
603599
// Runs on task exit.
604600
drop {
605-
// If we are failing, the whole taskgroup needs to die.
606-
if rustrt::rust_task_is_unwinding(self.me) {
601+
if self.failed {
607602
// Take everybody down with us.
608-
kill_taskgroup(self.tasks, self.me, self.my_pos, self.is_main);
603+
kill_taskgroup(self.tasks, self.me, self.my_pos);
609604
} else {
610605
// Remove ourselves from the group.
611606
leave_taskgroup(self.tasks, self.me, self.my_pos);
@@ -647,8 +642,7 @@ fn leave_taskgroup(group_arc: taskgroup_arc, me: *rust_task, index: uint) {
647642
}
648643

649644
// NB: Runs in destructor/post-exit context. Can't 'fail'.
650-
fn kill_taskgroup(group_arc: taskgroup_arc, me: *rust_task, index: uint,
651-
is_main: bool) {
645+
fn kill_taskgroup(group_arc: taskgroup_arc, me: *rust_task, index: uint) {
652646
// NB: We could do the killing iteration outside of the group arc, by
653647
// having "let mut newstate" here, swapping inside, and iterating after.
654648
// But that would let other exiting tasks fall-through and exit while we
@@ -673,40 +667,32 @@ fn kill_taskgroup(group_arc: taskgroup_arc, me: *rust_task, index: uint,
673667
rustrt::rust_task_kill_other(task);
674668
};
675669
}
676-
// Only one task should ever do this.
677-
if is_main {
678-
rustrt::rust_task_kill_all(me);
679-
}
680670
};
681-
// (note: multiple tasks may reach this point)
682671
};
683672
}
684673

685-
fn share_parent_taskgroup() -> (taskgroup_arc, bool) {
674+
fn share_parent_taskgroup() -> taskgroup_arc {
686675
let me = rustrt::rust_get_task();
687676
alt unsafe { local_get(me, taskgroup_key) } {
688677
some(group) {
689-
// Clone the shared state for the child; propagate main-ness.
690-
(group.tasks.clone(), group.is_main)
678+
group.tasks.clone()
691679
}
692680
none {
693-
// Main task, doing first spawn ever.
681+
/* Main task, doing first spawn ever. */
694682
let tasks = arc::exclusive(some(dvec::from_elem(some(me))));
695-
let group = @taskgroup(tasks.clone(), me, 0, true);
683+
let group = @taskgroup(tasks.clone(), me, 0);
696684
unsafe { local_set(me, taskgroup_key, group); }
697-
// Tell child task it's also in the main group.
698-
(tasks, true)
685+
tasks
699686
}
700687
}
701688
}
702689

703690
fn spawn_raw(opts: task_opts, +f: fn~()) {
704691
// Decide whether the child needs to be in a new linked failure group.
705-
let (child_tg, is_main) = if opts.supervise {
692+
let child_tg: taskgroup_arc = if opts.supervise {
706693
share_parent_taskgroup()
707694
} else {
708-
// Detached from the parent group; create a new (non-main) one.
709-
(arc::exclusive(some(dvec::from_elem(none))), false)
695+
arc::exclusive(some(dvec::from_elem(none)))
710696
};
711697

712698
unsafe {
@@ -726,8 +712,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) {
726712
// Getting killed after here would leak the task.
727713

728714
let child_wrapper =
729-
make_child_wrapper(new_task, child_tg,
730-
opts.supervise, is_main, f);
715+
make_child_wrapper(new_task, child_tg, opts.supervise, f);
731716
let fptr = ptr::addr_of(child_wrapper);
732717
let closure: *rust_closure = unsafe::reinterpret_cast(fptr);
733718

@@ -745,8 +730,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) {
745730
}
746731

747732
fn make_child_wrapper(child_task: *rust_task, -child_tg: taskgroup_arc,
748-
supervise: bool, is_main: bool,
749-
-f: fn~()) -> fn~() {
733+
supervise: bool, -f: fn~()) -> fn~() {
750734
let child_tg_ptr = ~mut some(child_tg);
751735
fn~() {
752736
// Agh. Get move-mode items into the closure. FIXME (#2829)
@@ -762,12 +746,13 @@ fn spawn_raw(opts: task_opts, +f: fn~()) {
762746
// parent was already failing, so don't bother doing anything.
763747
alt enlist_in_taskgroup(child_tg, child_task) {
764748
some(my_index) {
765-
let group =
766-
@taskgroup(child_tg, child_task, my_index, is_main);
749+
let group = @taskgroup(child_tg, child_task, my_index);
767750
unsafe { local_set(child_task, taskgroup_key, group); }
768751
// Run the child's body.
769752
f();
770-
// TLS cleanup code will exit the taskgroup.
753+
// Report successful exit. (TLS cleanup code will tear
754+
// down the group.)
755+
group.failed = false;
771756
}
772757
none { }
773758
}
@@ -1021,7 +1006,6 @@ extern mod rustrt {
10211006
fn rust_task_inhibit_kill();
10221007
fn rust_task_allow_kill();
10231008
fn rust_task_kill_other(task: *rust_task);
1024-
fn rust_task_kill_all(task: *rust_task);
10251009

10261010
#[rust_stack]
10271011
fn rust_get_task_local_data(task: *rust_task) -> *libc::c_void;

trunk/src/rt/rust_builtin.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -863,11 +863,6 @@ rust_task_kill_other(rust_task *task) { /* Used for linked failure */
863863
task->kill();
864864
}
865865

866-
extern "C" void
867-
rust_task_kill_all(rust_task *task) {
868-
task->fail_sched_loop();
869-
}
870-
871866
extern "C" rust_cond_lock*
872867
rust_create_cond_lock() {
873868
return new rust_cond_lock();

trunk/src/rt/rust_sched_loop.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ rust_task *
260260
rust_sched_loop::create_task(rust_task *spawner, const char *name) {
261261
rust_task *task =
262262
new (this->kernel, "rust_task")
263-
rust_task(this, task_state_newborn,
264-
spawner, name, kernel->env->min_stack_size);
263+
rust_task (this, task_state_newborn,
264+
spawner, name, kernel->env->min_stack_size);
265265
DLOG(this, task, "created task: " PTR ", spawner: %s, name: %s",
266266
task, spawner ? spawner->name : "null", name);
267267

trunk/src/rt/rust_task.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ cleanup_task(cleanup_args *args) {
129129
// assert(task->task_local_data != NULL);
130130
task->task_local_data_cleanup(task->task_local_data);
131131
task->task_local_data = NULL;
132-
} else if (threw_exception) {
133-
// Edge case: If main never spawns any tasks, but fails anyway, TLS
134-
// won't be around to take down the kernel (task.rs:kill_taskgroup,
135-
// rust_task_kill_all). Do it here instead.
136-
task->fail_sched_loop();
137132
}
138133

139134
// FIXME (#2676): For performance we should do the annihilator
@@ -287,7 +282,6 @@ rust_task::kill() {
287282
LOG(this, task, "preparing to unwind task: 0x%" PRIxPTR, this);
288283
}
289284

290-
// TODO(bblum): Move this to rust_builtin.cpp (cleanup)
291285
extern "C" CDECL
292286
bool rust_task_is_unwinding(rust_task *rt) {
293287
return rt->unwinding;
@@ -321,12 +315,8 @@ rust_task::begin_failure(char const *expr, char const *file, size_t line) {
321315
#else
322316
die();
323317
// FIXME (#908): Need unwinding on windows. This will end up aborting
324-
fail_sched_loop();
325-
#endif
326-
}
327-
328-
void rust_task::fail_sched_loop() {
329318
sched_loop->fail();
319+
#endif
330320
}
331321

332322
void

trunk/src/rt/rust_task.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,6 @@ rust_task : public kernel_owned<rust_task>
275275
void fail();
276276
void fail(char const *expr, char const *file, size_t line);
277277

278-
// Propagate failure to the entire rust runtime.
279-
// TODO(bblum): maybe this can be done at rust-level?
280-
void fail_sched_loop();
281-
282278
// Disconnect from our supervisor.
283279
void unsupervise();
284280

trunk/src/rt/rustrt.def.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ rust_port_task
178178
rust_task_inhibit_kill
179179
rust_task_allow_kill
180180
rust_task_kill_other
181-
rust_task_kill_all
182181
rust_create_cond_lock
183182
rust_destroy_cond_lock
184183
rust_lock_cond_lock

0 commit comments

Comments
 (0)