summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index 44336c0d71..707754a9e5 100644
--- a/gc.c
+++ b/gc.c
@@ -7138,6 +7138,8 @@ gc_ref_update_from_offset(rb_objspace_t *objspace, VALUE obj)
}
}
+static void mark_cvc_tbl(rb_objspace_t *objspace, VALUE klass);
+
static void
gc_mark_children(rb_objspace_t *objspace, VALUE obj)
{
@@ -7188,6 +7190,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
if (!RCLASS_EXT(obj)) break;
mark_m_tbl(objspace, RCLASS_M_TBL(obj));
+ mark_cvc_tbl(objspace, obj);
cc_table_mark(objspace, obj);
for (attr_index_t i = 0; i < RCLASS_IV_COUNT(obj); i++) {
gc_mark(objspace, RCLASS_IVPTR(obj)[i]);
@@ -10325,9 +10328,14 @@ static enum rb_id_table_iterator_result
update_cvc_tbl_i(VALUE cvc_entry, void *data)
{
struct rb_cvar_class_tbl_entry *entry;
+ rb_objspace_t * objspace = (rb_objspace_t *)data;
entry = (struct rb_cvar_class_tbl_entry *)cvc_entry;
+ if (entry->cref) {
+ TYPED_UPDATE_IF_MOVED(objspace, rb_cref_t *, entry->cref);
+ }
+
entry->class_value = rb_gc_location(entry->class_value);
return ID_TABLE_CONTINUE;
@@ -10343,6 +10351,28 @@ update_cvc_tbl(rb_objspace_t *objspace, VALUE klass)
}
static enum rb_id_table_iterator_result
+mark_cvc_tbl_i(VALUE cvc_entry, void *data)
+{
+ struct rb_cvar_class_tbl_entry *entry;
+
+ entry = (struct rb_cvar_class_tbl_entry *)cvc_entry;
+
+ RUBY_ASSERT(entry->cref == 0 || (BUILTIN_TYPE((VALUE)entry->cref) == T_IMEMO && IMEMO_TYPE_P(entry->cref, imemo_cref)));
+ rb_gc_mark((VALUE) entry->cref);
+
+ return ID_TABLE_CONTINUE;
+}
+
+static void
+mark_cvc_tbl(rb_objspace_t *objspace, VALUE klass)
+{
+ struct rb_id_table *tbl = RCLASS_CVC_TBL(klass);
+ if (tbl) {
+ rb_id_table_foreach_values(tbl, mark_cvc_tbl_i, objspace);
+ }
+}
+
+static enum rb_id_table_iterator_result
update_const_table(VALUE value, void *data)
{
rb_const_entry_t *ce = (rb_const_entry_t *)value;