diff options
author | Jan Kotas <jkotas@microsoft.com> | 2016-01-25 18:55:32 -0800 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2016-01-26 00:10:05 -0800 |
commit | 0462be1dde807ddad9238bf90824265d48d831c7 (patch) | |
tree | 7a4a02dffcddd3faa7287441048b06b5c842c64d | |
parent | 82e5fba902043783a9446048317d821860423f8e (diff) | |
download | coreclr-0462be1dde807ddad9238bf90824265d48d831c7.tar.gz coreclr-0462be1dde807ddad9238bf90824265d48d831c7.tar.bz2 coreclr-0462be1dde807ddad9238bf90824265d48d831c7.zip |
Update GC from CoreRT
https://github.com/dotnet/corert/tree/master/src/Native/gc 0dcc350dae128b6fcca6b1ed74b580ed3240460a
-rw-r--r-- | src/gc/env/common.h | 1 | ||||
-rw-r--r-- | src/gc/env/gcenv.base.h | 59 | ||||
-rw-r--r-- | src/gc/env/gcenv.interlocked.inl | 4 | ||||
-rw-r--r-- | src/gc/env/gcenv.os.h | 12 | ||||
-rw-r--r-- | src/gc/env/gcenv.structs.h | 16 | ||||
-rw-r--r-- | src/gc/gc.cpp | 22 | ||||
-rwxr-xr-x | src/gc/gcee.cpp | 2 | ||||
-rw-r--r-- | src/gc/gcpriv.h | 2 | ||||
-rw-r--r-- | src/gc/handletable.cpp | 2 | ||||
-rw-r--r-- | src/gc/sample/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/gc/sample/gcenv.ee.cpp | 4 | ||||
-rw-r--r-- | src/gc/sample/gcenv.h | 3 | ||||
-rw-r--r-- | src/gc/sample/gcenv.unix.cpp | 6 | ||||
-rw-r--r-- | src/gc/sample/gcenv.windows.cpp | 15 | ||||
-rw-r--r-- | src/inc/winwrap.h | 2 | ||||
-rw-r--r-- | src/vm/gcenv.h | 6 | ||||
-rw-r--r-- | src/vm/gcenv.os.cpp | 13 |
17 files changed, 68 insertions, 102 deletions
diff --git a/src/gc/env/common.h b/src/gc/env/common.h index 39e97b3e7a..35df7e0141 100644 --- a/src/gc/env/common.h +++ b/src/gc/env/common.h @@ -15,6 +15,7 @@ #include <stdint.h> #include <stddef.h> #include <stdio.h> +#include <string.h> #include <wchar.h> #include <assert.h> #include <stdarg.h> diff --git a/src/gc/env/gcenv.base.h b/src/gc/env/gcenv.base.h index fdfa0fc5eb..83376f5d11 100644 --- a/src/gc/env/gcenv.base.h +++ b/src/gc/env/gcenv.base.h @@ -37,18 +37,6 @@ typedef uint32_t BOOL; typedef uint32_t DWORD; typedef void* LPVOID; -typedef uint32_t UINT; -typedef int32_t LONG; -typedef uintptr_t ULONG_PTR; -typedef void VOID; -typedef void* PVOID; -typedef void * LPSECURITY_ATTRIBUTES; -typedef void const * LPCVOID; -typedef wchar_t * PWSTR, *LPWSTR; -typedef const wchar_t *LPCWSTR, *PCWSTR; -typedef size_t SIZE_T; - -typedef void * HANDLE; // ----------------------------------------------------------------------------------------------------------- // HRESULT subset. @@ -105,14 +93,24 @@ inline HRESULT HRESULT_FROM_WIN32(unsigned long x) #define UNREFERENCED_PARAMETER(P) (void)(P) -#define INVALID_HANDLE_VALUE ((HANDLE)-1) - #ifdef PLATFORM_UNIX #define _vsnprintf vsnprintf #define sprintf_s snprintf #define swprintf_s swprintf #endif +#ifdef UNICODE +#define _tcslen wcslen +#define _tcscpy wcscpy +#define _stprintf_s swprintf_s +#define _tfopen _wfopen +#else +#define _tcslen strlen +#define _tcscpy strcpy +#define _stprintf_s sprintf_s +#define _tfopen fopen +#endif + #define WINAPI __stdcall typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(void* lpThreadParameter); @@ -123,12 +121,12 @@ typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(void* lpThreadParameter); #if defined(_MSC_VER) #if defined(_ARM_) - + __forceinline void YieldProcessor() { } extern "C" void __emit(const unsigned __int32 opcode); #pragma intrinsic(__emit) #define MemoryBarrier() { __emit(0xF3BF); __emit(0x8F5F); } - + #elif defined(_ARM64_) extern "C" void __yield(void); @@ -141,26 +139,26 @@ typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(void* lpThreadParameter); #elif defined(_AMD64_) - extern "C" VOID + extern "C" void _mm_pause ( - VOID + void ); - extern "C" VOID + extern "C" void _mm_mfence ( - VOID + void ); - + #pragma intrinsic(_mm_pause) #pragma intrinsic(_mm_mfence) #define YieldProcessor _mm_pause #define MemoryBarrier _mm_mfence - + #elif defined(_X86_) #define YieldProcessor() __asm { rep nop } - + __forceinline void MemoryBarrier() { int32_t Barrier; @@ -168,7 +166,7 @@ typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(void* lpThreadParameter); xchg Barrier, eax } } - + #else // !_ARM_ && !_AMD64_ && !_X86_ #error Unsupported architecture #endif @@ -465,15 +463,6 @@ public: #ifdef FEATURE_REDHAWK typedef uint32_t (__stdcall *BackgroundCallback)(void* pCallbackContext); REDHAWK_PALIMPORT bool REDHAWK_PALAPI PalStartBackgroundGCThread(BackgroundCallback callback, void* pCallbackContext); - -enum PalCapability -{ - WriteWatchCapability = 0x00000001, // GetWriteWatch() and friends - LowMemoryNotificationCapability = 0x00000002, // CreateMemoryResourceNotification() and friends - GetCurrentProcessorNumberCapability = 0x00000004, // GetCurrentProcessorNumber() -}; - -REDHAWK_PALIMPORT bool REDHAWK_PALAPI PalHasCapability(PalCapability capability); #endif // FEATURE_REDHAWK void DestroyThread(Thread * pThread); @@ -530,7 +519,7 @@ namespace ETW #define LOG(x) -VOID LogSpewAlways(const char *fmt, ...); +void LogSpewAlways(const char *fmt, ...); #define LL_INFO10 4 @@ -581,7 +570,7 @@ public: typedef CLRConfigTypes ConfigStringInfo; static uint32_t GetConfigValue(ConfigDWORDInfo eType); - static HRESULT GetConfigValue(ConfigStringInfo /*eType*/, wchar_t * * outVal); + static HRESULT GetConfigValue(ConfigStringInfo /*eType*/, TCHAR * * outVal); }; inline bool FitsInU1(uint64_t val) diff --git a/src/gc/env/gcenv.interlocked.inl b/src/gc/env/gcenv.interlocked.inl index 62e171cadf..ea4ff88de4 100644 --- a/src/gc/env/gcenv.interlocked.inl +++ b/src/gc/env/gcenv.interlocked.inl @@ -188,12 +188,12 @@ __forceinline T Interlocked::CompareExchangePointer(T volatile *destination, T e { #ifdef _MSC_VER #ifdef BIT64 - return (T)(TADDR)_InterlockedCompareExchangePointer((void* volatile *)destination, exchange, comparand); + return (T)(TADDR)_InterlockedCompareExchangePointer((void* volatile *)destination, (void*)exchange, (void*)comparand); #else return (T)(TADDR)_InterlockedCompareExchange((long volatile *)(void* volatile *)destination, (long)(void*)exchange, (long)(void*)comparand); #endif #else - return (T)(TADDR)__sync_val_compare_and_swap((void* volatile *)destination, comparand, exchange); + return (T)(TADDR)__sync_val_compare_and_swap((void* volatile *)destination, (void*)comparand, (void*)exchange); #endif } diff --git a/src/gc/env/gcenv.os.h b/src/gc/env/gcenv.os.h index c1ae87a042..9ffd97b89a 100644 --- a/src/gc/env/gcenv.os.h +++ b/src/gc/env/gcenv.os.h @@ -257,18 +257,6 @@ public: // Return: // Time stamp in milliseconds static uint32_t GetLowPrecisionTimeStamp(); - - // - // File - // - - // Open a file - // Parameters: - // filename - name of the file to open - // mode - mode to open the file in (like in the CRT fopen) - // Return: - // FILE* of the opened file - static FILE* OpenFile(const WCHAR* filename, const WCHAR* mode); }; #endif // __GCENV_OS_H__ diff --git a/src/gc/env/gcenv.structs.h b/src/gc/env/gcenv.structs.h index 7c576a5928..8593e5efa1 100644 --- a/src/gc/env/gcenv.structs.h +++ b/src/gc/env/gcenv.structs.h @@ -33,6 +33,20 @@ typedef void * HANDLE; #ifdef PLATFORM_UNIX +typedef char TCHAR; +#define _T(s) s + +#else + +#ifndef _INC_WINDOWS +typedef wchar_t TCHAR; +#define _T(s) L##s +#endif + +#endif + +#ifdef PLATFORM_UNIX + class EEThreadId { pthread_t m_id; @@ -76,7 +90,7 @@ public: void SetToCurrentThread() { - m_uiId = ::GetCurrentThreadId(); + m_uiId = ::GetCurrentThreadId(); } void Clear() diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp index b329f894ed..0add1a9b8f 100644 --- a/src/gc/gc.cpp +++ b/src/gc/gc.cpp @@ -168,7 +168,7 @@ size_t GetHighPrecisionTimeStamp() GCStatistics g_GCStatistics; GCStatistics g_LastGCStatistics; -WCHAR* GCStatistics::logFileName = NULL; +TCHAR* GCStatistics::logFileName = NULL; FILE* GCStatistics::logFile = NULL; void GCStatistics::AddGCStats(const gc_mechanisms& settings, size_t timeInMSec) @@ -9507,21 +9507,22 @@ void gc_heap::adjust_ephemeral_limits () FILE* CreateLogFile(const CLRConfig::ConfigStringInfo & info, BOOL is_config) { FILE* logFile; - LPWSTR temp_logfile_name = NULL; + TCHAR * temp_logfile_name = NULL; CLRConfig::GetConfigValue(info, &temp_logfile_name); - WCHAR logfile_name[MAX_LONGPATH+1]; + TCHAR logfile_name[MAX_LONGPATH+1]; if (temp_logfile_name != 0) { - wcscpy(logfile_name, temp_logfile_name); + _tcscpy(logfile_name, temp_logfile_name); } - size_t logfile_name_len = wcslen(logfile_name); - WCHAR* szPid = logfile_name + logfile_name_len; + size_t logfile_name_len = _tcslen(logfile_name); + TCHAR* szPid = logfile_name + logfile_name_len; size_t remaining_space = MAX_LONGPATH + 1 - logfile_name_len; - swprintf_s(szPid, remaining_space, W(".%d%s"), GCToOSInterface::GetCurrentProcessId(), (is_config ? W(".config.log") : W(".log"))); - logFile = GCToOSInterface::OpenFile(logfile_name, W("wb")); + _stprintf_s(szPid, remaining_space, _T(".%d%s"), GCToOSInterface::GetCurrentProcessId(), (is_config ? _T(".config.log") : _T(".log"))); + + logFile = _tfopen(logfile_name, _T("wb")); delete temp_logfile_name; @@ -9614,9 +9615,8 @@ HRESULT gc_heap::initialize_gc (size_t segment_size, GCStatistics::logFileName = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_GCMixLog); if (GCStatistics::logFileName != NULL) { - GCStatistics::logFile = GCToOSInterface::OpenFile((LPCWSTR)GCStatistics::logFileName, W("a")); + GCStatistics::logFile = _tfopen(GCStatistics::logFileName, _T("a")); } - #endif // GC_STATS HRESULT hres = S_OK; @@ -14567,7 +14567,7 @@ int gc_heap::generation_to_condemn (int n_initial, // Need to get it early enough for all heaps to use. available_physical_mem = ms.ullAvailPhys; local_settings->entry_memory_load = ms.dwMemoryLoad; - + // @TODO: Force compaction more often under GCSTRESS if (ms.dwMemoryLoad >= high_memory_load_th || low_memory_detected) { diff --git a/src/gc/gcee.cpp b/src/gc/gcee.cpp index 498c3be7fd..8da9690a91 100755 --- a/src/gc/gcee.cpp +++ b/src/gc/gcee.cpp @@ -421,7 +421,7 @@ BOOL ProfilerShouldTrackConditionalWeakTableElements() { #if defined(GC_PROFILING) return CORProfilerTrackConditionalWeakTableElements(); #else - return FALSE; + return FALSE; #endif // defined (GC_PROFILING) } diff --git a/src/gc/gcpriv.h b/src/gc/gcpriv.h index fe40c0ccd7..9aa864ad60 100644 --- a/src/gc/gcpriv.h +++ b/src/gc/gcpriv.h @@ -611,7 +611,7 @@ struct GCStatistics : public StatisticsBase { // initialized to the contents of COMPLUS_GcMixLog, or NULL, if not present - static WCHAR* logFileName; + static TCHAR* logFileName; static FILE* logFile; // number of times we executed a background GC, a foreground GC, or a diff --git a/src/gc/handletable.cpp b/src/gc/handletable.cpp index 7ded783211..597aeb9dcc 100644 --- a/src/gc/handletable.cpp +++ b/src/gc/handletable.cpp @@ -391,7 +391,7 @@ void ValidateFetchObjrefForHandle(OBJECTREF objref, ADIndex appDomainIndex) _ASSERTE(!pDomain->NoAccessToHandleTable()); #if CHECK_APP_DOMAIN_LEAKS - if (g_pConfig->AppDomainLeaks() && objref != NULL) + if (g_pConfig->AppDomainLeaks() && objref != NULL) { if (appDomainIndex.m_dwIndex) objref->TryAssignAppDomain(pDomain); diff --git a/src/gc/sample/CMakeLists.txt b/src/gc/sample/CMakeLists.txt index a46f9aeb8b..45cdbb2b9d 100644 --- a/src/gc/sample/CMakeLists.txt +++ b/src/gc/sample/CMakeLists.txt @@ -22,6 +22,7 @@ set(SOURCES if(WIN32) list(APPEND SOURCES gcenv.windows.cpp) + add_definitions(-DUNICODE=1) else() list(APPEND SOURCES gcenv.unix.cpp) diff --git a/src/gc/sample/gcenv.ee.cpp b/src/gc/sample/gcenv.ee.cpp index e17bb834fa..cc809e7f86 100644 --- a/src/gc/sample/gcenv.ee.cpp +++ b/src/gc/sample/gcenv.ee.cpp @@ -250,7 +250,7 @@ void StompWriteBarrierResize(bool /*bReqUpperBoundsCheck*/) { } -VOID LogSpewAlways(const char * /*fmt*/, ...) +void LogSpewAlways(const char * /*fmt*/, ...) { } @@ -282,7 +282,7 @@ uint32_t CLRConfig::GetConfigValue(ConfigDWORDInfo eType) } } -HRESULT CLRConfig::GetConfigValue(ConfigStringInfo /*eType*/, wchar_t * * outVal) +HRESULT CLRConfig::GetConfigValue(ConfigStringInfo /*eType*/, TCHAR * * outVal) { *outVal = NULL; return 0; diff --git a/src/gc/sample/gcenv.h b/src/gc/sample/gcenv.h index c09d012ec4..9920f69e17 100644 --- a/src/gc/sample/gcenv.h +++ b/src/gc/sample/gcenv.h @@ -16,9 +16,6 @@ #define _ASSERTE(_expr) ASSERT(_expr) #endif -typedef wchar_t WCHAR; -#define W(s) L##s - #include "gcenv.structs.h" #include "gcenv.base.h" #include "gcenv.ee.h" diff --git a/src/gc/sample/gcenv.unix.cpp b/src/gc/sample/gcenv.unix.cpp index f3c502c78c..51ae723548 100644 --- a/src/gc/sample/gcenv.unix.cpp +++ b/src/gc/sample/gcenv.unix.cpp @@ -307,12 +307,6 @@ bool IsGCSpecialThread() #endif // 0 -bool PalHasCapability(PalCapability capability) -{ - // TODO: Implement for background GC - return false; -} - WINBASEAPI UINT WINAPI diff --git a/src/gc/sample/gcenv.windows.cpp b/src/gc/sample/gcenv.windows.cpp index bce8496fda..70157707ee 100644 --- a/src/gc/sample/gcenv.windows.cpp +++ b/src/gc/sample/gcenv.windows.cpp @@ -85,7 +85,7 @@ bool GCToOSInterface::SetCurrentThreadIdealAffinity(GCThreadAffinity* affinity) proc.Group = (WORD)affinity->Group; proc.Number = (BYTE)affinity->Processor; proc.Reserved = 0; - + success = !!SetThreadIdealProcessorEx(GetCurrentThread(), &proc, NULL); } else @@ -94,7 +94,7 @@ bool GCToOSInterface::SetCurrentThreadIdealAffinity(GCThreadAffinity* affinity) { proc.Number = affinity->Processor; success = !!SetThreadIdealProcessorEx(GetCurrentThread(), &proc, NULL); - } + } } #endif @@ -414,17 +414,6 @@ bool GCToOSInterface::CreateThread(GCThreadFunction function, void* param, GCThr return true; } -// Open a file -// Parameters: -// filename - name of the file to open -// mode - mode to open the file in (like in the CRT fopen) -// Return: -// FILE* of the opened file -FILE* GCToOSInterface::OpenFile(const WCHAR* filename, const WCHAR* mode) -{ - return _wfopen(filename, mode); -} - // Initialize the critical section void CLRCriticalSection::Initialize() { diff --git a/src/inc/winwrap.h b/src/inc/winwrap.h index c0c43eb74c..00940eb87e 100644 --- a/src/inc/winwrap.h +++ b/src/inc/winwrap.h @@ -721,7 +721,7 @@ #endif // FEATURE_CORESYSTEM #ifndef _T -#define _T(str) L ## str +#define _T(str) W(str) #endif diff --git a/src/vm/gcenv.h b/src/vm/gcenv.h index 7ddbe5e46a..c9d07043af 100644 --- a/src/vm/gcenv.h +++ b/src/vm/gcenv.h @@ -66,4 +66,10 @@ namespace ETW } GC_ROOT_KIND; }; +#ifdef PLATFORM_UNIX +#define _tcslen wcslen +#define _tcscpy wcscpy +#define _tfopen _wfopen +#endif + #endif // GCENV_H_ diff --git a/src/vm/gcenv.os.cpp b/src/vm/gcenv.os.cpp index 20fb179fe8..e54c3714ef 100644 --- a/src/vm/gcenv.os.cpp +++ b/src/vm/gcenv.os.cpp @@ -484,19 +484,6 @@ bool GCToOSInterface::CreateThread(GCThreadFunction function, void* param, GCThr return true; } -// Open a file -// Parameters: -// filename - name of the file to open -// mode - mode to open the file in (like in the CRT fopen) -// Return: -// FILE* of the opened file -FILE* GCToOSInterface::OpenFile(const WCHAR* filename, const WCHAR* mode) -{ - LIMITED_METHOD_CONTRACT; - - return _wfopen(filename, mode); -} - // Initialize the critical section void CLRCriticalSection::Initialize() { |