Skip to content

Commit 13f85cb

Browse files
committed
librustc: De-@mut CrateContext::vtables.
1 parent 5dcc516 commit 13f85cb

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/librustc/middle/trans/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub struct CrateContext {
6969
monomorphized: RefCell<HashMap<mono_id, ValueRef>>,
7070
monomorphizing: RefCell<HashMap<ast::DefId, uint>>,
7171
// Cache generated vtables
72-
vtables: HashMap<(ty::t, mono_id), ValueRef>,
72+
vtables: RefCell<HashMap<(ty::t, mono_id), ValueRef>>,
7373
// Cache of constant strings,
7474
const_cstr_cache: HashMap<@str, ValueRef>,
7575

@@ -196,7 +196,7 @@ impl CrateContext {
196196
non_inlineable_statics: HashSet::new(),
197197
monomorphized: RefCell::new(HashMap::new()),
198198
monomorphizing: RefCell::new(HashMap::new()),
199-
vtables: HashMap::new(),
199+
vtables: RefCell::new(HashMap::new()),
200200
const_cstr_cache: HashMap::new(),
201201
const_globals: HashMap::new(),
202202
const_values: HashMap::new(),

src/librustc/middle/trans/meth.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,12 @@ pub fn get_vtable(bcx: @Block,
539539

540540
// Check the cache.
541541
let hash_id = (self_ty, vtable_id(ccx, &origins[0]));
542-
match ccx.vtables.find(&hash_id) {
543-
Some(&val) => { return val }
544-
None => { }
542+
{
543+
let vtables = ccx.vtables.borrow();
544+
match vtables.get().find(&hash_id) {
545+
Some(&val) => { return val }
546+
None => { }
547+
}
545548
}
546549

547550
// Not in the cache. Actually build it.
@@ -559,7 +562,9 @@ pub fn get_vtable(bcx: @Block,
559562
glue::lazily_emit_all_tydesc_glue(ccx, tydesc);
560563

561564
let vtable = make_vtable(ccx, tydesc, methods);
562-
ccx.vtables.insert(hash_id, vtable);
565+
566+
let mut vtables = ccx.vtables.borrow_mut();
567+
vtables.get().insert(hash_id, vtable);
563568
return vtable;
564569
}
565570

0 commit comments

Comments
 (0)