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

ruby-changes:32031

From: ko1 <ko1@a...>
Date: Tue, 10 Dec 2013 15:22:00 +0900 (JST)
Subject: [ruby-changes:32031] ko1:r44110 (trunk): * gc.c (gc_marks_check): disable GC during checking and

ko1	2013-12-10 15:21:52 +0900 (Tue, 10 Dec 2013)

  New Revision: 44110

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

  Log:
    * gc.c (gc_marks_check): disable GC during checking and
      restore malloc_increase info.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44109)
+++ ChangeLog	(revision 44110)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Dec 10 15:15:37 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c (gc_marks_check): disable GC during checking and
+	  restore malloc_increase info.
+
 Tue Dec 10 14:41:53 2013  Aman Gupta <ruby@t...>
 
 	* gc.c (reflist_add): return 0 if reference already exists
Index: gc.c
===================================================================
--- gc.c	(revision 44109)
+++ gc.c	(revision 44110)
@@ -4262,8 +4262,6 @@ objspace_allrefs(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L4262
     struct mark_func_data_struct mfd;
     VALUE obj;
 
-    rb_gc_disable();
-
     data.objspace = objspace;
     data.references = st_init_numtable();
 
@@ -4281,7 +4279,6 @@ objspace_allrefs(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L4279
     }
     shrink_stack_chunk_cache(&objspace->mark_stack);
 
-    rb_gc_enable();
     return data.references;
 }
 
@@ -4379,8 +4376,14 @@ gc_check_after_marks_i(st_data_t k, st_d https://github.com/ruby/ruby/blob/trunk/gc.c#L4376
 static void
 gc_marks_check(rb_objspace_t *objspace, int (*checker_func)(ANYARGS), const char *checker_name)
 {
-    objspace->rgengc.allrefs_table = objspace_allrefs(objspace);
+    
+    size_t saved_malloc_increase = objspace->malloc_params.increase;
+#if RGENGC_ESTIMATE_OLDMALLOC
+    size_t saved_oldmalloc_increase = objspace->rgengc.oldmalloc_increase;
+#endif
+    VALUE already_disabled = rb_gc_disable();
 
+    objspace->rgengc.allrefs_table = objspace_allrefs(objspace);
     st_foreach(objspace->rgengc.allrefs_table, checker_func, (st_data_t)objspace);
 
     if (objspace->rgengc.error_count > 0) {
@@ -4392,6 +4395,12 @@ gc_marks_check(rb_objspace_t *objspace, https://github.com/ruby/ruby/blob/trunk/gc.c#L4395
 
     objspace_allrefs_destruct(objspace->rgengc.allrefs_table);
     objspace->rgengc.allrefs_table = 0;
+
+    if (already_disabled == Qfalse) rb_gc_enable();
+    objspace->malloc_params.increase = saved_malloc_increase;
+#if RGENGC_ESTIMATE_OLDMALLOC
+    objspace->rgengc.oldmalloc_increase = saved_oldmalloc_increase;
+#endif
 }
 
 #endif /* RGENGC_CHECK_MODE >= 2 */

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

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