Skip to content

Commit

Permalink
Rename bloom to hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
ecstatic-morse committed Jul 4, 2018
1 parent c6aea93 commit 10f2171
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ type EvalSnapshot<'a, 'mir, 'tcx, M>
pub(crate) struct InfiniteLoopDetector<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> {
/// The set of all `EvalSnapshot` *hashes* observed by this detector.
///
/// Not a proper bloom filter.
bloom: FxHashSet<u64>,
/// When a collision occurs in this table, we store the full snapshot in `snapshots`.
hashes: FxHashSet<u64>,

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

Expand All @@ -165,7 +165,7 @@ impl<'a, 'mir, 'tcx, M> Default for InfiniteLoopDetector<'a, 'mir, 'tcx, M>
{
fn default() -> Self {
InfiniteLoopDetector {
bloom: FxHashSet::default(),
hashes: FxHashSet::default(),
snapshots: FxHashSet::default(),
}
}
Expand All @@ -177,7 +177,7 @@ impl<'a, 'mir, 'tcx, M> InfiniteLoopDetector<'a, 'mir, 'tcx, M>
{
/// Returns `true` if the loop detector has not yet observed a snapshot.
pub fn is_empty(&self) -> bool {
self.bloom.is_empty()
self.hashes.is_empty()
}

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

if self.bloom.insert(hash) {
if self.hashes.insert(hash) {
// No collision
return Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/interpret/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
pub fn is_loop_detector_scheduled(&self) -> bool {
/// The number of steps between loop detector snapshots.
/// Should be a power of two for performance reasons.
const LOOP_SNAPSHOT_PERIOD: isize = 1 << 8;
const DETECTOR_SNAPSHOT_PERIOD: isize = 1 << 8;

let steps = self.steps_until_detector_enabled;
steps <= 0 && steps % LOOP_SNAPSHOT_PERIOD == 0
steps <= 0 && steps % DETECTOR_SNAPSHOT_PERIOD == 0
}

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

0 comments on commit 10f2171

Please sign in to comment.