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
|
|
@ -121,8 +121,8 @@ pub enum OpCode {
|
|||
/// Close scopes while leaving their expression value around.
|
||||
OpCloseScope(Count), // number of locals to pop
|
||||
|
||||
/// Asserts stack top is a boolean, and true.
|
||||
OpAssert,
|
||||
/// Return an error indicating that an `assert` failed
|
||||
OpAssertFail,
|
||||
|
||||
// Lambdas & closures
|
||||
OpCall,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue