diff --git a/src/intrinsic.rs b/src/intrinsic.rs index 5c86075883..9ccffc7b8f 100644 --- a/src/intrinsic.rs +++ b/src/intrinsic.rs @@ -423,7 +423,8 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, ' // Do it in memory let mplace = self.force_allocation(dest)?; assert!(mplace.meta.is_none()); - self.memory.mark_definedness(mplace.ptr.to_ptr()?, dest.layout.size, false)?; + let ptr = mplace.ptr.to_ptr()?; + self.memory.get_mut(ptr.alloc_id)?.mark_definedness(ptr, dest.layout.size, false)?; } } } diff --git a/src/lib.rs b/src/lib.rs index ed23eef3f5..39cac10fd4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -422,16 +422,6 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> { Cow::Owned(alloc) } - #[inline(always)] - fn memory_accessed( - alloc: &Allocation, - ptr: Pointer, - size: Size, - access: MemoryAccess, - ) -> EvalResult<'tcx> { - alloc.extra.memory_accessed(ptr, size, access) - } - #[inline(always)] fn memory_deallocated( alloc: &mut Allocation, diff --git a/src/operator.rs b/src/operator.rs index a11f8f34e7..a8ca0b7a78 100644 --- a/src/operator.rs +++ b/src/operator.rs @@ -142,8 +142,8 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, ' // allocations sit right next to each other. The C/C++ standards are // somewhat fuzzy about this case, so I think for now this check is // "good enough". - self.memory.check_bounds_ptr(left, false)?; - self.memory.check_bounds_ptr(right, false)?; + self.memory.get(left.alloc_id)?.check_bounds_ptr(left, false)?; + self.memory.get(right.alloc_id)?.check_bounds_ptr(right, false)?; // Two live in-bounds pointers, we can compare across allocations left == right } @@ -295,9 +295,9 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, ' if let Scalar::Ptr(ptr) = ptr { // Both old and new pointer must be in-bounds. // (Of the same allocation, but that part is trivial with our representation.) - self.memory.check_bounds_ptr(ptr, false)?; + self.memory.get(ptr.alloc_id)?.check_bounds_ptr(ptr, false)?; let ptr = ptr.signed_offset(offset, self)?; - self.memory.check_bounds_ptr(ptr, false)?; + self.memory.get(ptr.alloc_id)?.check_bounds_ptr(ptr, false)?; Ok(Scalar::Ptr(ptr)) } else { // An integer pointer. They can only be offset by 0, and we pretend there diff --git a/src/stacked_borrows.rs b/src/stacked_borrows.rs index 077deceecf..76179b1c55 100644 --- a/src/stacked_borrows.rs +++ b/src/stacked_borrows.rs @@ -5,7 +5,7 @@ use rustc::mir; use super::{ MemoryAccess, RangeMap, EvalResult, - Pointer, + Pointer, AllocationExtra, }; pub type Timestamp = u64; @@ -187,8 +187,9 @@ impl State { } /// Higher-level operations -impl<'tcx> Stacks { - pub fn memory_accessed( +impl AllocationExtra for Stacks { + #[inline(always)] + fn memory_accessed<'tcx>( &self, ptr: Pointer, size: Size, @@ -202,7 +203,10 @@ impl<'tcx> Stacks { } Ok(()) } +} +/// Higher-level operations +impl<'tcx> Stacks { pub fn memory_deallocated( &mut self, ptr: Pointer,