]> granicus.if.org Git - gc/commitdiff
Minor code refactoring of GC_thr_init (use 'markers_m1' local variable)
authorIvan Maidanski <ivmai@mail.ru>
Mon, 19 Nov 2012 04:50:44 +0000 (08:50 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 19 Nov 2012 11:51:11 +0000 (15:51 +0400)
* 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.

pthread_support.c
win32_threads.c

index 0fa0027a1c344fe169cc09e98e417536d1726860..eb6bad1bdf4e3f1ee5a4f162d04a3b501beacb5c 100644 (file)
@@ -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
index ec62dd5d5093ee8d8ee7ffc6eebb8daf805b46d9..24d15842db689f00c4c39b1750ef3a6e3275da45 100644 (file)
@@ -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.    */