summaryrefslogtreecommitdiff
path: root/src/gc/handletablecache.cpp
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2015-10-14 03:01:25 +0200
committerJan Vorlicek <janvorli@microsoft.com>2015-12-24 10:09:30 +0100
commit54990d90fcffbae79d72cfb2e37bb4cac4e0660c (patch)
tree299c88fa672bbdb2b4ce609df52945cf7d29326d /src/gc/handletablecache.cpp
parent38e554e5dcb8f6de9c014c5e1839b564a64937f6 (diff)
downloadcoreclr-54990d90fcffbae79d72cfb2e37bb4cac4e0660c.tar.gz
coreclr-54990d90fcffbae79d72cfb2e37bb4cac4e0660c.tar.bz2
coreclr-54990d90fcffbae79d72cfb2e37bb4cac4e0660c.zip
GC OS interface refactoring
This change replaces all calls of OS specific functions in the GC by a call to a platform agnostic interface. Critical sections were abstracted too. The logging file access was changed to use CRT functions instead of Windows specific APIs. A "size" member was added to the card_table_info so that we can pass the right size to the VirtualRelease method when destroying the card table. I have also fixed a bug in the gc_heap::make_card_table error path where when VirtualCommit failed, it called VirtualRelease with size that was not the reserved size, but the committed size. Other related changes - All interlocked operations moved to Interlocked class as static methods - Removed unused function prototypes - Shuffled stuff in the root CMakeLists.txt to enable building the GC sample using the settings inherited from the root CMakeLists.txt and to clean up some things that have rotted over time, like the FEATURE_xxx macros not being in one alphabetically ordered block - Fixed the VOLATILE_MEMORY_BARRIER macro in the gcenv.base.h - Replaced uint32_t thread id by EEThreadId - Removed thread handles storage (g_gc_thread) from the GC. The thread handle is closed right after the thread is launched. That allowed me to get rid of the GCThreadHandle - Renamed the methods of the EEThreadId to be easier to understand - Moved the gcenv.windows.cpp and gcenv.unix.cpp to the sample folder
Diffstat (limited to 'src/gc/handletablecache.cpp')
-rw-r--r--src/gc/handletablecache.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/gc/handletablecache.cpp b/src/gc/handletablecache.cpp
index 717348fdb4..33cc08e82f 100644
--- a/src/gc/handletablecache.cpp
+++ b/src/gc/handletablecache.cpp
@@ -86,7 +86,7 @@ void SpinUntil(void *pCond, BOOL fNonZero)
#endif //_DEBUG
// sleep for a little while
- __SwitchToThread(dwThisSleepPeriod, CALLER_LIMITS_SPINNING);
+ GCToOSInterface::Sleep(dwThisSleepPeriod);
// now update our sleep period
dwThisSleepPeriod = dwNextSleepPeriod;
@@ -471,7 +471,7 @@ void TableFullRebalanceCache(HandleTable *pTable,
// update the write index for the free bank
// NOTE: we use an interlocked exchange here to guarantee relative store order on MP
// AFTER THIS POINT THE FREE BANK IS LIVE AND COULD RECEIVE NEW HANDLES
- FastInterlockExchange((LONG*)&pCache->lFreeIndex, lMinFreeIndex);
+ Interlocked::Exchange(&pCache->lFreeIndex, lMinFreeIndex);
// now if we have any handles left, store them in the reserve bank
if (uHandleCount)
@@ -488,7 +488,7 @@ void TableFullRebalanceCache(HandleTable *pTable,
// update the read index for the reserve bank
// NOTE: we use an interlocked exchange here to guarantee relative store order on MP
// AT THIS POINT THE RESERVE BANK IS LIVE AND HANDLES COULD BE ALLOCATED FROM IT
- FastInterlockExchange((LONG*)&pCache->lReserveIndex, lMinReserveIndex);
+ Interlocked::Exchange(&pCache->lReserveIndex, lMinReserveIndex);
}
@@ -599,12 +599,12 @@ void TableQuickRebalanceCache(HandleTable *pTable,
// update the write index for the free bank
// NOTE: we use an interlocked exchange here to guarantee relative store order on MP
// AFTER THIS POINT THE FREE BANK IS LIVE AND COULD RECEIVE NEW HANDLES
- FastInterlockExchange((LONG*)&pCache->lFreeIndex, lMinFreeIndex);
+ Interlocked::Exchange(&pCache->lFreeIndex, lMinFreeIndex);
// update the read index for the reserve bank
// NOTE: we use an interlocked exchange here to guarantee relative store order on MP
// AT THIS POINT THE RESERVE BANK IS LIVE AND HANDLES COULD BE ALLOCATED FROM IT
- FastInterlockExchange((LONG*)&pCache->lReserveIndex, lMinReserveIndex);
+ Interlocked::Exchange(&pCache->lReserveIndex, lMinReserveIndex);
}
@@ -630,13 +630,13 @@ OBJECTHANDLE TableCacheMissOnAlloc(HandleTable *pTable, HandleTypeCache *pCache,
CrstHolder ch(&pTable->Lock);
// try again to take a handle (somebody else may have rebalanced)
- int32_t lReserveIndex = FastInterlockDecrement((LONG*)&pCache->lReserveIndex);
+ int32_t lReserveIndex = Interlocked::Decrement(&pCache->lReserveIndex);
// are we still waiting for handles?
if (lReserveIndex < 0)
{
// yup, suspend free list usage...
- int32_t lFreeIndex = FastInterlockExchange((LONG*)&pCache->lFreeIndex, 0L);
+ int32_t lFreeIndex = Interlocked::Exchange(&pCache->lFreeIndex, 0);
// ...and rebalance the cache...
TableQuickRebalanceCache(pTable, pCache, uType, lReserveIndex, lFreeIndex, &handle, NULL);
@@ -680,13 +680,13 @@ void TableCacheMissOnFree(HandleTable *pTable, HandleTypeCache *pCache, uint32_t
CrstHolder ch(&pTable->Lock);
// try again to take a slot (somebody else may have rebalanced)
- int32_t lFreeIndex = FastInterlockDecrement((LONG*)&pCache->lFreeIndex);
+ int32_t lFreeIndex = Interlocked::Decrement(&pCache->lFreeIndex);
// are we still waiting for free slots?
if (lFreeIndex < 0)
{
// yup, suspend reserve list usage...
- int32_t lReserveIndex = FastInterlockExchange((LONG*)&pCache->lReserveIndex, 0L);
+ int32_t lReserveIndex = Interlocked::Exchange(&pCache->lReserveIndex, 0);
// ...and rebalance the cache...
TableQuickRebalanceCache(pTable, pCache, uType, lReserveIndex, lFreeIndex, NULL, handle);
@@ -718,7 +718,7 @@ OBJECTHANDLE TableAllocSingleHandleFromCache(HandleTable *pTable, uint32_t uType
if (pTable->rgQuickCache[uType])
{
// try to grab the handle we saw
- handle = FastInterlockExchangePointer(pTable->rgQuickCache + uType, (OBJECTHANDLE)NULL);
+ handle = Interlocked::ExchangePointer(pTable->rgQuickCache + uType, (OBJECTHANDLE)NULL);
// if it worked then we're done
if (handle)
@@ -729,7 +729,7 @@ OBJECTHANDLE TableAllocSingleHandleFromCache(HandleTable *pTable, uint32_t uType
HandleTypeCache *pCache = pTable->rgMainCache + uType;
// try to take a handle from the main cache
- int32_t lReserveIndex = FastInterlockDecrement((LONG*)&pCache->lReserveIndex);
+ int32_t lReserveIndex = Interlocked::Decrement(&pCache->lReserveIndex);
// did we underflow?
if (lReserveIndex < 0)
@@ -787,7 +787,7 @@ void TableFreeSingleHandleToCache(HandleTable *pTable, uint32_t uType, OBJECTHAN
if (!pTable->rgQuickCache[uType])
{
// yup - try to stuff our handle in the slot we saw
- handle = FastInterlockExchangePointer(&pTable->rgQuickCache[uType], handle);
+ handle = Interlocked::ExchangePointer(&pTable->rgQuickCache[uType], handle);
// if we didn't end up with another handle then we're done
if (!handle)
@@ -798,7 +798,7 @@ void TableFreeSingleHandleToCache(HandleTable *pTable, uint32_t uType, OBJECTHAN
HandleTypeCache *pCache = pTable->rgMainCache + uType;
// try to take a free slot from the main cache
- int32_t lFreeIndex = FastInterlockDecrement((LONG*)&pCache->lFreeIndex);
+ int32_t lFreeIndex = Interlocked::Decrement(&pCache->lFreeIndex);
// did we underflow?
if (lFreeIndex < 0)