* compile.c (iseq_peephole_optimize): fix peephole optimization

bug. [ruby-dev:31360]
* bootstraptest/test_syntax.rb: add a test for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-08-12 19:37:16 +00:00
Родитель fc234a916a
Коммит 161b2e264f
3 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Mon Aug 13 04:35:30 2007 Koichi Sasada <ko1@atdot.net>
* 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 <ko1@atdot.net>
* vm_dump.c (debug_print_pre): fix to show control frame count.

Просмотреть файл

@ -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]'

Просмотреть файл

@ -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)) {
/*