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 <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-09-03 14:52:24 +03:00 committed by tazjin
parent d3421c1cb9
commit 48d5f4fd57
4 changed files with 30 additions and 32 deletions

View file

@ -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)
}