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:
authorFadi Hanna <fadim@microsoft.com>2017-09-13 01:07:07 +0300
committerFadi Hanna <fadim@microsoft.com>2017-09-13 01:07:07 +0300
commit92a6a3b1ae4aff4b3a904fed104d253f7d863a36 (patch)
tree6933a7db8ebdb1ba0338019137e65b75dfe9a2a0 /src/Native/Runtime/windows
parent665c60acc7f188d4a5e81c96f39431de1352b901 (diff)
These changes provide a way for ProjectX/CoreRT to get the target of custom instantiating unboxing stubs.
The implementation uses a general purpose infrastructure that can associate custom data to methods with unwind info, given the fact that unwind info lookups are very fast. Similar to GC info and EH info, this implementation now provides a way to associate any custom data to methods, by adding a flag and a reloc to the data in the method's unwind info. The custom data that can be attached to methods begin with a flag (indicating what data follows), followed by data. Right now, the only custom data we have for methods are unboxing stub target pointers. The dependency analysis models this custom data using a new node type: MethodAssociatedDataNode. The custom data (when it exists) can be be retrieved using a new API on ICodeManager. The changes also include all the necessary plumbing to link custom data nodes symbols for PX (given that it's UTC that emits the unwind info) [tfs-changeset: 1673664]
Diffstat (limited to 'src/Native/Runtime/windows')
-rw-r--r--src/Native/Runtime/windows/CoffNativeCodeManager.cpp41
-rw-r--r--src/Native/Runtime/windows/CoffNativeCodeManager.h2
2 files changed, 40 insertions, 3 deletions
diff --git a/src/Native/Runtime/windows/CoffNativeCodeManager.cpp b/src/Native/Runtime/windows/CoffNativeCodeManager.cpp
index 6690ffeb2..fa162aa75 100644
--- a/src/Native/Runtime/windows/CoffNativeCodeManager.cpp
+++ b/src/Native/Runtime/windows/CoffNativeCodeManager.cpp
@@ -25,9 +25,9 @@
#define UBF_FUNC_KIND_HANDLER 0x01
#define UBF_FUNC_KIND_FILTER 0x02
-#define UBF_FUNC_HAS_EHINFO 0x04
-
-#define UBF_FUNC_REVERSE_PINVOKE 0x08
+#define UBF_FUNC_HAS_EHINFO 0x04
+#define UBF_FUNC_REVERSE_PINVOKE 0x08
+#define UBF_FUNC_HAS_ASSOCIATED_DATA 0x10
#if defined(_TARGET_AMD64_)
@@ -297,6 +297,9 @@ void CoffNativeCodeManager::EnumGcRefs(MethodInfo * pMethodInfo,
uint8_t unwindBlockFlags = *p++;
+ if ((unwindBlockFlags & UBF_FUNC_HAS_ASSOCIATED_DATA) != 0)
+ p += sizeof(int32_t);
+
if ((unwindBlockFlags & UBF_FUNC_HAS_EHINFO) != 0)
p += sizeof(int32_t);
@@ -347,6 +350,9 @@ bool CoffNativeCodeManager::UnwindStackFrame(MethodInfo * pMethodInfo,
uint8_t unwindBlockFlags = *p++;
+ if ((unwindBlockFlags & UBF_FUNC_HAS_ASSOCIATED_DATA) != 0)
+ p += sizeof(int32_t);
+
if ((unwindBlockFlags & UBF_FUNC_REVERSE_PINVOKE) != 0)
{
// Reverse PInvoke transition should on the main function body only
@@ -455,6 +461,9 @@ bool CoffNativeCodeManager::GetReturnAddressHijackInfo(MethodInfo * pMethodIn
uint8_t unwindBlockFlags = *p++;
+ if ((unwindBlockFlags & UBF_FUNC_HAS_ASSOCIATED_DATA) != 0)
+ p += sizeof(int32_t);
+
// Check whether this is a funclet
if ((unwindBlockFlags & UBF_FUNC_KIND_MASK) != UBF_FUNC_KIND_ROOT)
return false;
@@ -550,6 +559,9 @@ bool CoffNativeCodeManager::EHEnumInit(MethodInfo * pMethodInfo, PTR_VOID * pMet
uint8_t unwindBlockFlags = *p++;
+ if ((unwindBlockFlags & UBF_FUNC_HAS_ASSOCIATED_DATA) != 0)
+ p += sizeof(int32_t);
+
// return if there is no EH info associated with this method
if ((unwindBlockFlags & UBF_FUNC_HAS_EHINFO) == 0)
{
@@ -634,6 +646,29 @@ void * CoffNativeCodeManager::GetClasslibFunction(ClasslibFunctionId functionId)
return m_pClasslibFunctions[id];
}
+PTR_VOID CoffNativeCodeManager::GetAssociatedData(PTR_VOID ControlPC)
+{
+ TADDR relativePC = dac_cast<TADDR>(ControlPC) - m_moduleBase;
+
+ int MethodIndex = LookupUnwindInfoForMethod((UInt32)relativePC, m_pRuntimeFunctionTable, 0, m_nRuntimeFunctionTable - 1);
+ if (MethodIndex < 0)
+ return NULL;
+
+ PTR_RUNTIME_FUNCTION pRuntimeFunction = m_pRuntimeFunctionTable + MethodIndex;
+
+ size_t unwindDataBlobSize;
+ PTR_UInt8 pUnwindDataBlob = GetUnwindDataBlob(m_moduleBase, pRuntimeFunction, &unwindDataBlobSize);
+
+ PTR_UInt8 p = dac_cast<PTR_UInt8>(pUnwindDataBlob) + unwindDataBlobSize;
+
+ uint8_t unwindBlockFlags = *p++;
+ if ((unwindBlockFlags & UBF_FUNC_HAS_ASSOCIATED_DATA) == 0)
+ return NULL;
+
+ UInt32 dataRVA = *(UInt32*)p;
+ return m_moduleBase + dataRVA;
+}
+
extern "C" bool __stdcall RegisterCodeManager(ICodeManager * pCodeManager, PTR_VOID pvStartRange, UInt32 cbRange);
extern "C" void __stdcall UnregisterCodeManager(ICodeManager * pCodeManager);
extern "C" bool __stdcall RegisterUnboxingStubs(PTR_VOID pvStartRange, UInt32 cbRange);
diff --git a/src/Native/Runtime/windows/CoffNativeCodeManager.h b/src/Native/Runtime/windows/CoffNativeCodeManager.h
index 09b960386..b0d5390a4 100644
--- a/src/Native/Runtime/windows/CoffNativeCodeManager.h
+++ b/src/Native/Runtime/windows/CoffNativeCodeManager.h
@@ -94,4 +94,6 @@ public:
PTR_VOID GetMethodStartAddress(MethodInfo * pMethodInfo);
void * GetClasslibFunction(ClasslibFunctionId functionId);
+
+ PTR_VOID GetAssociatedData(PTR_VOID ControlPC);
};