librustc: De-@mut CrateContext::vtables.

This commit is contained in:
Patrick Walton 2013-12-18 17:00:56 -08:00
parent 5dcc5165a6
commit 13f85cb097
2 changed files with 11 additions and 6 deletions

View File

@ -69,7 +69,7 @@ pub struct CrateContext {
monomorphized: RefCell<HashMap<mono_id, ValueRef>>,
monomorphizing: RefCell<HashMap<ast::DefId, uint>>,
// Cache generated vtables
vtables: HashMap<(ty::t, mono_id), ValueRef>,
vtables: RefCell<HashMap<(ty::t, mono_id), ValueRef>>,
// Cache of constant strings,
const_cstr_cache: HashMap<@str, ValueRef>,
@ -196,7 +196,7 @@ impl CrateContext {
non_inlineable_statics: HashSet::new(),
monomorphized: RefCell::new(HashMap::new()),
monomorphizing: RefCell::new(HashMap::new()),
vtables: HashMap::new(),
vtables: RefCell::new(HashMap::new()),
const_cstr_cache: HashMap::new(),
const_globals: HashMap::new(),
const_values: HashMap::new(),

View File

@ -539,9 +539,12 @@ pub fn get_vtable(bcx: @Block,
// Check the cache.
let hash_id = (self_ty, vtable_id(ccx, &origins[0]));
match ccx.vtables.find(&hash_id) {
Some(&val) => { return val }
None => { }
{
let vtables = ccx.vtables.borrow();
match vtables.get().find(&hash_id) {
Some(&val) => { return val }
None => { }
}
}
// Not in the cache. Actually build it.
@ -559,7 +562,9 @@ pub fn get_vtable(bcx: @Block,
glue::lazily_emit_all_tydesc_glue(ccx, tydesc);
let vtable = make_vtable(ccx, tydesc, methods);
ccx.vtables.insert(hash_id, vtable);
let mut vtables = ccx.vtables.borrow_mut();
vtables.get().insert(hash_id, vtable);
return vtable;
}