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:
authorJan Kotas <jkotas@microsoft.com>2017-09-14 05:52:02 +0300
committerGitHub <noreply@github.com>2017-09-14 05:52:02 +0300
commit764c8674d5463d3a4c744562941aef00b7210afb (patch)
treef082abf064f7650864702fa957184d24da58ef0e /src/Native
parentd776732f8b1438bfe27b454bb5be80c57b2a1734 (diff)
parent586845703c2b9dba47db2875cf13f159637c4a36 (diff)
Merge pull request #4488 from dotnet/nmirror
Merge nmirror to master
Diffstat (limited to 'src/Native')
-rw-r--r--src/Native/Runtime/ICodeManager.h11
-rw-r--r--src/Native/Runtime/MiscHelpers.cpp5
-rw-r--r--src/Native/Runtime/RuntimeInstance.cpp18
-rw-r--r--src/Native/Runtime/RuntimeInstance.h1
-rw-r--r--src/Native/Runtime/module.cpp8
-rw-r--r--src/Native/Runtime/module.h2
-rw-r--r--src/Native/Runtime/unix/UnixNativeCodeManager.cpp30
-rw-r--r--src/Native/Runtime/unix/UnixNativeCodeManager.h2
-rw-r--r--src/Native/Runtime/windows/CoffNativeCodeManager.cpp41
-rw-r--r--src/Native/Runtime/windows/CoffNativeCodeManager.h2
-rw-r--r--src/Native/jitinterface/JITCodeManager.cpp7
-rw-r--r--src/Native/jitinterface/JITCodeManager.h4
12 files changed, 124 insertions, 7 deletions
diff --git a/src/Native/Runtime/ICodeManager.h b/src/Native/Runtime/ICodeManager.h
index 7cbfc1838..3d5af20fd 100644
--- a/src/Native/Runtime/ICodeManager.h
+++ b/src/Native/Runtime/ICodeManager.h
@@ -80,6 +80,12 @@ enum class ClasslibFunctionId
OnFirstChanceException = 6,
};
+enum class AssociatedDataFlags : unsigned char
+{
+ None = 0,
+ HasUnboxingStubTarget = 1,
+};
+
class ICodeManager
{
public:
@@ -119,4 +125,9 @@ public:
virtual PTR_VOID GetMethodStartAddress(MethodInfo * pMethodInfo) = 0;
virtual void * GetClasslibFunction(ClasslibFunctionId functionId) = 0;
+
+ // Returns any custom data attached to the method. Format:
+ // AssociatedDataFlags // 1 byte. Flags describing the data stored
+ // Data (stream of bytes) // Variable size (depending on flags). Custom data associated with method
+ virtual PTR_VOID GetAssociatedData(PTR_VOID ControlPC) = 0;
};
diff --git a/src/Native/Runtime/MiscHelpers.cpp b/src/Native/Runtime/MiscHelpers.cpp
index eaf55a79a..507ffa608 100644
--- a/src/Native/Runtime/MiscHelpers.cpp
+++ b/src/Native/Runtime/MiscHelpers.cpp
@@ -332,6 +332,11 @@ COOP_PINVOKE_HELPER(void *, GetClasslibCCtorCheck, (void * pReturnAddress))
return pCallback;
}
+COOP_PINVOKE_HELPER(void *, RhGetTargetOfUnboxingAndInstantiatingStub, (void * pUnboxStub))
+{
+ return GetRuntimeInstance()->GetTargetOfUnboxingAndInstantiatingStub(pUnboxStub);
+}
+
COOP_PINVOKE_HELPER(Boolean, RhpHasDispatchMap, (EEType * pEEType))
{
return pEEType->HasDispatchMap();
diff --git a/src/Native/Runtime/RuntimeInstance.cpp b/src/Native/Runtime/RuntimeInstance.cpp
index b7254a401..35f22d38c 100644
--- a/src/Native/Runtime/RuntimeInstance.cpp
+++ b/src/Native/Runtime/RuntimeInstance.cpp
@@ -181,6 +181,24 @@ ICodeManager * RuntimeInstance::FindCodeManagerByAddress(PTR_VOID pvAddress)
return NULL;
}
+PTR_UInt8 RuntimeInstance::GetTargetOfUnboxingAndInstantiatingStub(PTR_VOID ControlPC)
+{
+ ICodeManager * pCodeManager = FindCodeManagerByAddress(ControlPC);
+ if (pCodeManager != NULL)
+ {
+ PTR_UInt8 pData = (PTR_UInt8)pCodeManager->GetAssociatedData(ControlPC);
+ if (pData != NULL)
+ {
+ UInt8 flags = *pData++;
+
+ if ((flags & (UInt8)AssociatedDataFlags::HasUnboxingStubTarget) != 0)
+ return *((PTR_PTR_UInt8)pData);
+ }
+ }
+
+ return NULL;
+}
+
GPTR_IMPL_INIT(RuntimeInstance, g_pTheRuntimeInstance, NULL);
PTR_RuntimeInstance GetRuntimeInstance()
diff --git a/src/Native/Runtime/RuntimeInstance.h b/src/Native/Runtime/RuntimeInstance.h
index 3d1ab3ed6..bd001fd19 100644
--- a/src/Native/Runtime/RuntimeInstance.h
+++ b/src/Native/Runtime/RuntimeInstance.h
@@ -174,6 +174,7 @@ public:
Module * FindModuleByReadOnlyDataAddress(PTR_VOID Data);
Module * FindModuleByOsHandle(HANDLE hOsHandle);
PTR_UInt8 FindMethodStartAddress(PTR_VOID ControlPC);
+ PTR_UInt8 GetTargetOfUnboxingAndInstantiatingStub(PTR_VOID ControlPC);
void EnableConservativeStackReporting();
bool IsConservativeStackReportingEnabled() { return m_conservativeStackReportingEnabled; }
diff --git a/src/Native/Runtime/module.cpp b/src/Native/Runtime/module.cpp
index f17eb2857..a83571cae 100644
--- a/src/Native/Runtime/module.cpp
+++ b/src/Native/Runtime/module.cpp
@@ -832,6 +832,14 @@ void * Module::GetClasslibFunction(ClasslibFunctionId functionId)
return pMethod;
}
+PTR_VOID Module::GetAssociatedData(PTR_VOID ControlPC)
+{
+ UNREFERENCED_PARAMETER(ControlPC);
+
+ // Not supported for ProjectN.
+ return NULL;
+}
+
// Get classlib-defined helper for running deferred static class constructors. Returns NULL if this is not the
// classlib module or the classlib doesn't implement this callback.
void * Module::GetClasslibCheckStaticClassConstruction()
diff --git a/src/Native/Runtime/module.h b/src/Native/Runtime/module.h
index a037bc828..f1a48b2a8 100644
--- a/src/Native/Runtime/module.h
+++ b/src/Native/Runtime/module.h
@@ -113,6 +113,8 @@ public:
void * RecoverLoopHijackTarget(UInt32 entryIndex, ModuleHeader * pModuleHeader);
+ PTR_VOID GetAssociatedData(PTR_VOID ControlPC);
+
private:
Module(ModuleHeader * pModuleHeader);
#ifdef FEATURE_CUSTOM_IMPORTS
diff --git a/src/Native/Runtime/unix/UnixNativeCodeManager.cpp b/src/Native/Runtime/unix/UnixNativeCodeManager.cpp
index e60e60130..788d81d0c 100644
--- a/src/Native/Runtime/unix/UnixNativeCodeManager.cpp
+++ b/src/Native/Runtime/unix/UnixNativeCodeManager.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
struct UnixNativeMethodInfo
{
@@ -130,6 +130,9 @@ void UnixNativeCodeManager::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);
@@ -176,6 +179,9 @@ bool UnixNativeCodeManager::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
@@ -265,6 +271,9 @@ bool UnixNativeCodeManager::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)
{
@@ -356,6 +365,21 @@ void * UnixNativeCodeManager::GetClasslibFunction(ClasslibFunctionId functionId)
return m_pClasslibFunctions[id];
}
+PTR_VOID UnixNativeCodeManager::GetAssociatedData(PTR_VOID ControlPC)
+{
+ UnixNativeMethodInfo methodInfo;
+ if (!FindMethodInfo(ControlPC, (MethodInfo*)&methodInfo))
+ return NULL;
+
+ PTR_UInt8 p = methodInfo.pMainLSDA;
+
+ uint8_t unwindBlockFlags = *p++;
+ if ((unwindBlockFlags & UBF_FUNC_HAS_ASSOCIATED_DATA) == 0)
+ return NULL;
+
+ return dac_cast<PTR_VOID>(p + *dac_cast<PTR_Int32>(p));
+}
+
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/unix/UnixNativeCodeManager.h b/src/Native/Runtime/unix/UnixNativeCodeManager.h
index e424a559c..13333ee73 100644
--- a/src/Native/Runtime/unix/UnixNativeCodeManager.h
+++ b/src/Native/Runtime/unix/UnixNativeCodeManager.h
@@ -58,4 +58,6 @@ public:
PTR_VOID GetMethodStartAddress(MethodInfo * pMethodInfo);
void * GetClasslibFunction(ClasslibFunctionId functionId);
+
+ PTR_VOID GetAssociatedData(PTR_VOID ControlPC);
};
diff --git a/src/Native/Runtime/windows/CoffNativeCodeManager.cpp b/src/Native/Runtime/windows/CoffNativeCodeManager.cpp
index 6690ffeb2..2f8b02781 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_VOID 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 dac_cast<PTR_VOID>(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);
};
diff --git a/src/Native/jitinterface/JITCodeManager.cpp b/src/Native/jitinterface/JITCodeManager.cpp
index fac0f426e..e16da72a9 100644
--- a/src/Native/jitinterface/JITCodeManager.cpp
+++ b/src/Native/jitinterface/JITCodeManager.cpp
@@ -730,3 +730,10 @@ void * JITCodeManager::GetClasslibFunction(ClasslibFunctionId functionId)
assert(false);
return false;
}
+
+PTR_VOID JITCodeManager::GetAssociatedData(PTR_VOID ControlPC)
+{
+ // @TODO: CORERT: GetAssociatedData
+ assert(false);
+ return NULL;
+}
diff --git a/src/Native/jitinterface/JITCodeManager.h b/src/Native/jitinterface/JITCodeManager.h
index 294a48016..4b0212943 100644
--- a/src/Native/jitinterface/JITCodeManager.h
+++ b/src/Native/jitinterface/JITCodeManager.h
@@ -276,4 +276,6 @@ public:
PTR_VOID GetMethodStartAddress(MethodInfo * pMethodInfo);
void * GetClasslibFunction(ClasslibFunctionId functionId);
-}; \ No newline at end of file
+
+ PTR_VOID GetAssociatedData(PTR_VOID ControlPC);
+};