Skip to content

Commit 1c8554c

Browse files
committed
---
yaml --- r: 97160 b: refs/heads/dist-snap c: 8c70364 h: refs/heads/master v: v3
1 parent ae484bc commit 1c8554c

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
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: 4b4ff2cf8b5f888581d41b3b2f10dacf7d716478
9+
refs/heads/dist-snap: 8c703643ad0bb1c70c249dc16b5a32e253815be1
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/reachable.rs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ struct ReachableContext {
8888
reachable_symbols: @RefCell<HashSet<ast::NodeId>>,
8989
// A worklist of item IDs. Each item ID in this worklist will be inlined
9090
// and will be scanned for further references.
91-
worklist: @mut ~[ast::NodeId],
91+
worklist: @RefCell<~[ast::NodeId]>,
9292
}
9393

9494
struct MarkSymbolVisitor {
95-
worklist: @mut ~[ast::NodeId],
95+
worklist: @RefCell<~[ast::NodeId]>,
9696
method_map: typeck::method_map,
9797
tcx: ty::ctxt,
9898
reachable_symbols: @RefCell<HashSet<ast::NodeId>>,
@@ -116,15 +116,19 @@ impl Visitor<()> for MarkSymbolVisitor {
116116
if is_local(def_id) {
117117
if ReachableContext::
118118
def_id_represents_local_inlined_item(self.tcx, def_id) {
119-
self.worklist.push(def_id.node)
119+
{
120+
let mut worklist = self.worklist.borrow_mut();
121+
worklist.get().push(def_id.node)
122+
}
120123
} else {
121124
match def {
122125
// If this path leads to a static, then we may have
123126
// to do some work to figure out whether the static
124127
// is indeed reachable (address_insignificant
125128
// statics are *never* reachable).
126129
ast::DefStatic(..) => {
127-
self.worklist.push(def_id.node);
130+
let mut worklist = self.worklist.borrow_mut();
131+
worklist.get().push(def_id.node);
128132
}
129133

130134
// If this wasn't a static, then this destination is
@@ -150,7 +154,11 @@ impl Visitor<()> for MarkSymbolVisitor {
150154
def_id_represents_local_inlined_item(
151155
self.tcx,
152156
def_id) {
153-
self.worklist.push(def_id.node)
157+
{
158+
let mut worklist = self.worklist
159+
.borrow_mut();
160+
worklist.get().push(def_id.node)
161+
}
154162
}
155163
{
156164
let mut reachable_symbols =
@@ -186,7 +194,7 @@ impl ReachableContext {
186194
tcx: tcx,
187195
method_map: method_map,
188196
reachable_symbols: @RefCell::new(HashSet::new()),
189-
worklist: @mut ~[],
197+
worklist: @RefCell::new(~[]),
190198
}
191199
}
192200

@@ -265,11 +273,19 @@ impl ReachableContext {
265273
fn propagate(&self) {
266274
let mut visitor = self.init_visitor();
267275
let mut scanned = HashSet::new();
268-
while self.worklist.len() > 0 {
269-
let search_item = self.worklist.pop();
270-
if scanned.contains(&search_item) {
271-
continue
272-
}
276+
loop {
277+
let search_item = {
278+
let mut worklist = self.worklist.borrow_mut();
279+
if worklist.get().len() == 0 {
280+
break
281+
}
282+
let search_item = worklist.get().pop();
283+
if scanned.contains(&search_item) {
284+
continue
285+
}
286+
search_item
287+
};
288+
273289
scanned.insert(search_item);
274290
match self.tcx.items.find(&search_item) {
275291
Some(item) => self.propagate_node(item, search_item,
@@ -407,7 +423,8 @@ pub fn find_reachable(tcx: ty::ctxt,
407423
// Step 1: Seed the worklist with all nodes which were found to be public as
408424
// a result of the privacy pass
409425
for &id in exported_items.iter() {
410-
reachable_context.worklist.push(id);
426+
let mut worklist = reachable_context.worklist.borrow_mut();
427+
worklist.get().push(id);
411428
}
412429

413430
// Step 2: Mark all symbols that the symbols on the worklist touch.

0 commit comments

Comments
 (0)