X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FStorage.h;h=1f6ef3f5e736382eddafcf296aa328108a20ed19;hb=58786d7131b8842c5d50cb3ac4173753951cc343;hp=4404dfad237b63c6f024ba53a2e81df9ddff01ec;hpb=0f3205e6c40575910d50bc2cc42020ccf55e07ba;p=ghc-hetmet.git diff --git a/ghc/includes/Storage.h b/ghc/includes/Storage.h index 4404dfa..1f6ef3f 100644 --- a/ghc/includes/Storage.h +++ b/ghc/includes/Storage.h @@ -10,6 +10,7 @@ #define STORAGE_H #include +#include "OSThreads.h" /* ----------------------------------------------------------------------------- * Generational GC @@ -61,12 +62,18 @@ typedef struct step_ { unsigned int n_large_blocks; /* no. of blocks used by large objs */ int is_compacted; /* compact this step? (old gen only) */ + /* During GC, if we are collecting this step, blocks and n_blocks + * are copied into the following two fields. After GC, these blocks + * are freed. */ + bdescr * old_blocks; /* bdescr of first from-space block */ + unsigned int n_old_blocks; /* number of blocks in from-space */ + /* 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_blocks; /* bdescr of first to-space block */ - unsigned int n_to_blocks; /* number of blocks in to-space */ + StgPtr scavd_hp; /* ... same as above, but already */ + StgPtr scavd_hpLim; /* scavenged. */ bdescr * scan_bd; /* block currently being scanned */ StgPtr scan; /* scan pointer in current block */ bdescr * new_large_objects; /* large objects collected so far */ @@ -138,6 +145,7 @@ extern void exitStorage(void); -------------------------------------------------------------------------- */ extern StgPtr allocate ( nat n ); +extern StgPtr allocateLocal ( Capability *cap, nat n ); extern StgPtr allocatePinned ( nat n ); extern lnat allocated_bytes ( void ); @@ -187,10 +195,23 @@ extern void GarbageCollect(void (*get_roots)(evac_fn),rtsBool force_major_gc); -------------------------------------------------------------------------- */ -/* ToDo: shouldn't recordMutable acquire some - * kind of lock in the SMP case? Or do we need per-processor - * mutable lists? +/* + * Storage manager mutex */ +#if defined(SMP) +extern Mutex sm_mutex; +#endif + +#if defined(SMP) +#define ACQUIRE_SM_LOCK ACQUIRE_LOCK(&sm_mutex); +#define RELEASE_SM_LOCK RELEASE_LOCK(&sm_mutex); +#define ASSERT_SM_LOCK() ASSERT_LOCK_HELD(&sm_mutex); +#else +#define ACQUIRE_SM_LOCK +#define RELEASE_SM_LOCK +#define ASSERT_SM_LOCK() +#endif + INLINE_HEADER void recordMutableGen(StgClosure *p, generation *gen) { @@ -205,6 +226,15 @@ recordMutableGen(StgClosure *p, generation *gen) gen->mut_list = bd; } *bd->free++ = (StgWord)p; + +} + +INLINE_HEADER void +recordMutableGenLock(StgClosure *p, generation *gen) +{ + ACQUIRE_SM_LOCK; + recordMutableGen(p,gen); + RELEASE_SM_LOCK; } INLINE_HEADER void @@ -216,6 +246,14 @@ recordMutable(StgClosure *p) if (bd->gen_no > 0) recordMutableGen(p, &RTS_DEREF(generations)[bd->gen_no]); } +INLINE_HEADER void +recordMutableLock(StgClosure *p) +{ + ACQUIRE_SM_LOCK; + recordMutable(p); + RELEASE_SM_LOCK; +} + /* ----------------------------------------------------------------------------- The CAF table - used to let us revert CAFs in GHCi -------------------------------------------------------------------------- */ @@ -343,11 +381,12 @@ INLINE_HEADER StgWord stack_frame_sizeW( StgClosure *frame ) Nursery manipulation -------------------------------------------------------------------------- */ -extern void allocNurseries ( void ); -extern void resetNurseries ( void ); -extern void resizeNurseries ( nat blocks ); -extern void tidyAllocateLists ( void ); -extern lnat countNurseryBlocks ( void ); +extern void allocNurseries ( void ); +extern void resetNurseries ( void ); +extern void resizeNurseries ( nat blocks ); +extern void resizeNurseriesFixed ( nat blocks ); +extern void tidyAllocateLists ( void ); +extern lnat countNurseryBlocks ( void ); /* ----------------------------------------------------------------------------- Functions from GC.c @@ -371,6 +410,7 @@ extern lnat calcNeeded ( void ); extern void memInventory(void); extern void checkSanity(void); extern nat countBlocks(bdescr *); +extern void checkNurserySanity( step *stp ); #endif #if defined(DEBUG) @@ -389,7 +429,6 @@ extern void newDynCAF(StgClosure *); extern void move_TSO(StgTSO *src, StgTSO *dest); extern StgTSO *relocate_stack(StgTSO *dest, ptrdiff_t diff); -extern StgClosure * RTS_VAR(static_objects); extern StgClosure * RTS_VAR(scavenged_static_objects); extern StgWeak * RTS_VAR(old_weak_ptr_list); extern StgWeak * RTS_VAR(weak_ptr_list);