8000 [GC] Expose need_major_gc via GC.latest_gc_info · ruby/ruby@10d3ebe · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 10d3ebe

Browse files
committed
[GC] Expose need_major_gc via GC.latest_gc_info
1 parent 20b9d7b commit 10d3ebe

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

gc.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10955,16 +10955,17 @@ gc_count(rb_execution_context_t 10000 *ec, VALUE self)
1095510955
static VALUE
1095610956
gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned int orig_flags)
1095710957
{
10958-
static VALUE sym_major_by = Qnil, sym_gc_by, sym_immediate_sweep, sym_have_finalizer, sym_state;
10958+
static VALUE sym_major_by = Qnil, sym_gc_by, sym_immediate_sweep, sym_have_finalizer, sym_state, sym_need_major_by;
1095910959
static VALUE sym_nofree, sym_oldgen, sym_shady, sym_force, sym_stress;
1096010960
#if RGENGC_ESTIMATE_OLDMALLOC
1096110961
static VALUE sym_oldmalloc;
1096210962
#endif
1096310963
static VALUE sym_newobj, sym_malloc, sym_method, sym_capi;
1096410964
static VALUE sym_none, sym_marking, sym_sweeping;
1096510965
VALUE hash = Qnil, key = Qnil;
10966-
VALUE major_by;
10966+
VALUE major_by, need_major_by;
1096710967
unsigned int flags = orig_flags ? orig_flags : objspace->profile.latest_gc_info;
10968+
unsigned int need_major_flags = objspace->rgengc.need_major_gc;
1096810969

1096910970
if (SYMBOL_P(hash_or_key)) {
1097010971
key = hash_or_key;
@@ -10983,6 +10984,7 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned
1098310984
S(immediate_sweep);
1098410985
S(have_finalizer);
1098510986
S(state);
10987+
S(need_major_by);
1098610988

1098710989
S(stress);
1098810990
S(nofree);
@@ -11020,6 +11022,19 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned
1102011022
Qnil;
1102111023
SET(major_by, major_by);
1102211024

11025+
if (orig_flags == 0) { /* set need_major_by only if flags not set explicitly */
11026+
need_major_by =
11027+
(need_major_flags & GPR_FLAG_MAJOR_BY_NOFREE) ? sym_nofree :
11028+
(need_major_flags & GPR_FLAG_MAJOR_BY_OLDGEN) ? sym_oldgen :
11029+
(need_major_flags & GPR_FLAG_MAJOR_BY_SHADY) ? sym_shady :
11030+
(need_major_flags & GPR_FLAG_MAJOR_BY_FORCE) ? sym_force :
11031+
#if RGENGC_ESTIMATE_OLDMALLOC
11032+
(need_major_flags & GPR_FLAG_MAJOR_BY_OLDMALLOC) ? sym_oldmalloc :
11033+
#endif
11034+
Qnil;
11035+
SET(need_major_by, need_major_by);
11036+
}
11037+
1102311038
SET(gc_by,
1102411039
(flags & GPR_FLAG_NEWOBJ) ? sym_newobj :
1102511040
(flags & GPR_FLAG_MALLOC) ? sym_malloc :

0 commit comments

Comments
 (0)
0