diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-28T14·28+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-06T14·58+0000 |
commit | 025a9a4a0a66c8593cd6b7e4b0f0fa7aea84c353 (patch) | |
tree | e7a6921ebafcdd65c87394f58e9c1614f65eb79c /tvix/eval/src/vm.rs | |
parent | 1bfe32f4129a1c8627a254fe0fefe18d15339d83 (diff) |
feat(tvix/eval): implement OpFinalise instruction r/4667
This instruction finalises the initialisation of deferred upvalues in closures (and soon, thunks). The compiler does not yet emit this instruction, some more accounting is needed for that. Change-Id: Ic4181b26e19779e206f51e17388559400da5f93a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6337 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r-- | tvix/eval/src/vm.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index d4eb0657251a..1aaba9b0573e 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -435,6 +435,19 @@ impl VM { } } + OpCode::OpFinalise(StackIdx(idx)) => { + match &self.stack[self.frame().stack_offset + idx] { + Value::Closure(closure) => closure + .resolve_deferred_upvalues(&self.stack[self.frame().stack_offset..]), + + v => { + #[cfg(feature = "disassembler")] + drop(tracer); + panic!("compiler error: invalid finaliser value: {}", v); + } + } + } + // Data-carrying operands should never be executed, // that is a critical error in the VM. OpCode::DataLocalIdx(_) |