Merge commit '7b0b9f603bb1215e2b7af23c2404d637b95a4988' as 'hadrian'
[ghc.git] / rts / sm / GC.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team 1998-2008
4 *
5 * Generational garbage collector
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 #pragma once
15
16 #include "BeginPrivate.h"
17
18 #include "HeapAlloc.h"
19
20 void GarbageCollect (uint32_t force_major_gc,
21 bool do_heap_census,
22 uint32_t gc_type, Capability *cap, bool idle_cap[]);
23
24 typedef void (*evac_fn)(void *user, StgClosure **root);
25
26 StgClosure * isAlive ( StgClosure *p );
27 void markCAFs ( evac_fn evac, void *user );
28
29 extern uint32_t N;
30 extern bool major_gc;
31
32 extern bdescr *mark_stack_bd;
33 extern bdescr *mark_stack_top_bd;
34 extern StgPtr mark_sp;
35
36 extern bool work_stealing;
37
38 #if defined(DEBUG)
39 extern uint32_t mutlist_MUTVARS, mutlist_MUTARRS, mutlist_MVARS, mutlist_OTHERS,
40 mutlist_TVAR,
41 mutlist_TVAR_WATCH_QUEUE,
42 mutlist_TREC_CHUNK,
43 mutlist_TREC_HEADER,
44 mutlist_ATOMIC_INVARIANT,
45 mutlist_INVARIANT_CHECK_QUEUE;
46 #endif
47
48 #if defined(PROF_SPIN) && defined(THREADED_RTS)
49 extern StgWord64 whitehole_spin;
50 #endif
51
52 void gcWorkerThread (Capability *cap);
53 void initGcThreads (uint32_t from, uint32_t to);
54 void freeGcThreads (void);
55
56 #if defined(THREADED_RTS)
57 void waitForGcThreads (Capability *cap, bool idle_cap[]);
58 void releaseGCThreads (Capability *cap, bool idle_cap[]);
59 #endif
60
61 #define WORK_UNIT_WORDS 128
62
63 #include "EndPrivate.h"