Skip to content

Commit 9879982

Browse files
committed
---
yaml --- r: 44275 b: refs/heads/snap-stage3 c: f9f942b h: refs/heads/master i: 44273: 788ad93 44271: 94f84c7 v: v3
1 parent c4c1047 commit 9879982

File tree

233 files changed

+2295
-2208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+2295
-2208
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: 19dfec2aaf746535de1521f68421f9980dbf25de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: c4ef822dc7e4fcd05f9e4663e6f5c2196129d605
4+
refs/heads/snap-stage3: f9f942bb142a36ce4c94181ae8d7f8dcf4160700
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/tutorial-tasks.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ concurrently:
157157

158158
~~~~
159159
use task::spawn;
160-
use pipes::{stream, Port, Chan};
160+
use comm::{stream, Port, Chan};
161161
162162
let (port, chan): (Port<int>, Chan<int>) = stream();
163163
@@ -178,7 +178,7 @@ stream for sending and receiving integers (the left-hand side of the `let`,
178178
a tuple into its component parts).
179179

180180
~~~~
181-
# use pipes::{stream, Chan, Port};
181+
# use comm::{stream, Chan, Port};
182182
let (port, chan): (Port<int>, Chan<int>) = stream();
183183
~~~~
184184

@@ -189,7 +189,7 @@ spawns the child task.
189189
~~~~
190190
# use task::{spawn};
191191
# use task::spawn;
192-
# use pipes::{stream, Port, Chan};
192+
# use comm::{stream, Port, Chan};
193193
# fn some_expensive_computation() -> int { 42 }
194194
# let (port, chan) = stream();
195195
do spawn || {
@@ -209,7 +209,7 @@ computation, then waits for the child's result to arrive on the
209209
port:
210210

211211
~~~~
212-
# use pipes::{stream, Port, Chan};
212+
# use comm::{stream, Port, Chan};
213213
# fn some_other_expensive_computation() {}
214214
# let (port, chan) = stream::<int>();
215215
# chan.send(0);
@@ -225,7 +225,7 @@ following program is ill-typed:
225225

226226
~~~ {.xfail-test}
227227
# use task::{spawn};
228-
# use pipes::{stream, Port, Chan};
228+
# use comm::{stream, Port, Chan};
229229
# fn some_expensive_computation() -> int { 42 }
230230
let (port, chan) = stream();
231231
@@ -245,7 +245,7 @@ Instead we can use a `SharedChan`, a type that allows a single
245245

246246
~~~
247247
# use task::spawn;
248-
use pipes::{stream, SharedChan};
248+
use comm::{stream, SharedChan};
249249
250250
let (port, chan) = stream();
251251
let chan = SharedChan(chan);
@@ -278,7 +278,7 @@ might look like the example below.
278278

279279
~~~
280280
# use task::spawn;
281-
# use pipes::{stream, Port, Chan};
281+
# use comm::{stream, Port, Chan};
282282
283283
// Create a vector of ports, one for each child task
284284
let ports = do vec::from_fn(3) |init_val| {
@@ -393,7 +393,7 @@ internally, with additional logic to wait for the child task to finish
393393
before returning. Hence:
394394

395395
~~~
396-
# use pipes::{stream, Chan, Port};
396+
# use comm::{stream, Chan, Port};
397397
# use task::{spawn, try};
398398
# fn sleep_forever() { loop { task::yield() } }
399399
# do task::try {
@@ -468,7 +468,7 @@ Here is the function that implements the child task:
468468

469469
~~~~
470470
# use std::comm::DuplexStream;
471-
# use pipes::{Port, Chan};
471+
# use comm::{Port, Chan};
472472
fn stringifier(channel: &DuplexStream<~str, uint>) {
473473
let mut value: uint;
474474
loop {
@@ -491,7 +491,7 @@ Here is the code for the parent task:
491491

492492
~~~~
493493
# use std::comm::DuplexStream;
494-
# use pipes::{Port, Chan};
494+
# use comm::{Port, Chan};
495495
# use task::spawn;
496496
# fn stringifier(channel: &DuplexStream<~str, uint>) {
497497
# let mut value: uint;

branches/snap-stage3/src/compiletest/procsrv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn run(lib_path: ~str,
7676

7777

7878
writeclose(pipe_in.out, input);
79-
let p = pipes::PortSet();
79+
let p = comm::PortSet();
8080
let ch = p.chan();
8181
do task::spawn_sched(task::SingleThreaded) || {
8282
let errput = readclose(pipe_err.in);

branches/snap-stage3/src/etc/x86.supp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,13 @@
415415
...
416416
}
417417

418+
{
419+
enum-instruction-scheduling-8
420+
Memcheck:Cond
421+
fun:*should_set_output_format_to_markdown_if_requested*
422+
...
423+
}
424+
418425
{
419426
llvm-user-new-leak
420427
Memcheck:Leak

branches/snap-stage3/src/libcore/cleanup.rs

Lines changed: 81 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -111,45 +111,102 @@ struct Task {
111111
* This runs at task death to free all boxes.
112112
*/
113113

114+
struct AnnihilateStats {
115+
n_total_boxes: uint,
116+
n_unique_boxes: uint,
117+
n_bytes_freed: uint
118+
}
119+
120+
unsafe fn each_live_alloc(f: fn(box: *mut BoxRepr, uniq: bool) -> bool) {
121+
use managed;
122+
123+
let task: *Task = transmute(rustrt::rust_get_task());
124+
let box = (*task).boxed_region.live_allocs;
125+
let mut box: *mut BoxRepr = transmute(copy box);
126+
while box != mut_null() {
127+
let next = transmute(copy (*box).header.next);
128+
let uniq =
129+
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
130+
131+
if ! f(box, uniq) {
132+
break
133+
}
134+
135+
box = next
136+
}
137+
}
138+
139+
#[cfg(unix)]
140+
fn debug_mem() -> bool {
141+
use os;
142+
use libc;
143+
do os::as_c_charp("RUST_DEBUG_MEM") |p| {
144+
unsafe { libc::getenv(p) != null() }
145+
}
146+
}
147+
148+
#[cfg(windows)]
149+
fn debug_mem() -> bool {
150+
false
151+
}
152+
114153
/// Destroys all managed memory (i.e. @ boxes) held by the current task.
115154
#[cfg(notest)]
116155
#[lang="annihilate"]
117156
pub unsafe fn annihilate() {
118157
use rt::rt_free;
119158
use io::WriterUtil;
159+
use io;
160+
use libc;
161+
use sys;
162+
use managed;
120163

121-
let task: *Task = transmute(rustrt::rust_get_task());
164+
let mut stats = AnnihilateStats {
165+
n_total_boxes: 0,
166+
n_unique_boxes: 0,
167+
n_bytes_freed: 0
168+
};
122169

123170
// Pass 1: Make all boxes immortal.
124-
let box = (*task).boxed_region.live_allocs;
125-
let mut box: *mut BoxRepr = transmute(copy box);
126-
while box != mut_null() {
127-
debug!("making box immortal: %x", box as uint);
128-
(*box).header.ref_count = 0x77777777;
129-
box = transmute(copy (*box).header.next);
171+
for each_live_alloc |box, uniq| {
172+
stats.n_total_boxes += 1;
173+
if uniq {
174+
stats.n_unique_boxes += 1;
175+
} else {
176+
(*box).header.ref_count = managed::raw::RC_IMMORTAL;
177+
}
130178
}
131179

132180
// Pass 2: Drop all boxes.
133-
let box = (*task).boxed_region.live_allocs;
134-
let mut box: *mut BoxRepr = transmute(copy box);
135-
while box != mut_null() {
136-
debug!("calling drop glue for box: %x", box as uint);
137-
let tydesc: *TypeDesc = transmute(copy (*box).header.type_desc);
138-
let drop_glue: DropGlue = transmute(((*tydesc).drop_glue, 0));
139-
drop_glue(to_unsafe_ptr(&tydesc), transmute(&(*box).data));
140-
141-
box = transmute(copy (*box).header.next);
181+
for each_live_alloc |box, uniq| {
182+
if !uniq {
183+
let tydesc: *TypeDesc = transmute(copy (*box).header.type_desc);
184+
let drop_glue: DropGlue = transmute(((*tydesc).drop_glue, 0));
185+
drop_glue(to_unsafe_ptr(&tydesc), transmute(&(*box).data));
186+
}
142187
}
143188

144189
// Pass 3: Free all boxes.
145-
loop {
146-
let box = (*task).boxed_region.live_allocs;
147-
if box == null() { break; }
148-
let mut box: *mut BoxRepr = transmute(copy box);
149-
assert (*box).header.prev == null();
150-
151-
debug!("freeing box: %x", box as uint);
152-
rt_free(transmute(box));
190+
for each_live_alloc |box, uniq| {
191+
if !uniq {
192+
stats.n_bytes_freed +=
193+
(*((*box).header.type_desc)).size
194+
+ sys::size_of::<BoxRepr>();
195+
rt_free(transmute(box));
196+
}
197+
}
198+
199+
if debug_mem() {
200+
// We do logging here w/o allocation.
201+
let dbg = libc::STDERR_FILENO as io::fd_t;
202+
dbg.write_str("annihilator stats:");
203+
dbg.write_str("\n total_boxes: ");
204+
dbg.write_uint(stats.n_total_boxes);
205+
dbg.write_str("\n unique_boxes: ");
206+
dbg.write_uint(stats.n_unique_boxes);
207+
dbg.write_str("\n bytes_freed: ");
208+
dbg.write_uint(stats.n_bytes_freed);
209+
dbg.write_str("\n");
153210
}
154211
}
155212

0 commit comments

Comments
 (0)