3 ms·
Not making a wasm interpreter but using it as the output of $whatever_language you choose abstract interpreter — written in $whatever_ language if you want the
by UncleEntity 4y ago
Not making a wasm interpreter but using it as the output of $whatever_language you choose abstract interpreter — written in $whatever_ language if you want the “free” jit compiler.
It doesn’t need fancy stuff like arrays or objects since it just operates on the sandboxed wasm memory. Probably need some runtime system to deal with memory management &etc but that’s just some extra code tacked onto the module.
If one wanted to get all fancy it would be:
code -> ast -> ir -> optimizer -> partial eval -> wasm
Or just a simple:
code -> ast -> tree walker -> wasm
There’s some pretty good algorithms for the first case where you get pretty close to optimal code without having to leave SSA form I’ve been reading about recently. In fact, I totally forgot about the Futamura transformations until I was reading TFA and was wondering why it wouldn’t work.
—edit—
I guess the first case is just a traditional compiler and it would probably not benefit from partial evaluation because there’s also an efficient algorithm that’s part of the mentioned reading to transform SSA -> AST which could be adapted to wasm output quite easily…which is on my laptop and I’m on my phone so…