summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorMirek Klimos <myreggg@gmail.com>2022-12-10 10:35:31 -0800
committerGitHub <noreply@github.com>2022-12-10 13:35:31 -0500
commitea613c63608232bf33fd454fc6cd1ce20d63d82e (patch)
tree24428c814d601d17d98bcf8cd2f036ac992186ac /gc.c
parent12003acbb9c2c2624be8c41c22c15e6d1fa3a42e (diff)
Expose need_major_gc via GC.latest_gc_info (#6791)
Notes
Notes: Merged-By: peterzhu2118 <peter@peterzhu.ca>
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/gc.c b/gc.c
index 4254922f78..b9e9a9d147 100644
--- a/gc.c
+++ b/gc.c
@@ -10954,7 +10954,7 @@ gc_count(rb_execution_context_t *ec, VALUE self)
static VALUE
gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned int orig_flags)
{
- static VALUE sym_major_by = Qnil, sym_gc_by, sym_immediate_sweep, sym_have_finalizer, sym_state;
+ static VALUE sym_major_by = Qnil, sym_gc_by, sym_immediate_sweep, sym_have_finalizer, sym_state, sym_need_major_by;
static VALUE sym_nofree, sym_oldgen, sym_shady, sym_force, sym_stress;
#if RGENGC_ESTIMATE_OLDMALLOC
static VALUE sym_oldmalloc;
@@ -10962,7 +10962,7 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned
static VALUE sym_newobj, sym_malloc, sym_method, sym_capi;
static VALUE sym_none, sym_marking, sym_sweeping;
VALUE hash = Qnil, key = Qnil;
- VALUE major_by;
+ VALUE major_by, need_major_by;
unsigned int flags = orig_flags ? orig_flags : objspace->profile.latest_gc_info;
if (SYMBOL_P(hash_or_key)) {
@@ -10982,6 +10982,7 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned
S(immediate_sweep);
S(have_finalizer);
S(state);
+ S(need_major_by);
S(stress);
S(nofree);
@@ -11019,6 +11020,20 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned
Qnil;
SET(major_by, major_by);
+ if (orig_flags == 0) { /* set need_major_by only if flags not set explicitly */
+ unsigned int need_major_flags = objspace->rgengc.need_major_gc;
+ need_major_by =
+ (need_major_flags & GPR_FLAG_MAJOR_BY_NOFREE) ? sym_nofree :
+ (need_major_flags & GPR_FLAG_MAJOR_BY_OLDGEN) ? sym_oldgen :
+ (need_major_flags & GPR_FLAG_MAJOR_BY_SHADY) ? sym_shady :
+ (need_major_flags & GPR_FLAG_MAJOR_BY_FORCE) ? sym_force :
+#if RGENGC_ESTIMATE_OLDMALLOC
+ (need_major_flags & GPR_FLAG_MAJOR_BY_OLDMALLOC) ? sym_oldmalloc :
+#endif
+ Qnil;
+ SET(need_major_by, need_major_by);
+ }
+
SET(gc_by,
(flags & GPR_FLAG_NEWOBJ) ? sym_newobj :
(flags & GPR_FLAG_MALLOC) ? sym_malloc :