[Yarv-devel] expandarray and opcode questions
SASADA Koichi
ko1 at atdot.net
Tue Apr 5 19:17:58 EDT 2005
George Marrows <george.marrows at ntlworld.com> wrote :
[ [Yarv-devel] expandarray and opcode questions ]
at Tue, 05 Apr 2005 21:58:44 +0100
Hi,
> 1. Can you explain the expandarray opcode a bit more please? The
> arguments to expandarray are num, flag. num seems to control how many
> elements to take from an array.
Right.
> -- what does it mean if num is negative?
I can't remember, but is cause when processing massign.
> -- what does flag do?
If flag is true, rest values packed as array.
example:
a, *b = [1, 2, 3]
p [a, b] #=> [1, [2, 3]]
> 2. Can you explain the optimized opcodes a bit - I don't understand
> their names.
>
> getlocal_OP_1
> -- I assume this getlocal with idx set to be 1. OP = 'operand'?
Yes. getlocal_OP_1 means "getlocal with operand 1".
>
> getdynamic_OP__WC__0
> -- what does 'WC' mean?
Wild card. getdynamic_OP__WC__0 means that:
getdynamic instruction with
operand 1 is unknown (given as instruction operand)
operand 2 is 0
If you have more suitable code, please teach me :)
>
> getlocal_SC_xx_ax, _ax_ab, _bx_ba etc
> -- what is SC? 'stack cache'?
Exactly.
> -- what are xx, ax, ab, bx, ba etc??
Stack caching (SC) caches stack top. YARV's SC support 2 level
(2 stack top values) stack caching.
SC_?1_?2 means stack caching state. before instruction dispatched and
after that.
1. A, B and X
X means stack top is not cached.
A means stack top is cached by register A.
B means stack top is cached by register B.
2. XX, AX, BX, AB and BA
XX means stack top is not cached.
AX means stack top is cached by register A.
BX means stack top is cached by register B.
AB means stack top is cached by register B.
stack 2nd value is cached by regsiter A.
BA means stack top is cached by register A.
stack 2nd value is cached by regsiter B.
3. example
getlocal instruction doesn't pop any stack value and push 1
value (local variable).
So any value is not cached (state XX), stack cache state
after dispatch this instruction will be AX.
getlocal_SC_xx_ax means that.
In general, we can't determine stack caching state before dispatch
the instruction, so YARV creates all instructions states for every
instructions.
examle:
nop_SC_xx_xx, nop_SC_ax_ax, nop_SC_bx_bx, nop_SC_ab_ab, nop_SC_ab_ab (no state change)
Regards,
--
// SASADA Koichi at atdot dot net
//
More information about the Yarv-devel
mailing list