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,
15 getSMRepClosureTypeInt
24 #include "HsVersions.h"
31 %************************************************************************
33 \subsubsection[SMRep-datatype]{@SMRep@---storage manager representation}
35 %************************************************************************
39 -- static closure have an extra static link field at the end.
40 = GenericRep -- GC routines consult sizes in info tbl
41 Bool -- True <=> This is a static closure. Affects how
42 -- we garbage-collect it
44 !Int -- # non-ptr words
45 ClosureType -- closure type
49 data ClosureType -- Corresponds 1-1 with the varieties of closures
50 -- implemented by the RTS. Compare with ghc/includes/ClosureTypes.h
58 Size of a closure header.
61 fixedHdrSize :: Int{-words-}
62 fixedHdrSize = sTD_HDR_SIZE + profHdrSize + granHdrSize
64 profHdrSize :: Int{-words-}
65 profHdrSize | opt_SccProfilingOn = pROF_HDR_SIZE
68 granHdrSize :: Int{-words-}
69 granHdrSize | opt_GranMacros = gRAN_HDR_SIZE
72 arrWordsHdrSize :: Int{-words-}
73 arrWordsHdrSize = fixedHdrSize + aRR_WORDS_HDR_SIZE
75 arrPtrsHdrSize :: Int{-words-}
76 arrPtrsHdrSize = fixedHdrSize + aRR_PTRS_HDR_SIZE
79 Size of an info table.
82 stdItblSize :: Int{-words-}
83 stdItblSize = sTD_ITBL_SIZE + profItblSize + granItblSize + tickyItblSize
85 retItblSize :: Int{-words-}
86 retItblSize = stdItblSize + rET_ITBL_SIZE
88 profItblSize :: Int{-words-}
89 profItblSize | opt_SccProfilingOn = pROF_ITBL_SIZE
92 granItblSize :: Int{-words-}
93 granItblSize | opt_GranMacros = gRAN_ITBL_SIZE
96 tickyItblSize :: Int{-words-}
97 tickyItblSize | opt_DoTickyProfiling = tICKY_ITBL_SIZE
102 isStaticRep :: SMRep -> Bool
103 isStaticRep (GenericRep is_static _ _ _) = is_static
104 isStaticRep BlackHoleRep = False
108 #include "../includes/ClosureTypes.h"
109 -- Defines CONSTR, CONSTR_1_0 etc
111 getSMRepClosureTypeInt :: SMRep -> Int
112 getSMRepClosureTypeInt (GenericRep False 1 0 Constr) = CONSTR_1_0
113 getSMRepClosureTypeInt (GenericRep False 0 1 Constr) = CONSTR_0_1
114 getSMRepClosureTypeInt (GenericRep False 2 0 Constr) = CONSTR_2_0
115 getSMRepClosureTypeInt (GenericRep False 1 1 Constr) = CONSTR_1_1
116 getSMRepClosureTypeInt (GenericRep False 0 2 Constr) = CONSTR_0_2
117 getSMRepClosureTypeInt (GenericRep False _ _ Constr) = CONSTR
119 getSMRepClosureTypeInt (GenericRep False 1 0 Fun) = FUN_1_0
120 getSMRepClosureTypeInt (GenericRep False 0 1 Fun) = FUN_0_1
121 getSMRepClosureTypeInt (GenericRep False 2 0 Fun) = FUN_2_0
122 getSMRepClosureTypeInt (GenericRep False 1 1 Fun) = FUN_1_1
123 getSMRepClosureTypeInt (GenericRep False 0 2 Fun) = FUN_0_2
124 getSMRepClosureTypeInt (GenericRep False _ _ Fun) = FUN
126 getSMRepClosureTypeInt (GenericRep False 1 0 Thunk) = THUNK_1_0
127 getSMRepClosureTypeInt (GenericRep False 0 1 Thunk) = THUNK_0_1
128 getSMRepClosureTypeInt (GenericRep False 2 0 Thunk) = THUNK_2_0
129 getSMRepClosureTypeInt (GenericRep False 1 1 Thunk) = THUNK_1_1
130 getSMRepClosureTypeInt (GenericRep False 0 2 Thunk) = THUNK_0_2
131 getSMRepClosureTypeInt (GenericRep False _ _ Thunk) = THUNK
133 getSMRepClosureTypeInt (GenericRep False _ _ ThunkSelector) = THUNK_SELECTOR
135 getSMRepClosureTypeInt (GenericRep True _ _ Constr) = CONSTR_STATIC
136 getSMRepClosureTypeInt (GenericRep True _ _ ConstrNoCaf) = CONSTR_NOCAF_STATIC
137 getSMRepClosureTypeInt (GenericRep True _ _ Fun) = FUN_STATIC
138 getSMRepClosureTypeInt (GenericRep True _ _ Thunk) = THUNK_STATIC
140 getSMRepClosureTypeInt BlackHoleRep = BLACKHOLE
142 getSMRepClosureTypeInt rep = panic "getSMRepClosureTypeInt"
145 -- We export these ones
146 rET_SMALL = (RET_SMALL :: Int)
147 rET_VEC_SMALL = (RET_VEC_SMALL :: Int)
148 rET_BIG = (RET_BIG :: Int)
149 rET_VEC_BIG = (RET_VEC_BIG :: Int)