refactor(tvix/eval): Compile OpAssert using conditional jumps
In order to behave nicely with tryEval, asserts need to leave the instruction pointer in a reasonable place even if they fail - whereas with the previous implementation catching a failed assert would still end up running the op for the *body* of the assert. With this change, we compile asserts much more like an `if` expression with conditional jumps rather than having an OpAssert op. Change-Id: I1b266c3be90185c84000da6b1995ac3e6fd5471b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6925 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
1ab252470a
commit
899fbdbddb
3 changed files with 26 additions and 10 deletions
|
@ -561,10 +561,8 @@ impl<'o> VM<'o> {
|
|||
}
|
||||
}
|
||||
|
||||
OpCode::OpAssert => {
|
||||
if !fallible!(self, self.pop().as_bool()) {
|
||||
return Err(self.error(ErrorKind::AssertionFailed));
|
||||
}
|
||||
OpCode::OpAssertFail => {
|
||||
return Err(self.error(ErrorKind::AssertionFailed));
|
||||
}
|
||||
|
||||
OpCode::OpCall => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue