Skip to content

Commit f5f69d4

Browse files
committed
Implement heap_final_slots in GC.stat_heap
[Feature #20408]
1 parent 83bf054 commit f5f69d4

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

gc/default/default.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7594,6 +7594,7 @@ enum gc_stat_heap_sym {
75947594
gc_stat_heap_sym_slot_size,
75957595
gc_stat_heap_sym_heap_live_slots,
75967596
gc_stat_heap_sym_heap_free_slots,
7597+
gc_stat_heap_sym_heap_final_slots,
75977598
gc_stat_heap_sym_heap_eden_pages,
75987599
gc_stat_heap_sym_heap_eden_slots,
75997600
gc_stat_heap_sym_total_allocated_pages,
@@ -7614,6 +7615,7 @@ setup_gc_stat_heap_symbols(void)
76147615
S(slot_size);
76157616
S(heap_live_slots);
76167617
S(heap_free_slots);
7618+
S(heap_final_slots);
76177619
S(heap_eden_pages);
76187620
S(heap_eden_slots);
76197621
S(total_allocated_pages);
@@ -7637,6 +7639,7 @@ stat_one_heap(rb_heap_t *heap, VALUE hash, VALUE key)
76377639
SET(slot_size, heap->slot_size);
76387640
SET(heap_live_slots, heap->total_allocated_objects - heap->total_freed_objects - heap->final_slots_count);
76397641
SET(heap_free_slots, heap->total_slots - (heap->total_allocated_objects - heap->total_freed_objects));
7642+
SET(heap_final_slots, heap->final_slots_count);
76407643
SET(heap_eden_pages, heap->total_pages);
76417644
SET(heap_eden_slots, heap->total_slots);
76427645
SET(total_allocated_pages, heap->total_allocated_pages);

test/ruby/test_gc.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ def test_stat_heap
233233
assert_equal (GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE] + GC::INTERNAL_CONSTANTS[:RVALUE_OVERHEAD]) * (2**i), stat_heap[:slot_size]
234234
assert_operator stat_heap[:heap_live_slots], :<=, stat[:heap_live_slots]
235235
assert_operator stat_heap[:heap_free_slots], :<=, stat[:heap_free_slots]
236+
assert_operator stat_heap[:heap_final_slots], :<=, stat[:heap_final_slots]
236237
assert_operator stat_heap[:heap_eden_pages], :<=, stat[:heap_eden_pages]
237238
assert_operator stat_heap[:heap_eden_slots], :>=, 0
238239
assert_operator stat_heap[:total_allocated_pages], :>=, 0
@@ -290,6 +291,7 @@ def test_stat_heap_constraints
290291

291292
assert_equal stat[:heap_live_slots], stat_heap_sum[:heap_live_slots]
292293
assert_equal stat[:heap_free_slots], stat_heap_sum[:heap_free_slots]
294+
assert_equal stat[:heap_final_slots], stat_heap_sum[:heap_final_slots]
293295
assert_equal stat[:heap_eden_pages], stat_heap_sum[:heap_eden_pages]
294296
assert_equal stat[:heap_available_slots], stat_heap_sum[:heap_eden_slots]
295297
assert_equal stat[:total_allocated_objects], stat_heap_sum[:total_allocated_objects]

0 commit comments

Comments
 (0)