diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-08-16 22:37:30 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-08-16 22:37:30 +0900 |
| commit | 0923ff6313d870cc9ae3f09c3710e2b6ffa48edc (patch) | |
| tree | f3d4e2990679a6cdc55d27716165c3a9cbb6b096 /src | |
| parent | 61763129dbbac84e0c9a476ff3c88cc958cd3393 (diff) | |
| download | mruby-0923ff6313d870cc9ae3f09c3710e2b6ffa48edc.tar.gz mruby-0923ff6313d870cc9ae3f09c3710e2b6ffa48edc.zip | |
Optimize bytecode for `Class#new`.
Diffstat (limited to 'src')
| -rw-r--r-- | src/class.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/class.c b/src/class.c index db9bef7b1..e4fda18fc 100644 --- a/src/class.c +++ b/src/class.c @@ -2119,17 +2119,15 @@ inspect_main(mrb_state *mrb, mrb_value mod) static mrb_code new_iseq[] = { OP_ENTER, 0x0, 0x10, 0x1, /* OP_ENTER 0:0:1:0:0:0:1 */ - OP_LOADSELF, 0x4, /* OP_LOADSELF R4 */ - OP_SEND, 0x4, 0x0, 0x0, /* OP_SEND R4 :allocate 0 */ - OP_MOVE, 0x3, 0x4, /* OP_MOVE R0 R3 */ - OP_LOADNIL, 0x5, /* OP_LOADNIL R5 */ - OP_MOVE, 0x6, 0x1, /* OP_MOVE R6 R1 */ - OP_ARYCAT, 0x5, /* OP_ARYCAT R5 */ - OP_MOVE, 0x6, 0x2, /* OP_MOVE R6 R2 */ - OP_SENDVB, 0x4, 0x1, /* OP_SENDVB R4 :initialize */ - OP_RETURN, 0x3 /* OP_RETURN R0 */ + OP_LOADSELF, 0x3, /* OP_LOADSELF R3 */ + OP_SEND, 0x3, 0x0, 0x0, /* OP_SEND R3 :allocate 0 */ + OP_MOVE, 0x0, 0x3, /* OP_MOVE R0 R3 */ + OP_MOVE, 0x4, 0x1, /* OP_MOVE R4 R1 */ + OP_MOVE, 0x5, 0x2, /* OP_MOVE R5 R2 */ + OP_SENDVB, 0x3, 0x1, /* OP_SENDVB R4 :initialize */ + OP_RETURN, 0x0 /* OP_RETURN R0 */ }; - + static void init_class_new(mrb_state *mrb, struct RClass *cls) { @@ -2146,8 +2144,8 @@ init_class_new(mrb_state *mrb, struct RClass *cls) new_irep->flags = MRB_ISEQ_NO_FREE; new_irep->iseq = new_iseq; new_irep->ilen = sizeof(new_iseq); - new_irep->nregs = 7; - new_irep->nlocals = 4; + new_irep->nregs = 6; + new_irep->nlocals = 3; p = mrb_proc_new(mrb, new_irep); MRB_METHOD_FROM_PROC(m, p); mrb_define_method_raw(mrb, cls, mrb_intern_lit(mrb, "new"), m); |
