[virtmach] Re: Test, Hello

Manoj Plakal plakal@cs.wisc.edu
Wed, 19 Apr 2000 04:03:53 -0500


thaddaeus.frogley@creaturelabs.com wrote (Wed, Apr 19, 2000 at 09:56:45AM +0100) :
> encoding, but I don't think it would be fast enough.  My current plan is to
> have a look up table for the op-code implementations, something like this:
> 
> 	while (pc!=end){
> 		//...
> 		instruction = *pc;
> 		(fnLookup[instruction.opcode])();
> 		// ...
> 	}

	Assuming the instruction dispatch becomes the bottleneck
	in your VM's execution, you could do the standard threaded
	code optimizations:
	   - replace the static opcodes with the results of the
	     table lookup and then call *pc
	   - instead of coming back to the dispatch loop every
	     time, have each instruction implementation function
	     jump directly to the next instruction's implementation
	     (e.g., using gcc allows taking address of labels and
	     then indirecting through these pointers)

	Manoj