1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Revert r63383, r63248 "compile.c: copy a short insn with leave"

When copying `leave` insn, TRACE also should be copied if it is
present, but this optimization is trivial and not worth the
complexity.  [ruby-core:91366] [Bug #15578]

4cae5353c0
5afd479de6

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2019-02-01 05:11:08 +00:00
parent e826b7d39e
commit 1bc6c3f407
3 changed files with 18 additions and 17 deletions

View file

@ -2709,7 +2709,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
optimize_checktype(iseq, iobj);
if (IS_INSN_ID(iobj, jump)) {
INSN *niobj, *diobj, *piobj, *dniobj;
INSN *niobj, *diobj, *piobj;
diobj = (INSN *)get_destination_insn(iobj);
niobj = (INSN *)get_next_insn(iobj);
@ -2740,11 +2740,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
remove_unreachable_chunk(iseq, iobj->link.next);
goto again;
}
else if (dniobj = 0,
IS_INSN_ID(diobj, leave) ||
(diobj->operand_size == 0 &&
(dniobj = (INSN *)get_next_insn(diobj)) != 0 &&
(IS_INSN_ID(dniobj, leave) || (dniobj = 0)))) {
else if (IS_INSN_ID(diobj, leave)) {
INSN *pop;
/*
* jump LABEL
@ -2760,19 +2756,12 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
*/
/* replace */
unref_destination(iobj, 0);
iobj->insn_id = diobj->insn_id;
iobj->insn_id = BIN(leave);
iobj->operand_size = 0;
iobj->insn_info = diobj->insn_info;
if (dniobj) {
dniobj = new_insn_body(iseq, dniobj->insn_info.line_no, BIN(leave), 0);
ELEM_INSERT_NEXT(&iobj->link, &dniobj->link);
}
else {
dniobj = iobj;
}
/* adjust stack depth */
pop = new_insn_body(iseq, diobj->insn_info.line_no, BIN(pop), 0);
ELEM_INSERT_NEXT(&dniobj->link, &pop->link);
ELEM_INSERT_NEXT(&iobj->link, &pop->link);
goto again;
}
else if ((piobj = (INSN *)get_prev_insn(iobj)) != 0 &&

View file

@ -171,8 +171,8 @@ class TestCoverage < Test::Unit::TestCase
result = {
:branches => {
[:"&.", 0, 1, 0, 1, 8] => {
[:then, 1, 1, 0, 1, 8] => 1,
[:else, 2, 1, 0, 1, 8] => 0,
[:then, 1, 1, 0, 1, 8] => 0,
[:else, 2, 1, 0, 1, 8] => 1,
},
},
}

View file

@ -2153,4 +2153,16 @@ class TestSetTraceFunc < Test::Unit::TestCase
assert_equal Array.new(2){th}, events
end
def test_return_event_with_rescue
obj = Object.new
def obj.example
1 if 1 == 1
rescue
end
ok = false
tp = TracePoint.new(:return) {ok = true}
tp.enable {obj.example}
assert ok, "return event should be emitted"
end
end