librustc: De-@mut monomorphized in the crate context

This commit is contained in:
Patrick Walton 2013-12-18 16:35:29 -08:00
parent 6a0450c67d
commit b5218ba6ad
2 changed files with 15 additions and 10 deletions
src/librustc/middle/trans

@ -27,6 +27,7 @@ use middle::trans::type_::Type;
use util::sha2::Sha256;
use std::cell::RefCell;
use std::c_str::ToCStr;
use std::hashmap::{HashMap, HashSet};
use std::local_data;
@ -68,7 +69,7 @@ pub struct CrateContext {
// that is generated
non_inlineable_statics: HashSet<ast::NodeId>,
// Cache instances of monomorphized functions
monomorphized: HashMap<mono_id, ValueRef>,
monomorphized: RefCell<HashMap<mono_id, ValueRef>>,
monomorphizing: HashMap<ast::DefId, uint>,
// Cache generated vtables
vtables: HashMap<(ty::t, mono_id), ValueRef>,
@ -199,7 +200,7 @@ impl CrateContext {
external: HashMap::new(),
external_srcs: HashMap::new(),
non_inlineable_statics: HashSet::new(),
monomorphized: HashMap::new(),
monomorphized: RefCell::new(HashMap::new()),
monomorphizing: HashMap::new(),
vtables: HashMap::new(),
const_cstr_cache: HashMap::new(),

@ -76,13 +76,16 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
psubsts.repr(ccx.tcx),
hash_id);
match ccx.monomorphized.find(&hash_id) {
Some(&val) => {
debug!("leaving monomorphic fn {}",
ty::item_path_str(ccx.tcx, fn_id));
return (val, must_cast);
}
None => ()
{
let monomorphized = ccx.monomorphized.borrow();
match monomorphized.get().find(&hash_id) {
Some(&val) => {
debug!("leaving monomorphic fn {}",
ty::item_path_str(ccx.tcx, fn_id));
return (val, must_cast);
}
None => ()
}
}
let tpt = ty::lookup_item_type(ccx.tcx, fn_id);
@ -201,7 +204,8 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
let mk_lldecl = || {
let lldecl = decl_internal_rust_fn(ccx, f.sig.inputs, f.sig.output, s);
ccx.monomorphized.insert(hash_id, lldecl);
let mut monomorphized = ccx.monomorphized.borrow_mut();
monomorphized.get().insert(hash_id, lldecl);
lldecl
};