@@ -48,9 +48,6 @@ pub struct DataFlowContext<'a, O> {
48
48
/// equal to bits_per_id/uint::BITS rounded up.
49
49
words_per_id : uint ,
50
50
51
- // mapping from cfg node index to bitset index.
52
- index_to_bitset : Vec < Option < uint > > ,
53
-
54
51
// mapping from node to cfg node index
55
52
// FIXME (#6298): Shouldn't this go with CFG?
56
53
nodeid_to_index : NodeMap < CFGIndex > ,
@@ -98,58 +95,16 @@ fn to_cfgidx_or_die(id: ast::NodeId, index: &NodeMap<CFGIndex>) -> CFGIndex {
98
95
impl < ' a , O : DataFlowOperator > DataFlowContext < ' a , O > {
99
96
fn has_bitset_for_nodeid ( & self , n : ast:: NodeId ) -> bool {
100
97
assert ! ( n != ast:: DUMMY_NODE_ID ) ;
101
- match self . nodeid_to_index . find ( & n) {
102
- None => false ,
103
- Some ( & cfgidx) => self . has_bitset_for_cfgidx ( cfgidx) ,
104
- }
98
+ self . nodeid_to_index . contains_key ( & n)
105
99
}
106
- fn has_bitset_for_cfgidx ( & self , cfgidx : CFGIndex ) -> bool {
107
- let node_id = cfgidx. node_id ( ) ;
108
- node_id < self . index_to_bitset . len ( ) &&
109
- self . index_to_bitset . get ( node_id) . is_some ( )
100
+ fn has_bitset_for_cfgidx ( & self , _cfgidx : CFGIndex ) -> bool {
101
+ true
110
102
}
111
103
fn get_bitset_index ( & self , cfgidx : CFGIndex ) -> uint {
112
- let node_id = cfgidx. node_id ( ) ;
113
- self . index_to_bitset . get ( node_id) . unwrap ( )
104
+ cfgidx. node_id ( )
114
105
}
115
106
fn get_or_create_bitset_index ( & mut self , cfgidx : CFGIndex ) -> uint {
116
- assert ! ( self . words_per_id > 0 ) ;
117
- let len = self . gens . len ( ) / self . words_per_id ;
118
- let expanded;
119
- let n;
120
- if self . index_to_bitset . len ( ) <= cfgidx. node_id ( ) {
121
- self . index_to_bitset . grow_set ( cfgidx. node_id ( ) , & None , Some ( len) ) ;
122
- expanded = true ;
123
- n = len;
124
- } else {
125
- let entry = self . index_to_bitset . get_mut ( cfgidx. node_id ( ) ) ;
126
- match * entry {
127
- None => {
128
- * entry = Some ( len) ;
129
- expanded = true ;
130
- n = len;
131
- }
132
- Some ( bitidx) => {
133
- expanded = false ;
134
- n = bitidx;
135
- }
136
- }
137
- }
138
- if expanded {
139
- let entry = if self . oper . initial_value ( ) { uint:: MAX } else { 0 } ;
140
- for _ in range ( 0 , self . words_per_id ) {
141
- self . gens . push ( 0 ) ;
142
- self . kills . push ( 0 ) ;
143
- self . on_entry . push ( entry) ;
144
- }
145
- }
146
-
147
- let start = n * self . words_per_id ;
148
- let end = start + self . words_per_id ;
149
- let len = self . gens . len ( ) ;
150
- assert ! ( start < len) ;
151
- assert ! ( end <= len) ;
152
- n
107
+ cfgidx. node_id ( )
153
108
}
154
109
}
155
110
@@ -243,22 +198,26 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> {
243
198
id_range : IdRange ,
244
199
bits_per_id : uint ) -> DataFlowContext < ' a , O > {
245
200
let words_per_id = ( bits_per_id + uint:: BITS - 1 ) / uint:: BITS ;
201
+ let num_nodes = cfg. graph . all_nodes ( ) . len ( ) ;
246
202
247
203
debug ! ( "DataFlowContext::new(analysis_name: {:s}, id_range={:?}, \
248
- bits_per_id={:?}, words_per_id={:?})",
249
- analysis_name, id_range, bits_per_id, words_per_id) ;
204
+ bits_per_id={:?}, words_per_id={:?}) \
205
+ num_nodes: {}",
206
+ analysis_name, id_range, bits_per_id, words_per_id,
207
+ num_nodes) ;
208
+
209
+ let entry = if oper. initial_value ( ) { uint:: MAX } else { 0 } ;
250
210
251
- let gens = Vec :: new ( ) ;
252
- let kills = Vec :: new ( ) ;
253
- let on_entry = Vec :: new ( ) ;
211
+ let gens = Vec :: from_elem ( num_nodes * words_per_id , 0 ) ;
212
+ let kills = Vec :: from_elem ( num_nodes * words_per_id , 0 ) ;
213
+ let on_entry = Vec :: from_elem ( num_nodes * words_per_id , entry ) ;
254
214
255
215
let nodeid_to_index = build_nodeid_to_index ( decl, cfg) ;
256
216
257
217
DataFlowContext {
258
218
tcx : tcx,
259
219
analysis_name : analysis_name,
260
220
words_per_id : words_per_id,
261
- index_to_bitset : Vec :: new ( ) ,
262
221
nodeid_to_index : nodeid_to_index,
263
222
bits_per_id : bits_per_id,
264
223
oper : oper,
0 commit comments