diff options
author | Peter Zhu <[email protected]> | 2024-08-07 11:12:49 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2024-08-09 10:27:40 -0400 |
commit | c91ec7ba1ec68b88b386b255fd48317d1b5715e5 (patch) | |
tree | 56825d2d7e2630d8cb00d1c856343b7ee047901f | |
parent | 2bd5dc47ac7527fa2cec98106959d318021ab135 (diff) |
Remove rb_gc_impl_objspace_mark
It's not necessary for the GC implementation to call rb_gc_mark_roots
which calls back into the GC implementation's rb_gc_impl_objspace_mark.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11325
-rw-r--r-- | gc.c | 6 | ||||
-rw-r--r-- | gc/default.c | 59 | ||||
-rw-r--r-- | gc/gc_impl.h | 1 |
3 files changed, 32 insertions, 34 deletions
@@ -616,7 +616,6 @@ typedef struct gc_function_map { void (*mark_maybe)(void *objspace_ptr, VALUE obj); void (*mark_weak)(void *objspace_ptr, VALUE *ptr); void (*remove_weak)(void *objspace_ptr, VALUE parent_obj, VALUE *ptr); - void (*objspace_mark)(void *objspace_ptr); // Compaction bool (*object_moved_p)(void *objspace_ptr, VALUE obj); VALUE (*location)(void *objspace_ptr, VALUE value); @@ -747,7 +746,6 @@ ruby_external_gc_init(void) load_external_gc_func(mark_maybe); load_external_gc_func(mark_weak); load_external_gc_func(remove_weak); - load_external_gc_func(objspace_mark); // Compaction load_external_gc_func(object_moved_p); load_external_gc_func(location); @@ -826,7 +824,6 @@ ruby_external_gc_init(void) # define rb_gc_impl_mark_maybe rb_gc_functions.mark_maybe # define rb_gc_impl_mark_weak rb_gc_functions.mark_weak # define rb_gc_impl_remove_weak rb_gc_functions.remove_weak -# define rb_gc_impl_objspace_mark rb_gc_functions.objspace_mark // Compaction # define rb_gc_impl_object_moved_p rb_gc_functions.object_moved_p # define rb_gc_impl_location rb_gc_functions.location @@ -2458,9 +2455,6 @@ rb_gc_mark_roots(void *objspace, const char **categoryp) if (categoryp) *categoryp = category; \ } while (0) - MARK_CHECKPOINT("objspace"); - rb_gc_impl_objspace_mark(objspace); - MARK_CHECKPOINT("vm"); SET_STACK_END; rb_vm_mark(vm); diff --git a/gc/default.c b/gc/default.c index c11e5885b0..d8e961eb39 100644 --- a/gc/default.c +++ b/gc/default.c @@ -4813,6 +4813,35 @@ rb_gc_impl_remove_weak(void *objspace_ptr, VALUE parent_obj, VALUE *ptr) } } +static int +pin_value(st_data_t key, st_data_t value, st_data_t data) +{ + rb_gc_impl_mark_and_pin((void *)data, (VALUE)value); + + return ST_CONTINUE; +} + +static void +mark_roots(rb_objspace_t *objspace, const char **categoryp) +{ +#define MARK_CHECKPOINT(category) do { \ + if (categoryp) *categoryp = category; \ +} while (0) + + MARK_CHECKPOINT("objspace"); + objspace->rgengc.parent_object = Qfalse; + + if (finalizer_table != NULL) { + st_foreach(finalizer_table, pin_value, (st_data_t)objspace); + } + + st_foreach(objspace->obj_to_id_tbl, gc_mark_tbl_no_pin_i, (st_data_t)objspace); + + if (stress_to_class) rb_gc_mark(stress_to_class); + + rb_gc_mark_roots(objspace, categoryp); +} + static inline void gc_mark_set_parent(rb_objspace_t *objspace, VALUE obj) { @@ -5037,7 +5066,7 @@ objspace_allrefs(rb_objspace_t *objspace) /* traverse root objects */ PUSH_MARK_FUNC_DATA(&mfd); GET_RACTOR()->mfd = &mfd; - rb_gc_mark_roots(objspace, &data.category); + mark_roots(objspace, &data.category); POP_MARK_FUNC_DATA(); /* traverse rest objects reachable from root objects */ @@ -5598,7 +5627,7 @@ gc_marks_finish(rb_objspace_t *objspace) mark_stack_size(&objspace->mark_stack)); } - rb_gc_mark_roots(objspace, NULL); + mark_roots(objspace, NULL); while (gc_mark_stacked_objects_incremental(objspace, INT_MAX) == false); #if RGENGC_CHECK_MODE >= 2 @@ -6019,7 +6048,7 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark) } } - rb_gc_mark_roots(objspace, NULL); + mark_roots(objspace, NULL); gc_report(1, objspace, "gc_marks_start: (%s) end, stack in %"PRIdSIZE"\n", full_mark ? "full" : "minor", mark_stack_size(&objspace->mark_stack)); @@ -9544,14 +9573,6 @@ rb_gc_impl_objspace_free(void *objspace_ptr) free(objspace); } -static int -pin_value(st_data_t key, st_data_t value, st_data_t data) -{ - rb_gc_impl_mark_and_pin((void *)data, (VALUE)value); - - return ST_CONTINUE; -} - void rb_gc_impl_mark(void *objspace_ptr, VALUE obj); #if MALLOC_ALLOCATED_SIZE @@ -9586,22 +9607,6 @@ gc_malloc_allocations(VALUE self) } #endif -void -rb_gc_impl_objspace_mark(void *objspace_ptr) -{ - rb_objspace_t *objspace = objspace_ptr; - - objspace->rgengc.parent_object = Qfalse; - - if (finalizer_table != NULL) { - st_foreach(finalizer_table, pin_value, (st_data_t)objspace); - } - - st_foreach(objspace->obj_to_id_tbl, gc_mark_tbl_no_pin_i, (st_data_t)objspace); - - if (stress_to_class) rb_gc_mark(stress_to_class); -} - void * rb_gc_impl_objspace_alloc(void) { diff --git a/gc/gc_impl.h b/gc/gc_impl.h index befeddccb6..12527845f7 100644 --- a/gc/gc_impl.h +++ b/gc/gc_impl.h @@ -65,7 +65,6 @@ GC_IMPL_FN void rb_gc_impl_mark_and_pin(void *objspace_ptr, VALUE obj); GC_IMPL_FN void rb_gc_impl_mark_maybe(void *objspace_ptr, VALUE obj); GC_IMPL_FN void rb_gc_impl_mark_weak(void *objspace_ptr, VALUE *ptr); GC_IMPL_FN void rb_gc_impl_remove_weak(void *objspace_ptr, VALUE parent_obj, VALUE *ptr); -GC_IMPL_FN void rb_gc_impl_objspace_mark(void *objspace_ptr); // Compaction GC_IMPL_FN bool rb_gc_impl_object_moved_p(void *objspace_ptr, VALUE obj); GC_IMPL_FN VALUE rb_gc_impl_location(void *objspace_ptr, VALUE value); |