The Magic of Partial Evaluation

(jimmyhmiller.com)

55 points | by aray07 2 hours ago

4 comments

  • apignotti 39 minutes ago
    We implemented a similar concept in our C++ -> JavaScript/WebAssembly compiler (Cheerp) several years ago. It was a nice challenge.

    https://labs.leaningtech.com/blog/reducing-webassembly-size-...

  • owlstuffing 48 minutes ago
    This type of optimization is also known as compile-time constant expression folding.

    The 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 26 minutes ago
    Doesn't Zig have a pretty nice implementation of compile-time evaluation built in?
  • measurablefunc 1 hour ago
    Combining this w/ a JIT gets you truffle/graal.