diff options
author | Jan Kotas <jkotas@microsoft.com> | 2017-03-09 01:16:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-09 01:16:16 +0300 |
commit | 01800d8ba5247379188dc967a47d12bf10b22e51 (patch) | |
tree | 86de3b4715b7525b1a234ec64fe2195c0338d665 /src/Native/Runtime/windows | |
parent | 2a2a698372eaa8d1e4259a642b6f0f843994c649 (diff) |
Add precise GC root stack enumeration (#2923)
Diffstat (limited to 'src/Native/Runtime/windows')
-rw-r--r-- | src/Native/Runtime/windows/CoffNativeCodeManager.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/Native/Runtime/windows/CoffNativeCodeManager.cpp b/src/Native/Runtime/windows/CoffNativeCodeManager.cpp index 076a57539..c4cbbeeae 100644 --- a/src/Native/Runtime/windows/CoffNativeCodeManager.cpp +++ b/src/Native/Runtime/windows/CoffNativeCodeManager.cpp @@ -270,26 +270,42 @@ PTR_VOID CoffNativeCodeManager::GetFramePointer(MethodInfo * pMethInfo, return NULL; } -// void EnumGCRefs(PTR_VOID pGCInfo, UINT32 curOffs, REGDISPLAY * pRD, GCEnumContext * hCallback, bool executionAborted); - void CoffNativeCodeManager::EnumGcRefs(MethodInfo * pMethodInfo, PTR_VOID safePointAddress, REGDISPLAY * pRegisterSet, GCEnumContext * hCallback) { - // @TODO: CORERT: PInvoke transitions - -#if 0 CoffNativeMethodInfo * pNativeMethodInfo = (CoffNativeMethodInfo *)pMethodInfo; - SIZE_T nUnwindDataSize; - PTR_VOID pUnwindData = GetUnwindDataBlob(dac_cast<TADDR>(m_pvStartRange), &pNativeMethodInfo->mainRuntimeFunction, &nUnwindDataSize); + size_t unwindDataBlobSize; + PTR_VOID pUnwindDataBlob = GetUnwindDataBlob(m_moduleBase, pNativeMethodInfo->mainRuntimeFunction, &unwindDataBlobSize); + + PTR_UInt8 p = dac_cast<PTR_UInt8>(pUnwindDataBlob) + unwindDataBlobSize; - // GCInfo immediatelly follows unwind data - PTR_VOID pGCInfo = dac_cast<PTR_VOID>(dac_cast<TADDR>(pUnwindData) + nUnwindDataSize + 1); + uint8_t unwindBlockFlags = *p++; - ::EnumGCRefs(pGCInfo, codeOffset, pRegisterSet, hCallback, pNativeMethodInfo->executionAborted); -#endif + if ((unwindBlockFlags & UBF_FUNC_HAS_EHINFO) != 0) + p += sizeof(int32_t); + + TADDR methodStartAddress = m_moduleBase + pNativeMethodInfo->mainRuntimeFunction->BeginAddress; + UInt32 codeOffset = (UInt32)(dac_cast<TADDR>(safePointAddress) - methodStartAddress); + + GcInfoDecoder decoder( + GCInfoToken(p), + GcInfoDecoderFlags(DECODE_GC_LIFETIMES | DECODE_SECURITY_OBJECT | DECODE_VARARG), + codeOffset - 1 // TODO: Is this adjustment correct? + ); + + if (!decoder.EnumerateLiveSlots( + pRegisterSet, + false /* reportScratchSlots */, + pNativeMethodInfo->executionAborted ? ICodeManagerFlags::ExecutionAborted : 0, // TODO: Flags? + hCallback->pCallback, + hCallback + )) + { + assert(false); + } } UIntNative CoffNativeCodeManager::GetConservativeUpperBoundForOutgoingArgs(MethodInfo * pMethodInfo, REGDISPLAY * pRegisterSet) |