1 | // Licensed to the .NET Foundation under one or more agreements. |
---|---|
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | // |
5 | // EEToProfInterfaceImpl.inl |
6 | // |
7 | |
8 | // |
9 | // Inline implementation of portions of the code that wraps calling into |
10 | // the profiler's implementation of ICorProfilerCallback* |
11 | // |
12 | |
13 | // ====================================================================================== |
14 | |
15 | #ifndef __EETOPROFINTERFACEIMPL_INL__ |
16 | #define __EETOPROFINTERFACEIMPL_INL__ |
17 | |
18 | #include "profilepriv.h" |
19 | #include "profilepriv.inl" |
20 | #include "simplerwlock.hpp" |
21 | |
22 | // ---------------------------------------------------------------------------- |
23 | // EEToProfInterfaceImpl::IsCallback3Supported |
24 | // |
25 | // Description: |
26 | // Returns BOOL indicating whether the profiler implements |
27 | // ICorProfilerCallback3. |
28 | // |
29 | |
30 | inline BOOL EEToProfInterfaceImpl::IsCallback3Supported() |
31 | { |
32 | LIMITED_METHOD_CONTRACT; |
33 | return (m_pCallback3 != NULL); |
34 | } |
35 | |
36 | // ---------------------------------------------------------------------------- |
37 | // EEToProfInterfaceImpl::IsCallback4Supported |
38 | // |
39 | // Description: |
40 | // Returns BOOL indicating whether the profiler implements |
41 | // ICorProfilerCallback4. |
42 | // |
43 | |
44 | inline BOOL EEToProfInterfaceImpl::IsCallback4Supported() |
45 | { |
46 | LIMITED_METHOD_CONTRACT; |
47 | return (m_pCallback4 != NULL); |
48 | } |
49 | |
50 | inline BOOL EEToProfInterfaceImpl::IsCallback5Supported() |
51 | { |
52 | LIMITED_METHOD_CONTRACT; |
53 | return (m_pCallback5 != NULL); |
54 | } |
55 | |
56 | inline BOOL EEToProfInterfaceImpl::IsCallback6Supported() |
57 | { |
58 | LIMITED_METHOD_CONTRACT; |
59 | return (m_pCallback6 != NULL); |
60 | } |
61 | |
62 | inline BOOL EEToProfInterfaceImpl::IsCallback7Supported() |
63 | { |
64 | LIMITED_METHOD_CONTRACT; |
65 | return (m_pCallback7 != NULL); |
66 | } |
67 | |
68 | inline BOOL EEToProfInterfaceImpl::IsCallback8Supported() |
69 | { |
70 | LIMITED_METHOD_CONTRACT; |
71 | return (m_pCallback8 != NULL); |
72 | } |
73 | |
74 | inline FunctionIDMapper * EEToProfInterfaceImpl::GetFunctionIDMapper() |
75 | { |
76 | LIMITED_METHOD_CONTRACT; |
77 | return m_pProfilersFuncIDMapper; |
78 | } |
79 | |
80 | inline FunctionIDMapper2 * EEToProfInterfaceImpl::GetFunctionIDMapper2() |
81 | { |
82 | LIMITED_METHOD_CONTRACT; |
83 | return m_pProfilersFuncIDMapper2; |
84 | } |
85 | |
86 | inline void EEToProfInterfaceImpl::SetFunctionIDMapper(FunctionIDMapper * pFunc) |
87 | { |
88 | LIMITED_METHOD_CONTRACT; |
89 | m_pProfilersFuncIDMapper = pFunc; |
90 | } |
91 | |
92 | inline void EEToProfInterfaceImpl::SetFunctionIDMapper2(FunctionIDMapper2 * pFunc, void * clientData) |
93 | { |
94 | LIMITED_METHOD_CONTRACT; |
95 | m_pProfilersFuncIDMapper2 = pFunc; |
96 | m_pProfilersFuncIDMapper2ClientData = clientData; |
97 | } |
98 | |
99 | inline BOOL EEToProfInterfaceImpl::IsLoadedViaAttach() |
100 | { |
101 | LIMITED_METHOD_CONTRACT; |
102 | return m_fLoadedViaAttach; |
103 | } |
104 | |
105 | inline void EEToProfInterfaceImpl::SetUnrevertiblyModifiedILFlag() |
106 | { |
107 | LIMITED_METHOD_CONTRACT; |
108 | m_fUnrevertiblyModifiedIL = TRUE; |
109 | } |
110 | |
111 | inline void EEToProfInterfaceImpl::SetModifiedRejitState() |
112 | { |
113 | LIMITED_METHOD_CONTRACT; |
114 | m_fModifiedRejitState = TRUE; |
115 | } |
116 | |
117 | inline FunctionEnter * EEToProfInterfaceImpl::GetEnterHook() |
118 | { |
119 | LIMITED_METHOD_CONTRACT; |
120 | return m_pEnter; |
121 | } |
122 | |
123 | inline FunctionLeave * EEToProfInterfaceImpl::GetLeaveHook() |
124 | { |
125 | LIMITED_METHOD_CONTRACT; |
126 | return m_pLeave; |
127 | } |
128 | |
129 | inline FunctionTailcall * EEToProfInterfaceImpl::GetTailcallHook() |
130 | { |
131 | LIMITED_METHOD_CONTRACT; |
132 | return m_pTailcall; |
133 | } |
134 | |
135 | inline FunctionEnter2 * EEToProfInterfaceImpl::GetEnter2Hook() |
136 | { |
137 | LIMITED_METHOD_CONTRACT; |
138 | return m_pEnter2; |
139 | } |
140 | |
141 | inline FunctionLeave2 * EEToProfInterfaceImpl::GetLeave2Hook() |
142 | { |
143 | LIMITED_METHOD_CONTRACT; |
144 | return m_pLeave2; |
145 | } |
146 | |
147 | inline FunctionTailcall2 * EEToProfInterfaceImpl::GetTailcall2Hook() |
148 | { |
149 | LIMITED_METHOD_CONTRACT; |
150 | return m_pTailcall2; |
151 | } |
152 | |
153 | inline FunctionEnter3 * EEToProfInterfaceImpl::GetEnter3Hook() |
154 | { |
155 | LIMITED_METHOD_CONTRACT; |
156 | return m_pEnter3; |
157 | } |
158 | |
159 | inline FunctionLeave3 * EEToProfInterfaceImpl::GetLeave3Hook() |
160 | { |
161 | LIMITED_METHOD_CONTRACT; |
162 | return m_pLeave3; |
163 | } |
164 | |
165 | inline FunctionTailcall3 * EEToProfInterfaceImpl::GetTailcall3Hook() |
166 | { |
167 | LIMITED_METHOD_CONTRACT; |
168 | return m_pTailcall3; |
169 | } |
170 | |
171 | inline FunctionEnter3WithInfo * EEToProfInterfaceImpl::GetEnter3WithInfoHook() |
172 | { |
173 | LIMITED_METHOD_CONTRACT; |
174 | return m_pEnter3WithInfo; |
175 | } |
176 | |
177 | inline FunctionLeave3WithInfo * EEToProfInterfaceImpl::GetLeave3WithInfoHook() |
178 | { |
179 | LIMITED_METHOD_CONTRACT; |
180 | return m_pLeave3WithInfo; |
181 | } |
182 | |
183 | inline FunctionTailcall3WithInfo * EEToProfInterfaceImpl::GetTailcall3WithInfoHook() |
184 | { |
185 | LIMITED_METHOD_CONTRACT; |
186 | return m_pTailcall3WithInfo; |
187 | } |
188 | |
189 | inline BOOL EEToProfInterfaceImpl::IsClientIDToFunctionIDMappingEnabled() |
190 | { |
191 | LIMITED_METHOD_CONTRACT; |
192 | return m_fIsClientIDToFunctionIDMappingEnabled; |
193 | } |
194 | |
195 | //--------------------------------------------------------------------------------------- |
196 | // |
197 | // Lookup the clientID for a given functionID |
198 | // |
199 | // Arguments: |
200 | // functionID |
201 | // |
202 | // Return Value: |
203 | // If found a match, return clientID; Otherwise return NULL. |
204 | // |
205 | inline UINT_PTR EEToProfInterfaceImpl::LookupClientIDFromCache(FunctionID functionID) |
206 | { |
207 | CONTRACTL |
208 | { |
209 | SO_NOT_MAINLINE; |
210 | NOTHROW; |
211 | GC_NOTRIGGER; |
212 | MODE_COOPERATIVE; |
213 | } CONTRACTL_END; |
214 | |
215 | _ASSERTE(functionID != NULL); |
216 | |
217 | SimpleReadLockHolder readLockHolder(m_pFunctionIDHashTableRWLock); |
218 | const FunctionIDAndClientID * entry = m_pFunctionIDHashTable->LookupPtr(functionID); |
219 | |
220 | // entry can be NULL when OOM happens. |
221 | if (entry != NULL) |
222 | { |
223 | return entry->clientID; |
224 | } |
225 | else |
226 | { |
227 | return NULL; |
228 | } |
229 | } |
230 | |
231 | //--------------------------------------------------------------------------------------- |
232 | // |
233 | // Returns whether the profiler chose options that require the JIT to compile with the |
234 | // CORINFO_GENERICS_CTXT_KEEP_ALIVE flag. |
235 | // |
236 | // Return Value: |
237 | // Nonzero iff the JIT should compile with CORINFO_GENERICS_CTXT_KEEP_ALIVE. |
238 | // |
239 | |
240 | inline BOOL EEToProfInterfaceImpl::RequiresGenericsContextForEnterLeave() |
241 | { |
242 | CONTRACTL |
243 | { |
244 | NOTHROW; |
245 | GC_NOTRIGGER; |
246 | CANNOT_TAKE_LOCK; |
247 | } |
248 | CONTRACTL_END; |
249 | |
250 | return |
251 | CORProfilerPresent() && |
252 | ((g_profControlBlock.dwEventMask & COR_PRF_ENABLE_FRAME_INFO) != 0) && |
253 | ( |
254 | (m_pEnter2 != NULL) || |
255 | (m_pLeave2 != NULL) || |
256 | (m_pTailcall2 != NULL) || |
257 | (m_pEnter3WithInfo != NULL) || |
258 | (m_pLeave3WithInfo != NULL) || |
259 | (m_pTailcall3WithInfo != NULL) |
260 | ); |
261 | } |
262 | |
263 | inline BOOL EEToProfInterfaceImpl::HasTimedOutWaitingForConcurrentGC() |
264 | { |
265 | LIMITED_METHOD_CONTRACT; |
266 | return m_bHasTimedOutWaitingForConcurrentGC; |
267 | } |
268 | |
269 | #endif // __EETOPROFINTERFACEIMPL_INL__ |
270 | |
271 |