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] 4cae5353c03009beb1e0a1619422072773580609 5afd479de63b6609ddcd1510da94d2c1ac384f7f git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e826b7d39e
commit
1bc6c3f407
19
compile.c
19
compile.c
@ -2709,7 +2709,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
|
|||||||
optimize_checktype(iseq, iobj);
|
optimize_checktype(iseq, iobj);
|
||||||
|
|
||||||
if (IS_INSN_ID(iobj, jump)) {
|
if (IS_INSN_ID(iobj, jump)) {
|
||||||
INSN *niobj, *diobj, *piobj, *dniobj;
|
INSN *niobj, *diobj, *piobj;
|
||||||
diobj = (INSN *)get_destination_insn(iobj);
|
diobj = (INSN *)get_destination_insn(iobj);
|
||||||
niobj = (INSN *)get_next_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);
|
remove_unreachable_chunk(iseq, iobj->link.next);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
else if (dniobj = 0,
|
else if (IS_INSN_ID(diobj, leave)) {
|
||||||
IS_INSN_ID(diobj, leave) ||
|
|
||||||
(diobj->operand_size == 0 &&
|
|
||||||
(dniobj = (INSN *)get_next_insn(diobj)) != 0 &&
|
|
||||||
(IS_INSN_ID(dniobj, leave) || (dniobj = 0)))) {
|
|
||||||
INSN *pop;
|
INSN *pop;
|
||||||
/*
|
/*
|
||||||
* jump LABEL
|
* jump LABEL
|
||||||
@ -2760,19 +2756,12 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
|
|||||||
*/
|
*/
|
||||||
/* replace */
|
/* replace */
|
||||||
unref_destination(iobj, 0);
|
unref_destination(iobj, 0);
|
||||||
iobj->insn_id = diobj->insn_id;
|
iobj->insn_id = BIN(leave);
|
||||||
iobj->operand_size = 0;
|
iobj->operand_size = 0;
|
||||||
iobj->insn_info = diobj->insn_info;
|
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 */
|
/* adjust stack depth */
|
||||||
pop = new_insn_body(iseq, diobj->insn_info.line_no, BIN(pop), 0);
|
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;
|
goto again;
|
||||||
}
|
}
|
||||||
else if ((piobj = (INSN *)get_prev_insn(iobj)) != 0 &&
|
else if ((piobj = (INSN *)get_prev_insn(iobj)) != 0 &&
|
||||||
|
@ -171,8 +171,8 @@ class TestCoverage < Test::Unit::TestCase
|
|||||||
result = {
|
result = {
|
||||||
:branches => {
|
:branches => {
|
||||||
[:"&.", 0, 1, 0, 1, 8] => {
|
[:"&.", 0, 1, 0, 1, 8] => {
|
||||||
[:then, 1, 1, 0, 1, 8] => 1,
|
[:then, 1, 1, 0, 1, 8] => 0,
|
||||||
[:else, 2, 1, 0, 1, 8] => 0,
|
[:else, 2, 1, 0, 1, 8] => 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -2153,4 +2153,16 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_equal Array.new(2){th}, events
|
assert_equal Array.new(2){th}, events
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user