Add a cache so we don't create so many shims.
This commit is contained in:
parent
39221a013f
commit
64bf5a8687
@ -262,6 +262,12 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
||||
let _icx = push_ctxt("trans_fn_pointer_shim");
|
||||
let tcx = ccx.tcx();
|
||||
|
||||
let bare_fn_ty = ty::normalize_ty(tcx, bare_fn_ty);
|
||||
match ccx.fn_pointer_shims().borrow().get(&bare_fn_ty) {
|
||||
Some(&llval) => { return llval; }
|
||||
None => { }
|
||||
}
|
||||
|
||||
debug!("trans_fn_pointer_shim(bare_fn_ty={})",
|
||||
bare_fn_ty.repr(tcx));
|
||||
|
||||
@ -345,6 +351,8 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
||||
|
||||
finish_fn(&fcx, bcx, output_ty);
|
||||
|
||||
ccx.fn_pointer_shims().borrow_mut().insert(bare_fn_ty, llfn);
|
||||
|
||||
llfn
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,7 @@ pub struct LocalCrateContext<'tcx> {
|
||||
tn: TypeNames,
|
||||
externs: RefCell<ExternMap>,
|
||||
item_vals: RefCell<NodeMap<ValueRef>>,
|
||||
fn_pointer_shims: RefCell<FnvHashMap<Ty<'tcx>, ValueRef>>,
|
||||
drop_glues: RefCell<FnvHashMap<Ty<'tcx>, ValueRef>>,
|
||||
tydescs: RefCell<FnvHashMap<Ty<'tcx>, Rc<tydesc_info<'tcx>>>>,
|
||||
/// Set when running emit_tydescs to enforce that no more tydescs are
|
||||
@ -573,6 +574,10 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
|
||||
&self.shared.link_meta
|
||||
}
|
||||
|
||||
pub fn fn_pointer_shims(&self) -> &RefCell<FnvHashMap<Ty<'tcx>, ValueRef>> {
|
||||
&self.local.fn_pointer_shims
|
||||
}
|
||||
|
||||
pub fn drop_glues<'a>(&'a self) -> &'a RefCell<FnvHashMap<Ty<'tcx>, ValueRef>> {
|
||||
&self.local.drop_glues
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user