4 ms·
> Be wary of any references about this that are from before 2013. And now that it is 2021, ignore the pre-2018 numbers. Somewhere in that old thread, I refere
by gopalv 6y ago
> Be wary of any references about this that are from before 2013.
And now that it is 2021, ignore the pre-2018 numbers.
Somewhere in that old thread, I referenced the indirect jump performance hit from the whole Spectre/Meltdown mitigations for any Xeons you might have bought before mid-2020.
There's a nice paper from VMWare on "JumpSwitches" from USENIX '19 that is worth reading in this context.
That suggests that of the five different types of indirect jumps, some are back to being fast again - the one we are dealing with is the search jumpswitch.
I would say direct threaded execution (computed goto) is still worth it over the single dispatch jumps, particularly if you can JIT basic blocks & replace something an "add, mul, add, store" into a single basic block without unloading from registers for the whole operation, jump into that directly with CGOTO like you would do with a compiled chunk of code & build your micro-JIT one opcode at a time.
- rurban 6y agoThe only difference of these two variants is that cgoto skips the switch range check at the beginning. Switch is largely implemented as such a jump table also. Compilers didn't get that smart yet to optimize switch tables to something better, even if it's constant. A vm or jit on the other hand could exploit bitmasks of ops or neighbor frequencies of ops better. LuaJit did that by hand.