Skip to content

Commit

Permalink
Always call GC_on_mark_stack_empty when mark stack top reached
Browse files Browse the repository at this point in the history
(fix of commit 0e63b39)

The previous check for GC_mark_stack_too_small did not indicated there
was not any room, rather that it was too small at some point during
marking.  If the stack had any content, it would set GC_mark_state to
MS_NONE and call alloc_mark_stack(), rather than call on_ms_empty()
first.

Without this change, GC_on_mark_stack_empty procedure would not be
executed when GC_mark_stack_too_small was set at any point during
a mark phase, e.g. in the MS_PUSH_RESCUERS case above.

* mark.c (GC_mark_some_inner): If on_ms_empty is non-zero, then call
on_ms_empty() even if GC_mark_stack_too_small (i.e. check
GC_mark_stack_too_small and call alloc_mark_stack() after on_ms_empty()
call); update comment.
  • Loading branch information
joncham authored and ivmai committed Feb 26, 2024
1 parent 6601eec commit c8c9f6d
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,24 +450,20 @@ GC_API GC_on_mark_stack_empty_proc GC_CALL GC_get_on_mark_stack_empty(void)
if ((word)GC_mark_stack_top >= (word)GC_mark_stack) {
MARK_FROM_MARK_STACK();
} else {
GC_on_mark_stack_empty_proc on_ms_empty;
GC_on_mark_stack_empty_proc on_ms_empty =
GC_on_mark_stack_empty;

if (GC_mark_stack_too_small) {
GC_mark_state = MS_NONE;
alloc_mark_stack(2*GC_mark_stack_size);
return TRUE;
}
on_ms_empty = GC_on_mark_stack_empty;
if (on_ms_empty != 0) {
GC_mark_stack_top = on_ms_empty(GC_mark_stack_top,
GC_mark_stack_limit);
/* If we pushed new items or overflowed the stack, */
/* we need to continue processing. */
if ((word)GC_mark_stack_top >= (word)GC_mark_stack
|| GC_mark_stack_too_small)
/* If we pushed new items, we need to continue */
/* processing. */
if ((word)GC_mark_stack_top >= (word)GC_mark_stack)
break;
}

if (GC_mark_stack_too_small) {
alloc_mark_stack(2*GC_mark_stack_size);
}
GC_mark_state = MS_NONE;
return TRUE;
}
Expand Down

0 comments on commit c8c9f6d

Please sign in to comment.