Skip to content

Commit a177799

Browse files
committed
catch up modular-gc
1 parent 024bbf5 commit a177799

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

gc.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,6 +2806,13 @@ mark_m_tbl(void *objspace, struct rb_id_table *tbl)
28062806

28072807
bool rb_gc_impl_checking_shareable(void *objspace_ptr); // in defaut/deafult.c
28082808

2809+
bool
2810+
rb_gc_checking_shareable(void)
2811+
{
2812+
return rb_gc_impl_checking_shareable(rb_gc_get_objspace());
2813+
}
2814+
2815+
28092816
static enum rb_id_table_iterator_result
28102817
mark_const_entry_i(VALUE value, void *objspace)
28112818
{
@@ -5420,6 +5427,18 @@ rb_gc_after_fork(rb_pid_t pid)
54205427
rb_gc_impl_after_fork(rb_gc_get_objspace(), pid);
54215428
}
54225429

5430+
bool
5431+
rb_gc_obj_shareable_p(VALUE obj)
5432+
{
5433+
return RB_OBJ_SHAREABLE_P(obj);
5434+
}
5435+
5436+
void
5437+
rb_gc_rp(VALUE obj)
5438+
{
5439+
rp(obj);
5440+
}
5441+
54235442
/*
54245443
* Document-module: ObjectSpace
54255444
*

gc/default/default.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,12 +1463,6 @@ rb_gc_impl_checking_shareable(void *objspace_ptr)
14631463
return objspace->flags.check_shareable;
14641464
}
14651465

1466-
bool
1467-
rb_gc_checking_shareable(void)
1468-
{
1469-
return rb_gc_impl_checking_shareable(rb_gc_get_objspace());
1470-
}
1471-
14721466
bool
14731467
rb_gc_impl_gc_enabled_p(void *objspace_ptr)
14741468
{
@@ -4981,11 +4975,11 @@ check_shareable_i(const VALUE child, void *ptr)
49814975
{
49824976
struct verify_internal_consistency_struct *data = (struct verify_internal_consistency_struct *)ptr;
49834977

4984-
if (!RB_OBJ_SHAREABLE_P(child)) {
4978+
if (!rb_gc_obj_shareable_p(child)) {
49854979
fprintf(stderr, "(a) ");
4986-
rp(data->parent);
4980+
rb_gc_rp(data->parent);
49874981
fprintf(stderr, "(b) ");
4988-
rp(child);
4982+
rb_gc_rp(child);
49894983
fprintf(stderr, "check_shareable_i: shareable (a) -> unshareable (b)\n");
49904984

49914985
data->err_count++;
@@ -4999,11 +4993,14 @@ gc_verify_shareable(rb_objspace_t *objspace, VALUE obj, void *data)
49994993
// while objspace->flags.check_shareable is true,
50004994
// other Ractors should not run the GC, until the flag is not local.
50014995
// TODO: remove VM locking if the flag is Ractor local
5002-
RB_VM_LOCKING() {
4996+
4997+
unsigned int lev = RB_GC_VM_LOCK();
4998+
{
50034999
objspace->flags.check_shareable = true;
50045000
rb_objspace_reachable_objects_from(obj, check_shareable_i, (void *)data);
50055001
objspace->flags.check_shareable = false;
50065002
}
5003+
RB_GC_VM_UNLOCK(lev);
50075004
}
50085005

50095006
// TODO: only one level (non-recursive)
@@ -5053,7 +5050,7 @@ verify_internal_consistency_i(void *page_start, void *page_end, size_t stride,
50535050
rb_objspace_reachable_objects_from(obj, check_generation_i, (void *)data);
50545051
}
50555052

5056-
if (!is_marking(objspace) && RB_OBJ_SHAREABLE_P(obj)) {
5053+
if (!is_marking(objspace) && rb_gc_obj_shareable_p(obj)) {
50575054
gc_verify_shareable(objspace, obj, data);
50585055
}
50595056

gc/gc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ MODULAR_GC_FN bool rb_memerror_reentered(void);
9696
MODULAR_GC_FN bool rb_obj_id_p(VALUE);
9797
MODULAR_GC_FN void rb_gc_before_updating_jit_code(void);
9898
MODULAR_GC_FN void rb_gc_after_updating_jit_code(void);
99+
MODULAR_GC_FN bool rb_gc_obj_shareable_p(VALUE);
100+
MODULAR_GC_FN void rb_gc_rp(VALUE);
99101

100102
#if USE_MODULAR_GC
101103
MODULAR_GC_FN bool rb_gc_event_hook_required_p(rb_event_flag_t event);

gc/mmtk/mmtk.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,12 @@ rb_gc_impl_copy_attributes(void *objspace_ptr, VALUE dest, VALUE obj)
12601260
rb_gc_impl_copy_finalizer(objspace_ptr, dest, obj);
12611261
}
12621262

1263+
bool
1264+
rb_gc_impl_checking_shareable(void *ptr)
1265+
{
1266+
return false;
1267+
}
1268+
12631269
// GC Identification
12641270

12651271
const char *

0 commit comments

Comments
 (0)