Skip to content

Commit

Permalink
[Feature #18290] Deprecate rb_gc_force_recycle and remove invalidate_…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
peterzhu2118 committed Nov 8, 2021
1 parent aeae6e2 commit 3094064
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 72 deletions.
73 changes: 1 addition & 72 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; i<limit; i++) {
if (chunk->data[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)
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions include/ruby/internal/intern/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down

0 comments on commit 3094064

Please sign in to comment.