4 ms·
> Alas, the fastest [dispatching] solutions require either non-standard extensions to C, or hand-written assembly code. I assume gcc's label addresses[0]. I'v
by UncleEntity 9y ago
> Alas, the fastest [dispatching] solutions require either non-standard extensions to C, or hand-written assembly code.
I assume gcc's label addresses[0].
I've been planning to try those out the next time I get around to playing with minischeme to see just how much of a speed difference they make -- I'd imagine quite a bit since it could just hop around from opcode to opcode instead of having to go through the loop (which I believe is outside the dispatching function).
It's funny, searched the google to see if clang supported this and the top result (from stackoverflow) has the comment "This is terrible coding style. Why don't you use a switch or a function table. If you really want such code, you should goto 70ies/80ies BASIC."
[0]https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
- chubot 9y agoI cited a paper here that says this is of limited value on modern Intel CPUs: https://news.ycombinator.com/item?id=16777564 https://news.ycombinator.com/item?id=16777564 Although I think they are overgeneralizing the results... you probably still want it for other architectures.
- munificent 9y ago> I assume gcc's label addresses[0]. Yes, that's definitely the main one I had in mind. > I've been planning to try those out the next time I get around to playing with minischeme to see just how much of a speed difference they make I added support for computed gotos to my bytecode interpreter for Wren and, if I recall, it gave about a 10% speed boost on my (mostly micro-) benchmarks. YMMV. https://github.com/munificent/wren/blob/master/src/vm/wren_vm.c#L815 https://github.com/munificent/wren/blob/master/src/vm/wren_v...