ruby-changes:56807
From: nagachika <ko1@a...>
Date: Sun, 4 Aug 2019 23:30:01 +0900 (JST)
Subject: [ruby-changes:56807] nagachika: fabb2fed25 (ruby_2_6): merge revision(s) 66977: [Backport #15578]
https://git.ruby-lang.org/ruby.git/commit/?id=fabb2fed25 From fabb2fed252c634d9196813d452667e8a0ed80ac Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Sun, 4 Aug 2019 14:29:17 +0000 Subject: merge revision(s) 66977: [Backport #15578] 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/branches/ruby_2_6@67726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e diff --git a/compile.c b/compile.c index d6e6c8f..4ceb895 100644 --- a/compile.c +++ b/compile.c @@ -2709,7 +2709,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal https://github.com/ruby/ruby/blob/trunk/compile.c#L2709 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 https://github.com/ruby/ruby/blob/trunk/compile.c#L2740 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 https://github.com/ruby/ruby/blob/trunk/compile.c#L2756 */ /* 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 (IS_INSN(iobj->link.prev) && diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb index 6a58706..30523c3 100644 --- a/test/coverage/test_coverage.rb +++ b/test/coverage/test_coverage.rb @@ -171,8 +171,8 @@ class TestCoverage < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/coverage/test_coverage.rb#L171 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, }, }, } diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index 2ada093..6021038 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -2115,4 +2115,16 @@ class TestSetTraceFunc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L2115 } assert_equal [], 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 diff --git a/version.h b/version.h index b81f9d7..4f26133 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1 #define RUBY_VERSION "2.6.3" #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 76 +#define RUBY_PATCHLEVEL 77 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 3 +#define RUBY_RELEASE_DAY 4 #include "ruby/version.h" -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/