1 /* -----------------------------------------------------------------------------
2 * $Id: Storage.h,v 1.2 1998/12/02 13:28:58 simonm Exp $
4 * External Storage Manger Interface
6 * ---------------------------------------------------------------------------*/
12 #include "BlockAlloc.h"
13 #include "StoragePriv.h"
15 /* -----------------------------------------------------------------------------
16 Initialisation / De-initialisation
17 -------------------------------------------------------------------------- */
19 extern void initStorage(void);
20 extern void exitStorage(void);
22 /* -----------------------------------------------------------------------------
25 StgPtr allocate(int n) Allocates a chunk of contiguous store
26 n words long, returning a pointer to
27 the first word. Always succeeds.
29 rtsBool doYouWantToGC(void) Returns True if the storage manager is
30 ready to perform a GC, False otherwise.
32 lnat allocated_bytes(void) Returns the number of bytes allocated
33 via allocate() since the last GC.
34 Used in the reoprting of statistics.
35 -------------------------------------------------------------------------- */
37 extern StgPtr allocate(nat n);
38 static inline rtsBool doYouWantToGC(void)
40 return (alloc_blocks >= alloc_blocks_lim);
42 extern lnat allocated_bytes(void);
44 /* -----------------------------------------------------------------------------
45 ExtendNursery(hp,hplim) When hplim is reached, try to grab
46 some more allocation space. Returns
47 False if the allocation space is
48 exhausted, and the application should
49 call GarbageCollect().
50 -------------------------------------------------------------------------- */
52 #define ExtendNursery(hp,hplim) \
53 (current_nursery->free = (P_)(hp)+1, \
54 current_nursery->link == NULL ? rtsFalse : \
55 (current_nursery = current_nursery->link, \
56 OpenNursery(hp,hplim), \
59 extern void PleaseStopAllocating(void);
61 /* -----------------------------------------------------------------------------
62 Performing Garbage Collection
64 GarbageCollect(get_roots) Performs a garbage collection.
65 'get_roots' is called to find all the
66 roots that the system knows about.
68 StgClosure Called by get_roots on each root.
69 MarkRoot(StgClosure *p) Returns the new location of the root.
70 -------------------------------------------------------------------------- */
72 extern void GarbageCollect(void (*get_roots)(void));
73 extern StgClosure *MarkRoot(StgClosure *p);
75 /* -----------------------------------------------------------------------------
76 Generational garbage collection support
78 RecordMutable(StgPtr p) Informs the garbage collector that a
79 previously immutable object has
80 become (permanently) mutable. Used
81 by thawArray and similar.
83 UpdateWithIndirection(p1,p2) Updates the object at p1 with an
84 indirection pointing to p2. This is
85 normally called for objects in an old
86 generation (>0) when they are updated.
88 -------------------------------------------------------------------------- */
90 extern void RecordMutable(StgPtr p);
91 extern void UpdateWithIndirection(StgPtr p1, StgPtr p2);
93 /* -----------------------------------------------------------------------------
94 The CAF list - used to let us revert CAFs
96 -------------------------------------------------------------------------- */