News for hackers. Stuff that matters.
Re:We need to seriously think about what to do with C++ modules by lenkite on Monday September 01, 2025 @03:05AM (#45090241)
Rust doesn't have computed goto (gcc/clang extension heavily used in interpreters like CPython and LuaJIT for direct threading).

You’re forced into function-call or jump-table dispatch, which tends to be slower.

Re:We need to seriously think about what to do with C++ modules by ozars on Monday September 01, 2025 @04:08AM (#45090627)
huh. I had no idea. Fair.
Re:We need to seriously think about what to do with C++ modules by aw1621107 on Monday September 01, 2025 @04:57AM (#45090883)
> Rust doesn't have computed goto (gcc/clang extension heavily used in interpreters like CPython and LuaJIT for direct threading).

On the other hand, there's the recently-added-to-nightly `become` for guaranteed tail calls, which might work better than computed gotos if CPython is a good example [0]

> When using both attributes [[[clang::musttail]] and preserve_none], Jin's new tail-call-based interpreter inherits the nice performance benefits of the computed-goto-based version, while also making it easier for the compiler to figure out optimal register allocations and other local optimizations.

To be fair I don't think Rust has a preserve_none equivalent yet, but given naked functions are a thing in Rust I'd hope it isn't too bad to support?

[0]: https://lwn.net/Articles/1010905/