#-----------------------------------
if (CLR_CMAKE_PLATFORM_ARCH_AMD64)
add_definitions(-D_AMD64_)
+ add_definitions(-DHOST_AMD64) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42
add_definitions(-D_WIN64)
add_definitions(-DAMD64)
add_definitions(-DBIT64=1)
+ add_definitions(-DHOST_64BIT=1) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42
elseif (CLR_CMAKE_PLATFORM_ARCH_I386)
add_definitions(-D_X86_)
+ add_definitions(-DHOST_X86) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42
elseif (CLR_CMAKE_PLATFORM_ARCH_ARM)
add_definitions(-D_ARM_)
add_definitions(-DARM)
+ add_definitions(-DHOST_ARM) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42
elseif (CLR_CMAKE_PLATFORM_ARCH_ARM64)
add_definitions(-D_ARM64_)
add_definitions(-DARM64)
+ add_definitions(-DHOST_ARM64) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42
add_definitions(-D_WIN64)
add_definitions(-DBIT64=1)
+ add_definitions(-DHOST_64BIT=1) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42
else ()
clr_unknown_arch()
endif ()
// NOTE: currently only one instance of the CommonTrace can exist at each
// moment, so global variable can be used.
static CommonTrace *g_pCommonTraceObject = nullptr;
+static thread_local ThreadInfo *tlsThreadInfo = nullptr;
static void SampleHandlerStub(
int code, siginfo_t *siginfo, void *context)
CommonTrace::CommonTrace(Profiler &profiler)
: BaseTrace(profiler)
- , m_tlsThreadInfoIndex(TLS_OUT_OF_INDEXES)
, m_threadStorage()
, m_classStorage()
, m_pauseAction()
// NOTE: we are dealing with a partially destroyed m_profiler!
this->Shutdown();
- if (m_tlsThreadInfoIndex != TLS_OUT_OF_INDEXES)
- {
- if (!TlsFree(m_tlsThreadInfoIndex))
- {
- m_profiler.HandleHresult(
- "CommonTrace::~CommonTrace(): TlsFree()",
- HRESULT_FROM_WIN32(GetLastError())
- );
- }
- }
-
_ASSERTE(g_pCommonTraceObject == this);
g_pCommonTraceObject = nullptr;
}
}
#endif
- //
- // Initializing thread local storage.
- //
-
- m_tlsThreadInfoIndex = TlsAlloc();
- if (m_tlsThreadInfoIndex == TLS_OUT_OF_INDEXES)
- {
- throw HresultException(
- "CommonTrace::ProcessConfig(): TlsAlloc()",
- HRESULT_FROM_WIN32(GetLastError())
- );
- }
-
//
// Setup signal handlers.
//
// Try to get thread info from the local storage.
//
- ThreadInfo *threadInfo = reinterpret_cast<ThreadInfo*>(
- TlsGetValue(m_tlsThreadInfoIndex));
-
- if (threadInfo == nullptr)
- {
- DWORD lastError = GetLastError();
- if (lastError != ERROR_SUCCESS)
- {
- m_profiler.HandleHresult(
- "CommonTrace::GetThreadInfo(): TlsGetValue()",
- HRESULT_FROM_WIN32(lastError)
- );
- }
- }
+ ThreadInfo *threadInfo = tlsThreadInfo;
HRESULT hr;
// Save new thead info to the local storage.
//
- if (!TlsSetValue(m_tlsThreadInfoIndex, threadInfo))
- {
- m_profiler.HandleHresult(
- "CommonTrace::GetThreadInfo(): TlsSetValue()",
- HRESULT_FROM_WIN32(GetLastError())
- );
- }
+ tlsThreadInfo = threadInfo;
}
return threadInfo;
// Try to get thread info from the local storage.
//
- ThreadInfo *threadInfo = reinterpret_cast<ThreadInfo*>(
- TlsGetValue(m_tlsThreadInfoIndex));
+ ThreadInfo *threadInfo = tlsThreadInfo;
#ifdef _TARGET_AMD64_
if (threadInfo == nullptr)