Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Computed Goto ≈ Function Pointers?

Name: Anonymous 2013-02-17 19:15

I'm thinking of writing a simple "bytecode" interpreter in C. I'm tempted to use the GNU C extension that provides labels as values/"computed goto" for the main interpreter loop as a nice speedup over a naive switch implementation1, but in the interest of portability, I'd rather not use that extension, even if it is apparently well supported by GCC, ICC, and Clang.

If instead wrote the interpreter as a collection of functions that modify a state data structure defined in the same source file, and performed dispatch with a table of pointers to those functions, could I expect similar performance characteristics (or even identical compiler output) when compared to the "computed goto" implementation?

And of course, before anyone assumes uncharitable things about me, I'm well aware that both implementations should ``compile down to'' a jump table. The question is whether C compilers are smart enough to optimize the function pointer table implementation that way.

1 http://eli.thegreenplace.net/2012/07/12/computed-goto-for-efficient-dispatch-tables/

Name: Anonymous 2013-02-19 12:56

>>13
google and mozilla, geniuses
much better designed javascript
lua is a dead language
IHBT.
He makes a lot more money than you do from corporate sponsorships towards his open source dynamic language implementation.

Why don't you go back to /proggit/ and brag to your dudebros there about slinging SCALABLE node.js picture galleries there, Lua troll?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List