librustc: De-@mut
llargs
and lllocals
in the function context
This commit is contained in:
parent
a5f4a40f24
commit
82f5a380a4
@ -1358,8 +1358,6 @@ fn insert_lllocals(bcx: @Block,
|
||||
* the bindings.
|
||||
*/
|
||||
|
||||
let llmap = bcx.fcx.lllocals;
|
||||
|
||||
for (&ident, &binding_info) in bindings_map.iter() {
|
||||
let llval = match binding_info.trmode {
|
||||
// By value bindings: use the stack slot that we
|
||||
@ -1378,8 +1376,13 @@ fn insert_lllocals(bcx: @Block,
|
||||
}
|
||||
};
|
||||
|
||||
debug!("binding {:?} to {}", binding_info.id, bcx.val_to_str(llval));
|
||||
llmap.insert(binding_info.id, llval);
|
||||
{
|
||||
debug!("binding {:?} to {}",
|
||||
binding_info.id,
|
||||
bcx.val_to_str(llval));
|
||||
let mut llmap = bcx.fcx.lllocals.borrow_mut();
|
||||
llmap.get().insert(binding_info.id, llval);
|
||||
}
|
||||
|
||||
if bcx.sess().opts.extra_debuginfo {
|
||||
debuginfo::create_match_binding_metadata(bcx,
|
||||
@ -1442,7 +1445,8 @@ fn compile_guard(bcx: @Block,
|
||||
}
|
||||
TrByRef => {}
|
||||
}
|
||||
bcx.fcx.lllocals.remove(&binding_info.id);
|
||||
let mut lllocals = bcx.fcx.lllocals.borrow_mut();
|
||||
lllocals.get().remove(&binding_info.id);
|
||||
}
|
||||
return bcx;
|
||||
}
|
||||
@ -2057,7 +2061,8 @@ pub fn store_arg(mut bcx: @Block,
|
||||
// Optimized path for `x: T` case. This just adopts
|
||||
// `llval` wholesale as the pointer for `x`, avoiding the
|
||||
// general logic which may copy out of `llval`.
|
||||
bcx.fcx.llargs.insert(pat.id, llval);
|
||||
let mut llargs = bcx.fcx.llargs.borrow_mut();
|
||||
llargs.get().insert(pat.id, llval);
|
||||
} else {
|
||||
// General path. Copy out the values that are used in the
|
||||
// pattern.
|
||||
@ -2077,11 +2082,11 @@ fn mk_binding_alloca(mut bcx: @Block,
|
||||
let ident = ast_util::path_to_ident(path);
|
||||
let llval = alloc_ty(bcx, var_ty, bcx.ident(ident));
|
||||
bcx = populate(bcx, var_ty, llval);
|
||||
let llmap = match binding_mode {
|
||||
BindLocal => bcx.fcx.lllocals,
|
||||
BindArgument => bcx.fcx.llargs
|
||||
let mut llmap = match binding_mode {
|
||||
BindLocal => bcx.fcx.lllocals.borrow_mut(),
|
||||
BindArgument => bcx.fcx.llargs.borrow_mut(),
|
||||
};
|
||||
llmap.insert(p_id, llval);
|
||||
llmap.get().insert(p_id, llval);
|
||||
add_clean(bcx, llval, var_ty);
|
||||
return bcx;
|
||||
}
|
||||
|
@ -1692,8 +1692,8 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
|
||||
llself: None,
|
||||
personality: None,
|
||||
caller_expects_out_pointer: uses_outptr,
|
||||
llargs: @mut HashMap::new(),
|
||||
lllocals: @mut HashMap::new(),
|
||||
llargs: RefCell::new(HashMap::new()),
|
||||
lllocals: RefCell::new(HashMap::new()),
|
||||
llupvars: RefCell::new(HashMap::new()),
|
||||
id: id,
|
||||
param_substs: param_substs,
|
||||
@ -2146,7 +2146,10 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
|
||||
fcx.llretptr.unwrap(),
|
||||
disr,
|
||||
i);
|
||||
let llarg = fcx.llargs.get_copy(&fn_arg.pat.id);
|
||||
let llarg = {
|
||||
let llargs = fcx.llargs.borrow();
|
||||
llargs.get().get_copy(&fn_arg.pat.id)
|
||||
};
|
||||
let arg_ty = arg_tys[i];
|
||||
memcpy_ty(bcx, lldestptr, llarg, arg_ty);
|
||||
}
|
||||
|
@ -240,10 +240,10 @@ pub struct FunctionContext {
|
||||
caller_expects_out_pointer: bool,
|
||||
|
||||
// Maps arguments to allocas created for them in llallocas.
|
||||
llargs: @mut HashMap<ast::NodeId, ValueRef>,
|
||||
llargs: RefCell<HashMap<ast::NodeId, ValueRef>>,
|
||||
// Maps the def_ids for local variables to the allocas created for
|
||||
// them in llallocas.
|
||||
lllocals: @mut HashMap<ast::NodeId, ValueRef>,
|
||||
lllocals: RefCell<HashMap<ast::NodeId, ValueRef>>,
|
||||
// Same as above, but for closure upvars
|
||||
llupvars: RefCell<HashMap<ast::NodeId, ValueRef>>,
|
||||
|
||||
|
@ -298,11 +298,15 @@ pub fn create_local_var_metadata(bcx: @Block,
|
||||
let var_ident = ast_util::path_to_ident(path_ref);
|
||||
let var_type = node_id_type(bcx, node_id);
|
||||
|
||||
let llptr = match bcx.fcx.lllocals.find_copy(&node_id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
bcx.tcx().sess.span_bug(span,
|
||||
format!("No entry in lllocals table for {:?}", node_id));
|
||||
let llptr = {
|
||||
let lllocals = bcx.fcx.lllocals.borrow();
|
||||
match lllocals.get().find_copy(&node_id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
bcx.tcx().sess.span_bug(span,
|
||||
format!("No entry in lllocals table for {:?}",
|
||||
node_id));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -397,10 +401,17 @@ pub fn create_match_binding_metadata(bcx: @Block,
|
||||
return;
|
||||
}
|
||||
|
||||
let llptr = match bcx.fcx.lllocals.find_copy(&node_id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
bcx.tcx().sess.span_bug(span, format!("No entry in lllocals table for {:?}", node_id));
|
||||
let llptr = {
|
||||
let lllocals = bcx.fcx.lllocals.borrow();
|
||||
match lllocals.get().find_copy(&node_id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
bcx.tcx()
|
||||
.sess
|
||||
.span_bug(span,
|
||||
format!("No entry in lllocals table for {:?}",
|
||||
node_id));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -506,11 +517,15 @@ pub fn create_argument_metadata(bcx: @Block,
|
||||
let scope_metadata = bcx.fcx.debug_context.get_ref(cx, arg.pat.span).fn_metadata;
|
||||
|
||||
pat_util::pat_bindings(def_map, arg.pat, |_, node_id, span, path_ref| {
|
||||
let llptr = match bcx.fcx.llargs.find_copy(&node_id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
bcx.tcx().sess.span_bug(span,
|
||||
format!("No entry in llargs table for {:?}", node_id));
|
||||
let llptr = {
|
||||
let llargs = bcx.fcx.llargs.borrow();
|
||||
match llargs.get().find_copy(&node_id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
bcx.tcx().sess.span_bug(span,
|
||||
format!("No entry in llargs table for {:?}",
|
||||
node_id));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1100,10 +1100,12 @@ pub fn trans_local_var(bcx: @Block, def: ast::Def) -> Datum {
|
||||
}
|
||||
}
|
||||
ast::DefArg(nid, _) => {
|
||||
take_local(bcx, bcx.fcx.llargs, nid)
|
||||
let llargs = bcx.fcx.llargs.borrow();
|
||||
take_local(bcx, llargs.get(), nid)
|
||||
}
|
||||
ast::DefLocal(nid, _) | ast::DefBinding(nid, _) => {
|
||||
take_local(bcx, bcx.fcx.lllocals, nid)
|
||||
let lllocals = bcx.fcx.lllocals.borrow();
|
||||
take_local(bcx, lllocals.get(), nid)
|
||||
}
|
||||
ast::DefSelf(nid, _) => {
|
||||
let self_info: ValSelfData = match bcx.fcx.llself {
|
||||
|
Loading…
x
Reference in New Issue
Block a user