The Magic of Partial Evaluation
60 points by aray07 3 hours ago | 7 comments
owlstuffing 2 hours ago
This type of optimization is also known as compile-time constant expression folding.
replyThe problem with expanding it to include function calls is that it compromises binary compatibility. A code change on a function that results in a different range or has different side effects, will not be realized unless the caller is recompiled.
infogulch 42 minutes ago
Doesn't Zig have a pretty nice implementation of compile-time evaluation built in?
replyjimmyhmiller 4 minutes ago
Comptime in zig is definitely quite cool, but not quite the same.
replyConsider this example. https://jimmyhmiller.com/split-shot/#/vm
Make the code a comptime argument in zig and you get "store to comptime variable depends on runtime condition".
measurablefunc 2 hours ago
Combining this w/ a JIT gets you truffle/graal.
replygrashalm 2 hours ago
If you are curious how this works in Truffle. Here are some docs:
replyhttps://www.graalvm.org/latest/graalvm-as-a-platform/languag...
https://labs.leaningtech.com/blog/reducing-webassembly-size-...