Skip to content

Commit ed35ab9

Browse files
committed
---
yaml --- r: 138455 b: refs/heads/try2 c: 4a85389 h: refs/heads/master i: 138453: 6aeb685 138451: 66b5b76 138447: 779a5aa v: v3
1 parent 279dd65 commit ed35ab9

34 files changed

+687
-756
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: 2f12e26d06ac106c54b293f0125d2c9319ac4191
8+
refs/heads/try2: 4a853894fab6b9a4b60c1b3260b446a3473577fa
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/cleanup.rs

Lines changed: 24 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -111,102 +111,45 @@ 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-
153114
/// Destroys all managed memory (i.e. @ boxes) held by the current task.
154115
#[cfg(notest)]
155116
#[lang="annihilate"]
156117
pub unsafe fn annihilate() {
157118
use rt::rt_free;
158119
use io::WriterUtil;
159-
use io;
160-
use libc;
161-
use sys;
162-
use managed;
163120

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

170123
// Pass 1: Make all boxes immortal.
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-
}
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);
178130
}
179131

180132
// Pass 2: Drop all boxes.
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-
}
187-
}
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));
188140

189-
// Pass 3: Free all boxes.
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-
}
141+
box = transmute(copy (*box).header.next);
197142
}
198143

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");
144+
// 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));
210153
}
211154
}
212155

branches/try2/src/libcore/managed.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ use managed::raw::BoxRepr;
1616
use prelude::*;
1717
use ptr;
1818

19-
2019
pub mod raw {
21-
22-
pub const RC_EXCHANGE_UNIQUE : uint = (-1) as uint;
23-
pub const RC_MANAGED_UNIQUE : uint = (-2) as uint;
24-
pub const RC_IMMORTAL : uint = 0x77777777;
25-
2620
use intrinsic::TyDesc;
2721

2822
pub struct BoxHeaderRepr {

branches/try2/src/libcore/vec.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -31,14 +31,9 @@ use vec;
3131

3232
#[abi = "cdecl"]
3333
pub extern mod rustrt {
34-
// These names are terrible. reserve_shared applies
35-
// to ~[] and reserve_shared_actual applies to @[].
3634
unsafe fn vec_reserve_shared(++t: *sys::TypeDesc,
3735
++v: **raw::VecRepr,
3836
++n: libc::size_t);
39-
unsafe fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
40-
++v: **raw::VecRepr,
41-
++n: libc::size_t);
4237
}
4338

4439
/// Returns true if a vector contains no elements
@@ -64,17 +59,11 @@ pub pure fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool {
6459
*/
6560
pub fn reserve<T>(v: &mut ~[T], n: uint) {
6661
// Only make the (slow) call into the runtime if we have to
67-
use managed;
6862
if capacity(v) < n {
6963
unsafe {
7064
let ptr: **raw::VecRepr = cast::transmute(v);
71-
let td = sys::get_type_desc::<T>();
72-
if ((**ptr).box_header.ref_count ==
73-
managed::raw::RC_MANAGED_UNIQUE) {
74-
rustrt::vec_reserve_shared_actual(td, ptr, n as size_t);
75-
} else {
76-
rustrt::vec_reserve_shared(td, ptr, n as size_t);
77-
}
65+
rustrt::vec_reserve_shared(sys::get_type_desc::<T>(),
66+
ptr, n as size_t);
7867
}
7968
}
8069
}

branches/try2/src/librustc/driver/session.rs

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -165,49 +165,49 @@ pub struct Session_ {
165165
pub type Session = @Session_;
166166

167167
pub impl Session {
168-
fn span_fatal(sp: span, msg: ~str) -> ! {
168+
fn span_fatal(&self, sp: span, msg: ~str) -> ! {
169169
self.span_diagnostic.span_fatal(sp, msg)
170170
}
171-
fn fatal(msg: ~str) -> ! {
171+
fn fatal(&self, msg: ~str) -> ! {
172172
self.span_diagnostic.handler().fatal(msg)
173173
}
174-
fn span_err(sp: span, msg: ~str) {
174+
fn span_err(&self, sp: span, msg: ~str) {
175175
self.span_diagnostic.span_err(sp, msg)
176176
}
177-
fn err(msg: ~str) {
177+
fn err(&self, msg: ~str) {
178178
self.span_diagnostic.handler().err(msg)
179179
}
180-
fn has_errors() -> bool {
180+
fn has_errors(&self) -> bool {
181181
self.span_diagnostic.handler().has_errors()
182182
}
183-
fn abort_if_errors() {
183+
fn abort_if_errors(&self) {
184184
self.span_diagnostic.handler().abort_if_errors()
185185
}
186-
fn span_warn(sp: span, msg: ~str) {
186+
fn span_warn(&self, sp: span, msg: ~str) {
187187
self.span_diagnostic.span_warn(sp, msg)
188188
}
189-
fn warn(msg: ~str) {
189+
fn warn(&self, msg: ~str) {
190190
self.span_diagnostic.handler().warn(msg)
191191
}
192-
fn span_note(sp: span, msg: ~str) {
192+
fn span_note(&self, sp: span, msg: ~str) {
193193
self.span_diagnostic.span_note(sp, msg)
194194
}
195-
fn note(msg: ~str) {
195+
fn note(&self, msg: ~str) {
196196
self.span_diagnostic.handler().note(msg)
197197
}
198-
fn span_bug(sp: span, msg: ~str) -> ! {
198+
fn span_bug(&self, sp: span, msg: ~str) -> ! {
199199
self.span_diagnostic.span_bug(sp, msg)
200200
}
201-
fn bug(msg: ~str) -> ! {
201+
fn bug(&self, msg: ~str) -> ! {
202202
self.span_diagnostic.handler().bug(msg)
203203
}
204-
fn span_unimpl(sp: span, msg: ~str) -> ! {
204+
fn span_unimpl(&self, sp: span, msg: ~str) -> ! {
205205
self.span_diagnostic.span_unimpl(sp, msg)
206206
}
207-
fn unimpl(msg: ~str) -> ! {
207+
fn unimpl(&self, msg: ~str) -> ! {
208208
self.span_diagnostic.handler().unimpl(msg)
209209
}
210-
fn span_lint_level(level: lint::level, sp: span, +msg: ~str) {
210+
fn span_lint_level(&self, level: lint::level, sp: span, +msg: ~str) {
211211
match level {
212212
lint::allow => { },
213213
lint::warn => self.span_warn(sp, msg),
@@ -216,7 +216,7 @@ pub impl Session {
216216
}
217217
}
218218
}
219-
fn span_lint(lint_mode: lint::lint,
219+
fn span_lint(&self, lint_mode: lint::lint,
220220
expr_id: ast::node_id,
221221
item_id: ast::node_id,
222222
span: span,
@@ -225,45 +225,55 @@ pub impl Session {
225225
self.lint_settings, lint_mode, expr_id, item_id);
226226
self.span_lint_level(level, span, msg);
227227
}
228-
fn next_node_id() -> ast::node_id {
228+
fn next_node_id(&self) -> ast::node_id {
229229
return syntax::parse::next_node_id(self.parse_sess);
230230
}
231-
fn diagnostic() -> diagnostic::span_handler {
231+
fn diagnostic(&self) -> diagnostic::span_handler {
232232
self.span_diagnostic
233233
}
234-
fn debugging_opt(opt: uint) -> bool {
234+
fn debugging_opt(&self, opt: uint) -> bool {
235235
(self.opts.debugging_opts & opt) != 0u
236236
}
237237
// This exists to help with refactoring to eliminate impossible
238238
// cases later on
239-
fn impossible_case(sp: span, msg: &str) -> ! {
239+
fn impossible_case(&self, sp: span, msg: &str) -> ! {
240240
self.span_bug(sp, fmt!("Impossible case reached: %s", msg));
241241
}
242-
fn verbose() -> bool { self.debugging_opt(verbose) }
243-
fn time_passes() -> bool { self.debugging_opt(time_passes) }
244-
fn count_llvm_insns() -> bool { self.debugging_opt(count_llvm_insns) }
245-
fn count_type_sizes() -> bool { self.debugging_opt(count_type_sizes) }
246-
fn time_llvm_passes() -> bool { self.debugging_opt(time_llvm_passes) }
247-
fn trans_stats() -> bool { self.debugging_opt(trans_stats) }
248-
fn meta_stats() -> bool { self.debugging_opt(meta_stats) }
249-
fn no_asm_comments() -> bool { self.debugging_opt(no_asm_comments) }
250-
fn no_verify() -> bool { self.debugging_opt(no_verify) }
251-
fn trace() -> bool { self.debugging_opt(trace) }
252-
fn coherence() -> bool { self.debugging_opt(coherence) }
253-
fn borrowck_stats() -> bool { self.debugging_opt(borrowck_stats) }
254-
fn borrowck_note_pure() -> bool { self.debugging_opt(borrowck_note_pure) }
255-
fn borrowck_note_loan() -> bool { self.debugging_opt(borrowck_note_loan) }
256-
fn no_monomorphic_collapse() -> bool {
242+
fn verbose(&self) -> bool { self.debugging_opt(verbose) }
243+
fn time_passes(&self) -> bool { self.debugging_opt(time_passes) }
244+
fn count_llvm_insns(&self) -> bool {
245+
self.debugging_opt(count_llvm_insns)
246+
}
247+
fn count_type_sizes(&self) -> bool {
248+
self.debugging_opt(count_type_sizes)
249+
}
250+
fn time_llvm_passes(&self) -> bool {
251+
self.debugging_opt(time_llvm_passes)
252+
}
253+
fn trans_stats(&self) -> bool { self.debugging_opt(trans_stats) }
254+
fn meta_stats(&self) -> bool { self.debugging_opt(meta_stats) }
255+
fn no_asm_comments(&self) -> bool { self.debugging_opt(no_asm_comments) }
256+
fn no_verify(&self) -> bool { self.debugging_opt(no_verify) }
257+
fn trace(&self) -> bool { self.debugging_opt(trace) }
258+
fn coherence(&self) -> bool { self.debugging_opt(coherence) }
259+
fn borrowck_stats(&self) -> bool { self.debugging_opt(borrowck_stats) }
260+
fn borrowck_note_pure(&self) -> bool {
261+
self.debugging_opt(borrowck_note_pure)
262+
}
263+
fn borrowck_note_loan(&self) -> bool {
264+
self.debugging_opt(borrowck_note_loan)
265+
}
266+
fn no_monomorphic_collapse(&self) -> bool {
257267
self.debugging_opt(no_monomorphic_collapse)
258268
}
259269

260-
fn str_of(id: ast::ident) -> @~str {
270+
fn str_of(&self, id: ast::ident) -> @~str {
261271
self.parse_sess.interner.get(id)
262272
}
263-
fn ident_of(+st: ~str) -> ast::ident {
273+
fn ident_of(&self, +st: ~str) -> ast::ident {
264274
self.parse_sess.interner.intern(@st)
265275
}
266-
fn intr() -> @syntax::parse::token::ident_interner {
276+
fn intr(&self) -> @syntax::parse::token::ident_interner {
267277
self.parse_sess.interner
268278
}
269279
}

branches/try2/src/librustc/metadata/filesearch.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
2929
}
3030

3131
pub trait FileSearch {
32-
fn sysroot() -> Path;
33-
fn lib_search_paths() -> ~[Path];
34-
fn get_target_lib_path() -> Path;
35-
fn get_target_lib_file_path(file: &Path) -> Path;
32+
fn sysroot(&self) -> Path;
33+
fn lib_search_paths(&self) -> ~[Path];
34+
fn get_target_lib_path(&self) -> Path;
35+
fn get_target_lib_file_path(&self, file: &Path) -> Path;
3636
}
3737

3838
pub fn mk_filesearch(maybe_sysroot: Option<Path>,
@@ -44,8 +44,8 @@ pub fn mk_filesearch(maybe_sysroot: Option<Path>,
4444
target_triple: ~str
4545
}
4646
impl FileSearch for FileSearchImpl {
47-
fn sysroot() -> Path { /*bad*/copy self.sysroot }
48-
fn lib_search_paths() -> ~[Path] {
47+
fn sysroot(&self) -> Path { /*bad*/copy self.sysroot }
48+
fn lib_search_paths(&self) -> ~[Path] {
4949
let mut paths = /*bad*/copy self.addl_lib_search_paths;
5050

5151
paths.push(
@@ -61,10 +61,10 @@ pub fn mk_filesearch(maybe_sysroot: Option<Path>,
6161
}
6262
paths
6363
}
64-
fn get_target_lib_path() -> Path {
64+
fn get_target_lib_path(&self) -> Path {
6565
make_target_lib_path(&self.sysroot, self.target_triple)
6666
}
67-
fn get_target_lib_file_path(file: &Path) -> Path {
67+
fn get_target_lib_file_path(&self, file: &Path) -> Path {
6868
self.get_target_lib_path().push_rel(file)
6969
}
7070
}

0 commit comments

Comments
 (0)