about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2014-04-20 15:43:37 +0300
committerEduard Burtescu <edy.burt@gmail.com>2014-04-22 19:06:55 +0300
commitc709c1efc6c399b404bc73ef9a8de10c81a67e35 (patch)
treea01c60320f411e061d13f114a004adcdd9dad3e4 /src
parent811bbfc782c3844efc1226e02ec9dcd4ba8d7fe8 (diff)
downloadrust-c709c1efc6c399b404bc73ef9a8de10c81a67e35.tar.gz
rust-c709c1efc6c399b404bc73ef9a8de10c81a67e35.zip
rustc: remove obsolete monomorphization modes.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/trans/adt.rs14
-rw-r--r--src/librustc/middle/trans/common.rs39
-rw-r--r--src/librustc/middle/trans/monomorphize.rs44
3 files changed, 37 insertions, 60 deletions
diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs
index da78b650852..c5a284e3f96 100644
--- a/src/librustc/middle/trans/adt.rs
+++ b/src/librustc/middle/trans/adt.rs
@@ -267,7 +267,19 @@ impl Case {
         mk_struct(cx, self.tys.as_slice(), false).size == 0
     }
     fn find_ptr(&self) -> Option<uint> {
-        self.tys.iter().position(|&ty| mono_data_classify(ty) == MonoNonNull)
+        self.tys.iter().position(|&ty| {
+            match ty::get(ty).sty {
+                ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
+                    ty::ty_vec(_, None) => false,
+                    _ => true,
+                },
+                ty::ty_uniq(..) | ty::ty_box(..) |
+                ty::ty_str(ty::VstoreUniq) |
+                ty::ty_bare_fn(..) => true,
+                // Is that everything?  Would closures or slices qualify?
+                _ => false
+            }
+        })
     }
 }
 
diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs
index ab474eacf25..4657c82c833 100644
--- a/src/librustc/middle/trans/common.rs
+++ b/src/librustc/middle/trans/common.rs
@@ -688,45 +688,16 @@ pub fn is_null(val: ValueRef) -> bool {
 
 // Used to identify cached monomorphized functions and vtables
 #[deriving(Eq, TotalEq, Hash)]
-pub enum mono_param_id {
-    mono_precise(ty::t, Option<@Vec<mono_id> >),
-    mono_any,
-    mono_repr(uint /* size */,
-              uint /* align */,
-              MonoDataClass,
-              datum::RvalueMode),
-}
-
-#[deriving(Eq, TotalEq, Hash)]
-pub enum MonoDataClass {
-    MonoBits,    // Anything not treated differently from arbitrary integer data
-    MonoNonNull, // Non-null pointers (used for optional-pointer optimization)
-    // FIXME(#3547)---scalars and floats are
-    // treated differently in most ABIs.  But we
-    // should be doing something more detailed
-    // here.
-    MonoFloat
-}
-
-pub fn mono_data_classify(t: ty::t) -> MonoDataClass {
-    match ty::get(t).sty {
-        ty::ty_float(_) => MonoFloat,
-        ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
-            ty::ty_vec(_, None) => MonoBits,
-            _ => MonoNonNull,
-        },
-        ty::ty_uniq(..) | ty::ty_box(..) |
-        ty::ty_str(ty::VstoreUniq) |
-        ty::ty_bare_fn(..) => MonoNonNull,
-        // Is that everything?  Would closures or slices qualify?
-        _ => MonoBits
-    }
+pub struct MonoParamId {
+    pub subst: ty::t,
+    pub vtables: Vec<mono_id>
 }
 
 #[deriving(Eq, TotalEq, Hash)]
 pub struct mono_id_ {
     pub def: ast::DefId,
-    pub params: Vec<mono_param_id> }
+    pub params: Vec<MonoParamId>
+}
 
 pub type mono_id = @mono_id_;
 
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index 445aa9f2323..fd8a1652fe7 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -49,7 +49,6 @@ pub fn monomorphic_fn(ccx: &CrateContext,
 
     assert!(real_substs.tps.iter().all(|t| !ty::type_needs_infer(*t)));
     let _icx = push_ctxt("monomorphic_fn");
-    let mut must_cast = false;
 
     let psubsts = @param_substs {
         tys: real_substs.tps.clone(),
@@ -62,10 +61,6 @@ pub fn monomorphic_fn(ccx: &CrateContext,
     for s in psubsts.tys.iter() { assert!(!ty::type_has_params(*s)); }
 
     let hash_id = make_mono_id(ccx, fn_id, &*psubsts);
-    if hash_id.params.iter().any(
-                |p| match *p { mono_precise(_, _) => false, _ => true }) {
-        must_cast = true;
-    }
 
     debug!("monomorphic_fn(\
             fn_id={}, \
@@ -79,7 +74,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
         Some(&val) => {
             debug!("leaving monomorphic fn {}",
             ty::item_path_str(ccx.tcx(), fn_id));
-            return (val, must_cast);
+            return (val, false);
         }
         None => ()
     }
@@ -286,32 +281,31 @@ pub fn monomorphic_fn(ccx: &CrateContext,
     ccx.monomorphizing.borrow_mut().insert(fn_id, depth);
 
     debug!("leaving monomorphic fn {}", ty::item_path_str(ccx.tcx(), fn_id));
-    (lldecl, must_cast)
+    (lldecl, false)
 }
 
 pub fn make_mono_id(ccx: &CrateContext,
                     item: ast::DefId,
                     substs: &param_substs) -> mono_id {
-    // FIXME (possibly #5801): Need a lot of type hints to get
-    // .collect() to work.
     let substs_iter = substs.self_ty.iter().chain(substs.tys.iter());
-    let precise_param_ids: Vec<(ty::t, Option<@Vec<mono_id> >)> = match substs.vtables {
-      Some(ref vts) => {
-        debug!("make_mono_id vtables={} substs={}",
-               vts.repr(ccx.tcx()), substs.tys.repr(ccx.tcx()));
-        let vts_iter = substs.self_vtables.iter().chain(vts.iter());
-        vts_iter.zip(substs_iter).map(|(vtable, subst)| {
-            let v = vtable.iter().map(|vt| meth::vtable_id(ccx, vt)).collect::<Vec<_>>();
-            (*subst, if !v.is_empty() { Some(@v) } else { None })
+    let param_ids: Vec<MonoParamId> = match substs.vtables {
+        Some(ref vts) => {
+            debug!("make_mono_id vtables={} substs={}",
+                   vts.repr(ccx.tcx()), substs.tys.repr(ccx.tcx()));
+            let vts_iter = substs.self_vtables.iter().chain(vts.iter());
+            vts_iter.zip(substs_iter).map(|(vtable, subst)| MonoParamId {
+                subst: *subst,
+                vtables: vtable.iter().map(|vt| meth::vtable_id(ccx, vt)).collect()
+            }).collect()
+        }
+        None => substs_iter.map(|subst| MonoParamId {
+            subst: *subst,
+            vtables: Vec::new()
         }).collect()
-      }
-      None => substs_iter.map(|subst| (*subst, None::<@Vec<mono_id> >)).collect()
     };
 
-
-    let param_ids = precise_param_ids.iter().map(|x| {
-        let (a, b) = *x;
-        mono_precise(a, b)
-    }).collect();
-    @mono_id_ {def: item, params: param_ids}
+    @mono_id_ {
+        def: item,
+        params: param_ids
+    }
 }