зеркало из https://github.com/github/ruby.git
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.
This commit is contained in:
Родитель
2bd5dc47ac
Коммит
c91ec7ba1e
6
gc.c
6
gc.c
|
@ -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);
|
||||
|
|
59
gc/default.c
59
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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче