Skip to content

Commit 450ef55

Browse files
committed
---
yaml --- r: 151007 b: refs/heads/try2 c: c709c1e h: refs/heads/master i: 151005: b265987 151003: 8d3b86c 150999: c63e3af 150991: 216aee4 150975: 2f18332 v: v3
1 parent 3cb774d commit 450ef55

File tree

4 files changed

+38
-61
lines changed

4 files changed

+38
-61
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: 811bbfc782c3844efc1226e02ec9dcd4ba8d7fe8
8+
refs/heads/try2: c709c1efc6c399b404bc73ef9a8de10c81a67e35
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/adt.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,19 @@ impl Case {
267267
mk_struct(cx, self.tys.as_slice(), false).size == 0
268268
}
269269
fn find_ptr(&self) -> Option<uint> {
270-
self.tys.iter().position(|&ty| mono_data_classify(ty) == MonoNonNull)
270+
self.tys.iter().position(|&ty| {
271+
match ty::get(ty).sty {
272+
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
273+
ty::ty_vec(_, None) => false,
274+
_ => true,
275+
},
276+
ty::ty_uniq(..) | ty::ty_box(..) |
277+
ty::ty_str(ty::VstoreUniq) |
278+
ty::ty_bare_fn(..) => true,
279+
// Is that everything? Would closures or slices qualify?
280+
_ => false
281+
}
282+
})
271283
}
272284
}
273285

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

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -688,45 +688,16 @@ pub fn is_null(val: ValueRef) -> bool {
688688

689689
// Used to identify cached monomorphized functions and vtables
690690
#[deriving(Eq, TotalEq, Hash)]
691-
pub enum mono_param_id {
692-
mono_precise(ty::t, Option<@Vec<mono_id> >),
693-
mono_any,
694-
mono_repr(uint /* size */,
695-
uint /* align */,
696-
MonoDataClass,
697-
datum::RvalueMode),
698-
}
699-
700-
#[deriving(Eq, TotalEq, Hash)]
701-
pub enum MonoDataClass {
702-
MonoBits, // Anything not treated differently from arbitrary integer data
703-
MonoNonNull, // Non-null pointers (used for optional-pointer optimization)
704-
// FIXME(#3547)---scalars and floats are
705-
// treated differently in most ABIs. But we
706-
// should be doing something more detailed
707-
// here.
708-
MonoFloat
709-
}
710-
711-
pub fn mono_data_classify(t: ty::t) -> MonoDataClass {
712-
match ty::get(t).sty {
713-
ty::ty_float(_) => MonoFloat,
714-
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
715-
ty::ty_vec(_, None) => MonoBits,
716-
_ => MonoNonNull,
717-
},
718-
ty::ty_uniq(..) | ty::ty_box(..) |
719-
ty::ty_str(ty::VstoreUniq) |
720-
ty::ty_bare_fn(..) => MonoNonNull,
721-
// Is that everything? Would closures or slices qualify?
722-
_ => MonoBits
723-
}
691+
pub struct MonoParamId {
692+
pub subst: ty::t,
693+
pub vtables: Vec<mono_id>
724694
}
725695

726696
#[deriving(Eq, TotalEq, Hash)]
727697
pub struct mono_id_ {
728698
pub def: ast::DefId,
729-
pub params: Vec<mono_param_id> }
699+
pub params: Vec<MonoParamId>
700+
}
730701

731702
pub type mono_id = @mono_id_;
732703

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

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub fn monomorphic_fn(ccx: &CrateContext,
4949

5050
assert!(real_substs.tps.iter().all(|t| !ty::type_needs_infer(*t)));
5151
let _icx = push_ctxt("monomorphic_fn");
52-
let mut must_cast = false;
5352

5453
let psubsts = @param_substs {
5554
tys: real_substs.tps.clone(),
@@ -62,10 +61,6 @@ pub fn monomorphic_fn(ccx: &CrateContext,
6261
for s in psubsts.tys.iter() { assert!(!ty::type_has_params(*s)); }
6362

6463
let hash_id = make_mono_id(ccx, fn_id, &*psubsts);
65-
if hash_id.params.iter().any(
66-
|p| match *p { mono_precise(_, _) => false, _ => true }) {
67-
must_cast = true;
68-
}
6964

7065
debug!("monomorphic_fn(\
7166
fn_id={}, \
@@ -79,7 +74,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
7974
Some(&val) => {
8075
debug!("leaving monomorphic fn {}",
8176
ty::item_path_str(ccx.tcx(), fn_id));
82-
return (val, must_cast);
77+
return (val, false);
8378
}
8479
None => ()
8580
}
@@ -286,32 +281,31 @@ pub fn monomorphic_fn(ccx: &CrateContext,
286281
ccx.monomorphizing.borrow_mut().insert(fn_id, depth);
287282

288283
debug!("leaving monomorphic fn {}", ty::item_path_str(ccx.tcx(), fn_id));
289-
(lldecl, must_cast)
284+
(lldecl, false)
290285
}
291286

292287
pub fn make_mono_id(ccx: &CrateContext,
293288
item: ast::DefId,
294289
substs: &param_substs) -> mono_id {
295-
// FIXME (possibly #5801): Need a lot of type hints to get
296-
// .collect() to work.
297290
let substs_iter = substs.self_ty.iter().chain(substs.tys.iter());
298-
let precise_param_ids: Vec<(ty::t, Option<@Vec<mono_id> >)> = match substs.vtables {
299-
Some(ref vts) => {
300-
debug!("make_mono_id vtables={} substs={}",
301-
vts.repr(ccx.tcx()), substs.tys.repr(ccx.tcx()));
302-
let vts_iter = substs.self_vtables.iter().chain(vts.iter());
303-
vts_iter.zip(substs_iter).map(|(vtable, subst)| {
304-
let v = vtable.iter().map(|vt| meth::vtable_id(ccx, vt)).collect::<Vec<_>>();
305-
(*subst, if !v.is_empty() { Some(@v) } else { None })
291+
let param_ids: Vec<MonoParamId> = match substs.vtables {
292+
Some(ref vts) => {
293+
debug!("make_mono_id vtables={} substs={}",
294+
vts.repr(ccx.tcx()), substs.tys.repr(ccx.tcx()));
295+
let vts_iter = substs.self_vtables.iter().chain(vts.iter());
296+
vts_iter.zip(substs_iter).map(|(vtable, subst)| MonoParamId {
297+
subst: *subst,
298+
vtables: vtable.iter().map(|vt| meth::vtable_id(ccx, vt)).collect()
299+
}).collect()
300+
}
301+
None => substs_iter.map(|subst| MonoParamId {
302+
subst: *subst,
303+
vtables: Vec::new()
306304
}).collect()
307-
}
308-
None => substs_iter.map(|subst| (*subst, None::<@Vec<mono_id> >)).collect()
309305
};
310306

311-
312-
let param_ids = precise_param_ids.iter().map(|x| {
313-
let (a, b) = *x;
314-
mono_precise(a, b)
315-
}).collect();
316-
@mono_id_ {def: item, params: param_ids}
307+
@mono_id_ {
308+
def: item,
309+
params: param_ids
310+
}
317311
}

0 commit comments

Comments
 (0)