mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-compiler (gen_move): avoid optimization of ADDI/SUBI
ADDI/SUBI may fall back to method call that may clear block argument place holder, which may be a live register. So we cannot directly call ADDI/SUBI over local variables.
This commit is contained in:
@@ -663,8 +663,7 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep)
|
||||
if (addr_pc(s, data.addr) == s->lastlabel || data.a != src || data.a < s->nlocals) goto normal;
|
||||
else {
|
||||
struct mrb_insn_data data0 = mrb_decode_insn(mrb_prev_pc(s, data.addr));
|
||||
if (data0.insn != OP_MOVE || data0.a != data.a || data0.b != dst) goto normal;
|
||||
s->pc = addr_pc(s, data0.addr);
|
||||
if (data0.insn != OP_MOVE || data0.a != data.a || data0.b != dst) break;
|
||||
if (addr_pc(s, data0.addr) != s->lastlabel) {
|
||||
/* constant folding */
|
||||
data0 = mrb_decode_insn(mrb_prev_pc(s, data0.addr));
|
||||
@@ -679,13 +678,12 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep)
|
||||
}
|
||||
}
|
||||
}
|
||||
genop_2(s, data.insn, dst, data.b);
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
normal:
|
||||
|
||||
genop_2(s, OP_MOVE, dst, src);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user