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