Skip to content

Commit 282148b

Browse files
committed
Copying GC support for EXIVAR
1 parent 5129ca3 commit 282148b

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

gc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10425,6 +10425,10 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
1042510425

1042610426
gc_report(4, objspace, "update-refs: %p ->\n", (void *)obj);
1042710427

10428+
if (FL_TEST(obj, FL_EXIVAR)) {
10429+
rb_update_generic_ivar(obj);
10430+
}
10431+
1042810432
switch (BUILTIN_TYPE(obj)) {
1042910433
case T_CLASS:
1043010434
case T_MODULE:

internal/variable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ int rb_gen_ivtbl_get(VALUE obj, ID id, struct gen_ivtbl **ivtbl);
4242
RUBY_SYMBOL_EXPORT_BEGIN
4343
/* variable.c (export) */
4444
void rb_mark_generic_ivar(VALUE);
45+
void rb_update_generic_ivar(VALUE);
4546
void rb_mv_generic_ivar(VALUE src, VALUE dst);
4647
VALUE rb_const_missing(VALUE klass, VALUE name);
4748
int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);

variable.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ gen_ivtbl_mark(const struct gen_ivtbl *ivtbl)
10341034
uint32_t i;
10351035

10361036
for (i = 0; i < ivtbl->numiv; i++) {
1037-
rb_gc_mark(ivtbl->ivptr[i]);
1037+
rb_gc_mark_movable(ivtbl->ivptr[i]);
10381038
}
10391039
}
10401040

@@ -1048,6 +1048,26 @@ rb_mark_generic_ivar(VALUE obj)
10481048
}
10491049
}
10501050

1051+
static void
1052+
gen_ivtbl_update(struct gen_ivtbl *ivtbl)
1053+
{
1054+
uint32_t i;
1055+
1056+
for (i = 0; i < ivtbl->numiv; i++) {
1057+
ivtbl->ivptr[i] = rb_gc_location(ivtbl->ivptr[i]);
1058+
}
1059+
}
1060+
1061+
void
1062+
rb_update_generic_ivar(VALUE obj)
1063+
{
1064+
struct gen_ivtbl *ivtbl;
1065+
1066+
if (rb_gen_ivtbl_get(obj, 0, &ivtbl)) {
1067+
gen_ivtbl_update(ivtbl);
1068+
}
1069+
}
1070+
10511071
void
10521072
rb_mv_generic_ivar(VALUE rsrc, VALUE dst)
10531073
{

0 commit comments

Comments
 (0)