e0fd7c30d5e13a58ce6068e4cfc4a7328e535836
[ghc-hetmet.git] / rts / Updates.cmm
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 1998-2004
4  *
5  * Code to perform updates.
6  *
7  * This file is written in a subset of C--, extended with various
8  * features specific to GHC.  It is compiled by GHC directly.  For the
9  * syntax of .cmm files, see the parser in ghc/compiler/cmm/CmmParse.y.
10  *
11  * ---------------------------------------------------------------------------*/
12
13
14 #include "Cmm.h"
15 #include "rts/prof/LDV.h"
16
17 #include "Updates.h"
18
19 /* on entry to the update code
20    (1) R1 points to the closure being returned
21    (2) Sp points to the update frame
22 */
23
24 /* The update fragment has been tuned so as to generate good
25    code with gcc, which accounts for some of the strangeness in the
26    way it is written.  
27
28    In particular, the JMP_(ret) bit is passed down and pinned on the
29    end of each branch (there end up being two major branches in the
30    code), since we don't mind duplicating this jump.
31 */
32
33 #define UPD_FRAME_ENTRY_TEMPLATE                                        \
34         {                                                               \
35           W_ updatee;                                                   \
36                                                                         \
37           updatee = StgUpdateFrame_updatee(Sp);                         \
38                                                                         \
39           /* remove the update frame from the stack */                  \
40           Sp = Sp + SIZEOF_StgUpdateFrame;                              \
41                                                                         \
42           /* ToDo: it might be a PAP, so we should check... */          \
43           TICK_UPD_CON_IN_NEW(sizeW_fromITBL(%GET_STD_INFO(updatee)));  \
44                                                                         \
45           updateWithIndirection(stg_IND_direct_info,                    \
46                                 updatee,                                \
47                                 R1,                                     \
48                                 jump %ENTRY_CODE(Sp(0)));               \
49         }
50
51 #if defined(PROFILING)
52 #define UPD_FRAME_PARAMS W_ unused1, W_ unused2, P_ unused3
53 #else
54 #define UPD_FRAME_PARAMS P_ unused1
55 #endif
56
57 /* this bitmap indicates that the first word of an update frame is a
58  * non-pointer - this is the update frame link.  (for profiling,
59  * there's a cost-centre-stack in there too).
60  */
61
62 INFO_TABLE_RET( stg_upd_frame, UPDATE_FRAME, UPD_FRAME_PARAMS)
63 UPD_FRAME_ENTRY_TEMPLATE
64
65
66 INFO_TABLE_RET( stg_marked_upd_frame, UPDATE_FRAME, UPD_FRAME_PARAMS)
67 UPD_FRAME_ENTRY_TEMPLATE