When in sanity mode, un-zero malloc'd memory; fix uninitialized memory bugs.
[ghc.git] / rts / sm / CNF.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team 1998-2014
4 *
5 * GC support for immutable non-GCed structures
6 *
7 * Documentation on the architecture of the Garbage Collector can be
8 * found in the online commentary:
9 *
10 * http://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/GC
11 *
12 * ---------------------------------------------------------------------------*/
13
14 #ifndef SM_CNF_H
15 #define SM_CNF_H
16
17 #include "BeginPrivate.h"
18
19 void initCompact (void);
20 void exitCompact (void);
21
22 StgCompactNFData *compactNew (Capability *cap,
23 StgWord size);
24 StgPtr compactAppend(Capability *cap,
25 StgCompactNFData *str,
26 StgClosure *what,
27 StgWord share);
28 void compactResize(Capability *cap,
29 StgCompactNFData *str,
30 StgWord new_size);
31 void compactFree (StgCompactNFData *str);
32 void compactMarkKnown(StgCompactNFData *str);
33 StgWord compactContains(StgCompactNFData *str,
34 StgPtr what);
35 StgWord countCompactBlocks(bdescr *outer);
36
37 StgCompactNFDataBlock *compactAllocateBlock(Capability *cap,
38 StgWord size,
39 StgCompactNFDataBlock *previous);
40 StgPtr compactFixupPointers(StgCompactNFData *str,
41 StgClosure *root);
42
43 INLINE_HEADER StgCompactNFDataBlock *objectGetCompactBlock (StgClosure *closure);
44 INLINE_HEADER StgCompactNFDataBlock *objectGetCompactBlock (StgClosure *closure)
45 {
46 bdescr *object_block, *head_block;
47
48 object_block = Bdescr((StgPtr)closure);
49
50 ASSERT ((object_block->flags & BF_COMPACT) != 0);
51
52 if (object_block->blocks == 0)
53 head_block = object_block->link;
54 else
55 head_block = object_block;
56
57 ASSERT ((head_block->flags & BF_COMPACT) != 0);
58
59 return (StgCompactNFDataBlock*)(head_block->start);
60 }
61
62 INLINE_HEADER StgCompactNFData *objectGetCompact (StgClosure *closure);
63 INLINE_HEADER StgCompactNFData *objectGetCompact (StgClosure *closure)
64 {
65 StgCompactNFDataBlock *block = objectGetCompactBlock (closure);
66 return block->owner;
67 }
68
69 #include "EndPrivate.h"
70
71 #endif // SM_COMPACT_H