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

ruby-changes:34844

From: ko1 <ko1@a...>
Date: Thu, 24 Jul 2014 20:13:36 +0900 (JST)
Subject: [ruby-changes:34844] ko1:r46927 (trunk): * gc.c: fix major GC flags.

ko1	2014-07-24 20:13:19 +0900 (Thu, 24 Jul 2014)

  New Revision: 46927

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

  Log:
    * gc.c: fix major GC flags.
      * add GPR_FLAG_MAJOR_BY_FORCE, which indicates
        major GC by METHOD, CAPI and so on (see GC_BY).
      * remove GPR_FLAG_MAJOR_BY_RESCAN because not used.
      * remove GPR_FLAG_MAJOR_BY_STRESS, use FORCE instead.
    * test/ruby/test_gc.rb: catch up.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/test/ruby/test_gc.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46926)
+++ ChangeLog	(revision 46927)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jul 24 20:10:59 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c: fix major GC flags.
+	  * add GPR_FLAG_MAJOR_BY_FORCE, which indicates
+	    major GC by METHOD, CAPI and so on (see GC_BY).
+	  * remove GPR_FLAG_MAJOR_BY_RESCAN because not used.
+	  * remove GPR_FLAG_MAJOR_BY_STRESS, use FORCE instead.
+
+	* test/ruby/test_gc.rb: catch up.
+
 Thu Jul 24 15:55:02 2014  Naohisa Goto  <ngotogenome@g...>
 
 	* include/ruby/io.h (struct rb_io_buffer_t): PACKED_STRUCT should not
Index: gc.c
===================================================================
--- gc.c	(revision 46926)
+++ gc.c	(revision 46927)
@@ -274,8 +274,7 @@ typedef enum { https://github.com/ruby/ruby/blob/trunk/gc.c#L274
     GPR_FLAG_MAJOR_BY_NOFREE    = 0x001,
     GPR_FLAG_MAJOR_BY_OLDGEN    = 0x002,
     GPR_FLAG_MAJOR_BY_SHADY     = 0x004,
-    GPR_FLAG_MAJOR_BY_RESCAN    = 0x008,
-    GPR_FLAG_MAJOR_BY_STRESS    = 0x010,
+    GPR_FLAG_MAJOR_BY_FORCE     = 0x008,
 #if RGENGC_ESTIMATE_OLDMALLOC
     GPR_FLAG_MAJOR_BY_OLDMALLOC = 0x020,
 #endif
@@ -5208,10 +5207,10 @@ garbage_collect_body(rb_objspace_t *objs https://github.com/ruby/ruby/blob/trunk/gc.c#L5207
     if (ruby_gc_stress && !ruby_disable_gc_stress) {
 	int flag = FIXNUM_P(ruby_gc_stress) ? FIX2INT(ruby_gc_stress) : 0;
 
-	if (flag & (1<<gc_stress_no_major))
-	    reason &= ~GPR_FLAG_MAJOR_MASK;
-	else
-	    reason |= GPR_FLAG_MAJOR_BY_STRESS;
+	if ((flag & (1<<gc_stress_no_major)) == 0) {
+	    full_mark = TRUE;
+	}
+
 	immediate_sweep = !(flag & (1<<gc_stress_no_immediate_sweep));
     }
     else {
@@ -5219,24 +5218,27 @@ garbage_collect_body(rb_objspace_t *objs https://github.com/ruby/ruby/blob/trunk/gc.c#L5218
 	    immediate_sweep = TRUE;
 	}
 #if USE_RGENGC
-	if (full_mark) {
-	    reason |= GPR_FLAG_MAJOR_BY_NOFREE;
-	}
 	if (objspace->rgengc.need_major_gc) {
 	    reason |= objspace->rgengc.need_major_gc;
 	    objspace->rgengc.need_major_gc = GPR_FLAG_NONE;
+	    full_mark = TRUE;
 	}
 	if (objspace->rgengc.remembered_shady_object_count > objspace->rgengc.remembered_shady_object_limit) {
 	    reason |= GPR_FLAG_MAJOR_BY_SHADY;
+	    full_mark = TRUE;
 	}
 	if (objspace->rgengc.old_object_count > objspace->rgengc.old_object_limit) {
 	    reason |= GPR_FLAG_MAJOR_BY_OLDGEN;
+	    full_mark = TRUE;
 	}
 #endif
     }
 
+    if (full_mark && (reason & GPR_FLAG_MAJOR_MASK) == 0) {
+	reason |= GPR_FLAG_MAJOR_BY_FORCE; /* GC by CAPI, METHOD, and so on. */
+    }
+
     if (immediate_sweep) reason |= GPR_FLAG_IMMEDIATE_SWEEP;
-    full_mark = (reason & GPR_FLAG_MAJOR_MASK) ? TRUE : FALSE;
 
     if (GC_NOTIFY)  fprintf(stderr, "start garbage_collect(%d, %d, %d)\n", full_mark, immediate_sweep, reason);
 
@@ -5479,7 +5481,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L5481
 gc_info_decode(int flags, VALUE hash_or_key)
 {
     static VALUE sym_major_by = Qnil, sym_gc_by, sym_immediate_sweep, sym_have_finalizer;
-    static VALUE sym_nofree, sym_oldgen, sym_shady, sym_rescan, sym_stress;
+    static VALUE sym_nofree, sym_oldgen, sym_shady, sym_force, sym_stress;
 #if RGENGC_ESTIMATE_OLDMALLOC
     static VALUE sym_oldmalloc;
 #endif
@@ -5500,11 +5502,11 @@ gc_info_decode(int flags, VALUE hash_or_ https://github.com/ruby/ruby/blob/trunk/gc.c#L5502
 	S(gc_by);
 	S(immediate_sweep);
 	S(have_finalizer);
+	S(stress);
 	S(nofree);
 	S(oldgen);
 	S(shady);
-	S(rescan);
-	S(stress);
+	S(force);
 #if RGENGC_ESTIMATE_OLDMALLOC
 	S(oldmalloc);
 #endif
@@ -5522,14 +5524,13 @@ gc_info_decode(int flags, VALUE hash_or_ https://github.com/ruby/ruby/blob/trunk/gc.c#L5524
 	rb_hash_aset(hash, sym_##name, (attr));
 
     major_by =
+      (flags & GPR_FLAG_MAJOR_BY_NOFREE) ? sym_nofree :
       (flags & GPR_FLAG_MAJOR_BY_OLDGEN) ? sym_oldgen :
       (flags & GPR_FLAG_MAJOR_BY_SHADY)  ? sym_shady :
-      (flags & GPR_FLAG_MAJOR_BY_RESCAN) ? sym_rescan :
-      (flags & GPR_FLAG_MAJOR_BY_STRESS) ? sym_stress :
+      (flags & GPR_FLAG_MAJOR_BY_FORCE)  ? sym_force :
 #if RGENGC_ESTIMATE_OLDMALLOC
       (flags & GPR_FLAG_MAJOR_BY_OLDMALLOC) ? sym_oldmalloc :
 #endif
-      (flags & GPR_FLAG_MAJOR_BY_NOFREE) ? sym_nofree :
       Qnil;
     SET(major_by, major_by);
 
Index: test/ruby/test_gc.rb
===================================================================
--- test/ruby/test_gc.rb	(revision 46926)
+++ test/ruby/test_gc.rb	(revision 46927)
@@ -118,12 +118,12 @@ 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] if use_rgengc?
+    assert_equal :force, 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]
 
     GC.stress = true
-    assert_equal :stress, GC.latest_gc_info[:major_by]
+    assert_equal :force, GC.latest_gc_info[:major_by]
   ensure
     GC.stress = false
   end

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

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