Struct rustc_middle::mir::interpret::Allocation [−][src]
pub struct Allocation<Tag = (), Extra = ()> { bytes: Vec<u8>, relocations: Relocations<Tag>, init_mask: InitMask, pub size: Size, pub align: Align, pub mutability: Mutability, pub extra: Extra, }
Fields
bytes: Vec<u8>Expand description
The actual bytes of the allocation. Note that the bytes of a pointer represent the offset of the pointer.
relocations: Relocations<Tag>Expand description
Maps from byte addresses to extra data for each pointer.
Only the first byte of a pointer is inserted into the map; i.e.,
every entry in this map applies to pointer_size consecutive bytes starting
at the given offset.
init_mask: InitMaskExpand description
Denotes which part of this allocation is initialized.
size: SizeExpand description
The size of the allocation. Currently, must always equal bytes.len().
align: AlignExpand description
The alignment of the allocation to detect unaligned reads.
(Align guarantees that this is a power of two.)
mutability: MutabilityExpand description
true if the allocation is mutable.
Also used by codegen to determine if a static should be put into mutable memory,
which happens for static mut and static with interior mutability.
extra: ExtraExpand description
Extra state for the machine.
Implementations
impl<Tag> Allocation<Tag>[src]
impl<Tag> Allocation<Tag>[src]impl Allocation<(), ()>[src]
impl Allocation<(), ()>[src]pub fn with_tags_and_extra<T, E>(
self,
tagger: impl FnMut(AllocId) -> T,
extra: E
) -> Allocation<T, E>[src]
pub fn with_tags_and_extra<T, E>(
self,
tagger: impl FnMut(AllocId) -> T,
extra: E
) -> Allocation<T, E>[src]Add Tag and Extra fields
impl<Tag, Extra> Allocation<Tag, Extra>[src]
impl<Tag, Extra> Allocation<Tag, Extra>[src]Raw accessors. Provide access to otherwise private bytes.
pub fn len(&self) -> usize[src]
pub fn inspect_with_uninit_and_ptr_outside_interpreter(
&self,
range: Range<usize>
) -> &[u8]ⓘ[src]
pub fn inspect_with_uninit_and_ptr_outside_interpreter(
&self,
range: Range<usize>
) -> &[u8]ⓘ[src]Looks at a slice which may describe uninitialized bytes or describe a relocation. This differs
from get_bytes_with_uninit_and_ptr in that it does no relocation checks (even on the
edges) at all. It further ignores AllocationExtra callbacks.
This must not be used for reads affecting the interpreter execution.
pub fn relocations(&self) -> &Relocations<Tag>[src]
pub fn relocations(&self) -> &Relocations<Tag>[src]Returns the relocation list.
impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra>[src]
impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra>[src]Byte accessors.
fn check_bounds(&self, offset: Size, size: Size) -> Range<usize>[src]
fn check_bounds(&self, offset: Size, size: Size) -> Range<usize>[src]Just a small local helper function to avoid a bit of code repetition. Returns the range of this allocation that was meant.
fn get_bytes_internal(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size,
check_init_and_ptr: bool
) -> InterpResult<'tcx, &[u8]>[src]
fn get_bytes_internal(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size,
check_init_and_ptr: bool
) -> InterpResult<'tcx, &[u8]>[src]The last argument controls whether we error out when there are uninitialized
or pointer bytes. You should never call this, call get_bytes or
get_bytes_with_uninit_and_ptr instead,
This function also guarantees that the resulting pointer will remain stable
even when new allocations are pushed to the HashMap. copy_repeatedly relies
on that.
It is the caller’s responsibility to check bounds and alignment beforehand.
pub fn get_bytes(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx, &[u8]>[src]
pub fn get_bytes(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx, &[u8]>[src]Checks that these bytes are initialized and not pointer bytes, and then return them as a slice.
It is the caller’s responsibility to check bounds and alignment beforehand.
Most likely, you want to use the PlaceTy and OperandTy-based methods
on InterpCx instead.
pub fn get_bytes_with_uninit_and_ptr(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx, &[u8]>[src]
pub fn get_bytes_with_uninit_and_ptr(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx, &[u8]>[src]It is the caller’s responsibility to handle uninitialized and pointer bytes. However, this still checks that there are no relocations on the edges.
It is the caller’s responsibility to check bounds and alignment beforehand.
pub fn get_bytes_mut(
&mut self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx, &mut [u8]>[src]
pub fn get_bytes_mut(
&mut self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx, &mut [u8]>[src]Just calling this already marks everything as defined and removes relocations, so be sure to actually put data there!
It is the caller’s responsibility to check bounds and alignment beforehand.
Most likely, you want to use the PlaceTy and OperandTy-based methods
on InterpCx instead.
impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra>[src]
impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra>[src]Reading and writing.
pub fn read_c_str(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>
) -> InterpResult<'tcx, &[u8]>[src]
pub fn read_c_str(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>
) -> InterpResult<'tcx, &[u8]>[src]Reads bytes until a 0 is encountered. Will error if the end of the allocation is reached
before a 0 is found.
Most likely, you want to call Memory::read_c_str instead of this method.
pub fn check_bytes(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size,
allow_uninit_and_ptr: bool
) -> InterpResult<'tcx>[src]
pub fn check_bytes(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size,
allow_uninit_and_ptr: bool
) -> InterpResult<'tcx>[src]Validates that ptr.offset and ptr.offset + size do not point to the middle of a
relocation. If allow_uninit_and_ptr is false, also enforces that the memory in the
given range contains neither relocations nor uninitialized bytes.
pub fn write_bytes(
&mut self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
src: impl IntoIterator<Item = u8>
) -> InterpResult<'tcx>[src]
pub fn write_bytes(
&mut self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
src: impl IntoIterator<Item = u8>
) -> InterpResult<'tcx>[src]Writes src to the memory starting at ptr.offset.
It is the caller’s responsibility to check bounds and alignment beforehand.
Most likely, you want to call Memory::write_bytes instead of this method.
pub fn read_scalar(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>>[src]
pub fn read_scalar(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>>[src]Reads a non-ZST scalar.
ZSTs can’t be read because in order to obtain a Pointer, we need to check
for ZSTness anyway due to integer pointers being valid for ZSTs.
It is the caller’s responsibility to check bounds and alignment beforehand.
Most likely, you want to call InterpCx::read_scalar instead of this method.
pub fn read_ptr_sized(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>>[src]
pub fn read_ptr_sized(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>>[src]Reads a pointer-sized scalar.
It is the caller’s responsibility to check bounds and alignment beforehand.
Most likely, you want to call InterpCx::read_scalar instead of this method.
pub fn write_scalar(
&mut self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
val: ScalarMaybeUninit<Tag>,
type_size: Size
) -> InterpResult<'tcx>[src]
pub fn write_scalar(
&mut self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
val: ScalarMaybeUninit<Tag>,
type_size: Size
) -> InterpResult<'tcx>[src]Writes a non-ZST scalar.
ZSTs can’t be read because in order to obtain a Pointer, we need to check
for ZSTness anyway due to integer pointers being valid for ZSTs.
It is the caller’s responsibility to check bounds and alignment beforehand.
Most likely, you want to call InterpCx::write_scalar instead of this method.
pub fn write_ptr_sized(
&mut self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
val: ScalarMaybeUninit<Tag>
) -> InterpResult<'tcx>[src]
pub fn write_ptr_sized(
&mut self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
val: ScalarMaybeUninit<Tag>
) -> InterpResult<'tcx>[src]Writes a pointer-sized scalar.
It is the caller’s responsibility to check bounds and alignment beforehand.
Most likely, you want to call InterpCx::write_scalar instead of this method.
impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra>[src]
impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra>[src]Relocations.
pub fn get_relocations(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> &[(Size, (Tag, AllocId))]ⓘ[src]
pub fn get_relocations(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> &[(Size, (Tag, AllocId))]ⓘ[src]Returns all relocations overlapping with the given pointer-offset pair.
fn check_relocations(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx>[src]
fn check_relocations(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx>[src]Checks that there are no relocations overlapping with the given range.
fn clear_relocations(
&mut self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
)[src]
fn clear_relocations(
&mut self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
)[src]Removes all relocations inside the given range. If there are relocations overlapping with the edges, they are removed as well and the bytes they cover are marked as uninitialized. This is a somewhat odd “spooky action at a distance”, but it allows strictly more code to run than if we would just error immediately in that case.
fn check_relocation_edges(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx>[src]
fn check_relocation_edges(
&self,
cx: &impl HasDataLayout,
ptr: Pointer<Tag>,
size: Size
) -> InterpResult<'tcx>[src]Errors if there are relocations overlapping with the edges of the given memory range.
impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra>[src]
impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra>[src]Uninitialized bytes.
fn is_init(&self, ptr: Pointer<Tag>, size: Size) -> Result<(), Range<Size>>[src]
fn is_init(&self, ptr: Pointer<Tag>, size: Size) -> Result<(), Range<Size>>[src]Checks whether the given range is entirely initialized.
Returns Ok(()) if it’s initialized. Otherwise returns the range of byte
indexes of the first contiguous uninitialized access.
fn check_init(&self, ptr: Pointer<Tag>, size: Size) -> InterpResult<'tcx>[src]
fn check_init(&self, ptr: Pointer<Tag>, size: Size) -> InterpResult<'tcx>[src]Checks that a range of bytes is initialized. If not, returns the InvalidUninitBytes
error which will report the first range of bytes which is uninitialized.
pub fn mark_init(&mut self, ptr: Pointer<Tag>, size: Size, is_init: bool)[src]
impl<Tag, Extra> Allocation<Tag, Extra>[src]
impl<Tag, Extra> Allocation<Tag, Extra>[src]Transferring the initialization mask to other allocations.
pub fn compress_uninit_range(
&self,
src: Pointer<Tag>,
size: Size
) -> InitMaskCompressed[src]
pub fn compress_uninit_range(
&self,
src: Pointer<Tag>,
size: Size
) -> InitMaskCompressed[src]Creates a run-length encoding of the initialization mask.
pub fn mark_compressed_init_range(
&mut self,
defined: &InitMaskCompressed,
dest: Pointer<Tag>,
size: Size,
repeat: u64
)[src]
pub fn mark_compressed_init_range(
&mut self,
defined: &InitMaskCompressed,
dest: Pointer<Tag>,
size: Size,
repeat: u64
)[src]Applies multiple instances of the run-length encoding to the initialization mask.
impl<Tag: Copy, Extra> Allocation<Tag, Extra>[src]
impl<Tag: Copy, Extra> Allocation<Tag, Extra>[src]pub fn prepare_relocation_copy(
&self,
cx: &impl HasDataLayout,
src: Pointer<Tag>,
size: Size,
dest: Pointer<Tag>,
length: u64
) -> AllocationRelocations<Tag>[src]
&self,
cx: &impl HasDataLayout,
src: Pointer<Tag>,
size: Size,
dest: Pointer<Tag>,
length: u64
) -> AllocationRelocations<Tag>
pub fn mark_relocation_range(&mut self, relocations: AllocationRelocations<Tag>)[src]
pub fn mark_relocation_range(&mut self, relocations: AllocationRelocations<Tag>)[src]Applies a relocation copy.
The affected range, as defined in the parameters to prepare_relocation_copy is expected
to be clear of relocations.
Trait Implementations
impl<'tcx> ArenaAllocatable<'tcx, Allocation<(), ()>> for Allocation[src]
impl<'tcx> ArenaAllocatable<'tcx, Allocation<(), ()>> for Allocation[src]fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self[src]
fn allocate_from_iter<'a>(
arena: &'a Arena<'tcx>,
iter: impl IntoIterator<Item = Self>
) -> &'a mut [Self]ⓘ[src]
arena: &'a Arena<'tcx>,
iter: impl IntoIterator<Item = Self>
) -> &'a mut [Self]ⓘ
impl<'tcx> Borrow<Allocation<(), ()>> for Interned<'tcx, Allocation>[src]
impl<'tcx> Borrow<Allocation<(), ()>> for Interned<'tcx, Allocation>[src]fn borrow<'a>(&'a self) -> &'a Allocation[src]
fn borrow<'a>(&'a self) -> &'a Allocation[src]Immutably borrows from an owned value. Read more
impl<Tag: Clone, Extra: Clone> Clone for Allocation<Tag, Extra>[src]
impl<Tag: Clone, Extra: Clone> Clone for Allocation<Tag, Extra>[src]fn clone(&self) -> Allocation<Tag, Extra>[src]
fn clone(&self) -> Allocation<Tag, Extra>[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]Performs copy-assignment from source. Read more
impl<Tag: Debug, Extra: Debug> Debug for Allocation<Tag, Extra>[src]
impl<Tag: Debug, Extra: Debug> Debug for Allocation<Tag, Extra>[src]impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for &'tcx Allocation[src]
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for &'tcx Allocation[src]impl<'tcx, Tag, Extra, __D: TyDecoder<'tcx>> Decodable<__D> for Allocation<Tag, Extra> where
Tag: Decodable<__D>,
Extra: Decodable<__D>, [src]
impl<'tcx, Tag, Extra, __D: TyDecoder<'tcx>> Decodable<__D> for Allocation<Tag, Extra> where
Tag: Decodable<__D>,
Extra: Decodable<__D>, [src]impl<'tcx, Tag, Extra, __E: TyEncoder<'tcx>> Encodable<__E> for Allocation<Tag, Extra> where
Tag: Encodable<__E>,
Extra: Encodable<__E>, [src]
impl<'tcx, Tag, Extra, __E: TyEncoder<'tcx>> Encodable<__E> for Allocation<Tag, Extra> where
Tag: Encodable<__E>,
Extra: Encodable<__E>, [src]impl<Tag: Hash, Extra: Hash> Hash for Allocation<Tag, Extra>[src]
impl<Tag: Hash, Extra: Hash> Hash for Allocation<Tag, Extra>[src]impl<'__ctx, Tag, Extra> HashStable<StableHashingContext<'__ctx>> for Allocation<Tag, Extra> where
Tag: HashStable<StableHashingContext<'__ctx>>,
Extra: HashStable<StableHashingContext<'__ctx>>, [src]
impl<'__ctx, Tag, Extra> HashStable<StableHashingContext<'__ctx>> for Allocation<Tag, Extra> where
Tag: HashStable<StableHashingContext<'__ctx>>,
Extra: HashStable<StableHashingContext<'__ctx>>, [src]fn hash_stable(
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)[src]
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)
impl<'a, 'tcx> Lift<'tcx> for &'a Allocation[src]
impl<'a, 'tcx> Lift<'tcx> for &'a Allocation[src]impl<Tag: Ord, Extra: Ord> Ord for Allocation<Tag, Extra>[src]
impl<Tag: Ord, Extra: Ord> Ord for Allocation<Tag, Extra>[src]impl<Tag: PartialEq, Extra: PartialEq> PartialEq<Allocation<Tag, Extra>> for Allocation<Tag, Extra>[src]
impl<Tag: PartialEq, Extra: PartialEq> PartialEq<Allocation<Tag, Extra>> for Allocation<Tag, Extra>[src]fn eq(&self, other: &Allocation<Tag, Extra>) -> bool[src]
fn eq(&self, other: &Allocation<Tag, Extra>) -> bool[src]This method tests for self and other values to be equal, and is used
by ==. Read more
fn ne(&self, other: &Allocation<Tag, Extra>) -> bool[src]
fn ne(&self, other: &Allocation<Tag, Extra>) -> bool[src]This method tests for !=.
impl<Tag: PartialOrd, Extra: PartialOrd> PartialOrd<Allocation<Tag, Extra>> for Allocation<Tag, Extra>[src]
impl<Tag: PartialOrd, Extra: PartialOrd> PartialOrd<Allocation<Tag, Extra>> for Allocation<Tag, Extra>[src]fn partial_cmp(&self, other: &Allocation<Tag, Extra>) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &Allocation<Tag, Extra>) -> Option<Ordering>[src]This method returns an ordering between self and other values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]This method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for Allocation[src]
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for Allocation[src]impl<Tag: Eq, Extra: Eq> Eq for Allocation<Tag, Extra>[src]
impl<Tag, Extra> StructuralEq for Allocation<Tag, Extra>[src]
impl<Tag, Extra> StructuralPartialEq for Allocation<Tag, Extra>[src]
Auto Trait Implementations
impl<Tag, Extra> RefUnwindSafe for Allocation<Tag, Extra> where
Extra: RefUnwindSafe,
Tag: RefUnwindSafe,
Extra: RefUnwindSafe,
Tag: RefUnwindSafe,
impl<Tag, Extra> Send for Allocation<Tag, Extra> where
Extra: Send,
Tag: Send,
Extra: Send,
Tag: Send,
impl<Tag, Extra> Sync for Allocation<Tag, Extra> where
Extra: Sync,
Tag: Sync,
Extra: Sync,
Tag: Sync,
impl<Tag, Extra> Unpin for Allocation<Tag, Extra> where
Extra: Unpin,
Tag: Unpin,
Extra: Unpin,
Tag: Unpin,
impl<Tag, Extra> UnwindSafe for Allocation<Tag, Extra> where
Extra: UnwindSafe,
Tag: UnwindSafe,
Extra: UnwindSafe,
Tag: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> MaybeResult<T> for T[src]
impl<T> MaybeResult<T> for T[src]impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> WithConstness for T[src]
impl<T> WithConstness for T[src]fn with_constness(self, constness: Constness) -> ConstnessAnd<Self>[src]
fn with_const(self) -> ConstnessAnd<Self>[src]
fn without_const(self) -> ConstnessAnd<Self>[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,