Skip to content

Commit 85f4810

Browse files
committed
---
yaml --- r: 151016 b: refs/heads/try2 c: 9dc99c8 h: refs/heads/master v: v3
1 parent fe74917 commit 85f4810

File tree

4 files changed

+71
-77
lines changed

4 files changed

+71
-77
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: 938eaaa304445101e2c516a9d339dcbc0a416d58
8+
refs/heads/try2: 9dc99c89d35bde63ac49c0acf93b55913010ea63
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: 52 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use util::nodemap::{NodeMap, NodeSet};
2727

2828
use serialize::Encodable;
2929
use std::cast;
30-
use std::cell::{Cell, RefCell};
30+
use std::cell::RefCell;
3131
use std::hash;
3232
use std::hash::Hash;
3333
use std::io::MemWriter;
@@ -76,26 +76,9 @@ pub struct EncodeParams<'a> {
7676
pub encode_inlined_item: EncodeInlinedItem<'a>,
7777
}
7878

79-
pub struct Stats {
80-
inline_bytes: Cell<u64>,
81-
attr_bytes: Cell<u64>,
82-
dep_bytes: Cell<u64>,
83-
lang_item_bytes: Cell<u64>,
84-
native_lib_bytes: Cell<u64>,
85-
macro_registrar_fn_bytes: Cell<u64>,
86-
macro_defs_bytes: Cell<u64>,
87-
impl_bytes: Cell<u64>,
88-
misc_bytes: Cell<u64>,
89-
item_bytes: Cell<u64>,
90-
index_bytes: Cell<u64>,
91-
zero_bytes: Cell<u64>,
92-
total_bytes: Cell<u64>,
93-
}
94-
9579
pub struct EncodeContext<'a> {
9680
pub diag: &'a SpanHandler,
9781
pub tcx: &'a ty::ctxt,
98-
pub stats: @Stats,
9982
pub reexports2: &'a middle::resolve::ExportMap2,
10083
pub item_symbols: &'a RefCell<NodeMap<~str>>,
10184
pub non_inlineable_statics: &'a RefCell<NodeSet>,
@@ -1701,20 +1684,33 @@ pub fn encode_metadata(parms: EncodeParams, krate: &Crate) -> Vec<u8> {
17011684
}
17021685

17031686
fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, krate: &Crate) {
1704-
let stats = Stats {
1705-
inline_bytes: Cell::new(0),
1706-
attr_bytes: Cell::new(0),
1707-
dep_bytes: Cell::new(0),
1708-
lang_item_bytes: Cell::new(0),
1709-
native_lib_bytes: Cell::new(0),
1710-
macro_registrar_fn_bytes: Cell::new(0),
1711-
macro_defs_bytes: Cell::new(0),
1712-
impl_bytes: Cell::new(0),
1713-
misc_bytes: Cell::new(0),
1714-
item_bytes: Cell::new(0),
1715-
index_bytes: Cell::new(0),
1716-
zero_bytes: Cell::new(0),
1717-
total_bytes: Cell::new(0),
1687+
struct Stats {
1688+
attr_bytes: u64,
1689+
dep_bytes: u64,
1690+
lang_item_bytes: u64,
1691+
native_lib_bytes: u64,
1692+
macro_registrar_fn_bytes: u64,
1693+
macro_defs_bytes: u64,
1694+
impl_bytes: u64,
1695+
misc_bytes: u64,
1696+
item_bytes: u64,
1697+
index_bytes: u64,
1698+
zero_bytes: u64,
1699+
total_bytes: u64,
1700+
}
1701+
let mut stats = Stats {
1702+
attr_bytes: 0,
1703+
dep_bytes: 0,
1704+
lang_item_bytes: 0,
1705+
native_lib_bytes: 0,
1706+
macro_registrar_fn_bytes: 0,
1707+
macro_defs_bytes: 0,
1708+
impl_bytes: 0,
1709+
misc_bytes: 0,
1710+
item_bytes: 0,
1711+
index_bytes: 0,
1712+
zero_bytes: 0,
1713+
total_bytes: 0,
17181714
};
17191715
let EncodeParams {
17201716
item_symbols,
@@ -1730,7 +1726,6 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, krate: &Crate)
17301726
let ecx = EncodeContext {
17311727
diag: diag,
17321728
tcx: tcx,
1733-
stats: @stats,
17341729
reexports2: reexports2,
17351730
item_symbols: item_symbols,
17361731
non_inlineable_statics: non_inlineable_statics,
@@ -1748,76 +1743,75 @@ fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, krate: &Crate)
17481743
let mut i = ebml_w.writer.tell().unwrap();
17491744
let crate_attrs = synthesize_crate_attrs(&ecx, krate);
17501745
encode_attributes(&mut ebml_w, crate_attrs.as_slice());
1751-
ecx.stats.attr_bytes.set(ebml_w.writer.tell().unwrap() - i);
1746+
stats.attr_bytes = ebml_w.writer.tell().unwrap() - i;
17521747

17531748
i = ebml_w.writer.tell().unwrap();
17541749
encode_crate_deps(&mut ebml_w, ecx.cstore);
1755-
ecx.stats.dep_bytes.set(ebml_w.writer.tell().unwrap() - i);
1750+
stats.dep_bytes = ebml_w.writer.tell().unwrap() - i;
17561751

17571752
// Encode the language items.
17581753
i = ebml_w.writer.tell().unwrap();
17591754
encode_lang_items(&ecx, &mut ebml_w);
1760-
ecx.stats.lang_item_bytes.set(ebml_w.writer.tell().unwrap() - i);
1755+
stats.lang_item_bytes = ebml_w.writer.tell().unwrap() - i;
17611756

17621757
// Encode the native libraries used
17631758
i = ebml_w.writer.tell().unwrap();
17641759
encode_native_libraries(&ecx, &mut ebml_w);
1765-
ecx.stats.native_lib_bytes.set(ebml_w.writer.tell().unwrap() - i);
1760+
stats.native_lib_bytes = ebml_w.writer.tell().unwrap() - i;
17661761

17671762
// Encode the macro registrar function
17681763
i = ebml_w.writer.tell().unwrap();
17691764
encode_macro_registrar_fn(&ecx, &mut ebml_w);
1770-
ecx.stats.macro_registrar_fn_bytes.set(ebml_w.writer.tell().unwrap() - i);
1765+
stats.macro_registrar_fn_bytes = ebml_w.writer.tell().unwrap() - i;
17711766

17721767
// Encode macro definitions
17731768
i = ebml_w.writer.tell().unwrap();
17741769
encode_macro_defs(&ecx, krate, &mut ebml_w);
1775-
ecx.stats.macro_defs_bytes.set(ebml_w.writer.tell().unwrap() - i);
1770+
stats.macro_defs_bytes = ebml_w.writer.tell().unwrap() - i;
17761771

17771772
// Encode the def IDs of impls, for coherence checking.
17781773
i = ebml_w.writer.tell().unwrap();
17791774
encode_impls(&ecx, krate, &mut ebml_w);
1780-
ecx.stats.impl_bytes.set(ebml_w.writer.tell().unwrap() - i);
1775+
stats.impl_bytes = ebml_w.writer.tell().unwrap() - i;
17811776

17821777
// Encode miscellaneous info.
17831778
i = ebml_w.writer.tell().unwrap();
17841779
encode_misc_info(&ecx, krate, &mut ebml_w);
1785-
ecx.stats.misc_bytes.set(ebml_w.writer.tell().unwrap() - i);
1780+
stats.misc_bytes = ebml_w.writer.tell().unwrap() - i;
17861781

17871782
// Encode and index the items.
17881783
ebml_w.start_tag(tag_items);
17891784
i = ebml_w.writer.tell().unwrap();
17901785
let items_index = encode_info_for_items(&ecx, &mut ebml_w, krate);
1791-
ecx.stats.item_bytes.set(ebml_w.writer.tell().unwrap() - i);
1786+
stats.item_bytes = ebml_w.writer.tell().unwrap() - i;
17921787

17931788
i = ebml_w.writer.tell().unwrap();
17941789
encode_index(&mut ebml_w, items_index, write_i64);
1795-
ecx.stats.index_bytes.set(ebml_w.writer.tell().unwrap() - i);
1790+
stats.index_bytes = ebml_w.writer.tell().unwrap() - i;
17961791
ebml_w.end_tag();
17971792

1798-
ecx.stats.total_bytes.set(ebml_w.writer.tell().unwrap());
1793+
stats.total_bytes = ebml_w.writer.tell().unwrap();
17991794

18001795
if tcx.sess.meta_stats() {
18011796
for e in ebml_w.writer.get_ref().iter() {
18021797
if *e == 0 {
1803-
ecx.stats.zero_bytes.set(ecx.stats.zero_bytes.get() + 1);
1798+
stats.zero_bytes += 1;
18041799
}
18051800
}
18061801

18071802
println!("metadata stats:");
1808-
println!(" inline bytes: {}", ecx.stats.inline_bytes.get());
1809-
println!(" attribute bytes: {}", ecx.stats.attr_bytes.get());
1810-
println!(" dep bytes: {}", ecx.stats.dep_bytes.get());
1811-
println!(" lang item bytes: {}", ecx.stats.lang_item_bytes.get());
1812-
println!(" native bytes: {}", ecx.stats.native_lib_bytes.get());
1813-
println!("macro registrar bytes: {}", ecx.stats.macro_registrar_fn_bytes.get());
1814-
println!(" macro def bytes: {}", ecx.stats.macro_defs_bytes.get());
1815-
println!(" impl bytes: {}", ecx.stats.impl_bytes.get());
1816-
println!(" misc bytes: {}", ecx.stats.misc_bytes.get());
1817-
println!(" item bytes: {}", ecx.stats.item_bytes.get());
1818-
println!(" index bytes: {}", ecx.stats.index_bytes.get());
1819-
println!(" zero bytes: {}", ecx.stats.zero_bytes.get());
1820-
println!(" total bytes: {}", ecx.stats.total_bytes.get());
1803+
println!(" attribute bytes: {}", stats.attr_bytes);
1804+
println!(" dep bytes: {}", stats.dep_bytes);
1805+
println!(" lang item bytes: {}", stats.lang_item_bytes);
1806+
println!(" native bytes: {}", stats.native_lib_bytes);
1807+
println!("macro registrar bytes: {}", stats.macro_registrar_fn_bytes);
1808+
println!(" macro def bytes: {}", stats.macro_defs_bytes);
1809+
println!(" impl bytes: {}", stats.impl_bytes);
1810+
println!(" misc bytes: {}", stats.misc_bytes);
1811+
println!(" item bytes: {}", stats.item_bytes);
1812+
println!(" index bytes: {}", stats.index_bytes);
1813+
println!(" zero bytes: {}", stats.zero_bytes);
1814+
println!(" total bytes: {}", stats.total_bytes);
18211815
}
18221816
}
18231817

branches/try2/src/librustc/middle/trans/common.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,6 @@ pub fn expr_info(expr: &ast::Expr) -> NodeInfo {
154154
NodeInfo { id: expr.id, span: expr.span }
155155
}
156156

157-
pub struct Stats {
158-
pub n_static_tydescs: Cell<uint>,
159-
pub n_glues_created: Cell<uint>,
160-
pub n_null_glues: Cell<uint>,
161-
pub n_real_glues: Cell<uint>,
162-
pub n_fns: Cell<uint>,
163-
pub n_monos: Cell<uint>,
164-
pub n_inlines: Cell<uint>,
165-
pub n_closures: Cell<uint>,
166-
pub n_llvm_insns: Cell<uint>,
167-
pub llvm_insns: RefCell<HashMap<~str, uint>>,
168-
// (ident, time-in-ms, llvm-instructions)
169-
pub fn_stats: RefCell<Vec<(~str, uint, uint)> >,
170-
}
171-
172157
pub struct BuilderRef_res {
173158
pub b: BuilderRef,
174159
}

branches/try2/src/librustc/middle/trans/context.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use middle::resolve;
2020
use middle::trans::adt;
2121
use middle::trans::base;
2222
use middle::trans::builder::Builder;
23-
use middle::trans::common::{ExternMap,tydesc_info,BuilderRef_res,Stats};
23+
use middle::trans::common::{ExternMap,tydesc_info,BuilderRef_res};
2424
use middle::trans::debuginfo;
2525
use middle::trans::monomorphize::MonoId;
2626
use middle::trans::type_::Type;
@@ -36,6 +36,21 @@ use collections::{HashMap, HashSet};
3636
use syntax::ast;
3737
use syntax::parse::token::InternedString;
3838

39+
pub struct Stats {
40+
pub n_static_tydescs: Cell<uint>,
41+
pub n_glues_created: Cell<uint>,
42+
pub n_null_glues: Cell<uint>,
43+
pub n_real_glues: Cell<uint>,
44+
pub n_fns: Cell<uint>,
45+
pub n_monos: Cell<uint>,
46+
pub n_inlines: Cell<uint>,
47+
pub n_closures: Cell<uint>,
48+
pub n_llvm_insns: Cell<uint>,
49+
pub llvm_insns: RefCell<HashMap<~str, uint>>,
50+
// (ident, time-in-ms, llvm-instructions)
51+
pub fn_stats: RefCell<Vec<(~str, uint, uint)> >,
52+
}
53+
3954
pub struct CrateContext {
4055
pub llmod: ModuleRef,
4156
pub llcx: ContextRef,
@@ -99,7 +114,7 @@ pub struct CrateContext {
99114
pub all_llvm_symbols: RefCell<HashSet<~str>>,
100115
pub tcx: ty::ctxt,
101116
pub maps: astencode::Maps,
102-
pub stats: @Stats,
117+
pub stats: Stats,
103118
pub int_type: Type,
104119
pub opaque_vec_type: Type,
105120
pub builder: BuilderRef_res,
@@ -181,7 +196,7 @@ impl CrateContext {
181196
all_llvm_symbols: RefCell::new(HashSet::new()),
182197
tcx: tcx,
183198
maps: maps,
184-
stats: @Stats {
199+
stats: Stats {
185200
n_static_tydescs: Cell::new(0u),
186201
n_glues_created: Cell::new(0u),
187202
n_null_glues: Cell::new(0u),

0 commit comments

Comments
 (0)