mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
vm: add OP_ADDILV/OP_SUBILV for local variable increment
fuse MOVE+ADDI+MOVE and MOVE+SUBI+MOVE patterns into single instructions. ADDILV/SUBILV add/subtract an immediate to a local variable in-place. BBB format: a=local, b=working space for method call, c=immediate. saves 5 bytes per instance (9->4 bytes), 40 occurrences in stdlib. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -78,6 +78,8 @@ OPCODE(ADD, B) /* R[a] = R[a]+R[a+1] */
|
||||
OPCODE(ADDI, BB) /* R[a] = R[a]+mrb_int(b) */
|
||||
OPCODE(SUB, B) /* R[a] = R[a]-R[a+1] */
|
||||
OPCODE(SUBI, BB) /* R[a] = R[a]-mrb_int(b) */
|
||||
OPCODE(ADDILV, BBB) /* R[a] = R[a]+mrb_int(c); R[b],R[b+1] for method call */
|
||||
OPCODE(SUBILV, BBB) /* R[a] = R[a]-mrb_int(c); R[b],R[b+1] for method call */
|
||||
OPCODE(MUL, B) /* R[a] = R[a]*R[a+1] */
|
||||
OPCODE(DIV, B) /* R[a] = R[a]/R[a+1] */
|
||||
OPCODE(EQ, B) /* R[a] = R[a]==R[a+1] */
|
||||
|
||||
Reference in New Issue
Block a user