rts: enable parallel GC scan of large (32M+) allocation area
[ghc.git] / rts / Updates.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2013
4 *
5 * Performing updates.
6 *
7 * ---------------------------------------------------------------------------*/
8
9 #ifndef UPDATES_H
10 #define UPDATES_H
11
12 #ifndef CMINUSMINUS
13 #include "BeginPrivate.h"
14 #endif
15
16 /* -----------------------------------------------------------------------------
17 Updates
18 -------------------------------------------------------------------------- */
19
20 /* LDV profiling:
21 * After all, we do *NOT* need to call LDV_RECORD_CREATE() for IND
22 * closures because they are inherently used. But, it corrupts
23 * the invariants that every closure keeps its creation time in the profiling
24 * field. So, we call LDV_RECORD_CREATE().
25 */
26
27 /*
28 * We have two versions of this macro (sadly), one for use in C-- code,
29 * and the other for C.
30 *
31 * The and_then argument is a performance hack so that we can paste in
32 * the continuation code directly. It helps shave a couple of
33 * instructions off the common case in the update code, which is
34 * worthwhile (the update code is often part of the inner loop).
35 */
36 #ifdef CMINUSMINUS
37
38 #define UPDATE_FRAME_FIELDS(w_,p_,info_ptr,ccs,p2,updatee) \
39 w_ info_ptr, \
40 PROF_HDR_FIELDS(w_,ccs,p2) \
41 p_ updatee
42
43
44 #define updateWithIndirection(p1, p2, and_then) \
45 W_ bd; \
46 \
47 OVERWRITING_CLOSURE(p1); \
48 StgInd_indirectee(p1) = p2; \
49 prim_write_barrier; \
50 SET_INFO(p1, stg_BLACKHOLE_info); \
51 LDV_RECORD_CREATE(p1); \
52 bd = Bdescr(p1); \
53 if (bdescr_gen_no(bd) != 0 :: bits16) { \
54 recordMutableCap(p1, TO_W_(bdescr_gen_no(bd))); \
55 TICK_UPD_OLD_IND(); \
56 and_then; \
57 } else { \
58 TICK_UPD_NEW_IND(); \
59 and_then; \
60 }
61
62 #else /* !CMINUSMINUS */
63
64 INLINE_HEADER void updateWithIndirection (Capability *cap,
65 StgClosure *p1,
66 StgClosure *p2)
67 {
68 bdescr *bd;
69
70 ASSERT( (P_)p1 != (P_)p2 );
71 /* not necessarily true: ASSERT( !closure_IND(p1) ); */
72 /* occurs in RaiseAsync.c:raiseAsync() */
73 OVERWRITING_CLOSURE(p1);
74 ((StgInd *)p1)->indirectee = p2;
75 write_barrier();
76 SET_INFO(p1, &stg_BLACKHOLE_info);
77 LDV_RECORD_CREATE(p1);
78 bd = Bdescr((StgPtr)p1);
79 if (bd->gen_no != 0) {
80 recordMutableCap(p1, cap, bd->gen_no);
81 TICK_UPD_OLD_IND();
82 } else {
83 TICK_UPD_NEW_IND();
84 }
85 }
86
87 #endif /* CMINUSMINUS */
88
89 #ifndef CMINUSMINUS
90 #include "EndPrivate.h"
91 #endif
92
93 #endif /* UPDATES_H */