Remove the per-generation mutable lists
[ghc-hetmet.git] / rts / sm / Storage.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 1998-2009
4  *
5  * External Storage Manger Interface
6  *
7  * ---------------------------------------------------------------------------*/
8
9 #ifndef SM_STORAGE_H
10 #define SM_STORAGE_H
11
12 #include "Capability.h"
13
14 #include "BeginPrivate.h"
15
16 /* -----------------------------------------------------------------------------
17    Initialisation / De-initialisation
18    -------------------------------------------------------------------------- */
19
20 void initStorage(void);
21 void exitStorage(void);
22 void freeStorage(rtsBool free_heap);
23
24 /* -----------------------------------------------------------------------------
25    Storage manager state
26    -------------------------------------------------------------------------- */
27
28 INLINE_HEADER rtsBool
29 doYouWantToGC( Capability *cap )
30 {
31   return (cap->r.rCurrentNursery->link == NULL ||
32           g0->n_new_large_words >= large_alloc_lim);
33 }
34
35 /* for splitting blocks groups in two */
36 bdescr * splitLargeBlock (bdescr *bd, nat blocks);
37
38 /* -----------------------------------------------------------------------------
39    Generational garbage collection support
40
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.
45
46    updateWithPermIndirection(p1,p2)  As above but uses a permanent indir.
47
48    -------------------------------------------------------------------------- */
49
50 /*
51  * Storage manager mutex
52  */
53 #if defined(THREADED_RTS)
54 extern Mutex sm_mutex;
55 #endif
56
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);
61 #else
62 #define ACQUIRE_SM_LOCK
63 #define RELEASE_SM_LOCK
64 #define ASSERT_SM_LOCK()
65 #endif
66
67 /* -----------------------------------------------------------------------------
68    The write barrier for MVARs
69    -------------------------------------------------------------------------- */
70
71 void dirty_MVAR(StgRegTable *reg, StgClosure *p);
72
73 /* -----------------------------------------------------------------------------
74    Nursery manipulation
75    -------------------------------------------------------------------------- */
76
77 extern nursery *nurseries;
78
79 void     resetNurseries       ( void );
80 lnat     clearNurseries       ( void );
81 void     resizeNurseries      ( nat blocks );
82 void     resizeNurseriesFixed ( nat blocks );
83 lnat     countNurseryBlocks   ( void );
84
85 /* -----------------------------------------------------------------------------
86    Stats 'n' DEBUG stuff
87    -------------------------------------------------------------------------- */
88
89 lnat    calcAllocated  (rtsBool count_nurseries);
90 lnat    calcLiveBlocks (void);
91 lnat    calcLiveWords  (void);
92 lnat    countOccupied  (bdescr *bd);
93 lnat    calcNeeded     (void);
94
95 /* ----------------------------------------------------------------------------
96    Storage manager internal APIs and globals
97    ------------------------------------------------------------------------- */
98
99 extern bdescr *exec_block;
100
101 #define END_OF_STATIC_LIST ((StgClosure*)1)
102
103 void move_STACK  (StgStack *src, StgStack *dest);
104
105 extern StgClosure * caf_list;
106 extern StgClosure * revertible_caf_list;
107
108 #include "EndPrivate.h"
109
110 #endif /* SM_STORAGE_H */