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

ruby-changes:25030

From: nobu <ko1@a...>
Date: Thu, 4 Oct 2012 16:31:41 +0900 (JST)
Subject: [ruby-changes:25030] nobu:r37082 (trunk): gc.c: self-referencing finalizers

nobu	2012-10-04 16:31:31 +0900 (Thu, 04 Oct 2012)

  New Revision: 37082

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

  Log:
    gc.c: self-referencing finalizers
    
    * gc.c (rb_objspace_call_finalizer): mark self-referencing finalizers
      before run finalizers, to fix SEGV from btest on 32bit.
    * gc.c (gc_mark_stacked_objects): extract from gc_marks().

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37081)
+++ ChangeLog	(revision 37082)
@@ -1,3 +1,10 @@
+Thu Oct  4 16:31:29 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* gc.c (rb_objspace_call_finalizer): mark self-referencing finalizers
+	  before run finalizers, to fix SEGV from btest on 32bit.
+
+	* gc.c (gc_mark_stacked_objects): extract from gc_marks().
+
 Thu Oct  4 11:43:28 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* thread_pthread.c (ruby_init_stack): round stack limit to page size
Index: gc.c
===================================================================
--- gc.c	(revision 37081)
+++ gc.c	(revision 37082)
@@ -358,6 +358,7 @@
 static int gc_lazy_sweep(rb_objspace_t *);
 static void mark_tbl(rb_objspace_t *, st_table *);
 static void rest_sweep(rb_objspace_t *);
+static void gc_mark_stacked_objects(rb_objspace_t *);
 
 static double getrusage_time(void);
 static inline void gc_prof_timer_start(rb_objspace_t *);
@@ -1483,6 +1484,9 @@
     RVALUE *final_list = 0;
     size_t i;
 
+    mark_tbl(objspace, finalizer_table);
+    gc_mark_stacked_objects(objspace);
+
     /* run finalizers */
     rest_sweep(objspace);
 
@@ -2831,12 +2835,24 @@
 }
 
 static void
+gc_mark_stacked_objects(rb_objspace_t *objspace)
+{
+    mark_stack_t *mstack = &objspace->mark_stack;
+    VALUE obj = 0;
+
+    if (!mstack->index) return;
+    while (pop_mark_stack(mstack, &obj)) {
+        gc_mark_children(objspace, obj);
+    }
+    shrink_stack_chunk_cache(mstack);
+}
+
+static void
 gc_marks(rb_objspace_t *objspace)
 {
     struct gc_list *list;
     rb_thread_t *th = GET_THREAD();
-    mark_stack_t *mstack = &objspace->mark_stack;
-    VALUE obj = 0;
+
     gc_prof_mark_timer_start(objspace);
 
     objspace->heap.live_num = 0;
@@ -2870,10 +2886,7 @@
     rb_gc_mark_unlinked_live_method_entries(th->vm);
 
     /* marking-loop */
-    while (pop_mark_stack(mstack, &obj)) {
-        gc_mark_children(objspace, obj);
-    }
-    shrink_stack_chunk_cache(mstack);
+    gc_mark_stacked_objects(objspace);
 
     gc_prof_mark_timer_stop(objspace);
 }

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

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