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

ruby-changes:6351

From: nari <ko1@a...>
Date: Fri, 4 Jul 2008 11:18:38 +0900 (JST)
Subject: [ruby-changes:6351] Ruby:r17867 (trunk): * gc.c (garbage_collect_force): sweep is completely ended.

nari	2008-07-04 11:18:17 +0900 (Fri, 04 Jul 2008)

  New Revision: 17867

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

  Log:
    * gc.c (garbage_collect_force): sweep is completely ended.
    
    * gc.c (os_obj_of): invoke garbage_collect_force() when freelist none.
    


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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17866)
+++ ChangeLog	(revision 17867)
@@ -1,3 +1,9 @@
+Fri Jul  4 11:08:37 2008  nari  <authorNari@g...>
+
+	* gc.c (garbage_collect_force): sweep is completely ended.
+
+	* gc.c (os_obj_of): invoke garbage_collect_force() when freelist none.
+
 Fri Jul  4 05:01:26 2008  NAKAMURA Usaku  <usa@r...>
 
 	* numeric.c (rb_num2uint, rb_fix2uint): typo.
Index: gc.c
===================================================================
--- gc.c	(revision 17866)
+++ gc.c	(revision 17867)
@@ -191,6 +191,7 @@
     struct gc_list *global_list;
     unsigned int count;
     int gc_stress;
+    int gc_not_lazy_sweep;
 } rb_objspace_t;
 
 #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
@@ -226,6 +227,7 @@
 #define mark_stack_overflow	objspace->markstack.overflow
 #define global_List		objspace->global_list
 #define ruby_gc_stress		objspace->gc_stress
+#define ruby_gc_not_lazy_sweep	objspace->gc_not_lazy_sweep
 
 #define need_call_final 	(finalizer_table && finalizer_table->num_entries)
 
@@ -1446,7 +1448,6 @@
 
 #define GC_NOT_LAZY_SWEEP 0
 
-#ifdef GC_NOT_LAZY_SWEEP
 static void
 heap_all_sweep(rb_objspace_t *objspace)
 {
@@ -1455,7 +1456,6 @@
 	heaps_sweep_index++;
     }
 }
-#endif
 
 static int
 gc_lazy_sweep(rb_objspace_t *objspace, rb_thread_t *th)
@@ -1468,9 +1468,9 @@
 	heap_sweep(objspace);
     }
 
-#ifdef GC_NOT_LAZY_SWEEP
-    if (GC_NOT_LAZY_SWEEP) heap_all_sweep(objspace);
-#endif
+    if (ruby_gc_not_lazy_sweep || GC_NOT_LAZY_SWEEP) {
+        heap_all_sweep(objspace);
+    }
 
     if (!freelist) {
 	return Qfalse;
@@ -1813,13 +1813,17 @@
 static int
 garbage_collect_force(rb_objspace_t *objspace)
 {
+    int is_gc_success;
+
     if (malloc_increase > malloc_limit) {
 	malloc_limit += (malloc_increase - malloc_limit) * (double)live / (heaps_used * HEAP_OBJ_LIMIT);
 	if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT;
     }
     malloc_increase = 0;
-    gc_marks(objspace, GET_THREAD());
-    return garbage_collect(objspace);
+    ruby_gc_not_lazy_sweep = Qtrue;
+    is_gc_success = garbage_collect(objspace);
+    ruby_gc_not_lazy_sweep = Qfalse;
+    return is_gc_success;
 }
 
 static int
@@ -1966,6 +1970,7 @@
 
 	p = heaps[i].slot; pend = p + heaps[i].limit;
 	for (;p < pend; p++) {
+	    if (!freelist) garbage_collect_force(objspace);
 	    if (p->as.basic.flags) {
 		switch (BUILTIN_TYPE(p)) {
 		  case T_NONE:

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

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