Skip to content

Commit 8f50428

Browse files
committed
Removed the _frozen methods from dataflow API.
Calls to methods like `each_bit_on_entry_frozen` and `each_gen_bit_frozen` now go to the `each_bit_on_entry` and `each_gen_bit` methods.
1 parent fc4f6ed commit 8f50428

File tree

3 files changed

+44
-52
lines changed

3 files changed

+44
-52
lines changed

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'a> CheckLoanCtxt<'a> {
172172
//! are issued for future scopes and thus they may have been
173173
//! *issued* but not yet be in effect.
174174
175-
self.dfcx_loans.each_bit_on_entry_frozen(scope_id, |loan_index| {
175+
self.dfcx_loans.each_bit_on_entry(scope_id, |loan_index| {
176176
let loan = &self.all_loans[loan_index];
177177
op(loan)
178178
})
@@ -271,7 +271,7 @@ impl<'a> CheckLoanCtxt<'a> {
271271
//! we encounter `scope_id`.
272272
273273
let mut result = Vec::new();
274-
self.dfcx_loans.each_gen_bit_frozen(scope_id, |loan_index| {
274+
self.dfcx_loans.each_gen_bit(scope_id, |loan_index| {
275275
result.push(loan_index);
276276
true
277277
});

src/librustc/middle/borrowck/move_data.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ impl<'a> FlowedMoveData<'a> {
576576
* Iterates through each path moved by `id`
577577
*/
578578

579-
self.dfcx_moves.each_gen_bit_frozen(id, |index| {
579+
self.dfcx_moves.each_gen_bit(id, |index| {
580580
let move = self.move_data.moves.borrow();
581581
let move = move.get(index);
582582
let moved_path = move.path;
@@ -592,7 +592,7 @@ impl<'a> FlowedMoveData<'a> {
592592
593593
let mut ret = None;
594594
for loan_path_index in self.move_data.path_map.borrow().find(&*loan_path).iter() {
595-
self.dfcx_moves.each_gen_bit_frozen(id, |move_index| {
595+
self.dfcx_moves.each_gen_bit(id, |move_index| {
596596
let move = self.move_data.moves.borrow();
597597
let move = move.get(move_index);
598598
if move.path == **loan_path_index {
@@ -637,7 +637,7 @@ impl<'a> FlowedMoveData<'a> {
637637

638638
let mut ret = true;
639639

640-
self.dfcx_moves.each_bit_on_entry_frozen(id, |index| {
640+
self.dfcx_moves.each_bit_on_entry(id, |index| {
641641
let move = self.move_data.moves.borrow();
642642
let move = move.get(index);
643643
let moved_path = move.path;
@@ -693,7 +693,7 @@ impl<'a> FlowedMoveData<'a> {
693693
}
694694
};
695695

696-
self.dfcx_assign.each_bit_on_entry_frozen(id, |index| {
696+
self.dfcx_assign.each_bit_on_entry(id, |index| {
697697
let assignment = self.move_data.var_assignments.borrow();
698698
let assignment = assignment.get(index);
699699
if assignment.path == loan_path_index && !f(assignment) {

src/librustc/middle/dataflow.rs

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,6 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> {
9797
assert!(n != ast::DUMMY_NODE_ID);
9898
self.nodeid_to_index.contains_key(&n)
9999
}
100-
fn has_bitset_for_cfgidx(&self, _cfgidx: CFGIndex) -> bool {
101-
true
102-
}
103-
fn get_bitset_index(&self, cfgidx: CFGIndex) -> uint {
104-
cfgidx.node_id()
105-
}
106-
fn get_or_create_bitset_index(&mut self, cfgidx: CFGIndex) -> uint {
107-
cfgidx.node_id()
108-
}
109100
}
110101

111102
impl<'a, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, O> {
@@ -120,8 +111,9 @@ impl<'a, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, O> {
120111
};
121112

122113
if self.has_bitset_for_nodeid(id) {
114+
assert!(self.bits_per_id > 0);
123115
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
124-
let (start, end) = self.compute_id_range_frozen(cfgidx);
116+
let (start, end) = self.compute_id_range(cfgidx);
125117
let on_entry = self.on_entry.slice(start, end);
126118
let entry_str = bits_to_string(on_entry);
127119

@@ -232,6 +224,8 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> {
232224
debug!("{:s} add_gen(id={:?}, bit={:?})",
233225
self.analysis_name, id, bit);
234226
assert!(self.nodeid_to_index.contains_key(&id));
227+
assert!(self.bits_per_id > 0);
228+
235229
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
236230
let (start, end) = self.compute_id_range(cfgidx);
237231
let gens = self.gens.mut_slice(start, end);
@@ -243,32 +237,21 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> {
243237
debug!("{:s} add_kill(id={:?}, bit={:?})",
244238
self.analysis_name, id, bit);
245239
assert!(self.nodeid_to_index.contains_key(&id));
240+
assert!(self.bits_per_id > 0);
241+
246242
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
247243
let (start, end) = self.compute_id_range(cfgidx);
248244
let kills = self.kills.mut_slice(start, end);
249245
set_bit(kills, bit);
250246
}
251247

252-
fn apply_gen_kill(&mut self, cfgidx: CFGIndex, bits: &mut [uint]) {
248+
fn apply_gen_kill(&self, cfgidx: CFGIndex, bits: &mut [uint]) {
253249
//! Applies the gen and kill sets for `cfgidx` to `bits`
254250
debug!("{:s} apply_gen_kill(cfgidx={}, bits={}) [before]",
255251
self.analysis_name, cfgidx, mut_bits_to_string(bits));
256-
let (start, end) = self.compute_id_range(cfgidx);
257-
let gens = self.gens.slice(start, end);
258-
bitwise(bits, gens, &Union);
259-
let kills = self.kills.slice(start, end);
260-
bitwise(bits, kills, &Subtract);
261-
262-
debug!("{:s} apply_gen_kill(cfgidx={}, bits={}) [after]",
263-
self.analysis_name, cfgidx, mut_bits_to_string(bits));
264-
}
252+
assert!(self.bits_per_id > 0);
265253

266-
fn apply_gen_kill_frozen(&self, cfgidx: CFGIndex, bits: &mut [uint]) {
267-
//! Applies the gen and kill sets for `cfgidx` to `bits`
268-
//! Only useful after `propagate()` has been called.
269-
debug!("{:s} apply_gen_kill(cfgidx={}, bits={}) [before]",
270-
self.analysis_name, cfgidx, mut_bits_to_string(bits));
271-
let (start, end) = self.compute_id_range_frozen(cfgidx);
254+
let (start, end) = self.compute_id_range(cfgidx);
272255
let gens = self.gens.slice(start, end);
273256
bitwise(bits, gens, &Union);
274257
let kills = self.kills.slice(start, end);
@@ -278,15 +261,8 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> {
278261
self.analysis_name, cfgidx, mut_bits_to_string(bits));
279262
}
280263

281-
fn compute_id_range_frozen(&self, cfgidx: CFGIndex) -> (uint, uint) {
282-
let n = self.get_bitset_index(cfgidx);
283-
let start = n * self.words_per_id;
284-
let end = start + self.words_per_id;
285-
(start, end)
286-
}
287-
288-
fn compute_id_range(&mut self, cfgidx: CFGIndex) -> (uint, uint) {
289-
let n = self.get_or_create_bitset_index(cfgidx);
264+
fn compute_id_range(&self, cfgidx: CFGIndex) -> (uint, uint) {
265+
let n = cfgidx.node_id();
290266
let start = n * self.words_per_id;
291267
let end = start + self.words_per_id;
292268

@@ -299,10 +275,10 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> {
299275
}
300276

301277

302-
pub fn each_bit_on_entry_frozen(&self,
303-
id: ast::NodeId,
304-
f: |uint| -> bool)
305-
-> bool {
278+
pub fn each_bit_on_entry(&self,
279+
id: ast::NodeId,
280+
f: |uint| -> bool)
281+
-> bool {
306282
//! Iterates through each bit that is set on entry to `id`.
307283
//! Only useful after `propagate()` has been called.
308284
if !self.has_bitset_for_nodeid(id) {
@@ -319,17 +295,21 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> {
319295
-> bool {
320296
//! Iterates through each bit that is set on entry/exit to `cfgidx`.
321297
//! Only useful after `propagate()` has been called.
322-
if !self.has_bitset_for_cfgidx(cfgidx) {
298+
299+
if self.bits_per_id == 0 {
300+
// Skip the surprisingly common degenerate case. (Note
301+
// compute_id_range requires self.words_per_id > 0.)
323302
return true;
324303
}
325-
let (start, end) = self.compute_id_range_frozen(cfgidx);
304+
305+
let (start, end) = self.compute_id_range(cfgidx);
326306
let on_entry = self.on_entry.slice(start, end);
327307
let temp_bits;
328308
let slice = match e {
329309
Entry => on_entry,
330310
Exit => {
331311
let mut t = on_entry.to_vec();
332-
self.apply_gen_kill_frozen(cfgidx, t.as_mut_slice());
312+
self.apply_gen_kill(cfgidx, t.as_mut_slice());
333313
temp_bits = t;
334314
temp_bits.as_slice()
335315
}
@@ -339,15 +319,21 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> {
339319
self.each_bit(slice, f)
340320
}
341321

342-
pub fn each_gen_bit_frozen(&self, id: ast::NodeId, f: |uint| -> bool)
343-
-> bool {
322+
pub fn each_gen_bit(&self, id: ast::NodeId, f: |uint| -> bool)
323+
-> bool {
344324
//! Iterates through each bit in the gen set for `id`.
345-
//! Only useful after `propagate()` has been called.
346325
if !self.has_bitset_for_nodeid(id) {
347326
return true;
348327
}
328+
329+
if self.bits_per_id == 0 {
330+
// Skip the surprisingly common degenerate case. (Note
331+
// compute_id_range requires self.words_per_id > 0.)
332+
return true;
333+
}
334+
349335
let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index);
350-
let (start, end) = self.compute_id_range_frozen(cfgidx);
336+
let (start, end) = self.compute_id_range(cfgidx);
351337
let gens = self.gens.slice(start, end);
352338
debug!("{:s} each_gen_bit(id={:?}, gens={})",
353339
self.analysis_name, id, bits_to_string(gens));
@@ -356,6 +342,8 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> {
356342

357343
fn each_bit(&self, words: &[uint], f: |uint| -> bool) -> bool {
358344
//! Helper for iterating over the bits in a bit set.
345+
//! Returns false on the first call to `f` that returns false;
346+
//! if all calls to `f` return true, then returns true.
359347
360348
for (word_index, &word) in words.iter().enumerate() {
361349
if word != 0 {
@@ -486,6 +474,8 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> {
486474
in_out: &mut [uint]) {
487475
debug!("DataFlowContext::walk_cfg(in_out={}) {:s}",
488476
bits_to_string(in_out), self.dfcx.analysis_name);
477+
assert!(self.dfcx.bits_per_id > 0);
478+
489479
cfg.graph.each_node(|node_index, node| {
490480
debug!("DataFlowContext::walk_cfg idx={} id={} begin in_out={}",
491481
node_index, node.data.id, bits_to_string(in_out));
@@ -529,6 +519,8 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> {
529519
let cfgidx = edge.target();
530520
debug!("{:s} propagate_bits_into_entry_set_for(pred_bits={}, {} to {})",
531521
self.dfcx.analysis_name, bits_to_string(pred_bits), source, cfgidx);
522+
assert!(self.dfcx.bits_per_id > 0);
523+
532524
let (start, end) = self.dfcx.compute_id_range(cfgidx);
533525
let changed = {
534526
// (scoping mutable borrow of self.dfcx.on_entry)

0 commit comments

Comments
 (0)