2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[SMRep]{Storage manager representations of closure}
6 This is here, rather than in ClosureInfo, just to keep nhc happy.
7 Other modules should access this info through ClosureInfo.
11 SMRep(..), ClosureType(..),
13 fixedHdrSize, arrWordsHdrSize, arrPtrsHdrSize,
14 stdItblSize, retItblSize
16 #ifndef OMIT_NATIVE_CODEGEN
17 , getSMRepClosureTypeInt
49 #include "HsVersions.h"
56 %************************************************************************
58 \subsubsection[SMRep-datatype]{@SMRep@---storage manager representation}
60 %************************************************************************
64 -- static closure have an extra static link field at the end.
65 = GenericRep -- GC routines consult sizes in info tbl
66 Bool -- True <=> This is a static closure. Affects how
67 -- we garbage-collect it
69 !Int -- # non-ptr words
70 ClosureType -- closure type
74 data ClosureType -- Corresponds 1-1 with the varieties of closures
75 -- implemented by the RTS. Compare with ghc/includes/ClosureTypes.h
83 Size of a closure header.
86 fixedHdrSize :: Int{-words-}
87 fixedHdrSize = sTD_HDR_SIZE + profHdrSize + granHdrSize
89 profHdrSize :: Int{-words-}
90 profHdrSize | opt_SccProfilingOn = pROF_HDR_SIZE
93 granHdrSize :: Int{-words-}
94 granHdrSize | opt_GranMacros = gRAN_HDR_SIZE
97 arrWordsHdrSize :: Int{-words-}
98 arrWordsHdrSize = fixedHdrSize + aRR_WORDS_HDR_SIZE
100 arrPtrsHdrSize :: Int{-words-}
101 arrPtrsHdrSize = fixedHdrSize + aRR_PTRS_HDR_SIZE
104 Size of an info table.
107 stdItblSize :: Int{-words-}
108 stdItblSize = sTD_ITBL_SIZE + profItblSize + granItblSize + tickyItblSize
110 retItblSize :: Int{-words-}
111 retItblSize = stdItblSize + rET_ITBL_SIZE
113 profItblSize :: Int{-words-}
114 profItblSize | opt_SccProfilingOn = pROF_ITBL_SIZE
117 granItblSize :: Int{-words-}
118 granItblSize | opt_GranMacros = gRAN_ITBL_SIZE
121 tickyItblSize :: Int{-words-}
122 tickyItblSize | opt_DoTickyProfiling = tICKY_ITBL_SIZE
127 isStaticRep :: SMRep -> Bool
128 isStaticRep (GenericRep is_static _ _ _) = is_static
129 isStaticRep BlackHoleRep = False
133 getSMRepClosureTypeInt :: SMRep -> Int
134 getSMRepClosureTypeInt (GenericRep False 1 0 CONSTR) = cONSTR_1_0
135 getSMRepClosureTypeInt (GenericRep False 0 1 CONSTR) = cONSTR_0_1
136 getSMRepClosureTypeInt (GenericRep False 2 0 CONSTR) = cONSTR_2_0
137 getSMRepClosureTypeInt (GenericRep False 1 1 CONSTR) = cONSTR_1_1
138 getSMRepClosureTypeInt (GenericRep False 0 2 CONSTR) = cONSTR_0_2
139 getSMRepClosureTypeInt (GenericRep False _ _ CONSTR) = cONSTR
141 getSMRepClosureTypeInt (GenericRep False 1 0 FUN) = fUN_1_0
142 getSMRepClosureTypeInt (GenericRep False 0 1 FUN) = fUN_0_1
143 getSMRepClosureTypeInt (GenericRep False 2 0 FUN) = fUN_2_0
144 getSMRepClosureTypeInt (GenericRep False 1 1 FUN) = fUN_1_1
145 getSMRepClosureTypeInt (GenericRep False 0 2 FUN) = fUN_0_2
146 getSMRepClosureTypeInt (GenericRep False _ _ FUN) = fUN
148 getSMRepClosureTypeInt (GenericRep False 1 0 THUNK) = tHUNK_1_0
149 getSMRepClosureTypeInt (GenericRep False 0 1 THUNK) = tHUNK_0_1
150 getSMRepClosureTypeInt (GenericRep False 2 0 THUNK) = tHUNK_2_0
151 getSMRepClosureTypeInt (GenericRep False 1 1 THUNK) = tHUNK_1_1
152 getSMRepClosureTypeInt (GenericRep False 0 2 THUNK) = tHUNK_0_2
153 getSMRepClosureTypeInt (GenericRep False _ _ THUNK) = tHUNK
155 getSMRepClosureTypeInt (GenericRep False _ _ THUNK_SELECTOR) = tHUNK_SELECTOR
157 getSMRepClosureTypeInt (GenericRep True _ _ CONSTR) = cONSTR_STATIC
158 getSMRepClosureTypeInt (GenericRep True _ _ CONSTR_NOCAF) = cONSTR_NOCAF_STATIC
159 getSMRepClosureTypeInt (GenericRep True _ _ FUN) = fUN_STATIC
160 getSMRepClosureTypeInt (GenericRep True _ _ THUNK) = tHUNK_STATIC
162 getSMRepClosureTypeInt BlackHoleRep = bLACKHOLE
164 getSMRepClosureTypeInt rep = panic "getSMRepClosureTypeInt"
167 -- Just the ones we need:
169 #include "../includes/ClosureTypes.h"
171 cONSTR = (CONSTR :: Int)
172 cONSTR_1_0 = (CONSTR_1_0 :: Int)
173 cONSTR_0_1 = (CONSTR_0_1 :: Int)
174 cONSTR_2_0 = (CONSTR_2_0 :: Int)
175 cONSTR_1_1 = (CONSTR_1_1 :: Int)
176 cONSTR_0_2 = (CONSTR_0_2 :: Int)
177 cONSTR_STATIC = (CONSTR_STATIC :: Int)
178 cONSTR_NOCAF_STATIC = (CONSTR_NOCAF_STATIC :: Int)
180 fUN_1_0 = (FUN_1_0 :: Int)
181 fUN_0_1 = (FUN_0_1 :: Int)
182 fUN_2_0 = (FUN_2_0 :: Int)
183 fUN_1_1 = (FUN_1_1 :: Int)
184 fUN_0_2 = (FUN_0_2 :: Int)
185 fUN_STATIC = (FUN_STATIC :: Int)
186 tHUNK = (THUNK :: Int)
187 tHUNK_1_0 = (THUNK_1_0 :: Int)
188 tHUNK_0_1 = (THUNK_0_1 :: Int)
189 tHUNK_2_0 = (THUNK_2_0 :: Int)
190 tHUNK_1_1 = (THUNK_1_1 :: Int)
191 tHUNK_0_2 = (THUNK_0_2 :: Int)
192 tHUNK_STATIC = (THUNK_STATIC :: Int)
193 tHUNK_SELECTOR = (THUNK_SELECTOR :: Int)
194 rET_SMALL = (RET_SMALL :: Int)
195 rET_VEC_SMALL = (RET_VEC_SMALL :: Int)
196 rET_BIG = (RET_BIG :: Int)
197 rET_VEC_BIG = (RET_VEC_BIG :: Int)
198 bLACKHOLE = (BLACKHOLE :: Int)