Expand description

An interpreter for MIR used in CTFE and by miri

Modules§

  • cast 🔒
  • Functions for reading and writing discriminants of multi-variant layouts (enums and coroutines).
  • 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.
  • step 🔒
    This module contains the InterpCx methods for executing a single step of the interpreter.
  • terminator 🔒
  • 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 consts 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§

  • 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§

  • The information that makes up a memory access: offset and size.
  • A reference to some allocation that was already bounds-checked for the given region and had the on-access machine hooks run.
  • A reference to some allocation that was already bounds-checked for the given region and had the on-access machine hooks run.
  • This type represents an Allocation in the Miri/CTFE core engine.
  • Details of an access to uninitialized bytes / bad pointer bytes where it is not allowed.
  • Interned types generally have an Outer type and an Inner type, where Outer is a newtype around Interned<Inner>, and all the operations are done on Outer, because all occurrences are interned. E.g. Ty is an outer type and TyKind is its inner type.
  • The type of provenance in the compile-time interpreter. This is a packed representation of an AllocId and an immutable: bool.
  • A stack frame.
  • What we store about a frame in an interpreter backtrace.
  • Uniquely identifies one of the following:
  • Packages the kind of error we got from the const code interpreter up with a Rust-level backtrace of where the error occurred. These should always be constructed by calling .into() on an InterpError. In rustc_mir::interpret, we have throw_err_* macros for this.
  • Input argument for tcx.lit_to_const.
  • A MemPlace with its layout. Constructing it is only possible in this module.
  • Information about a misaligned pointer.
  • An evaluated place, together with its type.
  • Represents a pointer in the Miri engine.
  • State for tracking recursive validation of references
  • Information about a size mismatch.

Enums§

  • We have our own error type that does not know about the AllocId; that information is added when converting to InterpError.
  • The return value of get_alloc_info indicates the “kind” of the allocation.
  • Details of which pointer is not aligned.
  • Details of why a pointer had to be in-bounds.
  • Extra things to check for during validation of CTFE results.
  • An argment passed to a function.
  • The value of a function pointer.
  • An allocation in the global (tcx-managed) memory can be either a function pointer, a static, or a “real” allocation with some data in it.
  • An Immediate represents a single immediate self-contained Rust value.
  • A contiguous chunk of initialized or uninitialized memory.
  • How a constant value should be interned.
  • Error information for when the program we executed turned out not to actually be a valid program. This cannot happen in stand-alone Miri, but it can happen during CTFE/ConstProp where we work on generic code or execution does not have all information available.
  • Error type for tcx.lit_to_const.
  • Information required for the sound usage of a MemPlace.
  • Describes the constraints placed on offset-projections.
  • Error information for when the program exhausted the resources granted to it by the interpreter.
  • A Scalar represents an immediate, primitive value existing outside of a memory::Allocation. It is in many ways like a small chunk of an Allocation, up to 16 bytes in size. Like a range of bytes in an Allocation, a Scalar can either represent the raw bytes of a simple value or a pointer into another Allocation
  • Data returned by Machine::stack_pop, to provide further control over the popping of the stack frame
  • Error information for when the program caused Undefined Behavior.
  • Error information for when the program did something that might (or might not) be correct to do according to the Rust spec, but due to limitations in the interpreter, the operation could not be carried out. These limitations can differ between CTFE and the Miri engine, e.g., CTFE does not support dereferencing pointers at integral addresses.

Traits§

  • Functionality required for the bytes of an Allocation.
  • The functionality needed by memory to manage its allocations
  • Methods of this trait signifies a point where CTFE evaluation would fail and some use case dependent behaviour can instead be applied.
  • A trait for machine-specific errors (or other “machine stop” conditions).
  • Whether this kind of memory is allowed to leak
  • A thing that we can project into, and that has a layout.
  • This trait abstracts over the kind of provenance that is associated with a Pointer. It is mostly opaque; the Machine trait extends it with some more operations that also have access to some global state. The Debug rendering is used to display bare provenance, and for the default impl of fmt.
  • The Readable trait describes interpreter values that one can read from.
  • How to traverse a value and what to do when we are at the leaves.
  • The Weiteable trait describes interpreter values that can be written to.

Functions§

Type Aliases§