ruby-changes:26688
From: nobu <ko1@a...>
Date: Tue, 8 Jan 2013 14:41:55 +0900 (JST)
Subject: [ruby-changes:26688] nobu:r38739 (trunk): vm_core.h: flip_cnt in rb_iseq_t
nobu 2013-01-08 14:41:44 +0900 (Tue, 08 Jan 2013) New Revision: 38739 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38739 Log: vm_core.h: flip_cnt in rb_iseq_t * vm_core.h (rb_iseq_t): move flip_cnt from struct iseq_compile_data, because it has same life span as enclosing iseq. [Bug #7671] [ruby-core:51296] Modified files: trunk/ChangeLog trunk/compile.c trunk/iseq.h trunk/test/ruby/test_flip.rb trunk/vm_core.h Index: ChangeLog =================================================================== --- ChangeLog (revision 38738) +++ ChangeLog (revision 38739) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Jan 8 14:41:41 2013 Nobuyoshi Nakada <nobu@r...> + + * vm_core.h (rb_iseq_t): move flip_cnt from struct iseq_compile_data, + because it has same life span as enclosing iseq. [Bug #7671] + [ruby-core:51296] + Mon Jan 7 23:43:00 2013 Kenta Murata <mrkn@m...> * ext/bigdecimal/bigdecimal.c (rmpd_power_by_big_decimal): Index: vm_core.h =================================================================== --- vm_core.h (revision 38738) +++ vm_core.h (revision 38739) @@ -306,6 +306,7 @@ struct rb_iseq_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L306 /* misc */ ID defined_method_id; /* for define_method */ + rb_num_t flip_cnt; /* used at compile time */ struct iseq_compile_data *compile_data; Index: iseq.h =================================================================== --- iseq.h (revision 38738) +++ iseq.h (revision 38739) @@ -98,7 +98,6 @@ struct iseq_compile_data { https://github.com/ruby/ruby/blob/trunk/iseq.h#L98 struct iseq_compile_data_storage *storage_current; int last_line; int last_coverable_line; - int flip_cnt; int label_no; int node_level; const rb_compile_option_t *option; Index: compile.c =================================================================== --- compile.c (revision 38738) +++ compile.c (revision 38739) @@ -5051,12 +5051,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5051 LABEL *lend = NEW_LABEL(nd_line(node)); LABEL *lfin = NEW_LABEL(nd_line(node)); LABEL *ltrue = NEW_LABEL(nd_line(node)); - struct iseq_compile_data *data = iseq->local_iseq->compile_data; + rb_iseq_t *local_iseq = iseq->local_iseq; rb_num_t cnt; VALUE key; - if (!data) data = iseq->compile_data; - cnt = data->flip_cnt++ + DEFAULT_SPECIAL_VAR_COUNT; + cnt = local_iseq->flip_cnt++ + DEFAULT_SPECIAL_VAR_COUNT; key = INT2FIX(cnt); ADD_INSN2(ret, nd_line(node), getspecial, key, INT2FIX(0)); Index: test/ruby/test_flip.rb =================================================================== --- test/ruby/test_flip.rb (revision 38738) +++ test/ruby/test_flip.rb (revision 38739) @@ -10,4 +10,12 @@ class TestFlip < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_flip.rb#L10 2000.times {eval %[(foo..bar) ? 1 : 2]} end end + + def test_shared_eval + bug7671 = '[ruby-core:51296]' + vs = (1..9).to_a + vs.select {|n| if n==2..n==16 then 1 end} + v = eval("vs.select {|n| if n==3..n==6 then 1 end}") + assert_equal([*3..6], v, bug7671) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/