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

ruby-changes:32867

From: usa <ko1@a...>
Date: Fri, 14 Feb 2014 15:44:43 +0900 (JST)
Subject: [ruby-changes:32867] usa:r44946 (ruby_1_9_3): merge revision(s) 44568: [Backport #9399]

usa	2014-02-14 15:44:36 +0900 (Fri, 14 Feb 2014)

  New Revision: 44946

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

  Log:
    merge revision(s) 44568: [Backport #9399]
    
    * iseq.c (iseq_load): keep type_map to get rid of memory leak.
      based on a patch by Eric Wong at [ruby-core:59699].  [Bug #9399]

  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/iseq.c
    branches/ruby_1_9_3/ruby_atomic.h
    branches/ruby_1_9_3/version.h
Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 44945)
+++ ruby_1_9_3/ChangeLog	(revision 44946)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Fri Feb 14 15:40:32 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* iseq.c (iseq_load): keep type_map to get rid of memory leak.
+	  based on a patch by Eric Wong at [ruby-core:59699].  [Bug #9399]
+
 Fri Feb 14 15:25:23 2014  Tanaka Akira  <akr@f...>
 
 	* lib/resolv.rb (Resolv::DNS::Resource::TXT#data): Return concatenated
Index: ruby_1_9_3/iseq.c
===================================================================
--- ruby_1_9_3/iseq.c	(revision 44945)
+++ ruby_1_9_3/iseq.c	(revision 44946)
@@ -450,6 +450,7 @@ iseq_load(VALUE self, VALUE data, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/iseq.c#L450
     VALUE type, body, locals, args, exception;
 
     st_data_t iseq_type;
+    static struct st_table *type_map_cache = 0;
     struct st_table *type_map = 0;
     rb_iseq_t *iseq;
     rb_compile_option_t option;
@@ -488,7 +489,9 @@ iseq_load(VALUE self, VALUE data, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/iseq.c#L489
     GetISeqPtr(iseqval, iseq);
     iseq->self = iseqval;
 
+    type_map = type_map_cache;
     if (type_map == 0) {
+	struct st_table *cached_map;
 	type_map = st_init_numtable();
 	st_insert(type_map, ID2SYM(rb_intern("top")), ISEQ_TYPE_TOP);
 	st_insert(type_map, ID2SYM(rb_intern("method")), ISEQ_TYPE_METHOD);
@@ -499,6 +502,11 @@ iseq_load(VALUE self, VALUE data, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/iseq.c#L502
 	st_insert(type_map, ID2SYM(rb_intern("eval")), ISEQ_TYPE_EVAL);
 	st_insert(type_map, ID2SYM(rb_intern("main")), ISEQ_TYPE_MAIN);
 	st_insert(type_map, ID2SYM(rb_intern("defined_guard")), ISEQ_TYPE_DEFINED_GUARD);
+	cached_map = ATOMIC_PTR_CAS(type_map_cache, (struct st_table *)0, type_map);
+	if (cached_map) {
+	    st_free_table(type_map);
+	    type_map = cached_map;
+	}
     }
 
     if (st_lookup(type_map, type, &iseq_type) == 0) {
Index: ruby_1_9_3/ruby_atomic.h
===================================================================
--- ruby_1_9_3/ruby_atomic.h	(revision 44945)
+++ ruby_1_9_3/ruby_atomic.h	(revision 44946)
@@ -56,6 +56,7 @@ rb_w32_atomic_or(volatile rb_atomic_t *v https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ruby_atomic.h#L56
 #  define ATOMIC_SIZE_INC(var) InterlockedIncrement64(&(var))
 #  define ATOMIC_SIZE_DEC(var) InterlockedDecrement64(&(var))
 #  define ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange64(&(var), (val))
+#  define ATOMIC_SIZE_CAS(var, oldval, val) InterlockedCompareExchange64(&(var), (oldval), (val))
 # else
 #  define ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd((LONG *)&(var), (val))
 #  define ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd((LONG *)&(var), -(val))
@@ -80,7 +81,7 @@ typedef unsigned int rb_atomic_t; https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ruby_atomic.h#L81
 #  define ATOMIC_SIZE_INC(var) atomic_inc_ulong(&(var))
 #  define ATOMIC_SIZE_DEC(var) atomic_dec_ulong(&(var))
 #  define ATOMIC_SIZE_EXCHANGE(var, val) atomic_swap_ulong(&(var), (val))
-# else
+#  define ATOMIC_SIZE_CAS(var, oldval, val) atomic_cas_ulong(&(var), (oldval), (# else
 #  define ATOMIC_SIZE_ADD(var, val) atomic_add_int(&(var), (val))
 #  define ATOMIC_SIZE_SUB(var, val) atomic_add_int(&(var), -(val))
 #  define ATOMIC_SIZE_INC(var) atomic_inc_uint(&(var))
@@ -113,10 +114,19 @@ atomic_size_exchange(size_t *ptr, size_t https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ruby_atomic.h#L114
 }
 #endif
 
+#ifndef ATOMIC_SIZE_CAS
+# define ATOMIC_SIZE_CAS(var, oldval, val) ATOMIC_CAS(var, oldval, val)
+#endif
+
 #ifndef ATOMIC_PTR_EXCHANGE
 # if SIZEOF_VOIDP == SIZEOF_SIZE_T
 #   define ATOMIC_PTR_EXCHANGE(var, val) (void *)ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val))
 # endif
 #endif
+#ifndef ATOMIC_PTR_CAS
+# if SIZEOF_VOIDP == SIZEOF_SIZE_T
+#   define ATOMIC_PTR_CAS(var, oldval, val) (void *)ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))
+# endif
+#endif
 
 #endif /* RUBY_ATOMIC_H */
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 44945)
+++ ruby_1_9_3/version.h	(revision 44946)
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 526
+#define RUBY_PATCHLEVEL 527
 
 #define RUBY_RELEASE_DATE "2014-02-14"
 #define RUBY_RELEASE_YEAR 2014

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


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

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