Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Wrighton <davidwr@microsoft.com>2017-02-15 02:35:19 +0300
committerDavid Wrighton <davidwr@microsoft.com>2017-02-15 02:35:19 +0300
commit720e17f599c1d8aca941dbca8a9492f3474f3b05 (patch)
tree544ecb53dbff7736b2945c7b58c5b6f997ee4734 /src/Native/Runtime/TypeManager.cpp
parent1a8e729b2e9e3915947cace8c3bf316237d519e6 (diff)
Refactor use of TypeManager and Module pointers within the BCL
- Move from using an IntPtr which may represent a TypeManager* or a OS module pointer to using a struct TypeManagerHandle consistently - Except for RuntimeSignature, which has a third possible meaning of its IntPtr. That work will be done in a seperate change, and wil result in removal of nearly all of the new TypeManagerHandle calls in this delta. - This struct contains a bit which indicates which form of pointer is being worked with, as well as routines for performing RVA access as appropriate - Added new api to redhawk to get the OS module list (Used in crash dump generation) - Added new api to get the OS module of of a pointer. These are not yet enabled for TypeManager based scenarios, but that will be done in a followon change. Eventually these will exclusively be use for instruction pointers, and will tie into diagnostic scenarios around stack traces, etc. Currently, it is also used in a few reflection scenarios. Those code patterns will be removed soon. - Similarly distinguished between getting the OS module for an EEType, and getting the module for an EEType. This is used in error message scenarios. - Update RhFindBlob to work with both types of module pointers [tfs-changeset: 1647831]
Diffstat (limited to 'src/Native/Runtime/TypeManager.cpp')
-rw-r--r--src/Native/Runtime/TypeManager.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/Native/Runtime/TypeManager.cpp b/src/Native/Runtime/TypeManager.cpp
index fd9e22352..655984788 100644
--- a/src/Native/Runtime/TypeManager.cpp
+++ b/src/Native/Runtime/TypeManager.cpp
@@ -24,7 +24,7 @@
#include "TypeManager.h"
/* static */
-TypeManager * TypeManager::Create(void * pModuleHeader)
+TypeManager * TypeManager::Create(HANDLE osModule, void * pModuleHeader)
{
ReadyToRunHeader * pReadyToRunHeader = (ReadyToRunHeader *)pModuleHeader;
@@ -38,11 +38,11 @@ TypeManager * TypeManager::Create(void * pModuleHeader)
if (pReadyToRunHeader->MajorVersion != ReadyToRunHeaderConstants::CurrentMajorVersion)
return nullptr;
- return new (nothrow) TypeManager(pReadyToRunHeader);
+ return new (nothrow) TypeManager(osModule, pReadyToRunHeader);
}
-TypeManager::TypeManager(ReadyToRunHeader * pHeader)
- : m_pHeader(pHeader), m_pDispatchMapTable(nullptr)
+TypeManager::TypeManager(HANDLE osModule, ReadyToRunHeader * pHeader)
+ : m_osModule(osModule), m_pHeader(pHeader), m_pDispatchMapTable(nullptr)
{
int length;
m_pStaticsGCDataSection = (UInt8*)GetModuleSection(ReadyToRunSectionType::GCStaticRegion, &length);
@@ -162,3 +162,31 @@ void TypeManager::EnumStaticGCRefs(void * pfnCallback, void * pvCallbackData)
END_FOREACH_THREAD
}
}
+
+HANDLE TypeManager::GetOsModuleHandle()
+{
+ return m_osModule;
+}
+
+bool TypeManagerHandle::IsTypeManager()
+{
+#if !CORERT
+ if (((int)_value & 1) == 0)
+ return false;
+#endif
+
+ return true;
+}
+
+TypeManager* TypeManagerHandle::AsTypeManager()
+{
+ ASSERT(IsTypeManager());
+ return (TypeManager*)(((uint8_t *)_value) - 1);
+}
+
+HANDLE TypeManagerHandle::AsOsModule()
+{
+ ASSERT(!IsTypeManager());
+ return (HANDLE)_value;
+}
+