From 81241330225ae8837c3e7a1cf268ba3bf96a95e3 Mon Sep 17 00:00:00 2001 From: pi1024e <49824824+pi1024e@users.noreply.github.com> Date: Mon, 4 Nov 2019 12:01:03 -0500 Subject: [PATCH] Change m_fPreemptiveGCDisabled to bool (dotnet/coreclr#27648) Commit migrated from https://github.com/dotnet/coreclr/commit/96e08af2e7f246ad2efe9ebe68c4d4ca51f1b638 --- src/coreclr/src/gc/sample/gcenv.ee.cpp | 13 ++++--------- src/coreclr/src/gc/sample/gcenv.h | 4 ++-- src/coreclr/src/gc/unix/events.cpp | 2 +- src/coreclr/src/md/enc/metamodelrw.cpp | 31 +++++++++++++------------------ src/coreclr/src/vm/gcenv.ee.cpp | 20 ++++++-------------- 5 files changed, 26 insertions(+), 44 deletions(-) diff --git a/src/coreclr/src/gc/sample/gcenv.ee.cpp b/src/coreclr/src/gc/sample/gcenv.ee.cpp index 12b9a8b..402fcad 100644 --- a/src/coreclr/src/gc/sample/gcenv.ee.cpp +++ b/src/coreclr/src/gc/sample/gcenv.ee.cpp @@ -177,19 +177,14 @@ bool GCToEEInterface::IsPreemptiveGCDisabled() bool GCToEEInterface::EnablePreemptiveGC() { - bool bToggleGC = false; Thread* pThread = ::GetThread(); - - if (pThread) + if (pThread && pThread->PreemptiveGCDisabled()) { - bToggleGC = !!pThread->PreemptiveGCDisabled(); - if (bToggleGC) - { - pThread->EnablePreemptiveGC(); - } + pThread->EnablePreemptiveGC(); + return true; } - return bToggleGC; + return false; } void GCToEEInterface::DisablePreemptiveGC() diff --git a/src/coreclr/src/gc/sample/gcenv.h b/src/coreclr/src/gc/sample/gcenv.h index 0da2e44..b14625b 100644 --- a/src/coreclr/src/gc/sample/gcenv.h +++ b/src/coreclr/src/gc/sample/gcenv.h @@ -92,7 +92,7 @@ struct alloc_context; class Thread { - uint32_t m_fPreemptiveGCDisabled; + bool m_fPreemptiveGCDisabled; uintptr_t m_alloc_context[16]; // Reserve enough space to fix allocation context friend class ThreadStore; @@ -105,7 +105,7 @@ public: bool PreemptiveGCDisabled() { - return !!m_fPreemptiveGCDisabled; + return m_fPreemptiveGCDisabled; } void EnablePreemptiveGC() diff --git a/src/coreclr/src/gc/unix/events.cpp b/src/coreclr/src/gc/unix/events.cpp index 96dba60..820475c 100644 --- a/src/coreclr/src/gc/unix/events.cpp +++ b/src/coreclr/src/gc/unix/events.cpp @@ -146,7 +146,7 @@ public: TimeSpecAdd(&endTime, milliseconds); } #else -#error "Don't know how to perfom timed wait on this platform" +#error "Don't know how to perform timed wait on this platform" #endif int st = 0; diff --git a/src/coreclr/src/md/enc/metamodelrw.cpp b/src/coreclr/src/md/enc/metamodelrw.cpp index 96f313b..cd9e26a 100644 --- a/src/coreclr/src/md/enc/metamodelrw.cpp +++ b/src/coreclr/src/md/enc/metamodelrw.cpp @@ -1422,7 +1422,7 @@ CMiniMdRW::InitOnMem( int iCol; // Look at all the tables, or until mixed sizes are discovered. - for (i=0; i<(int)m_TblCount && fMixed == false; i++) + for (i=0; i<(int)m_TblCount && !fMixed; i++) { // Look at all the columns of the table. pCols = m_TableDefs[i].m_pColDefs; for (iCol = 0; iCol < m_TableDefs[i].m_cCols && !fMixed; iCol++) @@ -1430,15 +1430,13 @@ CMiniMdRW::InitOnMem( if (!IsFixedType(m_TableDefs[i].m_pColDefs[iCol].m_Type)) { // If this is the first non-fixed size column... if (iSize == 0) - { // remember it's size. + { // remember its size. iSize = m_TableDefs[i].m_pColDefs[iCol].m_cbColumn; } - else - { // Not first non-fixed size, so if a different size... - if (iSize != m_TableDefs[i].m_pColDefs[iCol].m_cbColumn) - { // ...the table has mixed column sizes. - fMixed = true; - } + else if (iSize != m_TableDefs[i].m_pColDefs[iCol].m_cbColumn) + { // Not first non-fixed size, so if a different size + // the table has mixed column sizes. + fMixed = true; } } } @@ -1449,18 +1447,15 @@ CMiniMdRW::InitOnMem( IfFailGo(ExpandTables()); ComputeGrowLimits(FALSE /* ! small*/); } + else if (iSize == 2) + { + // small schema + ComputeGrowLimits(TRUE /* small */); + } else { - if (iSize == 2) - { - // small schema - ComputeGrowLimits(TRUE /* small */); - } - else - { - // large schema - ComputeGrowLimits(FALSE /* ! small */); - } + // large schema + ComputeGrowLimits(FALSE /* ! small */); } } else diff --git a/src/coreclr/src/vm/gcenv.ee.cpp b/src/coreclr/src/vm/gcenv.ee.cpp index aeaf6fb..34a1ec69 100644 --- a/src/coreclr/src/vm/gcenv.ee.cpp +++ b/src/coreclr/src/vm/gcenv.ee.cpp @@ -369,31 +369,23 @@ bool GCToEEInterface::IsPreemptiveGCDisabled() WRAPPER_NO_CONTRACT; Thread* pThread = ::GetThread(); - if (pThread) - { - return !!pThread->PreemptiveGCDisabled(); - } - - return false; + + return (pThread && pThread->PreemptiveGCDisabled()); } bool GCToEEInterface::EnablePreemptiveGC() { WRAPPER_NO_CONTRACT; - bool bToggleGC = false; Thread* pThread = ::GetThread(); - if (pThread) + if (pThread && pThread->PreemptiveGCDisabled()) { - bToggleGC = !!pThread->PreemptiveGCDisabled(); - if (bToggleGC) - { - pThread->EnablePreemptiveGC(); - } + pThread->EnablePreemptiveGC(); + return true; } - return bToggleGC; + return false; } void GCToEEInterface::DisablePreemptiveGC() -- 2.7.4