4 ms·
Wasm3 calls its interpreter design a "meta machine": https://github.com/wasm3/wasm3/blob/main/docs/Interpreter.md#m3-massey-meta-machine https://github.com/wasm
by haberman 6y ago
Wasm3 calls its interpreter design a "meta machine": https://github.com/wasm3/wasm3/blob/main/docs/Interpreter.md#m3-massey-meta-machine https://github.com/wasm3/wasm3/blob/main/docs/Interpreter.md...
It is heavily based around tail calls. I recently wrote a blog article about how we applied a similar tail-call-oriented strategy to accelerate protobuf parsing to 2+GB/s: https://blog.reverberate.org/2021/04/21/musttail-efficient-interpreters.html https://blog.reverberate.org/2021/04/21/musttail-efficient-i...
I also recently landed a change in Clang trunk that offers guaranteed tail calls, so that this tail call design is safe in non-opt builds: https://reviews.llvm.org/D99517 https://reviews.llvm.org/D99517 I think wasm3 could benefit from using this attribute when it is available.
- glandium 6y agoHow do guaranteed tail calls work when you needs to put arguments on the stack, which usually prevents tail call? (and whether a specific call needs to pass arguments on the stack depends on the platform, and the number and type of arguments)
- haberman 6y agoThe musttail attribute performs several checks to ensure that a tail call can be guaranteed, and rejects the program if these rules are violated. The documentation has the details: https://github.com/llvm/llvm-project/blob/3b8ec86fd576b9808dc63da620d9a4f7bbe04372/clang/include/clang/Basic/AttrDocs.td#L449-L468 https://github.com/llvm/llvm-project/blob/3b8ec86fd576b9808d... These rules guarantee that the tail call is possible to perform on every platform. They end up being more strict than is necessary on some platforms and calling conventions.