diff options
author | Michelle McDaniel <adiaaida@gmail.com> | 2018-09-27 07:28:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 07:28:36 -0700 |
commit | 3d9eed70cfc299906c94e0f2722c7d39f777f27d (patch) | |
tree | 8dc6f2362fcc1774463255947ca942456df0dd77 /src/vm | |
parent | 0bc8c62cfb7514b91b4ebd5f073835391e0502a3 (diff) | |
download | coreclr-3d9eed70cfc299906c94e0f2722c7d39f777f27d.tar.gz coreclr-3d9eed70cfc299906c94e0f2722c7d39f777f27d.tar.bz2 coreclr-3d9eed70cfc299906c94e0f2722c7d39f777f27d.zip |
Replace Crst* with CrstStatic for IBCLogger (#20148)
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/ceeload.cpp | 2 | ||||
-rw-r--r-- | src/vm/ceemain.cpp | 2 | ||||
-rw-r--r-- | src/vm/ibclogger.cpp | 30 | ||||
-rw-r--r-- | src/vm/ibclogger.h | 4 |
4 files changed, 13 insertions, 25 deletions
diff --git a/src/vm/ceeload.cpp b/src/vm/ceeload.cpp index ffdaea86fe..5160b7953b 100644 --- a/src/vm/ceeload.cpp +++ b/src/vm/ceeload.cpp @@ -3516,7 +3516,7 @@ void Module::StartUnload() // Acquire the Crst lock before creating the IBCLoggingDisabler object. // Only one thread at a time can be processing an IBC logging event. - CrstHolder lock(g_IBCLogger.GetSync()); + CrstHolder lock(IBCLogger::GetSync()); { IBCLoggingDisabler disableLogging( pInfo ); // runs IBCLoggingDisabler::DisableLogging diff --git a/src/vm/ceemain.cpp b/src/vm/ceemain.cpp index 885a524340..9874d26f4d 100644 --- a/src/vm/ceemain.cpp +++ b/src/vm/ceemain.cpp @@ -1667,7 +1667,7 @@ void STDMETHODCALLTYPE EEShutDownHelper(BOOL fIsDllUnloading) // Acquire the Crst lock before creating the IBCLoggingDisabler object. // Only one thread at a time can be processing an IBC logging event. - CrstHolder lock(g_IBCLogger.GetSync()); + CrstHolder lock(IBCLogger::GetSync()); { IBCLoggingDisabler disableLogging( pInfo ); // runs IBCLoggingDisabler::DisableLogging diff --git a/src/vm/ibclogger.cpp b/src/vm/ibclogger.cpp index c71921a23f..a780754e05 100644 --- a/src/vm/ibclogger.cpp +++ b/src/vm/ibclogger.cpp @@ -39,6 +39,7 @@ #endif DWORD dwIBCLogCount = 0; +CrstStatic IBCLogger::m_sync; #ifdef _DEBUG /*static*/ unsigned IbcCallback::s_highestId = 0; @@ -117,18 +118,16 @@ IBCLoggerAwareAllocMemTracker::~IBCLoggerAwareAllocMemTracker() IBCLogger::IBCLogger() : dwInstrEnabled(0) - , m_sync(NULL) -{ LIMITED_METHOD_CONTRACT;} +{ + LIMITED_METHOD_CONTRACT; + m_sync.Init(CrstIbcProfile, CrstFlags(CRST_UNSAFE_ANYMODE | CRST_REENTRANCY | CRST_DEBUGGER_THREAD)); +} IBCLogger::~IBCLogger() { WRAPPER_NO_CONTRACT; - if (m_sync) - { - delete m_sync; - m_sync = NULL; - } + m_sync.Destroy(); } void IBCLogger::LogAccessThreadSafeHelperStatic(const void * p, pfnIBCAccessCallback callback) @@ -177,7 +176,7 @@ void IBCLogger::LogAccessThreadSafeHelper(const void * p, pfnIBCAccessCallback c } } -Crst * IBCLogger::GetSync() +CrstStatic* IBCLogger::GetSync() { CONTRACTL { @@ -188,18 +187,7 @@ Crst * IBCLogger::GetSync() } CONTRACTL_END; - if (!m_sync) - { - Crst * pNewSync = new Crst(CrstIbcProfile, CrstFlags(CRST_UNSAFE_ANYMODE | CRST_REENTRANCY | CRST_DEBUGGER_THREAD)); - if (FastInterlockCompareExchangePointer(m_sync.GetPointer(), pNewSync, NULL) != NULL) - { - // We lost the race - delete pNewSync; - } - } - MemoryBarrier(); - - return m_sync; + return &m_sync; } void IBCLogger::DelayedCallbackPtr(pfnIBCAccessCallback callback, const void * pValue1, const void * pValue2 /*=NULL*/) @@ -448,7 +436,7 @@ void ThreadLocalIBCInfo::CallbackHelper(const void * p, pfnIBCAccessCallback cal // Acquire the Crst lock before creating the IBCLoggingDisabler object. // Only one thread at a time can be processing an IBC logging event. - CrstHolder lock(g_IBCLogger.GetSync()); + CrstHolder lock(IBCLogger::GetSync()); { // @ToDo: methods called from here should assert that they have the lock that we just took diff --git a/src/vm/ibclogger.h b/src/vm/ibclogger.h index 9f31151e64..1fc74ce5b0 100644 --- a/src/vm/ibclogger.h +++ b/src/vm/ibclogger.h @@ -599,7 +599,7 @@ public: return (dwInstrEnabled != 0); } - Crst * GetSync(); + static CrstStatic * GetSync(); private: void LogMethodAccessHelper(const MethodDesc* pMD, ULONG flagNum); @@ -614,7 +614,7 @@ private: private: DWORD dwInstrEnabled; - Volatile<Crst*> m_sync; + static CrstStatic m_sync; #endif // DACCESS_COMPILE }; |