ruby-changes:3206
From: ko1@a...
Date: 25 Dec 2007 21:37:38 +0900
Subject: [ruby-changes:3206] ko1 - Ruby:r14699 (trunk): * compile.c (iseq_compile_each): fix stack consistency error
ko1 2007-12-25 21:37:16 +0900 (Tue, 25 Dec 2007) New Revision: 14699 Modified files: trunk/ChangeLog trunk/bootstraptest/test_knownbug.rb trunk/bootstraptest/test_syntax.rb trunk/compile.c Log: * compile.c (iseq_compile_each): fix stack consistency error (break is compiled to throw instead of jump insn). these problems are reported by Yusuke ENDOH <mame AT tsg.ne.jp> * bootstraptest/test_knownbug.rb, test_syntax.rb: move fixed test. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/compile.c?r1=14699&r2=14698 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14699&r2=14698 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_syntax.rb?r1=14699&r2=14698 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_knownbug.rb?r1=14699&r2=14698 Index: ChangeLog =================================================================== --- ChangeLog (revision 14698) +++ ChangeLog (revision 14699) @@ -1,3 +1,11 @@ +Tue Dec 25 21:32:54 2007 Koichi Sasada <ko1@a...> + + * compile.c (iseq_compile_each): fix stack consistency error + (break is compiled to throw instead of jump insn). + these problems are reported by Yusuke ENDOH <mame AT tsg.ne.jp> + + * bootstraptest/test_knownbug.rb, test_syntax.rb: move fixed test. + Tue Dec 25 21:32:44 2007 Tanaka Akira <akr@f...> * parse.y (struct parser_params): make parser_ruby_sourcefile common Index: bootstraptest/test_syntax.rb =================================================================== --- bootstraptest/test_syntax.rb (revision 14698) +++ bootstraptest/test_syntax.rb (revision 14699) @@ -689,7 +689,7 @@ "#{next}" end :ok -} +}, 'reported by Yusuke ENDOH' assert_equal 'ok', %q{ counter = 2 @@ -700,7 +700,7 @@ redo end :ok -} +}, 'reported by Yusuke ENDOH' assert_equal 'ok', %q{ counter = 2 @@ -711,4 +711,38 @@ "#{ redo }" end :ok -} +}, 'reported by Yusuke ENDOH' + +assert_normal_exit %q{ + begin + raise + rescue + counter = 2 + while true + counter -= 1 + break if counter == 0 + next + retry + end + end +}, 'reported by Yusuke ENDOH' + +assert_normal_exit %q{ + counter = 2 + while true + counter -= 1 + break if counter == 0 + next + "#{ break }" + end +}, 'reported by Yusuke ENDOH' + +assert_normal_exit %q{ + counter = 2 + while true + counter -= 1 + next if counter != 0 + "#{ break }" + end +}, 'reported by Yusuke ENDOH' + Index: bootstraptest/test_knownbug.rb =================================================================== --- bootstraptest/test_knownbug.rb (revision 14698) +++ bootstraptest/test_knownbug.rb (revision 14699) @@ -2,27 +2,3 @@ # This test file concludes tests which point out known bugs. # So all tests will cause failure. # - -assert_normal_exit %q{ - begin - raise - rescue - counter = 2 - while true - counter -= 1 - break if counter == 0 - next - retry - end - end -}, 'reported by Yusuke ENDOH' - -assert_normal_exit %q{ - counter = 2 - while true - counter -= 1 - break if counter == 0 - next - "#{ break }" - end -}, 'reported by Yusuke ENDOH' Index: compile.c =================================================================== --- compile.c (revision 14698) +++ compile.c (revision 14699) @@ -2924,12 +2924,26 @@ if (iseq->compile_data->redo_label != 0) { /* while/until */ +#if 0 add_ensure_iseq(ret, iseq); COMPILE_(ret, "break val (while/until)", node->nd_stts, iseq->compile_data->loopval_popped); ADD_INSNL(ret, nd_line(node), jump, iseq->compile_data->end_label); - ADD_INSN(ret, nd_line(node), pop); + + if (poped) { + ADD_INSN(ret, nd_line(node), pop); + } +#else + level = 0x8000 | 0x4000; + COMPILE(ret, "break val (while/until)", node->nd_stts); + ADD_INSN1(ret, nd_line(node), throw, + INT2FIX(level | 0x02) /* TAG_BREAK */ ); + + if (poped) { + ADD_INSN(ret, nd_line(node), pop); + } +#endif } else if (iseq->type == ISEQ_TYPE_BLOCK) { break_by_insn: @@ -3089,6 +3103,10 @@ ADD_INSN(ret, nd_line(node), putnil); ADD_INSN1(ret, nd_line(node), throw, INT2FIX(0x04) /* TAG_RETRY */ ); + + if (poped) { + ADD_INSN(ret, nd_line(node), pop); + } } else { COMPILE_ERROR((ERROR_ARGS "Invalid retry")); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml