about summary refs log tree commit diff
path: root/tvix/eval/src/builtins/mod.rs
diff options
context:
space:
mode:
authorAspen Smith <root@gws.fyi>2024-02-10T17·39-0500
committerclbot <clbot@tvl.fyi>2024-02-13T16·49+0000
commit7e286aab1a573edc9aef16bb68e9907371917adc (patch)
treef3e9aeb1ac674800ed13dbb0bfacddfb50dd372e /tvix/eval/src/builtins/mod.rs
parentdd261773192d0928571f806892d8065fbba1cf2d (diff)
feat(tvix/eval): Box Value::Catchable r/7508
This is now the only enum variant for Value that is larger than 8
bytes (it's 16 bytes), so boxing it (especially since it's not
perf-critical) allows us to get the Value size down to only 16 bytes!

Change-Id: I98598e2b762944448bef982e8ff7da6d6683c4aa
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10798
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Autosubmit: aspen <root@gws.fyi>
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r--tvix/eval/src/builtins/mod.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index d63b035c05..c070bd44b1 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -303,7 +303,7 @@ mod pure_builtins {
                         context = context.join(other_context);
                     }
                 }
-                Err(c) => return Ok(Value::Catchable(c)),
+                Err(c) => return Ok(Value::Catchable(Box::new(c))),
             }
         }
         // FIXME: pass immediately the string res.
@@ -365,7 +365,7 @@ mod pure_builtins {
             {
                 Ok(true) => return Ok(true.into()),
                 Ok(false) => continue,
-                Err(cek) => return Ok(Value::Catchable(cek)),
+                Err(cek) => return Ok(Value::from(cek)),
             }
         }
         Ok(false.into())
@@ -452,7 +452,7 @@ mod pure_builtins {
     #[builtin("toJSON")]
     async fn builtin_to_json(co: GenCo, val: Value) -> Result<Value, ErrorKind> {
         match val.into_json(&co).await? {
-            Err(cek) => Ok(Value::Catchable(cek)),
+            Err(cek) => Ok(Value::from(cek)),
             Ok(json_value) => {
                 let json_str = serde_json::to_string(&json_value)?;
                 Ok(json_str.into())
@@ -471,7 +471,7 @@ mod pure_builtins {
     #[allow(non_snake_case)]
     async fn builtin_filterSource(_co: GenCo, #[lazy] _e: Value) -> Result<Value, ErrorKind> {
         // TODO: implement for nixpkgs compatibility
-        Ok(Value::Catchable(CatchableErrorKind::UnimplementedFeature(
+        Ok(Value::from(CatchableErrorKind::UnimplementedFeature(
             "filterSource".into(),
         )))
     }
@@ -690,7 +690,7 @@ mod pure_builtins {
         _string: Value,
     ) -> Result<Value, ErrorKind> {
         // FIXME: propagate contexts here.
-        Ok(Value::Catchable(CatchableErrorKind::UnimplementedFeature(
+        Ok(Value::from(CatchableErrorKind::UnimplementedFeature(
             "hashString".into(),
         )))
     }
@@ -884,7 +884,7 @@ mod pure_builtins {
     async fn builtin_less_than(co: GenCo, x: Value, y: Value) -> Result<Value, ErrorKind> {
         let span = generators::request_span(&co).await;
         match x.nix_cmp_ordering(y, co, span).await? {
-            Err(cek) => Ok(Value::Catchable(cek)),
+            Err(cek) => Ok(Value::from(cek)),
             Ok(Ordering::Less) => Ok(Value::Bool(true)),
             Ok(_) => Ok(Value::Bool(false)),
         }
@@ -1387,7 +1387,7 @@ mod pure_builtins {
         }
         // TODO(sterni): coerces to string
         // We do not care about the context here explicitly.
-        Ok(Value::Catchable(CatchableErrorKind::Throw(
+        Ok(Value::from(CatchableErrorKind::Throw(
             message.to_contextful_str()?.to_string().into(),
         )))
     }
@@ -1444,7 +1444,7 @@ mod pure_builtins {
         }
 
         match coerce_value_to_path(&co, s).await? {
-            Err(cek) => Ok(Value::Catchable(cek)),
+            Err(cek) => Ok(Value::from(cek)),
             Ok(path) => {
                 let path: Value = crate::value::canon_path(path).into();
                 let span = generators::request_span(&co).await;
@@ -1527,7 +1527,7 @@ pub fn pure_builtins() -> Vec<(&'static str, Value)> {
     // TODO: implement for nixpkgs compatibility
     result.push((
         "__curPos",
-        Value::Catchable(CatchableErrorKind::UnimplementedFeature("__curPos".into())),
+        Value::from(CatchableErrorKind::UnimplementedFeature("__curPos".into())),
     ));
 
     result