feat(tvix/eval): add Evaluation::strict to toggle top-level deepseq

This makes it possible for callers to control whether they can receive
partially evaluated values from an evaluation or not.

We're actually flipping the default behaviour to non-strict top-level
evaluation, which means that callers have to set `strict = true` on
the Evaluation to get the previous behaviour.

Change-Id: Ic048e9ba09c88866d4c3177d5fa07db11c4eb20e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8325
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Vincent Ambo 2023-03-18 00:10:29 +03:00 committed by clbot
parent a5f28eea94
commit ba138712e4
5 changed files with 26 additions and 5 deletions

View file

@ -1190,6 +1190,7 @@ pub fn run_lambda(
observer: &mut dyn RuntimeObserver,
globals: Rc<GlobalsMap>,
lambda: Rc<Lambda>,
strict: bool,
) -> EvalResult<RuntimeResult> {
// Retain the top-level span of the expression in this lambda, as
// synthetic "calls" in deep_force will otherwise not have a span
@ -1207,9 +1208,11 @@ pub fn run_lambda(
root_span.into(),
);
// Synthesise a frame that will instruct the VM to deep-force the final
// value before returning it.
vm.enqueue_generator("final_deep_force", root_span.into(), final_deep_force);
// When evaluating strictly, synthesise a frame that will instruct
// the VM to deep-force the final value before returning it.
if strict {
vm.enqueue_generator("final_deep_force", root_span.into(), final_deep_force);
}
vm.frames.push(Frame::CallFrame {
span: root_span.into(),