Skip to content

Commit 031c58b

Browse files
committed
---
yaml --- r: 88888 b: refs/heads/snap-stage3 c: d3f58c5 h: refs/heads/master v: v3
1 parent 775fb86 commit 031c58b

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: deeca5d586bfaa4aa60246f671a8d611d38f6248
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: b5218ba6ad05f0c5a31575b2fe59949b3dc25129
4+
refs/heads/snap-stage3: d3f58c59e48552612b8a177b527a5dcd0d6a1149
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub struct CrateContext {
7070
non_inlineable_statics: HashSet<ast::NodeId>,
7171
// Cache instances of monomorphized functions
7272
monomorphized: RefCell<HashMap<mono_id, ValueRef>>,
73-
monomorphizing: HashMap<ast::DefId, uint>,
73+
monomorphizing: RefCell<HashMap<ast::DefId, uint>>,
7474
// Cache generated vtables
7575
vtables: HashMap<(ty::t, mono_id), ValueRef>,
7676
// Cache of constant strings,
@@ -201,7 +201,7 @@ impl CrateContext {
201201
external_srcs: HashMap::new(),
202202
non_inlineable_statics: HashSet::new(),
203203
monomorphized: RefCell::new(HashMap::new()),
204-
monomorphizing: HashMap::new(),
204+
monomorphizing: RefCell::new(HashMap::new()),
205205
vtables: HashMap::new(),
206206
const_cstr_cache: HashMap::new(),
207207
const_globals: HashMap::new(),

branches/snap-stage3/src/librustc/middle/trans/monomorphize.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,22 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
184184

185185
ccx.stats.n_monos += 1;
186186

187-
let depth = match ccx.monomorphizing.find(&fn_id) {
188-
Some(&d) => d, None => 0
189-
};
190-
// Random cut-off -- code that needs to instantiate the same function
191-
// recursively more than thirty times can probably safely be assumed to be
192-
// causing an infinite expansion.
193-
if depth > 30 {
194-
ccx.sess.span_fatal(
195-
span, "overly deep expansion of inlined function");
187+
let depth;
188+
{
189+
let mut monomorphizing = ccx.monomorphizing.borrow_mut();
190+
depth = match monomorphizing.get().find(&fn_id) {
191+
Some(&d) => d, None => 0
192+
};
193+
194+
// Random cut-off -- code that needs to instantiate the same function
195+
// recursively more than thirty times can probably safely be assumed
196+
// to be causing an infinite expansion.
197+
if depth > 30 {
198+
ccx.sess.span_fatal(
199+
span, "overly deep expansion of inlined function");
200+
}
201+
monomorphizing.get().insert(fn_id, depth + 1);
196202
}
197-
ccx.monomorphizing.insert(fn_id, depth + 1);
198203

199204
let (_, elt) = gensym_name(ccx.sess.str_of(name));
200205
let mut pt = (*pt).clone();
@@ -292,7 +297,11 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
292297
ccx.tcx.sess.bug(format!("Can't monomorphize a {:?}", map_node))
293298
}
294299
};
295-
ccx.monomorphizing.insert(fn_id, depth);
300+
301+
{
302+
let mut monomorphizing = ccx.monomorphizing.borrow_mut();
303+
monomorphizing.get().insert(fn_id, depth);
304+
}
296305

297306
debug!("leaving monomorphic fn {}", ty::item_path_str(ccx.tcx, fn_id));
298307
(lldecl, must_cast)

0 commit comments

Comments
 (0)