1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-2009
5 * External Storage Manger Interface
7 * ---------------------------------------------------------------------------*/
12 #include "Capability.h"
14 #include "BeginPrivate.h"
16 /* -----------------------------------------------------------------------------
17 Initialisation / De-initialisation
18 -------------------------------------------------------------------------- */
20 void initStorage(void);
21 void exitStorage(void);
22 void freeStorage(rtsBool free_heap);
24 /* -----------------------------------------------------------------------------
26 -------------------------------------------------------------------------- */
29 doYouWantToGC( Capability *cap )
31 return (cap->r.rCurrentNursery->link == NULL ||
32 g0->n_new_large_words >= large_alloc_lim);
35 /* for splitting blocks groups in two */
36 bdescr * splitLargeBlock (bdescr *bd, nat blocks);
38 /* -----------------------------------------------------------------------------
39 Generational garbage collection support
41 updateWithIndirection(p1,p2) Updates the object at p1 with an
42 indirection pointing to p2. This is
43 normally called for objects in an old
44 generation (>0) when they are updated.
46 updateWithPermIndirection(p1,p2) As above but uses a permanent indir.
48 -------------------------------------------------------------------------- */
51 * Storage manager mutex
53 #if defined(THREADED_RTS)
54 extern Mutex sm_mutex;
57 #if defined(THREADED_RTS)
58 #define ACQUIRE_SM_LOCK ACQUIRE_LOCK(&sm_mutex);
59 #define RELEASE_SM_LOCK RELEASE_LOCK(&sm_mutex);
60 #define ASSERT_SM_LOCK() ASSERT_LOCK_HELD(&sm_mutex);
62 #define ACQUIRE_SM_LOCK
63 #define RELEASE_SM_LOCK
64 #define ASSERT_SM_LOCK()
67 /* -----------------------------------------------------------------------------
68 The write barrier for MVARs
69 -------------------------------------------------------------------------- */
71 void dirty_MVAR(StgRegTable *reg, StgClosure *p);
73 /* -----------------------------------------------------------------------------
75 -------------------------------------------------------------------------- */
77 extern nursery *nurseries;
79 void resetNurseries ( void );
80 lnat clearNurseries ( void );
81 void resizeNurseries ( nat blocks );
82 void resizeNurseriesFixed ( nat blocks );
83 lnat countNurseryBlocks ( void );
85 /* -----------------------------------------------------------------------------
87 -------------------------------------------------------------------------- */
89 lnat calcAllocated (rtsBool count_nurseries);
90 lnat countOccupied (bdescr *bd);
91 lnat calcNeeded (void);
93 lnat gcThreadLiveWords (nat i, nat g);
94 lnat gcThreadLiveBlocks (nat i, nat g);
96 lnat genLiveWords (generation *gen);
97 lnat genLiveBlocks (generation *gen);
99 lnat calcLiveBlocks (void);
100 lnat calcLiveWords (void);
102 /* ----------------------------------------------------------------------------
103 Storage manager internal APIs and globals
104 ------------------------------------------------------------------------- */
106 extern bdescr *exec_block;
108 #define END_OF_STATIC_LIST ((StgClosure*)1)
110 void move_STACK (StgStack *src, StgStack *dest);
112 extern StgClosure * caf_list;
113 extern StgClosure * revertible_caf_list;
115 #include "EndPrivate.h"
117 #endif /* SM_STORAGE_H */