ruby-changes:35382
From: ko1 <ko1@a...>
Date: Tue, 9 Sep 2014 12:13:35 +0900 (JST)
Subject: [ruby-changes:35382] ko1:r47464 (trunk): * gc.c: rename gc_stat entries and check stat transition.
ko1 2014-09-09 12:13:25 +0900 (Tue, 09 Sep 2014) New Revision: 47464 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47464 Log: * gc.c: rename gc_stat entries and check stat transition. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 47463) +++ ChangeLog (revision 47464) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Sep 9 12:11:41 2014 Koichi Sasada <ko1@a...> + + * gc.c: rename gc_stat entries and check stat transition. + Tue Sep 9 12:06:03 2014 Koichi Sasada <ko1@a...> * gc.c (gc_sweep_rest): remove wrong modification of during_gc flag. Index: gc.c =================================================================== --- gc.c (revision 47463) +++ gc.c (revision 47464) @@ -449,9 +449,9 @@ typedef struct rb_heap_struct { https://github.com/ruby/ruby/blob/trunk/gc.c#L449 } rb_heap_t; enum gc_stat { - none, - marking, - sweeping + gc_stat_none, + gc_stat_marking, + gc_stat_sweeping }; typedef struct rb_objspace { @@ -687,8 +687,8 @@ VALUE *ruby_initial_gc_stress_ptr = &rb_ https://github.com/ruby/ruby/blob/trunk/gc.c#L687 #define global_list objspace->global_list #define ruby_gc_stress objspace->gc_stress -#define is_marking(objspace) ((objspace)->flags.stat == marking) -#define is_sweeping(objspace) ((objspace)->flags.stat == sweeping) +#define is_marking(objspace) ((objspace)->flags.stat == gc_stat_marking) +#define is_sweeping(objspace) ((objspace)->flags.stat == gc_stat_sweeping) #define is_full_marking(objspace) ((objspace)->flags.during_minor_gc == FALSE) #if GC_ENABLE_INCREMENTAL_MARK #define is_incremental_marking(objspace) ((objspace)->flags.during_incremental_marking != FALSE) @@ -3161,6 +3161,20 @@ gc_heap_prepare_minimum_pages(rb_objspac https://github.com/ruby/ruby/blob/trunk/gc.c#L3161 } static void +gc_stat_transition(rb_objspace_t *objspace, enum gc_stat stat) +{ +#if RGEGNC_CHECK_MODE + enum gc_stat prev_stat = objspace->flags.stat; + switch (prev_stat) { + case gc_stat_none: assert(stat == gc_stat_marking); break; + case gc_stat_mark: assert(stat == gc_stat_sweeping); break; + case gc_stat_sweep: assert(stat == gc_stat_none); break; + } +#endif + objspace->flags.stat = stat; +} + +static void gc_sweep_start_heap(rb_objspace_t *objspace, rb_heap_t *heap) { heap->sweep_pages = heap->pages; @@ -3187,7 +3201,7 @@ gc_sweep_start(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L3201 rb_heap_t *heap; size_t total_limit_slot; - objspace->flags.stat = sweeping; + gc_stat_transition(objspace, gc_stat_sweeping); /* sweep unlinked method entries */ if (GET_VM()->unlinked_method_entry_list) { @@ -3242,7 +3256,7 @@ gc_sweep_finish(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L3256 } #endif gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END_SWEEP, 0); - objspace->flags.stat = none; + gc_stat_transition(objspace, gc_stat_none); #if RGENGC_CHECK_MODE >= 2 gc_verify_internal_consistency(Qnil); @@ -4819,7 +4833,7 @@ gc_marks_start(rb_objspace_t *objspace, https://github.com/ruby/ruby/blob/trunk/gc.c#L4833 { /* start marking */ gc_report(1, objspace, "gc_marks_start: (%s)\n", full_mark ? "full" : "minor"); - objspace->flags.stat = marking; + gc_stat_transition(objspace, gc_stat_marking); #if USE_RGENGC objspace->rgengc.old_object_count_at_gc_start = objspace->rgengc.old_object_count; @@ -5768,7 +5782,7 @@ gc_start(rb_objspace_t *objspace, const https://github.com/ruby/ruby/blob/trunk/gc.c#L5782 if (!ready_to_gc(objspace)) return TRUE; /* GC is not allowed */ if (RGENGC_CHECK_MODE) { - assert(objspace->flags.stat == none); + assert(objspace->flags.stat == gc_stat_none); assert(!is_lazy_sweeping(heap_eden)); assert(!is_incremental_marking(objspace)); #if RGENGC_CHECK_MODE >= 2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/