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

ruby-changes:35405

From: ko1 <ko1@a...>
Date: Wed, 10 Sep 2014 07:32:26 +0900 (JST)
Subject: [ruby-changes:35405] ko1:r47487 (trunk): * gc.c: refactoring for RGENGC_PROFILE > 0.

ko1	2014-09-10 07:32:09 +0900 (Wed, 10 Sep 2014)

  New Revision: 47487

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

  Log:
    * gc.c: refactoring for RGENGC_PROFILE > 0.
      * rename rb_objspace_t::profile::..._count
        to rb_objspace_t::profile::total_..._count
      * rename promote_infant_types to promote_types
    * gc.c (gc_remember_unprotected): count remembered shady objects here.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47486)
+++ ChangeLog	(revision 47487)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Sep 10 07:22:53 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c: refactoring for RGENGC_PROFILE > 0.
+
+	  * rename rb_objspace_t::profile::..._count
+	    to rb_objspace_t::profile::total_..._count
+	  * rename promote_infant_types to promote_types
+
+	* gc.c (gc_remember_unprotected): count remembered shady objects here.
+
 Wed Sep 10 03:12:12 2014  CHIKANAGA Tomoyuki  <nagachika@r...>
 
 	* gc.c (init_mark_stack): MEMZERO() receive type as 2nd argument instead
Index: gc.c
===================================================================
--- gc.c	(revision 47486)
+++ gc.c	(revision 47487)
@@ -531,18 +531,18 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L531
 	size_t minor_gc_count;
 	size_t major_gc_count;
 #if RGENGC_PROFILE > 0
-	size_t generated_normal_object_count;
-	size_t generated_shady_object_count;
-	size_t shade_operation_count;
-	size_t promote_infant_count;
-	size_t remembered_normal_object_count;
-	size_t remembered_shady_object_count;
+	size_t total_generated_normal_object_count;
+	size_t total_generated_shady_object_count;
+	size_t total_shade_operation_count;
+	size_t total_promoted_count;
+	size_t total_remembered_normal_object_count;
+	size_t total_remembered_shady_object_count;
 
 #if RGENGC_PROFILE >= 2
 	size_t generated_normal_object_count_types[RUBY_T_MASK];
 	size_t generated_shady_object_count_types[RUBY_T_MASK];
 	size_t shade_operation_count_types[RUBY_T_MASK];
-	size_t promote_infant_types[RUBY_T_MASK];
+	size_t promoted_types[RUBY_T_MASK];
 	size_t remembered_normal_object_count_types[RUBY_T_MASK];
 	size_t remembered_shady_object_count_types[RUBY_T_MASK];
 #endif
@@ -1052,14 +1052,9 @@ RVALUE_PROMOTE_RAW(rb_objspace_t *objspa https://github.com/ruby/ruby/blob/trunk/gc.c#L1052
     MARK_IN_BITMAP(GET_HEAP_LONG_LIVED_BITS(obj), obj);
     objspace->rgengc.old_object_count++;
 
-#if RGENGC_PROFILE >= 1
-    {
-	rb_objspace_t *objspace = &rb_objspace;
-	objspace->profile.promoted_count++;
 #if RGENGC_PROFILE >= 2
-	objspace->profile.promoted_types[BUILTIN_TYPE(obj)]++;
-#endif
-    }
+    objspace->profile.total_promoted_count++;
+    objspace->profile.promoted_types[BUILTIN_TYPE(obj)]++;
 #endif
 }
 
@@ -1626,6 +1621,8 @@ newobj_of(VALUE klass, VALUE flags, VALU https://github.com/ruby/ruby/blob/trunk/gc.c#L1621
     assert(RVALUE_MARKING(obj) == FALSE);
     assert(RVALUE_OLD_P(obj) == FALSE);
     assert(RVALUE_WB_UNPROTECTED(obj) == FALSE);
+    if (RVALUE_AGE(obj) > 0) rb_bug("newobj: %s of age (%d) > 0.", obj_info(obj), RVALUE_AGE(obj));
+    if (rgengc_remembered(objspace, (VALUE)obj)) rb_bug("newobj: %s is remembered.", obj_info(obj));
 #endif
 
 #if USE_RGENGC
@@ -1634,37 +1631,30 @@ newobj_of(VALUE klass, VALUE flags, VALU https://github.com/ruby/ruby/blob/trunk/gc.c#L1631
     }
 #endif
 
-#if GC_DEBUG
-    RANY(obj)->file = rb_sourcefile();
-    RANY(obj)->line = rb_sourceline();
-    assert(!SPECIAL_CONST_P(obj)); /* check alignment */
-#endif
-
 #if RGENGC_PROFILE
     if (flags & FL_WB_PROTECTED) {
-	objspace->profile.generated_normal_object_count++;
+	objspace->profile.total_generated_normal_object_count++;
 #if RGENGC_PROFILE >= 2
 	objspace->profile.generated_normal_object_count_types[BUILTIN_TYPE(obj)]++;
 #endif
     }
     else {
-	objspace->profile.generated_shady_object_count++;
+	objspace->profile.total_generated_shady_object_count++;
 #if RGENGC_PROFILE >= 2
 	objspace->profile.generated_shady_object_count_types[BUILTIN_TYPE(obj)]++;
 #endif
     }
 #endif
 
-    gc_report(5, objspace, "newobj: %s\n", obj_info(obj));
-
-#if USE_RGENGC && RGENGC_CHECK_MODE
-    if (RVALUE_AGE(obj) > 0) rb_bug("newobj: %s of age (%d) > 0.", obj_info(obj), RVALUE_AGE(obj));
-    if (rgengc_remembered(objspace, (VALUE)obj)) rb_bug("newobj: %s is remembered.", obj_info(obj));
+#if GC_DEBUG
+    RANY(obj)->file = rb_sourcefile();
+    RANY(obj)->line = rb_sourceline();
+    assert(!SPECIAL_CONST_P(obj)); /* check alignment */
 #endif
 
     objspace->total_allocated_objects++;
     gc_event_hook(objspace, RUBY_INTERNAL_EVENT_NEWOBJ, obj);
-
+    gc_report(5, objspace, "newobj: %s\n", obj_info(obj));
     return obj;
 }
 
@@ -3250,17 +3240,6 @@ gc_sweep_finish(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L3240
 	heap_allocatable_pages = heap_tomb->page_length;
     }
 
-#if RGENGC_PROFILE > 0
-    if (0) {
-	fprintf(stderr, "%d\t%d\t%d\t%d\t%d\t%d\n",
-		(int)rb_gc_count(),
-		(int)objspace->profile.major_gc_count,
-		(int)objspace->profile.minor_gc_count,
-		(int)objspace->profile.promote_infant_count,
-		(int)objspace->profile.remembered_normal_object_count,
-		(int)objspace->rgengc.remembered_shady_object_count);
-    }
-#endif
     gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END_SWEEP, 0);
     gc_stat_transition(objspace, gc_stat_none);
 
@@ -3901,6 +3880,13 @@ gc_remember_unprotected(rb_objspace_t *o https://github.com/ruby/ruby/blob/trunk/gc.c#L3880
 	page->flags.has_long_lived_shady_objects = TRUE;
 	MARK_IN_BITMAP(bits, obj);
 	objspace->rgengc.remembered_shady_object_count++;
+
+#if RGENGC_PROFILE > 0
+	objspace->profile.total_remembered_shady_object_count++;
+#if RGENGC_PROFILE >= 2
+	objspace->profile.remembered_shady_object_count_types[BUILTIN_TYPE(obj)]++;
+#endif
+#endif
 	return TRUE;
     }
     else {
@@ -5198,28 +5184,20 @@ rgengc_remember(rb_objspace_t *objspace, https://github.com/ruby/ruby/blob/trunk/gc.c#L5184
 
     check_rvalue_consistency(obj);
 
-    if (RGENGC_PROFILE) {
-	if (!rgengc_remembered(objspace, obj)) {
+    if (RGENGC_CHECK_MODE) {
+	if (RVALUE_WB_UNPROTECTED(obj)) rb_bug("rgengc_remember: %s is not wb protected.", obj_info(obj));
+    }
+
 #if RGENGC_PROFILE > 0
-	    if (RVALUE_WB_UNPROTECTED(obj) == 0) {
-		objspace->profile.remembered_normal_object_count++;
+    if (!rgengc_remembered(objspace, obj)) {
+	if (RVALUE_WB_UNPROTECTED(obj) == 0) {
+	    objspace->profile.total_remembered_normal_object_count++;
 #if RGENGC_PROFILE >= 2
-		objspace->profile.remembered_normal_object_count_types[BUILTIN_TYPE(obj)]++;
+	    objspace->profile.remembered_normal_object_count_types[BUILTIN_TYPE(obj)]++;
 #endif
-	    }
-	    else {
-		objspace->profile.remembered_shady_object_count++;
-#if RGENGC_PROFILE >= 2
-		objspace->profile.remembered_shady_object_count_types[BUILTIN_TYPE(obj)]++;
-#endif
-	    }
-#endif /* RGENGC_PROFILE > 0 */
 	}
     }
-
-    if (RGENGC_CHECK_MODE) {
-	if (RVALUE_WB_UNPROTECTED(obj)) rb_bug("rgengc_remember: %s is not wb protected.", obj_info(obj));
-    }
+#endif /* RGENGC_PROFILE > 0 */
 
     return rgengc_remembersetbits_set(objspace, obj);
 }
@@ -5414,7 +5392,7 @@ rb_gc_writebarrier_unprotect(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L5392
 	    gc_remember_unprotected(objspace, obj);
 
 #if RGENGC_PROFILE
-	    objspace->profile.shade_operation_count++;
+	    objspace->profile.total_shade_operation_count++;
 #if RGENGC_PROFILE >= 2
 	    objspace->profile.shade_operation_count_types[BUILTIN_TYPE(obj)]++;
 #endif /* RGENGC_PROFILE >= 2 */
@@ -6285,9 +6263,9 @@ gc_stat_internal(VALUE hash_or_sym) https://github.com/ruby/ruby/blob/trunk/gc.c#L6263
     static VALUE sym_oldmalloc_increase, sym_oldmalloc_limit;
 #endif
 #if RGENGC_PROFILE
-    static VALUE sym_generated_normal_object_count, sym_generated_shady_object_count;
-    static VALUE sym_shade_operation_count, sym_promote_infant_count, sym_promote_young_count;
-    static VALUE sym_remembered_normal_object_count, sym_remembered_shady_object_count;
+    static VALUE sym_total_generated_normal_object_count, sym_total_generated_shady_object_count;
+    static VALUE sym_total_shade_operation_count, sym_total_promoted_count;
+    static VALUE sym_total_remembered_normal_object_count, sym_total_remembered_shady_object_count;
 #endif /* RGENGC_PROFILE */
 #endif /* USE_RGENGC */
 
@@ -6333,13 +6311,12 @@ gc_stat_internal(VALUE hash_or_sym) https://github.com/ruby/ruby/blob/trunk/gc.c#L6311
 	S(oldmalloc_limit);
 #endif
 #if RGENGC_PROFILE
-	S(generated_normal_object_count);
-	S(generated_shady_object_count);
-	S(shade_operation_count);
-	S(promote_infant_count);
-	S(promote_young_count);
-	S(remembered_normal_object_count);
-	S(remembered_shady_object_count);
+	S(total_generated_normal_object_count);
+	S(total_generated_shady_object_count);
+	S(total_shade_operation_count);
+	S(total_promoted_count);
+	S(total_remembered_normal_object_count);
+	S(total_remembered_shady_object_count);
 #endif /* RGENGC_PROFILE */
 #endif /* USE_RGENGC */
 #undef S
@@ -6381,12 +6358,12 @@ gc_stat_internal(VALUE hash_or_sym) https://github.com/ruby/ruby/blob/trunk/gc.c#L6358
 #endif
 
 #if RGENGC_PROFILE
-    SET(generated_normal_object_count, objspace->profile.generated_normal_object_count);
-    SET(generated_shady_object_count, objspace->profile.generated_shady_object_count);
-    SET(shade_operation_count, objspace->profile.shade_operation_count);
-    SET(promote_infant_count, objspace->profile.promote_infant_count);
-    SET(remembered_normal_object_count, objspace->profile.remembered_normal_object_count);
-    SET(remembered_shady_object_count, objspace->profile.remembered_shady_object_count);
+    SET(total_generated_normal_object_count, objspace->profile.total_generated_normal_object_count);
+    SET(total_generated_shady_object_count, objspace->profile.total_generated_shady_object_count);
+    SET(total_shade_operation_count, objspace->profile.total_shade_operation_count);
+    SET(total_promoted_count, objspace->profile.total_promoted_count);
+    SET(total_remembered_normal_object_count, objspace->profile.total_remembered_normal_object_count);
+    SET(total_remembered_shady_object_count, objspace->profile.total_remembered_shady_object_count);
 #endif /* RGENGC_PROFILE */
 #endif /* USE_RGENGC */
 #undef SET
@@ -6400,7 +6377,7 @@ gc_stat_internal(VALUE hash_or_sym) https://github.com/ruby/ruby/blob/trunk/gc.c#L6377
 	gc_count_add_each_types(hash, "generated_normal_object_count_types", objspace->profile.generated_normal_object_count_types);
 	gc_count_add_each_types(hash, "generated_shady_object_count_types", objspace->profile.generated_shady_object_count_types);
 	gc_count_add_each_types(hash, "shade_operation_count_types", objspace->profile.shade_operation_count_types);
-	gc_count_add_each_types(hash, "promote_infant_types", objspace->profile.promote_infant_types);
+	gc_count_add_each_types(hash, "promoted_types", objspace->profile.promoted_types);
 	gc_count_add_each_types(hash, "remembered_normal_object_count_types", objspace->profile.remembered_normal_object_count_types);
 	gc_count_add_each_types(hash, "remembered_shady_object_count_types", objspace->profile.remembered_shady_object_count_types);
     }

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

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