Skip to content

Commit 2011be8

Browse files
committed
---
yaml --- r: 147663 b: refs/heads/try2 c: df0c13d h: refs/heads/master i: 147661: 8909073 147659: 587cc56 147655: 23c2a4c 147647: 3c2659e v: v3
1 parent 69c63f4 commit 2011be8

File tree

2 files changed

+47
-50
lines changed

2 files changed

+47
-50
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: 75c95e096075f3720c2461f2c61d5b73646b22f7
8+
refs/heads/try2: df0c13d2ea1bcbf999ea161e69707ccaad1c0771
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 46 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use middle::typeck;
2222
use middle;
2323

2424
use std::cast;
25-
use std::cell::RefCell;
25+
use std::cell::{Cell, RefCell};
2626
use std::hashmap::{HashMap, HashSet};
2727
use std::io::mem::MemWriter;
2828
use std::io::{Writer, Seek, Decorator};
@@ -69,25 +69,23 @@ pub struct EncodeParams<'a> {
6969
}
7070

7171
struct Stats {
72-
inline_bytes: u64,
73-
attr_bytes: u64,
74-
dep_bytes: u64,
75-
lang_item_bytes: u64,
76-
native_lib_bytes: u64,
77-
impl_bytes: u64,
78-
misc_bytes: u64,
79-
item_bytes: u64,
80-
index_bytes: u64,
81-
zero_bytes: u64,
82-
total_bytes: u64,
83-
84-
n_inlines: uint
72+
inline_bytes: Cell<u64>,
73+
attr_bytes: Cell<u64>,
74+
dep_bytes: Cell<u64>,
75+
lang_item_bytes: Cell<u64>,
76+
native_lib_bytes: Cell<u64>,
77+
impl_bytes: Cell<u64>,
78+
misc_bytes: Cell<u64>,
79+
item_bytes: Cell<u64>,
80+
index_bytes: Cell<u64>,
81+
zero_bytes: Cell<u64>,
82+
total_bytes: Cell<u64>,
8583
}
8684

8785
pub struct EncodeContext<'a> {
8886
diag: @mut span_handler,
8987
tcx: ty::ctxt,
90-
stats: @mut Stats,
88+
stats: @Stats,
9189
reexports2: middle::resolve::ExportMap2,
9290
item_symbols: &'a RefCell<HashMap<ast::NodeId, ~str>>,
9391
non_inlineable_statics: &'a RefCell<HashSet<ast::NodeId>>,
@@ -1796,18 +1794,17 @@ pub static metadata_encoding_version : &'static [u8] =
17961794
pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
17971795
let mut wr = MemWriter::new();
17981796
let stats = Stats {
1799-
inline_bytes: 0,
1800-
attr_bytes: 0,
1801-
dep_bytes: 0,
1802-
lang_item_bytes: 0,
1803-
native_lib_bytes: 0,
1804-
impl_bytes: 0,
1805-
misc_bytes: 0,
1806-
item_bytes: 0,
1807-
index_bytes: 0,
1808-
zero_bytes: 0,
1809-
total_bytes: 0,
1810-
n_inlines: 0
1797+
inline_bytes: Cell::new(0),
1798+
attr_bytes: Cell::new(0),
1799+
dep_bytes: Cell::new(0),
1800+
lang_item_bytes: Cell::new(0),
1801+
native_lib_bytes: Cell::new(0),
1802+
impl_bytes: Cell::new(0),
1803+
misc_bytes: Cell::new(0),
1804+
item_bytes: Cell::new(0),
1805+
index_bytes: Cell::new(0),
1806+
zero_bytes: Cell::new(0),
1807+
total_bytes: Cell::new(0),
18111808
};
18121809
let EncodeParams {
18131810
item_symbols,
@@ -1822,7 +1819,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
18221819
..
18231820
} = parms;
18241821
let type_abbrevs = @RefCell::new(HashMap::new());
1825-
let stats = @mut stats;
1822+
let stats = @stats;
18261823
let ecx = EncodeContext {
18271824
diag: diag,
18281825
tcx: tcx,
@@ -1844,65 +1841,65 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
18441841
let mut i = ebml_w.writer.tell();
18451842
let crate_attrs = synthesize_crate_attrs(&ecx, crate);
18461843
encode_attributes(&mut ebml_w, crate_attrs);
1847-
ecx.stats.attr_bytes = ebml_w.writer.tell() - i;
1844+
ecx.stats.attr_bytes.set(ebml_w.writer.tell() - i);
18481845

18491846
i = ebml_w.writer.tell();
18501847
encode_crate_deps(&ecx, &mut ebml_w, ecx.cstore);
1851-
ecx.stats.dep_bytes = ebml_w.writer.tell() - i;
1848+
ecx.stats.dep_bytes.set(ebml_w.writer.tell() - i);
18521849

18531850
// Encode the language items.
18541851
i = ebml_w.writer.tell();
18551852
encode_lang_items(&ecx, &mut ebml_w);
1856-
ecx.stats.lang_item_bytes = ebml_w.writer.tell() - i;
1853+
ecx.stats.lang_item_bytes.set(ebml_w.writer.tell() - i);
18571854

18581855
// Encode the native libraries used
18591856
i = ebml_w.writer.tell();
18601857
encode_native_libraries(&ecx, &mut ebml_w);
1861-
ecx.stats.native_lib_bytes = ebml_w.writer.tell() - i;
1858+
ecx.stats.native_lib_bytes.set(ebml_w.writer.tell() - i);
18621859

18631860
// Encode the def IDs of impls, for coherence checking.
18641861
i = ebml_w.writer.tell();
18651862
encode_impls(&ecx, crate, &mut ebml_w);
1866-
ecx.stats.impl_bytes = ebml_w.writer.tell() - i;
1863+
ecx.stats.impl_bytes.set(ebml_w.writer.tell() - i);
18671864

18681865
// Encode miscellaneous info.
18691866
i = ebml_w.writer.tell();
18701867
encode_misc_info(&ecx, crate, &mut ebml_w);
1871-
ecx.stats.misc_bytes = ebml_w.writer.tell() - i;
1868+
ecx.stats.misc_bytes.set(ebml_w.writer.tell() - i);
18721869

18731870
// Encode and index the items.
18741871
ebml_w.start_tag(tag_items);
18751872
i = ebml_w.writer.tell();
18761873
let items_index = encode_info_for_items(&ecx, &mut ebml_w, crate);
1877-
ecx.stats.item_bytes = ebml_w.writer.tell() - i;
1874+
ecx.stats.item_bytes.set(ebml_w.writer.tell() - i);
18781875

18791876
i = ebml_w.writer.tell();
18801877
let items_buckets = create_index(items_index);
18811878
encode_index(&mut ebml_w, items_buckets, write_i64);
1882-
ecx.stats.index_bytes = ebml_w.writer.tell() - i;
1879+
ecx.stats.index_bytes.set(ebml_w.writer.tell() - i);
18831880
ebml_w.end_tag();
18841881

1885-
ecx.stats.total_bytes = ebml_w.writer.tell();
1882+
ecx.stats.total_bytes.set(ebml_w.writer.tell());
18861883

18871884
if (tcx.sess.meta_stats()) {
18881885
for e in ebml_w.writer.inner_ref().iter() {
18891886
if *e == 0 {
1890-
ecx.stats.zero_bytes += 1;
1887+
ecx.stats.zero_bytes.set(ecx.stats.zero_bytes.get() + 1);
18911888
}
18921889
}
18931890

18941891
println("metadata stats:");
1895-
println!(" inline bytes: {}", ecx.stats.inline_bytes);
1896-
println!(" attribute bytes: {}", ecx.stats.attr_bytes);
1897-
println!(" dep bytes: {}", ecx.stats.dep_bytes);
1898-
println!(" lang item bytes: {}", ecx.stats.lang_item_bytes);
1899-
println!(" native bytes: {}", ecx.stats.native_lib_bytes);
1900-
println!(" impl bytes: {}", ecx.stats.impl_bytes);
1901-
println!(" misc bytes: {}", ecx.stats.misc_bytes);
1902-
println!(" item bytes: {}", ecx.stats.item_bytes);
1903-
println!(" index bytes: {}", ecx.stats.index_bytes);
1904-
println!(" zero bytes: {}", ecx.stats.zero_bytes);
1905-
println!(" total bytes: {}", ecx.stats.total_bytes);
1892+
println!(" inline bytes: {}", ecx.stats.inline_bytes.get());
1893+
println!(" attribute bytes: {}", ecx.stats.attr_bytes.get());
1894+
println!(" dep bytes: {}", ecx.stats.dep_bytes.get());
1895+
println!(" lang item bytes: {}", ecx.stats.lang_item_bytes.get());
1896+
println!(" native bytes: {}", ecx.stats.native_lib_bytes.get());
1897+
println!(" impl bytes: {}", ecx.stats.impl_bytes.get());
1898+
println!(" misc bytes: {}", ecx.stats.misc_bytes.get());
1899+
println!(" item bytes: {}", ecx.stats.item_bytes.get());
1900+
println!(" index bytes: {}", ecx.stats.index_bytes.get());
1901+
println!(" zero bytes: {}", ecx.stats.zero_bytes.get());
1902+
println!(" total bytes: {}", ecx.stats.total_bytes.get());
19061903
}
19071904

19081905
// Pad this, since something (LLVM, presumably) is cutting off the

0 commit comments

Comments
 (0)