Skip to content

Update to allocation method PR #493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Borrow, Self::AllocExtra>,
ptr: Pointer<Borrow>,
size: Size,
access: MemoryAccess,
) -> EvalResult<'tcx> {
alloc.extra.memory_accessed(ptr, size, access)
}

#[inline(always)]
fn memory_deallocated(
alloc: &mut Allocation<Self::PointerTag, Self::AllocExtra>,
Expand Down
8 changes: 4 additions & 4 deletions src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions src/stacked_borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc::mir;

use super::{
MemoryAccess, RangeMap, EvalResult,
Pointer,
Pointer, AllocationExtra,
};

pub type Timestamp = u64;
Expand Down Expand Up @@ -187,8 +187,9 @@ impl State {
}

/// Higher-level operations
impl<'tcx> Stacks {
pub fn memory_accessed(
impl AllocationExtra<Borrow> for Stacks {
#[inline(always)]
fn memory_accessed<'tcx>(
&self,
ptr: Pointer<Borrow>,
size: Size,
Expand All @@ -202,7 +203,10 @@ impl<'tcx> Stacks {
}
Ok(())
}
}

/// Higher-level operations
impl<'tcx> Stacks {
pub fn memory_deallocated(
&mut self,
ptr: Pointer<Borrow>,
Expand Down