16
16
#include "virtualcallstub.h"
17
17
#include "utilcode.h"
18
18
#include "interoplibinterface.h"
19
- #include "corinfo.h"
20
19
21
20
#if defined(TARGET_X86)
22
21
#define USE_CURRENT_CONTEXT_IN_FILTER
@@ -1777,10 +1776,8 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification(
1777
1776
// InlinedCallFrames (ICF) are allocated, initialized and linked to the Frame chain
1778
1777
// by the code generated by the JIT for a method containing a PInvoke.
1779
1778
//
1780
- // On platforms where USE_PER_FRAME_PINVOKE_INIT is not defined,
1781
- // the JIT generates code that links in the ICF
1782
- // at the start of the method and unlinks it towards the method end.
1783
- // Thus, ICF is present on the Frame chain at any given point so long as the
1779
+ // JIT generates code that links in the ICF at the start of the method and unlinks it towards
1780
+ // the method end. Thus, ICF is present on the Frame chain at any given point so long as the
1784
1781
// method containing the PInvoke is on the stack.
1785
1782
//
1786
1783
// Now, if the method containing ICF catches an exception, we will reset the Frame chain
@@ -1818,16 +1815,13 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification(
1818
1815
// below the callerSP for which we will invoke ExceptionUnwind.
1819
1816
//
1820
1817
// Thus, ICF::ExceptionUnwind should not do anything significant. If any of these assumptions
1821
- // break, then the next best thing will be to make the JIT link/unlink the frame dynamically
1818
+ // break, then the next best thing will be to make the JIT link/unlink the frame dynamically.
1822
1819
//
1823
- // If the current method executing is from precompiled ReadyToRun code, each PInvoke is wrapped
1824
- // by calls to the JIT_PInvokeBegin and JIT_PInvokeEnd helpers,
1825
- // which push and pop the ICF to the current thread. The ICF is not
1826
- // linked during the method prolog, and unlinked at the epilog.
1820
+ // If the current method executing is from precompiled ReadyToRun code, then the above is no longer
1821
+ // applicable because each PInvoke is wrapped by calls to the JIT_PInvokeBegin and JIT_PInvokeEnd
1822
+ // helpers, which push and pop the ICF to the current thread. Unlike jitted code, the ICF is not
1823
+ // linked during the method prolog, and unlinked at the epilog (it looks more like the X64 case) .
1827
1824
// In that case, we need to unlink the ICF during unwinding here.
1828
- // On platforms where USE_PER_FRAME_PINVOKE_INIT is defined, the JIT generates code that links in
1829
- // the ICF immediately before and after a PInvoke in non-IL-stubs, like ReadyToRun.
1830
- // See the usages for USE_PER_FRAME_PINVOKE_INIT for more information.
1831
1825
1832
1826
if (fTargetUnwind && (pFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()))
1833
1827
{
@@ -1836,12 +1830,8 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification(
1836
1830
//
1837
1831
// 1) ICF address is higher than the current frame's SP (which we get from DispatcherContext), AND
1838
1832
// 2) ICF address is below callerSP.
1839
- // 3) ICF is active.
1840
- // - IL stubs link the frame in for the whole stub, so if an exception is thrown during marshalling,
1841
- // the ICF will be on the frame chain and inactive.
1842
- if ((GetSP(pDispatcherContext->ContextRecord) < (TADDR)pICF)
1843
- && ((UINT_PTR)pICF < uCallerSP)
1844
- && InlinedCallFrame::FrameHasActiveCall(pICF))
1833
+ if ((GetSP(pDispatcherContext->ContextRecord) < (TADDR)pICF) &&
1834
+ ((UINT_PTR)pICF < uCallerSP))
1845
1835
{
1846
1836
pICFForUnwindTarget = pFrame;
1847
1837
@@ -1850,18 +1840,9 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification(
1850
1840
// to the JIT_PInvokeBegin and JIT_PInvokeEnd helpers, which push and pop the ICF on the thread. The
1851
1841
// ICF is not linked at the method prolog and unlined at the epilog when running R2R code. Since the
1852
1842
// JIT_PInvokeEnd helper will be skipped, we need to unlink the ICF here. If the executing method
1853
- // has another pinvoke , it will re-link the ICF again when the JIT_PInvokeBegin helper is called.
1843
+ // has another pinovoke , it will re-link the ICF again when the JIT_PInvokeBegin helper is called
1854
1844
1855
- TADDR returnAddress = ((InlinedCallFrame*)pFrame)->m_pCallerReturnAddress;
1856
- #ifdef USE_PER_FRAME_PINVOKE_INIT
1857
- // If we're setting up the frame for each P/Invoke for the given platform,
1858
- // then we do this for all P/Invokes except ones in IL stubs.
1859
- if (!ExecutionManager::GetCodeMethodDesc(returnAddress)->IsILStub())
1860
- #else
1861
- // If we aren't setting up the frame for each P/Invoke (instead setting up once per method),
1862
- // then ReadyToRun code is the only code using the per-P/Invoke logic.
1863
- if (ExecutionManager::IsReadyToRunCode(returnAddress))
1864
- #endif
1845
+ if (ExecutionManager::IsReadyToRunCode(((InlinedCallFrame*)pFrame)->m_pCallerReturnAddress))
1865
1846
{
1866
1847
pICFForUnwindTarget = pICFForUnwindTarget->Next();
1867
1848
}
0 commit comments