@@ -109,16 +109,10 @@ class ProfilerInfo
109109
110110 EventMask eventMask;
111111
112- // ---------------------------------------------------------------
113- // dwProfilerEvacuationCounter keeps track of how many profiler
114- // callback calls remain on the stack
115- // ---------------------------------------------------------------
116- // Why volatile?
117- // See code:ProfilingAPIUtility::InitializeProfiling#LoadUnloadCallbackSynchronization.
118- Volatile<DWORD> dwProfilerEvacuationCounter;
119-
120112 Volatile<BOOL> inUse;
121113
114+ DWORD slot;
115+
122116 // Reset those variables that is only for the current attach session
123117 void ResetPerSessionStatus ();
124118 void Init ();
@@ -150,19 +144,11 @@ class EvacuationCounterHolder
150144{
151145private:
152146 ProfilerInfo *m_pProfilerInfo;
147+ Thread *m_pThread;
153148
154149public:
155- EvacuationCounterHolder (ProfilerInfo *pProfilerInfo) :
156- m_pProfilerInfo (pProfilerInfo)
157- {
158- _ASSERTE (m_pProfilerInfo != NULL );
159- InterlockedIncrement ((LONG *)(m_pProfilerInfo->dwProfilerEvacuationCounter .GetPointer ()));
160- }
161-
162- ~EvacuationCounterHolder ()
163- {
164- InterlockedDecrement ((LONG *)(m_pProfilerInfo->dwProfilerEvacuationCounter .GetPointer ()));
165- }
150+ EvacuationCounterHolder (ProfilerInfo *pProfilerInfo);
151+ ~EvacuationCounterHolder ();
166152};
167153
168154struct StoredProfilerNode
@@ -289,23 +275,26 @@ class ProfControlBlock
289275 BOOL IsMainProfiler (ProfToEEInterfaceImpl *pProfToEE);
290276 ProfilerInfo *GetProfilerInfo (ProfToEEInterfaceImpl *pProfToEE);
291277
292- template <typename ConditionFunc, typename CallbackFunc, typename Data = void , typename ... Args>
293- FORCEINLINE HRESULT DoProfilerCallback (ProfilerCallbackType callbackType, ConditionFunc condition, Data *additionalData, CallbackFunc callback, Args... args)
278+ template <typename ConditionFunc, typename CallbackFunc, typename ... Args>
279+ static void DoProfilerCallbackHelper (ProfilerInfo *pProfilerInfo, ConditionFunc condition, CallbackFunc callback, HRESULT *pHR, Args... args)
280+ {
281+ if (condition (pProfilerInfo))
282+ {
283+ HRESULT innerHR = callback (pProfilerInfo->pProfInterface , args...);
284+ if (FAILED (innerHR))
285+ {
286+ *pHR = innerHR;
287+ }
288+ }
289+ }
290+
291+ template <typename ConditionFunc, typename CallbackFunc, typename ... Args>
292+ FORCEINLINE HRESULT DoProfilerCallback (ProfilerCallbackType callbackType, ConditionFunc condition, CallbackFunc callback, Args... args)
294293 {
295294 HRESULT hr = S_OK;
296295 IterateProfilers (callbackType,
297- [](ProfilerInfo *pProfilerInfo, ConditionFunc condition, Data *additionalData, CallbackFunc callback, HRESULT *pHR, Args... args)
298- {
299- if (condition (pProfilerInfo))
300- {
301- HRESULT innerHR = callback (additionalData, pProfilerInfo->pProfInterface , args...);
302- if (FAILED (innerHR))
303- {
304- *pHR = innerHR;
305- }
306- }
307- },
308- condition, additionalData, callback, &hr, args...);
296+ &DoProfilerCallbackHelper<ConditionFunc, CallbackFunc, Args...>,
297+ condition, callback, &hr, args...);
309298 return hr;
310299 }
311300
@@ -317,7 +306,6 @@ class ProfControlBlock
317306
318307 BOOL IsCallback3Supported ();
319308 BOOL IsCallback5Supported ();
320- BOOL IsDisableTransparencySet ();
321309 BOOL RequiresGenericsContextForEnterLeave ();
322310 UINT_PTR EEFunctionIDMapper (FunctionID funcId, BOOL * pbHookFunction);
323311
0 commit comments