From 09336c5d49481d56587f6e28924014954b4c8dd2 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 3 Oct 2021 17:14:00 +0900 Subject: mruby/ops.h: add new instructions `OP_GETIDX` and `OP_SETIDX`. Which represent `obj[int]` and `obj[int]=val` respectively where `obj` is either `string`, `array` or `hash`, so that index access could be faster. When `obj` is not assumed type or `R(a+1)` is not integer, the instructions fallback to method calls. --- src/codedump.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/codedump.c') diff --git a/src/codedump.c b/src/codedump.c index 431771ca9..df88b37fc 100644 --- a/src/codedump.c +++ b/src/codedump.c @@ -265,6 +265,12 @@ codedump(mrb_state *mrb, const mrb_irep *irep) printf("OP_SETCV\t%s\tR%d\t", mrb_sym_dump(mrb, irep->syms[b]), a); print_lv_a(mrb, irep, a); break; + CASE(OP_GETIDX, B): + printf("OP_GETIDX\tR%d\tR%d\n", a, a+1); + break; + CASE(OP_SETIDX, B): + printf("OP_SETIDX\tR%d\tR%d\tR%d\n", a, a+1, a+2); + break; CASE(OP_JMP, S): i = pc - irep->iseq; printf("OP_JMP\t\t%03d\n", (int)i+(int16_t)a); -- cgit v1.2.3