[Gc] Minor changes (some global vars made static)

Ivan Maidanski ivmai at mail.ru
Sun Feb 1 04:36:14 PST 2009


Hi!

Three minor changes suggested:
- STATIC added to GC_need_full_gc (alloc.c), GC_retry_signals (pthread_stop_world.c), GC_suspend_ack_sem, GC_restart_ack_sem, GC_explicit_typing_initialized (typd_mlc.c), GC_explicit_kind, GC_array_kind, GC_ext_descriptors, GC_ed_size, GC_avail_descr, GC_typed_mark_proc_index, GC_array_mark_proc_index, GC_eobjfreelist, GC_arobjfreelist;
- GC_stack_last_cleared (misc.c), GC_min_sp, GC_high_water, GC_bytes_allocd_at_reset are defined only if threads (and STATIC added);
- GC_markers (pthread_support.c) value is silently limited if "GC_MARKERS" is not specified (like in win32_threads.c).

Bye.
-------------- next part --------------
diff -ru bdwgc/alloc.c updated/bdwgc/alloc.c
--- bdwgc/alloc.c	2008-11-20 18:49:26.000000000 +0300
+++ updated/bdwgc/alloc.c	2009-02-01 12:49:12.000000000 +0300
@@ -73,7 +73,7 @@
 
 int GC_full_freq = GC_FULL_FREQ;
 
-GC_bool GC_need_full_gc = FALSE;
+STATIC GC_bool GC_need_full_gc = FALSE;
 			   /* Need full GC do to heap growth.	*/
 
 #ifdef THREADS
diff -ru bdwgc/misc.c updated/bdwgc/misc.c
--- bdwgc/misc.c	2008-12-08 13:37:34.000000000 +0300
+++ updated/bdwgc/misc.c	2009-02-01 13:48:26.000000000 +0300
@@ -212,22 +212,21 @@
  * that are not written.  We partially address this by clearing
  * sections of the stack whenever we get control.
  */
-word GC_stack_last_cleared = 0;	/* GC_no when we last did this */
 # ifdef THREADS
 #   define BIG_CLEAR_SIZE 2048	/* Clear this much now and then.	*/
 #   define SMALL_CLEAR_SIZE 256 /* Clear this much every time.		*/
-# endif
-# define CLEAR_SIZE 213  /* Granularity for GC_clear_stack_inner */
-# define DEGRADE_RATE 50
-
-ptr_t GC_min_sp;	/* Coolest stack pointer value from which we've */
-			/* already cleared the stack.			*/
-			
-ptr_t GC_high_water;
+# else
+  STATIC word GC_stack_last_cleared = 0; /* GC_no when we last did this */
+  STATIC ptr_t GC_min_sp; /* Coolest stack pointer value from which	*/
+			  /* we've already cleared the stack.		*/
+  STATIC ptr_t GC_high_water;
 			/* "hottest" stack pointer value we have seen	*/
 			/* recently.  Degrades over time.		*/
+  STATIC word GC_bytes_allocd_at_reset;
+#   define DEGRADE_RATE 50
+# endif
 
-word GC_bytes_allocd_at_reset;
+# define CLEAR_SIZE 213  /* Granularity for GC_clear_stack_inner */
 
 #if defined(ASM_CLEAR_CODE)
   extern void *GC_clear_stack_inner(void *, ptr_t);
diff -ru bdwgc/pthread_stop_world.c updated/bdwgc/pthread_stop_world.c
--- bdwgc/pthread_stop_world.c	2008-10-28 17:23:20.000000000 +0300
+++ updated/bdwgc/pthread_stop_world.c	2009-02-01 13:20:42.000000000 +0300
@@ -75,9 +75,9 @@
 			/* stopped).					     */
 
 #ifdef GC_OSF1_THREADS
-  GC_bool GC_retry_signals = TRUE;
+  STATIC GC_bool GC_retry_signals = TRUE;
 #else
-  GC_bool GC_retry_signals = FALSE;
+  STATIC GC_bool GC_retry_signals = FALSE;
 #endif
 
 /*
@@ -104,13 +104,13 @@
 #  endif
 #endif
 
-sem_t GC_suspend_ack_sem;
+STATIC sem_t GC_suspend_ack_sem;
 
 #ifdef GC_NETBSD_THREADS
 # define GC_NETBSD_THREADS_WORKAROUND
   /* It seems to be necessary to wait until threads have restarted.	*/
   /* But it is unclear why that is the case.				*/
-  sem_t GC_restart_ack_sem;
+  STATIC sem_t GC_restart_ack_sem;
 #endif
 
 STATIC void GC_suspend_handler_inner(ptr_t sig_arg, void *context);
diff -ru bdwgc/pthread_support.c updated/bdwgc/pthread_support.c
--- bdwgc/pthread_support.c	2008-11-22 13:21:26.000000000 +0300
+++ updated/bdwgc/pthread_support.c	2009-02-01 13:40:40.000000000 +0300
@@ -318,10 +318,6 @@
     unsigned i;
     pthread_attr_t attr;
 
-    if (GC_markers > MAX_MARKERS) {
-	WARN("Limiting number of mark threads\n", 0);
-	GC_markers = MAX_MARKERS;
-    }
     if (0 != pthread_attr_init(&attr)) ABORT("pthread_attr_init failed");
 	
     if (0 != pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
@@ -807,8 +803,14 @@
 	    char * markers_string = GETENV("GC_MARKERS");
 	    if (markers_string != NULL) {
 	      GC_markers = atoi(markers_string);
+	      if (GC_markers > MAX_MARKERS) {
+		WARN("Limiting number of mark threads\n", 0);
+		GC_markers = MAX_MARKERS;
+	      }
 	    } else {
 	      GC_markers = GC_nprocs;
+	      if (GC_markers >= MAX_MARKERS)
+		GC_markers = MAX_MARKERS; /* silently limit GC_markers value */
 	    }
           }
 #	endif
@@ -818,7 +820,7 @@
           GC_log_printf("Number of processors = %ld, "
 		 "number of marker threads = %ld\n", GC_nprocs, GC_markers);
       }
-      if (GC_markers == 1) {
+      if (GC_markers <= 1) {
 	GC_parallel = FALSE;
 	if (GC_print_stats) {
 	    GC_log_printf(
diff -ru bdwgc/typd_mlc.c updated/bdwgc/typd_mlc.c
--- bdwgc/typd_mlc.c	2008-11-01 19:37:30.000000000 +0300
+++ updated/bdwgc/typd_mlc.c	2009-02-01 13:29:38.000000000 +0300
@@ -41,12 +41,14 @@
 
 # define TYPD_EXTRA_BYTES (sizeof(word) - EXTRA_BYTES)
 
-GC_bool GC_explicit_typing_initialized = FALSE;
+STATIC GC_bool GC_explicit_typing_initialized = FALSE;
 
-int GC_explicit_kind;	/* Object kind for objects with indirect	*/
+STATIC int GC_explicit_kind;
+			/* Object kind for objects with indirect	*/
 			/* (possibly extended) descriptors.		*/
 
-int GC_array_kind;	/* Object kind for objects with complex		*/
+STATIC int GC_array_kind;
+			/* Object kind for objects with complex		*/
 			/* descriptors and GC_array_mark_proc.		*/
 
 /* Extended descriptors.  GC_typed_mark_proc understands these.	*/
@@ -86,16 +88,16 @@
 } complex_descriptor;
 #define TAG ld.ld_tag
 
-ext_descr * GC_ext_descriptors;	/* Points to array of extended 	*/
-				/* descriptors.			*/
+STATIC ext_descr * GC_ext_descriptors;	/* Points to array of extended 	*/
+					/* descriptors.			*/
 
-size_t GC_ed_size = 0;	/* Current size of above arrays.	*/
+STATIC size_t GC_ed_size = 0;	/* Current size of above arrays.	*/
 # define ED_INITIAL_SIZE 100;
 
-size_t GC_avail_descr = 0;	/* Next available slot.		*/
+STATIC size_t GC_avail_descr = 0;	/* Next available slot.		*/
 
-int GC_typed_mark_proc_index;	/* Indices of my mark		*/
-int GC_array_mark_proc_index;	/* procedures.			*/
+STATIC int GC_typed_mark_proc_index;	/* Indices of my mark		*/
+STATIC int GC_array_mark_proc_index;	/* procedures.			*/
 
 static void GC_push_typed_structures_proc (void)
 {
@@ -330,9 +332,9 @@
 }
 #endif
 
-ptr_t * GC_eobjfreelist;
+STATIC ptr_t * GC_eobjfreelist;
 
-ptr_t * GC_arobjfreelist;
+STATIC ptr_t * GC_arobjfreelist;
 
 STATIC mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
 				mse * mark_stack_limit, word env);


More information about the Gc mailing list