feat(tvix/eval): Box Value::Catchable

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>
This commit is contained in:
Aspen Smith 2024-02-10 12:39:24 -05:00 committed by clbot
parent dd26177319
commit 7e286aab1a
11 changed files with 45 additions and 40 deletions

View file

@ -609,7 +609,7 @@ pub async fn request_string_coerce(
match val {
Value::String(s) => Ok(*s),
_ => match co.yield_(VMRequest::StringCoerce(val, kind)).await {
VMResponse::Value(Value::Catchable(c)) => Err(c),
VMResponse::Value(Value::Catchable(c)) => Err(*c),
VMResponse::Value(value) => Ok(value
.to_contextful_str()
.expect("coerce_to_string always returns a string")),
@ -644,7 +644,7 @@ pub(crate) async fn check_equality(
.await
{
VMResponse::Value(Value::Bool(b)) => Ok(Ok(b)),
VMResponse::Value(Value::Catchable(cek)) => Ok(Err(cek)),
VMResponse::Value(Value::Catchable(cek)) => Ok(Err(*cek)),
msg => panic!(
"Tvix bug: VM responded with incorrect generator message: {}",
msg
@ -776,7 +776,7 @@ pub(crate) async fn request_to_json(
) -> Result<serde_json::Value, CatchableErrorKind> {
match co.yield_(VMRequest::ToJson(value)).await {
VMResponse::Value(Value::Json(json)) => Ok(*json),
VMResponse::Value(Value::Catchable(cek)) => Err(cek),
VMResponse::Value(Value::Catchable(cek)) => Err(*cek),
msg => panic!(
"Tvix bug: VM responded with incorrect generator message: {}",
msg