@@ -101,7 +101,7 @@ where
101
101
}
102
102
103
103
pub struct VecCache < K : Idx , V > {
104
- cache : Sharded < IndexVec < K , Option < ( V , DepNodeIndex ) > > > ,
104
+ cache : Lock < IndexVec < K , Option < ( V , DepNodeIndex ) > > > ,
105
105
}
106
106
107
107
impl < K : Idx , V > Default for VecCache < K , V > {
@@ -120,24 +120,20 @@ where
120
120
121
121
#[ inline( always) ]
122
122
fn lookup ( & self , key : & K ) -> Option < ( V , DepNodeIndex ) > {
123
- // FIXME: lock_shard_by_hash will use high bits which are usually zero in the index() passed
124
- // here. This makes sharding essentially useless, always selecting the zero'th shard.
125
- let lock = self . cache . lock_shard_by_hash ( key. index ( ) as u64 ) ;
123
+ let lock = self . cache . lock ( ) ;
126
124
if let Some ( Some ( value) ) = lock. get ( * key) { Some ( * value) } else { None }
127
125
}
128
126
129
127
#[ inline]
130
128
fn complete ( & self , key : K , value : V , index : DepNodeIndex ) {
131
- let mut lock = self . cache . lock_shard_by_hash ( key . index ( ) as u64 ) ;
129
+ let mut lock = self . cache . lock ( ) ;
132
130
lock. insert ( key, ( value, index) ) ;
133
131
}
134
132
135
133
fn iter ( & self , f : & mut dyn FnMut ( & Self :: Key , & Self :: Value , DepNodeIndex ) ) {
136
- for shard in self . cache . lock_shards ( ) {
137
- for ( k, v) in shard. iter_enumerated ( ) {
138
- if let Some ( v) = v {
139
- f ( & k, & v. 0 , v. 1 ) ;
140
- }
134
+ for ( k, v) in self . cache . lock ( ) . iter_enumerated ( ) {
135
+ if let Some ( v) = v {
136
+ f ( & k, & v. 0 , v. 1 ) ;
141
137
}
142
138
}
143
139
}
@@ -149,9 +145,6 @@ pub struct DefIdCache<V> {
149
145
///
150
146
/// The second element of the tuple is the set of keys actually present in the IndexVec, used
151
147
/// for faster iteration in `iter()`.
152
- // FIXME: This may want to be sharded, like VecCache. However *how* to shard an IndexVec isn't
153
- // super clear; VecCache is effectively not sharded today (see FIXME there). For now just omit
154
- // that complexity here.
155
148
local : Lock < ( IndexVec < DefIndex , Option < ( V , DepNodeIndex ) > > , Vec < DefIndex > ) > ,
156
149
foreign : DefaultCache < DefId , V > ,
157
150
}
0 commit comments