diff --git a/src/coreclr/vm/callcounting.cpp b/src/coreclr/vm/callcounting.cpp index 9177036fa5fb0e..ee053d81052275 100644 --- a/src/coreclr/vm/callcounting.cpp +++ b/src/coreclr/vm/callcounting.cpp @@ -380,33 +380,10 @@ CallCountingManager::MethodDescForwarderStubHashTraits::Hash(const key_t &k) return (count_t)(size_t)k; } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// CallCountingManager::CallCountingManagerHashTraits - -CallCountingManager::CallCountingManagerHashTraits::key_t -CallCountingManager::CallCountingManagerHashTraits::GetKey(const element_t &e) -{ - WRAPPER_NO_CONTRACT; - return e; -} - -BOOL CallCountingManager::CallCountingManagerHashTraits::Equals(const key_t &k1, const key_t &k2) -{ - WRAPPER_NO_CONTRACT; - return k1 == k2; -} - -CallCountingManager::CallCountingManagerHashTraits::count_t -CallCountingManager::CallCountingManagerHashTraits::Hash(const key_t &k) -{ - WRAPPER_NO_CONTRACT; - return (count_t)dac_cast(k); -} - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CallCountingManager -CallCountingManager::PTR_CallCountingManagerHash CallCountingManager::s_callCountingManagers = PTR_NULL; +SList CallCountingManager::s_callCountingManagers; COUNT_T CallCountingManager::s_callCountingStubCount = 0; COUNT_T CallCountingManager::s_activeCallCountingStubCount = 0; COUNT_T CallCountingManager::s_completedCallCountingStubCount = 0; @@ -423,7 +400,7 @@ CallCountingManager::CallCountingManager() #ifndef DACCESS_COMPILE CodeVersionManager::LockHolder codeVersioningLockHolder; - s_callCountingManagers->Add(this); + s_callCountingManagers.InsertTail(this); #endif } @@ -448,22 +425,12 @@ CallCountingManager::~CallCountingManager() delete callCountingInfo; } - s_callCountingManagers->Remove(this); + s_callCountingManagers.FindAndRemove(this); #endif } #ifndef DACCESS_COMPILE -void CallCountingManager::StaticInitialize() -{ - WRAPPER_NO_CONTRACT; - s_callCountingManagers = PTR_CallCountingManagerHash(new CallCountingManagerHash()); - CallCountingStub::StaticInitialize(); -} -#endif - -#ifndef DACCESS_COMPILE - // Returns true if the code entry point was updated to reflect the active code version, false otherwise. In normal paths, the // code entry point is not updated only when the use of call counting stubs is disabled, as in that case returning to the // prestub is necessary for further call counting. On exception, the code entry point may or may not have been updated and it's @@ -762,9 +729,8 @@ COUNT_T CallCountingManager::GetCountOfCodeVersionsPendingCompletion() CodeVersionManager::LockHolder codeVersioningLockHolder; - for (auto itEnd = s_callCountingManagers->End(), it = s_callCountingManagers->Begin(); it != itEnd; ++it) + for (CallCountingManager *callCountingManager = s_callCountingManagers.GetHead(); callCountingManager != nullptr; callCountingManager = SList::GetNext(callCountingManager)) { - CallCountingManager *callCountingManager = *it; count += callCountingManager->m_callCountingInfosPendingCompletion.GetCount(); } @@ -790,9 +756,8 @@ void CallCountingManager::CompleteCallCounting() MethodDescBackpatchInfoTracker::ConditionalLockHolder slotBackpatchLockHolder; CodeVersionManager::LockHolder codeVersioningLockHolder; - for (auto itEnd = s_callCountingManagers->End(), it = s_callCountingManagers->Begin(); it != itEnd; ++it) + for (CallCountingManager *callCountingManager = s_callCountingManagers.GetHead(); callCountingManager != nullptr; callCountingManager = SList::GetNext(callCountingManager)) { - CallCountingManager *callCountingManager = *it; SArray &callCountingInfosPendingCompletion = callCountingManager->m_callCountingInfosPendingCompletion; COUNT_T callCountingInfoCount = callCountingInfosPendingCompletion.GetCount(); @@ -951,10 +916,8 @@ void CallCountingManager::StopAllCallCounting(TieredCompilationManager *tieredCo _ASSERTE(CodeVersionManager::IsLockOwnedByCurrentThread()); _ASSERTE(tieredCompilationManager != nullptr); - for (auto itEnd = s_callCountingManagers->End(), it = s_callCountingManagers->Begin(); it != itEnd; ++it) + for (CallCountingManager *callCountingManager = s_callCountingManagers.GetHead(); callCountingManager != nullptr; callCountingManager = SList::GetNext(callCountingManager)) { - CallCountingManager *callCountingManager = *it; - CallCountingInfoByCodeVersionHash &callCountingInfoByCodeVersionHash = callCountingManager->m_callCountingInfoByCodeVersionHash; for (auto itEnd = callCountingInfoByCodeVersionHash.End(), it = callCountingInfoByCodeVersionHash.Begin(); @@ -1039,9 +1002,8 @@ void CallCountingManager::DeleteAllCallCountingStubs() s_callCountingStubCount = 0; s_completedCallCountingStubCount = 0; - for (auto itEnd = s_callCountingManagers->End(), it = s_callCountingManagers->Begin(); it != itEnd; ++it) + for (CallCountingManager *callCountingManager = s_callCountingManagers.GetHead(); callCountingManager != nullptr; callCountingManager = SList::GetNext(callCountingManager)) { - CallCountingManager *callCountingManager = *it; _ASSERTE(callCountingManager->m_callCountingInfosPendingCompletion.IsEmpty()); // Clear the call counting stub from call counting infos and delete completed infos diff --git a/src/coreclr/vm/callcounting.h b/src/coreclr/vm/callcounting.h index 7db35016307ef1..a9600c883cc0ae 100644 --- a/src/coreclr/vm/callcounting.h +++ b/src/coreclr/vm/callcounting.h @@ -296,33 +296,14 @@ class CallCountingManager typedef SHash MethodDescForwarderStubHash; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // CallCountingManager::CallCountingManagerHashTraits - -private: - class CallCountingManagerHashTraits : public DefaultSHashTraits - { - private: - typedef DefaultSHashTraits Base; - public: - typedef Base::element_t element_t; - typedef Base::count_t count_t; - typedef PTR_CallCountingManager key_t; - - public: - static key_t GetKey(const element_t &e); - static BOOL Equals(const key_t &k1, const key_t &k2); - static count_t Hash(const key_t &k); - }; - - typedef SHash CallCountingManagerHash; - typedef DPTR(CallCountingManagerHash) PTR_CallCountingManagerHash; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CallCountingManager members +public: + SLink m_Link; + private: - static PTR_CallCountingManagerHash s_callCountingManagers; + static SList s_callCountingManagers; static COUNT_T s_callCountingStubCount; static COUNT_T s_activeCallCountingStubCount; static COUNT_T s_completedCallCountingStubCount; @@ -337,11 +318,6 @@ class CallCountingManager CallCountingManager(); ~CallCountingManager(); -#ifndef DACCESS_COMPILE -public: - static void StaticInitialize(); -#endif // !DACCESS_COMPILE - #ifndef DACCESS_COMPILE public: static bool SetCodeEntryPoint( diff --git a/src/coreclr/vm/ceemain.cpp b/src/coreclr/vm/ceemain.cpp index 3180399f9ce2cd..bd9c5a2186c30e 100644 --- a/src/coreclr/vm/ceemain.cpp +++ b/src/coreclr/vm/ceemain.cpp @@ -668,7 +668,7 @@ void EEStartupHelper() #ifdef FEATURE_TIERED_COMPILATION TieredCompilationManager::StaticInitialize(); - CallCountingManager::StaticInitialize(); + CallCountingStub::StaticInitialize(); #endif // FEATURE_TIERED_COMPILATION OnStackReplacementManager::StaticInitialize();