diff options
Diffstat (limited to 'tvix/eval/src/compiler')
-rw-r--r-- | tvix/eval/src/compiler/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 60f5666ea9ce..0fa3d4139308 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -1457,6 +1457,15 @@ impl Compiler<'_> { } fn emit_force<N: ToSpan>(&mut self, node: &N) { + if let Some(&OpCode::OpConstant(c)) = self.chunk().last_op() { + if !self.chunk().get_constant(c).unwrap().is_thunk() { + // Optimization: Don't emit a force op for non-thunk constants, since they don't + // need one! + // TODO: this is probably doable for more ops (?) + return; + } + } + self.push_op(OpCode::OpForce, node); } |