Skip to content

Commit b6658c1

Browse files
Introduce RVALUE_SIZE GC constant
Add GC::INTERNAL_CONSTANTS[:RVALUE_SIZE] to store the usable size (excluding debug overhead) of the smallest pool that can hold a standard RVALUE.
1 parent c9b7088 commit b6658c1

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

gc/default/default.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9591,6 +9591,12 @@ rb_gc_impl_init(void)
95919591
{
95929592
VALUE gc_constants = rb_hash_new();
95939593
rb_hash_aset(gc_constants, ID2SYM(rb_intern("DEBUG")), GC_DEBUG ? Qtrue : Qfalse);
9594+
/* Minimum slot size that fits a standard RVALUE */
9595+
size_t rvalue_pool = 0;
9596+
for (size_t i = 0; i < HEAP_COUNT; i++) {
9597+
if (pool_slot_sizes[i] >= RVALUE_SLOT_SIZE) { rvalue_pool = pool_slot_sizes[i]; break; }
9598+
}
9599+
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(rvalue_pool - RVALUE_OVERHEAD));
95949600
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RBASIC_SIZE")), SIZET2NUM(sizeof(struct RBasic)));
95959601
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OVERHEAD")), SIZET2NUM(RVALUE_OVERHEAD));
95969602
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_BITMAP_SIZE")), SIZET2NUM(HEAP_PAGE_BITMAP_SIZE));

gc/mmtk/mmtk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ void
653653
rb_gc_impl_init(void)
654654
{
655655
VALUE gc_constants = rb_hash_new();
656+
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(SIZEOF_VALUE >= 8 ? 64 : 32));
656657
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RBASIC_SIZE")), SIZET2NUM(sizeof(struct RBasic)));
657658
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OVERHEAD")), INT2NUM(0));
658659
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVARGC_MAX_ALLOCATE_SIZE")), LONG2FIX(MMTK_MAX_OBJ_SIZE));

0 commit comments

Comments
 (0)