librustc: De-@mut the vtable map
This commit is contained in:
parent
dd745b388d
commit
4fe1cb1aff
8 changed files with 40 additions and 23 deletions
|
|
@ -992,7 +992,8 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
|
|||
}
|
||||
|
||||
{
|
||||
let r = maps.vtable_map.find(&id);
|
||||
let vtable_map = maps.vtable_map.borrow();
|
||||
let r = vtable_map.get().find(&id);
|
||||
for &dr in r.iter() {
|
||||
ebml_w.tag(c::tag_table_vtable_map, |ebml_w| {
|
||||
ebml_w.id(id);
|
||||
|
|
@ -1267,9 +1268,11 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
|
|||
val_dsr.read_method_map_entry(xcx));
|
||||
}
|
||||
c::tag_table_vtable_map => {
|
||||
dcx.maps.vtable_map.insert(
|
||||
id,
|
||||
val_dsr.read_vtable_res(xcx.dcx.tcx, xcx.dcx.cdata));
|
||||
let vtable_res =
|
||||
val_dsr.read_vtable_res(xcx.dcx.tcx,
|
||||
xcx.dcx.cdata);
|
||||
let mut vtable_map = dcx.maps.vtable_map.borrow_mut();
|
||||
vtable_map.get().insert(id, vtable_res);
|
||||
}
|
||||
c::tag_table_adjustments => {
|
||||
let adj: @ty::AutoAdjustment = @Decodable::decode(val_dsr);
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt,
|
|||
let maps = astencode::Maps {
|
||||
root_map: @RefCell::new(HashMap::new()),
|
||||
method_map: @mut HashMap::new(),
|
||||
vtable_map: @mut HashMap::new(),
|
||||
vtable_map: @RefCell::new(HashMap::new()),
|
||||
write_guard_map: @mut HashSet::new(),
|
||||
capture_map: @RefCell::new(HashMap::new())
|
||||
};
|
||||
|
|
@ -172,7 +172,7 @@ pub fn lookup_const_by_id(tcx: ty::ctxt,
|
|||
let maps = astencode::Maps {
|
||||
root_map: @RefCell::new(HashMap::new()),
|
||||
method_map: @mut HashMap::new(),
|
||||
vtable_map: @mut HashMap::new(),
|
||||
vtable_map: @RefCell::new(HashMap::new()),
|
||||
write_guard_map: @mut HashSet::new(),
|
||||
capture_map: @RefCell::new(HashMap::new())
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1160,7 +1160,8 @@ pub fn node_id_type_params(bcx: &Block, id: ast::NodeId) -> ~[ty::t] {
|
|||
|
||||
pub fn node_vtables(bcx: @Block, id: ast::NodeId)
|
||||
-> Option<typeck::vtable_res> {
|
||||
let raw_vtables = bcx.ccx().maps.vtable_map.find(&id);
|
||||
let vtable_map = bcx.ccx().maps.vtable_map.borrow();
|
||||
let raw_vtables = vtable_map.get().find(&id);
|
||||
raw_vtables.map(|vts| resolve_vtables_in_fn_ctxt(bcx.fcx, *vts))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -262,8 +262,11 @@ pub fn trans_static_method_callee(bcx: @Block,
|
|||
debug!("trans_static_method_callee: method_id={:?}, callee_id={:?}, \
|
||||
name={}", method_id, callee_id, ccx.sess.str_of(mname));
|
||||
|
||||
let vtbls = resolve_vtables_in_fn_ctxt(
|
||||
bcx.fcx, ccx.maps.vtable_map.get_copy(&callee_id));
|
||||
let vtbls = {
|
||||
let vtable_map = ccx.maps.vtable_map.borrow();
|
||||
vtable_map.get().get_copy(&callee_id)
|
||||
};
|
||||
let vtbls = resolve_vtables_in_fn_ctxt(bcx.fcx, vtbls);
|
||||
|
||||
match vtbls[bound_index][0] {
|
||||
typeck::vtable_static(impl_did, ref rcvr_substs, rcvr_origins) => {
|
||||
|
|
@ -670,8 +673,11 @@ pub fn trans_trait_cast(bcx: @Block,
|
|||
// Store the vtable into the pair or triple.
|
||||
// This is structured a bit funny because of dynamic borrow failures.
|
||||
let origins = {
|
||||
let res = ccx.maps.vtable_map.get(&id);
|
||||
let res = resolve_vtables_in_fn_ctxt(bcx.fcx, *res);
|
||||
let res = {
|
||||
let vtable_map = ccx.maps.vtable_map.borrow();
|
||||
*vtable_map.get().get(&id)
|
||||
};
|
||||
let res = resolve_vtables_in_fn_ctxt(bcx.fcx, res);
|
||||
res[0]
|
||||
};
|
||||
let vtable = get_vtable(bcx, v_ty, origins);
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ impl Inherited {
|
|||
node_type_substs: RefCell::new(HashMap::new()),
|
||||
adjustments: RefCell::new(HashMap::new()),
|
||||
method_map: @mut HashMap::new(),
|
||||
vtable_map: @mut HashMap::new(),
|
||||
vtable_map: @RefCell::new(HashMap::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -538,7 +538,8 @@ fn insert_vtables(fcx: @FnCtxt,
|
|||
vtables: vtable_res) {
|
||||
debug!("insert_vtables(callee_id={}, vtables={:?})",
|
||||
callee_id, vtables.repr(fcx.tcx()));
|
||||
fcx.inh.vtable_map.insert(callee_id, vtables);
|
||||
let mut vtable_map = fcx.inh.vtable_map.borrow_mut();
|
||||
vtable_map.get().insert(callee_id, vtables);
|
||||
}
|
||||
|
||||
pub fn location_info_for_expr(expr: @ast::Expr) -> LocationInfo {
|
||||
|
|
|
|||
|
|
@ -82,14 +82,20 @@ fn resolve_method_map_entry(fcx: @FnCtxt, sp: Span, id: ast::NodeId) {
|
|||
|
||||
fn resolve_vtable_map_entry(fcx: @FnCtxt, sp: Span, id: ast::NodeId) {
|
||||
// Resolve any method map entry
|
||||
match fcx.inh.vtable_map.find(&id) {
|
||||
None => {}
|
||||
Some(origins) => {
|
||||
let r_origins = resolve_origins(fcx, sp, *origins);
|
||||
let vtable_map = fcx.ccx.vtable_map;
|
||||
vtable_map.insert(id, r_origins);
|
||||
debug!("writeback::resolve_vtable_map_entry(id={}, vtables={:?})",
|
||||
id, r_origins.repr(fcx.tcx()));
|
||||
{
|
||||
let origins_opt = {
|
||||
let vtable_map = fcx.inh.vtable_map.borrow();
|
||||
vtable_map.get().find_copy(&id)
|
||||
};
|
||||
match origins_opt {
|
||||
None => {}
|
||||
Some(origins) => {
|
||||
let r_origins = resolve_origins(fcx, sp, origins);
|
||||
let mut vtable_map = fcx.ccx.vtable_map.borrow_mut();
|
||||
vtable_map.get().insert(id, r_origins);
|
||||
debug!("writeback::resolve_vtable_map_entry(id={}, vtables={:?})",
|
||||
id, r_origins.repr(fcx.tcx()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ impl Repr for vtable_origin {
|
|||
}
|
||||
}
|
||||
|
||||
pub type vtable_map = @mut HashMap<ast::NodeId, vtable_res>;
|
||||
pub type vtable_map = @RefCell<HashMap<ast::NodeId, vtable_res>>;
|
||||
|
||||
|
||||
// Information about the vtable resolutions for for a trait impl.
|
||||
|
|
@ -459,7 +459,7 @@ pub fn check_crate(tcx: ty::ctxt,
|
|||
let ccx = @mut CrateCtxt {
|
||||
trait_map: trait_map,
|
||||
method_map: @mut HashMap::new(),
|
||||
vtable_map: @mut HashMap::new(),
|
||||
vtable_map: @RefCell::new(HashMap::new()),
|
||||
tcx: tcx
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue