At 11:17 AM 9/5/2001 -0700, Hong Zhang wrote:
>Howerver, I like to point out one hidden overhead of register opcode is
>decoding the parameter. The add instrction of stack machine does not have
>args, but for register machine, it has 3 arguments.
I skipped the decoding step in the machine design on purpose. Each opcode
sort of does its own decoding. The way it works is you get an instruction
stream that looks like:
1
0
1000
for "integer_store constant 1000 in register I0". The integer_store
function gets a pointer to the start of the instruction (1 in this case)
and looks like:
IV *int_store(IV *opstream, Perl_Interp interpreter) {
interpreter->int_regs[opstream[1]] = opstream[2];
return opstream + 3;
}
more or less. (It's not quite a cut'n'paste from the current parrot source,
but close, after macro substitution)
There's still more dereferencing going on than I'd like, but at least we
only have a single write (to the register) not a pair (the stack top and
the stack pointer) and we don't have to check the stack pointer to make
sure we're not extending past the end of our stack.
Fewer writes, fewer branches, and higher instruction density is where the
register-based system should buy us a win. If anyone wants to cobble
together a simple stack machine we can compare against, that'd be fine.
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk