|
|
1
|
+{-# LANGUAGE CPP #-}
|
|
|
2
|
+{-# LANGUAGE DerivingStrategies #-}
|
|
|
3
|
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
|
|
4
|
+module GHC.Internal.Stack.ConstantsProf where
|
|
|
5
|
+
|
|
|
6
|
+import GHC.Internal.Base
|
|
|
7
|
+import GHC.Internal.Enum
|
|
|
8
|
+import GHC.Internal.Num
|
|
|
9
|
+import GHC.Internal.Show
|
|
|
10
|
+import GHC.Internal.Real
|
|
|
11
|
+
|
|
|
12
|
+#define PROFILING
|
|
|
13
|
+#include "Rts.h"
|
|
|
14
|
+#undef BLOCK_SIZE
|
|
|
15
|
+#undef MBLOCK_SIZE
|
|
|
16
|
+#undef BLOCKS_PER_MBLOCK
|
|
|
17
|
+#include "DerivedConstants.h"
|
|
|
18
|
+
|
|
|
19
|
+newtype ByteOffset = ByteOffset { offsetInBytes :: Int }
|
|
|
20
|
+ deriving newtype (Eq, Show, Integral, Real, Num, Enum, Ord)
|
|
|
21
|
+
|
|
|
22
|
+newtype WordOffset = WordOffset { offsetInWords :: Int }
|
|
|
23
|
+ deriving newtype (Eq, Show, Integral, Real, Num, Enum, Ord)
|
|
|
24
|
+
|
|
|
25
|
+offsetStgCatchFrameHandler :: WordOffset
|
|
|
26
|
+offsetStgCatchFrameHandler = byteOffsetToWordOffset $
|
|
|
27
|
+ (#const OFFSET_StgCatchFrame_handler) + (#size StgHeader)
|
|
|
28
|
+
|
|
|
29
|
+sizeStgCatchFrame :: Int
|
|
|
30
|
+sizeStgCatchFrame = bytesToWords $
|
|
|
31
|
+ (#const SIZEOF_StgCatchFrame_NoHdr) + (#size StgHeader)
|
|
|
32
|
+
|
|
|
33
|
+offsetStgCatchSTMFrameCode :: WordOffset
|
|
|
34
|
+offsetStgCatchSTMFrameCode = byteOffsetToWordOffset $
|
|
|
35
|
+ (#const OFFSET_StgCatchSTMFrame_code) + (#size StgHeader)
|
|
|
36
|
+
|
|
|
37
|
+offsetStgCatchSTMFrameHandler :: WordOffset
|
|
|
38
|
+offsetStgCatchSTMFrameHandler = byteOffsetToWordOffset $
|
|
|
39
|
+ (#const OFFSET_StgCatchSTMFrame_handler) + (#size StgHeader)
|
|
|
40
|
+
|
|
|
41
|
+sizeStgCatchSTMFrame :: Int
|
|
|
42
|
+sizeStgCatchSTMFrame = bytesToWords $
|
|
|
43
|
+ (#const SIZEOF_StgCatchSTMFrame_NoHdr) + (#size StgHeader)
|
|
|
44
|
+
|
|
|
45
|
+offsetStgUpdateFrameUpdatee :: WordOffset
|
|
|
46
|
+offsetStgUpdateFrameUpdatee = byteOffsetToWordOffset $
|
|
|
47
|
+ (#const OFFSET_StgUpdateFrame_updatee) + (#size StgHeader)
|
|
|
48
|
+
|
|
|
49
|
+sizeStgUpdateFrame :: Int
|
|
|
50
|
+sizeStgUpdateFrame = bytesToWords $
|
|
|
51
|
+ (#const SIZEOF_StgUpdateFrame_NoHdr) + (#size StgHeader)
|
|
|
52
|
+
|
|
|
53
|
+offsetStgAtomicallyFrameCode :: WordOffset
|
|
|
54
|
+offsetStgAtomicallyFrameCode = byteOffsetToWordOffset $
|
|
|
55
|
+ (#const OFFSET_StgAtomicallyFrame_code) + (#size StgHeader)
|
|
|
56
|
+
|
|
|
57
|
+offsetStgAtomicallyFrameResult :: WordOffset
|
|
|
58
|
+offsetStgAtomicallyFrameResult = byteOffsetToWordOffset $
|
|
|
59
|
+ (#const OFFSET_StgAtomicallyFrame_result) + (#size StgHeader)
|
|
|
60
|
+
|
|
|
61
|
+sizeStgAtomicallyFrame :: Int
|
|
|
62
|
+sizeStgAtomicallyFrame = bytesToWords $
|
|
|
63
|
+ (#const SIZEOF_StgAtomicallyFrame_NoHdr) + (#size StgHeader)
|
|
|
64
|
+
|
|
|
65
|
+offsetStgCatchRetryFrameRunningAltCode :: WordOffset
|
|
|
66
|
+offsetStgCatchRetryFrameRunningAltCode = byteOffsetToWordOffset $
|
|
|
67
|
+ (#const OFFSET_StgCatchRetryFrame_running_alt_code) + (#size StgHeader)
|
|
|
68
|
+
|
|
|
69
|
+offsetStgCatchRetryFrameRunningFirstCode :: WordOffset
|
|
|
70
|
+offsetStgCatchRetryFrameRunningFirstCode = byteOffsetToWordOffset $
|
|
|
71
|
+ (#const OFFSET_StgCatchRetryFrame_first_code) + (#size StgHeader)
|
|
|
72
|
+
|
|
|
73
|
+offsetStgCatchRetryFrameAltCode :: WordOffset
|
|
|
74
|
+offsetStgCatchRetryFrameAltCode = byteOffsetToWordOffset $
|
|
|
75
|
+ (#const OFFSET_StgCatchRetryFrame_alt_code) + (#size StgHeader)
|
|
|
76
|
+
|
|
|
77
|
+sizeStgCatchRetryFrame :: Int
|
|
|
78
|
+sizeStgCatchRetryFrame = bytesToWords $
|
|
|
79
|
+ (#const SIZEOF_StgCatchRetryFrame_NoHdr) + (#size StgHeader)
|
|
|
80
|
+
|
|
|
81
|
+offsetStgRetFunFrameSize :: WordOffset
|
|
|
82
|
+-- StgRetFun has no header, but only a pointer to the info table at the beginning.
|
|
|
83
|
+offsetStgRetFunFrameSize = byteOffsetToWordOffset (#const OFFSET_StgRetFun_size)
|
|
|
84
|
+
|
|
|
85
|
+offsetStgRetFunFrameFun :: WordOffset
|
|
|
86
|
+offsetStgRetFunFrameFun = byteOffsetToWordOffset (#const OFFSET_StgRetFun_fun)
|
|
|
87
|
+
|
|
|
88
|
+offsetStgRetFunFramePayload :: WordOffset
|
|
|
89
|
+offsetStgRetFunFramePayload = byteOffsetToWordOffset (#const OFFSET_StgRetFun_payload)
|
|
|
90
|
+
|
|
|
91
|
+sizeStgRetFunFrame :: Int
|
|
|
92
|
+sizeStgRetFunFrame = bytesToWords (#const SIZEOF_StgRetFun)
|
|
|
93
|
+
|
|
|
94
|
+sizeStgAnnFrame :: Int
|
|
|
95
|
+sizeStgAnnFrame = bytesToWords $
|
|
|
96
|
+ (#const SIZEOF_StgAnnFrame_NoHdr) + (#size StgHeader)
|
|
|
97
|
+
|
|
|
98
|
+offsetStgAnnFrameAnn :: WordOffset
|
|
|
99
|
+offsetStgAnnFrameAnn = byteOffsetToWordOffset $
|
|
|
100
|
+ (#const OFFSET_StgAnnFrame_ann) + (#size StgHeader)
|
|
|
101
|
+
|
|
|
102
|
+offsetStgBCOFrameInstrs :: ByteOffset
|
|
|
103
|
+offsetStgBCOFrameInstrs = (#const OFFSET_StgBCO_instrs) + (#size StgHeader)
|
|
|
104
|
+
|
|
|
105
|
+offsetStgBCOFrameLiterals :: ByteOffset
|
|
|
106
|
+offsetStgBCOFrameLiterals = (#const OFFSET_StgBCO_literals) + (#size StgHeader)
|
|
|
107
|
+
|
|
|
108
|
+offsetStgBCOFramePtrs :: ByteOffset
|
|
|
109
|
+offsetStgBCOFramePtrs = (#const OFFSET_StgBCO_ptrs) + (#size StgHeader)
|
|
|
110
|
+
|
|
|
111
|
+offsetStgBCOFrameArity :: ByteOffset
|
|
|
112
|
+offsetStgBCOFrameArity = (#const OFFSET_StgBCO_arity) + (#size StgHeader)
|
|
|
113
|
+
|
|
|
114
|
+offsetStgBCOFrameSize :: ByteOffset
|
|
|
115
|
+offsetStgBCOFrameSize = (#const OFFSET_StgBCO_size) + (#size StgHeader)
|
|
|
116
|
+
|
|
|
117
|
+offsetStgClosurePayload :: WordOffset
|
|
|
118
|
+offsetStgClosurePayload = byteOffsetToWordOffset $
|
|
|
119
|
+ (#const OFFSET_StgClosure_payload) + (#size StgHeader)
|
|
|
120
|
+
|
|
|
121
|
+sizeStgClosure :: Int
|
|
|
122
|
+sizeStgClosure = bytesToWords (#size StgHeader)
|
|
|
123
|
+
|
|
|
124
|
+byteOffsetToWordOffset :: ByteOffset -> WordOffset
|
|
|
125
|
+byteOffsetToWordOffset = WordOffset . bytesToWords . fromInteger . toInteger
|
|
|
126
|
+
|
|
|
127
|
+bytesToWords :: Int -> Int
|
|
|
128
|
+bytesToWords b =
|
|
|
129
|
+ if b `mod` bytesInWord == 0 then
|
|
|
130
|
+ fromIntegral $ b `div` bytesInWord
|
|
|
131
|
+ else
|
|
|
132
|
+ error "Unexpected struct alignment!"
|
|
|
133
|
+
|
|
|
134
|
+bytesInWord :: Int
|
|
|
135
|
+bytesInWord = (#const SIZEOF_VOID_P)
|
|
|
136
|
+ |