diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-10-08 12:09:05 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-10-08 12:09:05 +0900 |
| commit | fd6d911b5382283ae375e6ae6256543070469a26 (patch) | |
| tree | ea4422fa718c08441619f60ccf06c034061c04cb /mrbgems/mruby-compiler/core/codegen.c | |
| parent | 7018286453f7d0ba3c6bb0719ef88f0449fbfbce (diff) | |
| download | mruby-fd6d911b5382283ae375e6ae6256543070469a26.tar.gz mruby-fd6d911b5382283ae375e6ae6256543070469a26.zip | |
codegen.c: peephole optimize `OP_MOVE` after `OP_ARRAY` or `OP_HASH`.
When the length operand is zero, we don't need `OP_MOVE` but adjust the
destination operand instead.
Diffstat (limited to 'mrbgems/mruby-compiler/core/codegen.c')
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 5197cc7fe..5d23b2dd4 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -594,6 +594,9 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep) rewind_pc(s); genop_1(s, data.insn, dst); return; + case OP_HASH: case OP_ARRAY: + if (data.b != 0) goto normal; + /* fall through */ case OP_LOADI: case OP_LOADINEG: case OP_LOADL: case OP_LOADSYM: case OP_GETGV: case OP_GETSV: case OP_GETIV: case OP_GETCV: |
