[project @ 2002-08-16 13:29:05 by simonmar]
authorsimonmar <unknown>
Fri, 16 Aug 2002 13:29:07 +0000 (13:29 +0000)
committersimonmar <unknown>
Fri, 16 Aug 2002 13:29:07 +0000 (13:29 +0000)
Global and common variable sweep: staticize many variables that don't
need to be globally visible.

12 files changed:
ghc/includes/Stable.h
ghc/rts/Capability.c
ghc/rts/GC.c
ghc/rts/Itimer.c
ghc/rts/Linker.c
ghc/rts/ProfHeap.c
ghc/rts/RtsStartup.c
ghc/rts/RtsUtils.c
ghc/rts/Schedule.c
ghc/rts/Stable.c
ghc/rts/Stats.c
ghc/rts/ThreadLabels.c

index 12056f9..386087e 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Stable.h,v 1.12 2001/12/20 16:12:09 sewardj Exp $
+ * $Id: Stable.h,v 1.13 2002/08/16 13:29:05 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -38,9 +38,6 @@ typedef struct {
 } snEntry;
 
 extern DLL_IMPORT_RTS snEntry *stable_ptr_table;
-extern DLL_IMPORT_RTS snEntry *stable_ptr_free;
-
-extern DLL_IMPORT_RTS unsigned int SPT_size;
 
 extern void freeStablePtr(StgStablePtr sp);
 
index d8bdbe6..668f435 100644 (file)
@@ -26,7 +26,7 @@
 Capability MainCapability;     /* for non-SMP, we have one global capability */
 #endif
 
-nat rts_n_free_capabilities;
+static nat rts_n_free_capabilities;
 
 #if defined(RTS_SUPPORTS_THREADS)
 /* returning_worker_cond: when a worker thread returns from executing an
index 14dc91f..7821853 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.137 2002/07/17 09:21:49 simonmar Exp $
+ * $Id: GC.c,v 1.138 2002/08/16 13:29:06 simonmar Exp $
  *
  * (c) The GHC Team 1998-1999
  *
@@ -81,8 +81,8 @@
  * We build up a static object list while collecting generations 0..N,
  * which is then appended to the static object list of generation N+1.
  */
-StgClosure* static_objects;          // live static objects
-StgClosure* scavenged_static_objects; // static objects scavenged so far
+static StgClosure* static_objects;      // live static objects
+StgClosure* scavenged_static_objects;   // static objects scavenged so far
 
 /* N is the oldest generation being collected, where the generations
  * are numbered starting at 0.  A major GC (indicated by the major_gc
@@ -120,16 +120,16 @@ static rtsBool failed_to_evac;
 
 /* Old to-space (used for two-space collector only)
  */
-bdescr *old_to_blocks;
+static bdescr *old_to_blocks;
 
 /* Data used for allocation area sizing.
  */
-lnat new_blocks;               // blocks allocated during this GC 
-lnat g0s0_pcnt_kept = 30;      // percentage of g0s0 live at last minor GC 
+static lnat new_blocks;                 // blocks allocated during this GC 
+static lnat g0s0_pcnt_kept = 30; // percentage of g0s0 live at last minor GC 
 
 /* Used to avoid long recursion due to selector thunks
  */
-lnat thunk_selector_depth = 0;
+static lnat thunk_selector_depth = 0;
 #define MAX_THUNK_SELECTOR_DEPTH 256
 
 /* -----------------------------------------------------------------------------
@@ -1469,8 +1469,8 @@ copyPart(StgClosure *src, nat size_to_reserve, nat size_to_copy, step *stp)
    Evacuate a large object
 
    This just consists of removing the object from the (doubly-linked)
-   large_alloc_list, and linking it on to the (singly-linked)
-   new_large_objects list, from where it will be scavenged later.
+   step->large_objects list, and linking it on to the (singly-linked)
+   step->new_large_objects list, from where it will be scavenged later.
 
    Convention: bd->flags has BF_EVACUATED set for a large object
    that has been evacuated, or unset otherwise.
index e40c83d..bbc8738 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Itimer.c,v 1.30 2002/07/17 09:21:49 simonmar Exp $
+ * $Id: Itimer.c,v 1.31 2002/08/16 13:29:06 simonmar Exp $
  *
  * (c) The GHC Team, 1995-1999
  *
 # include <signal.h>
 #endif
 
-lnat total_ticks = 0;
+static lnat total_ticks = 0;
 
 /* ticks left before next pre-emptive context switch */
-int ticks_to_ctxt_switch = 0;
+static int ticks_to_ctxt_switch = 0;
 
 /* -----------------------------------------------------------------------------
    Tick handler
index f742749..bb2be5b 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Linker.c,v 1.100 2002/07/18 06:05:29 sof Exp $
+ * $Id: Linker.c,v 1.101 2002/08/16 13:29:06 simonmar Exp $
  *
  * (c) The GHC Team, 2000, 2001
  *
@@ -71,7 +71,7 @@
 #endif
 
 /* Hash table mapping symbol names to Symbol */
-/*Str*/HashTable *symhash;
+static /*Str*/HashTable *symhash;
 
 #if defined(OBJFORMAT_ELF)
 static int ocVerifyImage_ELF    ( ObjectCode* oc );
index ffbbd1d..0173754 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: ProfHeap.c,v 1.37 2002/07/18 09:12:34 simonmar Exp $
+ * $Id: ProfHeap.c,v 1.38 2002/08/16 13:29:06 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -95,8 +95,8 @@ typedef struct {
     int       drag_total;
 } Census;
 
-Census *censuses = NULL;
-nat n_censuses = 0;
+static Census *censuses = NULL;
+static nat n_censuses = 0;
 
 #ifdef PROFILING
 static void aggregateCensusInfo( void );
index c375426..2a288b7 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsStartup.c,v 1.65 2002/07/17 09:21:50 simonmar Exp $
+ * $Id: RtsStartup.c,v 1.66 2002/08/16 13:29:06 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -226,7 +226,6 @@ startupHaskell(int argc, char *argv[], void (*init_root)(void))
  */
 #define INIT_STACK_BLOCKS  4
 F_ *init_stack = NULL;
-nat init_sp = 0;
 
 static void
 initModules ( void (*init_root)(void) )
@@ -237,6 +236,7 @@ initModules ( void (*init_root)(void) )
 #else
 #define cap MainCapability
 #endif
+    nat init_sp;
 
     init_sp = 0;
     bd = allocGroup(INIT_STACK_BLOCKS);
index 693531e..7757359 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsUtils.c,v 1.26 2002/07/17 09:21:50 simonmar Exp $
+ * $Id: RtsUtils.c,v 1.27 2002/08/16 13:29:07 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -188,7 +188,7 @@ nat stg_strlen(char *s)
    ToDo: put this somewhere sensible.
    -------------------------------------------------------------------------  */
 
-I_ __GenSymCounter = 0;
+static I_ __GenSymCounter = 0;
 
 I_
 genSymZh(void)
index 2e2bbec..468a596 100644 (file)
@@ -1,5 +1,5 @@
 /* ---------------------------------------------------------------------------
- * $Id: Schedule.c,v 1.151 2002/07/25 18:36:59 sof Exp $
+ * $Id: Schedule.c,v 1.152 2002/08/16 13:29:07 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
 /* Main thread queue.
  * Locks required: sched_mutex.
  */
-StgMainThread *main_threads;
+StgMainThread *main_threads = NULL;
 
 /* Thread queues.
  * Locks required: sched_mutex.
@@ -160,16 +160,18 @@ StgTSO *ccalling_threadss[MAX_PROC];
 
 #else /* !GRAN */
 
-StgTSO *run_queue_hd, *run_queue_tl;
-StgTSO *blocked_queue_hd, *blocked_queue_tl;
-StgTSO *sleeping_queue;                /* perhaps replace with a hash table? */
+StgTSO *run_queue_hd = NULL;
+StgTSO *run_queue_tl = NULL;
+StgTSO *blocked_queue_hd = NULL;
+StgTSO *blocked_queue_tl = NULL;
+StgTSO *sleeping_queue = NULL;    /* perhaps replace with a hash table? */
 
 #endif
 
 /* Linked list of all threads.
  * Used for detecting garbage collected threads.
  */
-StgTSO *all_threads;
+StgTSO *all_threads = NULL;
 
 /* When a thread performs a safe C call (_ccall_GC, using old
  * terminology), it gets put on the suspended_ccalling_threads
@@ -186,17 +188,17 @@ static StgTSO *threadStackOverflow(StgTSO *tso);
 
 /* flag set by signal handler to precipitate a context switch */
 //@cindex context_switch
-nat context_switch;
+nat context_switch = 0;
 
 /* if this flag is set as well, give up execution */
 //@cindex interrupted
-rtsBool interrupted;
+rtsBool interrupted = rtsFalse;
 
 /* Next thread ID to allocate.
  * Locks required: thread_id_mutex
  */
 //@cindex next_thread_id
-StgThreadID next_thread_id = 1;
+static StgThreadID next_thread_id = 1;
 
 /*
  * Pointers to the state of the current thread.
@@ -227,7 +229,7 @@ StgTSO *CurrentTSO;
  */
 StgTSO dummy_tso;
 
-rtsBool ready_to_gc;
+static rtsBool ready_to_gc;
 
 /*
  * Set to TRUE when entering a shutdown state (via shutdownHaskellAndExit()) --
@@ -275,21 +277,13 @@ rtsBool emitSchedule = rtsTrue;
 #endif
 
 #if DEBUG
-char *whatNext_strs[] = {
+static char *whatNext_strs[] = {
   "ThreadEnterGHC",
   "ThreadRunGHC",
   "ThreadEnterInterp",
   "ThreadKilled",
   "ThreadComplete"
 };
-
-char *threadReturnCode_strs[] = {
-  "HeapOverflow",                      /* might also be StackOverflow */
-  "StackOverflow",
-  "ThreadYielding",
-  "ThreadBlocked",
-  "ThreadFinished"
-};
 #endif
 
 #if defined(PAR)
@@ -2493,7 +2487,7 @@ GetRoots(evac_fn evac)
    This needs to be protected by the GC condition variable above.  KH.
    -------------------------------------------------------------------------- */
 
-void (*extra_roots)(evac_fn);
+static void (*extra_roots)(evac_fn);
 
 void
 performGC(void)
@@ -3279,6 +3273,8 @@ raiseAsync(StgTSO *tso, StgClosure *exception)
     nat i;
     StgAP_UPD * ap;
 
+    ASSERT((P_)su > (P_)sp);
+    
     /* If we find a CATCH_FRAME, and we've got an exception to raise,
      * then build the THUNK raise(exception), and leave it on
      * top of the CATCH_FRAME ready to enter.
@@ -3326,8 +3322,6 @@ raiseAsync(StgTSO *tso, StgClosure *exception)
      */
     ap = (StgAP_UPD *)allocate(AP_sizeW(words));
     
-    ASSERT(words >= 0);
-    
     ap->n_args = words;
     ap->fun    = (StgClosure *)sp[0];
     sp++;
index 474134e..7bfd15e 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Stable.c,v 1.21 2002/04/24 13:29:01 simonmar Exp $
+ * $Id: Stable.c,v 1.22 2002/08/16 13:29:07 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -88,9 +88,9 @@
 */
 
 snEntry *stable_ptr_table;
-snEntry *stable_ptr_free;
+static snEntry *stable_ptr_free;
 
-unsigned int SPT_size;
+static unsigned int SPT_size;
 
 /* This hash table maps Haskell objects to stable names, so that every
  * call to lookupStableName on a given object will return the same
@@ -125,7 +125,7 @@ unsigned int SPT_size;
  * to the weight stored in the table entry.
  * */
 
-HashTable *addrToStableHash;
+static HashTable *addrToStableHash;
 
 #define INIT_SPT_SIZE 64
 
index 5052e26..546466d 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Stats.c,v 1.44 2002/02/06 01:21:40 sof Exp $
+ * $Id: Stats.c,v 1.45 2002/08/16 13:29:07 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -111,9 +111,9 @@ static TICK_TYPE HCe_start_time, HCe_tot_time = 0;   // heap census prof elap ti
 #define PROF_VAL(x)   0
 #endif
 
-lnat MaxResidency = 0;     /* in words; for stats only */
-lnat AvgResidency = 0;
-lnat ResidencySamples = 0; /* for stats only */
+static lnat MaxResidency = 0;     // in words; for stats only
+static lnat AvgResidency = 0;
+static lnat ResidencySamples = 0; // for stats only
 
 static lnat GC_start_faults = 0, GC_end_faults = 0;
 
index 79a0a77..dacd8a3 100644 (file)
@@ -4,7 +4,7 @@
 
 #include <stdlib.h>
 
-HashTable * threadLabels = NULL;
+static HashTable * threadLabels = NULL;
 
 void
 initThreadLabelTable(void)