1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* gc.c: change the counting method for young objects.

clear counter at the beggining of every GC and
  count promoted (infant->young) objects.
  Some promotions (infant->young) are transition of promoting to old
  objects. We should not count such promotions.
  With this technique, we don't need to check young objects
  at obj_free().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2014-06-03 09:00:53 +00:00
parent 9d71a0ae33
commit 2e437f8b45
2 changed files with 29 additions and 11 deletions

View file

@ -1,3 +1,15 @@
Tue Jun 3 17:54:21 2014 Koichi Sasada <ko1@atdot.net>
* gc.c: change the counting method for young objects.
clear counter at the beggining of every GC and
count promoted (infant->young) objects.
Some promotions (infant->young) are transition of promoting to old
objects. We should not count such promotions.
With this technique, we don't need to check young objects
at obj_free().
Tue Jun 3 16:38:19 2014 Koichi Sasada <ko1@atdot.net>
* gc.c: add verifying counters code in gc_verify_internal_consistency().

26
gc.c
View file

@ -801,7 +801,7 @@ RVALUE_PROMOTED_P(VALUE obj)
}
static inline void
RVALUE_PROMOTE_INFANT(rb_objspace_t *objspace, VALUE obj)
RVALUE_PROMOTE_INFANT(rb_objspace_t *objspace, VALUE obj, int add)
{
check_gen_consistency(obj);
@ -810,7 +810,9 @@ RVALUE_PROMOTE_INFANT(rb_objspace_t *objspace, VALUE obj)
#if RGENGC_AGE2_PROMOTION
/* infant -> young */
if (add) {
objspace->rgengc.young_object_count++;
}
#else
/* infant -> old */
objspace->rgengc.old_object_count++;
@ -857,7 +859,6 @@ RVALUE_PROMOTE_YOUNG(rb_objspace_t *objspace, VALUE obj)
MARK_IN_BITMAP(GET_HEAP_OLDGEN_BITS(obj), obj);
objspace->rgengc.young_object_count--;
objspace->rgengc.old_object_count++;
check_gen_consistency(obj);
@ -1553,11 +1554,6 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
}
#if USE_RGENGC
#if RGENGC_AGE2_PROMOTION
if (RVALUE_YOUNG_P(obj)) {
objspace->rgengc.young_object_count--;
}
#endif
if (MARKED_IN_BITMAP(GET_HEAP_OLDGEN_BITS(obj), obj)) {
CLEAR_IN_BITMAP(GET_HEAP_OLDGEN_BITS(obj), obj);
}
@ -3638,7 +3634,7 @@ rgengc_check_relation(rb_objspace_t *objspace, VALUE obj)
}
else {
if (RVALUE_INFANT_P(obj)) {
RVALUE_PROMOTE_INFANT(objspace, obj);
RVALUE_PROMOTE_INFANT(objspace, obj, FALSE);
}
}
}
@ -3697,6 +3693,12 @@ rb_gc_resurrect(VALUE obj)
if (RVALUE_OLD_P(obj)) {
objspace->rgengc.old_object_count++;
}
#if RGENGC_AGE2_PROMOTION
/* similar reason of old object counts */
else if (RVALUE_YOUNG_P(obj)) {
objspace->rgengc.young_object_count++;
}
#endif
}
}
@ -3729,7 +3731,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr)
if (RVALUE_WB_PROTECTED(obj)) {
if (RVALUE_INFANT_P((VALUE)obj)) {
/* infant -> young */
RVALUE_PROMOTE_INFANT(objspace, (VALUE)obj);
RVALUE_PROMOTE_INFANT(objspace, (VALUE)obj, TRUE);
#if RGENGC_AGE2_PROMOTION
objspace->rgengc.parent_object_is_old = FALSE;
#else
@ -4221,6 +4223,10 @@ gc_marks_body(rb_objspace_t *objspace, int full_mark)
objspace->rgengc.parent_object_is_old = FALSE;
objspace->rgengc.during_minor_gc = full_mark ? FALSE : TRUE;
#if RGENGC_AGE2_PROMOTION
objspace->rgengc.young_object_count = 0;
#endif
if (objspace->rgengc.during_minor_gc) {
objspace->profile.minor_gc_count++;
rgengc_rememberset_mark(objspace, heap_eden);
@ -4797,7 +4803,7 @@ rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap)
rgengc_report(2, objspace, "rgengc_rememberset_mark: clear %p (%s)\n", p, obj_type_name((VALUE)p));
#if RGENGC_AGE2_PROMOTION
if (RVALUE_INFANT_P((VALUE)p)) {
RVALUE_PROMOTE_INFANT(objspace, (VALUE)p);
RVALUE_PROMOTE_INFANT(objspace, (VALUE)p, FALSE);
RVALUE_PROMOTE_YOUNG(objspace, (VALUE)p);
}
else if (RVALUE_YOUNG_P((VALUE)p)) {