Skip to content

Commit

Permalink
Refactor GC functions to have consistent naming
Browse files Browse the repository at this point in the history
Refactor function names for consistency. Function with name xyz_page
should have a corresponding function named xyz_plane.
  • Loading branch information
peterzhu2118 committed Dec 3, 2021
1 parent 81eadd9 commit 0815390
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4868,7 +4868,7 @@ unlock_page_body(rb_objspace_t *objspace, struct heap_page_body *body)
}

static inline bool
try_move_in_plane(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page, uintptr_t p, bits_t bits, VALUE dest)
try_move_plane(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page, uintptr_t p, bits_t bits, VALUE dest)
{
if (bits) {
do {
Expand Down Expand Up @@ -4936,7 +4936,7 @@ try_move(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_page,
bits_t bits = mark_bits[index] & ~pin_bits[index];

bits >>= NUM_IN_PAGE(p);
if (try_move_in_plane(objspace, heap, sweep_page, (uintptr_t)p, bits, dest)) return 1;
if (try_move_plane(objspace, heap, sweep_page, (uintptr_t)p, bits, dest)) return 1;

if (index == 0) {
p = cursor->start + (BITS_BITLENGTH - NUM_IN_PAGE(cursor->start));
Expand All @@ -4949,7 +4949,7 @@ try_move(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_page,
* marked, so we iterate using the marking bitmap */
for (size_t i = index + 1; i < HEAP_PAGE_BITMAP_LIMIT; i++) {
bits_t bits = mark_bits[i] & ~pin_bits[i];
if (try_move_in_plane(objspace, heap, sweep_page, (uintptr_t)p, bits, dest)) return 1;
if (try_move_plane(objspace, heap, sweep_page, (uintptr_t)p, bits, dest)) return 1;
p += BITS_BITLENGTH;
}

Expand Down Expand Up @@ -5181,7 +5181,7 @@ struct gc_sweep_context {
};

static inline void
gc_fill_swept_page_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bitset, bool *finished_compacting, struct gc_sweep_context *ctx)
gc_fill_swept_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bitset, bool *finished_compacting, struct gc_sweep_context *ctx)
{
struct heap_page * sweep_page = ctx->page;

Expand Down Expand Up @@ -5258,13 +5258,13 @@ gc_fill_swept_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *s
/* *Want to move* objects are pinned but not marked. */
bitset = pin_bits[0] & ~mark_bits[0];
bitset >>= NUM_IN_PAGE(p); // Skip header / dead space bits
gc_fill_swept_page_plane(objspace, heap, (uintptr_t)p, bitset, &finished_compacting, ctx);
gc_fill_swept_plane(objspace, heap, (uintptr_t)p, bitset, &finished_compacting, ctx);
p += ((BITS_BITLENGTH - NUM_IN_PAGE(p)) * sizeof(RVALUE));

for (int i = 1; i < HEAP_PAGE_BITMAP_LIMIT; i++) {
/* *Want to move* objects are pinned but not marked. */
bitset = pin_bits[i] & ~mark_bits[i];
gc_fill_swept_page_plane(objspace, heap, (uintptr_t)p, bitset, &finished_compacting, ctx);
gc_fill_swept_plane(objspace, heap, (uintptr_t)p, bitset, &finished_compacting, ctx);
p += ((BITS_BITLENGTH) * sizeof(RVALUE));
}

Expand All @@ -5274,7 +5274,7 @@ gc_fill_swept_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *s
}

static inline void
gc_plane_sweep(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bitset, struct gc_sweep_context *ctx)
gc_sweep_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bitset, struct gc_sweep_context *ctx)
{
struct heap_page * sweep_page = ctx->page;
short slot_size = sweep_page->slot_size;
Expand Down Expand Up @@ -5351,7 +5351,7 @@ gc_plane_sweep(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bit
}

static inline void
gc_page_sweep(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap, struct gc_sweep_context *ctx)
gc_sweep_page(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap, struct gc_sweep_context *ctx)
{
struct heap_page *sweep_page = ctx->page;

Expand Down Expand Up @@ -5392,14 +5392,14 @@ gc_page_sweep(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea
bitset = ~bits[0];
bitset >>= NUM_IN_PAGE(p);
if (bitset) {
gc_plane_sweep(objspace, heap, (uintptr_t)p, bitset, ctx);
gc_sweep_plane(objspace, heap, (uintptr_t)p, bitset, ctx);
}
p += (BITS_BITLENGTH - NUM_IN_PAGE(p));

for (i=1; i < HEAP_PAGE_BITMAP_LIMIT; i++) {
bitset = ~bits[i];
if (bitset) {
gc_plane_sweep(objspace, heap, (uintptr_t)p, bitset, ctx);
gc_sweep_plane(objspace, heap, (uintptr_t)p, bitset, ctx);
}
p += BITS_BITLENGTH;
}
Expand All @@ -5421,7 +5421,7 @@ gc_page_sweep(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea
record->empty_objects += ctx->empty_slots;
}
#endif
if (0) fprintf(stderr, "gc_page_sweep(%"PRIdSIZE"): total_slots: %d, freed_slots: %d, empty_slots: %d, final_slots: %d\n",
if (0) fprintf(stderr, "gc_sweep_page(%"PRIdSIZE"): total_slots: %d, freed_slots: %d, empty_slots: %d, final_slots: %d\n",
rb_gc_count(),
sweep_page->total_slots,
ctx->freed_slots, ctx->empty_slots, ctx->final_slots);
Expand Down Expand Up @@ -5675,7 +5675,7 @@ gc_sweep_step(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea
.freed_slots = 0,
.empty_slots = 0,
};
gc_page_sweep(objspace, size_pool, heap, &ctx);
gc_sweep_page(objspace, size_pool, heap, &ctx);
int free_slots = ctx.freed_slots + ctx.empty_slots;

heap->sweeping_page = list_next(&heap->pages, sweep_page, page_node);
Expand Down Expand Up @@ -7865,7 +7865,7 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark)

#if GC_ENABLE_INCREMENTAL_MARK
static inline void
gc_marks_wb_unprotected_objects_in_plane(rb_objspace_t *objspace, uintptr_t p, bits_t bits)
gc_marks_wb_unprotected_objects_plane(rb_objspace_t *objspace, uintptr_t p, bits_t bits)
{
if (bits) {
do {
Expand Down Expand Up @@ -7894,13 +7894,13 @@ gc_marks_wb_unprotected_objects(rb_objspace_t *objspace, rb_heap_t *heap)

bits_t bits = mark_bits[0] & wbun_bits[0];
bits >>= NUM_IN_PAGE(p);
gc_marks_wb_unprotected_objects_in_plane(objspace, (uintptr_t)p, bits);
gc_marks_wb_unprotected_objects_plane(objspace, (uintptr_t)p, bits);
p += (BITS_BITLENGTH - NUM_IN_PAGE(p));

for (j=1; j<HEAP_PAGE_BITMAP_LIMIT; j++) {
bits_t bits = mark_bits[j] & wbun_bits[j];

gc_marks_wb_unprotected_objects_in_plane(objspace, (uintptr_t)p, bits);
gc_marks_wb_unprotected_objects_plane(objspace, (uintptr_t)p, bits);
p += BITS_BITLENGTH;
}
}
Expand Down Expand Up @@ -8275,7 +8275,7 @@ rgengc_remembered(rb_objspace_t *objspace, VALUE obj)
#endif

static inline void
rgengc_rememberset_mark_in_plane(rb_objspace_t *objspace, uintptr_t p, bits_t bitset)
rgengc_rememberset_mark_plane(rb_objspace_t *objspace, uintptr_t p, bits_t bitset)
{
if (bitset) {
do {
Expand Down Expand Up @@ -8323,12 +8323,12 @@ rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap)

bitset = bits[0];
bitset >>= NUM_IN_PAGE(p);
rgengc_rememberset_mark_in_plane(objspace, (uintptr_t)p, bitset);
rgengc_rememberset_mark_plane(objspace, (uintptr_t)p, bitset);
p += (BITS_BITLENGTH - NUM_IN_PAGE(p));

for (j=1; j < HEAP_PAGE_BITMAP_LIMIT; j++) {
bitset = bits[j];
rgengc_rememberset_mark_in_plane(objspace, (uintptr_t)p, bitset);
rgengc_rememberset_mark_plane(objspace, (uintptr_t)p, bitset);
p += BITS_BITLENGTH;
}
}
Expand Down

0 comments on commit 0815390

Please sign in to comment.