jrsonnet
jrsonnet copied to clipboard
WIP: Proper tco optimization
C++ jsonnet does have proper TCO optimization. However, I haven't used this approach since it is hard to maintain in some cases, especially when it is used in most of the code. But now I got an idea: Why not implement a hybrid approach where TCO exists only for the main interpreter loop and not in the rest of the codebase, i.e. builtins? In this PR I explore this possibility, it may also allow for async builtins/std.parallelMap/huge optimizations in recursive functions/better GC root management strategies.
Stack traces and some other things are broken for now, not ready for use.
Why not implement a hybrid approach where TCO exists only for the main interpreter loop and not in the rest of the codebase, i.e. builtins?
Builtins can be implemented too, I.e by utilizing generators/async-await
In cpp-jsonnet, there is a PR to implement manifestification inside of interpreter loop, and it looks like a cool idea https://github.com/google/jsonnet/pull/1142