3 ms·
Huh -- when I read this: > This pattern is hard to achieve in practice in a high level language, although you might have luck emulating it with gcc’s labels as
by mr_luc 7y ago
Huh -- when I read this:
> This pattern is hard to achieve in practice in a high level language, although you might have luck emulating it with gcc’s labels as values functionality.
it sounded familiar, and immediately made me wonder if it's the same as the 'direct threading' technique used in the BEAM VM under the hood that uses that gcc extension -- it sounds like it is, if I'm reading this right:
https://blog.stenmans.org/theBeamBook/#_dispatch_directly_threaded_code https://blog.stenmans.org/theBeamBook/#_dispatch_directly_th...
(A language based more or less on embracing context switches is of course funny company for an article about performance speed limits)
- caf 7y agoThis is using the same GCC functionality, but for a different purpose. The emulator is using it to replace a loop which selects one of several bodies on each iteration, with a direct jump from the body of the previous iteration to the correct body for the next iteration. This article is suggesting using it to replace a call/return pair to a leaf function with what essentially amounts to a single-entry call stack (or a manually implemented link register).