Step limit is now terminator limit

This commit is contained in:
Oliver Schneider 2018-02-19 12:00:15 +01:00
parent b63c6bbfee
commit 0ca4b45a0c
No known key found for this signature in database
GPG Key ID: A69F8D225B3AD7D9
3 changed files with 4 additions and 3 deletions

View File

@ -196,7 +196,7 @@ impl<'tcx> Error for EvalError<'tcx> {
OutOfMemory{..} =>
"could not allocate more memory",
ExecutionTimeLimitReached =>
"reached the configured maximum execution time",
"the expression was too complex to be evaluated or resulted in an infinite loop",
StackFrameLimitReached =>
"reached the configured maximum number of stack frames",
OutOfTls =>

View File

@ -41,7 +41,7 @@ pub struct EvalContext<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> {
/// The maximum number of stack frames allowed
pub(crate) stack_limit: usize,
/// The maximum number of operations that may be executed.
/// The maximum number of terminators that may be evaluated.
/// This prevents infinite loops and huge computations from freezing up const eval.
/// Remove once halting problem is solved.
pub(crate) steps_remaining: usize,

View File

@ -19,7 +19,6 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
/// Returns true as long as there are more things to do.
pub fn step(&mut self) -> EvalResult<'tcx, bool> {
self.inc_step_counter_and_check_limit(1)?;
if self.stack.is_empty() {
return Ok(false);
}
@ -37,6 +36,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
return Ok(true);
}
self.inc_step_counter_and_check_limit(1)?;
let terminator = basic_block.terminator();
assert_eq!(old_frames, self.cur_frame());
self.terminator(terminator)?;