From 48d5f4fd573e05410a3b0dfc3bb2a0289e8736b1 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 3 Sep 2022 14:52:24 +0300 Subject: feat(tvix/eval): print lambda memory adresses in disassembler 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 Tested-by: BuildkiteCI --- tvix/eval/src/vm.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tvix/eval/src/vm.rs') diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index 5d26afe3f3..2c490200e1 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -173,8 +173,9 @@ impl VM { ) -> EvalResult { #[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(rc: Rc) -> T { Rc::try_unwrap(rc).unwrap_or_else(|rc| (*rc).clone()) } -pub fn run_lambda(lambda: Lambda) -> EvalResult { +pub fn run_lambda(lambda: Rc) -> EvalResult { 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) } -- cgit 1.4.1