1 use rand::rngs::StdRng;
3 use rustc_mir::interpret::{Pointer, Allocation, AllocationExtra, InterpResult};
4 use rustc_target::abi::Size;
6 use crate::{stacked_borrows, intptrcast};
7 use crate::stacked_borrows::Tag;
9 #[derive(Default, Clone, Debug)]
10 pub struct MemoryExtra {
11 pub stacked_borrows: stacked_borrows::MemoryExtra,
12 pub intptrcast: intptrcast::MemoryExtra,
13 /// The random number generator to use if Miri is running in non-deterministic mode and to
15 pub(crate) rng: Option<StdRng>
18 #[derive(Debug, Clone)]
19 pub struct AllocExtra {
20 pub stacked_borrows: stacked_borrows::AllocExtra,
21 pub intptrcast: intptrcast::AllocExtra,
24 impl AllocationExtra<Tag> for AllocExtra {
27 alloc: &Allocation<Tag, AllocExtra>,
30 ) -> InterpResult<'tcx> {
31 alloc.extra.stacked_borrows.memory_read(ptr, size)
35 fn memory_written<'tcx>(
36 alloc: &mut Allocation<Tag, AllocExtra>,
39 ) -> InterpResult<'tcx> {
40 alloc.extra.stacked_borrows.memory_written(ptr, size)
44 fn memory_deallocated<'tcx>(
45 alloc: &mut Allocation<Tag, AllocExtra>,
48 ) -> InterpResult<'tcx> {
49 alloc.extra.stacked_borrows.memory_deallocated(ptr, size)