move stack size check to const_eval machine

This commit is contained in:
Ralf Jung 2020-08-09 18:01:37 +02:00
parent 8bc801b050
commit aec6df9b94
2 changed files with 10 additions and 5 deletions

View File

@ -301,6 +301,15 @@ fn before_terminator(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx>
Ok(())
}
fn after_stack_push(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
// Enforce stack size limit.
if !ecx.tcx.sess.recursion_limit().value_within_limit(ecx.stack().len()) {
throw_exhaust!(StackFrameLimitReached)
} else {
Ok(())
}
}
#[inline(always)]
fn stack(
ecx: &'a InterpCx<'mir, 'tcx, Self>,

View File

@ -653,11 +653,7 @@ pub fn push_stack_frame(
M::after_stack_push(self)?;
info!("ENTERING({}) {}", self.frame_idx(), self.frame().instance);
if !self.tcx.sess.recursion_limit().value_within_limit(self.stack().len()) {
throw_exhaust!(StackFrameLimitReached)
} else {
Ok(())
}
Ok(())
}
/// Jump to the given block.