1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-2004
5 * Code to perform updates.
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.
11 * ---------------------------------------------------------------------------*/
16 #include "StgLdvProf.h"
18 /* on entry to the update code
19 (1) R1 points to the closure being returned
20 (2) Sp points to the update frame
23 /* The update fragment has been tuned so as to generate good
24 code with gcc, which accounts for some of the strangeness in the
27 In particular, the JMP_(ret) bit is passed down and pinned on the
28 end of each branch (there end up being two major branches in the
29 code), since we don't mind duplicating this jump.
32 #define UPD_FRAME_ENTRY_TEMPLATE \
36 updatee = StgUpdateFrame_updatee(Sp); \
38 /* remove the update frame from the stack */ \
39 Sp = Sp + SIZEOF_StgUpdateFrame; \
41 /* ToDo: it might be a PAP, so we should check... */ \
42 TICK_UPD_CON_IN_NEW(sizeW_fromITBL(%GET_STD_INFO(updatee))); \
44 UPD_SPEC_IND(updatee, stg_IND_direct_info, R1, jump %ENTRY_CODE(Sp(0))); \
47 #if defined(PROFILING)
48 #define UPD_FRAME_BITMAP 3
49 #define UPD_FRAME_WORDS 3
51 #define UPD_FRAME_BITMAP 0
52 #define UPD_FRAME_WORDS 1
55 /* this bitmap indicates that the first word of an update frame is a
56 * non-pointer - this is the update frame link. (for profiling,
57 * there's a cost-centre-stack in there too).
60 INFO_TABLE_RET( stg_upd_frame,
61 UPD_FRAME_WORDS, UPD_FRAME_BITMAP, UPDATE_FRAME)
62 UPD_FRAME_ENTRY_TEMPLATE
65 INFO_TABLE_RET( stg_marked_upd_frame,
66 UPD_FRAME_WORDS, UPD_FRAME_BITMAP, UPDATE_FRAME)
67 UPD_FRAME_ENTRY_TEMPLATE