Skip to content

Commit b8fe223

Browse files
committed
Move to single InterpreterFrame and few fixes
1 parent 71813c1 commit b8fe223

File tree

10 files changed

+46
-96
lines changed

10 files changed

+46
-96
lines changed

src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -189,23 +189,7 @@ void DacDbiInterfaceImpl::SetStackWalkCurrentContext(VMPTR_Thread vmTh
189189
// Allocate a context in DDImpl's memory space. DDImpl can't contain raw pointers back into
190190
// the client space since that may not marshal.
191191
T_CONTEXT * pContext2 = GetContextBufferFromHandle(pSFIHandle);
192-
193-
#ifdef FEATURE_INTERPRETER
194-
PTR_Frame pTopFrame = vmThread.GetDacPtr()->GetFrame();
195-
196-
if ((pTopFrame != FRAME_TOP) && (pTopFrame->GetFrameIdentifier() == FrameIdentifier::InterpreterEntryFrame))
197-
{
198-
InterpreterEntryFrame *pEntryFrame = dac_cast<PTR_InterpreterEntryFrame>(pTopFrame);
199-
PTR_InterpMethodContextFrame pTOSInterpMethodContextFrame = pEntryFrame->GetInterpMethodTopmostContextFrame();
200-
SetIP(pContext2, (TADDR)pTOSInterpMethodContextFrame->ip);
201-
SetSP(pContext2, dac_cast<TADDR>(pTOSInterpMethodContextFrame));
202-
pContext2->ContextFlags = CONTEXT_CONTROL;
203-
}
204-
else
205-
#endif // FEATURE_INTERPRETER
206-
{
207-
CopyMemory(pContext2, pContext, sizeof(*pContext));
208-
}
192+
CopyMemory(pContext2, pContext, sizeof(*pContext));
209193

210194
// update the REGDISPLAY with the given CONTEXT.
211195
// Be sure that the context is in DDImpl's memory space and not the Right-sides.

src/coreclr/debug/daccess/stack.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -467,24 +467,10 @@ ClrDataStackWalk::Init(void)
467467
return E_FAIL;
468468
}
469469

470-
#ifdef FEATURE_INTERPRETER
471-
PTR_Frame pTopFrame = m_thread->GetFrame();
472-
#endif // FEATURE_INTERPRETER
473-
474470
if (m_thread->GetFilterContext())
475471
{
476472
m_context = *m_thread->GetFilterContext();
477473
}
478-
#ifdef FEATURE_INTERPRETER
479-
else if ((pTopFrame != FRAME_TOP) && (pTopFrame->GetFrameIdentifier() == FrameIdentifier::InterpreterEntryFrame))
480-
{
481-
InterpreterEntryFrame *pEntryFrame = dac_cast<PTR_InterpreterEntryFrame>(pTopFrame);
482-
PTR_InterpMethodContextFrame pTOSInterpMethodContextFrame = pEntryFrame->GetInterpMethodTopmostContextFrame();
483-
SetIP(&m_context, (TADDR)pTOSInterpMethodContextFrame->ip);
484-
SetSP(&m_context, dac_cast<TADDR>(pTOSInterpMethodContextFrame));
485-
m_context.ContextFlags = CONTEXT_CONTROL;
486-
}
487-
#endif // FEATURE_INTERPRETER
488474
else
489475
{
490476
DacGetThreadContext(m_thread, &m_context);

src/coreclr/vm/FrameTypes.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ FRAME_TYPE_NAME(DebuggerExitFrame)
4848
FRAME_TYPE_NAME(DebuggerU2MCatchHandlerFrame)
4949
FRAME_TYPE_NAME(ExceptionFilterFrame)
5050
#ifdef FEATURE_INTERPRETER
51-
FRAME_TYPE_NAME(InterpreterEntryFrame)
52-
FRAME_TYPE_NAME(InterpreterExitFrame)
51+
FRAME_TYPE_NAME(InterpreterFrame)
5352
#endif // FEATURE_INTERPRETER
5453

5554
#undef FRAME_TYPE_NAME

src/coreclr/vm/eetwain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,7 @@ static void VirtualUnwindInterpreterCallFrame(TADDR sp, CONTEXT *pContext)
22962296
{
22972297
// This indicates that there are no more interpreter frames to unwind in the current InterpExecMethod
22982298
// The stack walker will not find any code manager for the address 0 and move on to the next explicit
2299-
// frame which is the InterpreterEntryFrame.
2299+
// frame which is the InterpreterFrame.
23002300
// Interpreter-TODO: Consider returning the context of the JITted / AOTed code that called the interpreter instead
23012301
SetIP(pContext, 0);
23022302
SetSP(pContext, sp);

src/coreclr/vm/frames.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,7 @@ PCODE UnmanagedToManagedFrame::GetReturnAddress_Impl()
20842084
#endif // FEATURE_COMINTEROP
20852085

20862086
#ifdef FEATURE_INTERPRETER
2087-
PTR_InterpMethodContextFrame InterpreterEntryFrame::GetInterpMethodTopmostContextFrame()
2087+
PTR_InterpMethodContextFrame InterpreterFrame::GetInterpMethodTopmostContextFrame()
20882088
{
20892089
LIMITED_METHOD_CONTRACT;
20902090
PTR_InterpMethodContextFrame pFrame = m_pInterpMethodContextFrame;
@@ -2101,20 +2101,6 @@ PTR_InterpMethodContextFrame InterpreterEntryFrame::GetInterpMethodTopmostContex
21012101
return pFrame;
21022102
}
21032103

2104-
void InterpreterExitFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats)
2105-
{
2106-
LIMITED_METHOD_DAC_CONTRACT;
2107-
2108-
SetIP(pRD->pCurrentContext, (TADDR)m_pInterpMethodContextFrame->ip);
2109-
SetSP(pRD->pCurrentContext, dac_cast<TADDR>(m_pInterpMethodContextFrame));
2110-
SyncRegDisplayToCurrentContext(pRD);
2111-
}
2112-
2113-
TADDR InterpreterExitFrame::GetReturnAddress_Impl()
2114-
{
2115-
return (TADDR)m_pInterpMethodContextFrame->ip;
2116-
}
2117-
21182104
#endif // FEATURE_INTERPRETER
21192105

21202106
#ifndef DACCESS_COMPILE

src/coreclr/vm/frames.h

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,49 +2865,17 @@ class ExceptionFilterFrame : public Frame
28652865
};
28662866

28672867
#ifdef FEATURE_INTERPRETER
2868-
typedef DPTR(class InterpreterExitFrame) PTR_InterpreterExitFrame;
28692868
struct InterpMethodContextFrame;
28702869
typedef DPTR(struct InterpMethodContextFrame) PTR_InterpMethodContextFrame;
28712870

2872-
class InterpreterExitFrame : public Frame
2873-
{
2874-
public:
2875-
#ifndef DACCESS_COMPILE
2876-
InterpreterExitFrame(InterpMethodContextFrame* pContextFrame) : Frame(FrameIdentifier::InterpreterExitFrame),
2877-
m_pInterpMethodContextFrame(pContextFrame)
2878-
{
2879-
WRAPPER_NO_CONTRACT;
2880-
Push();
2881-
}
2882-
#endif // DACCESS_COMPILE
2883-
2884-
PTR_InterpMethodContextFrame GetInterpMethodContextFrame()
2885-
{
2886-
LIMITED_METHOD_CONTRACT;
2887-
return m_pInterpMethodContextFrame;
2888-
}
2889-
2890-
BOOL NeedsUpdateRegDisplay_Impl()
2891-
{
2892-
return TRUE;
2893-
}
2894-
2895-
TADDR GetReturnAddress_Impl();
2896-
2897-
void UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats);
2898-
2899-
private:
2900-
PTR_InterpMethodContextFrame m_pInterpMethodContextFrame;
2901-
};
2902-
2903-
typedef DPTR(class InterpreterEntryFrame) PTR_InterpreterEntryFrame;
2871+
typedef DPTR(class InterpreterFrame) PTR_InterpreterFrame;
29042872

2905-
class InterpreterEntryFrame : public FramedMethodFrame
2873+
class InterpreterFrame : public FramedMethodFrame
29062874
{
29072875
public:
29082876
#ifndef DACCESS_COMPILE
2909-
InterpreterEntryFrame(TransitionBlock* pTransitionBlock, InterpMethodContextFrame* pContextFrame)
2910-
: FramedMethodFrame(FrameIdentifier::InterpreterEntryFrame, pTransitionBlock, NULL),
2877+
InterpreterFrame(TransitionBlock* pTransitionBlock, InterpMethodContextFrame* pContextFrame)
2878+
: FramedMethodFrame(FrameIdentifier::InterpreterFrame, pTransitionBlock, NULL),
29112879
m_pInterpMethodContextFrame(pContextFrame)
29122880
{
29132881
WRAPPER_NO_CONTRACT;

src/coreclr/vm/interpexec.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -706,13 +706,9 @@ void InterpExecMethod(InterpMethodContextFrame *pFrame, InterpThreadContext *pTh
706706
MethodDesc *pMD = (MethodDesc*)(targetMethod & ~INTERP_METHOD_DESC_TAG);
707707
PCODE code = pMD->GetNativeCode();
708708
if (!code) {
709-
InterpreterExitFrame exitFrame(pFrame);
710-
{
711-
GCX_PREEMP();
712-
pMD->PrepareInitialCode(CallerGCMode::Coop);
713-
code = pMD->GetNativeCode();
714-
}
715-
exitFrame.Pop();
709+
GCX_PREEMP();
710+
pMD->PrepareInitialCode(CallerGCMode::Coop);
711+
code = pMD->GetNativeCode();
716712
}
717713
pMethod->pDataItems[ip[3]] = (void*)code;
718714
targetIp = (const int32_t*)code;

src/coreclr/vm/prestub.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,16 +2748,14 @@ extern "C" void STDCALL ExecuteInterpretedMethod(TransitionBlock* pTransitionBlo
27482748

27492749
InterpMethodContextFrame interpFrame = {0};
27502750
interpFrame.startIp = (int32_t*)byteCodeAddr;
2751-
interpFrame.ip = interpFrame.startIp;
27522751
interpFrame.pStack = sp;
27532752
interpFrame.pRetVal = sp;
27542753

2755-
InterpreterEntryFrame interpreterEntryFrame(pTransitionBlock, &interpFrame);
2754+
InterpreterFrame InterpreterFrame(pTransitionBlock, &interpFrame);
27562755

2757-
// Interpreter-TODO: catch exceptions stemming from the InterpExecMethod and call the managed exception handling
27582756
InterpExecMethod(&interpFrame, threadContext);
27592757

2760-
interpreterEntryFrame.Pop();
2758+
InterpreterFrame.Pop();
27612759
}
27622760
#endif // FEATURE_INTERPRETER
27632761

src/coreclr/vm/stackwalk.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,9 @@ void StackFrameIterator::CommonCtor(Thread * pThread, PTR_Frame pFrame, ULONG32
989989
m_movedPastFirstExInfo = false;
990990
m_fFuncletNotSeen = false;
991991
m_fFoundFirstFunclet = false;
992+
#ifdef FEATURE_INTERPRETER
993+
m_walkingInterpreterFrames = false;
994+
#endif
992995
#if defined(RECORD_RESUMABLE_FRAME_SP)
993996
m_pvResumableFrameTargetSP = NULL;
994997
#endif
@@ -2896,6 +2899,33 @@ void StackFrameIterator::ProcessCurrentFrame(void)
28962899
sizeof(m_crawl.codeManState.stateBuf));
28972900
#endif // _DEBUG
28982901

2902+
#ifdef FEATURE_INTERPRETER
2903+
if (!m_crawl.isFrameless)
2904+
{
2905+
if (m_crawl.pFrame->GetFrameIdentifier() == FrameIdentifier::InterpreterFrame)
2906+
{
2907+
if (!m_walkingInterpreterFrames)
2908+
{
2909+
// We have hit the InterpreterFrame while we were not processing the interpreter frames.
2910+
// Switch to walking the underlying interpreted frames.
2911+
PTR_InterpMethodContextFrame pTOSInterpMethodContextFrame = ((PTR_InterpreterFrame)m_crawl.pFrame)->GetInterpMethodTopmostContextFrame();
2912+
PREGDISPLAY pRD = m_crawl.GetRegisterSet();
2913+
SetIP(pRD->pCurrentContext, (TADDR)pTOSInterpMethodContextFrame->ip);
2914+
SetSP(pRD->pCurrentContext, dac_cast<TADDR>(pTOSInterpMethodContextFrame));
2915+
pRD->pCurrentContext->ContextFlags = CONTEXT_CONTROL;
2916+
SyncRegDisplayToCurrentContext(pRD);
2917+
ProcessIp(GetControlPC(pRD));
2918+
m_walkingInterpreterFrames = m_crawl.isFrameless;
2919+
}
2920+
else
2921+
{
2922+
// We have finished walking the interpreted frames. Process the InterpreterFrame itself.
2923+
m_walkingInterpreterFrames = false;
2924+
}
2925+
}
2926+
}
2927+
#endif // FEATURE_INTERPRETER
2928+
28992929
if (m_crawl.isFrameless)
29002930
{
29012931
//------------------------------------------------------------------------

src/coreclr/vm/stackwalk.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,9 @@ class StackFrameIterator
767767
bool m_fFuncletNotSeen;
768768
// Indicates that the stack walk has moved past a funclet
769769
bool m_fFoundFirstFunclet;
770+
#ifdef FEATURE_INTERPRETER
771+
bool m_walkingInterpreterFrames;
772+
#endif // FEATURE_INTERPRETER
770773

771774
#if defined(RECORD_RESUMABLE_FRAME_SP)
772775
LPVOID m_pvResumableFrameTargetSP;

0 commit comments

Comments
 (0)