Expand description
An interpreter for MIR used in CTFE and by miri
Re-exports§
pub use rustc_middle::mir::interpret::*;
Modules§
- call π
- Manages calling a concrete function (with known MIR body) with argument passing, and returning the return value to the caller.
- cast π
- discriminant π
- Functions for reading and writing discriminants of multi-variant layouts (enums and coroutines).
- eval_
context π - intern π
- This module specifies the type based interner for constants.
- intrinsics π
- Intrinsics and other functions that the interpreter executes without looking at their MIR. Intrinsics/functions supported here are shared by CTFE and miri.
- machine π
- This module contains everything needed to instantiate an interpreter. This separation exists to ensure that no fancy miri features like interpreting common C functions leak into CTFE.
- memory π
- The memory subsystem.
- operand π
- Functions concerning immediate values and operands, and reading from operands. All high-level functions to read from memory work on operands as sources.
- operator π
- place π
- Computations on places β field projections, going from mir::Place, and writing into a place. All high-level functions to write to memory work on places as destinations.
- projection π
- This file implements βplace projectionsβ; basically a symmetric API for 3 types: MPlaceTy, OpTy, PlaceTy.
- stack π
- Manages the low-level pushing and popping of stack frames and the (de)allocation of local variables.
For handling of argument passing and return values, see the
call
module. - step π
- This module contains the
InterpCx
methods for executing a single step of the interpreter. - traits π
- util π
- validity π
- Check the validity invariant of a given value, and tell the user
where in the value it got violated.
In const context, this goes even further and tries to approximate const safety.
Thatβs useful because it means other passes (e.g. promotion) can rely on
const
s to be const-safe. - visitor π
- Visitor for a run-time value with a given layout: Traverse enums, structs and other compound types until we arrive at the leaves, with custom handling for primitive types.
Macros§
- compile_
time_ machine - A lot of the flexibility above is just needed for
Miri
, but all βcompile-timeβ machines (CTFE and ConstProp) use the same instance. Here, we share that code.
Structs§
- Alloc
Info - Metadata about an
AllocId
. - Alloc
Ref - A reference to some allocation that was already bounds-checked for the given region and had the on-access machine hooks run.
- Alloc
RefMut - A reference to some allocation that was already bounds-checked for the given region and had the on-access machine hooks run.
- Frame
- A stack frame.
- Frame
Info - What we store about a frame in an interpreter backtrace.
- ImmTy
- Interp
Cx - Local
State - State of a local variable including a memoized layout
- MPlace
Ty - A MemPlace with its layout. Constructing it is only possible in this module.
- Memory
- OpTy
- PlaceTy
- An evaluated place, together with its type.
- Range
Set - Represents a set of
Size
values as a sorted list of ranges. - RefTracking
- State for tracking recursive validation of references
- Stack
PopInfo - Return type of
InterpCx::pop_stack_frame_raw
.
Enums§
- Alloc
Kind - The return value of
get_alloc_info
indicates the βkindβ of the allocation. - Ctfe
Validation Mode - Extra things to check for during validation of CTFE results.
- FnArg
- An argument passed to a function.
- FnVal
- The value of a function pointer.
- Immediate
- An
Immediate
represents a single immediate self-contained Rust value. - Intern
Kind - How a constant value should be interned.
- Intern
Result - MemPlace
Meta - Information required for the sound usage of a
MemPlace
. - Memory
Kind - Offset
Mode - Describes the constraints placed on offset-projections.
- Return
Action - Data returned by
Machine::after_stack_pop
, and consumed byInterpCx::return_from_current_stack_frame
to determine what actions should be done when returning from a stack frame. - Stack
PopCleanup
Traits§
- Alloc
Map - The functionality needed by memory to manage its allocations
- HasStatic
Root DefId - Machine
- Methods of this trait signifies a point where CTFE evaluation would fail and some use case dependent behaviour can instead be applied.
- MayLeak
- Whether this kind of memory is allowed to leak
- Projectable
- A thing that we can project into, and that has a layout.
- Value
Visitor - How to traverse a value and what to do when we are at the leaves.
- Writeable
- The
Weiteable
trait describes interpreter values that can be written to.
Functions§
- format_
interp_ error - Turn the given error into a human-readable string. Expects the string to be printed, so if
RUSTC_CTFE_BACKTRACE
is set this will show a backtrace of the rustc internals that triggered the error. - intern_
const_ alloc_ for_ constprop - Intern
ret
. This function assumes thatret
references no other allocation. - intern_
const_ alloc_ recursive - Intern
ret
and everything it references.