[前][次][番号順一覧][スレッド一覧]

ruby-changes:26260

From: usa <ko1@a...>
Date: Tue, 11 Dec 2012 18:51:55 +0900 (JST)
Subject: [ruby-changes:26260] usa:r38317 (ruby_1_9_3): merge revision(s) 38292: [Backport #6899]

usa	2012-12-11 18:51:43 +0900 (Tue, 11 Dec 2012)

  New Revision: 38317

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38317

  Log:
    merge revision(s) 38292: [Backport #6899]
    
    * compile.c (iseq_compile_each): count flip-flop state in local iseq
      not in each iseqs, so that the keys can be other than hidden
      strings.  [ruby-core:47253] [Bug #6899]
    
    * vm_insnhelper.c (lep_svar_get, lep_svar_set, vm_getspecial): store
      flip-flop states in an array instead of a hash.
    
    * iseq.c (set_relation): main iseq also can has local scope.

  Added files:
    branches/ruby_1_9_3/test/ruby/test_flip.rb
  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/compile.c
    branches/ruby_1_9_3/insns.def
    branches/ruby_1_9_3/iseq.c
    branches/ruby_1_9_3/iseq.h
    branches/ruby_1_9_3/version.h
    branches/ruby_1_9_3/vm_insnhelper.c

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 38316)
+++ ruby_1_9_3/ChangeLog	(revision 38317)
@@ -1,3 +1,14 @@
+Tue Dec 11 17:53:55 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* compile.c (iseq_compile_each): count flip-flop state in local iseq
+	  not in each iseqs, so that the keys can be other than hidden
+	  strings.  [ruby-core:47253] [Bug #6899]
+
+	* vm_insnhelper.c (lep_svar_get, lep_svar_set, vm_getspecial): store
+	  flip-flop states in an array instead of a hash.
+
+	* iseq.c (set_relation): main iseq also can has local scope.
+
 Tue Dec 11 17:52:30 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* include/ruby/backward/rubysig.h: fix visibility.  [Bug #6607]
Index: ruby_1_9_3/insns.def
===================================================================
--- ruby_1_9_3/insns.def	(revision 38316)
+++ ruby_1_9_3/insns.def	(revision 38317)
@@ -79,7 +79,7 @@
  */
 DEFINE_INSN
 getspecial
-(VALUE key, rb_num_t type)
+(rb_num_t key, rb_num_t type)
 ()
 (VALUE val)
 {
@@ -93,7 +93,7 @@
  */
 DEFINE_INSN
 setspecial
-(VALUE key)
+(rb_num_t key)
 (VALUE obj)
 ()
 {
Index: ruby_1_9_3/iseq.c
===================================================================
--- ruby_1_9_3/iseq.c	(revision 38316)
+++ ruby_1_9_3/iseq.c	(revision 38317)
@@ -216,6 +216,10 @@
 	GetISeqPtr(parent, piseq);
 	iseq->parent_iseq = piseq;
     }
+
+    if (type == ISEQ_TYPE_MAIN) {
+	iseq->local_iseq = iseq;
+    }
 }
 
 static VALUE
Index: ruby_1_9_3/iseq.h
===================================================================
--- ruby_1_9_3/iseq.h	(revision 38316)
+++ ruby_1_9_3/iseq.h	(revision 38317)
@@ -118,6 +118,8 @@
     DEFINED_FUNC
 };
 
+#define DEFAULT_SPECIAL_VAR_COUNT 2
+
 #if defined __GNUC__ && __GNUC__ >= 4
 #pragma GCC visibility pop
 #endif
Index: ruby_1_9_3/compile.c
===================================================================
--- ruby_1_9_3/compile.c	(revision 38316)
+++ ruby_1_9_3/compile.c	(revision 38317)
@@ -4844,12 +4844,14 @@
 	LABEL *lend = NEW_LABEL(nd_line(node));
 	LABEL *lfin = NEW_LABEL(nd_line(node));
 	LABEL *ltrue = NEW_LABEL(nd_line(node));
-	VALUE key = rb_sprintf("flipflag/%s-%p-%d",
-			       RSTRING_PTR(iseq->name), (void *)iseq,
-			       iseq->compile_data->flip_cnt++);
+	struct iseq_compile_data *data = iseq->local_iseq->compile_data;
+	rb_num_t cnt;
+	VALUE key;
 
-	hide_obj(key);
-	iseq_add_mark_object_compile_time(iseq, key);
+	if (!data) data = iseq->compile_data;
+	cnt = data->flip_cnt++ + DEFAULT_SPECIAL_VAR_COUNT;
+	key = INT2FIX(cnt);
+
 	ADD_INSN2(ret, nd_line(node), getspecial, key, INT2FIX(0));
 	ADD_INSNL(ret, nd_line(node), branchif, lend);
 
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 38316)
+++ ruby_1_9_3/version.h	(revision 38317)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 335
+#define RUBY_PATCHLEVEL 336
 
 #define RUBY_RELEASE_DATE "2012-12-11"
 #define RUBY_RELEASE_YEAR 2012
Index: ruby_1_9_3/vm_insnhelper.c
===================================================================
--- ruby_1_9_3/vm_insnhelper.c	(revision 38316)
+++ ruby_1_9_3/vm_insnhelper.c	(revision 38317)
@@ -981,7 +981,7 @@
 }
 
 static VALUE
-lfp_svar_get(rb_thread_t *th, VALUE *lfp, VALUE key)
+lfp_svar_get(rb_thread_t *th, VALUE *lfp, rb_num_t key)
 {
     NODE *svar = lfp_svar_place(th, lfp);
 
@@ -991,20 +991,20 @@
       case 1:
 	return svar->u2.value;
       default: {
-	const VALUE hash = svar->u3.value;
+	const VALUE ary = svar->u3.value;
 
-	if (hash == Qnil) {
+	if (NIL_P(ary)) {
 	    return Qnil;
 	}
 	else {
-	    return rb_hash_lookup(hash, key);
+	    return rb_ary_entry(ary, key - DEFAULT_SPECIAL_VAR_COUNT);
 	}
       }
     }
 }
 
 static void
-lfp_svar_set(rb_thread_t *th, VALUE *lfp, VALUE key, VALUE val)
+lfp_svar_set(rb_thread_t *th, VALUE *lfp, rb_num_t key, VALUE val)
 {
     NODE *svar = lfp_svar_place(th, lfp);
 
@@ -1016,27 +1016,23 @@
 	svar->u2.value = val;
 	return;
       default: {
-	VALUE hash = svar->u3.value;
+	VALUE ary = svar->u3.value;
 
-	if (hash == Qnil) {
-	    svar->u3.value = hash = rb_hash_new();
+	if (NIL_P(ary)) {
+	    svar->u3.value = ary = rb_ary_new();
 	}
-	rb_hash_aset(hash, key, val);
+	rb_ary_store(ary, key - DEFAULT_SPECIAL_VAR_COUNT, val);
       }
     }
 }
 
 static inline VALUE
-vm_getspecial(rb_thread_t *th, VALUE *lfp, VALUE key, rb_num_t type)
+vm_getspecial(rb_thread_t *th, VALUE *lfp, rb_num_t key, rb_num_t type)
 {
     VALUE val;
 
     if (type == 0) {
-	VALUE k = key;
-	if (FIXNUM_P(key)) {
-	    k = FIX2INT(key);
-	}
-	val = lfp_svar_get(th, lfp, k);
+	val = lfp_svar_get(th, lfp, key);
     }
     else {
 	VALUE backref = lfp_svar_get(th, lfp, 1);
Index: ruby_1_9_3/test/ruby/test_flip.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_flip.rb	(revision 0)
+++ ruby_1_9_3/test/ruby/test_flip.rb	(revision 38317)
@@ -0,0 +1,13 @@
+require 'test/unit'
+require_relative 'envutil'
+
+class TestFlip < Test::Unit::TestCase
+  def test_hidden_key
+    bug6899 = '[ruby-core:47253]'
+    foo = "foor"
+    bar = "bar"
+    assert_nothing_raised(NotImplementedError, bug6899) do
+      2000.times {eval %[(foo..bar) ? 1 : 2]}
+    end
+  end
+end

Property changes on: ruby_1_9_3/test/ruby/test_flip.rb
___________________________________________________________________
Added: svn:eol-style
   + LF


Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r38292


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]