From: Ralf Jung Date: Fri, 7 Jun 2019 17:01:49 +0000 (+0200) Subject: rename EvalSnapshot -> InterpSnapshot X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=059e7c0c80413b9913eed143b4152821d8f46340;p=rust.git rename EvalSnapshot -> InterpSnapshot --- diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index 98ab6906fc9..ae09ae0a198 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -29,18 +29,18 @@ #[derive(Default)] pub(crate) struct InfiniteLoopDetector<'a, 'mir, 'tcx: 'a + 'mir> { - /// The set of all `EvalSnapshot` *hashes* observed by this detector. + /// The set of all `InterpSnapshot` *hashes* observed by this detector. /// /// When a collision occurs in this table, we store the full snapshot in /// `snapshots`. hashes: FxHashSet, - /// The set of all `EvalSnapshot`s observed by this detector. + /// The set of all `InterpSnapshot`s observed by this detector. /// - /// An `EvalSnapshot` will only be fully cloned once it has caused a + /// An `InterpSnapshot` 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>, + snapshots: FxHashSet>, } impl<'a, 'mir, 'tcx> InfiniteLoopDetector<'a, 'mir, 'tcx> @@ -72,7 +72,7 @@ pub fn observe_and_analyze<'b>( // We need to make a full copy. NOW things that to get really expensive. info!("snapshotting the state of the interpreter"); - if self.snapshots.insert(EvalSnapshot::new(memory, stack)) { + if self.snapshots.insert(InterpSnapshot::new(memory, stack)) { // Spurious collision or first cycle return Ok(()) } @@ -384,18 +384,18 @@ fn resolve(&'b self, id: &AllocId) -> Option<&'b Allocation> { /// The virtual machine state during const-evaluation at a given point in time. /// We assume the `CompileTimeInterpreter` has no interesting extra state that /// is worth considering here. -struct EvalSnapshot<'a, 'mir, 'tcx: 'a + 'mir> { +struct InterpSnapshot<'a, 'mir, 'tcx: 'a + 'mir> { memory: Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>, stack: Vec>, } -impl<'a, 'mir, 'tcx: 'a + 'mir> EvalSnapshot<'a, 'mir, 'tcx> +impl<'a, 'mir, 'tcx: 'a + 'mir> InterpSnapshot<'a, 'mir, 'tcx> { fn new( memory: &Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>, stack: &[Frame<'mir, 'tcx>] ) -> Self { - EvalSnapshot { + InterpSnapshot { memory: memory.clone(), stack: stack.into(), } @@ -411,7 +411,7 @@ fn snapshot(&'b self) } -impl<'a, 'mir, 'tcx> Hash for EvalSnapshot<'a, 'mir, 'tcx> +impl<'a, 'mir, 'tcx> Hash for InterpSnapshot<'a, 'mir, 'tcx> { fn hash(&self, state: &mut H) { // Implement in terms of hash stable, so that k1 == k2 -> hash(k1) == hash(k2) @@ -422,16 +422,16 @@ fn hash(&self, state: &mut H) { } } -impl_stable_hash_for!(impl<'tcx, 'b, 'mir> for struct EvalSnapshot<'b, 'mir, 'tcx> { +impl_stable_hash_for!(impl<'tcx, 'b, 'mir> for struct InterpSnapshot<'b, 'mir, 'tcx> { // Not hashing memory: Avoid hashing memory all the time during execution memory -> _, stack, }); -impl<'a, 'mir, 'tcx> Eq for EvalSnapshot<'a, 'mir, 'tcx> +impl<'a, 'mir, 'tcx> Eq for InterpSnapshot<'a, 'mir, 'tcx> {} -impl<'a, 'mir, 'tcx> PartialEq for EvalSnapshot<'a, 'mir, 'tcx> +impl<'a, 'mir, 'tcx> PartialEq for InterpSnapshot<'a, 'mir, 'tcx> { fn eq(&self, other: &Self) -> bool { // FIXME: This looks to be a *ridiculously expensive* comparison operation.