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

ruby-changes:33029

From: nagachika <ko1@a...>
Date: Sat, 22 Feb 2014 14:06:17 +0900 (JST)
Subject: [ruby-changes:33029] nagachika:r45108 (ruby_2_0_0): merge revision(s) r44568: [Backport #9399]

nagachika	2014-02-22 14:06:09 +0900 (Sat, 22 Feb 2014)

  New Revision: 45108

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

  Log:
    merge revision(s) r44568: [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_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/iseq.c
    branches/ruby_2_0_0/ruby_atomic.h
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 45107)
+++ ruby_2_0_0/ChangeLog	(revision 45108)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sat Feb 22 14:01:42 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]
+
 Sat Feb 22 13:56:38 2014  Charlie Somerville  <charliesome@r...>
 
 	* compile.c (iseq_build_from_ary_body): Use :blockptr instead of :block
Index: ruby_2_0_0/iseq.c
===================================================================
--- ruby_2_0_0/iseq.c	(revision 45107)
+++ ruby_2_0_0/iseq.c	(revision 45108)
@@ -480,6 +480,7 @@ iseq_load(VALUE self, VALUE data, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/iseq.c#L480
     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;
@@ -519,7 +520,9 @@ iseq_load(VALUE self, VALUE data, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/iseq.c#L520
     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);
@@ -530,6 +533,11 @@ iseq_load(VALUE self, VALUE data, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/iseq.c#L533
 	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_2_0_0/ruby_atomic.h
===================================================================
--- ruby_2_0_0/ruby_atomic.h	(revision 45107)
+++ ruby_2_0_0/ruby_atomic.h	(revision 45108)
@@ -161,5 +161,10 @@ atomic_size_exchange(size_t *ptr, size_t https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ruby_atomic.h#L161
 #   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_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 45107)
+++ ruby_2_0_0/version.h	(revision 45108)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-02-22"
-#define RUBY_PATCHLEVEL 448
+#define RUBY_PATCHLEVEL 449
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 2

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


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

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