[][src]Struct rustc_mir::interpret::Memory

pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
    pub(super) alloc_map: M::MemoryMap,
    extra_fn_ptr_map: FxHashMap<AllocId, M::ExtraFnVal>,
    pub(super) dead_alloc_map: FxHashMap<AllocId, (Size, Align)>,
    pub extra: M::MemoryExtra,
    pub tcx: TyCtxt<'tcx>,
}
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Fields

alloc_map: M::MemoryMap
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Allocations local to this instance of the miri engine. The kind helps ensure that the same mechanism is used for allocation and deallocation. When an allocation is not found here, it is a global and looked up in the tcx for read access. Some machines may have to mutate this map even on a read-only access to a global (because they do pointer provenance tracking and the allocations in tcx have the wrong type), so we let the machine override this type. Either way, if the machine allows writing to a global, doing so will create a copy of the global allocation here.

extra_fn_ptr_map: FxHashMap<AllocId, M::ExtraFnVal>
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Map for "extra" function pointers.

dead_alloc_map: FxHashMap<AllocId, (Size, Align)>
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

To be able to compare pointers with NULL, and to check alignment for accesses to ZSTs (where pointers may dangle), we keep track of the size even for allocations that do not exist any more.

extra: M::MemoryExtra
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Extra data added by the machine.

tcx: TyCtxt<'tcx>
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Lets us implement HasDataLayout, which is awfully convenient.

Implementations

impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M>[src]

pub fn new(tcx: TyCtxt<'tcx>, extra: M::MemoryExtra) -> Self[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn tag_global_base_pointer(&self, ptr: Pointer) -> Pointer<M::PointerTag>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Call this to turn untagged "global" pointers (obtained via tcx) into the canonical machine pointer to the allocation. Must never be used for any other pointers!

This represents a direct access to that memory, as opposed to access through a pointer that was created by the program.

pub fn create_fn_alloc(
    &mut self,
    fn_val: FnVal<'tcx, M::ExtraFnVal>
) -> Pointer<M::PointerTag>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn allocate(
    &mut self,
    size: Size,
    align: Align,
    kind: MemoryKind<M::MemoryKind>
) -> Pointer<M::PointerTag>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn allocate_bytes(
    &mut self,
    bytes: &[u8],
    kind: MemoryKind<M::MemoryKind>
) -> Pointer<M::PointerTag>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn allocate_with(
    &mut self,
    alloc: Allocation,
    kind: MemoryKind<M::MemoryKind>
) -> Pointer<M::PointerTag>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn reallocate(
    &mut self,
    ptr: Pointer<M::PointerTag>,
    old_size_and_align: Option<(Size, Align)>,
    new_size: Size,
    new_align: Align,
    kind: MemoryKind<M::MemoryKind>
) -> InterpResult<'tcx, Pointer<M::PointerTag>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn deallocate_local(
    &mut self,
    ptr: Pointer<M::PointerTag>
) -> InterpResult<'tcx>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Deallocate a local, or do nothing if that local has been made into a global.

pub fn deallocate(
    &mut self,
    ptr: Pointer<M::PointerTag>,
    old_size_and_align: Option<(Size, Align)>,
    kind: MemoryKind<M::MemoryKind>
) -> InterpResult<'tcx>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn check_ptr_access(
    &self,
    sptr: Scalar<M::PointerTag>,
    size: Size,
    align: Align
) -> InterpResult<'tcx, Option<Pointer<M::PointerTag>>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Check if the given scalar is allowed to do a memory access of given size and align. On success, returns None for zero-sized accesses (where nothing else is left to do) and a Pointer to use for the actual access otherwise. Crucially, if the input is a Pointer, we will test it for liveness even if the size is 0.

Everyone accessing memory based on a Scalar should use this method to get the Pointer they need. And even if you already have a Pointer, call this method to make sure it is sufficiently aligned and not dangling. Not doing that may cause ICEs.

Most of the time you should use check_mplace_access, but when you just have a pointer, this method is still appropriate.

pub fn check_ptr_access_align(
    &self,
    sptr: Scalar<M::PointerTag>,
    size: Size,
    align: Option<Align>,
    msg: CheckInAllocMsg
) -> InterpResult<'tcx, Option<Pointer<M::PointerTag>>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Like check_ptr_access, but definitely checks alignment when align is Some (overriding M::enforce_alignment). Also lets the caller control the error message for the out-of-bounds case.

pub fn ptr_may_be_null(&self, ptr: Pointer<M::PointerTag>) -> bool[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Test if the pointer might be NULL.

impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M>[src]

Allocation accessors

fn get_global_alloc(
    memory_extra: &M::MemoryExtra,
    tcx: TyCtxt<'tcx>,
    id: AllocId,
    is_write: bool
) -> InterpResult<'tcx, Cow<'tcx, Allocation<M::PointerTag, M::AllocExtra>>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Helper function to obtain a global (tcx) allocation. This attempts to return a reference to an existing allocation if one can be found in tcx. That, however, is only possible if tcx and this machine use the same pointer tag, so it is indirected through M::tag_allocation.

pub fn get_raw(
    &self,
    id: AllocId
) -> InterpResult<'tcx, &Allocation<M::PointerTag, M::AllocExtra>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Gives raw access to the Allocation, without bounds or alignment checks. Use the higher-level, PlaceTy- and OpTy-based APIs in InterpCx instead!

pub fn get_raw_mut(
    &mut self,
    id: AllocId
) -> InterpResult<'tcx, &mut Allocation<M::PointerTag, M::AllocExtra>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Gives raw mutable access to the Allocation, without bounds or alignment checks. Use the higher-level, PlaceTy- and OpTy-based APIs in InterpCx instead!

pub fn get_size_and_align(
    &self,
    id: AllocId,
    liveness: AllocCheck
) -> InterpResult<'static, (Size, Align)>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Obtain the size and alignment of an allocation, even if that allocation has been deallocated.

If liveness is AllocCheck::MaybeDead, this function always returns Ok.

fn get_fn_alloc(&self, id: AllocId) -> Option<FnVal<'tcx, M::ExtraFnVal>>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Assumes id is already canonical.

pub fn get_fn(
    &self,
    ptr: Scalar<M::PointerTag>
) -> InterpResult<'tcx, FnVal<'tcx, M::ExtraFnVal>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn mark_immutable(&mut self, id: AllocId) -> InterpResult<'tcx>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn dump_alloc(&self, id: AllocId)[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Print an allocation and all allocations it points to, recursively. This prints directly to stderr, ignoring RUSTC_LOG! It is up to the caller to control for this.

pub fn dump_allocs(&self, allocs: Vec<AllocId>)[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Print a list of allocations and all allocations they point to, recursively. This prints directly to stderr, ignoring RUSTC_LOG! It is up to the caller to control for this.

pub fn leak_report(&self) -> usize[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn alloc_map(&self) -> &M::MemoryMap[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

This is used by priroda

impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M>[src]

Reading and writing.

pub fn read_bytes(
    &self,
    ptr: Scalar<M::PointerTag>,
    size: Size
) -> InterpResult<'tcx, &[u8]>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Reads the given number of bytes from memory. Returns them as a slice.

Performs appropriate bounds checks.

pub fn read_c_str(
    &self,
    ptr: Scalar<M::PointerTag>
) -> InterpResult<'tcx, &[u8]>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Reads a 0-terminated sequence of bytes from memory. Returns them as a slice.

Performs appropriate bounds checks.

pub fn read_wide_str(
    &self,
    ptr: Scalar<M::PointerTag>
) -> InterpResult<'tcx, Vec<u16>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Reads a 0x0000-terminated u16-sequence from memory. Returns them as a Vec. Terminator 0x0000 is not included in the returned Vec.

Performs appropriate bounds checks.

pub fn write_bytes(
    &mut self,
    ptr: Scalar<M::PointerTag>,
    src: impl IntoIterator<Item = u8>
) -> InterpResult<'tcx>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Writes the given stream of bytes into memory.

Performs appropriate bounds checks.

pub fn write_u16s(
    &mut self,
    ptr: Scalar<M::PointerTag>,
    src: impl IntoIterator<Item = u16>
) -> InterpResult<'tcx>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Writes the given stream of u16s into memory.

Performs appropriate bounds checks.

pub fn copy(
    &mut self,
    src: Pointer<M::PointerTag>,
    dest: Pointer<M::PointerTag>,
    size: Size,
    nonoverlapping: bool
) -> InterpResult<'tcx>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Expects the caller to have checked bounds and alignment.

pub fn copy_repeatedly(
    &mut self,
    src: Pointer<M::PointerTag>,
    dest: Pointer<M::PointerTag>,
    size: Size,
    length: u64,
    nonoverlapping: bool
) -> InterpResult<'tcx>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Expects the caller to have checked bounds and alignment.

impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M>[src]

Machine pointer introspection.

pub fn force_ptr(
    &self,
    scalar: Scalar<M::PointerTag>
) -> InterpResult<'tcx, Pointer<M::PointerTag>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn force_bits(
    &self,
    scalar: Scalar<M::PointerTag>,
    size: Size
) -> InterpResult<'tcx, u128>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Trait Implementations

impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout for Memory<'mir, 'tcx, M>[src]

Auto Trait Implementations

impl<'mir, 'tcx, M> !RefUnwindSafe for Memory<'mir, 'tcx, M>

impl<'mir, 'tcx, M> !Send for Memory<'mir, 'tcx, M>

impl<'mir, 'tcx, M> !Sync for Memory<'mir, 'tcx, M>

impl<'mir, 'tcx, M> Unpin for Memory<'mir, 'tcx, M> where
    <M as Machine<'mir, 'tcx>>::ExtraFnVal: Unpin,
    <M as Machine<'mir, 'tcx>>::MemoryExtra: Unpin,
    <M as Machine<'mir, 'tcx>>::MemoryMap: Unpin

impl<'mir, 'tcx, M> !UnwindSafe for Memory<'mir, 'tcx, M>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> Cast for T

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MaybeResult<T> for T[src]

type Error = !

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<T> PointerArithmetic for T where
    T: HasDataLayout
[src]

impl<T> Same<T> for T

type Output = T

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Should always be Self

impl<E> SpecializationError for E[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]