summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorwanabe <s.wanabe@gmail.com>2020-08-08 08:37:52 +0900
committerwanabe <s.wanabe@gmail.com>2020-10-16 08:37:04 +0900
commitce7a053475cbebfb2f3e5ed6614e0ba631541917 (patch)
treeb72b49eb34ca341c2cff023f205d80379e62c3a4 /compile.c
parentb68c22b3c6a80ebf96d446348bc8007b8a10f694 (diff)
Adjust sp for `x = false; y = (return until x unless x)` [Bug #16695]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3445
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/compile.c b/compile.c
index 6aca1230af..015cbc7333 100644
--- a/compile.c
+++ b/compile.c
@@ -2855,7 +2855,6 @@ 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
* ...
@@ -2863,7 +2862,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
* leave
* =>
* leave
- * pop
* ...
* LABEL:
* leave
@@ -2873,9 +2871,6 @@ 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 (IS_INSN(iobj->link.prev) &&
@@ -5382,6 +5377,9 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
branches);
end_label = NEW_LABEL(line);
ADD_INSNL(then_seq, line, jump, end_label);
+ if (!popped) {
+ ADD_INSN(then_seq, line, pop);
+ }
}
ADD_SEQ(ret, then_seq);
}