about summary refs log tree commit diff
path: root/tvix/eval/src/vm.rs
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2022-11-23T08·34-0800
committerclbot <clbot@tvl.fyi>2022-11-23T13·02+0000
commita740653c83436e3adc14343efa82422eb0a44933 (patch)
tree685fd9550b9ac0caf5330f95a801b93de92a3d96 /tvix/eval/src/vm.rs
parentc537cc6fcee5f5cde4b0e6f8c5d6dcd5d8e3690f (diff)
feat(tvix/eval): make NixList::clone() cheap r/5301
When we start unrecursivifying (sp?) things, Rust's borrow checker
is going to be a headache; its magic only works when you use the CPU
stack as your call stack.

Fixing the borrow checker issues usually involves adding lots of
`clone()`s.  Right now `NixList` is the only variant of `Value` that
isn't cheap to clone() -- all the others are either a wrapper around
Rc or else are of bounded size.

Note that this requires dropping the `DerefMut for NixList` instance
and using `Vec<Value>` instead in those situations.

Change-Id: I5a47df66855342aa2064f8f3cb7934ff422d26bd
Signed-off-by: Adam Joseph <adam@westernsemico.com>
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7359
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r--tvix/eval/src/vm.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index 17a7e0ce2758..400d85adac30 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -538,8 +538,9 @@ impl<'o> VM<'o> {
 
             OpCode::OpConcat => {
                 let rhs = fallible!(self, self.pop().to_list());
-                let lhs = fallible!(self, self.pop().to_list());
-                self.push(Value::List(lhs.concat(&rhs)))
+                let mut lhs = fallible!(self, self.pop().to_list()).into_vec();
+                lhs.extend_from_slice(&rhs);
+                self.push(Value::List(NixList::from(lhs)))
             }
 
             OpCode::OpInterpolate(Count(count)) => self.run_interpolate(count)?,