Move RUBY_INTERNAL_EVENT_FREEOBJ into GC implementation

Instead of calling rb_gc_event_hook inside of rb_gc_obj_free, it should
be up to the GC implementation to call the event.
This commit is contained in:
Peter Zhu 2024-09-30 13:37:28 -04:00
parent 292c9793ab
commit 30507a4aed
Notes: git 2024-09-30 18:23:51 +00:00
2 changed files with 2 additions and 2 deletions

2
gc.c
View File

@ -1087,8 +1087,6 @@ rb_gc_obj_free(void *objspace, VALUE obj)
{
RB_DEBUG_COUNTER_INC(obj_free);
rb_gc_event_hook(obj, RUBY_INTERNAL_EVENT_FREEOBJ);
switch (BUILTIN_TYPE(obj)) {
case T_NIL:
case T_FIXNUM:

View File

@ -3565,6 +3565,8 @@ gc_sweep_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bit
#undef CHECK
#endif
rb_gc_event_hook(vp, RUBY_INTERNAL_EVENT_FREEOBJ);
bool has_object_id = FL_TEST(vp, FL_SEEN_OBJ_ID);
if (rb_gc_obj_free(objspace, vp)) {
if (has_object_id) {