You may find this recent LWN discussion, and the article that it links to, interesting - it discusses the state of the art in bytecode interpreters, and some of the ways modern compiler optimisations interact with them. It's complicated!Pedantically: that sort of dynamic dispatch may well be slower than a switch statement as it requires a full function call. With a switch you might get as simple as a jump table — no separate scope so no stack activity whatsoever.
Statistics: Posted by atsampson — Wed Mar 19, 2025 12:28 am