Skip to content

Commit 10f2171

Browse files
Rename bloom to hashes
1 parent c6aea93 commit 10f2171

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/librustc_mir/interpret/eval_context.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ type EvalSnapshot<'a, 'mir, 'tcx, M>
148148
pub(crate) struct InfiniteLoopDetector<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> {
149149
/// The set of all `EvalSnapshot` *hashes* observed by this detector.
150150
///
151-
/// Not a proper bloom filter.
152-
bloom: FxHashSet<u64>,
151+
/// When a collision occurs in this table, we store the full snapshot in `snapshots`.
152+
hashes: FxHashSet<u64>,
153153

154154
/// The set of all `EvalSnapshot`s observed by this detector.
155155
///
156-
/// An `EvalSnapshot` will only be fully cloned once it has caused a collision
157-
/// in `bloom`. As a result, the detector must observe *two* full cycles of
158-
/// an infinite loop before it triggers.
156+
/// An `EvalSnapshot` will only be fully cloned once it has caused a collision in `hashes`. As
157+
/// a result, the detector must observe at least *two* full cycles of an infinite loop before
158+
/// it triggers.
159159
snapshots: FxHashSet<EvalSnapshot<'a, 'mir, 'tcx, M>>,
160160
}
161161

@@ -165,7 +165,7 @@ impl<'a, 'mir, 'tcx, M> Default for InfiniteLoopDetector<'a, 'mir, 'tcx, M>
165165
{
166166
fn default() -> Self {
167167
InfiniteLoopDetector {
168-
bloom: FxHashSet::default(),
168+
hashes: FxHashSet::default(),
169169
snapshots: FxHashSet::default(),
170170
}
171171
}
@@ -177,7 +177,7 @@ impl<'a, 'mir, 'tcx, M> InfiniteLoopDetector<'a, 'mir, 'tcx, M>
177177
{
178178
/// Returns `true` if the loop detector has not yet observed a snapshot.
179179
pub fn is_empty(&self) -> bool {
180-
self.bloom.is_empty()
180+
self.hashes.is_empty()
181181
}
182182

183183
pub fn observe_and_analyze(
@@ -192,7 +192,7 @@ impl<'a, 'mir, 'tcx, M> InfiniteLoopDetector<'a, 'mir, 'tcx, M>
192192
snapshot.hash(&mut fx);
193193
let hash = fx.finish();
194194

195-
if self.bloom.insert(hash) {
195+
if self.hashes.insert(hash) {
196196
// No collision
197197
return Ok(())
198198
}

src/librustc_mir/interpret/step.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
1616
pub fn is_loop_detector_scheduled(&self) -> bool {
1717
/// The number of steps between loop detector snapshots.
1818
/// Should be a power of two for performance reasons.
19-
const LOOP_SNAPSHOT_PERIOD: isize = 1 << 8;
19+
const DETECTOR_SNAPSHOT_PERIOD: isize = 1 << 8;
2020

2121
let steps = self.steps_until_detector_enabled;
22-
steps <= 0 && steps % LOOP_SNAPSHOT_PERIOD == 0
22+
steps <= 0 && steps % DETECTOR_SNAPSHOT_PERIOD == 0
2323
}
2424

2525
pub fn inc_step_counter_and_detect_loops(&mut self, n: usize) -> EvalResult<'tcx, ()> {

0 commit comments

Comments
 (0)