pub struct CompileTimeInterpreter<'mir, 'tcx> {
    pub(super) steps_remaining: usize,
    pub(super) stack: Vec<Frame<'mir, 'tcx, AllocId, ()>>,
    pub(super) can_access_statics: bool,
    pub(super) check_alignment: bool,
}
Expand description

Extra machine state for CTFE, and the Machine instance

Fields

steps_remaining: usize

For now, the number of terminators that can be evaluated before we throw a resource exhaustion error.

Setting this to 0 disables the limit and allows the interpreter to run forever.

stack: Vec<Frame<'mir, 'tcx, AllocId, ()>>

The virtual call stack.

can_access_statics: bool

We need to make sure consts never point to anything mutable, even recursively. That is relied on for pattern matching on consts with references. To achieve this, two pieces have to work together:

  • Interning makes everything outside of statics immutable.
  • Pointers to allocations inside of statics can never leak outside, to a non-static global. This boolean here controls the second part.
check_alignment: bool

Whether to check alignment during evaluation.

Implementations

Trait Implementations

Pointers are “tagged” with provenance information; typically the AllocId they belong to.
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. Read more
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. Read more
Memory’s allocation map
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. Read more
Extra data stored in every allocation.
Extra data stored in every call frame.
Whether, when checking alignment, we should look at the actual address and thus support custom alignment logic based on whatever the integer address happens to be. Read more
Whether CheckedBinOp MIR statements should actually check for overflow.
Execute fn_val. It is the hook’s responsibility to advance the instruction pointer as appropriate. Read more
Called to adjust allocations to the Provenance and AllocExtra of this machine. Read more
Return the root pointer for the given extern static.
Return a “base” 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
“Int-to-pointer cast”
Convert a pointer with provenance into an allocation-offset pair and extra provenance info. Read more
Additional memory kinds a machine wishes to distinguish from the builtin ones
Should the machine panic on allocation failures?
Whether memory accesses should be alignment-checked.
Whether to enforce the validity invariant
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, … Read more
Entry point to all function calls. Read more
Directly process an intrinsic without pushing a stack frame. It is the hook’s responsibility to advance the instruction pointer as appropriate. Read more
Called to evaluate Assert MIR terminators that trigger a panic.
Called to evaluate Abort MIR terminator.
Called for all binary operations where the LHS has pointer type. Read more
Called before a basic block terminator is executed. You can use this to detect endlessly running programs. Read more
Marks a pointer as exposed, allowing it’s provenance to be recovered. “Pointer-to-int cast” Read more
Called immediately before a new stack frame gets pushed.
Borrow the current thread’s stack.
Mutably borrow the current thread’s stack.
Called before a global allocation is accessed. def_id is Some if this is the “lazy” allocation of a static. Read more
Whether function calls should be ABI-checked.
Called to write the specified local from the frame. Since writing a ZST is not actually accessing memory or locals, this is never invoked for ZST reads. Read more
Return the AllocId for the given thread-local static in the current thread.
Hook for performing extra checks on a memory read access. Read more
Hook for performing extra checks on a memory write access.
Hook for performing extra operations on a memory deallocation.
Executes a retagging operation.
Called immediately after a stack frame got pushed and its locals got initialized.
Called immediately after a stack frame got popped, but before jumping back to the caller. The locals have already been destroyed! Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion 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: 40 bytes