From bc494ba9e73aae1d127a7b8f67d522337fca8bf4 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 28 Jan 2012 19:28:13 +0400 Subject: [PATCH] Make GC_parallel a synonym to GC_markers_m1 * include/gc.h (GC_parallel, GC_enable_incremental): Update comment. * include/private/gc_priv.h (GC_markers_m1): Define as a synonym (macro) to GC_parallel instead of declaring a global variable (only if PARALLEL_MARKER); update the comment. * mark.c (GC_markers_m1): Remove global variable. * pthread_support.c (start_mark_threads): Remove unnecessary GC_parallel zeroing (after setting GC_markers_m1 to 0). * win32_threads.c (start_mark_threads): Likewise. * pthread_support.c (GC_fork_child_proc, GC_thr_init): Remove unnecessary GC_markers_m1 zeroing (after setting GC_parallel to FALSE). * win32_threads.c (GC_thr_init): Likewise. * pthread_support.c (GC_thr_init): Set GC_parallel to FALSE instead of zeroing GC_markers_m1; remove GC_parallel assignment to TRUE (since GC_markers_m1 is set to non-zero value); add the comment. * pthread_support.c (GC_thr_init): Set GC_parallel to FALSE instead of zeroing GC_markers_m1; add the comment. * pthread_support.c (GC_thr_init): Remove GC_parallel assignment to TRUE (since GC_markers_m1 is set to non-zero value). * win32_threads.c (GC_thr_init): Likewise. --- include/gc.h | 12 ++++++++---- include/private/gc_priv.h | 6 +++--- mark.c | 3 --- pthread_support.c | 6 ++---- win32_threads.c | 6 +----- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/include/gc.h b/include/gc.h index 5f06c38..6f08335 100644 --- a/include/gc.h +++ b/include/gc.h @@ -87,11 +87,15 @@ GC_API GC_word GC_CALL GC_get_gc_no(void); /* PARALLEL_MARK defined and if either: */ /* Env variable GC_NPROC is set to > 1, or */ /* GC_NPROC is not set and this is an MP. */ - /* If GC_parallel is set, incremental */ + /* If GC_parallel is on (non-zero), incremental */ /* collection is only partially functional, */ - /* and may not be desirable. This getter does */ + /* and may not be desirable. The getter does */ /* not use or need synchronization (i.e. */ - /* acquiring the GC lock). */ + /* acquiring the GC lock). Starting from */ + /* GC v7.3, GC_parallel value is equal to the */ + /* number of marker threads minus one (i.e. */ + /* number of existing parallel marker threads */ + /* excluding the initiating one). */ GC_API int GC_CALL GC_get_parallel(void); #endif @@ -592,7 +596,7 @@ GC_API void GC_CALL GC_enable(void); /* dirty bits are available or most heap objects are pointer-free */ /* (atomic) or immutable. Don't use in leak finding mode. Ignored if */ /* GC_dont_gc is non-zero. Only the generational piece of this is */ -/* functional if GC_parallel is TRUE or if GC_time_limit is */ +/* functional if GC_parallel is non-zero or if GC_time_limit is */ /* GC_TIME_UNLIMITED. Causes thread-local variant of GC_gcj_malloc() */ /* to revert to locked allocation. Must be called before any such */ /* GC_gcj_malloc() calls. For best performance, should be called as */ diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index e687a66..d9f8651 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -2203,9 +2203,9 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str, /* than the main garbage collector lock; standard pthreads-based */ /* implementations should be sufficient. */ - GC_EXTERN int GC_markers_m1; /* Number of mark threads we would like */ - /* to have excluding the initiating */ - /* thread. Defined in mark.c. */ +# define GC_markers_m1 GC_parallel + /* Number of mark threads we would like to have */ + /* excluding the initiating thread. */ /* The mark lock and condition variable. If the GC lock is also */ /* acquired, the GC lock must be acquired first. The mark lock is */ diff --git a/mark.c b/mark.c index c8a63ec..2d4f8de 100644 --- a/mark.c +++ b/mark.c @@ -1017,9 +1017,6 @@ STATIC void GC_do_local_mark(mse *local_mark_stack, mse *local_top) #define ENTRIES_TO_GET 5 -GC_INNER int GC_markers_m1 = 1; /* Normally changed by thread-library- */ - /* -specific code. */ - /* Mark using the local mark stack until the global mark stack is empty */ /* and there are no active workers. Update GC_first_nonempty to reflect */ /* progress. */ diff --git a/pthread_support.c b/pthread_support.c index 02e243c..40c889d 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -427,7 +427,6 @@ static void start_mark_threads(void) errno); /* Don't try to create other marker threads. */ GC_markers_m1 = i; - if (i == 0) GC_parallel = FALSE; break; } } @@ -901,7 +900,6 @@ STATIC void GC_fork_child_proc(void) # ifdef PARALLEL_MARK /* Turn off parallel marking in the child, since we are probably */ /* just going to exec, and we would have to restart mark threads. */ - GC_markers_m1 = 0; GC_parallel = FALSE; # endif /* PARALLEL_MARK */ RESTORE_CANCEL(fork_cancel_state); @@ -1036,7 +1034,7 @@ GC_INNER void GC_thr_init(void) WARN("GC_get_nprocs() returned %" WARN_PRIdPTR "\n", GC_nprocs); GC_nprocs = 2; /* assume dual-core */ # ifdef PARALLEL_MARK - GC_markers_m1 = 0; /* but use only one marker */ + GC_parallel = FALSE; /* but use only one marker */ # endif } else { # ifdef PARALLEL_MARK @@ -1068,12 +1066,12 @@ GC_INNER void GC_thr_init(void) GC_nprocs, GC_markers_m1 + 1); } if (GC_markers_m1 <= 0) { + /* Disable parallel marking. */ GC_parallel = FALSE; if (GC_print_stats) { GC_log_printf("Single marker thread, turning off parallel marking\n"); } } else { - GC_parallel = TRUE; /* Disable true incremental collection, but generational is OK. */ GC_time_limit = GC_TIME_UNLIMITED; } diff --git a/win32_threads.c b/win32_threads.c index 5a642cb..4d03525 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -1595,7 +1595,6 @@ GC_INNER void GC_get_next_stack(char *start, char *limit, WARN("Marker thread creation failed.\n", 0); /* Don't try to create other marker threads. */ GC_markers_m1 = i; - if (i == 0) GC_parallel = FALSE; break; } } @@ -1788,7 +1787,6 @@ GC_INNER void GC_get_next_stack(char *start, char *limit, GC_markers_m1 = i; # endif if (i == 0) { - GC_parallel = FALSE; CloseHandle(mark_cv); CloseHandle(builder_cv); CloseHandle(mark_mutex_event); @@ -2311,7 +2309,7 @@ GC_INNER void GC_thr_init(void) } } - /* Set GC_parallel. */ + /* Check whether parallel mode could be enabled. */ { # if !defined(GC_PTHREADS_PARAMARK) && !defined(MSWINCE) \ && !defined(DONT_USE_SIGNALANDWAIT) @@ -2329,7 +2327,6 @@ GC_INNER void GC_thr_init(void) ) { /* Disable parallel marking. */ GC_parallel = FALSE; - GC_markers_m1 = 0; } else { # ifndef GC_PTHREADS_PARAMARK /* Initialize Win32 event objects for parallel marking. */ @@ -2345,7 +2342,6 @@ GC_INNER void GC_thr_init(void) || mark_cv == (HANDLE)0) ABORT("CreateEvent() failed"); # endif - GC_parallel = TRUE; /* Disable true incremental collection, but generational is OK. */ GC_time_limit = GC_TIME_UNLIMITED; } -- 2.7.4