Skip to content

Commit cb1ea54

Browse files
committed
objspace_dump: Include shareable flag
Given that the currently planned ractor local GC implementation performance will heavilly be influenced by the number of shareable objects it would be valuable to be able to know how many of them are in the heap.
1 parent 7af5a63 commit cb1ea54

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

gc/default/default.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -6199,7 +6199,7 @@ rb_gc_impl_object_metadata(void *objspace_ptr, VALUE obj)
61996199
{
62006200
rb_objspace_t *objspace = objspace_ptr;
62016201
size_t n = 0;
6202-
static ID ID_wb_protected, ID_age, ID_old, ID_uncollectible, ID_marking, ID_marked, ID_pinned, ID_object_id;
6202+
static ID ID_wb_protected, ID_age, ID_old, ID_uncollectible, ID_marking, ID_marked, ID_pinned, ID_object_id, ID_shareable;
62036203

62046204
if (!ID_marked) {
62056205
#define I(s) ID_##s = rb_intern(#s);
@@ -6211,6 +6211,7 @@ rb_gc_impl_object_metadata(void *objspace_ptr, VALUE obj)
62116211
I(marked);
62126212
I(pinned);
62136213
I(object_id);
6214+
I(shareable);
62146215
#undef I
62156216
}
62166217

@@ -6229,6 +6230,7 @@ rb_gc_impl_object_metadata(void *objspace_ptr, VALUE obj)
62296230
if (RVALUE_MARKED(objspace, obj)) SET_ENTRY(marked, Qtrue);
62306231
if (RVALUE_PINNED(objspace, obj)) SET_ENTRY(pinned, Qtrue);
62316232
if (FL_TEST(obj, FL_SEEN_OBJ_ID)) SET_ENTRY(object_id, rb_obj_id(obj));
6233+
if (FL_TEST(obj, FL_SHAREABLE)) SET_ENTRY(shareable, Qtrue);
62326234

62336235
object_metadata_entries[n].name = 0;
62346236
object_metadata_entries[n].val = 0;

test/objspace/test_objspace.rb

+7
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,13 @@ def test_escape_class_name
977977
assert_equal class_name, JSON.parse(json)["name"]
978978
end
979979

980+
def test_dump_include_shareable
981+
omit 'Not provided by mmtk' if RUBY_DESCRIPTION.include?("+GC[mmtk]")
982+
983+
assert_include(ObjectSpace.dump(ENV), '"shareable":true')
984+
assert_not_include(ObjectSpace.dump([]), '"shareable":true')
985+
end
986+
980987
def test_utf8_method_names
981988
name = "utf8_❨╯°□°❩╯︵┻━┻"
982989
obj = ObjectSpace.trace_object_allocations do

0 commit comments

Comments
 (0)