summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-12 19:37:16 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-12 19:37:16 +0000
commit161b2e264fcfc0ecb046b35245139e02847bbdb0 (patch)
tree37c80ca28abd603af769d37aabfbf7cf70114d10
parentfc234a916a18f27b47005358c8ae3f7e4205415a (diff)
* 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
-rw-r--r--ChangeLog8
-rw-r--r--bootstraptest/test_syntax.rb6
-rw-r--r--compile.c6
3 files changed, 16 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index cb9bbc9edc..cdacfb7ea2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb
index db10e12959..1b6d0c8eab 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 776129d781..770e1cf89b 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)) {
/*