From 8fdb67847cc1f68ca88dfe7a282f30e9f6ab2cc9 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 3 Sep 2022 16:22:12 +0300 Subject: chore(tvix/eval): debug_assert that all jumps are patched Suggestion from sterni in cl/6282 Change-Id: I1adbdda9ff74f55a2f72892ffa524808b305f403 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6445 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/vm.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tvix/eval') diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index 2c490200e1d1..d42a2e303312 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -342,22 +342,26 @@ impl VM { OpCode::OpInterpolate(Count(count)) => self.run_interpolate(count)?, OpCode::OpJump(JumpOffset(offset)) => { + debug_assert!(offset != 0); self.frame_mut().ip += offset; } OpCode::OpJumpIfTrue(JumpOffset(offset)) => { + debug_assert!(offset != 0); if fallible!(self, self.peek(0).as_bool()) { self.frame_mut().ip += offset; } } OpCode::OpJumpIfFalse(JumpOffset(offset)) => { + debug_assert!(offset != 0); if !fallible!(self, self.peek(0).as_bool()) { self.frame_mut().ip += offset; } } OpCode::OpJumpIfNotFound(JumpOffset(offset)) => { + debug_assert!(offset != 0); if matches!(self.peek(0), Value::AttrNotFound) { self.pop(); self.frame_mut().ip += offset; -- cgit 1.4.1