summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorMatt Valentine-House <matt@eightbitraptor.com>2021-11-15 21:09:10 +0000
committerPeter Zhu <peter@peterzhu.ca>2021-11-22 09:11:04 -0500
commitb680b632e5b88e4ea550de3f15cf6ef782efeb48 (patch)
tree20037c65d61d82f04972af4cf029c36f58074b35 /gc.c
parentfa9fa23ea844047d0d4f83a3864bdb24ecf95646 (diff)
Make RCLASS_EXT(c)->subclasses a doubly linked list
Updating RCLASS_PARENT_SUBCLASSES and RCLASS_MODULE_SUBCLASSES while compacting can trigger the read barrier. This commit makes RCLASS_SUBCLASSES a doubly linked list with a dedicated head object so that we can add and remove entries from the list without having to touch an object in the Ruby heap
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5125
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/gc.c b/gc.c
index 60387d2ab3..b36688979e 100644
--- a/gc.c
+++ b/gc.c
@@ -3134,15 +3134,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
rb_id_table_foreach_values(RCLASS_CVC_TBL(obj), cvar_table_free_i, NULL);
rb_id_table_free(RCLASS_CVC_TBL(obj));
}
- if (RCLASS_SUBCLASSES(obj)) {
- if (BUILTIN_TYPE(obj) == T_MODULE) {
- rb_class_detach_module_subclasses(obj);
- }
- else {
- rb_class_detach_subclasses(obj);
- }
- RCLASS_SUBCLASSES(obj) = NULL;
- }
+ rb_class_remove_subclass_head(obj);
rb_class_remove_from_module_subclasses(obj);
rb_class_remove_from_super_subclasses(obj);
#if !USE_RVARGC
@@ -3307,10 +3299,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
if (RCLASS_CALLABLE_M_TBL(obj) != NULL) {
rb_id_table_free(RCLASS_CALLABLE_M_TBL(obj));
}
- if (RCLASS_SUBCLASSES(obj)) {
- rb_class_detach_subclasses(obj);
- RCLASS_SUBCLASSES(obj) = NULL;
- }
+ rb_class_remove_subclass_head(obj);
cc_table_free(objspace, obj, FALSE);
rb_class_remove_from_module_subclasses(obj);
rb_class_remove_from_super_subclasses(obj);