Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Fixes for code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
noahfalk committed Mar 29, 2017
1 parent c756426 commit 52ed5e6
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4334,7 +4334,7 @@ void AppDomain::Init()
#endif //FEATURE_COMINTEROP

#ifdef FEATURE_TIERED_COMPILATION
m_callCounter.SetTieredCompilationManager(&GetTieredCompilationManager());
m_callCounter.SetTieredCompilationManager(GetTieredCompilationManager());
m_tieredCompilationManager.Init(GetId());
#endif
#endif // CROSSGEN_COMPILE
Expand Down
8 changes: 4 additions & 4 deletions src/vm/appdomain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3831,20 +3831,20 @@ class AppDomain : public BaseDomain
#if defined(FEATURE_TIERED_COMPILATION)

public:
TieredCompilationManager & GetTieredCompilationManager()
TieredCompilationManager * GetTieredCompilationManager()
{
LIMITED_METHOD_CONTRACT;
return m_tieredCompilationManager;
return &m_tieredCompilationManager;
}

private:
TieredCompilationManager m_tieredCompilationManager;

public:
CallCounter & GetCallCounter()
CallCounter * GetCallCounter()
{
LIMITED_METHOD_CONTRACT;
return m_callCounter;
return &m_callCounter;
}

private:
Expand Down
7 changes: 2 additions & 5 deletions src/vm/callcounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ void CallCounter::SetTieredCompilationManager(TieredCompilationManager* pTieredC
}
CONTRACTL_END;

SpinLockHolder holder(&m_lock);
m_pTieredCompilationManager = pTieredCompilationManager;
m_pTieredCompilationManager.Store(pTieredCompilationManager);
}

// This is called by the prestub each time the method is invoked in a particular
Expand Down Expand Up @@ -80,8 +79,6 @@ BOOL CallCounter::OnMethodCalled(MethodDesc* pMethodDesc)
//each claiming to be exactly the threshhold call count needed to trigger
//optimization.
SpinLockHolder holder(&m_lock);
pCallCounterSink = m_pTieredCompilationManager;

CallCounterEntry* pEntry = const_cast<CallCounterEntry*>(m_methodToCallCount.LookupPtr(pMethodDesc));
if (pEntry == NULL)
{
Expand All @@ -95,7 +92,7 @@ BOOL CallCounter::OnMethodCalled(MethodDesc* pMethodDesc)
}
}

return pCallCounterSink->OnMethodCalled(pMethodDesc, callCount);
return m_pTieredCompilationManager.Load()->OnMethodCalled(pMethodDesc, callCount);
}

#endif // FEATURE_TIERED_COMPILATION
4 changes: 3 additions & 1 deletion src/vm/callcounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ class CallCounter

private:

VolatilePtr<TieredCompilationManager> m_pTieredCompilationManager;

// fields protected by lock
SpinLock m_lock;
TieredCompilationManager* m_pTieredCompilationManager;
CallCounterHash m_methodToCallCount;
};

Expand Down
2 changes: 1 addition & 1 deletion src/vm/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ class MethodDesc
// pointer need to be very careful about if and when they cache it
// if it is not stable.
//
// The stability of the native code pointer is seperate from the
// The stability of the native code pointer is separate from the
// stability of the entrypoint. A stable entrypoint can be a precode
// which dispatches to an unstable native code pointer.
BOOL IsNativeCodeStableAfterInit()
Expand Down
10 changes: 5 additions & 5 deletions src/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7034,12 +7034,12 @@ MethodTableBuilder::NeedsNativeCodeSlot(bmtMDMethod * pMDMethod)

#ifdef FEATURE_TIERED_COMPILATION
// Keep in-sync with MethodDesc::IsEligibleForTieredCompilation()
if (g_pConfig->TieredCompilation() &&
if (g_pConfig->TieredCompilation() &&
!GetModule()->HasNativeOrReadyToRunImage() &&
(pMDMethod->GetMethodType() == METHOD_TYPE_NORMAL || pMDMethod->GetMethodType() == METHOD_TYPE_INSTANTIATED))
{
return TRUE;
}
(pMDMethod->GetMethodType() == METHOD_TYPE_NORMAL || pMDMethod->GetMethodType() == METHOD_TYPE_INSTANTIATED))
{
return TRUE;
}
#endif

return GetModule()->IsEditAndContinueEnabled();
Expand Down
8 changes: 4 additions & 4 deletions src/vm/prestub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1311,8 +1311,8 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT)
PCODE pNativeCode = GetNativeCode();
if (pNativeCode && IsEligibleForTieredCompilation())
{
CallCounter & callCounter = GetAppDomain()->GetCallCounter();
BOOL doBackPatch = callCounter.OnMethodCalled(this);
CallCounter * pCallCounter = GetAppDomain()->GetCallCounter();
BOOL doBackPatch = pCallCounter->OnMethodCalled(this);
if (!doBackPatch)
{
return pNativeCode;
Expand Down Expand Up @@ -1626,8 +1626,8 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT)
#ifdef FEATURE_TIERED_COMPILATION
if (pCode && IsEligibleForTieredCompilation())
{
CallCounter & callCounter = GetAppDomain()->GetCallCounter();
BOOL doBackPatch = callCounter.OnMethodCalled(this);
CallCounter * pCallCounter = GetAppDomain()->GetCallCounter();
BOOL doBackPatch = pCallCounter->OnMethodCalled(this);
if (!doBackPatch)
{
return pCode;
Expand Down
2 changes: 1 addition & 1 deletion src/vm/tieredcompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ BOOL TieredCompilationManager::OnMethodCalled(MethodDesc* pMethodDesc, DWORD cur
// unserviced. Synchronous retries appear unlikely to offer any material improvement
// and complicating the code to narrow an already rare error case isn't desirable.
{
SpinLockHolder holder(&m_lock);
SListElem<MethodDesc*>* pMethodListItem = new (nothrow) SListElem<MethodDesc*>(pMethodDesc);
SpinLockHolder holder(&m_lock);
if (pMethodListItem != NULL)
{
m_methodsToOptimize.InsertTail(pMethodListItem);
Expand Down

0 comments on commit 52ed5e6

Please sign in to comment.