about summary refs log tree commit diff
path: root/tvix/eval/src/vm.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-09-03T11·52+0300
committertazjin <tazjin@tvl.su>2022-09-08T20·17+0000
commit48d5f4fd573e05410a3b0dfc3bb2a0289e8736b1 (patch)
tree5f3a0683f7d0bd7948ab4ee336b0b7cceca0efd1 /tvix/eval/src/vm.rs
parentd3421c1cb9fc52a583b888e5040ea6d60a4d02ac (diff)
feat(tvix/eval): print lambda memory adresses in disassembler r/4768
This makes it easier to track exactly which lambda is which when
inspecting e.g. the concrete representation of a thunk.

At runtime all lambdas live in an Rc. To make this print the right
address, the construction of these Rcs had to be moved up right to the
point where the lambda is first emitted (and disassembled).

Change-Id: I6070e6c8ac55f0bd697966c4e7c5565c20d19106
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6435
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r--tvix/eval/src/vm.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index 5d26afe3f304..2c490200e1d1 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -173,8 +173,9 @@ impl VM {
     ) -> EvalResult<Value> {
         #[cfg(feature = "disassembler")]
         self.tracer.literal(&format!(
-            "=== entering closure/{} [{}] ===",
+            "=== entering closure/{} @ {:p} [{}] ===",
             arg_count,
+            lambda,
             self.frames.len()
         ));
 
@@ -706,9 +707,9 @@ fn unwrap_or_clone_rc<T: Clone>(rc: Rc<T>) -> T {
     Rc::try_unwrap(rc).unwrap_or_else(|rc| (*rc).clone())
 }
 
-pub fn run_lambda(lambda: Lambda) -> EvalResult<Value> {
+pub fn run_lambda(lambda: Rc<Lambda>) -> EvalResult<Value> {
     let mut vm = VM::default();
-    let value = vm.call(Rc::new(lambda), vec![], 0)?;
+    let value = vm.call(lambda, vec![], 0)?;
     vm.force_for_output(&value)?;
     Ok(value)
 }