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>2016-10-25 02:08:52 +0300
committerJan Kotas <jkotas@microsoft.com>2016-11-01 21:14:27 +0300
commitdc615445b739500abcbafd68adb83168ad0a4e93 (patch)
tree94b68e137ea31eab9cecd8c2857656cc4e5f6c99 /src/Native/Runtime/windows
parenta09de49cbf64f7c22d950a98678830bcf8d6ce82 (diff)
Make unhandled exceptions fail gracefully on Windows
Persist GCInfo in the native image on Windows
Diffstat (limited to 'src/Native/Runtime/windows')
-rw-r--r--src/Native/Runtime/windows/CoffNativeCodeManager.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/Native/Runtime/windows/CoffNativeCodeManager.cpp b/src/Native/Runtime/windows/CoffNativeCodeManager.cpp
index c4c8fca05..79ac103b6 100644
--- a/src/Native/Runtime/windows/CoffNativeCodeManager.cpp
+++ b/src/Native/Runtime/windows/CoffNativeCodeManager.cpp
@@ -16,6 +16,9 @@
#include "CommonMacros.inl"
+#define GCINFODECODER_NO_EE
+#include "coreclr\gcinfodecoder.cpp"
+
#define UBF_FUNC_KIND_MASK 0x03
#define UBF_FUNC_KIND_ROOT 0x00
#define UBF_FUNC_KIND_HANDLER 0x01
@@ -23,6 +26,8 @@
#define UBF_FUNC_HAS_EHINFO 0x04
+#define UBF_FUNC_REVERSE_PINVOKE 0x08
+
#if defined(_TARGET_AMD64_)
//
@@ -300,8 +305,27 @@ bool CoffNativeCodeManager::UnwindStackFrame(MethodInfo * pMethodInfo,
{
CoffNativeMethodInfo * pNativeMethodInfo = (CoffNativeMethodInfo *)pMethodInfo;
- // @TODO: CORERT: PInvoke transitions
- *ppPreviousTransitionFrame = NULL;
+ size_t unwindDataBlobSize;
+ PTR_VOID pUnwindDataBlob = GetUnwindDataBlob(m_moduleBase, pNativeMethodInfo->mainRuntimeFunction, &unwindDataBlobSize);
+
+ PTR_UInt8 p = dac_cast<PTR_UInt8>(pUnwindDataBlob) + unwindDataBlobSize;
+
+ uint8_t unwindBlockFlags = *p++;
+
+ if ((unwindBlockFlags & UBF_FUNC_REVERSE_PINVOKE) != 0)
+ {
+ GcInfoDecoder decoder(GCInfoToken(p), DECODE_REVERSE_PINVOKE_VAR);
+
+ // @TODO: CORERT: Encode reverse PInvoke frame slot in GCInfo: https://github.com/dotnet/corert/issues/2115
+ // INT32 slot = decoder.GetReversePInvokeFrameStackSlot();
+ // assert(slot != NO_REVERSE_PINVOKE_FRAME);
+
+ *ppPreviousTransitionFrame = (PTR_VOID)-1;
+ }
+ else
+ {
+ *ppPreviousTransitionFrame = NULL;
+ }
CONTEXT context;
KNONVOLATILE_CONTEXT_POINTERS contextPointers;
@@ -409,7 +433,9 @@ bool CoffNativeCodeManager::EHEnumInit(MethodInfo * pMethodInfo, PTR_VOID * pMet
size_t unwindDataBlobSize;
PTR_VOID pUnwindDataBlob = GetUnwindDataBlob(m_moduleBase, pNativeMethodInfo->mainRuntimeFunction, &unwindDataBlobSize);
- uint8_t unwindBlockFlags = *(dac_cast<DPTR(uint8_t)>(pUnwindDataBlob) + unwindDataBlobSize);
+ PTR_UInt8 p = dac_cast<PTR_UInt8>(pUnwindDataBlob) + unwindDataBlobSize;
+
+ uint8_t unwindBlockFlags = *p++;
// return if there is no EH info associated with this method
if ((unwindBlockFlags & UBF_FUNC_HAS_EHINFO) == 0)
@@ -419,7 +445,7 @@ bool CoffNativeCodeManager::EHEnumInit(MethodInfo * pMethodInfo, PTR_VOID * pMet
*pMethodStartAddress = dac_cast<PTR_VOID>(m_moduleBase + pNativeMethodInfo->mainRuntimeFunction->BeginAddress);
pEnumState->pMethodStartAddress = dac_cast<PTR_UInt8>(*pMethodStartAddress);
- pEnumState->pEHInfo = dac_cast<PTR_UInt8>(pUnwindDataBlob) + unwindDataBlobSize + 1;
+ pEnumState->pEHInfo = dac_cast<PTR_UInt8>(m_moduleBase + *dac_cast<PTR_Int32>(p));
pEnumState->uClause = 0;
pEnumState->nClauses = VarInt::ReadUnsigned(pEnumState->pEHInfo);