EvalContext, PlaceTy, OpTy, Pointer, MemPlace, MemoryKind,
};
-/// Classifying memory accesses
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum MemoryAccess {
- Read,
- Write,
-}
-
/// Whether this kind of memory is allowed to leak
pub trait MayLeak: Copy {
fn may_leak(self) -> bool;
dest: PlaceTy<'tcx, Self::PointerTag>,
) -> EvalResult<'tcx>;
- /// Hook for performing extra checks on a memory access.
- ///
- /// Takes read-only access to the allocation so we can keep all the memory read
- /// operations take `&self`. Use a `RefCell` in `AllocExtra` if you
- /// need to mutate.
+ /// Hook for performing extra checks on a memory read access.
#[inline]
- fn memory_accessed(
+ fn memory_read(
_alloc: &Allocation<Self::PointerTag, Self::AllocExtra>,
_ptr: Pointer<Self::PointerTag>,
_size: Size,
- _access: MemoryAccess,
+ ) -> EvalResult<'tcx> {
+ Ok(())
+ }
+
+ /// Hook for performing extra checks on a memory write access.
+ #[inline]
+ fn memory_written(
+ _alloc: &mut Allocation<Self::PointerTag, Self::AllocExtra>,
+ _ptr: Pointer<Self::PointerTag>,
+ _size: Size,
) -> EvalResult<'tcx> {
Ok(())
}
use super::{
Pointer, AllocId, Allocation, ConstValue, GlobalId,
EvalResult, Scalar, EvalErrorKind, AllocType, PointerArithmetic,
- Machine, MemoryAccess, AllocMap, MayLeak, ScalarMaybeUndef, ErrorHandled,
+ Machine, AllocMap, MayLeak, ScalarMaybeUndef, ErrorHandled,
};
#[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)]
}
let alloc = self.get(ptr.alloc_id)?;
- M::memory_accessed(alloc, ptr, size, MemoryAccess::Read)?;
+ M::memory_read(alloc, ptr, size)?;
assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes());
assert_eq!(size.bytes() as usize as u64, size.bytes());
self.clear_relocations(ptr, size)?;
let alloc = self.get_mut(ptr.alloc_id)?;
- M::memory_accessed(alloc, ptr, size, MemoryAccess::Write)?;
+ M::memory_written(alloc, ptr, size)?;
assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes());
assert_eq!(size.bytes() as usize as u64, size.bytes());
pub use self::memory::{Memory, MemoryKind};
-pub use self::machine::{Machine, AllocMap, MemoryAccess, MayLeak};
+pub use self::machine::{Machine, AllocMap, MayLeak};
pub use self::operand::{ScalarMaybeUndef, Value, ValTy, Operand, OpTy};