feat(tvix/eval): give generators human-readable names

This adds static strings to generator frames that describe the
generator in a human-readable fashion, which are then logged in
observers.

This makes runtime traces very precise, explaining exactly what is
being requested from where.

Change-Id: I695659a6bd0b7b0bdee75bc8049651f62b150e0c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8206
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
Vincent Ambo 2023-03-04 00:52:37 +03:00 committed by tazjin
parent dfd0066de5
commit 1e37f8b52e
5 changed files with 84 additions and 55 deletions

View file

@ -41,7 +41,7 @@ pub enum BuiltinResult {
Partial(Builtin),
/// Builtin was called and constructed a generator that the VM must run.
Called(Generator),
Called(&'static str, Generator),
}
/// Represents a single built-in function which directly executes Rust
@ -105,7 +105,7 @@ impl Builtin {
/// applied or return the builtin if it is partially applied.
pub fn call(self) -> BuiltinResult {
if self.0.partials.len() == self.0.arg_count {
BuiltinResult::Called((self.0.func)(self.0.partials))
BuiltinResult::Called(self.0.name, (self.0.func)(self.0.partials))
} else {
BuiltinResult::Partial(self)
}