Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 7 additions & 45 deletions src/coreclr/vm/callcounting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TADDR>(k);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CallCountingManager

CallCountingManager::PTR_CallCountingManagerHash CallCountingManager::s_callCountingManagers = PTR_NULL;
SList<CallCountingManager> CallCountingManager::s_callCountingManagers;
COUNT_T CallCountingManager::s_callCountingStubCount = 0;
COUNT_T CallCountingManager::s_activeCallCountingStubCount = 0;
COUNT_T CallCountingManager::s_completedCallCountingStubCount = 0;
Expand All @@ -423,7 +400,7 @@ CallCountingManager::CallCountingManager()

#ifndef DACCESS_COMPILE
CodeVersionManager::LockHolder codeVersioningLockHolder;
s_callCountingManagers->Add(this);
s_callCountingManagers.InsertTail(this);
#endif
}

Expand All @@ -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
Expand Down Expand Up @@ -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<CallCountingManager>::GetNext(callCountingManager))
{
CallCountingManager *callCountingManager = *it;
count += callCountingManager->m_callCountingInfosPendingCompletion.GetCount();
}

Expand All @@ -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<CallCountingManager>::GetNext(callCountingManager))
{
CallCountingManager *callCountingManager = *it;
SArray<CallCountingInfo *> &callCountingInfosPendingCompletion =
callCountingManager->m_callCountingInfosPendingCompletion;
COUNT_T callCountingInfoCount = callCountingInfosPendingCompletion.GetCount();
Expand Down Expand Up @@ -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<CallCountingManager>::GetNext(callCountingManager))
{
CallCountingManager *callCountingManager = *it;

CallCountingInfoByCodeVersionHash &callCountingInfoByCodeVersionHash =
callCountingManager->m_callCountingInfoByCodeVersionHash;
for (auto itEnd = callCountingInfoByCodeVersionHash.End(), it = callCountingInfoByCodeVersionHash.Begin();
Expand Down Expand Up @@ -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<CallCountingManager>::GetNext(callCountingManager))
{
CallCountingManager *callCountingManager = *it;
_ASSERTE(callCountingManager->m_callCountingInfosPendingCompletion.IsEmpty());

// Clear the call counting stub from call counting infos and delete completed infos
Expand Down
32 changes: 4 additions & 28 deletions src/coreclr/vm/callcounting.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,33 +296,14 @@ class CallCountingManager

typedef SHash<MethodDescForwarderStubHashTraits> MethodDescForwarderStubHash;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CallCountingManager::CallCountingManagerHashTraits

private:
class CallCountingManagerHashTraits : public DefaultSHashTraits<PTR_CallCountingManager>
{
private:
typedef DefaultSHashTraits<PTR_CallCountingManager> 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<CallCountingManagerHashTraits> CallCountingManagerHash;
typedef DPTR(CallCountingManagerHash) PTR_CallCountingManagerHash;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CallCountingManager members

public:
SLink m_Link;

private:
static PTR_CallCountingManagerHash s_callCountingManagers;
static SList<CallCountingManager> s_callCountingManagers;
static COUNT_T s_callCountingStubCount;
static COUNT_T s_activeCallCountingStubCount;
static COUNT_T s_completedCallCountingStubCount;
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/ceemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ void EEStartupHelper()

#ifdef FEATURE_TIERED_COMPILATION
TieredCompilationManager::StaticInitialize();
CallCountingManager::StaticInitialize();
CallCountingStub::StaticInitialize();
#endif // FEATURE_TIERED_COMPILATION

OnStackReplacementManager::StaticInitialize();
Expand Down
Loading