summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-08 05:41:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-08 05:41:44 +0000
commit69b716111f04a5a692578638a16fc55a75a9dd1d (patch)
treec347b8f115c98bb87505a8d3a713ebcf711d253f
parentbdb18e5ffad55f326c0fc3ea659fbe254f15b909 (diff)
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--compile.c5
-rw-r--r--iseq.h1
-rw-r--r--test/ruby/test_flip.rb8
-rw-r--r--vm_core.h1
5 files changed, 17 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index dc4345a2ef..1f726bd624 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Jan 8 14:41:41 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@mrkn.jp>
* ext/bigdecimal/bigdecimal.c (rmpd_power_by_big_decimal):
diff --git a/compile.c b/compile.c
index 7dffe08141..35feaa3122 100644
--- a/compile.c
+++ b/compile.c
@@ -5051,12 +5051,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
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));
diff --git a/iseq.h b/iseq.h
index 4a7965adf9..0790529638 100644
--- a/iseq.h
+++ b/iseq.h
@@ -98,7 +98,6 @@ struct iseq_compile_data {
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;
diff --git a/test/ruby/test_flip.rb b/test/ruby/test_flip.rb
index 8d7cdd03ad..bd14228a8c 100644
--- a/test/ruby/test_flip.rb
+++ b/test/ruby/test_flip.rb
@@ -10,4 +10,12 @@ class TestFlip < Test::Unit::TestCase
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
diff --git a/vm_core.h b/vm_core.h
index 6ecbd70289..f1dc013313 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -306,6 +306,7 @@ struct rb_iseq_struct {
/* misc */
ID defined_method_id; /* for define_method */
+ rb_num_t flip_cnt;
/* used at compile time */
struct iseq_compile_data *compile_data;