Implementing an Intermediate Representation for ArkScript

submited by
Style Pass
2024-10-19 10:30:03

ArkScript is a scripting language, running on a VM. To accomplish this, we had (as of September 2024) a compiler generating bytecode for the virtual machine, receiving an AST from the parser (and a few other passes like name resolution, macro evaluation, name and scope resolution…).

The only thing we could optimize was the virtual machine and the memory layout of our values, and some very little things directly in the compiler, like tail call optimization. Having implemented computed gotos a few weeks ago, I think I’ve hit the limit in terms of feasible optimization for this VM.

For a while, a friend tried to push me toward making an intermediate representation for ArkScript. I shrugged it off, saying it was too much work, not really knowing what I would get into and having bigger fish to fry.

At the end of September, I stumbled upon a post by Eniko on Mastodon (if you don’t follow her already, what are you waiting for?), and the idea of making an IR came back into my mind… and I just started thinking about, but seriously this time.

Leave a Comment