From 182ae1407b3f6597cdbf6872f788c1ed3aa22a35 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 19 Jul 2019 13:02:38 +0900 Subject: fix shared array terminology. Shared arrays created by Array#dup and so on points a shared_root object to manage lifetime of Array buffer. However, sometimes shared_root is called only shared so it is confusing. So I fixed these wording "shared" to "shared_root". * RArray::heap::aux::shared -> RArray::heap::aux::shared_root * ARY_SHARED() -> ARY_SHARED_ROOT() * ARY_SHARED_NUM() -> ARY_SHARED_ROOT_REFCNT() Also, add some debug_counters to count shared array objects. * ary_shared_create: shared ary by Array#dup and so on. * ary_shared: finished in shard. * ary_shared_root_occupied: shared_root but has only 1 refcnt. The number (ary_shared - ary_shared_root_occupied) is meaningful. --- gc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gc.c') diff --git a/gc.c b/gc.c index f1e9ecf47c..060e1ed48b 100644 --- a/gc.c +++ b/gc.c @@ -5083,7 +5083,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj) case T_ARRAY: if (FL_TEST(obj, ELTS_SHARED)) { - VALUE root = any->as.array.as.heap.aux.shared; + VALUE root = any->as.array.as.heap.aux.shared_root; gc_mark(objspace, root); } else { @@ -8007,7 +8007,7 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj) case T_ARRAY: if (FL_TEST(obj, ELTS_SHARED)) { - UPDATE_IF_MOVED(objspace, any->as.array.as.heap.aux.shared); + UPDATE_IF_MOVED(objspace, any->as.array.as.heap.aux.shared_root); } else { gc_ref_update_array(objspace, obj); @@ -11219,7 +11219,7 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj) case T_ARRAY: if (FL_TEST(obj, ELTS_SHARED)) { APPENDF((BUFF_ARGS, "shared -> %s", - rb_obj_info(RARRAY(obj)->as.heap.aux.shared))); + rb_obj_info(RARRAY(obj)->as.heap.aux.shared_root))); } else if (FL_TEST(obj, RARRAY_EMBED_FLAG)) { APPENDF((BUFF_ARGS, "[%s%s] len: %d (embed)", -- cgit v1.2.1