@@ -462,14 +462,21 @@ void rb_gc_impl_set_params(void *objspace_ptr) { }
462462
463463static VALUE gc_verify_internal_consistency (VALUE self ) { return Qnil ; }
464464
465+ #define MMTK_HEAP_COUNT 5
466+ #define MMTK_MAX_OBJ_SIZE 640
467+
468+ static size_t heap_sizes [MMTK_HEAP_COUNT + 1 ] = {
469+ 40 , 80 , 160 , 320 , MMTK_MAX_OBJ_SIZE , 0
470+ };
471+
465472void
466473rb_gc_impl_init (void )
467474{
468475 VALUE gc_constants = rb_hash_new ();
469476 rb_hash_aset (gc_constants , ID2SYM (rb_intern ("BASE_SLOT_SIZE" )), SIZET2NUM (sizeof (VALUE ) * 5 ));
470477 rb_hash_aset (gc_constants , ID2SYM (rb_intern ("RBASIC_SIZE" )), SIZET2NUM (sizeof (struct RBasic )));
471478 rb_hash_aset (gc_constants , ID2SYM (rb_intern ("RVALUE_OVERHEAD" )), INT2NUM (0 ));
472- rb_hash_aset (gc_constants , ID2SYM (rb_intern ("RVARGC_MAX_ALLOCATE_SIZE" )), LONG2FIX (640 ));
479+ rb_hash_aset (gc_constants , ID2SYM (rb_intern ("RVARGC_MAX_ALLOCATE_SIZE" )), LONG2FIX (MMTK_MAX_OBJ_SIZE ));
473480 // Pretend we have 5 size pools
474481 rb_hash_aset (gc_constants , ID2SYM (rb_intern ("SIZE_POOL_COUNT" )), LONG2FIX (5 ));
475482 OBJ_FREEZE (gc_constants );
@@ -485,12 +492,6 @@ rb_gc_impl_init(void)
485492 rb_define_singleton_method (rb_mGC , "verify_compaction_references" , rb_f_notimplement , -1 );
486493}
487494
488- #define MMTK_HEAP_COUNT 5
489-
490- static size_t heap_sizes [MMTK_HEAP_COUNT + 1 ] = {
491- 40 , 80 , 160 , 320 , 640 , 0
492- };
493-
494495size_t *
495496rb_gc_impl_heap_sizes (void * objspace_ptr )
496497{
@@ -611,7 +612,7 @@ rb_gc_impl_new_obj(void *objspace_ptr, void *cache_ptr, VALUE klass, VALUE flags
611612 struct objspace * objspace = objspace_ptr ;
612613 struct MMTk_ractor_cache * ractor_cache = cache_ptr ;
613614
614- if (alloc_size > 640 ) rb_bug ("too big" );
615+ if (alloc_size > MMTK_MAX_OBJ_SIZE ) rb_bug ("too big" );
615616 for (int i = 0 ; i < MMTK_HEAP_COUNT ; i ++ ) {
616617 if (alloc_size == heap_sizes [i ]) break ;
617618 if (alloc_size < heap_sizes [i ]) {
@@ -660,7 +661,7 @@ rb_gc_impl_heap_id_for_size(void *objspace_ptr, size_t size)
660661bool
661662rb_gc_impl_size_allocatable_p (size_t size )
662663{
663- return size <= 640 ;
664+ return size <= MMTK_MAX_OBJ_SIZE ;
664665}
665666
666667// Malloc
0 commit comments