Skip to content

Commit 791f6c3

Browse files
committed
---
yaml --- r: 151009 b: refs/heads/try2 c: 7b3d6af h: refs/heads/master i: 151007: 450ef55 v: v3
1 parent 4ef07d2 commit 791f6c3

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
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: 5fa7be659c00eb0cc2fc7cce1ad1ab65b2219637
8+
refs/heads/try2: 7b3d6afe0a1d7fb2c918e9ba1ed8c2d859c6e772
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -686,22 +686,6 @@ pub fn is_null(val: ValueRef) -> bool {
686686
}
687687
}
688688

689-
// Used to identify cached monomorphized functions and vtables
690-
#[deriving(Eq, TotalEq, Hash)]
691-
pub struct MonoParamId {
692-
pub subst: ty::t,
693-
// Do we really need the vtables to be hashed? Isn't the type enough?
694-
pub vtables: Vec<mono_id>
695-
}
696-
697-
#[deriving(Eq, TotalEq, Hash)]
698-
pub struct mono_id_ {
699-
pub def: ast::DefId,
700-
pub params: Vec<MonoParamId>
701-
}
702-
703-
pub type mono_id = @mono_id_;
704-
705689
pub fn monomorphize_type(bcx: &Block, t: ty::t) -> ty::t {
706690
match bcx.fcx.param_substs {
707691
Some(substs) => {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ use middle::resolve;
2020
use middle::trans::adt;
2121
use middle::trans::base;
2222
use middle::trans::builder::Builder;
23-
use middle::trans::common::{mono_id,ExternMap,tydesc_info,BuilderRef_res,Stats};
23+
use middle::trans::common::{ExternMap,tydesc_info,BuilderRef_res,Stats};
2424
use middle::trans::debuginfo;
25+
use middle::trans::monomorphize::MonoId;
2526
use middle::trans::type_::Type;
2627
use middle::ty;
2728
use util::sha2::Sha256;
@@ -61,10 +62,10 @@ pub struct CrateContext {
6162
/// that is generated
6263
pub non_inlineable_statics: RefCell<NodeSet>,
6364
/// Cache instances of monomorphized functions
64-
pub monomorphized: RefCell<HashMap<mono_id, ValueRef>>,
65+
pub monomorphized: RefCell<HashMap<MonoId, ValueRef>>,
6566
pub monomorphizing: RefCell<DefIdMap<uint>>,
6667
/// Cache generated vtables
67-
pub vtables: RefCell<HashMap<(ty::t, mono_id), ValueRef>>,
68+
pub vtables: RefCell<HashMap<(ty::t, MonoId), ValueRef>>,
6869
/// Cache of constant strings,
6970
pub const_cstr_cache: RefCell<HashMap<InternedString, ValueRef>>,
7071

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

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use middle::trans::base::{trans_enum_variant, push_ctxt, get_item_val};
1616
use middle::trans::base::{trans_fn, decl_internal_rust_fn};
1717
use middle::trans::base;
1818
use middle::trans::common::*;
19-
use middle::trans::meth;
2019
use middle::trans::intrinsic;
2120
use middle::ty;
2221
use middle::typeck;
@@ -26,7 +25,7 @@ use syntax::abi;
2625
use syntax::ast;
2726
use syntax::ast_map;
2827
use syntax::ast_util::local_def;
29-
use std::hash::sip;
28+
use std::hash::{sip, Hash};
3029

3130
pub fn monomorphic_fn(ccx: &CrateContext,
3231
fn_id: ast::DefId,
@@ -71,7 +70,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
7170
}).collect()
7271
};
7372

74-
let hash_id = @mono_id_ {
73+
let hash_id = MonoId {
7574
def: fn_id,
7675
params: param_ids
7776
};
@@ -194,16 +193,22 @@ pub fn monomorphic_fn(ccx: &CrateContext,
194193
}
195194

196195
let s = ccx.tcx.map.with_path(fn_id.node, |path| {
197-
exported_name(path, format!("h{}", sip::hash(&(hash_id, mono_ty))),
196+
let mut state = sip::SipState::new();
197+
hash_id.hash(&mut state);
198+
mono_ty.hash(&mut state);
199+
200+
exported_name(path, format!("h{}", state.result()),
198201
ccx.link_meta.crateid.version_or_default())
199202
});
200203
debug!("monomorphize_fn mangled to {}", s);
201204

205+
// This shouldn't need to option dance.
206+
let mut hash_id = Some(hash_id);
202207
let mk_lldecl = || {
203208
let lldecl = decl_internal_rust_fn(ccx, false,
204209
f.sig.inputs.as_slice(),
205210
f.sig.output, s);
206-
ccx.monomorphized.borrow_mut().insert(hash_id, lldecl);
211+
ccx.monomorphized.borrow_mut().insert(hash_id.take_unwrap(), lldecl);
207212
lldecl
208213
};
209214

@@ -305,21 +310,34 @@ pub fn monomorphic_fn(ccx: &CrateContext,
305310
(lldecl, false)
306311
}
307312

313+
// Used to identify cached monomorphized functions and vtables
314+
#[deriving(Eq, TotalEq, Hash)]
315+
pub struct MonoParamId {
316+
pub subst: ty::t,
317+
// Do we really need the vtables to be hashed? Isn't the type enough?
318+
pub vtables: Vec<MonoId>
319+
}
320+
321+
#[deriving(Eq, TotalEq, Hash)]
322+
pub struct MonoId {
323+
pub def: ast::DefId,
324+
pub params: Vec<MonoParamId>
325+
}
326+
308327
pub fn make_vtable_id(ccx: &CrateContext,
309328
origin: &typeck::vtable_origin)
310-
-> mono_id {
329+
-> MonoId {
311330
match origin {
312331
&typeck::vtable_static(impl_id, ref substs, ref sub_vtables) => {
313-
let param_ids = sub_vtables.iter().zip(substs.iter()).map(|(vtable, subst)| {
314-
MonoParamId {
315-
subst: *subst,
316-
vtables: vtable.iter().map(|vt| make_vtable_id(ccx, vt)).collect()
317-
}
318-
}).collect();
319-
320-
@mono_id_ {
332+
MonoId {
321333
def: impl_id,
322-
params: param_ids
334+
params: sub_vtables.iter().zip(substs.iter()).map(|(vtable, subst)| {
335+
MonoParamId {
336+
subst: *subst,
337+
// Do we really need the vtables to be hashed? Isn't the type enough?
338+
vtables: vtable.iter().map(|vt| make_vtable_id(ccx, vt)).collect()
339+
}
340+
}).collect()
323341
}
324342
}
325343

0 commit comments

Comments
 (0)