diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-05-05 21:39:33 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-05-06 10:03:39 +0300 |
commit | 750d393b91161c036bbd680054515587e9bfbc16 (patch) | |
tree | fd1e9e4805fe014fc1f1e5a2bd85dbfc245a0562 /mark.c | |
parent | 4c21deefd01a6687708c1116263316918d7b2650 (diff) | |
download | bdwgc-750d393b91161c036bbd680054515587e9bfbc16.tar.gz |
Add assertions about GC_mark_state to alloc.c and mark.c
* alloc.c (GC_collect_a_little_inner): Add assertion the collection
is not in progress; refine comment.
* alloc.c (GC_stopped_mark): Add assertion about allowed GC_mark_state
values on entry.
* mark.c (GC_initiate_gc): Replace conditional abort with an assertion
(about GC_mark_state value).
* mark.c (GC_mark_some_inner): Add assertion about possible
GC_mark_state values before every break in switch (i.e. on returning
FALSE).
Diffstat (limited to 'mark.c')
-rw-r--r-- | mark.c | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -252,9 +252,10 @@ GC_INNER void GC_initiate_gc(void) # endif if (GC_mark_state == MS_NONE) { GC_mark_state = MS_PUSH_RESCUERS; - } else if (GC_mark_state != MS_INVALID) { - ABORT("Unexpected state"); - } /* Else this is really a full collection, and mark bits are invalid. */ + } else { + GC_ASSERT(GC_mark_state == MS_INVALID); + /* This is really a full collection, and mark bits are invalid. */ + } GC_scan_ptr = NULL; } @@ -318,7 +319,6 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) /* in the future. */ GC_mark_stack_too_small = TRUE; MARK_FROM_MARK_STACK(); - break; } else { GC_scan_ptr = GC_push_next_marked_dirty(GC_scan_ptr); # ifndef GC_DISABLE_INCREMENTAL @@ -329,6 +329,9 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) # endif push_roots_and_advance(FALSE, cold_gc_frame); } + GC_ASSERT(GC_mark_state == MS_PUSH_RESCUERS + || GC_mark_state == MS_ROOTS_PUSHED + || GC_mark_state == MS_INVALID); break; case MS_PUSH_UNCOLLECTABLE: @@ -340,11 +343,13 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) if (GC_parallel) GC_mark_stack_too_small = TRUE; # endif MARK_FROM_MARK_STACK(); - break; } else { GC_scan_ptr = GC_push_next_marked_uncollectable(GC_scan_ptr); push_roots_and_advance(TRUE, cold_gc_frame); } + GC_ASSERT(GC_mark_state == MS_PUSH_UNCOLLECTABLE + || GC_mark_state == MS_ROOTS_PUSHED + || GC_mark_state == MS_INVALID); break; case MS_ROOTS_PUSHED: @@ -366,12 +371,12 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) GC_mark_state = MS_NONE; return TRUE; } + GC_ASSERT(GC_mark_state == MS_INVALID); break; } # endif if ((word)GC_mark_stack_top >= (word)GC_mark_stack) { MARK_FROM_MARK_STACK(); - break; } else { GC_mark_state = MS_NONE; if (GC_mark_stack_too_small) { @@ -379,6 +384,9 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) } return TRUE; } + GC_ASSERT(GC_mark_state == MS_ROOTS_PUSHED + || GC_mark_state == MS_INVALID); + break; case MS_INVALID: case MS_PARTIALLY_INVALID: @@ -388,6 +396,8 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) } if ((word)GC_mark_stack_top >= (word)GC_mark_stack) { MARK_FROM_MARK_STACK(); + GC_ASSERT(GC_mark_state == MS_PARTIALLY_INVALID + || GC_mark_state == MS_INVALID); break; } if (NULL == GC_scan_ptr && GC_mark_state == MS_INVALID) { @@ -401,6 +411,9 @@ static void push_roots_and_advance(GC_bool push_all, ptr_t cold_gc_frame) GC_scan_ptr = GC_push_next_marked(GC_scan_ptr); if (GC_mark_state == MS_PARTIALLY_INVALID) push_roots_and_advance(TRUE, cold_gc_frame); + GC_ASSERT(GC_mark_state == MS_ROOTS_PUSHED + || GC_mark_state == MS_PARTIALLY_INVALID + || GC_mark_state == MS_INVALID); break; default: |