* gc.c: rename `RGENGC_THREEGEN' to `RGENGC_AGE2_PROMOTION'.

* gc.c (rgengc_rememberset_mark): don't promote, but remain in
  remember set for infant objects.
* gc.c (RVALUE_PROMOTE_INFANT, RVALUE_PROMOTE_YOUNG): count numbers
  in these functions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2014-04-08 13:36:02 +00:00
Родитель 1aa54bebaf
Коммит bdf4eb0615
2 изменённых файлов: 68 добавлений и 42 удалений

Просмотреть файл

@ -1,3 +1,13 @@
Tue Apr 8 22:31:44 2014 Koichi Sasada <ko1@atdot.net>
* gc.c: rename `RGENGC_THREEGEN' to `RGENGC_AGE2_PROMOTION'.
* gc.c (rgengc_rememberset_mark): don't promote, but remain in
remember set for infant objects.
* gc.c (RVALUE_PROMOTE_INFANT, RVALUE_PROMOTE_YOUNG): count numbers
in these functions.
Mon Apr 7 21:11:49 2014 Tanaka Akira <akr@fsij.org>
* ext/socket/socket.c (sock_s_getnameinfo): Save errno for EAI_SYSTEM.

100
gc.c
Просмотреть файл

@ -209,13 +209,13 @@ static ruby_gc_params_t gc_params = {
#define RGENGC_PROFILE 0
#endif
/* RGENGC_THREEGEN
* Enable/disable three gen GC.
/* RGENGC_AGE2_PROMOTION
* Enable/disable age2 promotion strategy
* 0: Infant gen -> Old gen
* 1: Infant gen -> Young -> Old gen
*/
#ifndef RGENGC_THREEGEN
#define RGENGC_THREEGEN 0
#ifndef RGENGC_AGE2_PROMOTION
#define RGENGC_AGE2_PROMOTION 0
#endif
/* RGENGC_ESTIMATE_OLDMALLOC
@ -233,7 +233,7 @@ static ruby_gc_params_t gc_params = {
#define RGENGC_DEBUG 0
#define RGENGC_CHECK_MODE 0
#define RGENGC_PROFILE 0
#define RGENGC_THREEGEN 0
#define RGENGC_AGE2_PROMOTION 0
#define RGENGC_ESTIMATE_OLDMALLOC 0
#endif /* USE_RGENGC */
@ -478,7 +478,7 @@ typedef struct rb_objspace {
size_t generated_shady_object_count;
size_t shade_operation_count;
size_t promote_infant_count;
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
size_t promote_young_count;
#endif
size_t remembered_normal_object_count;
@ -489,7 +489,7 @@ typedef struct rb_objspace {
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];
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
size_t promote_young_types[RUBY_T_MASK];
#endif
size_t remembered_normal_object_count_types[RUBY_T_MASK];
@ -528,7 +528,7 @@ typedef struct rb_objspace {
size_t remembered_shady_object_limit;
size_t old_object_count;
size_t old_object_limit;
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
size_t young_object_count;
#endif
@ -735,7 +735,7 @@ check_gen_consistency(VALUE obj)
rb_bug("check_gen_consistency: %p (%s) is not WB protected, but %s object.", (void *)obj, obj_type_name(obj), type);
}
#if !RGENGC_THREEGEN
#if !RGENGC_AGE2_PROMOTION
if (!old_flag) {
rb_bug("check_gen_consistency: %p (%s) is not infant, but is not old (on 2gen).", (void *)obj, obj_type_name(obj));
}
@ -772,7 +772,7 @@ static inline VALUE
RVALUE_OLD_P(VALUE obj)
{
check_gen_consistency(obj);
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
return FL_TEST2(obj, FL_PROMOTED) && RVALUE_OLD_BITMAP_P(obj);
#else
return FL_TEST2(obj, FL_PROMOTED);
@ -787,14 +787,25 @@ RVALUE_PROMOTED_P(VALUE obj)
}
static inline void
RVALUE_PROMOTE_INFANT(VALUE obj)
RVALUE_PROMOTE_INFANT(rb_objspace_t *objspace, VALUE obj)
{
check_gen_consistency(obj);
if (RGENGC_CHECK_MODE && !RVALUE_INFANT_P(obj)) rb_bug("RVALUE_PROMOTE_INFANT: %p (%s) is not infant object.", (void *)obj, obj_type_name(obj));
FL_SET2(obj, FL_PROMOTED);
#if !RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
/* infant -> young */
objspace->rgengc.young_object_count++;
#else
/* infant -> old */
objspace->rgengc.old_object_count++;
#endif
#if !RGENGC_AGE2_PROMOTION
MARK_IN_BITMAP(GET_HEAP_OLDGEN_BITS(obj), obj);
#endif
check_gen_consistency(obj);
#if RGENGC_PROFILE >= 1
@ -809,10 +820,10 @@ RVALUE_PROMOTE_INFANT(VALUE obj)
#endif
}
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
/*
* Two gen: Infant -> Old.
* Three gen: Infant -> Young -> Old.
* Age1 promotion: Infant (0) -> Old (1 and later).
* Age2 promotion: Infant (0) -> Young (1) -> Old (2 and later).
*/
static inline VALUE
RVALUE_YOUNG_P(VALUE obj)
@ -822,11 +833,14 @@ RVALUE_YOUNG_P(VALUE obj)
}
static inline void
RVALUE_PROMOTE_YOUNG(VALUE obj)
RVALUE_PROMOTE_YOUNG(rb_objspace_t *objspace, VALUE obj)
{
check_gen_consistency(obj);
if (RGENGC_CHECK_MODE && !RVALUE_YOUNG_P(obj)) rb_bug("RVALUE_PROMOTE_YOUNG: %p (%s) is not young object.", (void *)obj, obj_type_name(obj));
MARK_IN_BITMAP(GET_HEAP_OLDGEN_BITS(obj), obj);
objspace->rgengc.old_object_count++;
check_gen_consistency(obj);
#if RGENGC_PROFILE >= 1
@ -2996,7 +3010,7 @@ gc_after_sweep(rb_objspace_t *objspace)
(int)objspace->profile.major_gc_count,
(int)objspace->profile.minor_gc_count,
(int)objspace->profile.promote_infant_count,
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
(int)objspace->profile.promote_young_count,
#else
0,
@ -3571,7 +3585,7 @@ rgengc_check_relation(rb_objspace_t *objspace, VALUE obj)
objspace->rgengc.remembered_shady_object_count++;
}
}
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
else {
if (gc_marked(objspace, obj)) {
if (!RVALUE_OLD_P(obj)) {
@ -3581,7 +3595,7 @@ rgengc_check_relation(rb_objspace_t *objspace, VALUE obj)
}
else {
if (RVALUE_INFANT_P(obj)) {
RVALUE_PROMOTE_INFANT(obj);
RVALUE_PROMOTE_INFANT(objspace, obj);
}
}
}
@ -3665,14 +3679,10 @@ 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((VALUE)obj);
#if RGENGC_THREEGEN
/* infant -> young */
objspace->rgengc.young_object_count++;
RVALUE_PROMOTE_INFANT(objspace, (VALUE)obj);
#if RGENGC_AGE2_PROMOTION
objspace->rgengc.parent_object_is_old = FALSE;
#else
/* infant -> old */
objspace->rgengc.old_object_count++;
objspace->rgengc.parent_object_is_old = TRUE;
#endif
rgengc_report(3, objspace, "gc_mark_children: promote infant -> young %p (%s).\n", (void *)obj, obj_type_name((VALUE)obj));
@ -3680,11 +3690,10 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr)
else {
objspace->rgengc.parent_object_is_old = TRUE;
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
if (RVALUE_YOUNG_P((VALUE)obj)) {
/* young -> old */
RVALUE_PROMOTE_YOUNG((VALUE)obj);
objspace->rgengc.old_object_count++;
RVALUE_PROMOTE_YOUNG(objspace, (VALUE)obj);
rgengc_report(3, objspace, "gc_mark_children: promote young -> old %p (%s).\n", (void *)obj, obj_type_name((VALUE)obj));
}
else {
@ -3693,7 +3702,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr)
/* major/full GC */
objspace->rgengc.old_object_count++;
}
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
}
#endif
}
@ -4523,7 +4532,7 @@ gc_marks(rb_objspace_t *objspace, int full_mark)
if (full_mark == TRUE) { /* major/full GC */
objspace->rgengc.remembered_shady_object_count = 0;
objspace->rgengc.old_object_count = 0;
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
objspace->rgengc.young_object_count = 0;
#endif
@ -4691,11 +4700,18 @@ rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap)
if (RVALUE_WB_PROTECTED(p)) {
rgengc_report(2, objspace, "rgengc_rememberset_mark: clear %p (%s)\n", p, obj_type_name((VALUE)p));
#if RGENGC_THREEGEN
if (RVALUE_INFANT_P((VALUE)p)) RVALUE_PROMOTE_INFANT((VALUE)p);
if (RVALUE_YOUNG_P((VALUE)p)) RVALUE_PROMOTE_YOUNG((VALUE)p);
#endif
#if RGENGC_AGE2_PROMOTION
if (RVALUE_INFANT_P((VALUE)p)) {
/* infant objects should remain in remembered because remembered objects should become old objects */
/* young objects become old objects soon */
}
else {
CLEAR_IN_BITMAP(bits, p);
}
#else
CLEAR_IN_BITMAP(bits, p);
#endif
#if RGENGC_PROFILE > 0
clear_count++;
#endif
@ -4798,7 +4814,7 @@ rb_gc_writebarrier_unprotect_promoted(VALUE obj)
#endif /* RGENGC_PROFILE >= 2 */
#endif /* RGENGC_PROFILE */
}
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
else {
RVALUE_DEMOTE_FROM_YOUNG(obj);
}
@ -4878,7 +4894,7 @@ rb_obj_gc_flags(VALUE obj, ID* flags, size_t max)
static ID ID_marked;
#if USE_RGENGC
static ID ID_wb_protected, ID_old, ID_remembered;
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
static ID ID_young, ID_infant;
#endif
#endif
@ -4890,7 +4906,7 @@ rb_obj_gc_flags(VALUE obj, ID* flags, size_t max)
I(wb_protected);
I(old);
I(remembered);
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
I(young);
I(infant);
#endif
@ -4903,7 +4919,7 @@ rb_obj_gc_flags(VALUE obj, ID* flags, size_t max)
flags[n++] = ID_wb_protected;
if (RVALUE_OLD_P(obj) && n<max)
flags[n++] = ID_old;
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
if (RVALUE_YOUNG_P(obj) && n<max)
flags[n++] = ID_young;
if (RVALUE_INFANT_P(obj) && n<max)
@ -5488,7 +5504,7 @@ gc_stat_internal(VALUE hash_or_sym, size_t *out)
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);
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
SET(promote_young_count, objspace->profile.promote_young_count);
#endif
SET(remembered_normal_object_count, objspace->profile.remembered_normal_object_count);
@ -5507,7 +5523,7 @@ gc_stat_internal(VALUE hash_or_sym, size_t *out)
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);
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
gc_count_add_each_types(hash, "promote_young_types", objspace->profile.promote_young_types);
#endif
gc_count_add_each_types(hash, "remembered_normal_object_count_types", objspace->profile.remembered_normal_object_count_types);
@ -7445,7 +7461,7 @@ rb_gcdebug_print_obj_condition(VALUE obj)
fprintf(stderr, "marked? : %s\n", MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj) ? "true" : "false");
#if USE_RGENGC
#if RGENGC_THREEGEN
#if RGENGC_AGE2_PROMOTION
fprintf(stderr, "young? : %s\n", RVALUE_YOUNG_P(obj) ? "true" : "false");
#endif
fprintf(stderr, "old? : %s\n", RVALUE_OLD_P(obj) ? "true" : "false");
@ -7631,7 +7647,7 @@ Init_GC(void)
OPT(RGENGC_DEBUG);
OPT(RGENGC_CHECK_MODE);
OPT(RGENGC_PROFILE);
OPT(RGENGC_THREEGEN);
OPT(RGENGC_AGE2_PROMOTION);
OPT(RGENGC_ESTIMATE_OLDMALLOC);
OPT(GC_PROFILE_MORE_DETAIL);
OPT(GC_ENABLE_LAZY_SWEEP);