about summary refs log tree commit diff
path: root/tvix/eval/src/value
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-09-02T18·49+0300
committertazjin <tazjin@tvl.su>2022-09-08T12·53+0000
commit2246a31e726762ea741a299f598c7878fa66dd83 (patch)
treea3d44e78f5f6cef449c0bb5247cc82dd62fffaa1 /tvix/eval/src/value
parentcc526a2c873524faa83cad62bde2edda59ea7820 (diff)
refactor(tvix/eval): return call frame result from VM::call r/4748
Previously, "calling" (setting up the VM run loop for executing a call
frame) and "running" (running this loop to completion) were separate
operations.

This was basically an attempt to avoid nesting `VM::run` invocations.
However, doing things this way introduced some tricky bugs for exiting
out of the call frames of thunks vs. builtins & closures.

For now, we unify the two operations and always return the value to
the caller directly. For now this makes calls a little less effective,
but it gives us a chance to nail down some other strange behaviours
and then re-optimise this afterwards.

To make sure we tackle this again further down I've added it to the
list of known possible optimisations.

Change-Id: I96828ab6a628136e0bac1bf03555faa4e6b74ece
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6415
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/value')
-rw-r--r--tvix/eval/src/value/thunk.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs
index 4fd41689c7..59fe55cec9 100644
--- a/tvix/eval/src/value/thunk.rs
+++ b/tvix/eval/src/value/thunk.rs
@@ -84,9 +84,9 @@ impl Thunk {
                     if let ThunkRepr::Suspended { lambda, upvalues } =
                         std::mem::replace(&mut *thunk_mut, ThunkRepr::Blackhole)
                     {
-                        vm.call(lambda, upvalues, 0);
                         *thunk_mut = ThunkRepr::Evaluated(
-                            vm.run().map_err(|e| ErrorKind::ThunkForce(Box::new(e)))?,
+                            vm.call(lambda, upvalues, 0)
+                                .map_err(|e| ErrorKind::ThunkForce(Box::new(e)))?,
                         );
                     }
                 }