1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Refactor GC functions to have consistent naming

Refactor function names for consistency. Function with name xyz_page
should have a corresponding function named xyz_plane.
This commit is contained in:
Peter Zhu 2021-12-02 16:27:43 -05:00
parent 81eadd976f
commit 081539023a
Notes: git 2021-12-04 00:26:47 +09:00

36
gc.c
View file

@ -4868,7 +4868,7 @@ unlock_page_body(rb_objspace_t *objspace, struct heap_page_body *body)
} }
static inline bool 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) { if (bits) {
do { do {
@ -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_t bits = mark_bits[index] & ~pin_bits[index];
bits >>= NUM_IN_PAGE(p); 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) { if (index == 0) {
p = cursor->start + (BITS_BITLENGTH - NUM_IN_PAGE(cursor->start)); p = cursor->start + (BITS_BITLENGTH - NUM_IN_PAGE(cursor->start));
@ -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 */ * marked, so we iterate using the marking bitmap */
for (size_t i = index + 1; i < HEAP_PAGE_BITMAP_LIMIT; i++) { for (size_t i = index + 1; i < HEAP_PAGE_BITMAP_LIMIT; i++) {
bits_t bits = mark_bits[i] & ~pin_bits[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; p += BITS_BITLENGTH;
} }
@ -5181,7 +5181,7 @@ struct gc_sweep_context {
}; };
static inline void 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; struct heap_page * sweep_page = ctx->page;
@ -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. */ /* *Want to move* objects are pinned but not marked. */
bitset = pin_bits[0] & ~mark_bits[0]; bitset = pin_bits[0] & ~mark_bits[0];
bitset >>= NUM_IN_PAGE(p); // Skip header / dead space bits 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)); p += ((BITS_BITLENGTH - NUM_IN_PAGE(p)) * sizeof(RVALUE));
for (int i = 1; i < HEAP_PAGE_BITMAP_LIMIT; i++) { for (int i = 1; i < HEAP_PAGE_BITMAP_LIMIT; i++) {
/* *Want to move* objects are pinned but not marked. */ /* *Want to move* objects are pinned but not marked. */
bitset = pin_bits[i] & ~mark_bits[i]; 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)); p += ((BITS_BITLENGTH) * sizeof(RVALUE));
} }
@ -5274,7 +5274,7 @@ gc_fill_swept_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *s
} }
static inline void 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; struct heap_page * sweep_page = ctx->page;
short slot_size = sweep_page->slot_size; short slot_size = sweep_page->slot_size;
@ -5351,7 +5351,7 @@ gc_plane_sweep(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bit
} }
static inline void 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; struct heap_page *sweep_page = ctx->page;
@ -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 = ~bits[0];
bitset >>= NUM_IN_PAGE(p); bitset >>= NUM_IN_PAGE(p);
if (bitset) { 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)); p += (BITS_BITLENGTH - NUM_IN_PAGE(p));
for (i=1; i < HEAP_PAGE_BITMAP_LIMIT; i++) { for (i=1; i < HEAP_PAGE_BITMAP_LIMIT; i++) {
bitset = ~bits[i]; bitset = ~bits[i];
if (bitset) { 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; p += BITS_BITLENGTH;
} }
@ -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; record->empty_objects += ctx->empty_slots;
} }
#endif #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(), rb_gc_count(),
sweep_page->total_slots, sweep_page->total_slots,
ctx->freed_slots, ctx->empty_slots, ctx->final_slots); ctx->freed_slots, ctx->empty_slots, ctx->final_slots);
@ -5675,7 +5675,7 @@ gc_sweep_step(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea
.freed_slots = 0, .freed_slots = 0,
.empty_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; int free_slots = ctx.freed_slots + ctx.empty_slots;
heap->sweeping_page = list_next(&heap->pages, sweep_page, page_node); heap->sweeping_page = list_next(&heap->pages, sweep_page, page_node);
@ -7865,7 +7865,7 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark)
#if GC_ENABLE_INCREMENTAL_MARK #if GC_ENABLE_INCREMENTAL_MARK
static inline void 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) { if (bits) {
do { do {
@ -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_t bits = mark_bits[0] & wbun_bits[0];
bits >>= NUM_IN_PAGE(p); 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)); p += (BITS_BITLENGTH - NUM_IN_PAGE(p));
for (j=1; j<HEAP_PAGE_BITMAP_LIMIT; j++) { for (j=1; j<HEAP_PAGE_BITMAP_LIMIT; j++) {
bits_t bits = mark_bits[j] & wbun_bits[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; p += BITS_BITLENGTH;
} }
} }
@ -8275,7 +8275,7 @@ rgengc_remembered(rb_objspace_t *objspace, VALUE obj)
#endif #endif
static inline void 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) { if (bitset) {
do { do {
@ -8323,12 +8323,12 @@ rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap)
bitset = bits[0]; bitset = bits[0];
bitset >>= NUM_IN_PAGE(p); 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)); p += (BITS_BITLENGTH - NUM_IN_PAGE(p));
for (j=1; j < HEAP_PAGE_BITMAP_LIMIT; j++) { for (j=1; j < HEAP_PAGE_BITMAP_LIMIT; j++) {
bitset = bits[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; p += BITS_BITLENGTH;
} }
} }