Skip to content

Commit f6c8d2b

Browse files
committed
---
yaml --- r: 152875 b: refs/heads/try2 c: deb6b04 h: refs/heads/master i: 152873: 1dd640c 152871: 6b1fce2 v: v3
1 parent a65f887 commit f6c8d2b

File tree

13 files changed

+376
-121
lines changed

13 files changed

+376
-121
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: dfef4220242227fb210e58eedc91bcc74de8921f
8+
refs/heads/try2: deb6b04e91e9046b80f2ad7552d4aaf41fa78622
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libgreen/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ pub fn start(argc: int, argv: **u8,
299299
let mut ret = None;
300300
simple::task().run(|| {
301301
ret = Some(run(event_loop_factory, main.take_unwrap()));
302-
});
302+
}).destroy();
303303
// unsafe is ok b/c we're sure that the runtime is gone
304304
unsafe { rt::cleanup() }
305305
ret.unwrap()

branches/try2/src/libgreen/task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ extern fn bootstrap_green_task(task: uint, code: *(), env: *()) -> ! {
110110
// requested. This is the "try/catch" block for this green task and
111111
// is the wrapper for *all* code run in the task.
112112
let mut start = Some(start);
113-
let task = task.swap().run(|| start.take_unwrap()());
113+
let task = task.swap().run(|| start.take_unwrap()()).destroy();
114114

115115
// Once the function has exited, it's time to run the termination
116116
// routine. This means we need to context switch one more time but
@@ -120,7 +120,7 @@ extern fn bootstrap_green_task(task: uint, code: *(), env: *()) -> ! {
120120
// this we could add a `terminate` function to the `Runtime` trait
121121
// in libstd, but that seems less appropriate since the coversion
122122
// method exists.
123-
GreenTask::convert(task).terminate()
123+
GreenTask::convert(task).terminate();
124124
}
125125

126126
impl GreenTask {

branches/try2/src/libnative/io/process.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,10 @@ fn spawn_process_os(cfg: ProcessConfig,
533533

534534
let dirp = cfg.cwd.map(|c| c.with_ref(|p| p)).unwrap_or(ptr::null());
535535

536+
let cfg = unsafe {
537+
mem::transmute::<ProcessConfig,ProcessConfig<'static>>(cfg)
538+
};
539+
536540
with_envp(cfg.env, proc(envp) {
537541
with_argv(cfg.program, cfg.args, proc(argv) unsafe {
538542
let (mut input, mut output) = try!(pipe());

branches/try2/src/libnative/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,12 @@ pub fn start(argc: int, argv: **u8, main: proc()) -> int {
134134
let mut main = Some(main);
135135
let mut task = task::new((my_stack_bottom, my_stack_top));
136136
task.name = Some(str::Slice("<main>"));
137-
let t = task.run(|| {
137+
drop(task.run(|| {
138138
unsafe {
139139
rt::stack::record_stack_bounds(my_stack_bottom, my_stack_top);
140140
}
141141
exit_code = Some(run(main.take_unwrap()));
142-
});
143-
drop(t);
142+
}).destroy());
144143
unsafe { rt::cleanup(); }
145144
// If the exit code wasn't set, then the task block must have failed.
146145
return exit_code.unwrap_or(rt::DEFAULT_ERROR_CODE);

branches/try2/src/libnative/task.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ pub fn spawn_opts(opts: TaskOpts, f: proc():Send) {
9292
let mut f = Some(f);
9393
let mut task = task;
9494
task.put_runtime(ops);
95-
let t = task.run(|| { f.take_unwrap()() });
96-
drop(t);
95+
drop(task.run(|| { f.take_unwrap()() }).destroy());
9796
bookkeeping::decrement();
9897
})
9998
}

branches/try2/src/librustc/middle/kind.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,14 @@ fn with_appropriate_checker(cx: &Context,
198198
let fty = ty::node_id_to_type(cx.tcx, id);
199199
match ty::get(fty).sty {
200200
ty::ty_closure(box ty::ClosureTy {
201-
store: ty::UniqTraitStore, bounds, ..
202-
}) => b(|cx, fv| check_for_uniq(cx, fv, bounds)),
201+
store: ty::UniqTraitStore,
202+
bounds: mut bounds, ..
203+
}) => {
204+
// Procs can't close over non-static references!
205+
bounds.add(ty::BoundStatic);
206+
207+
b(|cx, fv| check_for_uniq(cx, fv, bounds))
208+
}
203209

204210
ty::ty_closure(box ty::ClosureTy {
205211
store: ty::RegionTraitStore(region, _), bounds, ..

branches/try2/src/librustrt/local_heap.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ impl LocalHeap {
110110
self.memory_region.free(alloc);
111111
}
112112

113-
pub unsafe fn annihilate(&mut self) {
113+
/// Immortalize all pending allocations, forcing them to live forever.
114+
///
115+
/// This function will freeze all allocations to prevent all pending
116+
/// allocations from being deallocated. This is used in preparation for when
117+
/// a task is about to destroy TLD.
118+
pub unsafe fn immortalize(&mut self) {
114119
let mut n_total_boxes = 0u;
115120

116121
// Pass 1: Make all boxes immortal.
@@ -122,6 +127,17 @@ impl LocalHeap {
122127
(*alloc).ref_count = RC_IMMORTAL;
123128
});
124129

130+
if debug_mem() {
131+
// We do logging here w/o allocation.
132+
rterrln!("total boxes annihilated: {}", n_total_boxes);
133+
}
134+
}
135+
136+
/// Continues deallocation of the all pending allocations in this arena.
137+
///
138+
/// This is invoked from the destructor, and requires that `immortalize` has
139+
/// been called previously.
140+
unsafe fn annihilate(&mut self) {
125141
// Pass 2: Drop all boxes.
126142
//
127143
// In this pass, unique-managed boxes may get freed, but not
@@ -142,11 +158,6 @@ impl LocalHeap {
142158
self.each_live_alloc(true, |me, alloc| {
143159
me.free(alloc);
144160
});
145-
146-
if debug_mem() {
147-
// We do logging here w/o allocation.
148-
rterrln!("total boxes annihilated: {}", n_total_boxes);
149-
}
150161
}
151162

152163
unsafe fn each_live_alloc(&mut self, read_next_before: bool,
@@ -170,6 +181,7 @@ impl LocalHeap {
170181

171182
impl Drop for LocalHeap {
172183
fn drop(&mut self) {
184+
unsafe { self.annihilate() }
173185
assert!(self.live_allocs.is_null());
174186
}
175187
}

0 commit comments

Comments
 (0)