[virtmach] Switch vs. Jump Tables?

Tom Fjellstrom tfjellstrom@home.com
Tue, 14 Nov 2000 11:38:45 -0700


Lars Szuwalski wrote:
> 
> I don't have actual documentation on this, but "swicth's" I have looked at
> all turned in to some sort of jump-tables (VC++ 6.0) when compiled (don't
> know how gcc does it). The reason for this seems straigh forward (to me at
> least): Not only is it faster because of a lower "call/return" overhead, it
> allso makes it easyer (read: possible) for the optimizer to choose which
> variables to put into the machine-registers. This abillity may get lost if
> you do function-pointer-calls (as the compiler/optimizer may not be able to
> figure out what code is actully called at runtime. And even if it can, it
> may be forced to preserve registers (to the stack or the heap) across
> calls - making the call/return even more expensive). As I'm working on a
> simular project myself (allso using a switch) I look forward to hearing more
> about "First VM" and the internals of it :-)

Well CHIP right now is implemented 2 different ways, one big 'switch'
style
execution function and an equally large function using direct threading.

The later way is faster but non protable.

> Best regards!
> 
> Lars Szuwalski
> mnemonics.net

-- 
Tom Fjellstrom
tfjellstrom@home.com
http://strangesoft.net/