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

ruby-changes:32683

From: usa <ko1@a...>
Date: Thu, 30 Jan 2014 19:11:23 +0900 (JST)
Subject: [ruby-changes:32683] usa:r44762 (ruby_1_9_3): merge revision(s) 33361, 33460: [Backport #9463]

usa	2014-01-30 19:11:14 +0900 (Thu, 30 Jan 2014)

  New Revision: 44762

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

  Log:
    merge revision(s) 33361,33460: [Backport #9463]
    
    * gc.c (slot_sweep, rb_gc_finalize_deferred)
      (rb_objspace_call_finalizer, rb_gc): run finalizers
      sequencially.  [ruby-dev:44562]
    
    * gc.c (rb_gc_finalize_deferred, rb_objspace_call_finalizer):
      should use ATOMIC_EXCHANGE() to check the previous value.
      [ruby-dev:44596] [Bug #5439]

  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/gc.c
    branches/ruby_1_9_3/version.h
Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 44761)
+++ ruby_1_9_3/ChangeLog	(revision 44762)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Thu Jan 30 19:08:00 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* gc.c (rb_gc_finalize_deferred, rb_objspace_call_finalizer):
+	  should use ATOMIC_EXCHANGE() to check the previous value.
+	  [ruby-dev:44596] [Bug #5439]
+
+Thu Jan 30 19:08:00 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* gc.c (slot_sweep, rb_gc_finalize_deferred)
+	  (rb_objspace_call_finalizer, rb_gc): run finalizers
+	  sequencially.  [ruby-dev:44562]
+
 Thu Jan 30 11:07:09 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/bigdecimal/bigdecimal.c (CLASS_NAME): macro to wrap
Index: ruby_1_9_3/gc.c
===================================================================
--- ruby_1_9_3/gc.c	(revision 44761)
+++ ruby_1_9_3/gc.c	(revision 44762)
@@ -377,6 +377,7 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/gc.c#L377
 	int dont_gc;
 	int dont_lazy_sweep;
 	int during_gc;
+	rb_atomic_t finalizing;
     } flags;
     struct {
 	st_table *table;
@@ -415,6 +416,7 @@ int *ruby_initial_gc_stress_ptr = &rb_ob https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/gc.c#L416
 #define heaps_freed		objspace->heap.freed
 #define dont_gc 		objspace->flags.dont_gc
 #define during_gc		objspace->flags.during_gc
+#define finalizing		objspace->flags.finalizing
 #define finalizer_table 	objspace->final.table
 #define deferred_final_list	objspace->final.deferred
 #define global_List		objspace->global_list
@@ -2175,7 +2177,7 @@ slot_sweep(rb_objspace_t *objspace, stru https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/gc.c#L2177
     }
     objspace->heap.final_num += final_num;
 
-    if (deferred_final_list) {
+    if (deferred_final_list && !finalizing) {
         rb_thread_t *th = GET_THREAD();
         if (th) {
             RUBY_VM_SET_FINALIZER_INTERRUPT(th);
@@ -3053,7 +3055,10 @@ finalize_deferred(rb_objspace_t *objspac https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/gc.c#L3055
 void
 rb_gc_finalize_deferred(void)
 {
-    finalize_deferred(&rb_objspace);
+    rb_objspace_t *objspace = &rb_objspace;
+    if (ATOMIC_EXCHANGE(finalizing, 1)) return;
+    finalize_deferred(objspace);
+    ATOMIC_SET(finalizing, 0);
 }
 
 struct force_finalize_list {
@@ -3093,6 +3098,8 @@ rb_objspace_call_finalizer(rb_objspace_t https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/gc.c#L3098
     finalize_deferred(objspace);
     assert(deferred_final_list == 0);
 
+    if (ATOMIC_EXCHANGE(finalizing, 1)) return;
+
     /* force to run finalizer */
     while (finalizer_table->num_entries) {
 	struct force_finalize_list *list = 0;
@@ -3147,6 +3154,7 @@ rb_objspace_call_finalizer(rb_objspace_t https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/gc.c#L3154
 
     st_free_table(finalizer_table);
     finalizer_table = 0;
+    ATOMIC_SET(finalizing, 0);
 }
 
 void
@@ -3154,7 +3162,7 @@ rb_gc(void) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/gc.c#L3162
 {
     rb_objspace_t *objspace = &rb_objspace;
     garbage_collect(objspace);
-    finalize_deferred(objspace);
+    if (!finalizing) finalize_deferred(objspace);
     free_unused_heaps(objspace);
 }
 
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 44761)
+++ ruby_1_9_3/version.h	(revision 44762)
@@ -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 505
+#define RUBY_PATCHLEVEL 506
 
 #define RUBY_RELEASE_DATE "2014-01-30"
 #define RUBY_RELEASE_YEAR 2014

Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r33361,33460


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

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