diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-05 14:23:23 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-05 14:23:23 +0000 |
commit | 43c1eb440a7adedfb3cc1063b63573ade714c76a (patch) | |
tree | 429d5b41acd5419e15b1435cbe9fc8b24d2b15f9 /compile.c | |
parent | 665839dddaa33f733682f5446fce04d457803fda (diff) | |
download | ruby-43c1eb440a7adedfb3cc1063b63573ade714c76a.tar.gz |
compile.c: fix stack consistency error
* compile.c (iseq_peephole_optimize): fix stack consistency error
from return in loop, by adding extra `pop` when replacing `jump`
with `leave`, which is never reached but needed to adjust sp
calculation. [ruby-core:84589] [Bug #14273]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -2476,6 +2476,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal goto again; } else if (IS_INSN_ID(diobj, leave)) { + INSN *pop; /* * jump LABEL * ... @@ -2483,6 +2484,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal * leave * => * leave + * pop * ... * LABEL: * leave @@ -2492,6 +2494,9 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal iobj->insn_id = BIN(leave); iobj->operand_size = 0; iobj->insn_info = diobj->insn_info; + /* adjust stack depth */ + pop = new_insn_body(iseq, diobj->insn_info.line_no, BIN(pop), 0); + ELEM_INSERT_NEXT(&iobj->link, &pop->link); goto again; } else if ((piobj = (INSN *)get_prev_insn(iobj)) != 0 && |