From: Ivan Maidanski Date: Mon, 19 Nov 2012 04:50:44 +0000 (+0400) Subject: Minor code refactoring of GC_thr_init (use 'markers_m1' local variable) X-Git-Tag: gc7_4_0~148 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2641c9ec0ec43ecf3b2743a458d213fe36493dd6;p=gc Minor code refactoring of GC_thr_init (use 'markers_m1' local variable) * pthread_support.c (GC_thr_init): Declare "markers_m1" local variable, use it for keeping intermediate results (and store the final result to global GC_markers_m1). * win32_threads.c (GC_thr_init): Likewise. * pthread_support.c (GC_thr_init): Remove redundant check of GC_parallel. --- diff --git a/pthread_support.c b/pthread_support.c index 0fa0027a..eb6bad1b 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -1061,22 +1061,25 @@ GC_INNER void GC_thr_init(void) # ifdef PARALLEL_MARK { char * markers_string = GETENV("GC_MARKERS"); + int markers_m1; + if (markers_string != NULL) { - GC_markers_m1 = atoi(markers_string) - 1; - if (GC_markers_m1 >= MAX_MARKERS) { + markers_m1 = atoi(markers_string) - 1; + if (markers_m1 >= MAX_MARKERS) { WARN("Limiting number of mark threads\n", 0); - GC_markers_m1 = MAX_MARKERS - 1; + markers_m1 = MAX_MARKERS - 1; } } else { - GC_markers_m1 = GC_nprocs - 1; + markers_m1 = GC_nprocs - 1; # ifdef GC_MIN_MARKERS /* This is primarily for targets without getenv(). */ - if (GC_markers_m1 < GC_MIN_MARKERS - 1) - GC_markers_m1 = GC_MIN_MARKERS - 1; + if (markers_m1 < GC_MIN_MARKERS - 1) + markers_m1 = GC_MIN_MARKERS - 1; # endif - if (GC_markers_m1 >= MAX_MARKERS) - GC_markers_m1 = MAX_MARKERS - 1; /* silently limit the value */ + if (markers_m1 >= MAX_MARKERS) + markers_m1 = MAX_MARKERS - 1; /* silently limit the value */ } + GC_markers_m1 = markers_m1; } # endif } @@ -1092,9 +1095,7 @@ GC_INNER void GC_thr_init(void) } else { /* Disable true incremental collection, but generational is OK. */ GC_time_limit = GC_TIME_UNLIMITED; - } - /* If we are using a parallel marker, actually start helper threads. */ - if (GC_parallel) { + /* If we are using a parallel marker, actually start helper threads. */ start_mark_threads(); } # else diff --git a/win32_threads.c b/win32_threads.c index ec62dd5d..24d15842 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -2402,20 +2402,21 @@ GC_INNER void GC_thr_init(void) GC_ASSERT(sb_result == GC_SUCCESS); # if defined(PARALLEL_MARK) - /* Set GC_markers_m1. */ { char * markers_string = GETENV("GC_MARKERS"); + int markers_m1; + if (markers_string != NULL) { - GC_markers_m1 = atoi(markers_string) - 1; - if (GC_markers_m1 >= MAX_MARKERS) { + markers_m1 = atoi(markers_string) - 1; + if (markers_m1 >= MAX_MARKERS) { WARN("Limiting number of mark threads\n", 0); - GC_markers_m1 = MAX_MARKERS - 1; + markers_m1 = MAX_MARKERS - 1; } } else { # ifdef MSWINCE /* There is no GetProcessAffinityMask() in WinCE. */ /* GC_sysinfo is already initialized. */ - GC_markers_m1 = (int)GC_sysinfo.dwNumberOfProcessors - 1; + markers_m1 = (int)GC_sysinfo.dwNumberOfProcessors - 1; # else # ifdef _WIN64 DWORD_PTR procMask = 0; @@ -2432,16 +2433,17 @@ GC_INNER void GC_thr_init(void) ncpu++; } while ((procMask &= procMask - 1) != 0); } - GC_markers_m1 = ncpu - 1; + markers_m1 = ncpu - 1; # endif # ifdef GC_MIN_MARKERS /* This is primarily for testing on systems without getenv(). */ - if (GC_markers_m1 < GC_MIN_MARKERS - 1) - GC_markers_m1 = GC_MIN_MARKERS - 1; + if (markers_m1 < GC_MIN_MARKERS - 1) + markers_m1 = GC_MIN_MARKERS - 1; # endif - if (GC_markers_m1 >= MAX_MARKERS) - GC_markers_m1 = MAX_MARKERS - 1; /* silently limit the value */ + if (markers_m1 >= MAX_MARKERS) + markers_m1 = MAX_MARKERS - 1; /* silently limit the value */ } + GC_markers_m1 = markers_m1; } /* Check whether parallel mode could be enabled. */