summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authortmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-10 02:26:09 +0000
committertmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-10 02:26:09 +0000
commit7170baa878ac0223f26fcf8c8bf25492415e6eaa (patch)
tree284ae309fe2ac5c1aace26feb6ab4836b5382e62 /gc.c
parent97d292cb5580f15de13b2e8f54b6e4e366e8f0cb (diff)
objspace_dump.c: include object's gc flags in dump
* ext/objspace/objspace_dump.c (dump_object): include fstring flag on strings. include gc flags (old, remembered, wb_protected) on all objects. * ext/objspace/objspace_dump.c (Init_objspace_dump): initialize lazy IDs before first use. * gc.c (rb_obj_gc_flags): new function to retrieve object flags * internal.h (RB_OBJ_GC_FLAGS_MAX): maximum flags allowed for one obj * test/objspace/test_objspace.rb (test_dump_flags): test for above * test/objspace/test_objspace.rb (test_trace_object_allocations): resolve name before dump (for rb_class_path_cached) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index 2083cc1027..3d6ca43e37 100644
--- a/gc.c
+++ b/gc.c
@@ -4749,6 +4749,53 @@ rb_obj_rgengc_promoted_p(VALUE obj)
return OBJ_PROMOTED(obj) ? Qtrue : Qfalse;
}
+size_t
+rb_obj_gc_flags(VALUE obj, ID* flags, size_t max)
+{
+ size_t n = 0;
+ static ID ID_marked;
+#if USE_RGENGC
+ static ID ID_wb_protected, ID_old, ID_remembered;
+#if RGENGC_THREEGEN
+ static ID ID_young, ID_infant;
+#endif
+#endif
+
+ if (!ID_marked) {
+#define I(s) ID_##s = rb_intern(#s);
+ I(marked);
+#if USE_RGENGC
+ I(wb_protected);
+ I(old);
+ I(remembered);
+#if RGENGC_THREEGEN
+ I(young);
+ I(infant);
+#endif
+#endif
+#undef I
+ }
+
+#if USE_RGENGC
+ if (OBJ_WB_PROTECTED(obj) && n<max)
+ flags[n++] = ID_wb_protected;
+ if (RVALUE_OLD_P(obj) && n<max)
+ flags[n++] = ID_old;
+#if RGENGC_THREEGEN
+ if (RVALUE_YOUNG_P(obj) && n<max)
+ flags[n++] = ID_young;
+ if (RVALUE_INFANT_P(obj) && n<max)
+ flags[n++] = ID_infant;
+#endif
+ if (MARKED_IN_BITMAP(GET_HEAP_REMEMBERSET_BITS(obj), obj) && n<max)
+ flags[n++] = ID_remembered;
+#endif
+ if (MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj) && n<max)
+ flags[n++] = ID_marked;
+
+ return n;
+}
+
/* GC */
void