Skip to content

Commit 7e42817

Browse files
committed
---
yaml --- r: 96972 b: refs/heads/dist-snap c: d16cca1 h: refs/heads/master v: v3
1 parent a6017ca commit 7e42817

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 28943e96cb0f0dfb05b3b5ce604c5a0fb8e24095
9+
refs/heads/dist-snap: d16cca1f50d97e78334cba96bba0e6e0235cae7d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/trans/base.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,7 +2233,9 @@ pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) {
22332233
"cannot have static_assert on a mutable \
22342234
static");
22352235
}
2236-
let v = ccx.const_values.get_copy(&item.id);
2236+
2237+
let const_values = ccx.const_values.borrow();
2238+
let v = const_values.get().get_copy(&item.id);
22372239
unsafe {
22382240
if !(llvm::LLVMConstIntGetZExtValue(v) != 0) {
22392241
ccx.sess.span_fatal(expr.span, "static assertion failed");
@@ -2489,7 +2491,11 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
24892491
// We need the translated value here, because for enums the
24902492
// LLVM type is not fully determined by the Rust type.
24912493
let (v, inlineable) = consts::const_expr(ccx, expr);
2492-
ccx.const_values.insert(id, v);
2494+
{
2495+
let mut const_values = ccx.const_values
2496+
.borrow_mut();
2497+
const_values.get().insert(id, v);
2498+
}
24932499
let mut inlineable = inlineable;
24942500

24952501
unsafe {

branches/dist-snap/src/librustc/middle/trans/consts.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ fn const_deref(cx: &mut CrateContext, v: ValueRef, t: ty::t, explicit: bool)
157157

158158
pub fn get_const_val(cx: @mut CrateContext,
159159
mut def_id: ast::DefId) -> (ValueRef, bool) {
160-
let contains_key = cx.const_values.contains_key(&def_id.node);
160+
let contains_key = {
161+
let const_values = cx.const_values.borrow();
162+
const_values.get().contains_key(&def_id.node)
163+
};
161164
if !ast_util::is_local(def_id) || !contains_key {
162165
if !ast_util::is_local(def_id) {
163166
def_id = inline::maybe_instantiate_inline(cx, def_id);
@@ -171,7 +174,9 @@ pub fn get_const_val(cx: @mut CrateContext,
171174
_ => cx.tcx.sess.bug("expected a const to be an item")
172175
}
173176
}
174-
(cx.const_values.get_copy(&def_id.node),
177+
178+
let const_values = cx.const_values.borrow();
179+
(const_values.get().get_copy(&def_id.node),
175180
!cx.non_inlineable_statics.contains(&def_id.node))
176181
}
177182

@@ -642,7 +647,8 @@ pub fn trans_const(ccx: @mut CrateContext, m: ast::Mutability, id: ast::NodeId)
642647
let g = base::get_item_val(ccx, id);
643648
// At this point, get_item_val has already translated the
644649
// constant's initializer to determine its LLVM type.
645-
let v = ccx.const_values.get_copy(&id);
650+
let const_values = ccx.const_values.borrow();
651+
let v = const_values.get().get_copy(&id);
646652
llvm::LLVMSetInitializer(g, v);
647653
if m != ast::MutMutable {
648654
llvm::LLVMSetGlobalConstant(g, True);

branches/dist-snap/src/librustc/middle/trans/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub struct CrateContext {
8484
const_globals: RefCell<HashMap<int, ValueRef>>,
8585

8686
// Cache of emitted const values
87-
const_values: HashMap<ast::NodeId, ValueRef>,
87+
const_values: RefCell<HashMap<ast::NodeId, ValueRef>>,
8888

8989
// Cache of external const values
9090
extern_const_values: HashMap<ast::DefId, ValueRef>,
@@ -199,7 +199,7 @@ impl CrateContext {
199199
vtables: RefCell::new(HashMap::new()),
200200
const_cstr_cache: RefCell::new(HashMap::new()),
201201
const_globals: RefCell::new(HashMap::new()),
202-
const_values: HashMap::new(),
202+
const_values: RefCell::new(HashMap::new()),
203203
extern_const_values: HashMap::new(),
204204
impl_method_cache: HashMap::new(),
205205
module_data: HashMap::new(),

0 commit comments

Comments
 (0)