mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
vm: add OP_TDEF/OP_SDEF for fused method definition
TDEF fuses TCLASS+METHOD+DEF for normal method definitions. SDEF fuses SCLASS+METHOD+DEF for singleton method definitions. Saves 4 bytes per method definition (8 bytes -> 4 bytes). Falls back to unfused instructions if irep index exceeds 255. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -427,6 +427,12 @@ codedump(mrb_state *mrb, const mrb_irep *irep, FILE *out)
|
||||
CASE(OP_DEF, BB):
|
||||
fprintf(out, "DEF\t\tR%d\t:%s\t(R%d)\n", a, mrb_sym_dump(mrb, irep->syms[b]),a+1);
|
||||
break;
|
||||
CASE(OP_TDEF, BBB):
|
||||
fprintf(out, "TDEF\t\tR%d\t:%s\tI[%d]\n", a, mrb_sym_dump(mrb, irep->syms[b]), c);
|
||||
break;
|
||||
CASE(OP_SDEF, BBB):
|
||||
fprintf(out, "SDEF\t\tR%d\t:%s\tI[%d]\n", a, mrb_sym_dump(mrb, irep->syms[b]), c);
|
||||
break;
|
||||
CASE(OP_UNDEF, B):
|
||||
fprintf(out, "UNDEF\t\t:%s\n", mrb_sym_dump(mrb, irep->syms[a]));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user