int max_deficit = GC_rate * n;
for (i = GC_deficit; i < max_deficit; i++) {
- if (GC_mark_some((ptr_t)0)) {
- /* Need to finish a collection */
-# ifdef SAVE_CALL_CHAIN
- GC_save_callers(GC_last_stack);
-# endif
-# ifdef PARALLEL_MARK
- if (GC_parallel)
- GC_wait_for_reclaim();
-# endif
- if (GC_n_attempts < max_prior_attempts
- && GC_time_limit != GC_TIME_UNLIMITED) {
-# ifndef NO_CLOCK
+ if (GC_mark_some(NULL))
+ break;
+ }
+
+ if (i < max_deficit) {
+ /* Need to finish a collection. */
+# ifdef SAVE_CALL_CHAIN
+ GC_save_callers(GC_last_stack);
+# endif
+# ifdef PARALLEL_MARK
+ if (GC_parallel)
+ GC_wait_for_reclaim();
+# endif
+ if (GC_n_attempts < max_prior_attempts
+ && GC_time_limit != GC_TIME_UNLIMITED) {
+# ifndef NO_CLOCK
GET_TIME(GC_start_time);
-# endif
- if (!GC_stopped_mark(GC_timeout_stop_func)) {
- GC_n_attempts++;
- break;
- }
+# endif
+ if (GC_stopped_mark(GC_timeout_stop_func)) {
+ GC_finish_collection();
} else {
- /* TODO: If possible, GC_default_stop_func should be */
- /* used here. */
- (void)GC_stopped_mark(GC_never_stop_func);
+ GC_n_attempts++;
}
+ } else {
+ /* TODO: If possible, GC_default_stop_func should be */
+ /* used here. */
+ (void)GC_stopped_mark(GC_never_stop_func);
GC_finish_collection();
- break;
}
}
if (GC_deficit > 0) {
*/
STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func)
{
- unsigned i;
+ int i;
# ifndef NO_CLOCK
CLOCK_TYPE start_time = CLOCK_TYPE_INITIALIZER;
# endif
GC_noop6(0,0,0,0,0,0);
GC_initiate_gc();
- for (i = 0;;i++) {
- if ((*stop_func)()) {
- GC_COND_LOG_PRINTF("Abandoned stopped marking after"
- " %u iterations\n", i);
- GC_deficit = i; /* Give the mutator a chance. */
-# ifdef THREAD_LOCAL_ALLOC
- GC_world_stopped = FALSE;
-# endif
+ for (i = 0; !(*stop_func)(); i++) {
+ if (GC_mark_some(GC_approx_sp())) {
+ i = -1;
+ break;
+ }
+ }
-# ifdef THREADS
- if (GC_on_collection_event)
- GC_on_collection_event(GC_EVENT_PRE_START_WORLD);
-# endif
+ if (i >= 0) {
+ GC_COND_LOG_PRINTF("Abandoned stopped marking after"
+ " %d iterations\n", i);
+ GC_deficit = i; /* Give the mutator a chance. */
+# ifdef THREAD_LOCAL_ALLOC
+ GC_world_stopped = FALSE;
+# endif
- START_WORLD();
+# ifdef THREADS
+ if (GC_on_collection_event)
+ GC_on_collection_event(GC_EVENT_PRE_START_WORLD);
+# endif
-# ifdef THREADS
- if (GC_on_collection_event)
- GC_on_collection_event(GC_EVENT_POST_START_WORLD);
-# endif
+ START_WORLD();
- /* TODO: Notify GC_EVENT_MARK_ABANDON */
- return(FALSE);
- }
- if (GC_mark_some(GC_approx_sp())) break;
+# ifdef THREADS
+ if (GC_on_collection_event)
+ GC_on_collection_event(GC_EVENT_POST_START_WORLD);
+# endif
+
+ /* TODO: Notify GC_EVENT_MARK_ABANDON */
+ return FALSE;
}
GC_gc_no++;