Ok, I think I’ve realised the best way to take advantage of asm.js with a JS terp: use it only for acceleration-safe functions. If I do that then I don’t need to worry about storing locals in a memory buffer, and the stack can start empty when first calling an accelerated function. I was already planning to recompile accelerated functions when the VM is inactive, so now they can just be recompiled using asm.js’s semantics.
This would leave a lot of functions not using asm.js, but hopefully it would speed up enough of the core functions. It’s worth a try at least.