Tailcall VM #552
Replies: 2 comments 4 replies
|
We've looked into this a little bit and it doesn't seem to work for complex code, because [IIRC] clang compiles functions that aren't leaf to have an actual stack frame. For Luau most opcodes have a metatable-based slow path or a type-based error paths, and so most functions would likely end up wasting time on this. Additionally, this is clang-specific and would require forking the VM code, whereas computed gotos are simple to support in parallel with portable switch-based code. OTOH all three modern compilers mostly succeed in keeping the 4-5 elements of our state in registers, so I'm surprised it's a problem for Forth VM. |
|
Stumbled upon this discussion and I wanted to note that we did try out a full tailcall implementation of Luau interpreter in December of 2025 and it ended up being a net loss on performance for us. |
Uh oh!
There was an error while loading. Please reload this page.
Hi! Has there been any research on implementing the VM using tailcalls? Clang has had [clang::musttail] attribute for some time. A friend of mine who is into high speed (Forth) interpreters says he's getting a major speed up over computed gotos by using tailcalls. The theory is that a tailcall VM can keep important state (pc, data and return stacks in Forth's case) more likely in CPU registers because the calling convention enforces this. Of course a Forth interpreter is a much more primal beast, so I'm not sure if the same applies to Luau.
All reactions