librustc: De-@mut the borrow check's root map

This commit is contained in:
Patrick Walton 2013-12-19 19:54:52 -08:00
parent c4661fd258
commit 72f9cbe8ac
5 changed files with 17 additions and 9 deletions

View file

@ -279,7 +279,9 @@ impl<'a> GuaranteeLifetimeContext<'a> {
// Add a record of what is required
let rm_key = root_map_key {id: cmt_deref.id, derefs: derefs};
let root_info = RootInfo {scope: root_scope, freeze: opt_dyna};
self.bccx.root_map.insert(rm_key, root_info);
let mut root_map = self.bccx.root_map.borrow_mut();
root_map.get().insert(rm_key, root_info);
debug!("root_key: {:?} root_info: {:?}", rm_key, root_info);
Ok(())

View file

@ -20,6 +20,7 @@ use middle::dataflow::DataFlowOperator;
use util::common::stmt_set;
use util::ppaux::{note_and_explain_region, Repr, UserString};
use std::cell::RefCell;
use std::hashmap::{HashSet, HashMap};
use std::ops::{BitOr, BitAnd};
use std::result::{Result};
@ -413,10 +414,10 @@ pub struct RootInfo {
freeze: Option<DynaFreezeKind> // Some() if we should freeze box at runtime
}
pub type root_map = @mut HashMap<root_map_key, RootInfo>;
pub type root_map = @RefCell<HashMap<root_map_key, RootInfo>>;
pub fn root_map() -> root_map {
return @mut HashMap::new();
return @RefCell::new(HashMap::new());
}
pub enum DynaFreezeKind {

View file

@ -19,6 +19,7 @@ use syntax::visit;
use syntax::visit::Visitor;
use syntax::ast::*;
use std::cell::RefCell;
use std::hashmap::{HashMap, HashSet};
//
@ -119,7 +120,7 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt,
}
}
let maps = astencode::Maps {
root_map: @mut HashMap::new(),
root_map: @RefCell::new(HashMap::new()),
method_map: @mut HashMap::new(),
vtable_map: @mut HashMap::new(),
write_guard_map: @mut HashSet::new(),
@ -169,7 +170,7 @@ pub fn lookup_const_by_id(tcx: ty::ctxt,
}
}
let maps = astencode::Maps {
root_map: @mut HashMap::new(),
root_map: @RefCell::new(HashMap::new()),
method_map: @mut HashMap::new(),
vtable_map: @mut HashMap::new(),
write_guard_map: @mut HashSet::new(),

View file

@ -1112,7 +1112,8 @@ fn pats_require_rooting(bcx: @Block,
m.iter().any(|br| {
let pat_id = br.pats[col].id;
let key = root_map_key {id: pat_id, derefs: 0u };
bcx.ccx().maps.root_map.contains_key(&key)
let root_map = bcx.ccx().maps.root_map.borrow();
root_map.get().contains_key(&key)
})
}

View file

@ -45,9 +45,12 @@ pub fn root_and_write_guard(datum: &Datum,
//
// (Note: root'd values are always boxes)
let ccx = bcx.ccx();
bcx = match ccx.maps.root_map.find(&key) {
None => bcx,
Some(&root_info) => root(datum, bcx, span, key, root_info)
bcx = {
let root_map = ccx.maps.root_map.borrow();
match root_map.get().find(&key) {
None => bcx,
Some(&root_info) => root(datum, bcx, span, key, root_info)
}
};
// Perform the write guard, if necessary.