X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FStoragePriv.h;h=add78a4e29f64e6f126d6f1e7e75c7adc4cd654e;hb=fb7a723bfd7650a705cb226e07c5b08b7a8e9279;hp=defe1425de16a66f99f50644c5c7a6e9a8a2f759;hpb=bbab3c15e58912433d5f2b5dcd2344f5a176848c;p=ghc-hetmet.git diff --git a/ghc/rts/StoragePriv.h b/ghc/rts/StoragePriv.h index defe142..add78a4 100644 --- a/ghc/rts/StoragePriv.h +++ b/ghc/rts/StoragePriv.h @@ -1,5 +1,7 @@ /* ----------------------------------------------------------------------------- - * $Id: StoragePriv.h,v 1.5 1999/01/19 17:06:05 simonm Exp $ + * $Id: StoragePriv.h,v 1.17 2001/08/08 10:50:37 simonmar Exp $ + * + * (c) The GHC Team, 1998-1999 * * Internal Storage Manger Interface * @@ -8,77 +10,7 @@ #ifndef STORAGEPRIV_H #define STORAGEPRIV_H -/* GENERATION GC NOTES - * - * We support an arbitrary number of generations, with an arbitrary number - * of steps per generation. Notes (in no particular order): - * - * - all generations except the oldest should have two steps. This gives - * objects a decent chance to age before being promoted, and in - * particular will ensure that we don't end up with too many - * thunks being updated in older generations. - * - * - the oldest generation has one step. There's no point in aging - * objects in the oldest generation. - * - * - generation 0, step 0 (G0S0) is the allocation area. It is given - * a fixed set of blocks during initialisation, and these blocks - * are never freed. - * - * - during garbage collection, each step which is an evacuation - * destination (i.e. all steps except G0S0) is allocated a to-space. - * evacuated objects are allocated into the step's to-space until - * GC is finished, when the original step's contents may be freed - * and replaced by the to-space. - * - * - the mutable-list is per-generation (not per-step). G0 doesn't - * have one (since every garbage collection collects at least G0). - * - * - block descriptors contain pointers to both the step and the - * generation that the block belongs to, for convenience. - * - * - static objects are stored in per-generation lists. See GC.c for - * details of how we collect CAFs in the generational scheme. - * - * - large objects are per-step, and are promoted in the same way - * as small objects, except that we may allocate large objects into - * generation 1 initially. - */ - -typedef struct _step { - nat no; /* step number */ - bdescr *blocks; /* blocks in this step */ - nat n_blocks; /* number of blocks */ - struct _step *to; /* where collected objects from this step go */ - struct _generation *gen; /* generation this step belongs to */ - bdescr *large_objects; /* large objects (doubly linked) */ - - /* temporary use during GC: */ - StgPtr hp; /* next free locn in to-space */ - StgPtr hpLim; /* end of current to-space block */ - bdescr *hp_bd; /* bdescr of current to-space block */ - bdescr *to_space; /* bdescr of first to-space block */ - nat to_blocks; /* number of blocks in to-space */ - bdescr *scan_bd; /* block currently being scanned */ - StgPtr scan; /* scan pointer in current block */ - bdescr *new_large_objects; /* large objects collected so far */ - bdescr *scavenged_large_objects; /* live large objects after GC (dbl link) */ -} step; - -typedef struct _generation { - nat no; /* generation number */ - step *steps; /* steps */ - nat n_steps; /* number of steps */ - nat max_blocks; /* max blocks in step 0 */ - StgMutClosure *mut_list; /* mutable objects in this generation (not G0)*/ - - /* temporary use during GC: */ - StgMutClosure *saved_mut_list; - - /* stats information */ - nat collections; - nat failed_promotions; -} generation; +#include #define END_OF_STATIC_LIST stgCast(StgClosure*,1) @@ -89,13 +21,19 @@ extern step *g0s0; extern generation *oldest_gen; extern void newCAF(StgClosure*); -extern StgTSO *relocate_TSO(StgTSO *src, StgTSO *dest); + +extern void move_TSO(StgTSO *src, StgTSO *dest); +extern StgTSO *relocate_stack(StgTSO *dest, ptrdiff_t diff); + +extern StgClosure *static_objects; +extern StgClosure *scavenged_static_objects; extern StgWeak *weak_ptr_list; extern StgClosure *caf_list; extern bdescr *small_alloc_list; extern bdescr *large_alloc_list; +extern bdescr *pinned_object_block; extern StgPtr alloc_Hp; extern StgPtr alloc_HpLim; @@ -106,15 +44,26 @@ extern nat nursery_blocks; extern nat alloc_blocks; extern nat alloc_blocks_lim; -extern bdescr *allocNursery (bdescr *last_bd, nat blocks); +extern lnat total_allocated; + +/* Nursery manipulation */ +extern void allocNurseries ( void ); +extern void resetNurseries ( void ); +extern bdescr * allocNursery ( bdescr *last_bd, nat blocks ); +extern void resizeNursery ( nat blocks ); + +/* Stats 'n' stuff */ +extern lnat calcAllocated ( void ); +extern lnat calcLive ( void ); +extern lnat calcNeeded ( void ); static inline void dbl_link_onto(bdescr *bd, bdescr **list) { bd->link = *list; - bd->back = NULL; + bd->u.back = NULL; if (*list) { - (*list)->back = bd; /* double-link the list */ + (*list)->u.back = bd; /* double-link the list */ } *list = bd; } @@ -123,10 +72,26 @@ dbl_link_onto(bdescr *bd, bdescr **list) * A mutable list is ended with END_MUT_LIST, so that we can use NULL * as an indication that an object is not on a mutable list. */ -#define END_MUT_LIST ((StgMutClosure *)(void *)&END_MUT_LIST_closure) +#define END_MUT_LIST ((StgMutClosure *)(void *)&stg_END_MUT_LIST_closure) #ifdef DEBUG extern void memInventory(void); +extern void checkSanity(void); #endif +/* + * These three are used by the garbage collector when we have + * dynamically-linked object modules. (see ClosureMacros.h, + * IS_CODE_PTR etc.). + * Defined in Linker.c. + */ +int is_dynamically_loaded_code_or_rodata_ptr ( void* p ); +int is_dynamically_loaded_rwdata_ptr ( void* p ); +int is_not_dynamically_loaded_ptr ( void* p ); + +/* Functions from GC.c + */ +void threadPaused(StgTSO *); +StgClosure *isAlive(StgClosure *p); + #endif /* STORAGEPRIV_H */