summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-compiler/core/codegen.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-07-23 11:20:18 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-07-23 11:20:18 +0900
commit9c43276eb51d81ed6f62ec1810c944580caebc40 (patch)
treecae160639790800727a206fb9cd38ad5b46e5b67 /mrbgems/mruby-compiler/core/codegen.c
parent598c97ef76771f3b741657ee6807c58b0ca4f393 (diff)
downloadmruby-9c43276eb51d81ed6f62ec1810c944580caebc40.tar.gz
mruby-9c43276eb51d81ed6f62ec1810c944580caebc40.zip
codegen.c: fixed a bug in `OP_LOADI32` peephole optimization.
Diffstat (limited to 'mrbgems/mruby-compiler/core/codegen.c')
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index 4aac984a3..c0d39dcb7 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -488,11 +488,19 @@ 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: case OP_LOADI32:
+ 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;
+ case OP_LOADI32:
+ if (nopeep || data.a != src || data.a < s->nlocals) goto normal;
+ else {
+ uint32_t i = (uint32_t)data.b<<16|data.c;
+ s->pc = s->lastpc;
+ genop_2SS(s, data.insn, dst, i);
+ }
+ break;
default:
goto normal;
}