mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 20:19:19 +00:00
catch up modular-gc
This commit is contained in:
parent
024bbf5401
commit
a177799807
Notes:
git
2025-10-23 04:09:07 +00:00
19
gc.c
19
gc.c
@ -2806,6 +2806,13 @@ mark_m_tbl(void *objspace, struct rb_id_table *tbl)
|
||||
|
||||
bool rb_gc_impl_checking_shareable(void *objspace_ptr); // in defaut/deafult.c
|
||||
|
||||
bool
|
||||
rb_gc_checking_shareable(void)
|
||||
{
|
||||
return rb_gc_impl_checking_shareable(rb_gc_get_objspace());
|
||||
}
|
||||
|
||||
|
||||
static enum rb_id_table_iterator_result
|
||||
mark_const_entry_i(VALUE value, void *objspace)
|
||||
{
|
||||
@ -5420,6 +5427,18 @@ rb_gc_after_fork(rb_pid_t pid)
|
||||
rb_gc_impl_after_fork(rb_gc_get_objspace(), pid);
|
||||
}
|
||||
|
||||
bool
|
||||
rb_gc_obj_shareable_p(VALUE obj)
|
||||
{
|
||||
return RB_OBJ_SHAREABLE_P(obj);
|
||||
}
|
||||
|
||||
void
|
||||
rb_gc_rp(VALUE obj)
|
||||
{
|
||||
rp(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* Document-module: ObjectSpace
|
||||
*
|
||||
|
||||
@ -1463,12 +1463,6 @@ rb_gc_impl_checking_shareable(void *objspace_ptr)
|
||||
return objspace->flags.check_shareable;
|
||||
}
|
||||
|
||||
bool
|
||||
rb_gc_checking_shareable(void)
|
||||
{
|
||||
return rb_gc_impl_checking_shareable(rb_gc_get_objspace());
|
||||
}
|
||||
|
||||
bool
|
||||
rb_gc_impl_gc_enabled_p(void *objspace_ptr)
|
||||
{
|
||||
@ -4981,11 +4975,11 @@ check_shareable_i(const VALUE child, void *ptr)
|
||||
{
|
||||
struct verify_internal_consistency_struct *data = (struct verify_internal_consistency_struct *)ptr;
|
||||
|
||||
if (!RB_OBJ_SHAREABLE_P(child)) {
|
||||
if (!rb_gc_obj_shareable_p(child)) {
|
||||
fprintf(stderr, "(a) ");
|
||||
rp(data->parent);
|
||||
rb_gc_rp(data->parent);
|
||||
fprintf(stderr, "(b) ");
|
||||
rp(child);
|
||||
rb_gc_rp(child);
|
||||
fprintf(stderr, "check_shareable_i: shareable (a) -> unshareable (b)\n");
|
||||
|
||||
data->err_count++;
|
||||
@ -4999,11 +4993,14 @@ gc_verify_shareable(rb_objspace_t *objspace, VALUE obj, void *data)
|
||||
// while objspace->flags.check_shareable is true,
|
||||
// other Ractors should not run the GC, until the flag is not local.
|
||||
// TODO: remove VM locking if the flag is Ractor local
|
||||
RB_VM_LOCKING() {
|
||||
|
||||
unsigned int lev = RB_GC_VM_LOCK();
|
||||
{
|
||||
objspace->flags.check_shareable = true;
|
||||
rb_objspace_reachable_objects_from(obj, check_shareable_i, (void *)data);
|
||||
objspace->flags.check_shareable = false;
|
||||
}
|
||||
RB_GC_VM_UNLOCK(lev);
|
||||
}
|
||||
|
||||
// TODO: only one level (non-recursive)
|
||||
@ -5053,7 +5050,7 @@ verify_internal_consistency_i(void *page_start, void *page_end, size_t stride,
|
||||
rb_objspace_reachable_objects_from(obj, check_generation_i, (void *)data);
|
||||
}
|
||||
|
||||
if (!is_marking(objspace) && RB_OBJ_SHAREABLE_P(obj)) {
|
||||
if (!is_marking(objspace) && rb_gc_obj_shareable_p(obj)) {
|
||||
gc_verify_shareable(objspace, obj, data);
|
||||
}
|
||||
|
||||
|
||||
2
gc/gc.h
2
gc/gc.h
@ -96,6 +96,8 @@ MODULAR_GC_FN bool rb_memerror_reentered(void);
|
||||
MODULAR_GC_FN bool rb_obj_id_p(VALUE);
|
||||
MODULAR_GC_FN void rb_gc_before_updating_jit_code(void);
|
||||
MODULAR_GC_FN void rb_gc_after_updating_jit_code(void);
|
||||
MODULAR_GC_FN bool rb_gc_obj_shareable_p(VALUE);
|
||||
MODULAR_GC_FN void rb_gc_rp(VALUE);
|
||||
|
||||
#if USE_MODULAR_GC
|
||||
MODULAR_GC_FN bool rb_gc_event_hook_required_p(rb_event_flag_t event);
|
||||
|
||||
@ -1260,6 +1260,12 @@ rb_gc_impl_copy_attributes(void *objspace_ptr, VALUE dest, VALUE obj)
|
||||
rb_gc_impl_copy_finalizer(objspace_ptr, dest, obj);
|
||||
}
|
||||
|
||||
bool
|
||||
rb_gc_impl_checking_shareable(void *ptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// GC Identification
|
||||
|
||||
const char *
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user