From 864856cd198a6ea575470cac1ce59cea91aed0f6 Mon Sep 17 00:00:00 2001 From: ko1 Date: Sun, 12 Aug 2007 19:37:16 +0000 Subject: * compile.c (iseq_peephole_optimize): fix peephole optimization bug. [ruby-dev:31360] * bootstraptest/test_syntax.rb: add a test for above. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ bootstraptest/test_syntax.rb | 6 ++++-- compile.c | 6 ++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb9bbc9ed..cdacfb7ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Aug 13 04:35:30 2007 Koichi Sasada + + * compile.c (iseq_peephole_optimize): fix peephole optimization + bug. [ruby-dev:31360] + + * bootstraptest/test_syntax.rb: add a test for above. + + Mon Aug 13 04:02:29 2007 Koichi Sasada * vm_dump.c (debug_print_pre): fix to show control frame count. diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb index db10e1295..1b6d0c8ea 100644 --- a/bootstraptest/test_syntax.rb +++ b/bootstraptest/test_syntax.rb @@ -541,5 +541,7 @@ assert_syntax_error "Can't set variable $1", %q{0..$1=1} # [ruby-dev:31118] assert_syntax_error "void value expression", %q{1.times{1+(1&&next)}} # [ruby-dev:31119] assert_syntax_error "void value expression", %q{x=-1;loop{x+=1&&redo if (x+=1).zero?}} # [ruby-dev:31119] assert_syntax_error %q{syntax error, unexpected $end}, %q{!} # [ruby-dev:31243] -assert_equal %q{[nil]}, %q{[()]} # [ruby-dev:31252] -assert_equal %q{true}, %q{!_=()} # [ruby-dev:31263] +assert_equal %q{[nil]}, %q{[()]}, '[ruby-dev:31252]' +assert_equal %q{true}, %q{!_=()}, '[ruby-dev:31263]' +assert_equal 'ok', %q{while true; redo; end if 1 == 2; :ok}, '[ruby-dev:31360]' + diff --git a/compile.c b/compile.c index 776129d78..770e1cf89 100644 --- a/compile.c +++ b/compile.c @@ -1318,8 +1318,10 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal REMOVE_ELEM(&iobj->link); } else if (iobj != diobj && diobj->insn_id == BIN(jump)) { - OPERAND_AT(iobj, 0) = OPERAND_AT(diobj, 0); - goto again; + if (OPERAND_AT(iobj, 0) != OPERAND_AT(diobj, 0)) { + OPERAND_AT(iobj, 0) = OPERAND_AT(diobj, 0); + goto again; + } } else if (diobj->insn_id == BIN(leave)) { /* -- cgit