summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-25 06:45:05 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-25 06:45:05 (GMT)
commit067066fc9b2c3edf114974082a2172ca8527a4bf (patch)
tree858bc26c290ca7f50d5fe0075a3fdf6cc9d26921 /compile.c
parentb768dc2207d800e1c462fc4367e89b2ae2f5a919 (diff)
compile.c: fix unconditional branch optimization
* compile.c (iseq_peephole_optimize): add dummy `putnil` after a `jump` replacing an unconditional branch, to adjust removed `dup`. [ruby-core:86666] [Bug #14708] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 6a7f0ed..2fadf64 100644
--- a/compile.c
+++ b/compile.c
@@ -2893,6 +2893,10 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
ELEM_INSERT_NEXT(&iobj->link, &pobj->link);
}
if (cond) {
+ if (prev_dup) {
+ pobj = new_insn_core(iseq, pobj->insn_info.line_no, BIN(putnil), 0, NULL);
+ ELEM_INSERT_NEXT(&iobj->link, &pobj->link);
+ }
iobj->insn_id = BIN(jump);
goto again;
}