@@ -622,16 +622,16 @@ typedef struct rb_objspace {
622622
623623 struct {
624624 unsigned int mode : 2 ;
625- unsigned int immediate_sweep : 1 ;
626- unsigned int dont_incremental : 1 ;
627- unsigned int during_compacting : 1 ;
628- #if RUBY_DEBUG
629- unsigned int was_compacting : 1 ;
630- #endif
631625 unsigned int during_reference_updating : 1 ;
632- unsigned int during_incremental_marking : 1 ;
633626 unsigned int measure_gc : 1 ;
634627 } flags ;
628+ bool during_incremental_marking ;
629+ bool immediate_sweep ;
630+ bool dont_incremental ;
631+ bool during_compacting ;
632+ #if RUBY_DEBUG
633+ bool was_compacting ;
634+ #endif
635635 bool during_lazy_sweeping ;
636636 bool during_minor_gc ;
637637 bool during_gc ;
@@ -1624,7 +1624,7 @@ total_final_slots_count(rb_objspace_t *objspace)
16241624#define is_marking (objspace ) (gc_mode(objspace) == gc_mode_marking)
16251625#define is_sweeping (objspace ) (gc_mode(objspace) == gc_mode_sweeping)
16261626#define is_full_marking (objspace ) ((objspace)->during_minor_gc == FALSE)
1627- #define is_incremental_marking (objspace ) ((objspace)->flags. during_incremental_marking != FALSE)
1627+ #define is_incremental_marking (objspace ) ((objspace)->during_incremental_marking != FALSE)
16281628#define will_be_incremental_marking (objspace ) ((objspace)->rgengc.need_major_gc != GPR_FLAG_NONE)
16291629/*
16301630 * Byte budget for incremental sweep steps. Each step sweeps at most
@@ -3314,7 +3314,7 @@ objspace_each_objects_ensure(VALUE arg)
33143314
33153315 /* Reenable incremental GC */
33163316 if (data -> reenable_incremental ) {
3317- objspace -> flags . dont_incremental = FALSE;
3317+ objspace -> dont_incremental = FALSE;
33183318 }
33193319
33203320 for (int i = 0 ; i < HEAP_COUNT ; i ++ ) {
@@ -3396,10 +3396,10 @@ objspace_each_exec(bool protected, struct each_obj_data *each_obj_data)
33963396 rb_objspace_t * objspace = each_obj_data -> objspace ;
33973397 bool reenable_incremental = FALSE;
33983398 if (protected ) {
3399- reenable_incremental = !objspace -> flags . dont_incremental ;
3399+ reenable_incremental = !objspace -> dont_incremental ;
34003400
34013401 gc_rest (objspace );
3402- objspace -> flags . dont_incremental = TRUE;
3402+ objspace -> dont_incremental = TRUE;
34033403 }
34043404
34053405 each_obj_data -> reenable_incremental = reenable_incremental ;
@@ -3647,7 +3647,7 @@ gc_abort(void *objspace_ptr)
36473647 VALUE obj ;
36483648 while (pop_mark_stack (& objspace -> mark_stack , & obj ));
36493649
3650- objspace -> flags . during_incremental_marking = FALSE;
3650+ objspace -> during_incremental_marking = FALSE;
36513651 }
36523652
36533653#if USE_PARALLEL_SWEEP
@@ -3751,7 +3751,7 @@ rb_gc_impl_shutdown_call_finalizer(void *objspace_ptr)
37513751#endif
37523752
37533753 /* prohibit incremental GC */
3754- objspace -> flags . dont_incremental = 1 ;
3754+ objspace -> dont_incremental = 1 ;
37553755
37563756 if (RUBY_ATOMIC_EXCHANGE (finalizing , 1 )) {
37573757 /* Abort incremental marking and lazy sweeping to speed up shutdown. */
@@ -4170,7 +4170,7 @@ gc_compact_finish(rb_objspace_t *objspace)
41704170 gc_profile_record * record = gc_prof_record (objspace );
41714171 record -> moved_objects = objspace -> rcompactor .total_moved - record -> moved_objects ;
41724172 }
4173- objspace -> flags . during_compacting = FALSE;
4173+ objspace -> during_compacting = FALSE;
41744174}
41754175
41764176struct gc_sweep_context {
@@ -4197,7 +4197,7 @@ gc_sweep_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bit
41974197 if (bitset & 1 ) {
41984198 switch (BUILTIN_TYPE (vp )) {
41994199 case T_MOVED :
4200- if (RB_UNLIKELY (objspace -> flags . during_compacting )) {
4200+ if (RB_UNLIKELY (objspace -> during_compacting )) {
42014201 /* The sweep cursor shouldn't have made it to any
42024202 * T_MOVED slots while the compact flag is enabled.
42034203 * The sweep cursor and compact cursor move in
@@ -4367,7 +4367,7 @@ gc_post_sweep_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *s
43674367 gc_report (2 , objspace , "post_page_sweep: start.\n" );
43684368
43694369#if RGENGC_CHECK_MODE
4370- if (!objspace -> flags . immediate_sweep ) {
4370+ if (!objspace -> immediate_sweep ) {
43714371 GC_ASSERT (sweep_page -> before_sweep );
43724372 }
43734373#endif
@@ -4423,7 +4423,7 @@ gc_sweep_page(rb_objspace_t *objspace, rb_heap_t *heap, struct gc_sweep_context
44234423 psweep_debug (1 , "[gc] gc_sweep_page: heap:%p (%ld) page:%p\n" , heap , heap - heaps , sweep_page );
44244424
44254425#if RGENGC_CHECK_MODE
4426- if (!objspace -> flags . immediate_sweep ) {
4426+ if (!objspace -> immediate_sweep ) {
44274427 GC_ASSERT (sweep_page -> before_sweep );
44284428 }
44294429#endif
@@ -5290,7 +5290,7 @@ gc_sweep_start_heap(rb_objspace_t *objspace, rb_heap_t *heap)
52905290
52915291#if USE_PARALLEL_SWEEP
52925292 /* During compaction we defer building the snapshot until gc_sweep_compact has finished */
5293- const bool build_snapshot = !objspace -> flags . during_compacting ;
5293+ const bool build_snapshot = !objspace -> during_compacting ;
52945294
52955295 if (build_snapshot ) {
52965296 if (rb_darray_capa (heap -> sweep_pages ) < heap -> total_pages ) {
@@ -5415,7 +5415,7 @@ gc_sweep_start(rb_objspace_t *objspace)
54155415 }
54165416
54175417#if GC_CAN_COMPILE_COMPACTION
5418- if (objspace -> flags . during_compacting ) {
5418+ if (objspace -> during_compacting ) {
54195419 gc_sort_heap_by_compare_func (
54205420 objspace ,
54215421 objspace -> rcompactor .compare_func ? objspace -> rcompactor .compare_func : compare_pinned_slots
@@ -5441,7 +5441,7 @@ gc_sweep_start(rb_objspace_t *objspace)
54415441 psweep_debug (1 , "[gc] gc_sweep_start\n" );
54425442 bool do_signal = false;
54435443 if (objspace -> sweep_thread &&
5444- !objspace -> flags . during_compacting &&
5444+ !objspace -> during_compacting &&
54455445 !(objspace -> hook_events & RUBY_INTERNAL_EVENT_FREEOBJ )) {
54465446 psweep_debug (-1 , "[gc] gc_sweep_start: requesting sweep thread\n" );
54475447 objspace -> use_background_sweep_thread = true;
@@ -5478,7 +5478,7 @@ gc_sweep_finish_heap(rb_objspace_t *objspace, rb_heap_t *heap)
54785478 heap -> is_finished_sweeping = true;
54795479 heap -> sweeping_page = NULL ;
54805480#if RUBY_DEBUG
5481- if (!objspace -> flags . was_compacting ) {
5481+ if (!objspace -> was_compacting ) {
54825482 if (heap -> total_pages + heap -> unlinked_pages != rb_darray_size (heap -> sweep_pages )) {
54835483 rb_bug ("sweep_pages:%lu, total_pages:%lu, unlinked pages:%lu\n" , rb_darray_size (heap -> sweep_pages ), heap -> total_pages , heap -> unlinked_pages );
54845484 }
@@ -5491,7 +5491,7 @@ gc_sweep_finish_heap(rb_objspace_t *objspace, rb_heap_t *heap)
54915491#endif // USE_PARALLEL_SWEEP
54925492
54935493#if RUBY_DEBUG
5494- if (!objspace -> flags . during_compacting ) {
5494+ if (!objspace -> during_compacting ) {
54955495 objspace -> have_swept_slots += swept_slots ;
54965496 objspace -> have_swept_slots += heap -> made_zombies ;
54975497 objspace -> will_be_swept_slots -= heap -> zombie_slots ;
@@ -5544,9 +5544,9 @@ gc_sweep_finish(rb_objspace_t *objspace)
55445544
55455545#if RUBY_DEBUG
55465546#if USE_PARALLEL_SWEEP
5547- if (!objspace -> flags . was_compacting && !objspace -> sweep_rest && gc_config_full_mark_val ) {
5547+ if (!objspace -> was_compacting && !objspace -> sweep_rest && gc_config_full_mark_val ) {
55485548#else
5549- if (!objspace -> flags . was_compacting && gc_config_full_mark_val ) {
5549+ if (!objspace -> was_compacting && gc_config_full_mark_val ) {
55505550#endif
55515551 if (objspace -> will_be_swept_slots != objspace -> have_swept_slots ) {
55525552 fprintf (stderr , "Expecting to free %lu slots, freed %lu slots (major:%d)\n" , objspace -> will_be_swept_slots , objspace -> have_swept_slots , is_full_marking (objspace ));
@@ -5559,7 +5559,7 @@ gc_sweep_finish(rb_objspace_t *objspace)
55595559 rb_bug ("MISMATCH: marked_slots:%lu, pooled_slots:%lu, empty_pages:%lu" , objspace -> marked_slots , objspace -> rincgc .pooled_slots , objspace -> empty_pages_count );
55605560 }
55615561 }
5562- objspace -> flags . was_compacting = FALSE;
5562+ objspace -> was_compacting = FALSE;
55635563#endif
55645564
55655565 gc_prof_set_heap_info (objspace );
@@ -6192,14 +6192,14 @@ static void gc_sweep_compact(rb_objspace_t *objspace);
61926192static void
61936193gc_sweep (rb_objspace_t * objspace )
61946194{
6195- const unsigned int immediate_sweep = objspace -> flags . immediate_sweep ;
6195+ const unsigned int immediate_sweep = objspace -> immediate_sweep ;
61966196
61976197 gc_sweeping_enter (objspace , "gc_sweep" );
61986198
61996199 gc_report (1 , objspace , "gc_sweep: immediate: %d\n" , immediate_sweep );
62006200
62016201 gc_sweep_start (objspace );
6202- if (objspace -> flags . during_compacting ) {
6202+ if (objspace -> during_compacting ) {
62036203 gc_sweep_compact (objspace );
62046204#if USE_PARALLEL_SWEEP
62056205 /* Snapshot was deliberately deferred in gc_sweep_start_heap — build it
@@ -6546,7 +6546,7 @@ static inline void
65466546gc_pin (rb_objspace_t * objspace , VALUE obj )
65476547{
65486548 GC_ASSERT (!SPECIAL_CONST_P (obj ));
6549- if (RB_UNLIKELY (objspace -> flags . during_compacting )) {
6549+ if (RB_UNLIKELY (objspace -> during_compacting )) {
65506550 if (RB_LIKELY (during_gc )) {
65516551 if (!RVALUE_PINNED (objspace , obj )) {
65526552 GC_ASSERT (GET_HEAP_PAGE (obj )-> pinned_slots <= GET_HEAP_PAGE (obj )-> total_slots );
@@ -6570,7 +6570,7 @@ rb_gc_impl_mark_and_move(void *objspace_ptr, VALUE *ptr)
65706570 rb_objspace_t * objspace = objspace_ptr ;
65716571
65726572 if (RB_UNLIKELY (objspace -> flags .during_reference_updating )) {
6573- GC_ASSERT (objspace -> flags . during_compacting );
6573+ GC_ASSERT (objspace -> during_compacting );
65746574 GC_ASSERT (during_gc );
65756575
65766576 VALUE destination = rb_gc_impl_location (objspace , * ptr );
@@ -7495,7 +7495,7 @@ gc_marks_finish(rb_objspace_t *objspace)
74957495 }
74967496#endif
74977497
7498- objspace -> flags . during_incremental_marking = FALSE;
7498+ objspace -> during_incremental_marking = FALSE;
74997499 /* check children of all marked wb-unprotected objects */
75007500 for (int i = 0 ; i < HEAP_COUNT ; i ++ ) {
75017501 gc_marks_wb_unprotected_objects (objspace , & heaps [i ]);
@@ -7528,7 +7528,7 @@ gc_marks_finish(rb_objspace_t *objspace)
75287528
75297529 int full_marking = is_full_marking (objspace );
75307530#if RUBY_DEBUG
7531- if (!objspace -> flags . during_compacting ) {
7531+ if (!objspace -> during_compacting ) {
75327532 objspace -> have_swept_slots = 0 ;
75337533 objspace -> will_be_swept_slots = sweep_slots ;
75347534 }
@@ -7851,7 +7851,7 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark)
78517851 objspace -> marked_slots , objspace -> rincgc .pooled_slots , objspace -> rincgc .step_slots );
78527852 objspace -> during_minor_gc = FALSE;
78537853 if (ruby_enable_autocompact ) {
7854- objspace -> flags . during_compacting |= TRUE;
7854+ objspace -> during_compacting |= TRUE;
78557855 }
78567856 objspace -> profile .major_gc_count ++ ;
78577857 objspace -> rgengc .uncollectible_wb_unprotected_objects = 0 ;
@@ -7864,7 +7864,7 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark)
78647864 rgengc_mark_and_rememberset_clear (objspace , heap );
78657865 heap_move_pooled_pages_to_free_pages (heap );
78667866
7867- if (objspace -> flags . during_compacting ) {
7867+ if (objspace -> during_compacting ) {
78687868 struct heap_page * page = NULL ;
78697869
78707870 ccan_list_for_each (& heap -> pages , page , page_node ) {
@@ -8149,7 +8149,7 @@ gc_writebarrier_incremental(VALUE a, VALUE b, rb_objspace_t *objspace)
81498149 rgengc_remember (objspace , a );
81508150 }
81518151
8152- if (RB_UNLIKELY (objspace -> flags . during_compacting )) {
8152+ if (RB_UNLIKELY (objspace -> during_compacting )) {
81538153 MARK_IN_BITMAP (GET_HEAP_PINNED_BITS (b ), b );
81548154 }
81558155 }
@@ -8501,7 +8501,7 @@ gc_start(rb_objspace_t *objspace, unsigned int reason)
85018501 gc_enter (objspace , gc_enter_event_start , & lock_lev );
85028502
85038503 /* reason may be clobbered, later, so keep set immediate_sweep here */
8504- objspace -> flags . immediate_sweep = !!(reason & GPR_FLAG_IMMEDIATE_SWEEP );
8504+ objspace -> immediate_sweep = !!(reason & GPR_FLAG_IMMEDIATE_SWEEP );
85058505
85068506#if RGENGC_CHECK_MODE >= 2
85078507 gc_verify_internal_consistency (objspace );
@@ -8514,7 +8514,7 @@ gc_start(rb_objspace_t *objspace, unsigned int reason)
85148514 do_full_mark = TRUE;
85158515 }
85168516
8517- objspace -> flags . immediate_sweep = !(flag & (1 <<gc_stress_no_immediate_sweep ));
8517+ objspace -> immediate_sweep = !(flag & (1 <<gc_stress_no_immediate_sweep ));
85188518 }
85198519
85208520 if (gc_needs_major_flags ) {
@@ -8532,41 +8532,41 @@ gc_start(rb_objspace_t *objspace, unsigned int reason)
85328532 reason |= GPR_FLAG_MAJOR_BY_FORCE ; /* GC by CAPI, METHOD, and so on. */
85338533 }
85348534
8535- if (objspace -> flags . dont_incremental ||
8535+ if (objspace -> dont_incremental ||
85368536 reason & GPR_FLAG_IMMEDIATE_MARK ||
85378537 ruby_gc_stressful ) {
8538- objspace -> flags . during_incremental_marking = FALSE;
8538+ objspace -> during_incremental_marking = FALSE;
85398539 }
85408540 else {
8541- objspace -> flags . during_incremental_marking = do_full_mark ;
8541+ objspace -> during_incremental_marking = do_full_mark ;
85428542 }
85438543
85448544 /* Explicitly enable compaction (GC.compact) */
85458545 if (do_full_mark && ruby_enable_autocompact ) {
8546- objspace -> flags . during_compacting = TRUE;
8546+ objspace -> during_compacting = TRUE;
85478547#if RUBY_DEBUG
8548- objspace -> flags . was_compacting = TRUE;
8548+ objspace -> was_compacting = TRUE;
85498549#endif
85508550#if RGENGC_CHECK_MODE
85518551 objspace -> rcompactor .compare_func = ruby_autocompact_compare_func ;
85528552#endif
85538553 }
85548554 else {
8555- objspace -> flags . during_compacting = !!(reason & GPR_FLAG_COMPACT );
8555+ objspace -> during_compacting = !!(reason & GPR_FLAG_COMPACT );
85568556#if RUBY_DEBUG
8557- objspace -> flags . was_compacting = objspace -> flags . during_compacting ;
8557+ objspace -> was_compacting = objspace -> during_compacting ;
85588558#endif
85598559 }
85608560
8561- if (!GC_ENABLE_LAZY_SWEEP || objspace -> flags . dont_incremental ) {
8562- objspace -> flags . immediate_sweep = TRUE;
8561+ if (!GC_ENABLE_LAZY_SWEEP || objspace -> dont_incremental ) {
8562+ objspace -> immediate_sweep = TRUE;
85638563 }
85648564
8565- if (objspace -> flags . immediate_sweep ) reason |= GPR_FLAG_IMMEDIATE_SWEEP ;
8565+ if (objspace -> immediate_sweep ) reason |= GPR_FLAG_IMMEDIATE_SWEEP ;
85668566
85678567 gc_report (1 , objspace , "gc_start(reason: %x) => %u, %d, %d\n" ,
85688568 reason ,
8569- do_full_mark , !is_incremental_marking (objspace ), objspace -> flags . immediate_sweep );
8569+ do_full_mark , !is_incremental_marking (objspace ), objspace -> immediate_sweep );
85708570
85718571 RB_DEBUG_COUNTER_INC (gc_count );
85728572
@@ -8936,7 +8936,7 @@ gc_sweeping_enter(rb_objspace_t *objspace, const char *from_fn)
89368936 GC_ASSERT (during_gc != 0 );
89378937
89388938#if USE_PARALLEL_SWEEP
8939- MAYBE_UNUSED (const unsigned int immediate_sweep ) = objspace -> flags . immediate_sweep ;
8939+ MAYBE_UNUSED (const unsigned int immediate_sweep ) = objspace -> immediate_sweep ;
89408940 psweep_debug (1 , "[gc] gc_sweeping_enter from %s (immediate:%u)\n" , from_fn , immediate_sweep );
89418941 sweep_lock_lock (objspace );
89428942 {
0 commit comments