about summary refs log tree commit diff
path: root/tvix/eval
diff options
context:
space:
mode:
authorMatthew Tromp <matthewktromp@gmail.com>2024-07-27T22·15-0400
committerclbot <clbot@tvl.fyi>2024-07-27T22·37+0000
commit038d1dd5519647c7da75e352b7a6bd284f71ad8b (patch)
tree0560136f01f1942d6d9eade1d358902e333cb26f /tvix/eval
parentf3c80c10b95b73ce4f9b334e3a9f2be128007fae (diff)
feat(tvix/eval): ConstantIdx expansion for more ops r/8418
Previously, OpConstant would display some detail about its
ConstantIdx: whether it's a thunk or closure, and what its address
is. This has been expanded to also show when the ConstantIdx is a
blueprint, along with the blueprint's address, and to the other
opcodes that use a ConstantIdx.

Currently, it seems like blueprint addresses don't correspond to the
address of the thunk listed in the bytecode output, but it's still
useful to see that the constant being grabbed is a blueprint, and
maybe this pointer can be made to make more sense in the future.

Change-Id: Ia212b0d52b004c87051542c093274e7106ee08e4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12044
Tested-by: BuildkiteCI
Reviewed-by: aspen <root@gws.fyi>
Autosubmit: chickadee <matthewktromp@gmail.com>
Diffstat (limited to 'tvix/eval')
-rw-r--r--tvix/eval/src/chunk.rs26
1 files changed, 19 insertions, 7 deletions
diff --git a/tvix/eval/src/chunk.rs b/tvix/eval/src/chunk.rs
index f1a35a6ce162..95659cffa58f 100644
--- a/tvix/eval/src/chunk.rs
+++ b/tvix/eval/src/chunk.rs
@@ -155,15 +155,27 @@ impl Chunk {
             write!(writer, "{:4}\t", line)?;
         }
 
+        let a = |idx| {
+            match &self[idx] {
+                Value::Thunk(t) => t.debug_repr(),
+                Value::Closure(c) => format!("closure({:p})", c.lambda),
+                Value::Blueprint(b) => format!("blueprint({:p})", b),
+                val => format!("{}", val),
+            }
+        };
+
         match self[idx] {
             OpCode::OpConstant(idx) => {
-                let val_str = match &self[idx] {
-                    Value::Thunk(t) => t.debug_repr(),
-                    Value::Closure(c) => format!("closure({:p})", c.lambda),
-                    val => format!("{}", val),
-                };
-
-                writeln!(writer, "OpConstant({}@{})", val_str, idx.0)
+                writeln!(writer, "OpConstant({}@{})", a(idx), idx.0)
+            }
+            OpCode::OpClosure(idx) => {
+                writeln!(writer, "OpClosure({}@{})", a(idx), idx.0)
+            }
+            OpCode::OpThunkClosure(idx) => {
+                writeln!(writer, "OpThunkClosure({}@{})", a(idx), idx.0)
+            }
+            OpCode::OpThunkSuspended(idx) => {
+                writeln!(writer, "OpThunkSuspended({}@{})", a(idx), idx.0)
             }
             op => writeln!(writer, "{:?}", op),
         }?;