@@ -10611,16 +10611,18 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
1061110611#if USE_RVARGC
1061210612 VALUE new_root = any -> as .string .as .heap .aux .shared ;
1061310613 rb_str_update_shared_ary (obj , old_root , new_root );
10614+ #endif
10615+ }
1061410616
10615- // if, after move the string is not embedded, and can fit in the
10616- // slot it's been placed in, then re-embed it
10617- if ( rb_gc_obj_slot_size ( obj ) >= rb_str_size_as_embedded ( obj )) {
10618- if (! STR_EMBED_P (obj ) && rb_str_reembeddable_p (obj )) {
10619- rb_str_make_embedded (obj );
10620- }
10617+ #if USE_RVARGC
10618+ /* If, after move the string is not embedded, and can fit in the
10619+ * slot it's been placed in, then re-embed it. */
10620+ if (rb_gc_obj_slot_size (obj ) >= rb_str_size_as_embedded (obj )) {
10621+ if (! STR_EMBED_P ( obj ) && rb_str_reembeddable_p (obj )) {
10622+ rb_str_make_embedded ( obj );
1062110623 }
10622- #endif
1062310624 }
10625+ #endif
1062410626
1062510627 break ;
1062610628 }
@@ -11719,24 +11721,25 @@ get_envparam_double(const char *name, double *default_value, double lower_bound,
1171911721}
1172011722
1172111723static void
11722- gc_set_initial_pages (void )
11724+ gc_set_initial_pages (rb_objspace_t * objspace )
1172311725{
11724- size_t min_pages ;
11725- rb_objspace_t * objspace = & rb_objspace ;
11726-
1172711726 gc_rest (objspace );
1172811727
11729- min_pages = gc_params .heap_init_slots / HEAP_PAGE_OBJ_LIMIT ;
11730-
11731- size_t pages_per_class = (min_pages - heap_eden_total_pages (objspace )) / SIZE_POOL_COUNT ;
11732-
1173311728 for (int i = 0 ; i < SIZE_POOL_COUNT ; i ++ ) {
1173411729 rb_size_pool_t * size_pool = & size_pools [i ];
1173511730
11736- heap_add_pages (objspace , size_pool , SIZE_POOL_EDEN_HEAP (size_pool ), pages_per_class );
11731+ if (gc_params .heap_init_slots > size_pool -> eden_heap .total_slots ) {
11732+ size_t slots = gc_params .heap_init_slots - size_pool -> eden_heap .total_slots ;
11733+ int multiple = size_pool -> slot_size / BASE_SLOT_SIZE ;
11734+ size_pool -> allocatable_pages = slots * multiple / HEAP_PAGE_OBJ_LIMIT ;
11735+ }
11736+ else {
11737+ /* We already have more slots than heap_init_slots allows, so
11738+ * prevent creating more pages. */
11739+ size_pool -> allocatable_pages = 0 ;
11740+ }
1173711741 }
11738-
11739- heap_add_pages (objspace , & size_pools [0 ], SIZE_POOL_EDEN_HEAP (& size_pools [0 ]), min_pages - heap_eden_total_pages (objspace ));
11742+ heap_pages_expand_sorted (objspace );
1174011743}
1174111744
1174211745/*
@@ -11792,7 +11795,7 @@ ruby_gc_set_params(void)
1179211795
1179311796 /* RUBY_GC_HEAP_INIT_SLOTS */
1179411797 if (get_envparam_size ("RUBY_GC_HEAP_INIT_SLOTS" , & gc_params .heap_init_slots , 0 )) {
11795- gc_set_initial_pages ();
11798+ gc_set_initial_pages (objspace );
1179611799 }
1179711800
1179811801 get_envparam_double ("RUBY_GC_HEAP_GROWTH_FACTOR" , & gc_params .growth_factor , 1.0 , 0.0 , FALSE);
@@ -12840,6 +12843,7 @@ wmap_free(void *ptr)
1284012843 st_foreach (w -> obj2wmap , wmap_free_map , 0 );
1284112844 st_free_table (w -> obj2wmap );
1284212845 st_free_table (w -> wmap2obj );
12846+ xfree (w );
1284312847}
1284412848
1284512849static int
0 commit comments