[virtmach] Your VM

virtmach@iecc.com virtmach@iecc.com
Wed, 30 May 2001 12:46:01 +0100


> Now I have a question: does any one know for sure
> if an array of function pointers is faster than
> a switch case? I know threaded code is faster but
> is an function pointer array? (will it help the
> cpu cache enough to make a difference?)

apart from speed considerations, i recently came across a useful reason
for implementing as an array of function pointers rather than a switch
statement: the core execution loop is very small, so it's possible to
have alternative execution loops for very little cost.

the Inferno VM uses this to implement single-step/breakpoint debugging
- a process being debugged uses an alternative core execution function;
others use the usual one (which is only 22 lines of code).

so not only is the code prettier, it's also substantially more
versatile.

  cheers,
    rog.