From 2ede24a8f16385c14a27441308699ed42fcbb238 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 23 Apr 2016 14:12:27 +0000 Subject: [PATCH] compile.c: remove redundant trace insn * compile.c (iseq_peephole_optimize): remove successive line trace instructions except for the last. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compile.c b/compile.c index 3cc7696fda..7e3fe14d3f 100644 --- a/compile.c +++ b/compile.c @@ -2279,6 +2279,17 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal } } } + + #define IS_TRACE_LINE(insn) \ + (IS_INSN_ID(insn, trace) && \ + OPERAND_AT(insn, 0) == INT2FIX(RUBY_EVENT_LINE)) + if (IS_TRACE_LINE(iobj) && iobj->link.prev && IS_INSN(iobj->link.prev)) { + INSN *piobj = (INSN *)iobj->link.prev; + if (IS_TRACE_LINE(piobj)) { + REMOVE_ELEM(iobj->link.prev); + } + } + return COMPILE_OK; }