Get the latest tech news
Implementing an Intermediate Representation for ArkScript
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…).\nExploring new optimizations 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.\n
Having implemented computed gotos a few weeks ago, I think I’ve hit the limit in terms of feasible optimization for this VM. However I didn’t really like this idea, it felt like reinventing the wheel, another tree, as we have a non-flat structure to handle a sequence of conditions(if cond (if cond2 ...)). This way we can add and remove as many instructions as we want, as long as we don’t update a label we can still compute its address later and compile our gotos to absolute jumps without any issues.
Or read this on Hacker News