about summary refs log tree commit diff
path: root/tvix/eval/src/vm
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2023-03-12T21·30+0300
committerclbot <clbot@tvl.fyi>2023-03-17T19·31+0000
commit3fa6b13c1e8cbd7a007365dbac0ffc30d03d8472 (patch)
tree5aa4b1692bc71730408dae780b172b777e4bf815 /tvix/eval/src/vm
parent5095e4f2696ef85ee7c6ae0515eb8d1586459f8c (diff)
feat(tvix/eval): track span of first force in a thunk blackhole r/6025
This is step 1 towards being able to use all 4 spans that we know when
dealing with infinite recursion. It tracks the span at which the
force of a thunk was first requested when constructing a blackhole, so
that we can highlight the spans of the first and second forces.

These are actually the least relevant spans, but the easiest to put in
place, more coming soon.

Change-Id: I4c7e82f6211b98756439d4148a4191457cc46807
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8269
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/eval/src/vm')
-rw-r--r--tvix/eval/src/vm/generators.rs16
-rw-r--r--tvix/eval/src/vm/mod.rs5
2 files changed, 16 insertions, 5 deletions
diff --git a/tvix/eval/src/vm/generators.rs b/tvix/eval/src/vm/generators.rs
index 853ab063465f..b7d8f7aeb5c5 100644
--- a/tvix/eval/src/vm/generators.rs
+++ b/tvix/eval/src/vm/generators.rs
@@ -293,7 +293,9 @@ impl<'o> VM<'o> {
                         // back to the outer VM loop.
                         VMRequest::ForceValue(value) => {
                             self.reenqueue_generator(name, span.clone(), generator);
-                            self.enqueue_generator("force", span, |co| value.force(co));
+                            self.enqueue_generator("force", span.clone(), |co| {
+                                value.force(co, span)
+                            });
                             return Ok(false);
                         }
 
@@ -313,7 +315,9 @@ impl<'o> VM<'o> {
                             self.reenqueue_generator(name, span.clone(), generator);
 
                             let value = self.stack[self.with_stack[idx]].clone();
-                            self.enqueue_generator("force", span, |co| value.force(co));
+                            self.enqueue_generator("force", span.clone(), |co| {
+                                value.force(co, span)
+                            });
 
                             return Ok(false);
                         }
@@ -328,7 +332,9 @@ impl<'o> VM<'o> {
                                 .expect("Tvix bug: generator requested captured with-value, but there is no call frame");
 
                             let value = call_frame.upvalues.with_stack().unwrap()[idx].clone();
-                            self.enqueue_generator("force", span, |co| value.force(co));
+                            self.enqueue_generator("force", span.clone(), |co| {
+                                value.force(co, span)
+                            });
 
                             return Ok(false);
                         }
@@ -441,7 +447,9 @@ impl<'o> VM<'o> {
                                 "generator should be reenqueued with the same frame ID"
                             );
 
-                            self.enqueue_generator("force", span, |co| value.force(co));
+                            self.enqueue_generator("force", span.clone(), |co| {
+                                value.force(co, span)
+                            });
                             return Ok(false);
                         }
 
diff --git a/tvix/eval/src/vm/mod.rs b/tvix/eval/src/vm/mod.rs
index 450d950b34a6..0fb1f9cd8cc9 100644
--- a/tvix/eval/src/vm/mod.rs
+++ b/tvix/eval/src/vm/mod.rs
@@ -483,7 +483,10 @@ impl<'o> VM<'o> {
                         let gen_span = frame.current_light_span();
 
                         self.push_call_frame(span, frame);
-                        self.enqueue_generator("force", gen_span, |co| thunk.force(co));
+                        self.enqueue_generator("force", gen_span.clone(), |co| {
+                            thunk.force(co, gen_span)
+                        });
+
                         return Ok(false);
                     }
                 }