diff options
| author | Ralf Jung <post@ralfj.de> | 2020-08-09 18:01:37 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-08-09 18:01:37 +0200 |
| commit | aec6df9b944c052ed7899b150f6537c6c6fae535 (patch) | |
| tree | 531cd604d36a379048aba520081301fc32522991 /src | |
| parent | 8bc801b05019cd3e0ef19e6c4c028d55baa645d2 (diff) | |
| download | rust-aec6df9b944c052ed7899b150f6537c6c6fae535.tar.gz rust-aec6df9b944c052ed7899b150f6537c6c6fae535.zip | |
move stack size check to const_eval machine
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/const_eval/machine.rs | 9 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/eval_context.rs | 6 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/librustc_mir/const_eval/machine.rs b/src/librustc_mir/const_eval/machine.rs index 0dac8b64910..3a753a0edb6 100644 --- a/src/librustc_mir/const_eval/machine.rs +++ b/src/librustc_mir/const_eval/machine.rs @@ -301,6 +301,15 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, 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>, diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 1e9be097815..edf0dd0d5ed 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -653,11 +653,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { 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. |
