MiriMachine in miri - Rust
Description: The machine itself.

Skip to main content

## MiriMachine

# Struct MiriMachine

Source

    pub struct MiriMachine<'tcx> {Show 58 fields
        pub tcx: TyCtxt<'tcx>,
        pub borrow_tracker: Option<RefCell<GlobalStateInner>>,
        pub data_race: GlobalDataRaceHandler,
        pub alloc_addresses: RefCell<GlobalStateInner>,
        pub(crate) env_vars: EnvVars<'tcx>,
        pub(crate) main_fn_ret_place: Option<MPlaceTy<'tcx>>,
        pub(crate) argc: Option<Pointer>,
        pub(crate) argv: Option<Pointer>,
        pub(crate) cmd_line: Option<Pointer>,
        pub(crate) tls: TlsData<'tcx>,
        pub(crate) isolated_op: IsolatedOp,
        pub(crate) validation: ValidationMode,
        pub(crate) fds: FdTable,
        pub(crate) dirs: DirTable,
        pub(crate) epoll_interests: EpollInterestTable,
        pub(crate) monotonic_clock: MonotonicClock,
        pub(crate) threads: ThreadManager<'tcx>,
        pub(crate) blocking_io: BlockingIoManager,
        pub(crate) thread_cpu_affinity: Option<FxHashMap<ThreadId, CpuAffinityMask>>,
        pub(crate) layouts: PrimitiveLayouts<'tcx>,
        pub(crate) static_roots: Vec<AllocId>,
        profiler: Option<Profiler>,
        string_cache: FxHashMap<String, StringId>,
        pub(crate) exported_symbols_cache: FxHashMap<Symbol, Option<Instance<'tcx>>>,
        pub(crate) backtrace_style: BacktraceStyle,
        pub(crate) user_relevant_crates: Vec<CrateNum>,
        pub(crate) extern_statics: FxHashMap<Symbol, StrictPointer>,
        pub(crate) missing_weak_symbol: Option<StrictPointer>,
        pub(crate) rng: RefCell<StdRng>,
        pub(crate) allocator: Option<Rc<RefCell<IsolatedAlloc>>>,
        pub(crate) tracked_alloc_ids: FxHashSet<AllocId>,
        track_alloc_accesses: bool,
        pub(crate) check_alignment: AlignmentCheck,
        pub(crate) cmpxchg_weak_failure_rate: f64,
        pub(crate) preemption_rate: f64,
        pub(crate) report_progress: Option<u32>,
        pub(crate) basic_block_count: u64,
        pub native_lib: Vec<(Library, PathBuf)>,
        pub native_lib_ecx_interchange: &'static Cell<usize>,
        pub(crate) gc_interval: u32,
        pub(crate) since_gc: u32,
        pub(crate) num_cpus: u32,
        pub(crate) page_size: u64,
        pub(crate) stack_addr: u64,
        pub(crate) stack_size: u64,
        pub(crate) collect_leak_backtraces: bool,
        pub(crate) allocation_spans: RefCell<FxHashMap<AllocId, (Span, Option<Span>)>>,
        pub(crate) symbolic_alignment: RefCell<FxHashMap<AllocId, (Size, Align)>>,
        union_data_ranges: FxHashMap<Ty<'tcx>, RangeSet>,
        pub(crate) pthread_mutex_sanity: Cell<bool>,
        pub(crate) pthread_rwlock_sanity: Cell<bool>,
        pub(crate) pthread_condvar_sanity: Cell<bool>,
        pub(crate) allocator_shim_symbols: FxHashMap<Symbol, Either<Symbol, SpecialAllocatorMethod>>,
        pub(crate) mangle_internal_symbol_cache: FxHashMap<&'static str, String>,
        pub force_intrinsic_fallback: bool,
        pub float_nondet: bool,
        pub float_rounding_error: FloatRoundingErrorMode,
        pub short_fd_operations: bool,
    }

Expand description

The machine itself.

If you add anything here that stores machine values, remember to update `visit_all_machine_values`!

## Fields§

§`tcx: TyCtxt<'tcx>`§`borrow_tracker: Option<RefCell<GlobalStateInner>>`

Global data for borrow tracking.

§`data_race: GlobalDataRaceHandler`

Depending on settings, this will be `None`, global data for a data race detector, or the context required for running in GenMC mode.

Invariant: The enum variant must match the enum variant of `AllocDataRaceHandler` in the `data_race` field of all `AllocExtra`.

§`alloc_addresses: RefCell<GlobalStateInner>`

Ptr-int-cast module global data.

§`env_vars: EnvVars<'tcx>`

Environment variables.

§`main_fn_ret_place: Option<MPlaceTy<'tcx>>`

Return place of the main function.

§`argc: Option<Pointer>`

Program arguments (`Option` because we can only initialize them after creating the ecx). These are pointers to argc/argv because macOS. We also need the full command line as one string because of Windows.

§`argv: Option<Pointer>`§`cmd_line: Option<Pointer>`§`tls: TlsData<'tcx>`

TLS state.

§`isolated_op: IsolatedOp`

What should Miri do when an op requires communicating with the host, such as accessing host env vars, random number generation, and file system access.

§`validation: ValidationMode`

Whether to enforce the validity invariant.

§`fds: FdTable`

The table of file descriptors.

§`dirs: DirTable`

The table of directory descriptors.

§`epoll_interests: EpollInterestTable`

The list of all EpollEventInterest.

§`monotonic_clock: MonotonicClock`

This machine’s monotone clock.

§`threads: ThreadManager<'tcx>`

The set of threads.

§`blocking_io: BlockingIoManager`

Handles blocking I/O and polling for completion.

§`thread_cpu_affinity: Option<FxHashMap<ThreadId, CpuAffinityMask>>`

Stores which thread is eligible to run on which CPUs. This has no effect at all, it is just tracked to produce the correct result in `sched_getaffinity` This will be `None` when running `#![no_core]` crates.

§`layouts: PrimitiveLayouts<'tcx>`

Precomputed `TyLayout`s for primitive data types that are commonly used inside Miri.

§`static_roots: Vec<AllocId>`

Allocations that are considered roots of static memory (that may leak).

§`profiler: Option<Profiler>`

The `measureme` profiler used to record timing information about the emulated program.

§`string_cache: FxHashMap<String, StringId>`

Used with `profiler` to cache the `StringId`s for event names used with `measureme`.

§`exported_symbols_cache: FxHashMap<Symbol, Option<Instance<'tcx>>>`

Cache of `Instance` exported under the given `Symbol` name. `None` means no `Instance` exported under the given name is found.

§`backtrace_style: BacktraceStyle`

Equivalent setting as RUST_BACKTRACE on encountering an error.

§`user_relevant_crates: Vec<CrateNum>`

Crates which are considered user-relevant for the purposes of error reporting.

§`extern_statics: FxHashMap<Symbol, StrictPointer>`

Mapping extern static names to their pointer.

§`missing_weak_symbol: Option<StrictPointer>`

A pointer to the allocation we provide for non-existent weak symbols.

§`rng: RefCell<StdRng>`

The random number generator used for resolving non-determinism. Needs to be queried by ptr_to_int, hence needs interior mutability.

§`allocator: Option<Rc<RefCell<IsolatedAlloc>>>`

The allocator used for the machine’s `AllocBytes` in native-libs mode.

§`tracked_alloc_ids: FxHashSet<AllocId>`

The allocation IDs to report when they are being allocated (helps for debugging memory leaks and use after free bugs).

§`track_alloc_accesses: bool`

For the tracked alloc ids, also report read/write accesses.

§`check_alignment: AlignmentCheck`

Controls whether alignment of memory accesses is being checked.

§`cmpxchg_weak_failure_rate: f64`

Failure rate of compare_exchange_weak, between 0.0 and 1.0

§`preemption_rate: f64`

The probability of the active thread being preempted at the end of each basic block.

§`report_progress: Option<u32>`

If `Some`, we will report the current stack every N basic blocks.

§`basic_block_count: u64`§`native_lib: Vec<(Library, PathBuf)>`

Handle of the optional shared object file for native functions.

§`native_lib_ecx_interchange: &'static Cell<usize>`

A memory location for exchanging the current `ecx` pointer with native code.

§`gc_interval: u32`

Run a garbage collector for BorTags every N basic blocks.

§`since_gc: u32`

The number of blocks that passed since the last BorTag GC pass.

§`num_cpus: u32`

The number of CPUs to be reported by miri.

§`page_size: u64`

Determines Miri’s page size and associated values

§`stack_addr: u64`§`stack_size: u64`§`collect_leak_backtraces: bool`

Whether to collect a backtrace when each allocation is created, just in case it leaks.

§`allocation_spans: RefCell<FxHashMap<AllocId, (Span, Option<Span>)>>`

The spans we will use to report where an allocation was created and deallocated in diagnostics.

§`symbolic_alignment: RefCell<FxHashMap<AllocId, (Size, Align)>>`

For each allocation, an offset inside that allocation that was deemed aligned even for symbolic alignment checks. This cannot be stored in `AllocExtra` since it needs to be tracked for vtables and function allocations as well as regular allocations.

Invariant: the promised alignment will never be less than the native alignment of the allocation.

§`union_data_ranges: FxHashMap<Ty<'tcx>, RangeSet>`

A cache of “data range” computations for unions (i.e., the offsets of non-padding bytes).

§`pthread_mutex_sanity: Cell<bool>`

Caches the sanity-checks for various pthread primitives.

§`pthread_rwlock_sanity: Cell<bool>`§`pthread_condvar_sanity: Cell<bool>`§`allocator_shim_symbols: FxHashMap<Symbol, Either<Symbol, SpecialAllocatorMethod>>`

(Foreign) symbols that are synthesized as part of the allocator shim: the key indicates the name of the symbol being synthesized; the value indicates whether this should invoke some other symbol or whether this has special allocator semantics.

§`mangle_internal_symbol_cache: FxHashMap<&'static str, String>`

Cache for `mangle_internal_symbol`.

§`force_intrinsic_fallback: bool`

Always prefer the intrinsic fallback body over the native Miri implementation.

§`float_nondet: bool`

Whether floating-point operations can behave non-deterministically.

§`float_rounding_error: FloatRoundingErrorMode`

Whether floating-point operations can have a non-deterministic rounding error.

§`short_fd_operations: bool`

Whether Miri artificially introduces short reads/writes on file descriptors.

## Implementations§

Source§

### impl<'tcx> MiriMachine<'tcx>

Source

#### pub fn free_alloc_id( &mut self, dead_id: AllocId, size: Size, align: Align, kind: MemoryKind, )

Source§

### impl MiriMachine<'_>

Source

#### pub fn timeout( &self, clock: TimeoutClock, style: TimeoutStyle, duration: Duration, ) -> Deadline

Computes the deadline for a given timeout configuration and duration.

Source§

### impl<'tcx> MiriMachine<'tcx>

Source

#### pub fn emit_diagnostic(&self, e: NonHaltingDiagnostic)

Source§

### impl<'tcx> MiriMachine<'tcx>

Source

#### pub fn current_user_relevant_span(&self) -> Span

Get the current span in the topmost function which is workspace-local and not `#[track_caller]`. This function is backed by a cache, and can be assumed to be very fast. It will work even when the stack is empty.

Source

#### pub fn caller_span(&self) -> Span

Returns the span of the caller of the current operation, again walking down the stack to find the closest frame in a local crate, if the caller of the current operation is not in a local crate. This is useful when we are processing something which occurs on function-entry and we want to point at the call to the function, not the function definition generally.

Source

#### fn stack(&self) -> &[Frame<'tcx, Provenance, FrameExtra<'tcx>>]

Source

#### fn top_user_relevant_frame(&self) -> Option<usize>

Source

#### pub fn user_relevance(&self, frame: &Frame<'tcx, Provenance>) -> u8

This is the source of truth for the `user_relevance` flag in our `FrameExtra`.

Source§

### impl<'tcx> MiriMachine<'tcx>

Source

#### pub(crate) fn new( config: &MiriConfig, layout_cx: LayoutCx<'tcx>, genmc_ctx: Option<Rc<GenmcCtx>>, ) -> Self

Create a new MiriMachine.

Invariant: `genmc_ctx.is_some() == config.genmc_config.is_some()`

Source

#### fn allocator_shim_symbols( tcx: TyCtxt<'tcx>, ) -> FxHashMap<Symbol, Either<Symbol, SpecialAllocatorMethod>>

Source

#### fn get_user_relevant_crates( tcx: TyCtxt<'_>, config: &MiriConfig, ) -> Vec<CrateNum>

Retrieve the list of user-relevant crates based on MIRI_LOCAL_CRATES as set by cargo-miri, and extra crates set in the config.

Source

#### pub(crate) fn late_init( ecx: &mut MiriInterpCx<'tcx>, config: &MiriConfig, on_main_stack_empty: StackEmptyCallback<'tcx>, ) -> InterpResult<'tcx>

Source

#### pub(crate) fn add_extern_static( ecx: &mut MiriInterpCx<'tcx>, name: &str, ptr: Pointer, )

Source

#### pub(crate) fn communicate(&self) -> bool

Source

#### pub(crate) fn is_local(&self, instance: Instance<'tcx>) -> bool

Check whether the stack frame that this `FrameInfo` refers to is part of a local crate.

Source

#### pub(crate) fn handle_abnormal_termination(&mut self)

Called when the interpreter is going to shut down abnormally, such as due to a Ctrl-C.

Source

#### pub(crate) fn page_align(&self) -> Align

Source

#### pub(crate) fn allocated_span(&self, alloc_id: AllocId) -> Option<SpanData>

Source

#### pub(crate) fn deallocated_span(&self, alloc_id: AllocId) -> Option<SpanData>

Source

#### fn init_allocation( ecx: &MiriInterpCx<'tcx>, id: AllocId, kind: MemoryKind, size: Size, align: Align, ) -> InterpResult<'tcx, AllocExtra<'tcx>>

Source§

### impl<'tcx> MiriMachine<'tcx>

Source

#### fn alloc_extern_static( ecx: &mut MiriInterpCx<'tcx>, name: &str, val: ImmTy<'tcx>, ) -> InterpResult<'tcx>

Source

#### fn weak_symbol_extern_statics( ecx: &mut MiriInterpCx<'tcx>, names: &[&str], ) -> InterpResult<'tcx>

Extern statics that are initialized with function pointers to the symbols of the same name.

Source

#### pub fn init_extern_statics(ecx: &mut MiriInterpCx<'tcx>) -> InterpResult<'tcx>

Sets up the “extern statics” for this machine.

## Trait Implementations§

Source§

### impl<'tcx> Machine<'tcx> for MiriMachine<'tcx>

Machine hook implementations.

Source§

#### fn ptr_from_addr_cast( ecx: &MiriInterpCx<'tcx>, addr: u64, ) -> InterpResult<'tcx, Pointer>

Called on `usize as ptr` casts.

Source§

#### fn expose_provenance( ecx: &InterpCx<'tcx, Self>, provenance: Self::Provenance, ) -> InterpResult<'tcx>

Called on `ptr as usize` casts. (Actually computing the resulting `usize` doesn’t need machine help, that’s just `Scalar::try_to_int`.)

Source§

#### fn ptr_get_alloc( ecx: &MiriInterpCx<'tcx>, ptr: StrictPointer, size: i64, ) -> Option<(AllocId, Size, Self::ProvenanceExtra)>

Convert a pointer with provenance into an allocation-offset pair and extra provenance info. `size` says how many bytes of memory are expected at that pointer. The sign of `size` can be used to disambiguate situations where a wildcard pointer sits right in between two allocations.

If `ptr.provenance.get_alloc_id()` is `Some(p)`, the returned `AllocId` must be `p`. The resulting `AllocId` will just be used for that one step and the forgotten again (i.e., we’ll never turn the data returned here back into a `Pointer` that might be stored in machine state).

When this fails, that means the pointer does not point to a live allocation.

Source§

#### fn adjust_global_allocation<'b>( ecx: &InterpCx<'tcx, Self>, id: AllocId, alloc: &'b Allocation, ) -> InterpResult<'tcx, Cow<'b, Allocation<Self::Provenance, Self::AllocExtra, Self::Bytes>>>

Called to adjust global allocations to the Provenance and AllocExtra of this machine.

If `alloc` contains pointers, then they are all pointing to globals.

This should avoid copying if no work has to be done! If this returns an owned allocation (because a copy had to be done to adjust things), machine memory will cache the result. (This relies on `AllocMap::get_or` being able to add the owned allocation to the map even when the map is shared.)

Source§

#### const GLOBAL_KIND: Option<MiriMemoryKind>

The memory kind to use for copied global memory (held in `tcx`) – or None if such memory should not be mutated and thus any such attempt will cause a `ModifiedStatic` error to be raised. Statics are copied under two circumstances: When they are mutated, and when `adjust_allocation` (see below) returns an owned allocation that is added to the memory so that the work is not done twice.
Source§

#### const PANIC_ON_ALLOC_FAIL: bool = false

Should the machine panic on allocation failures?
Source§

#### type MemoryKind = MiriMemoryKind

Additional memory kinds a machine wishes to distinguish from the builtin ones
Source§

#### type ExtraFnVal = DynSym

Machines can define extra (non-instance) things that represent values of function pointers. For example, Miri uses this to return a function pointer from `dlsym` that can later be called to execute the right thing.
Source§

#### type FrameExtra = FrameExtra<'tcx>

Extra data stored in every call frame.
Source§

#### type AllocExtra = AllocExtra<'tcx>

Extra data stored in every allocation.
Source§

#### type Provenance = Provenance

Pointers are “tagged” with provenance information; typically the `AllocId` they belong to.
Source§

#### type ProvenanceExtra = ProvenanceExtra

When getting the AllocId of a pointer, some extra data is also obtained from the provenance that is passed to memory access hooks so they can do things with it.
Source§

#### type Bytes = MiriAllocBytes

Type for the bytes of the allocation.
Source§

#### type MemoryMap = MonoHashMap<AllocId, (MemoryKind<MiriMemoryKind>, Allocation<Provenance, <MiriMachine<'tcx> as Machine<'tcx>>::AllocExtra, <MiriMachine<'tcx> as Machine<'tcx>>::Bytes>)>

Memory’s allocation map
Source§

#### fn enforce_alignment(ecx: &MiriInterpCx<'tcx>) -> bool

Whether memory accesses should be alignment-checked.
Source§

#### fn alignment_check( ecx: &MiriInterpCx<'tcx>, alloc_id: AllocId, alloc_align: Align, alloc_kind: AllocKind, offset: Size, align: Align, ) -> Option<Misalignment>

Gives the machine a chance to detect more misalignment than the built-in checks would catch.
Source§

#### fn enforce_validity( ecx: &MiriInterpCx<'tcx>, _layout: TyAndLayout<'tcx>, ) -> bool

Whether to enforce the validity invariant for a specific layout.
Source§

#### fn enforce_validity_recursively( ecx: &InterpCx<'tcx, Self>, _layout: TyAndLayout<'tcx>, ) -> bool

Whether to enforce the validity invariant recursively.
Source§

#### fn ignore_optional_overflow_checks(ecx: &MiriInterpCx<'tcx>) -> bool

Whether Assert(OverflowNeg) and Assert(Overflow) MIR terminators should actually check for overflow.
Source§

#### fn check_fn_target_features( ecx: &MiriInterpCx<'tcx>, instance: Instance<'tcx>, ) -> InterpResult<'tcx>

Check whether the given function may be executed on the current machine, in terms of the target features is requires.
Source§

#### fn find_mir_or_eval_fn( ecx: &mut MiriInterpCx<'tcx>, instance: Instance<'tcx>, abi: &FnAbi<'tcx, Ty<'tcx>>, args: &[FnArg<'tcx>], dest: &PlaceTy<'tcx>, ret: Option<BasicBlock>, unwind: UnwindAction, ) -> InterpResult<'tcx, Option<(&'tcx Body<'tcx>, Instance<'tcx>)>>

Entry point to all function calls. Read more
Source§

#### fn call_extra_fn( ecx: &mut MiriInterpCx<'tcx>, fn_val: DynSym, abi: &FnAbi<'tcx, Ty<'tcx>>, args: &[FnArg<'tcx>], dest: &PlaceTy<'tcx>, ret: Option<BasicBlock>, unwind: UnwindAction, ) -> InterpResult<'tcx>

Execute `fn_val`. It is the hook’s responsibility to advance the instruction pointer as appropriate.
Source§

#### fn call_intrinsic( ecx: &mut MiriInterpCx<'tcx>, instance: Instance<'tcx>, args: &[OpTy<'tcx>], dest: &PlaceTy<'tcx>, ret: Option<BasicBlock>, unwind: UnwindAction, ) -> InterpResult<'tcx, Option<Instance<'tcx>>>

Directly process an intrinsic without pushing a stack frame. It is the hook’s responsibility to advance the instruction pointer as appropriate. Read more
Source§

#### fn assert_panic( ecx: &mut MiriInterpCx<'tcx>, msg: &AssertMessage<'tcx>, unwind: UnwindAction, ) -> InterpResult<'tcx>

Called to evaluate `Assert` MIR terminators that trigger a panic.
Source§

#### fn panic_nounwind( ecx: &mut InterpCx<'tcx, Self>, msg: &str, ) -> InterpResult<'tcx>

Called to trigger a non-unwinding panic.
Source§

#### fn unwind_terminate( ecx: &mut InterpCx<'tcx, Self>, reason: UnwindTerminateReason, ) -> InterpResult<'tcx>

Called when unwinding reached a state where execution should be terminated.
Source§

#### fn binary_ptr_op( ecx: &MiriInterpCx<'tcx>, bin_op: BinOp, left: &ImmTy<'tcx>, right: &ImmTy<'tcx>, ) -> InterpResult<'tcx, ImmTy<'tcx>>

Called for all binary operations where the LHS has pointer type. Read more
Source§

#### fn generate_nan<F1: Float + FloatConvert<F2>, F2: Float>( ecx: &InterpCx<'tcx, Self>, inputs: &[F1], ) -> F2

Generate the NaN returned by a float operation, given the list of inputs. (This is all inputs, not just NaN inputs!)
Source§

#### fn apply_float_nondet( ecx: &mut InterpCx<'tcx, Self>, val: ImmTy<'tcx>, ) -> InterpResult<'tcx, ImmTy<'tcx>>

Apply non-determinism to float operations that do not return a precise result.
Source§

#### fn equal_float_min_max<F: Float>(ecx: &MiriInterpCx<'tcx>, a: F, b: F) -> F

Determines the result of `min`/`max` on floats when the arguments are equal.
Source§

#### fn float_fuse_mul_add(ecx: &InterpCx<'tcx, Self>) -> bool

Determines whether the `fmuladd` intrinsics fuse the multiply-add or use separate operations.
Source§

#### fn runtime_checks( ecx: &InterpCx<'tcx, Self>, r: RuntimeChecks, ) -> InterpResult<'tcx, bool>

Determines the result of a `Operand::RuntimeChecks` invocation.
Source§

#### fn thread_local_static_pointer( ecx: &mut MiriInterpCx<'tcx>, def_id: DefId, ) -> InterpResult<'tcx, StrictPointer>

Return the `AllocId` for the given thread-local static in the current thread.
Source§

#### fn extern_static_pointer( ecx: &MiriInterpCx<'tcx>, def_id: DefId, ) -> InterpResult<'tcx, StrictPointer>

Return the `AllocId` for the given `extern static`.
Source§

#### fn init_local_allocation( ecx: &MiriInterpCx<'tcx>, id: AllocId, kind: MemoryKind, size: Size, align: Align, ) -> InterpResult<'tcx, Self::AllocExtra>

Initialize the extra state of an allocation local to this machine. Read more
Source§

#### fn adjust_alloc_root_pointer( ecx: &MiriInterpCx<'tcx>, ptr: Pointer<CtfeProvenance>, kind: Option<MemoryKind>, ) -> InterpResult<'tcx, Pointer<Provenance>>

Return a “root” pointer for the given allocation: the one that is used for direct accesses to this static/const/fn allocation, or the one returned from the heap allocator. Read more
Source§

#### fn before_memory_read( _tcx: TyCtxtAt<'tcx>, machine: &Self, alloc_extra: &AllocExtra<'tcx>, ptr: Pointer, (alloc_id, prov_extra): (AllocId, Self::ProvenanceExtra), range: AllocRange, ) -> InterpResult<'tcx>

Hook for performing extra checks on a memory read access. `ptr` will always be a pointer with the provenance in `prov` pointing to the beginning of `range`. Read more
Source§

#### fn before_memory_write( _tcx: TyCtxtAt<'tcx>, machine: &mut Self, alloc_extra: &mut AllocExtra<'tcx>, ptr: Pointer, (alloc_id, prov_extra): (AllocId, Self::ProvenanceExtra), range: AllocRange, ) -> InterpResult<'tcx>

Hook for performing extra checks on a memory write access. This is not invoked for ZST accesses, as no write actually happens. `ptr` will always be a pointer with the provenance in `prov` pointing to the beginning of `range`.
Source§

#### fn before_memory_deallocation( _tcx: TyCtxtAt<'tcx>, machine: &mut Self, alloc_extra: &mut AllocExtra<'tcx>, ptr: Pointer, (alloc_id, prove_extra): (AllocId, Self::ProvenanceExtra), size: Size, align: Align, kind: MemoryKind, ) -> InterpResult<'tcx>

Hook for performing extra operations on a memory deallocation. `ptr` will always be a pointer with the provenance in `prov` pointing to the beginning of the allocation.
Source§

#### fn retag_ptr_value( ecx: &mut InterpCx<'tcx, Self>, val: &ImmTy<'tcx>, ty: Ty<'tcx>, ) -> InterpResult<'tcx, Option<ImmTy<'tcx>>>

Executes a retagging operation for a single pointer. Returns the possibly adjusted pointer. Return `None` if the pointer was left unchanged. Read more
Source§

#### fn with_retag_mode<T>( ecx: &mut InterpCx<'tcx, Self>, mode: RetagMode, f: impl FnOnce(&mut InterpCx<'tcx, Self>) -> InterpResult<'tcx, T>, ) -> InterpResult<'tcx, T>

Invoke `f` in a state where calls to `retag_ptr_value` will use the given retag mode.
Source§

#### fn protect_in_place_function_argument( ecx: &mut InterpCx<'tcx, Self>, place: &MPlaceTy<'tcx>, ) -> InterpResult<'tcx>

Called on places used for in-place function argument and return value handling. Read more
Source§

#### fn init_frame( ecx: &mut InterpCx<'tcx, Self>, frame: Frame<'tcx, Provenance>, ) -> InterpResult<'tcx, Frame<'tcx, Provenance, FrameExtra<'tcx>>>

Called immediately before a new stack frame gets pushed.
Source§

#### fn stack<'a>( ecx: &'a InterpCx<'tcx, Self>, ) -> &'a [Frame<'tcx, Self::Provenance, Self::FrameExtra>]

Borrow the current thread’s stack.
Source§

#### fn stack_mut<'a>( ecx: &'a mut InterpCx<'tcx, Self>, ) -> &'a mut Vec<Frame<'tcx, Self::Provenance, Self::FrameExtra>>

Mutably borrow the current thread’s stack.
Source§

#### fn before_terminator(ecx: &mut InterpCx<'tcx, Self>) -> InterpResult<'tcx>

Called before a basic block terminator is executed.
Source§

#### fn after_stack_push(ecx: &mut InterpCx<'tcx, Self>) -> InterpResult<'tcx>

Called immediately after a stack frame got pushed and its locals got initialized.
Source§

#### fn before_stack_pop(ecx: &mut InterpCx<'tcx, Self>) -> InterpResult<'tcx>

Called just before the frame is removed from the stack (followed by return value copy and local cleanup).
Source§

#### fn after_stack_pop( ecx: &mut InterpCx<'tcx, Self>, frame: Frame<'tcx, Provenance, FrameExtra<'tcx>>, unwinding: bool, ) -> InterpResult<'tcx, ReturnAction>

Called immediately after a stack frame got popped, but before jumping back to the caller. The `locals` have already been destroyed!
Source§

#### fn after_local_read( ecx: &InterpCx<'tcx, Self>, frame: &Frame<'tcx, Provenance, FrameExtra<'tcx>>, local: Local, ) -> InterpResult<'tcx>

Called immediately after an “immediate” local variable is read in a given frame (i.e., this is called for reads that do not end up accessing addressable memory).
Source§

#### fn after_local_write( ecx: &mut InterpCx<'tcx, Self>, local: Local, storage_live: bool, ) -> InterpResult<'tcx>

Called immediately after an “immediate” local variable is assigned a new value (i.e., this is called for writes that do not end up in memory). `storage_live` indicates whether this is the initial write upon `StorageLive`.
Source§

#### fn after_local_moved_to_memory( ecx: &mut InterpCx<'tcx, Self>, local: Local, mplace: &MPlaceTy<'tcx>, ) -> InterpResult<'tcx>

Called immediately after actual memory was allocated for a local but before the local’s stack frame is updated to point to that memory.
Source§

#### fn get_global_alloc_salt( ecx: &InterpCx<'tcx, Self>, instance: Option<Instance<'tcx>>, ) -> usize

Returns the salt to be used for a deduplicated global alloation. If the allocation is for a function, the instance is provided as well (this lets Miri ensure unique addresses for some functions).
Source§

#### fn cached_union_data_range<'e>( ecx: &'e mut InterpCx<'tcx, Self>, ty: Ty<'tcx>, compute_range: impl FnOnce() -> RangeSet, ) -> Cow<'e, RangeSet>

Source§

#### fn get_default_alloc_params(&self) -> <Self::Bytes as AllocBytes>::AllocParams

Compute the value passed to the constructors of the `AllocBytes` type for abstract machine allocations.
Source§

#### fn enter_trace_span(span: impl FnOnce() -> Span) -> impl EnteredTraceSpan

Allows enabling/disabling tracing calls from within `rustc_const_eval` at compile time, by delegating the entering of [tracing::Span]s to implementors of the Machine trait. The default implementation corresponds to tracing being disabled, meaning the tracing calls will supposedly be optimized out completely. To enable tracing, override this trait method and return `span.entered()`. Also see crate::enter_trace_span.
Source§

#### const ALL_CONSTS_ARE_PRECHECKED: bool = true

Determines whether `eval_mir_constant` can never fail because all required consts have already been checked before.
Source§

#### fn load_mir( ecx: &InterpCx<'tcx, Self>, instance: InstanceKind<'tcx>, ) -> &'tcx Body<'tcx>

Entry point for obtaining the MIR of anything that should get evaluated. So not just functions and shims, but also const/static initializers, anonymous constants, …
Source§

#### fn increment_const_eval_counter( _ecx: &mut InterpCx<'tcx, Self>, ) -> InterpResult<'tcx>

Called when the interpreter encounters a `StatementKind::ConstEvalCounter` instruction. You can use this to detect long or endlessly running programs.
Source§

#### fn before_access_global( _tcx: TyCtxtAt<'tcx>, _machine: &Self, _alloc_id: AllocId, _allocation: ConstAllocation<'tcx>, _static_def_id: Option<DefId>, _is_write: bool, ) -> InterpResult<'tcx>

Called before a global allocation is accessed. `def_id` is `Some` if this is the “lazy” allocation of a static.
Source§

#### fn before_alloc_access( _tcx: TyCtxtAt<'tcx>, _machine: &Self, _alloc_id: AllocId, ) -> InterpResult<'tcx>

Hook for performing extra checks on any memory read access, that involves an allocation, even ZST reads. Read more
Source§

### impl VisitProvenance for MiriMachine<'_>

Source§

#### fn visit_provenance(&self, visit: &mut VisitWith<'_>)

## Auto Trait Implementations§

§

### impl<'tcx> !Freeze for MiriMachine<'tcx>

§

### impl<'tcx> !RefUnwindSafe for MiriMachine<'tcx>

§

### impl<'tcx> !Send for MiriMachine<'tcx>

§

### impl<'tcx> !Sync for MiriMachine<'tcx>

§

### impl<'tcx> !UnwindSafe for MiriMachine<'tcx>

§

### impl<'tcx> Unpin for MiriMachine<'tcx>

§

### impl<'tcx> UnsafeUnpin for MiriMachine<'tcx>

## Blanket Implementations§

Source§

### impl<T> Any for T
where T: 'static + ?Sized,

Source§

#### fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more
Source§

### impl<T> Borrow<T> for T
where T: ?Sized,

Source§

#### fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

### impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

#### fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

### impl<T> From<T> for T

Source§

#### fn from(t: T) -> T

Returns the argument unchanged.

Source§

### impl<T, U> Into<U> for T
where U: From<T>,

Source§

#### fn into(self) -> U

Calls `U::from(self)`.

That is, this conversion is whatever the implementation of `From<T> for U` chooses to do.

Source§

### impl<T> Same for T

Source§

#### type Output = T

Should always be `Self`
Source§

### impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

#### type Error = Infallible

The type returned in the event of a conversion error.
Source§

#### fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

### impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

#### fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

## Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain `repr(...)` attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 2176 bytes