1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-2009
5 * External Storage Manger Interface
7 * ---------------------------------------------------------------------------*/
14 /* -----------------------------------------------------------------------------
15 Initialisation / De-initialisation
16 -------------------------------------------------------------------------- */
18 void initStorage(void);
19 void exitStorage(void);
20 void freeStorage(void);
22 /* -----------------------------------------------------------------------------
24 -------------------------------------------------------------------------- */
26 extern bdescr * pinned_object_block;
31 return (alloc_blocks >= alloc_blocks_lim);
34 /* for splitting blocks groups in two */
35 bdescr * splitLargeBlock (bdescr *bd, nat blocks);
37 /* -----------------------------------------------------------------------------
38 Generational garbage collection support
40 recordMutable(StgPtr p) Informs the garbage collector that a
41 previously immutable object has
42 become (permanently) mutable. Used
43 by thawArray and similar.
45 updateWithIndirection(p1,p2) Updates the object at p1 with an
46 indirection pointing to p2. This is
47 normally called for objects in an old
48 generation (>0) when they are updated.
50 updateWithPermIndirection(p1,p2) As above but uses a permanent indir.
52 -------------------------------------------------------------------------- */
55 * Storage manager mutex
57 #if defined(THREADED_RTS)
58 extern Mutex sm_mutex;
61 #if defined(THREADED_RTS)
62 #define ACQUIRE_SM_LOCK ACQUIRE_LOCK(&sm_mutex);
63 #define RELEASE_SM_LOCK RELEASE_LOCK(&sm_mutex);
64 #define ASSERT_SM_LOCK() ASSERT_LOCK_HELD(&sm_mutex);
66 #define ACQUIRE_SM_LOCK
67 #define RELEASE_SM_LOCK
68 #define ASSERT_SM_LOCK()
72 recordMutableGen(StgClosure *p, nat gen_no)
76 bd = generations[gen_no].mut_list;
77 if (bd->free >= bd->start + BLOCK_SIZE_W) {
79 new_bd = allocBlock();
82 generations[gen_no].mut_list = bd;
84 *bd->free++ = (StgWord)p;
89 recordMutableGenLock(StgClosure *p, nat gen_no)
92 recordMutableGen(p,gen_no);
97 recordMutable(StgClosure *p)
100 ASSERT(closure_MUTABLE(p));
102 if (bd->gen_no > 0) recordMutableGen(p, bd->gen_no);
106 recordMutableLock(StgClosure *p)
113 /* -----------------------------------------------------------------------------
114 The write barrier for MVARs
115 -------------------------------------------------------------------------- */
117 void dirty_MVAR(StgRegTable *reg, StgClosure *p);
119 /* -----------------------------------------------------------------------------
121 -------------------------------------------------------------------------- */
123 void resetNurseries ( void );
124 void resizeNurseries ( nat blocks );
125 void resizeNurseriesFixed ( nat blocks );
126 lnat countNurseryBlocks ( void );
128 /* -----------------------------------------------------------------------------
129 Stats 'n' DEBUG stuff
130 -------------------------------------------------------------------------- */
132 extern ullong total_allocated;
134 lnat calcAllocated (void);
135 lnat calcLiveBlocks (void);
136 lnat calcLiveWords (void);
137 lnat countOccupied (bdescr *bd);
138 lnat calcNeeded (void);
139 HsInt64 getAllocations (void);
142 void memInventory (rtsBool show);
143 void checkSanity (void);
144 nat countBlocks (bdescr *);
145 void checkNurserySanity (step *stp);
148 /* ----------------------------------------------------------------------------
149 Storage manager internal APIs and globals
150 ------------------------------------------------------------------------- */
152 #define END_OF_STATIC_LIST ((StgClosure*)1)
154 void move_TSO (StgTSO *src, StgTSO *dest);
156 extern StgClosure * caf_list;
157 extern StgClosure * revertible_caf_list;
161 #endif /* SM_STORAGE_H */