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

ruby-changes:34541

From: ko1 <ko1@a...>
Date: Mon, 30 Jun 2014 15:14:49 +0900 (JST)
Subject: [ruby-changes:34541] ko1:r46622 (trunk): * gc.c: support `USE_RGENGC == 0'.

ko1	2014-06-30 15:14:37 +0900 (Mon, 30 Jun 2014)

  New Revision: 46622

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

  Log:
    * gc.c: support `USE_RGENGC == 0'.
    * test/ruby/test_gc.rb: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/test/ruby/test_gc.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46621)
+++ ChangeLog	(revision 46622)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jun 30 15:07:34 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c: support `USE_RGENGC == 0'.
+
+	* test/ruby/test_gc.rb: ditto.
+
 Mon Jun 30 11:36:04 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* file.c: [DOC] document File.join returns a string.
Index: gc.c
===================================================================
--- gc.c	(revision 46621)
+++ gc.c	(revision 46622)
@@ -3038,6 +3038,7 @@ gc_after_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L3038
 		  (int)heap->total_slots, (int)heap_pages_swept_slots, (int)heap_pages_min_free_slots);
 
     if (heap_pages_swept_slots < heap_pages_min_free_slots) {
+#if USE_RGENGC
 	if (objspace->rgengc.during_minor_gc && objspace->profile.count - objspace->rgengc.last_major_gc > 2 /* magic number */) {
 	    objspace->rgengc.need_major_gc = GPR_FLAG_MAJOR_BY_NOFREE;
 	}
@@ -3045,6 +3046,10 @@ gc_after_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L3046
 	    heap_set_increment(objspace, heap_extend_pages(objspace));
 	    heap_increment(objspace, heap);
 	}
+#else
+	heap_set_increment(objspace, heap_extend_pages(objspace));
+	heap_increment(objspace, heap);
+#endif
     }
 
     gc_prof_set_heap_info(objspace);
@@ -3709,6 +3714,7 @@ rb_gc_resurrect(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L3714
 	!is_swept_object(objspace, obj)) {
 	gc_mark_ptr(objspace, obj);
 
+#if USE_RGENGC
 	/* unmarked old objects means the last GC is major GC */
 	/* at major GC, old object count is reset.            */
 	/* So that resurrect also increment old object count  */
@@ -3721,6 +3727,7 @@ rb_gc_resurrect(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L3727
 	    objspace->rgengc.young_object_count++;
 	}
 #endif
+#endif
     }
 }
 
@@ -4518,20 +4525,22 @@ gc_marks_check(rb_objspace_t *objspace, https://github.com/ruby/ruby/blob/trunk/gc.c#L4525
 
 #endif /* RGENGC_CHECK_MODE >= 2 */
 
-#if USE_RGENGC
-
 struct verify_internal_consistency_struct {
     rb_objspace_t *objspace;
     int err_count;
     size_t live_object_count;
+    size_t zombie_object_count;
+
+#if USE_RGENGC
+    VALUE parent;
     size_t old_object_count;
 #if RGENGC_AGE2_PROMOTION
     size_t young_object_count;
 #endif
-    size_t zombie_object_count;
-    VALUE parent;
+#endif
 };
 
+#if USE_RGENGC
 static void
 verify_internal_consistency_reachable_i(VALUE child, void *ptr)
 {
@@ -4549,6 +4558,7 @@ verify_internal_consistency_reachable_i( https://github.com/ruby/ruby/blob/trunk/gc.c#L4558
 	}
     }
 }
+#endif
 
 static int
 verify_internal_consistency_i(void *page_start, void *page_end, size_t stride, void *ptr)
@@ -4558,9 +4568,10 @@ verify_internal_consistency_i(void *page https://github.com/ruby/ruby/blob/trunk/gc.c#L4568
 
     for (v = (VALUE)page_start; v != (VALUE)page_end; v += stride) {
 	if (is_live_object(data->objspace, v)) {
-
 	    /* count objects */
 	    data->live_object_count++;
+
+#if USE_RGENGC
 	    if (RVALUE_OLD_P(v)) {
 		data->old_object_count++;
 	    }
@@ -4574,6 +4585,7 @@ verify_internal_consistency_i(void *page https://github.com/ruby/ruby/blob/trunk/gc.c#L4585
 		/* reachable objects from an oldgen object should be old or (young with remember) */
 		rb_objspace_reachable_objects_from(v, verify_internal_consistency_reachable_i, (void *)data);
 	    }
+#endif
 	}
 	else {
 	    if (BUILTIN_TYPE(v) == T_ZOMBIE) {
@@ -4586,8 +4598,6 @@ verify_internal_consistency_i(void *page https://github.com/ruby/ruby/blob/trunk/gc.c#L4598
     return 0;
 }
 
-#endif /* USE_RGENGC */
-
 /*
  *  call-seq:
  *     GC.verify_internal_consistency                  -> nil
@@ -4601,9 +4611,8 @@ verify_internal_consistency_i(void *page https://github.com/ruby/ruby/blob/trunk/gc.c#L4611
 static VALUE
 gc_verify_internal_consistency(VALUE self)
 {
-#if USE_RGENGC
-    struct verify_internal_consistency_struct data = {0};
     rb_objspace_t *objspace = &rb_objspace;
+    struct verify_internal_consistency_struct data = {0};
     data.objspace = objspace;
 
     {
@@ -4612,16 +4621,15 @@ gc_verify_internal_consistency(VALUE sel https://github.com/ruby/ruby/blob/trunk/gc.c#L4621
 	eo_args.data = (void *)&data;
 	objspace_each_objects((VALUE)&eo_args);
     }
+
     if (data.err_count != 0) {
 #if RGENGC_CHECK_MODE >= 4
-	rb_objspace_t *objspace = &rb_objspace;
 	objspace->rgengc.error_count = data.err_count;
 	gc_marks_check(objspace, NULL, NULL);
 	allrefs_dump(objspace);
 #endif
 	rb_bug("gc_verify_internal_consistency: found internal inconsistency.");
     }
-#endif
 
     if (!is_lazy_sweeping(heap_eden) && !finalizing) {
 	if (objspace_live_slot(objspace) != data.live_object_count) {
@@ -4630,6 +4638,8 @@ gc_verify_internal_consistency(VALUE sel https://github.com/ruby/ruby/blob/trunk/gc.c#L4638
 	    rb_bug("inconsistent live slot nubmer: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace_live_slot(objspace), data.live_object_count);
 	}
     }
+
+#if USE_RGENGC
     if (objspace->rgengc.old_object_count != data.old_object_count) {
 	rb_bug("inconsistent old slot nubmer: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace->rgengc.old_object_count, data.old_object_count);
     }
@@ -4638,6 +4648,7 @@ gc_verify_internal_consistency(VALUE sel https://github.com/ruby/ruby/blob/trunk/gc.c#L4648
 	rb_bug("inconsistent young slot nubmer: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace->rgengc.young_object_count, data.young_object_count);
     }
 #endif
+#endif
 
     if (!finalizing) {
 	size_t list_count = 0;
Index: test/ruby/test_gc.rb
===================================================================
--- test/ruby/test_gc.rb	(revision 46621)
+++ test/ruby/test_gc.rb	(revision 46622)
@@ -35,6 +35,10 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L35
     GC.stress = prev_stress
   end
 
+  def use_rgengc?
+    GC::OPTS.include? 'USE_RGENGC'.freeze
+  end
+
   def test_enable_disable
     GC.enable
     assert_equal(false, GC.enable)
@@ -49,6 +53,8 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L53
   end
 
   def test_start_full_mark
+    return unless use_rgengc?
+
     GC.start(full_mark: false)
     assert_nil GC.latest_gc_info(:major_by)
 
@@ -112,7 +118,7 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L118
     assert_equal :newobj, GC.latest_gc_info[:gc_by]
 
     GC.start
-    assert_equal :nofree, GC.latest_gc_info[:major_by]
+    assert_equal :nofree, GC.latest_gc_info[:major_by] if use_rgengc?
     assert_equal :method, GC.latest_gc_info[:gc_by]
     assert_equal true, GC.latest_gc_info[:immediate_sweep]
 
@@ -190,8 +196,9 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L196
     }
     assert_normal_exit("exit", "", :child_env => env)
     assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=0\.9/, "")
+
     # always full GC when RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR < 1.0
-    assert_in_out_err([env, "-e", "1000_000.times{Object.new}; p(GC.stat[:minor_gc_count] < GC.stat[:major_gc_count])"], "", ['true'], //, "")
+    assert_in_out_err([env, "-e", "1000_000.times{Object.new}; p(GC.stat[:minor_gc_count] < GC.stat[:major_gc_count])"], "", ['true'], //, "") if use_rgengc?
 
     # check obsolete
     assert_in_out_err([{'RUBY_FREE_MIN' => '100'}, '-w', '-eexit'], '', [],
@@ -209,15 +216,17 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L216
     assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_MALLOC_LIMIT_MAX=16000000/, "")
     assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=2.0/, "")
 
-    env = {
-      "RUBY_GC_OLDMALLOC_LIMIT"               => "60000000",
-      "RUBY_GC_OLDMALLOC_LIMIT_MAX"           => "160000000",
-      "RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR" => "2.0"
-    }
-    assert_normal_exit("exit", "", :child_env => env)
-    assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT=6000000/, "")
-    assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT_MAX=16000000/, "")
-    assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=2.0/, "")
+    if use_rgengc?
+      env = {
+        "RUBY_GC_OLDMALLOC_LIMIT"               => "60000000",
+        "RUBY_GC_OLDMALLOC_LIMIT_MAX"           => "160000000",
+        "RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR" => "2.0"
+      }
+      assert_normal_exit("exit", "", :child_env => env)
+      assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT=6000000/, "")
+      assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT_MAX=16000000/, "")
+      assert_in_out_err([env, "-w", "-e", "exit"], "", [], /RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=2.0/, "")
+    end
   end
 
   def test_profiler_enabled

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

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