diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-07-16 07:55:25 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-07-16 07:55:25 +0900 |
| commit | 70f31d4bb4b251d13c959557552e1c285878f5f3 (patch) | |
| tree | 93ba3ef3647c6b567f078a009a0cbfdccb006c5d /mrbgems/mruby-compiler/core/codegen.c | |
| parent | 1a3564f2f1fce239d7982cd5b3850bfff32222c0 (diff) | |
| download | mruby-70f31d4bb4b251d13c959557552e1c285878f5f3.tar.gz mruby-70f31d4bb4b251d13c959557552e1c285878f5f3.zip | |
codegen.c: add new peephole optimization for `OP_MOVE`.
If `OP_MOVE` comes after `OP_GETUPVAR`, you can skip move and redirect
the destination register of `OP_GETUPVAR`.
Diffstat (limited to 'mrbgems/mruby-compiler/core/codegen.c')
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index fce55999d..f3d6d2d25 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -488,6 +488,11 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep) s->pc = s->lastpc; genop_2(s, data.insn, dst, data.b); break; + case OP_GETUPVAR: + if (nopeep || data.a != src || data.a < s->nlocals) goto normal; + s->pc = s->lastpc; + genop_3(s, data.insn, dst, data.b, data.c); + break; default: goto normal; } |
