Skip to content

Commit 02dfe16

Browse files
committed
---
yaml --- r: 64913 b: refs/heads/snap-stage3 c: 66a0b58 h: refs/heads/master i: 64911: f77e699 v: v3
1 parent b6abcc3 commit 02dfe16

File tree

12 files changed

+87
-144
lines changed

12 files changed

+87
-144
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: bc7cee7bbf816be7a712c06a93015dc3c6fd5611
4+
refs/heads/snap-stage3: 66a0b5870d7c1c436b197d744fba5ced2e5f6462
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/configure

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ opt docs 1 "build documentation"
371371
opt optimize 1 "build optimized rust code"
372372
opt optimize-cxx 1 "build optimized C++ code"
373373
opt optimize-llvm 1 "build optimized LLVM"
374+
opt llvm-assertions 1 "build LLVM with assertions"
374375
opt debug 0 "build with extra debug fun"
375376
opt ratchet-bench 0 "ratchet benchmarks"
376377
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
@@ -793,10 +794,17 @@ do
793794
LLVM_DBG_OPTS="--enable-debug-symbols --disable-optimized"
794795
# Just use LLVM straight from its build directory to
795796
# avoid 'make install' time
796-
LLVM_INST_DIR=$LLVM_BUILD_DIR/Debug+Asserts
797+
LLVM_INST_DIR=$LLVM_BUILD_DIR/Debug
797798
else
798799
LLVM_DBG_OPTS="--enable-optimized"
799-
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release+Asserts
800+
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release
801+
fi
802+
if [ ! -z "$CFG_DISABLE_LLVM_ASSERTIONS" ]
803+
then
804+
LLVM_ASSERTION_OPTS="--disable-assertions"
805+
else
806+
LLVM_ASSERTION_OPTS="--enable-assertions"
807+
LLVM_INST_DIR=${LLVM_INST_DIR}+Asserts
800808
fi
801809
else
802810
msg "not reconfiguring LLVM, external LLVM root"
@@ -836,7 +844,7 @@ do
836844
LLVM_TARGET="--target=$t"
837845

838846
# Disable unused LLVM features
839-
LLVM_OPTS="$LLVM_DBG_OPTS --disable-docs --enable-bindings=none"
847+
LLVM_OPTS="$LLVM_DBG_OPTS $LLVM_ASSERTION_OPTS --disable-docs --enable-bindings=none"
840848

841849
case "$CFG_C_COMPILER" in
842850
("ccache clang")

branches/snap-stage3/src/libstd/rt/kill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub struct Death {
8484
on_exit: Option<~fn(bool)>,
8585
// nesting level counter for task::unkillable calls (0 == killable).
8686
unkillable: int,
87-
// nesting level counter for unstable::atomically calls (0 == can yield).
87+
// nesting level counter for task::atomically calls (0 == can yield).
8888
wont_sleep: int,
8989
// A "spare" handle to the kill flag inside the kill handle. Used during
9090
// blocking/waking as an optimization to avoid two xadds on the refcount.

branches/snap-stage3/src/libstd/rt/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,12 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
316316
// Just put an unpinned task onto one of the default schedulers.
317317
let mut main_task = ~Task::new_root(&mut scheds[0].stack_pool, main);
318318
main_task.death.on_exit = Some(on_exit);
319-
main_task.name = Some(~"main");
320319
scheds[0].enqueue_task(main_task);
321320
}
322321
Some(ref mut main_sched) => {
323322
let home = Sched(main_sched.make_handle());
324323
let mut main_task = ~Task::new_root_homed(&mut scheds[0].stack_pool, home, main);
325324
main_task.death.on_exit = Some(on_exit);
326-
main_task.name = Some(~"main");
327325
main_sched.enqueue_task(main_task);
328326
}
329327
};

branches/snap-stage3/src/libstd/rt/task.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ pub struct Task {
4040
taskgroup: Option<Taskgroup>,
4141
death: Death,
4242
destroyed: bool,
43-
coroutine: Option<~Coroutine>,
44-
// FIXME(#6874/#7599) use StringRef to save on allocations
45-
name: Option<~str>,
43+
coroutine: Option<~Coroutine>
4644
}
4745

4846
pub struct Coroutine {
@@ -92,8 +90,7 @@ impl Task {
9290
taskgroup: None,
9391
death: Death::new(),
9492
destroyed: false,
95-
coroutine: Some(~Coroutine::new(stack_pool, start)),
96-
name: None,
93+
coroutine: Some(~Coroutine::new(stack_pool, start))
9794
}
9895
}
9996

@@ -112,8 +109,7 @@ impl Task {
112109
// FIXME(#7544) make watching optional
113110
death: self.death.new_child(),
114111
destroyed: false,
115-
coroutine: Some(~Coroutine::new(stack_pool, start)),
116-
name: None,
112+
coroutine: Some(~Coroutine::new(stack_pool, start))
117113
}
118114
}
119115

branches/snap-stage3/src/libstd/sys.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,12 @@ impl FailWithCause for &'static str {
137137

138138
// FIXME #4427: Temporary until rt::rt_fail_ goes away
139139
pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
140+
use cell::Cell;
140141
use either::Left;
141-
use option::{Some, None};
142142
use rt::{context, OldTaskContext, TaskContext};
143143
use rt::task::Task;
144144
use rt::local::Local;
145145
use rt::logging::Logger;
146-
use str::Str;
147146

148147
let context = context();
149148
match context {
@@ -160,26 +159,20 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
160159
let msg = str::raw::from_c_str(msg);
161160
let file = str::raw::from_c_str(file);
162161

162+
let outmsg = fmt!("task failed at '%s', %s:%i",
163+
msg, file, line as int);
164+
163165
// XXX: Logging doesn't work correctly in non-task context because it
164166
// invokes the local heap
165167
if context == TaskContext {
166168
// XXX: Logging doesn't work here - the check to call the log
167169
// function never passes - so calling the log function directly.
170+
let outmsg = Cell::new(outmsg);
168171
do Local::borrow::<Task, ()> |task| {
169-
let msg = match task.name {
170-
Some(ref name) =>
171-
fmt!("task '%s' failed at '%s', %s:%i",
172-
name.as_slice(), msg, file, line as int),
173-
None =>
174-
fmt!("task <unnamed> failed at '%s', %s:%i",
175-
msg, file, line as int)
176-
};
177-
178-
task.logger.log(Left(msg));
172+
task.logger.log(Left(outmsg.take()));
179173
}
180174
} else {
181-
rterrln!("failed in non-task context at '%s', %s:%i",
182-
msg, file, line as int);
175+
rterrln!("%s", outmsg);
183176
}
184177

185178
gc::cleanup_stack_for_failure();

branches/snap-stage3/src/libstd/task/mod.rs

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ pub struct SchedOpts {
120120
*
121121
* * notify_chan - Enable lifecycle notifications on the given channel
122122
*
123-
* * name - A name for the task-to-be, for identification in failure messages.
124-
*
125123
* * sched - Specify the configuration of a new scheduler to create the task
126124
* in
127125
*
@@ -141,7 +139,6 @@ pub struct TaskOpts {
141139
watched: bool,
142140
indestructible: bool,
143141
notify_chan: Option<Chan<TaskResult>>,
144-
name: Option<~str>,
145142
sched: SchedOpts
146143
}
147144

@@ -188,23 +185,23 @@ impl TaskBuilder {
188185
self.consumed = true;
189186
let gen_body = self.gen_body.take();
190187
let notify_chan = self.opts.notify_chan.take();
191-
let name = self.opts.name.take();
192188
TaskBuilder {
193189
opts: TaskOpts {
194190
linked: self.opts.linked,
195191
supervised: self.opts.supervised,
196192
watched: self.opts.watched,
197193
indestructible: self.opts.indestructible,
198194
notify_chan: notify_chan,
199-
name: name,
200195
sched: self.opts.sched
201196
},
202197
gen_body: gen_body,
203198
can_not_copy: None,
204199
consumed: false
205200
}
206201
}
202+
}
207203

204+
impl TaskBuilder {
208205
/// Decouple the child task's failure from the parent's. If either fails,
209206
/// the other will not be killed.
210207
pub fn unlinked(&mut self) {
@@ -284,12 +281,6 @@ impl TaskBuilder {
284281
self.opts.notify_chan = Some(notify_pipe_ch);
285282
}
286283

287-
/// Name the task-to-be. Currently the name is used for identification
288-
/// only in failure messages.
289-
pub fn name(&mut self, name: ~str) {
290-
self.opts.name = Some(name);
291-
}
292-
293284
/// Configure a custom scheduler mode for the task.
294285
pub fn sched_mode(&mut self, mode: SchedMode) {
295286
self.opts.sched.mode = mode;
@@ -342,15 +333,13 @@ impl TaskBuilder {
342333
pub fn spawn(&mut self, f: ~fn()) {
343334
let gen_body = self.gen_body.take();
344335
let notify_chan = self.opts.notify_chan.take();
345-
let name = self.opts.name.take();
346336
let x = self.consume();
347337
let opts = TaskOpts {
348338
linked: x.opts.linked,
349339
supervised: x.opts.supervised,
350340
watched: x.opts.watched,
351341
indestructible: x.opts.indestructible,
352342
notify_chan: notify_chan,
353-
name: name,
354343
sched: x.opts.sched
355344
};
356345
let f = match gen_body {
@@ -419,7 +408,6 @@ pub fn default_task_opts() -> TaskOpts {
419408
watched: true,
420409
indestructible: false,
421410
notify_chan: None,
422-
name: None,
423411
sched: SchedOpts {
424412
mode: DefaultScheduler,
425413
}
@@ -519,21 +507,6 @@ pub fn try<T:Send>(f: ~fn() -> T) -> Result<T,()> {
519507

520508
/* Lifecycle functions */
521509

522-
/// Read the name of the current task.
523-
pub fn with_task_name<U>(blk: &fn(Option<&str>) -> U) -> U {
524-
use rt::task::Task;
525-
526-
match context() {
527-
TaskContext => do Local::borrow::<Task, U> |task| {
528-
match task.name {
529-
Some(ref name) => blk(Some(name.as_slice())),
530-
None => blk(None)
531-
}
532-
},
533-
_ => fail!("no task name exists in %?", context()),
534-
}
535-
}
536-
537510
pub fn yield() {
538511
//! Yield control to the task scheduler
539512
@@ -655,6 +628,44 @@ pub unsafe fn rekillable<U>(f: &fn() -> U) -> U {
655628
}
656629
}
657630

631+
/**
632+
* A stronger version of unkillable that also inhibits scheduling operations.
633+
* For use with exclusive Arcs, which use pthread mutexes directly.
634+
*/
635+
pub unsafe fn atomically<U>(f: &fn() -> U) -> U {
636+
use rt::task::Task;
637+
638+
match context() {
639+
OldTaskContext => {
640+
let t = rt::rust_get_task();
641+
do (|| {
642+
rt::rust_task_inhibit_kill(t);
643+
rt::rust_task_inhibit_yield(t);
644+
f()
645+
}).finally {
646+
rt::rust_task_allow_yield(t);
647+
rt::rust_task_allow_kill(t);
648+
}
649+
}
650+
TaskContext => {
651+
let t = Local::unsafe_borrow::<Task>();
652+
do (|| {
653+
// It's important to inhibit kill after inhibiting yield, because
654+
// inhibit-kill might fail if we were already killed, and the
655+
// inhibit-yield must happen to match the finally's allow-yield.
656+
(*t).death.inhibit_yield();
657+
(*t).death.inhibit_kill((*t).unwinder.unwinding);
658+
f()
659+
}).finally {
660+
(*t).death.allow_kill((*t).unwinder.unwinding);
661+
(*t).death.allow_yield();
662+
}
663+
}
664+
// FIXME(#3095): As in unkillable().
665+
_ => f()
666+
}
667+
}
668+
658669
#[test] #[should_fail] #[ignore(cfg(windows))]
659670
fn test_cant_dup_task_builder() {
660671
let mut builder = task();
@@ -794,34 +805,6 @@ fn test_spawn_linked_sup_propagate_sibling() {
794805
fail!();
795806
}
796807

797-
#[test]
798-
fn test_unnamed_task() {
799-
use rt::test::run_in_newsched_task;
800-
801-
do run_in_newsched_task {
802-
do spawn {
803-
do with_task_name |name| {
804-
assert!(name.is_none());
805-
}
806-
}
807-
}
808-
}
809-
810-
#[test]
811-
fn test_named_task() {
812-
use rt::test::run_in_newsched_task;
813-
814-
do run_in_newsched_task {
815-
let mut t = task();
816-
t.name(~"ada lovelace");
817-
do t.spawn {
818-
do with_task_name |name| {
819-
assert!(name.get() == "ada lovelace");
820-
}
821-
}
822-
}
823-
}
824-
825808
#[test]
826809
fn test_run_basic() {
827810
let (po, ch) = stream::<()>();
@@ -1139,6 +1122,21 @@ fn test_unkillable_nested() {
11391122
po.recv();
11401123
}
11411124

1125+
#[test] #[should_fail] #[ignore(cfg(windows))]
1126+
fn test_atomically() {
1127+
unsafe { do atomically { yield(); } }
1128+
}
1129+
1130+
#[test]
1131+
fn test_atomically2() {
1132+
unsafe { do atomically { } } yield(); // shouldn't fail
1133+
}
1134+
1135+
#[test] #[should_fail] #[ignore(cfg(windows))]
1136+
fn test_atomically_nested() {
1137+
unsafe { do atomically { do atomically { } yield(); } }
1138+
}
1139+
11421140
#[test]
11431141
fn test_child_doesnt_ref_parent() {
11441142
// If the child refcounts the parent task, this will stack overflow when

branches/snap-stage3/src/libstd/task/spawn.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,6 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) {
726726
task.death.on_exit = Some(on_exit);
727727
}
728728

729-
task.name = opts.name.take();
730-
731729
rtdebug!("spawn about to take scheduler");
732730

733731
let sched = Local::take::<Scheduler>();

branches/snap-stage3/src/libstd/unstable/dynamic_lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ mod dl {
105105
use path;
106106
use ptr;
107107
use str;
108-
use unstable::sync::atomically;
108+
use task;
109109
use result::*;
110110

111111
pub unsafe fn open_external(filename: &path::Path) -> *libc::c_void {
@@ -120,7 +120,7 @@ mod dl {
120120

121121
pub fn check_for_errors_in<T>(f: &fn()->T) -> Result<T, ~str> {
122122
unsafe {
123-
do atomically {
123+
do task::atomically {
124124
let _old_error = dlerror();
125125

126126
let result = f();
@@ -164,7 +164,7 @@ mod dl {
164164
use libc;
165165
use path;
166166
use ptr;
167-
use unstable::sync::atomically;
167+
use task;
168168
use result::*;
169169

170170
pub unsafe fn open_external(filename: &path::Path) -> *libc::c_void {
@@ -181,7 +181,7 @@ mod dl {
181181

182182
pub fn check_for_errors_in<T>(f: &fn()->T) -> Result<T, ~str> {
183183
unsafe {
184-
do atomically {
184+
do task::atomically {
185185
SetLastError(0);
186186

187187
let result = f();

0 commit comments

Comments
 (0)