-
Notifications
You must be signed in to change notification settings - Fork 385
Implement intptrcast methods #779
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fd3a291
Implement intptrcast methods
pvdrz e574470
Duplicate compile-fail tests for intptrcast
pvdrz dd732e5
Force intptrcast for binary operations
pvdrz 2861ceb
Rename new fields and move rng to MemoryExtra
pvdrz 84cfbb0
Reorganize MemoryExtra and AllocExtra structures
pvdrz 792d665
Fix merge conflicts
pvdrz 7fbf8e5
Fix alignment of base addresses
pvdrz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::cell::RefCell; | ||
|
||
use rustc::mir::interpret::AllocId; | ||
|
||
pub type MemoryState = RefCell<GlobalState>; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct GlobalState { | ||
pub vec: Vec<(u64, AllocId)>, | ||
pub addr: u64, | ||
pvdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
impl Default for GlobalState { | ||
fn default() -> Self { | ||
GlobalState { | ||
vec: Vec::default(), | ||
addr: 2u64.pow(16) | ||
pvdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use std::cell::RefCell; | ||
|
||
use rustc_mir::interpret::{Pointer, Allocation, AllocationExtra, InterpResult}; | ||
use rustc_target::abi::Size; | ||
|
||
use crate::{stacked_borrows, intptrcast}; | ||
use crate::stacked_borrows::{Tag, AccessKind}; | ||
|
||
#[derive(Default, Clone, Debug)] | ||
pub struct MemoryState { | ||
pvdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub stacked: stacked_borrows::MemoryState, | ||
pub intptrcast: intptrcast::MemoryState, | ||
pvdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub seed: Option<u64>, | ||
pvdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
#[derive(Debug, Clone,)] | ||
pub struct AllocExtra { | ||
pub stacks: stacked_borrows::Stacks, | ||
pub base_addr: RefCell<Option<u64>>, | ||
pvdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
impl AllocationExtra<Tag> for AllocExtra { | ||
#[inline(always)] | ||
fn memory_read<'tcx>( | ||
alloc: &Allocation<Tag, AllocExtra>, | ||
ptr: Pointer<Tag>, | ||
size: Size, | ||
) -> InterpResult<'tcx> { | ||
trace!("read access with tag {:?}: {:?}, size {}", ptr.tag, ptr.erase_tag(), size.bytes()); | ||
alloc.extra.stacks.for_each(ptr, size, |stack, global| { | ||
stack.access(AccessKind::Read, ptr.tag, global)?; | ||
Ok(()) | ||
}) | ||
} | ||
pvdrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#[inline(always)] | ||
fn memory_written<'tcx>( | ||
alloc: &mut Allocation<Tag, AllocExtra>, | ||
ptr: Pointer<Tag>, | ||
size: Size, | ||
) -> InterpResult<'tcx> { | ||
trace!("write access with tag {:?}: {:?}, size {}", ptr.tag, ptr.erase_tag(), size.bytes()); | ||
alloc.extra.stacks.for_each(ptr, size, |stack, global| { | ||
stack.access(AccessKind::Write, ptr.tag, global)?; | ||
Ok(()) | ||
}) | ||
} | ||
|
||
#[inline(always)] | ||
fn memory_deallocated<'tcx>( | ||
alloc: &mut Allocation<Tag, AllocExtra>, | ||
ptr: Pointer<Tag>, | ||
size: Size, | ||
) -> InterpResult<'tcx> { | ||
trace!("deallocation with tag {:?}: {:?}, size {}", ptr.tag, ptr.erase_tag(), size.bytes()); | ||
alloc.extra.stacks.for_each(ptr, size, |stack, global| { | ||
stack.dealloc(ptr.tag, global) | ||
}) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.