vm: add OP_GETIDX0 for fast array[0] access

Fuses MOVE+LOADI_0+GETIDX pattern into single instruction.
Saves 4 bytes per arr[0] access (7 bytes -> 3 bytes).

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-01-20 12:38:05 +09:00
parent 5475ea573a
commit 51e8da6614
4 changed files with 41 additions and 0 deletions
+1
View File
@@ -48,6 +48,7 @@ OPCODE(SETMCNST, BB) /* R[a+1]::Syms[b] = R[a] */
OPCODE(GETUPVAR, BBB) /* R[a] = uvget(b,c) */
OPCODE(SETUPVAR, BBB) /* uvset(b,c,R[a]) */
OPCODE(GETIDX, B) /* R[a] = R[a][R[a+1]] */
OPCODE(GETIDX0, BB) /* R[a] = R[b][0]; a+1 for method call */
OPCODE(SETIDX, B) /* R[a][R[a+1]] = R[a+2] */
OPCODE(JMP, S) /* pc+=a */
OPCODE(JMPIF, BS) /* if R[a] pc+=b */