Introduce Machine::POST_MONO_CHECKS.
This commit is contained in:
parent
e5fedceabf
commit
054ed8e7eb
3 changed files with 12 additions and 4 deletions
|
@ -749,11 +749,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
self.stack_mut().push(frame);
|
self.stack_mut().push(frame);
|
||||||
|
|
||||||
// Make sure all the constants required by this frame evaluate successfully (post-monomorphization check).
|
// Make sure all the constants required by this frame evaluate successfully (post-monomorphization check).
|
||||||
|
if M::POST_MONO_CHECKS {
|
||||||
for ct in &body.required_consts {
|
for ct in &body.required_consts {
|
||||||
let span = ct.span;
|
let span = ct.span;
|
||||||
let ct = self.subst_from_current_frame_and_normalize_erasing_regions(ct.literal)?;
|
let ct = self.subst_from_current_frame_and_normalize_erasing_regions(ct.literal)?;
|
||||||
self.eval_mir_constant(&ct, Some(span), None)?;
|
self.eval_mir_constant(&ct, Some(span), None)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// done
|
// done
|
||||||
M::after_stack_push(self)?;
|
M::after_stack_push(self)?;
|
||||||
|
|
|
@ -130,6 +130,9 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
|
||||||
/// Should the machine panic on allocation failures?
|
/// Should the machine panic on allocation failures?
|
||||||
const PANIC_ON_ALLOC_FAIL: bool;
|
const PANIC_ON_ALLOC_FAIL: bool;
|
||||||
|
|
||||||
|
/// Should post-monomorphization checks be run when a stack frame is pushed?
|
||||||
|
const POST_MONO_CHECKS: bool = true;
|
||||||
|
|
||||||
/// Whether memory accesses should be alignment-checked.
|
/// Whether memory accesses should be alignment-checked.
|
||||||
fn enforce_alignment(ecx: &InterpCx<'mir, 'tcx, Self>) -> CheckAlignment;
|
fn enforce_alignment(ecx: &InterpCx<'mir, 'tcx, Self>) -> CheckAlignment;
|
||||||
|
|
||||||
|
|
|
@ -143,8 +143,11 @@ impl ConstPropMachine<'_, '_> {
|
||||||
|
|
||||||
impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx> {
|
impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx> {
|
||||||
compile_time_machine!(<'mir, 'tcx>);
|
compile_time_machine!(<'mir, 'tcx>);
|
||||||
|
|
||||||
const PANIC_ON_ALLOC_FAIL: bool = true; // all allocations are small (see `MAX_ALLOC_LIMIT`)
|
const PANIC_ON_ALLOC_FAIL: bool = true; // all allocations are small (see `MAX_ALLOC_LIMIT`)
|
||||||
|
|
||||||
|
const POST_MONO_CHECKS: bool = false; // this MIR is still generic!
|
||||||
|
|
||||||
type MemoryKind = !;
|
type MemoryKind = !;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue