> There's no reason why you can.t have a hybrid scheme. In fact I think
> it's a big win over a pure register-addressing scheme. Consider...

The hybrid scheme may be a win in some cases, but I am not sure if it
worth the complexity. I personally prefer a strict RISC style opcodes,
mainly load, store, and ops for common operators (+, -, * etc), plus
escaped opcode for complicated operators and functions.

> Consider the following code.
> 
> $a = $x*$y+$z
> 
> Suppose we have r5 and r6 available for scratch use, and that for some
> reason we wish to keep a pointer to $a in r1 at the end 
> (perhaps we use $a again a couple of lines later):
> 
> 
> This might have the following bytecode with a pure resiger scheme:
> 
> GETSV('x',r5) # get pointer to global $x, store in register 5
> GETSV('y',r6)
> MULT(r5,r5,r6)  # multiply the things pointed to by r5 and 
> r6; store ptr to
>               # result in r5
> GETSV('z',r6)
> ADD(r5,r5,r6)
> GETSV('a',r1)
> SASSIGN(r1,r5)

Please note most of common operations will deal with locals, not
globals. Since almost all locals will fit into register set, the
generated bytecode will be very small and very fast.

The global access is doomed to be slower than locals, especailly
considering the synchronization overhead associated with threading.

Hong

Reply via email to