Tailcall VM #552
petrihakkinen
started this conversation in
Ideas
Tailcall VM
#552
Replies: 1 comment 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. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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.
Beta Was this translation helpful? Give feedback.
All reactions