From 309406484b98fe0aea55016d8f5971b4e6b91761 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 5 Nov 2021 09:52:07 -0400 Subject: [PATCH] [Feature #18290] Deprecate rb_gc_force_recycle and remove invalidate_mark_stack_chunk This commit deprecates rb_gc_force_recycle and coverts it to a no-op function. Also removes invalidate_mark_stack_chunk since only rb_gc_force_recycle uses it. --- gc.c | 73 +------------------------------ include/ruby/internal/intern/gc.h | 2 + 2 files changed, 3 insertions(+), 72 deletions(-) diff --git a/gc.c b/gc.c index 3fa1abb59a..3251719066 100644 --- a/gc.c +++ b/gc.c @@ -6142,35 +6142,6 @@ pop_mark_stack(mark_stack_t *stack, VALUE *data) return TRUE; } -#if GC_ENABLE_INCREMENTAL_MARK -static int -invalidate_mark_stack_chunk(stack_chunk_t *chunk, int limit, VALUE obj) -{ - int i; - for (i=0; idata[i] == obj) { - chunk->data[i] = Qundef; - return TRUE; - } - } - return FALSE; -} - -static void -invalidate_mark_stack(mark_stack_t *stack, VALUE obj) -{ - stack_chunk_t *chunk = stack->chunk; - int limit = stack->index; - - while (chunk) { - if (invalidate_mark_stack_chunk(chunk, limit, obj)) return; - chunk = chunk->next; - limit = stack->limit; - } - rb_bug("invalid_mark_stack: unreachable"); -} -#endif - static void init_mark_stack(mark_stack_t *stack) { @@ -8743,49 +8714,7 @@ rb_gc_ractor_newobj_cache_clear(rb_ractor_newobj_cache_t *newobj_cache) void rb_gc_force_recycle(VALUE obj) { - rb_objspace_t *objspace = &rb_objspace; - RB_VM_LOCK_ENTER(); - { - int is_old = RVALUE_OLD_P(obj); - - gc_report(2, objspace, "rb_gc_force_recycle: %s\n", obj_info(obj)); - - if (is_old) { - if (RVALUE_MARKED(obj)) { - objspace->rgengc.old_objects--; - } - } - CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(obj), obj); - CLEAR_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), obj); - CLEAR_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj); - - if (is_incremental_marking(objspace)) { -#if GC_ENABLE_INCREMENTAL_MARK - if (MARKED_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj)) { - invalidate_mark_stack(&objspace->mark_stack, obj); - CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj); - } - CLEAR_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj); -#endif - } - else { - if (is_old || GET_HEAP_PAGE(obj)->flags.before_sweep) { - CLEAR_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj); - } - CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj); - } - - objspace->profile.total_freed_objects++; - - heap_page_add_freeobj(objspace, GET_HEAP_PAGE(obj), obj); - - /* Disable counting swept_slots because there are no meaning. - * if (!MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(p), p)) { - * objspace->heap.swept_slots++; - * } - */ - } - RB_VM_LOCK_LEAVE(); + /* no-op */ } #ifndef MARK_OBJECT_ARY_BUCKET_SIZE diff --git a/include/ruby/internal/intern/gc.h b/include/ruby/internal/intern/gc.h index d8e476b078..e7b8008729 100644 --- a/include/ruby/internal/intern/gc.h +++ b/include/ruby/internal/intern/gc.h @@ -208,7 +208,9 @@ VALUE rb_gc_location(VALUE obj); * @post `obj` could be invalidated. * @warning It is a failure to pass an object multiple times to this * function. + * @deprecated This is now a no-op function. */ +RBIMPL_ATTR_DEPRECATED(("this is now a no-op function")) void rb_gc_force_recycle(VALUE obj); /**