From 4c3764280dab0fcfe4b846b4de6ee8a71d21afbe Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Tue, 4 Feb 2025 14:35:45 -0800 Subject: [PATCH 01/17] Initial pass where names all changed --- src/coreclr/debug/daccess/daccess.cpp | 6 +- src/coreclr/debug/daccess/dacdbiimpl.cpp | 2 +- .../debug/daccess/dacdbiimplstackwalk.cpp | 36 +- src/coreclr/debug/daccess/request.cpp | 2 +- src/coreclr/debug/daccess/stack.cpp | 2 +- src/coreclr/debug/ee/controller.cpp | 36 +- src/coreclr/debug/ee/debugger.cpp | 261 +++++- src/coreclr/debug/ee/debugger.inl | 253 ------ src/coreclr/debug/ee/frameinfo.cpp | 58 +- src/coreclr/inc/daccess.h | 3 - src/coreclr/inc/vptr_list.h | 46 - src/coreclr/vm/FrameTypes.h | 63 ++ src/coreclr/vm/amd64/PInvokeStubs.asm | 4 +- src/coreclr/vm/amd64/asmconstants.h | 3 + src/coreclr/vm/amd64/cgenamd64.cpp | 22 +- src/coreclr/vm/arm/stubs.cpp | 16 +- src/coreclr/vm/arm64/stubs.cpp | 22 +- src/coreclr/vm/callsiteinspect.cpp | 10 +- src/coreclr/vm/clrtocomcall.cpp | 12 +- src/coreclr/vm/common.h | 2 +- src/coreclr/vm/comtoclrcall.cpp | 2 +- src/coreclr/vm/dllimport.cpp | 4 +- src/coreclr/vm/eedbginterfaceimpl.cpp | 2 +- src/coreclr/vm/eventtrace.cpp | 2 +- src/coreclr/vm/excep.cpp | 10 +- src/coreclr/vm/exceptionhandling.cpp | 44 +- src/coreclr/vm/frames.cpp | 327 +++++-- src/coreclr/vm/frames.h | 822 +++++++----------- src/coreclr/vm/gcenv.ee.common.cpp | 8 +- src/coreclr/vm/gcenv.ee.cpp | 2 +- src/coreclr/vm/i386/cgenx86.cpp | 42 +- src/coreclr/vm/i386/excepx86.cpp | 2 +- src/coreclr/vm/i386/jitinterfacex86.cpp | 2 +- src/coreclr/vm/loongarch64/stubs.cpp | 22 +- src/coreclr/vm/prestub.cpp | 6 +- src/coreclr/vm/riscv64/stubs.cpp | 22 +- src/coreclr/vm/stackwalk.cpp | 38 +- src/coreclr/vm/syncblk.cpp | 10 +- src/coreclr/vm/syncblk.inl | 2 +- src/coreclr/vm/threads.cpp | 16 +- src/coreclr/vm/threadsuspend.cpp | 11 +- src/coreclr/vm/virtualcallstub.cpp | 2 +- 42 files changed, 1099 insertions(+), 1158 deletions(-) create mode 100644 src/coreclr/vm/FrameTypes.h diff --git a/src/coreclr/debug/daccess/daccess.cpp b/src/coreclr/debug/daccess/daccess.cpp index 5deb0937c3acbd..694d20406834e9 100644 --- a/src/coreclr/debug/daccess/daccess.cpp +++ b/src/coreclr/debug/daccess/daccess.cpp @@ -5111,8 +5111,8 @@ ClrDataAccess::FollowStubStep( trace.InitForFramePush(CORDB_ADDRESS_TO_TADDR(inBuffer->u.addr)); DacGetThreadContext(thread, &localContext); thread->FillRegDisplay(®Disp, &localContext); - if (!thread->GetFrame()-> - TraceFrame(thread, + if (!Frame_TraceFrame(thread->GetFrame(), + thread, TRUE, &trace, ®Disp)) @@ -8043,7 +8043,7 @@ StackWalkAction DacStackReferenceWalker::Callback(CrawlFrame *pCF, VOID *pData) } else { - pFrame->GcScanRoots(gcctx->f, gcctx->sc); + Frame_GcScanRoots(pFrame, gcctx->f, gcctx->sc); } } } diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index eef3dc127b9206..20a867462e7e92 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -5644,7 +5644,7 @@ void DacDbiInterfaceImpl::GetContext(VMPTR_Thread vmThread, DT_CONTEXT * pContex Frame *frame = pThread->GetFrame(); while (frame != NULL && frame != FRAME_TOP) { - frame->UpdateRegDisplay(&tmpRd); + Frame_UpdateRegDisplay(frame, &tmpRd); if (GetRegdisplaySP(&tmpRd) != 0 && GetControlPC(&tmpRd) != 0) { UpdateContextFromRegDisp(&tmpRd, &tmpContext); diff --git a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp index 3f60dec6a9b1ad..771835d41cfaa4 100644 --- a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp +++ b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp @@ -536,7 +536,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread frameData.vmCurrentAppDomainToken.SetHostPtr(pAppDomain); - MethodDesc * pMD = pFrame->GetFunction(); + MethodDesc * pMD = Frame_GetFunction(pFrame); #if defined(FEATURE_COMINTEROP) if (frameData.stubFrame.frameType == STUBFRAME_U2M) { @@ -558,7 +558,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread // it. In this case, pMD will remain NULL. EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY { - if (pFrame->GetVTablePtr() == ComMethodFrame::GetMethodFrameVPtr()) + if (pFrame->GetType() == ::FrameType::ComMethodFrame) { ComMethodFrame * pCOMFrame = dac_cast(pFrame); PTR_VOID pUnkStackSlot = pCOMFrame->GetPointerToArguments(); @@ -1111,26 +1111,26 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra { CorDebugInternalFrameType resultType = STUBFRAME_NONE; - Frame::ETransitionType tt = pFrame->GetTransitionType(); - Frame::Interception it = pFrame->GetInterception(); - int ft = pFrame->GetFrameType(); + ETransitionType tt = Frame_GetTransitionType(pFrame); + Interception it = Frame_GetInterception(pFrame); + int ft = Frame_GetFrameType(pFrame); switch (tt) { - case Frame::TT_NONE: - if (it == Frame::INTERCEPTION_CLASS_INIT) + case TT_NONE: + if (it == INTERCEPTION_CLASS_INIT) { resultType = STUBFRAME_CLASS_INIT; } - else if (it == Frame::INTERCEPTION_EXCEPTION) + else if (it == INTERCEPTION_EXCEPTION) { resultType = STUBFRAME_EXCEPTION; } - else if (it == Frame::INTERCEPTION_SECURITY) + else if (it == INTERCEPTION_SECURITY) { resultType = STUBFRAME_SECURITY; } - else if (it == Frame::INTERCEPTION_PRESTUB) + else if (it == INTERCEPTION_PRESTUB) { resultType = STUBFRAME_JIT_COMPILATION; } @@ -1142,7 +1142,7 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra } else if (ft == Frame::TYPE_EXIT) { - if ((pFrame->GetVTablePtr() != InlinedCallFrame::GetMethodFrameVPtr()) || + if ((pFrame->GetType() != ::FrameType::InlinedCallFrame) || InlinedCallFrame::FrameHasActiveCall(pFrame)) { resultType = STUBFRAME_M2U; @@ -1151,11 +1151,11 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra } break; - case Frame::TT_M2U: + case TT_M2U: // Refer to the comment in DebuggerWalkStackProc() for StubDispatchFrame. - if (pFrame->GetVTablePtr() != StubDispatchFrame::GetMethodFrameVPtr()) + if (pFrame->GetType() != ::FrameType::StubDispatchFrame) { - if (it == Frame::INTERCEPTION_SECURITY) + if (it == INTERCEPTION_SECURITY) { resultType = STUBFRAME_SECURITY; } @@ -1166,16 +1166,16 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra } break; - case Frame::TT_U2M: + case TT_U2M: resultType = STUBFRAME_U2M; break; - case Frame::TT_AppDomain: + case TT_AppDomain: resultType = STUBFRAME_APPDOMAIN_TRANSITION; break; - case Frame::TT_InternalCall: - if (it == Frame::INTERCEPTION_EXCEPTION) + case TT_InternalCall: + if (it == INTERCEPTION_EXCEPTION) { resultType = STUBFRAME_EXCEPTION; } diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp index 7a07a8c0f6c3c1..81d41acc1ac8e9 100644 --- a/src/coreclr/debug/daccess/request.cpp +++ b/src/coreclr/debug/daccess/request.cpp @@ -1393,7 +1393,7 @@ ClrDataAccess::GetMethodDescPtrFromFrame(CLRDATA_ADDRESS frameAddr, CLRDATA_ADDR SOSDacEnter(); Frame *pFrame = PTR_Frame(TO_TADDR(frameAddr)); - CLRDATA_ADDRESS methodDescAddr = HOST_CDADDR(pFrame->GetFunction()); + CLRDATA_ADDRESS methodDescAddr = HOST_CDADDR(Frame_GetFunction(pFrame)); if ((methodDescAddr == (CLRDATA_ADDRESS)NULL) || !DacValidateMD(PTR_MethodDesc(TO_TADDR(methodDescAddr)))) { hr = E_INVALIDARG; diff --git a/src/coreclr/debug/daccess/stack.cpp b/src/coreclr/debug/daccess/stack.cpp index a0dc074ae1f67a..516bc0ba29ed4b 100644 --- a/src/coreclr/debug/daccess/stack.cpp +++ b/src/coreclr/debug/daccess/stack.cpp @@ -555,7 +555,7 @@ ClrDataStackWalk::RawGetFrameType( if (detailedType) { - if (m_frameIter.m_crawl.GetFrame() && m_frameIter.m_crawl.GetFrame()->GetFrameAttribs() & Frame::FRAME_ATTR_EXCEPTION) + if (m_frameIter.m_crawl.GetFrame() && Frame_GetFrameAttribs(m_frameIter.m_crawl.GetFrame()) & Frame::FRAME_ATTR_EXCEPTION) *detailedType = CLRDATA_DETFRAME_EXCEPTION_FILTER; else *detailedType = CLRDATA_DETFRAME_UNRECOGNIZED; diff --git a/src/coreclr/debug/ee/controller.cpp b/src/coreclr/debug/ee/controller.cpp index ca63a24170d127..7bd542a4cc9ee4 100644 --- a/src/coreclr/debug/ee/controller.cpp +++ b/src/coreclr/debug/ee/controller.cpp @@ -3774,7 +3774,7 @@ bool DebuggerController::DispatchTraceCall(Thread *thread, { // Make sure that the frame pointer of the active frame is actually // the address of an exit frame. - _ASSERTE( (static_cast(info.m_activeFrame.fp.GetSPValue()))->GetFrameType() + _ASSERTE( Frame_GetFrameType(static_cast(info.m_activeFrame.fp.GetSPValue())) == Frame::TYPE_EXIT ); _ASSERTE(!info.GetReturnFrame().HasChainMarker()); fpToCheck = info.GetReturnFrame().fp; @@ -5360,12 +5360,12 @@ bool DebuggerStepper::DetectHandleInterceptors(ControllerStackInfo *info) { if (info->m_activeFrame.frame != NULL && info->m_activeFrame.frame != FRAME_TOP && - info->m_activeFrame.frame->GetInterception() != Frame::INTERCEPTION_NONE) + Frame_GetInterception(info->m_activeFrame.frame) != INTERCEPTION_NONE) { - if (!((CorDebugIntercept)info->m_activeFrame.frame->GetInterception() & Frame::Interception(m_rgfInterceptStop))) + if (!((CorDebugIntercept)Frame_GetInterception(info->m_activeFrame.frame) & Interception(m_rgfInterceptStop))) { LOG((LF_CORDB,LL_INFO10000,"DS::DHI: Stepping out b/c of excluded frame type:0x%x\n", - info->m_activeFrame.frame->GetInterception())); + Frame_GetInterception(info->m_activeFrame.frame))); fAttemptStepOut = true; } @@ -5381,7 +5381,7 @@ bool DebuggerStepper::DetectHandleInterceptors(ControllerStackInfo *info) (info->HasReturnFrame() && info->GetReturnFrame().frame != NULL && info->GetReturnFrame().frame != FRAME_TOP && - info->GetReturnFrame().frame->GetInterception() != Frame::INTERCEPTION_NONE)) + Frame_GetInterception(info->GetReturnFrame().frame) != INTERCEPTION_NONE)) { if (m_reason == STEP_EXCEPTION_FILTER) { @@ -5389,16 +5389,16 @@ bool DebuggerStepper::DetectHandleInterceptors(ControllerStackInfo *info) // insert an ExceptionFrame, and hence info->GetReturnFrame().frame->GetInterception() // will not be accurate. Hence we use m_reason instead - if (!(Frame::INTERCEPTION_EXCEPTION & Frame::Interception(m_rgfInterceptStop))) + if (!(INTERCEPTION_EXCEPTION & Interception(m_rgfInterceptStop))) { LOG((LF_CORDB,LL_INFO10000,"DS::DHI: Stepping out b/c of excluded INTERCEPTION_EXCEPTION\n")); fAttemptStepOut = true; } } - else if (!(info->GetReturnFrame().frame->GetInterception() & Frame::Interception(m_rgfInterceptStop))) + else if (!(Frame_GetInterception(info->GetReturnFrame().frame) & Interception(m_rgfInterceptStop))) { LOG((LF_CORDB,LL_INFO10000,"DS::DHI: Stepping out b/c of excluded return frame type:0x%x\n", - info->GetReturnFrame().frame->GetInterception())); + Frame_GetInterception(info->GetReturnFrame().frame))); fAttemptStepOut = true; } @@ -6600,7 +6600,7 @@ void DebuggerStepper::TrapStepOut(ControllerStackInfo *info, bool fForceTraditio // stepComplete message to the right side. break; } - else if (info->m_activeFrame.frame->GetFrameType() == Frame::TYPE_FUNC_EVAL) + else if (Frame_GetFrameType(info->m_activeFrame.frame) == Frame::TYPE_FUNC_EVAL) { // Note: we treat walking off the top of the stack and // walking off the top of a func eval the same way, @@ -6613,8 +6613,8 @@ void DebuggerStepper::TrapStepOut(ControllerStackInfo *info, bool fForceTraditio m_reason = STEP_EXIT; break; } - else if (info->m_activeFrame.frame->GetFrameType() == Frame::TYPE_SECURITY && - info->m_activeFrame.frame->GetInterception() == Frame::INTERCEPTION_NONE) + else if (Frame_GetFrameType(info->m_activeFrame.frame) == Frame::TYPE_SECURITY && + Frame_GetInterception(info->m_activeFrame.frame) == INTERCEPTION_NONE) { // If we're stepping out of something that was protected by (declarative) security, // the security subsystem may leave a frame on the stack to cache it's computation. @@ -8211,12 +8211,12 @@ void DebuggerJMCStepper::TriggerMethodEnter(Thread * thread, // The intercept value in EE Frame's is a 0-based enumeration (not a bitfield). // The intercept value for ICorDebug is a bitfied. //----------------------------------------------------------------------------- -CorDebugIntercept ConvertFrameBitsToDbg(Frame::Interception i) +CorDebugIntercept ConvertFrameBitsToDbg(Interception i) { - _ASSERTE(i >= 0 && i < Frame::INTERCEPTION_COUNT); + _ASSERTE(i >= 0 && i < INTERCEPTION_COUNT); // Since the ee frame is a 0-based enum, we can just use a map. - const CorDebugIntercept map[Frame::INTERCEPTION_COUNT] = + const CorDebugIntercept map[INTERCEPTION_COUNT] = { // ICorDebug EE Frame INTERCEPT_NONE, // INTERCEPTION_NONE, @@ -8299,12 +8299,12 @@ class InterceptorStackInfo // If there's an interceptor frame here, then set those // bits in our bitfield. - Frame::Interception i = Frame::INTERCEPTION_NONE; + Interception i = INTERCEPTION_NONE; Frame * pFrame = pInfo->frame; if ((pFrame != NULL) && (pFrame != FRAME_TOP)) { - i = pFrame->GetInterception(); - if (i != Frame::INTERCEPTION_NONE) + i = Frame_GetInterception(pFrame); + if (i != INTERCEPTION_NONE) { pThis->m_bits |= (int) ConvertFrameBitsToDbg(i); } @@ -8452,7 +8452,7 @@ TP_RESULT DebuggerThreadStarter::TriggerPatch(DebuggerControllerPatch *patch, CONTRACT_VIOLATION(GCViolation); traceOk = g_pEEInterface->TraceManager(thread, patch->trace.GetStubManager(), &trace, context, &dummy); } - else if ((patch->trace.GetTraceType() == TRACE_FRAME_PUSH) && (thread->GetFrame()->IsTransitionToNativeFrame())) + else if ((patch->trace.GetTraceType() == TRACE_FRAME_PUSH) && (Frame_IsTransitionToNativeFrame(thread->GetFrame()))) { // If we've got a frame that is transitioning to native, there's no reason to try to keep tracing. So we // bail early and save ourselves some effort. This also works around a problem where we deadlock trying to diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 6c494e29922628..f677dcbd08d6fd 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -7946,8 +7946,8 @@ LONG Debugger::NotifyOfCHFFilter(EXCEPTION_POINTERS* pExceptionPointers, PVOID p // Calling a virtual method will enforce that we have a valid Frame. ;) // If we got passed in a random catch address, then when we cast to a Frame // the vtable pointer will be bogus and this call will AV. - Frame::ETransitionType e; - e = pFrame->GetTransitionType(); + ETransitionType e; + e = Frame_GetTransitionType(pFrame); } #endif } @@ -12552,7 +12552,7 @@ bool Debugger::IsThreadAtSafePlaceWorker(Thread *thread) if (ISREDIRECTEDTHREAD(thread)) { - thread->GetFrame()->UpdateRegDisplay(&rd); + Frame_UpdateRegDisplay(thread->GetFrame(), &rd); } } @@ -16669,7 +16669,7 @@ Debugger::EnumMemoryRegionsIfFuncEvalFrame(CLRDataEnumMemoryFlags flags, Frame * { SUPPORTS_DAC; - if ((pFrame != NULL) && (pFrame->GetFrameType() == Frame::TYPE_FUNC_EVAL)) + if ((pFrame != NULL) && (Frame_GetFrameType(pFrame) == Frame::TYPE_FUNC_EVAL)) { FuncEvalFrame * pFEF = dac_cast(pFrame); DebuggerEval * pDE = pFEF->GetDebuggerEval(); @@ -16799,4 +16799,257 @@ void Debugger::ExternalMethodFixupNextStep(PCODE address) } #endif //DACCESS_COMPILE +unsigned FuncEvalFrame::GetFrameAttribs_Impl(void) +{ + LIMITED_METHOD_DAC_CONTRACT; + + if (GetDebuggerEval()->m_evalDuringException) + { + return FRAME_ATTR_NONE; + } + else + { + return FRAME_ATTR_RESUMABLE; // Treat the next frame as the top frame. + } +} + +TADDR FuncEvalFrame::GetReturnAddressPtr_Impl() +{ + LIMITED_METHOD_DAC_CONTRACT; + + if (GetDebuggerEval()->m_evalDuringException) + { + return (TADDR)NULL; + } + else + { + return PTR_HOST_MEMBER_TADDR(FuncEvalFrame, this, m_ReturnAddress); + } +} + +// +// This updates the register display for a FuncEvalFrame. +// +void FuncEvalFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) +{ + SUPPORTS_DAC; + DebuggerEval * pDE = GetDebuggerEval(); + + // No context to update if we're doing a func eval from within exception processing. + if (pDE->m_evalDuringException) + { + return; + } + +#ifndef FEATURE_EH_FUNCLETS + // Reset pContext; it's only valid for active (top-most) frame. + pRD->pContext = NULL; +#endif // !FEATURE_EH_FUNCLETS + + +#ifdef TARGET_X86 + // Update all registers in the reg display from the CONTEXT we stored when the thread was hijacked for this func + // eval. We have to update all registers, not just the callee saved registers, because we can hijack a thread at any + // point for a func eval, not just at a call site. + pRD->SetEdiLocation(&(pDE->m_context.Edi)); + pRD->SetEsiLocation(&(pDE->m_context.Esi)); + pRD->SetEbxLocation(&(pDE->m_context.Ebx)); + pRD->SetEdxLocation(&(pDE->m_context.Edx)); + pRD->SetEcxLocation(&(pDE->m_context.Ecx)); + pRD->SetEaxLocation(&(pDE->m_context.Eax)); + pRD->SetEbpLocation(&(pDE->m_context.Ebp)); + pRD->PCTAddr = GetReturnAddressPtr(); + +#ifdef FEATURE_EH_FUNCLETS + + pRD->IsCallerContextValid = FALSE; + pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. + + pRD->pCurrentContext->Eip = *PTR_PCODE(pRD->PCTAddr); + pRD->pCurrentContext->Esp = (DWORD)GetSP(&pDE->m_context); + + SyncRegDisplayToCurrentContext(pRD); + +#else // FEATURE_EH_FUNCLETS + + pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr); + pRD->SP = (DWORD)GetSP(&pDE->m_context); + +#endif // FEATURE_EH_FUNCLETS + +#elif defined(TARGET_AMD64) + pRD->IsCallerContextValid = FALSE; + pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary. + + memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(CONTEXT)); + + pRD->pCurrentContextPointers->Rax = &(pDE->m_context.Rax); + pRD->pCurrentContextPointers->Rcx = &(pDE->m_context.Rcx); + pRD->pCurrentContextPointers->Rdx = &(pDE->m_context.Rdx); + pRD->pCurrentContextPointers->R8 = &(pDE->m_context.R8); + pRD->pCurrentContextPointers->R9 = &(pDE->m_context.R9); + pRD->pCurrentContextPointers->R10 = &(pDE->m_context.R10); + pRD->pCurrentContextPointers->R11 = &(pDE->m_context.R11); + + pRD->pCurrentContextPointers->Rbx = &(pDE->m_context.Rbx); + pRD->pCurrentContextPointers->Rsi = &(pDE->m_context.Rsi); + pRD->pCurrentContextPointers->Rdi = &(pDE->m_context.Rdi); + pRD->pCurrentContextPointers->Rbp = &(pDE->m_context.Rbp); + pRD->pCurrentContextPointers->R12 = &(pDE->m_context.R12); + pRD->pCurrentContextPointers->R13 = &(pDE->m_context.R13); + pRD->pCurrentContextPointers->R14 = &(pDE->m_context.R14); + pRD->pCurrentContextPointers->R15 = &(pDE->m_context.R15); + + // SyncRegDisplayToCurrentContext() sets the pRD->SP and pRD->ControlPC on AMD64. + SyncRegDisplayToCurrentContext(pRD); + +#elif defined(TARGET_ARM) + pRD->IsCallerContextValid = FALSE; + pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary. + + memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT)); + + pRD->pCurrentContextPointers->R4 = &(pDE->m_context.R4); + pRD->pCurrentContextPointers->R5 = &(pDE->m_context.R5); + pRD->pCurrentContextPointers->R6 = &(pDE->m_context.R6); + pRD->pCurrentContextPointers->R7 = &(pDE->m_context.R7); + pRD->pCurrentContextPointers->R8 = &(pDE->m_context.R8); + pRD->pCurrentContextPointers->R9 = &(pDE->m_context.R9); + pRD->pCurrentContextPointers->R10 = &(pDE->m_context.R10); + pRD->pCurrentContextPointers->R11 = &(pDE->m_context.R11); + pRD->pCurrentContextPointers->Lr = &(pDE->m_context.Lr); + + pRD->volatileCurrContextPointers.R0 = &(pDE->m_context.R0); + pRD->volatileCurrContextPointers.R1 = &(pDE->m_context.R1); + pRD->volatileCurrContextPointers.R2 = &(pDE->m_context.R2); + pRD->volatileCurrContextPointers.R3 = &(pDE->m_context.R3); + pRD->volatileCurrContextPointers.R12 = &(pDE->m_context.R12); + + SyncRegDisplayToCurrentContext(pRD); + +#elif defined(TARGET_ARM64) + pRD->IsCallerContextValid = FALSE; + pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary. + + memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT)); + + pRD->pCurrentContextPointers->X19 = &(pDE->m_context.X19); + pRD->pCurrentContextPointers->X20 = &(pDE->m_context.X20); + pRD->pCurrentContextPointers->X21 = &(pDE->m_context.X21); + pRD->pCurrentContextPointers->X22 = &(pDE->m_context.X22); + pRD->pCurrentContextPointers->X23 = &(pDE->m_context.X23); + pRD->pCurrentContextPointers->X24 = &(pDE->m_context.X24); + pRD->pCurrentContextPointers->X25 = &(pDE->m_context.X25); + pRD->pCurrentContextPointers->X26 = &(pDE->m_context.X26); + pRD->pCurrentContextPointers->X27 = &(pDE->m_context.X27); + pRD->pCurrentContextPointers->X28 = &(pDE->m_context.X28); + pRD->pCurrentContextPointers->Lr = &(pDE->m_context.Lr); + pRD->pCurrentContextPointers->Fp = &(pDE->m_context.Fp); + + pRD->volatileCurrContextPointers.X0 = &(pDE->m_context.X0); + pRD->volatileCurrContextPointers.X1 = &(pDE->m_context.X1); + pRD->volatileCurrContextPointers.X2 = &(pDE->m_context.X2); + pRD->volatileCurrContextPointers.X3 = &(pDE->m_context.X3); + pRD->volatileCurrContextPointers.X4 = &(pDE->m_context.X4); + pRD->volatileCurrContextPointers.X5 = &(pDE->m_context.X5); + pRD->volatileCurrContextPointers.X6 = &(pDE->m_context.X6); + pRD->volatileCurrContextPointers.X7 = &(pDE->m_context.X7); + pRD->volatileCurrContextPointers.X8 = &(pDE->m_context.X8); + pRD->volatileCurrContextPointers.X9 = &(pDE->m_context.X9); + pRD->volatileCurrContextPointers.X10 = &(pDE->m_context.X10); + pRD->volatileCurrContextPointers.X11 = &(pDE->m_context.X11); + pRD->volatileCurrContextPointers.X12 = &(pDE->m_context.X12); + pRD->volatileCurrContextPointers.X13 = &(pDE->m_context.X13); + pRD->volatileCurrContextPointers.X14 = &(pDE->m_context.X14); + pRD->volatileCurrContextPointers.X15 = &(pDE->m_context.X15); + pRD->volatileCurrContextPointers.X16 = &(pDE->m_context.X16); + pRD->volatileCurrContextPointers.X17 = &(pDE->m_context.X17); + + SyncRegDisplayToCurrentContext(pRD); +#elif defined(TARGET_RISCV64) + pRD->IsCallerContextValid = FALSE; + pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary. + + memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT)); + + pRD->pCurrentContextPointers->S1 = &(pDE->m_context.S1); + pRD->pCurrentContextPointers->S2 = &(pDE->m_context.S2); + pRD->pCurrentContextPointers->S3 = &(pDE->m_context.S3); + pRD->pCurrentContextPointers->S4 = &(pDE->m_context.S4); + pRD->pCurrentContextPointers->S5 = &(pDE->m_context.S5); + pRD->pCurrentContextPointers->S6 = &(pDE->m_context.S6); + pRD->pCurrentContextPointers->S7 = &(pDE->m_context.S7); + pRD->pCurrentContextPointers->S8 = &(pDE->m_context.S8); + pRD->pCurrentContextPointers->S9 = &(pDE->m_context.S9); + pRD->pCurrentContextPointers->S10 = &(pDE->m_context.S10); + pRD->pCurrentContextPointers->S11 = &(pDE->m_context.S11); + pRD->pCurrentContextPointers->Fp = &(pDE->m_context.Fp); + pRD->pCurrentContextPointers->Gp = &(pDE->m_context.Gp); + pRD->pCurrentContextPointers->Tp = &(pDE->m_context.Tp); + pRD->pCurrentContextPointers->Ra = &(pDE->m_context.Ra); + + pRD->volatileCurrContextPointers.R0 = &(pDE->m_context.R0); + pRD->volatileCurrContextPointers.A0 = &(pDE->m_context.A0); + pRD->volatileCurrContextPointers.A1 = &(pDE->m_context.A1); + pRD->volatileCurrContextPointers.A2 = &(pDE->m_context.A2); + pRD->volatileCurrContextPointers.A3 = &(pDE->m_context.A3); + pRD->volatileCurrContextPointers.A4 = &(pDE->m_context.A4); + pRD->volatileCurrContextPointers.A5 = &(pDE->m_context.A5); + pRD->volatileCurrContextPointers.A6 = &(pDE->m_context.A6); + pRD->volatileCurrContextPointers.A7 = &(pDE->m_context.A7); + pRD->volatileCurrContextPointers.T0 = &(pDE->m_context.T0); + pRD->volatileCurrContextPointers.T1 = &(pDE->m_context.T1); + pRD->volatileCurrContextPointers.T2 = &(pDE->m_context.T2); + pRD->volatileCurrContextPointers.T3 = &(pDE->m_context.T3); + pRD->volatileCurrContextPointers.T4 = &(pDE->m_context.T4); + pRD->volatileCurrContextPointers.T5 = &(pDE->m_context.T5); + pRD->volatileCurrContextPointers.T6 = &(pDE->m_context.T6); + + SyncRegDisplayToCurrentContext(pRD); +#elif defined(TARGET_LOONGARCH64) + pRD->IsCallerContextValid = FALSE; + pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary. + + memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT)); + + pRD->pCurrentContextPointers->S0 = &(pDE->m_context.S0); + pRD->pCurrentContextPointers->S1 = &(pDE->m_context.S1); + pRD->pCurrentContextPointers->S2 = &(pDE->m_context.S2); + pRD->pCurrentContextPointers->S3 = &(pDE->m_context.S3); + pRD->pCurrentContextPointers->S4 = &(pDE->m_context.S4); + pRD->pCurrentContextPointers->S5 = &(pDE->m_context.S5); + pRD->pCurrentContextPointers->S6 = &(pDE->m_context.S6); + pRD->pCurrentContextPointers->S7 = &(pDE->m_context.S7); + pRD->pCurrentContextPointers->S8 = &(pDE->m_context.S8); + pRD->pCurrentContextPointers->Tp = &(pDE->m_context.Tp); + pRD->pCurrentContextPointers->Fp = &(pDE->m_context.Fp); + pRD->pCurrentContextPointers->Ra = &(pDE->m_context.Ra); + + pRD->volatileCurrContextPointers.R0 = &(pDE->m_context.R0); + pRD->volatileCurrContextPointers.A0 = &(pDE->m_context.A0); + pRD->volatileCurrContextPointers.A1 = &(pDE->m_context.A1); + pRD->volatileCurrContextPointers.A2 = &(pDE->m_context.A2); + pRD->volatileCurrContextPointers.A3 = &(pDE->m_context.A3); + pRD->volatileCurrContextPointers.A4 = &(pDE->m_context.A4); + pRD->volatileCurrContextPointers.A5 = &(pDE->m_context.A5); + pRD->volatileCurrContextPointers.A6 = &(pDE->m_context.A6); + pRD->volatileCurrContextPointers.A7 = &(pDE->m_context.A7); + pRD->volatileCurrContextPointers.T0 = &(pDE->m_context.T0); + pRD->volatileCurrContextPointers.T1 = &(pDE->m_context.T1); + pRD->volatileCurrContextPointers.T2 = &(pDE->m_context.T2); + pRD->volatileCurrContextPointers.T3 = &(pDE->m_context.T3); + pRD->volatileCurrContextPointers.T4 = &(pDE->m_context.T4); + pRD->volatileCurrContextPointers.T5 = &(pDE->m_context.T5); + pRD->volatileCurrContextPointers.T6 = &(pDE->m_context.T6); + pRD->volatileCurrContextPointers.T7 = &(pDE->m_context.T7); + pRD->volatileCurrContextPointers.T8 = &(pDE->m_context.T8); + pRD->volatileCurrContextPointers.X0 = &(pDE->m_context.X0); + + SyncRegDisplayToCurrentContext(pRD); + +#else + PORTABILITY_ASSERT("FuncEvalFrame::UpdateRegDisplay is not implemented on this platform."); +#endif +} + #endif //DEBUGGING_SUPPORTED diff --git a/src/coreclr/debug/ee/debugger.inl b/src/coreclr/debug/ee/debugger.inl index 7d1ad99c518704..4f69164a292f9f 100644 --- a/src/coreclr/debug/ee/debugger.inl +++ b/src/coreclr/debug/ee/debugger.inl @@ -132,257 +132,4 @@ inline DebuggerEval * FuncEvalFrame::GetDebuggerEval() return m_pDebuggerEval; } -inline unsigned FuncEvalFrame::GetFrameAttribs(void) -{ - LIMITED_METHOD_DAC_CONTRACT; - - if (GetDebuggerEval()->m_evalDuringException) - { - return FRAME_ATTR_NONE; - } - else - { - return FRAME_ATTR_RESUMABLE; // Treat the next frame as the top frame. - } -} - -inline TADDR FuncEvalFrame::GetReturnAddressPtr() -{ - LIMITED_METHOD_DAC_CONTRACT; - - if (GetDebuggerEval()->m_evalDuringException) - { - return (TADDR)NULL; - } - else - { - return PTR_HOST_MEMBER_TADDR(FuncEvalFrame, this, m_ReturnAddress); - } -} - -// -// This updates the register display for a FuncEvalFrame. -// -inline void FuncEvalFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) -{ - SUPPORTS_DAC; - DebuggerEval * pDE = GetDebuggerEval(); - - // No context to update if we're doing a func eval from within exception processing. - if (pDE->m_evalDuringException) - { - return; - } - -#ifndef FEATURE_EH_FUNCLETS - // Reset pContext; it's only valid for active (top-most) frame. - pRD->pContext = NULL; -#endif // !FEATURE_EH_FUNCLETS - - -#ifdef TARGET_X86 - // Update all registers in the reg display from the CONTEXT we stored when the thread was hijacked for this func - // eval. We have to update all registers, not just the callee saved registers, because we can hijack a thread at any - // point for a func eval, not just at a call site. - pRD->SetEdiLocation(&(pDE->m_context.Edi)); - pRD->SetEsiLocation(&(pDE->m_context.Esi)); - pRD->SetEbxLocation(&(pDE->m_context.Ebx)); - pRD->SetEdxLocation(&(pDE->m_context.Edx)); - pRD->SetEcxLocation(&(pDE->m_context.Ecx)); - pRD->SetEaxLocation(&(pDE->m_context.Eax)); - pRD->SetEbpLocation(&(pDE->m_context.Ebp)); - pRD->PCTAddr = GetReturnAddressPtr(); - -#ifdef FEATURE_EH_FUNCLETS - - pRD->IsCallerContextValid = FALSE; - pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. - - pRD->pCurrentContext->Eip = *PTR_PCODE(pRD->PCTAddr); - pRD->pCurrentContext->Esp = (DWORD)GetSP(&pDE->m_context); - - SyncRegDisplayToCurrentContext(pRD); - -#else // FEATURE_EH_FUNCLETS - - pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr); - pRD->SP = (DWORD)GetSP(&pDE->m_context); - -#endif // FEATURE_EH_FUNCLETS - -#elif defined(TARGET_AMD64) - pRD->IsCallerContextValid = FALSE; - pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary. - - memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(CONTEXT)); - - pRD->pCurrentContextPointers->Rax = &(pDE->m_context.Rax); - pRD->pCurrentContextPointers->Rcx = &(pDE->m_context.Rcx); - pRD->pCurrentContextPointers->Rdx = &(pDE->m_context.Rdx); - pRD->pCurrentContextPointers->R8 = &(pDE->m_context.R8); - pRD->pCurrentContextPointers->R9 = &(pDE->m_context.R9); - pRD->pCurrentContextPointers->R10 = &(pDE->m_context.R10); - pRD->pCurrentContextPointers->R11 = &(pDE->m_context.R11); - - pRD->pCurrentContextPointers->Rbx = &(pDE->m_context.Rbx); - pRD->pCurrentContextPointers->Rsi = &(pDE->m_context.Rsi); - pRD->pCurrentContextPointers->Rdi = &(pDE->m_context.Rdi); - pRD->pCurrentContextPointers->Rbp = &(pDE->m_context.Rbp); - pRD->pCurrentContextPointers->R12 = &(pDE->m_context.R12); - pRD->pCurrentContextPointers->R13 = &(pDE->m_context.R13); - pRD->pCurrentContextPointers->R14 = &(pDE->m_context.R14); - pRD->pCurrentContextPointers->R15 = &(pDE->m_context.R15); - - // SyncRegDisplayToCurrentContext() sets the pRD->SP and pRD->ControlPC on AMD64. - SyncRegDisplayToCurrentContext(pRD); - -#elif defined(TARGET_ARM) - pRD->IsCallerContextValid = FALSE; - pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary. - - memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT)); - - pRD->pCurrentContextPointers->R4 = &(pDE->m_context.R4); - pRD->pCurrentContextPointers->R5 = &(pDE->m_context.R5); - pRD->pCurrentContextPointers->R6 = &(pDE->m_context.R6); - pRD->pCurrentContextPointers->R7 = &(pDE->m_context.R7); - pRD->pCurrentContextPointers->R8 = &(pDE->m_context.R8); - pRD->pCurrentContextPointers->R9 = &(pDE->m_context.R9); - pRD->pCurrentContextPointers->R10 = &(pDE->m_context.R10); - pRD->pCurrentContextPointers->R11 = &(pDE->m_context.R11); - pRD->pCurrentContextPointers->Lr = &(pDE->m_context.Lr); - - pRD->volatileCurrContextPointers.R0 = &(pDE->m_context.R0); - pRD->volatileCurrContextPointers.R1 = &(pDE->m_context.R1); - pRD->volatileCurrContextPointers.R2 = &(pDE->m_context.R2); - pRD->volatileCurrContextPointers.R3 = &(pDE->m_context.R3); - pRD->volatileCurrContextPointers.R12 = &(pDE->m_context.R12); - - SyncRegDisplayToCurrentContext(pRD); - -#elif defined(TARGET_ARM64) - pRD->IsCallerContextValid = FALSE; - pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary. - - memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT)); - - pRD->pCurrentContextPointers->X19 = &(pDE->m_context.X19); - pRD->pCurrentContextPointers->X20 = &(pDE->m_context.X20); - pRD->pCurrentContextPointers->X21 = &(pDE->m_context.X21); - pRD->pCurrentContextPointers->X22 = &(pDE->m_context.X22); - pRD->pCurrentContextPointers->X23 = &(pDE->m_context.X23); - pRD->pCurrentContextPointers->X24 = &(pDE->m_context.X24); - pRD->pCurrentContextPointers->X25 = &(pDE->m_context.X25); - pRD->pCurrentContextPointers->X26 = &(pDE->m_context.X26); - pRD->pCurrentContextPointers->X27 = &(pDE->m_context.X27); - pRD->pCurrentContextPointers->X28 = &(pDE->m_context.X28); - pRD->pCurrentContextPointers->Lr = &(pDE->m_context.Lr); - pRD->pCurrentContextPointers->Fp = &(pDE->m_context.Fp); - - pRD->volatileCurrContextPointers.X0 = &(pDE->m_context.X0); - pRD->volatileCurrContextPointers.X1 = &(pDE->m_context.X1); - pRD->volatileCurrContextPointers.X2 = &(pDE->m_context.X2); - pRD->volatileCurrContextPointers.X3 = &(pDE->m_context.X3); - pRD->volatileCurrContextPointers.X4 = &(pDE->m_context.X4); - pRD->volatileCurrContextPointers.X5 = &(pDE->m_context.X5); - pRD->volatileCurrContextPointers.X6 = &(pDE->m_context.X6); - pRD->volatileCurrContextPointers.X7 = &(pDE->m_context.X7); - pRD->volatileCurrContextPointers.X8 = &(pDE->m_context.X8); - pRD->volatileCurrContextPointers.X9 = &(pDE->m_context.X9); - pRD->volatileCurrContextPointers.X10 = &(pDE->m_context.X10); - pRD->volatileCurrContextPointers.X11 = &(pDE->m_context.X11); - pRD->volatileCurrContextPointers.X12 = &(pDE->m_context.X12); - pRD->volatileCurrContextPointers.X13 = &(pDE->m_context.X13); - pRD->volatileCurrContextPointers.X14 = &(pDE->m_context.X14); - pRD->volatileCurrContextPointers.X15 = &(pDE->m_context.X15); - pRD->volatileCurrContextPointers.X16 = &(pDE->m_context.X16); - pRD->volatileCurrContextPointers.X17 = &(pDE->m_context.X17); - - SyncRegDisplayToCurrentContext(pRD); -#elif defined(TARGET_RISCV64) - pRD->IsCallerContextValid = FALSE; - pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary. - - memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT)); - - pRD->pCurrentContextPointers->S1 = &(pDE->m_context.S1); - pRD->pCurrentContextPointers->S2 = &(pDE->m_context.S2); - pRD->pCurrentContextPointers->S3 = &(pDE->m_context.S3); - pRD->pCurrentContextPointers->S4 = &(pDE->m_context.S4); - pRD->pCurrentContextPointers->S5 = &(pDE->m_context.S5); - pRD->pCurrentContextPointers->S6 = &(pDE->m_context.S6); - pRD->pCurrentContextPointers->S7 = &(pDE->m_context.S7); - pRD->pCurrentContextPointers->S8 = &(pDE->m_context.S8); - pRD->pCurrentContextPointers->S9 = &(pDE->m_context.S9); - pRD->pCurrentContextPointers->S10 = &(pDE->m_context.S10); - pRD->pCurrentContextPointers->S11 = &(pDE->m_context.S11); - pRD->pCurrentContextPointers->Fp = &(pDE->m_context.Fp); - pRD->pCurrentContextPointers->Gp = &(pDE->m_context.Gp); - pRD->pCurrentContextPointers->Tp = &(pDE->m_context.Tp); - pRD->pCurrentContextPointers->Ra = &(pDE->m_context.Ra); - - pRD->volatileCurrContextPointers.R0 = &(pDE->m_context.R0); - pRD->volatileCurrContextPointers.A0 = &(pDE->m_context.A0); - pRD->volatileCurrContextPointers.A1 = &(pDE->m_context.A1); - pRD->volatileCurrContextPointers.A2 = &(pDE->m_context.A2); - pRD->volatileCurrContextPointers.A3 = &(pDE->m_context.A3); - pRD->volatileCurrContextPointers.A4 = &(pDE->m_context.A4); - pRD->volatileCurrContextPointers.A5 = &(pDE->m_context.A5); - pRD->volatileCurrContextPointers.A6 = &(pDE->m_context.A6); - pRD->volatileCurrContextPointers.A7 = &(pDE->m_context.A7); - pRD->volatileCurrContextPointers.T0 = &(pDE->m_context.T0); - pRD->volatileCurrContextPointers.T1 = &(pDE->m_context.T1); - pRD->volatileCurrContextPointers.T2 = &(pDE->m_context.T2); - pRD->volatileCurrContextPointers.T3 = &(pDE->m_context.T3); - pRD->volatileCurrContextPointers.T4 = &(pDE->m_context.T4); - pRD->volatileCurrContextPointers.T5 = &(pDE->m_context.T5); - pRD->volatileCurrContextPointers.T6 = &(pDE->m_context.T6); - - SyncRegDisplayToCurrentContext(pRD); -#elif defined(TARGET_LOONGARCH64) - pRD->IsCallerContextValid = FALSE; - pRD->IsCallerSPValid = FALSE; // Don't add usage of this flag. This is only temporary. - - memcpy(pRD->pCurrentContext, &(pDE->m_context), sizeof(T_CONTEXT)); - - pRD->pCurrentContextPointers->S0 = &(pDE->m_context.S0); - pRD->pCurrentContextPointers->S1 = &(pDE->m_context.S1); - pRD->pCurrentContextPointers->S2 = &(pDE->m_context.S2); - pRD->pCurrentContextPointers->S3 = &(pDE->m_context.S3); - pRD->pCurrentContextPointers->S4 = &(pDE->m_context.S4); - pRD->pCurrentContextPointers->S5 = &(pDE->m_context.S5); - pRD->pCurrentContextPointers->S6 = &(pDE->m_context.S6); - pRD->pCurrentContextPointers->S7 = &(pDE->m_context.S7); - pRD->pCurrentContextPointers->S8 = &(pDE->m_context.S8); - pRD->pCurrentContextPointers->Tp = &(pDE->m_context.Tp); - pRD->pCurrentContextPointers->Fp = &(pDE->m_context.Fp); - pRD->pCurrentContextPointers->Ra = &(pDE->m_context.Ra); - - pRD->volatileCurrContextPointers.R0 = &(pDE->m_context.R0); - pRD->volatileCurrContextPointers.A0 = &(pDE->m_context.A0); - pRD->volatileCurrContextPointers.A1 = &(pDE->m_context.A1); - pRD->volatileCurrContextPointers.A2 = &(pDE->m_context.A2); - pRD->volatileCurrContextPointers.A3 = &(pDE->m_context.A3); - pRD->volatileCurrContextPointers.A4 = &(pDE->m_context.A4); - pRD->volatileCurrContextPointers.A5 = &(pDE->m_context.A5); - pRD->volatileCurrContextPointers.A6 = &(pDE->m_context.A6); - pRD->volatileCurrContextPointers.A7 = &(pDE->m_context.A7); - pRD->volatileCurrContextPointers.T0 = &(pDE->m_context.T0); - pRD->volatileCurrContextPointers.T1 = &(pDE->m_context.T1); - pRD->volatileCurrContextPointers.T2 = &(pDE->m_context.T2); - pRD->volatileCurrContextPointers.T3 = &(pDE->m_context.T3); - pRD->volatileCurrContextPointers.T4 = &(pDE->m_context.T4); - pRD->volatileCurrContextPointers.T5 = &(pDE->m_context.T5); - pRD->volatileCurrContextPointers.T6 = &(pDE->m_context.T6); - pRD->volatileCurrContextPointers.T7 = &(pDE->m_context.T7); - pRD->volatileCurrContextPointers.T8 = &(pDE->m_context.T8); - pRD->volatileCurrContextPointers.X0 = &(pDE->m_context.X0); - - SyncRegDisplayToCurrentContext(pRD); - -#else - PORTABILITY_ASSERT("FuncEvalFrame::UpdateRegDisplay is not implemented on this platform."); -#endif -} - #endif // DEBUGGER_INL_ diff --git a/src/coreclr/debug/ee/frameinfo.cpp b/src/coreclr/debug/ee/frameinfo.cpp index 48e0d2d56c146f..b3bac9cb2da7e9 100644 --- a/src/coreclr/debug/ee/frameinfo.cpp +++ b/src/coreclr/debug/ee/frameinfo.cpp @@ -416,7 +416,7 @@ bool HasExitRuntime(Frame *pFrame, DebuggerFrameData *pData, FramePointer *pPote NOTHROW; GC_NOTRIGGER; // Callers demand this function be GC_NOTRIGGER. MODE_ANY; - PRECONDITION(pFrame->GetFrameType() == Frame::TYPE_EXIT); + PRECONDITION(Frame_GetFrameType(pFrame) == Frame::TYPE_EXIT); } CONTRACTL_END; @@ -454,7 +454,7 @@ bool HasExitRuntime(Frame *pFrame, DebuggerFrameData *pData, FramePointer *pPote #else // TARGET_X86 // DebuggerExitFrame always return a NULL returnSP on x86. - if (pFrame->GetVTablePtr() == DebuggerExitFrame::GetMethodFrameVPtr()) + if (pFrame->GetType() == ::FrameType::DebuggerExitFrame) { if (pPotentialFP != NULL) { @@ -462,7 +462,7 @@ bool HasExitRuntime(Frame *pFrame, DebuggerFrameData *pData, FramePointer *pPote } return true; } - else if (pFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()) + else if (pFrame->GetType() == ::FrameType::InlinedCallFrame) { InlinedCallFrame *pInlinedFrame = static_cast(pFrame); LPVOID sp = (LPVOID)pInlinedFrame->GetCallSiteSP(); @@ -787,9 +787,9 @@ void FrameInfo::InitForM2UInternalFrame(CrawlFrame * pCF) { // For a M2U call, there's a managed method wrapping the unmanaged call. Use that. Frame * pFrame = pCF->GetFrame(); - _ASSERTE(pFrame->GetTransitionType() == Frame::TT_M2U); + _ASSERTE(Frame_GetTransitionType(pFrame) == TT_M2U); FramedMethodFrame * pM2U = static_cast (pFrame); - MethodDesc * pMDWrapper = pM2U->GetFunction(); + MethodDesc * pMDWrapper = Frame_GetFunction(pM2U); // Soem M2U transitions may not have a function associated w/ them, // so pMDWrapper may be NULL. PInvokeCalliFrame is an example. @@ -814,7 +814,7 @@ void FrameInfo::InitForU2MInternalFrame(CrawlFrame * pCF) // For regular U2M PInvoke cases, we don't care about MD b/c it's just going to // be the next frame. // If we're a COM2CLR call, perhaps we can get the MD for the interface. - if (pFrame->GetVTablePtr() == ComMethodFrame::GetMethodFrameVPtr()) + if (pFrame->GetType() == FrameType::ComMethodFrame) { ComMethodFrame* pCOMFrame = static_cast (pFrame); ComCallMethodDesc* pCMD = reinterpret_cast (pCOMFrame->ComMethodFrame::GetDatum()); @@ -836,7 +836,7 @@ void FrameInfo::InitForADTransition(CrawlFrame * pCF) { Frame * pFrame; pFrame = pCF->GetFrame(); - _ASSERTE(pFrame->GetTransitionType() == Frame::TT_AppDomain); + _ASSERTE(Frame_GetTransitionType(pFrame) == TT_AppDomain); MethodDesc * pMDWrapper = NULL; InitFromStubHelper(pCF, pMDWrapper, STUBFRAME_APPDOMAIN_TRANSITION); @@ -956,7 +956,7 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) // If we encounter an ExitFrame out in the wild, then we'll convert it to an UM chain. if (!d->IsTrackingUMChain()) { - if ((frame != NULL) && (frame != FRAME_TOP) && (frame->GetFrameType() == Frame::TYPE_EXIT)) + if ((frame != NULL) && (frame != FRAME_TOP) && (Frame_GetFrameType(frame) == Frame::TYPE_EXIT)) { LOG((LF_CORDB, LL_EVERYTHING, "DWSP. ExitFrame while not tracking\n")); REGDISPLAY* pRDSrc = pCF->GetRegisterSet(); @@ -988,14 +988,14 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) d->SetUMChainEnd(FramePointer::MakeFramePointer((LPVOID)(frame))); - Frame::ETransitionType t = frame->GetTransitionType(); - int ft = frame->GetFrameType(); + ETransitionType t = Frame_GetTransitionType(frame); + int ft = Frame_GetFrameType(frame); // Sometimes we may not want to show an UM chain b/c we know it's just // code inside of mscorwks. (Eg: Funcevals & AD transitions both fall into this category). // These are perfectly valid UM chains and we could give them if we wanted to. - if ((t == Frame::TT_AppDomain) || (ft == Frame::TYPE_FUNC_EVAL)) + if ((t == TT_AppDomain) || (ft == Frame::TYPE_FUNC_EVAL)) { d->CancelUMChain(); return SWA_CONTINUE; @@ -1003,7 +1003,7 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) // If we hit an M2U frame, then go ahead and dispatch the UM chain now. // This will likely also be an exit frame. - if (t == Frame::TT_M2U) + if (t == TT_M2U) { fDispatchUMChain = true; } @@ -1085,7 +1085,7 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) // UM chain must still be in CLR internal code. // Either way, this UM chain has ended (and some new chain based off the frame has started) // so we need to either Cancel the chain or dispatch it. - if (frame->GetInterception() != Frame::INTERCEPTION_NONE) + if (Frame_GetInterception(frame) != INTERCEPTION_NONE) { // Interceptors may contain calls out to unmanaged code (such as unmanaged dllmain when // loading a new dll), so we need to dispatch these. @@ -1190,7 +1190,7 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) #ifdef FEATURE_COMINTEROP if ((frame != NULL) && - (frame->GetVTablePtr() == CLRToCOMMethodFrame::GetMethodFrameVPtr())) + (frame->GetType() == FrameType::CLRToCOMMethodFrame)) { // This condition is part of the fix for 650903. (See // code:ControllerStackInfo::WalkStack and code:DebuggerStepper::TrapStepOut @@ -1216,8 +1216,8 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) if (d->ShouldProvideInternalFrames() && (frame != NULL) && (frame != FRAME_TOP)) { // We want to dispatch a M2U transition right after we dispatch the UM chain. - Frame::ETransitionType t = frame->GetTransitionType(); - if (t == Frame::TT_M2U) + ETransitionType t = Frame_GetTransitionType(frame); + if (t == TT_M2U) { // Frame for a M2U transition. FrameInfo fM2U; @@ -1496,7 +1496,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) d->info.fIsLeaf = true; } else if ( (pPrevFrame != NULL) && - (pPrevFrame->GetFrameType() == Frame::TYPE_EXIT) && + (Frame_GetFrameType(pPrevFrame) == Frame::TYPE_EXIT) && !HasExitRuntime(pPrevFrame, d, NULL) ) { // This is for the inlined NDirectMethodFrameGeneric case. We have not exit the runtime yet, so the current @@ -1629,27 +1629,27 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) // CHAIN_CONTEXT_SWITCH - not used // CHAIN_FUNC_EVAL - funceval - switch (frame->GetInterception()) + switch (Frame_GetInterception(frame)) { - case Frame::INTERCEPTION_CLASS_INIT: + case INTERCEPTION_CLASS_INIT: // // Fall through // // V2 assumes that the only thing the prestub intercepts is the class constructor - case Frame::INTERCEPTION_PRESTUB: + case INTERCEPTION_PRESTUB: d->info.chainReason = CHAIN_CLASS_INIT; break; - case Frame::INTERCEPTION_EXCEPTION: + case INTERCEPTION_EXCEPTION: d->info.chainReason = CHAIN_EXCEPTION_FILTER; break; - case Frame::INTERCEPTION_CONTEXT: + case INTERCEPTION_CONTEXT: d->info.chainReason = CHAIN_CONTEXT_POLICY; break; - case Frame::INTERCEPTION_SECURITY: + case INTERCEPTION_SECURITY: d->info.chainReason = CHAIN_SECURITY; break; @@ -1663,7 +1663,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) LOG((LF_CORDB, LL_INFO100000, "DWSP: Chain reason is 0x%X.\n", d->info.chainReason)); - switch (frame->GetFrameType()) + switch (Frame_GetFrameType(frame)) { case Frame::TYPE_ENTRY: // We now ignore entry + exit frames. case Frame::TYPE_EXIT: @@ -1717,7 +1717,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) // The jitted code on X64 behaves differently. // // Note that there is a corresponding change in DacDbiInterfaceImpl::GetInternalFrameType(). - if (frame->GetVTablePtr() == StubDispatchFrame::GetMethodFrameVPtr()) + if (frame->GetType() == FrameType::StubDispatchFrame) { use = false; } @@ -1768,17 +1768,17 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) // These callbacks are dispatched out of band. if (d->ShouldProvideInternalFrames() && (frame != NULL) && (frame != FRAME_TOP)) { - Frame::ETransitionType t = frame->GetTransitionType(); + ETransitionType t = Frame_GetTransitionType(frame); FrameInfo f; bool fUse = false; - if (t == Frame::TT_U2M) + if (t == TT_U2M) { // We can invoke the Internal U2M frame now. f.InitForU2MInternalFrame(pCF); fUse = true; } - else if (t == Frame::TT_AppDomain) + else if (t == TT_AppDomain) { // Internal frame for an Appdomain transition. // We used to ignore frames for ADs which we hadn't sent a Create event for yet. In V3 we send AppDomain @@ -1846,7 +1846,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) if (!pCF->IsFrameless()) { LOG((LF_CORDB, LL_INFO100000, "DWSP: updating regdisplay.\n")); - pCF->GetFrame()->UpdateRegDisplay(&d->regDisplay); + Frame_UpdateRegDisplay(pCF->GetFrame(), &d->regDisplay); } return SWA_CONTINUE; diff --git a/src/coreclr/inc/daccess.h b/src/coreclr/inc/daccess.h index 7bc2baed536e39..ca3cb5c004c327 100644 --- a/src/coreclr/inc/daccess.h +++ b/src/coreclr/inc/daccess.h @@ -2205,9 +2205,6 @@ public: name(int dummy) : base(dummy) {} // helper macro to make the vtables unique for DAC #define VPTR_UNIQUE(unique) virtual int MakeVTableUniqueForDAC() { return unique; } -#define VPTR_UNIQUE_ComMethodFrame (100000) -#define VPTR_UNIQUE_RedirectedThreadFrame (VPTR_UNIQUE_ComMethodFrame + 1) -#define VPTR_UNIQUE_HijackFrame (VPTR_UNIQUE_RedirectedThreadFrame + 1) #define PTR_TO_TADDR(ptr) ((TADDR)(ptr)) #define GFN_TADDR(name) ((TADDR)(name)) diff --git a/src/coreclr/inc/vptr_list.h b/src/coreclr/inc/vptr_list.h index 17e1867aa79b95..dcc1e197acd770 100644 --- a/src/coreclr/inc/vptr_list.h +++ b/src/coreclr/inc/vptr_list.h @@ -41,52 +41,6 @@ VPTR_CLASS(ConvertedImageLayout) VPTR_CLASS(LoadedImageLayout) VPTR_CLASS(FlatImageLayout) -#ifdef FEATURE_COMINTEROP -VPTR_CLASS(ComMethodFrame) -VPTR_CLASS(CLRToCOMMethodFrame) -VPTR_CLASS(ComPrestubMethodFrame) -#endif // FEATURE_COMINTEROP - -VPTR_CLASS(DebuggerClassInitMarkFrame) -VPTR_CLASS(DebuggerExitFrame) -VPTR_CLASS(DebuggerU2MCatchHandlerFrame) -VPTR_CLASS(FaultingExceptionFrame) -#ifdef FEATURE_EH_FUNCLETS -VPTR_CLASS(SoftwareExceptionFrame) -#endif // FEATURE_EH_FUNCLETS -VPTR_CLASS(FuncEvalFrame) -VPTR_CLASS(HelperMethodFrame) -VPTR_CLASS(HelperMethodFrame_1OBJ) -VPTR_CLASS(HelperMethodFrame_2OBJ) -VPTR_CLASS(HelperMethodFrame_3OBJ) -VPTR_CLASS(HelperMethodFrame_PROTECTOBJ) -#ifdef FEATURE_HIJACK -VPTR_CLASS(HijackFrame) -#endif -VPTR_CLASS(InlinedCallFrame) -VPTR_CLASS(PInvokeCalliFrame) -VPTR_CLASS(PrestubMethodFrame) -VPTR_CLASS(ProtectByRefsFrame) -VPTR_CLASS(ProtectValueClassFrame) -#ifdef FEATURE_HIJACK -VPTR_CLASS(ResumableFrame) -VPTR_CLASS(RedirectedThreadFrame) -#endif -VPTR_CLASS(StubDispatchFrame) -VPTR_CLASS(CallCountingHelperFrame) -VPTR_CLASS(ExternalMethodFrame) -#ifdef FEATURE_READYTORUN -VPTR_CLASS(DynamicHelperFrame) -#endif -#if defined(TARGET_X86) && !defined(UNIX_X86_ABI) -VPTR_CLASS(TailCallFrame) -#endif -VPTR_CLASS(ExceptionFilterFrame) - -#ifdef _DEBUG -VPTR_CLASS(AssumeByrefFromJITStack) -#endif - #ifdef DEBUGGING_SUPPORTED VPTR_CLASS(Debugger) VPTR_CLASS(EEDbgInterfaceImpl) diff --git a/src/coreclr/vm/FrameTypes.h b/src/coreclr/vm/FrameTypes.h new file mode 100644 index 00000000000000..6659423b44d521 --- /dev/null +++ b/src/coreclr/vm/FrameTypes.h @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#ifndef FRAME_ABSTRACT_TYPE_NAME +#define FRAME_ABSTRACT_TYPE_NAME(frameType) +#endif +#ifndef FRAME_TYPE_NAME +#define FRAME_TYPE_NAME(frameType) +#endif + +FRAME_ABSTRACT_TYPE_NAME(FrameBase) +FRAME_ABSTRACT_TYPE_NAME(Frame) +FRAME_ABSTRACT_TYPE_NAME(TransitionFrame) +FRAME_TYPE_NAME(InlinedCallFrame) +#ifdef FEATURE_HIJACK +FRAME_TYPE_NAME(ResumableFrame) +FRAME_TYPE_NAME(RedirectedThreadFrame) +#endif // FEATURE_HIJACK +FRAME_TYPE_NAME(FaultingExceptionFrame) +#ifdef FEATURE_EH_FUNCLETS +FRAME_TYPE_NAME(SoftwareExceptionFrame) +#endif // FEATURE_EH_FUNCLETS +#ifdef DEBUGGING_SUPPORTED +FRAME_TYPE_NAME(FuncEvalFrame) +#endif // DEBUGGING_SUPPORTED +FRAME_TYPE_NAME(HelperMethodFrame) +FRAME_TYPE_NAME(HelperMethodFrame_1OBJ) +FRAME_TYPE_NAME(HelperMethodFrame_2OBJ) +FRAME_TYPE_NAME(HelperMethodFrame_3OBJ) +FRAME_TYPE_NAME(HelperMethodFrame_PROTECTOBJ) +FRAME_ABSTRACT_TYPE_NAME(FramedMethodFrame) +#ifdef FEATURE_COMINTEROP +FRAME_ABSTRACT_TYPE_NAME(UnmanagedToManagedFrame) +FRAME_TYPE_NAME(ComMethodFrame) +FRAME_TYPE_NAME(CLRToCOMMethodFrame) +FRAME_TYPE_NAME(ComPrestubMethodFrame) +#endif // FEATURE_COMINTEROP +FRAME_TYPE_NAME(PInvokeCalliFrame) +#ifdef FEATURE_HIJACK +FRAME_TYPE_NAME(HijackFrame) +#endif // FEATURE_HIJACK +FRAME_TYPE_NAME(PrestubMethodFrame) +FRAME_TYPE_NAME(CallCountingHelperFrame) +FRAME_TYPE_NAME(StubDispatchFrame) +FRAME_TYPE_NAME(ExternalMethodFrame) +#ifdef FEATURE_READYTORUN +FRAME_TYPE_NAME(DynamicHelperFrame) +#endif +FRAME_TYPE_NAME(ProtectByRefsFrame) +FRAME_TYPE_NAME(ProtectValueClassFrame) +FRAME_TYPE_NAME(DebuggerClassInitMarkFrame) +FRAME_TYPE_NAME(DebuggerExitFrame) +FRAME_TYPE_NAME(DebuggerU2MCatchHandlerFrame) +#if defined(TARGET_X86) && !defined(UNIX_X86_ABI) +FRAME_TYPE_NAME(TailCallFrame) +#endif +FRAME_TYPE_NAME(ExceptionFilterFrame) +#if defined(_DEBUG) +FRAME_TYPE_NAME(AssumeByrefFromJITStack) +#endif // _DEBUG + +#undef FRAME_ABSTRACT_TYPE_NAME +#undef FRAME_TYPE_NAME diff --git a/src/coreclr/vm/amd64/PInvokeStubs.asm b/src/coreclr/vm/amd64/PInvokeStubs.asm index 4f19cb7d032a21..142831053463af 100644 --- a/src/coreclr/vm/amd64/PInvokeStubs.asm +++ b/src/coreclr/vm/amd64/PInvokeStubs.asm @@ -9,7 +9,6 @@ extern VarargPInvokeStubWorker:proc extern JIT_PInvokeEndRarePath:proc extern s_gsCookie:QWORD -extern ??_7InlinedCallFrame@@6B@:QWORD extern g_TrapReturningThreads:DWORD ; @@ -146,8 +145,7 @@ LEAF_ENTRY JIT_PInvokeBegin, _TEXT add rcx, SIZEOF_GSCookie ;; set first slot to the value of InlinedCallFrame::`vftable' (checked by runtime code) - lea rax,[??_7InlinedCallFrame@@6B@] - mov qword ptr [rcx], rax + mov qword ptr [rcx], FRAMETYPE_InlinedCallFrame mov qword ptr [rcx + OFFSETOF__InlinedCallFrame__m_Datum], 0 diff --git a/src/coreclr/vm/amd64/asmconstants.h b/src/coreclr/vm/amd64/asmconstants.h index 4b38aeeaca52d7..cb19b495cdac89 100644 --- a/src/coreclr/vm/amd64/asmconstants.h +++ b/src/coreclr/vm/amd64/asmconstants.h @@ -78,6 +78,9 @@ ASMCONSTANTS_C_ASSERT(SIZEOF_CalleeSavedRegisters == sizeof(CalleeSavedRegisters ASMCONSTANTS_C_ASSERT(SIZEOF_CalleeSavedRegisters == sizeof(CalleeSavedRegisters)); #endif +#define FRAMETYPE_InlinedCallFrame 0x1 +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) + #define SIZEOF_GSCookie 0x8 ASMCONSTANTS_C_ASSERT(SIZEOF_GSCookie == sizeof(GSCookie)); diff --git a/src/coreclr/vm/amd64/cgenamd64.cpp b/src/coreclr/vm/amd64/cgenamd64.cpp index 7548cd8a1742b5..f32a5e5d508cb5 100644 --- a/src/coreclr/vm/amd64/cgenamd64.cpp +++ b/src/coreclr/vm/amd64/cgenamd64.cpp @@ -58,7 +58,7 @@ void ClearRegDisplayArgumentAndScratchRegisters(REGDISPLAY * pRD) pContextPointers->R11 = NULL; } -void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void TransitionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { LIMITED_METHOD_CONTRACT; @@ -66,14 +66,14 @@ void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) if (updateFloats) { UpdateFloatingPointRegisters(pRD); - _ASSERTE(pRD->pCurrentContext->Rip == GetReturnAddress()); + _ASSERTE(pRD->pCurrentContext->Rip == Frame_GetReturnAddress(this)); } #endif // DACCESS_COMPILE pRD->IsCallerContextValid = FALSE; pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. - pRD->pCurrentContext->Rip = GetReturnAddress(); + pRD->pCurrentContext->Rip = Frame_GetReturnAddress(this); pRD->pCurrentContext->Rsp = GetSP(); UpdateRegDisplayFromCalleeSavedRegisters(pRD, GetCalleeSavedRegisters()); @@ -81,10 +81,10 @@ void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) SyncRegDisplayToCurrentContext(pRD); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay(rip:%p, rsp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay_Impl(rip:%p, rsp:%p)\n", pRD->ControlPC, pRD->SP)); } -void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACTL { @@ -135,10 +135,10 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats SyncRegDisplayToCurrentContext(pRD); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK InlinedCallFrame::UpdateRegDisplay(rip:%p, rsp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK InlinedCallFrame::UpdateRegDisplay_Impl(rip:%p, rsp:%p)\n", pRD->ControlPC, pRD->SP)); } -void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HelperMethodFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACTL { @@ -225,7 +225,7 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloat ClearRegDisplayArgumentAndScratchRegisters(pRD); } -void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void FaultingExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { LIMITED_METHOD_DAC_CONTRACT; @@ -264,13 +264,13 @@ void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool update } #ifdef FEATURE_HIJACK -TADDR ResumableFrame::GetReturnAddressPtr() +TADDR ResumableFrame::GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; return dac_cast(m_Regs) + offsetof(CONTEXT, Rip); } -void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void ResumableFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -310,7 +310,7 @@ void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) } // The HijackFrame has to know the registers that are pushed by OnHijackTripThread -void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HijackFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACTL { NOTHROW; diff --git a/src/coreclr/vm/arm/stubs.cpp b/src/coreclr/vm/arm/stubs.cpp index 57594beb859d82..b55b48bc77ff27 100644 --- a/src/coreclr/vm/arm/stubs.cpp +++ b/src/coreclr/vm/arm/stubs.cpp @@ -615,7 +615,7 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState, unwoundstate->_isValid = true; } -void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HelperMethodFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACTL { @@ -1144,7 +1144,7 @@ Stub *GenerateInitPInvokeFrameHelper() psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfGSCookie - negSpace); // mov [regFrame + FrameInfo.offsetOfFrameVptr], InlinedCallFrame::GetMethodFrameVPtr() - psl->ThumbEmitMovConstant(regScratch, InlinedCallFrame::GetMethodFrameVPtr()); + psl->ThumbEmitMovConstant(regScratch, (DWORD)FrameType::InlinedCallFrame); psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfFrameVptr - negSpace); // ldr regScratch, [regThread + offsetof(Thread, m_pFrame)] @@ -1497,7 +1497,7 @@ void UpdateRegDisplayFromCalleeSavedRegisters(REGDISPLAY * pRD, CalleeSavedRegis pRD->pCurrentContextPointers->Lr = NULL; } -void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void TransitionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { #ifndef DACCESS_COMPILE if (updateFloats) @@ -1531,10 +1531,10 @@ void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) // Finally, syncup the regdisplay with the context SyncRegDisplayToCurrentContext(pRD); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay(rip:%p, rsp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay_Impl(rip:%p, rsp:%p)\n", pRD->ControlPC, pRD->SP)); } -void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void FaultingExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { LIMITED_METHOD_DAC_CONTRACT; @@ -1560,7 +1560,7 @@ void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool update pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. } -void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -1624,7 +1624,7 @@ TADDR ResumableFrame::GetReturnAddressPtr(void) return dac_cast(m_Regs) + offsetof(T_CONTEXT, Pc); } -void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void ResumableFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -1660,7 +1660,7 @@ void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. } -void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HijackFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACTL { NOTHROW; diff --git a/src/coreclr/vm/arm64/stubs.cpp b/src/coreclr/vm/arm64/stubs.cpp index 825d2e0e4fd811..22931c69716329 100644 --- a/src/coreclr/vm/arm64/stubs.cpp +++ b/src/coreclr/vm/arm64/stubs.cpp @@ -412,7 +412,7 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState, unwoundstate->_isValid = TRUE; } -void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HelperMethodFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACTL { @@ -595,7 +595,7 @@ void UpdateRegDisplayFromCalleeSavedRegisters(REGDISPLAY * pRD, CalleeSavedRegis } -void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void TransitionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { #ifndef DACCESS_COMPILE if (updateFloats) @@ -623,12 +623,12 @@ void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) // Finally, syncup the regdisplay with the context SyncRegDisplayToCurrentContext(pRD); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); } -void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void FaultingExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { LIMITED_METHOD_DAC_CONTRACT; @@ -662,10 +662,10 @@ void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool update pRD->IsCallerContextValid = FALSE; pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK FaultingExceptionFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK FaultingExceptionFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); } -void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -722,7 +722,7 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats // Update the frame pointer in the current context. pRD->pCurrentContextPointers->Fp = (DWORD64 *)&m_pCalleeSavedFP; - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK InlinedCallFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK InlinedCallFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } @@ -734,7 +734,7 @@ TADDR ResumableFrame::GetReturnAddressPtr(void) return dac_cast(m_Regs) + offsetof(T_CONTEXT, Pc); } -void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void ResumableFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -769,12 +769,12 @@ void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) pRD->IsCallerContextValid = FALSE; pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK ResumableFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK ResumableFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } -void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HijackFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { LIMITED_METHOD_CONTRACT; @@ -822,7 +822,7 @@ void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) SyncRegDisplayToCurrentContext(pRD); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK HijackFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK HijackFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); } #endif // FEATURE_HIJACK diff --git a/src/coreclr/vm/callsiteinspect.cpp b/src/coreclr/vm/callsiteinspect.cpp index 8209e41e6a7d44..0854230cb9ad3b 100644 --- a/src/coreclr/vm/callsiteinspect.cpp +++ b/src/coreclr/vm/callsiteinspect.cpp @@ -71,7 +71,7 @@ namespace if (!fIsByRef && (ELEMENT_TYPE_R4 == eType || ELEMENT_TYPE_R8 == eType) && frame != nullptr - && !TransitionBlock::IsStackArgumentOffset(static_cast((TADDR) val - frame->GetTransitionBlock()))) + && !TransitionBlock::IsStackArgumentOffset(static_cast((TADDR) val - Frame_GetTransitionBlock(frame)))) { if (ELEMENT_TYPE_R4 == eType) *(UINT32*)pDest = (UINT32)FPSpillToR4(val); @@ -349,7 +349,7 @@ void CallsiteInspect::GetCallsiteArgs( for (int index = 0; index < numArgs; index++) { ArgDetails details = GetArgDetails(callsite.Frame, iter); - PVOID addr = (LPBYTE)callsite.Frame->GetTransitionBlock() + details.Offset; + PVOID addr = (LPBYTE)Frame_GetTransitionBlock(callsite.Frame) + details.Offset; // How do we handle pointer types? _ASSERTE(details.ElementType != ELEMENT_TYPE_PTR); @@ -423,7 +423,7 @@ void CallsiteInspect::PropagateOutParametersBackToCallsite( // Copy from RetVal into the retBuff. INT64 retVal = CopyOBJECTREFToStack( &gc.RetVal, - *(void**)(frame->GetTransitionBlock() + argit.GetRetBuffArgOffset()), + *(void**)(Frame_GetTransitionBlock(frame) + argit.GetRetBuffArgOffset()), pSig->GetReturnType(), TypeHandle{}, pSig, @@ -488,7 +488,7 @@ void CallsiteInspect::PropagateOutParametersBackToCallsite( if (typ != ELEMENT_TYPE_BYREF) continue; - argAddr = reinterpret_cast(frame->GetTransitionBlock() + argit.GetNextOffset()); + argAddr = reinterpret_cast(Frame_GetTransitionBlock(frame) + argit.GetNextOffset()); } else { @@ -499,7 +499,7 @@ void CallsiteInspect::PropagateOutParametersBackToCallsite( if (argit.GetArgType() != ELEMENT_TYPE_BYREF) continue; - argAddr = reinterpret_cast(frame->GetTransitionBlock() + ofs); + argAddr = reinterpret_cast(Frame_GetTransitionBlock(frame) + ofs); } TypeHandle ty; diff --git a/src/coreclr/vm/clrtocomcall.cpp b/src/coreclr/vm/clrtocomcall.cpp index b7e3fc8ca06b56..377d4bca18e854 100644 --- a/src/coreclr/vm/clrtocomcall.cpp +++ b/src/coreclr/vm/clrtocomcall.cpp @@ -340,7 +340,7 @@ UINT32 CLRToCOMEventCallWorker(CLRToCOMMethodFrame* pFrame, CLRToCOMCallMethodDe MethodDescCallSite eventProvider(pEvProvMD, &gc.EventProviderObj); // Retrieve the event handler passed in. - OBJECTREF EventHandlerObj = *(OBJECTREF*)(pFrame->GetTransitionBlock() + ArgItr.GetNextOffset()); + OBJECTREF EventHandlerObj = *(OBJECTREF*)(Frame_GetTransitionBlock(pFrame) + ArgItr.GetNextOffset()); ARG_SLOT EventMethArgs[] = { @@ -375,7 +375,7 @@ static CallsiteDetails CreateCallsiteDetails(_In_ FramedMethodFrame *pFrame) } CONTRACTL_END; - MethodDesc *pMD = pFrame->GetFunction(); + MethodDesc *pMD = Frame_GetFunction(pFrame); _ASSERTE(!pMD->ContainsGenericVariables() && pMD->IsRuntimeMethodHandle()); const BOOL fIsDelegate = pMD->GetMethodTable()->IsDelegate(); @@ -780,7 +780,7 @@ TADDR CLRToCOMCall::GetFrameCallIP(FramedMethodFrame *frame) } CONTRACT_END; - CLRToCOMCallMethodDesc *pCMD = dac_cast(frame->GetFunction()); + CLRToCOMCallMethodDesc *pCMD = dac_cast(Frame_GetFunction(frame)); MethodTable *pItfMT = pCMD->GetInterfaceMethodTable(); TADDR ip = NULL; #ifndef DACCESS_COMPILE @@ -843,7 +843,7 @@ TADDR CLRToCOMCall::GetFrameCallIP(FramedMethodFrame *frame) RETURN ip; } -void CLRToCOMMethodFrame::GetUnmanagedCallSite(TADDR* ip, +void CLRToCOMMethodFrame::GetUnmanagedCallSite_Impl(TADDR* ip, TADDR* returnIP, TADDR* returnSP) { @@ -884,7 +884,7 @@ void CLRToCOMMethodFrame::GetUnmanagedCallSite(TADDR* ip, -BOOL CLRToCOMMethodFrame::TraceFrame(Thread *thread, BOOL fromPatch, +BOOL CLRToCOMMethodFrame::TraceFrame_Impl(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) { CONTRACTL @@ -909,7 +909,7 @@ BOOL CLRToCOMMethodFrame::TraceFrame(Thread *thread, BOOL fromPatch, #endif // HOST_64BIT TADDR ip, returnIP, returnSP; - GetUnmanagedCallSite(&ip, &returnIP, &returnSP); + Frame_GetUnmanagedCallSite(this, &ip, &returnIP, &returnSP); // // If we've already made the call, we can't trace any more. diff --git a/src/coreclr/vm/common.h b/src/coreclr/vm/common.h index 7e38b98e3f452f..b2e9dd295d02ee 100644 --- a/src/coreclr/vm/common.h +++ b/src/coreclr/vm/common.h @@ -128,7 +128,7 @@ typedef DPTR(class EEConfig) PTR_EEConfig; typedef VPTR(class EEDbgInterfaceImpl) PTR_EEDbgInterfaceImpl; typedef VPTR(class DebugInfoManager) PTR_DebugInfoManager; typedef DPTR(class FieldDesc) PTR_FieldDesc; -typedef VPTR(class Frame) PTR_Frame; +typedef DPTR(class Frame) PTR_Frame; typedef DPTR(class GCFrame) PTR_GCFrame; typedef VPTR(class ICodeManager) PTR_ICodeManager; typedef VPTR(class IJitManager) PTR_IJitManager; diff --git a/src/coreclr/vm/comtoclrcall.cpp b/src/coreclr/vm/comtoclrcall.cpp index 7d5b9e3140511f..640a0a7993340b 100644 --- a/src/coreclr/vm/comtoclrcall.cpp +++ b/src/coreclr/vm/comtoclrcall.cpp @@ -471,7 +471,7 @@ extern "C" UINT64 __stdcall COMToCLRWorker(ComMethodFrame* pFrame) } // Initialize the frame's VPTR and GS cookie. - *((TADDR*)pFrame) = ComMethodFrame::GetMethodFrameVPtr(); + *((TADDR*)pFrame) = (TADDR)FrameType::ComMethodFrame; *pFrame->GetGSCookiePtr() = GetProcessGSCookie(); // Link frame into the chain. pFrame->Push(pThread); diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 55ba8dc4151bdd..6ef5e4fbea0221 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -5859,7 +5859,7 @@ EXTERN_C LPVOID STDCALL NDirectImportWorker(NDirectMethodDesc* pMD) // INDEBUG(Thread *pThread = GetThread()); { - _ASSERTE((pThread->GetFrame() != FRAME_TOP && pThread->GetFrame()->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()) + _ASSERTE((pThread->GetFrame() != FRAME_TOP && pThread->GetFrame()->GetType() == FrameType::InlinedCallFrame) || pMD->ShouldSuppressGCTransition()); CONSISTENCY_CHECK(pMD->IsNDirect()); @@ -5910,7 +5910,7 @@ EXTERN_C void STDCALL VarargPInvokeStubWorker(TransitionBlock * pTransitionBlock pFrame->Push(CURRENT_THREAD); _ASSERTE(pVASigCookie == pFrame->GetVASigCookie()); - _ASSERTE(pMD == pFrame->GetFunction()); + _ASSERTE(pMD == Frame_GetFunction(pFrame)); GetILStubForCalli(pVASigCookie, pMD); diff --git a/src/coreclr/vm/eedbginterfaceimpl.cpp b/src/coreclr/vm/eedbginterfaceimpl.cpp index 1c8de12c3f3d52..45704e5f0d2b6a 100644 --- a/src/coreclr/vm/eedbginterfaceimpl.cpp +++ b/src/coreclr/vm/eedbginterfaceimpl.cpp @@ -1220,7 +1220,7 @@ bool EEDbgInterfaceImpl::TraceFrame(Thread *thread, } CONTRACTL_END; - bool fResult = frame->TraceFrame(thread, fromPatch, trace, regs) != FALSE; + bool fResult = Frame_TraceFrame(frame, thread, fromPatch, trace, regs) != FALSE; #ifdef _DEBUG StubManager::DbgWriteLog("Doing TraceFrame on frame=0x%p (fromPatch=%d), yields:\n", frame, fromPatch); diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index 19c35aa9452ed7..7e0e44c2e39454 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -2870,7 +2870,7 @@ VOID ETW::ExceptionLog::ExceptionThrown(CrawlFrame *pCf, BOOL bIsReThrownExcept } else { - exceptionEIP = (PVOID)(pCf->GetFrame()->GetIP()); + exceptionEIP = (PVOID)(Frame_GetIP(pCf->GetFrame())); } // On platforms other than IA64, we are at the instruction after the faulting instruction diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index d4441504c0811e..d5735c3d076e15 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -7326,8 +7326,8 @@ LONG WINAPI CLRVectoredExceptionHandlerShim(PEXCEPTION_POINTERS pExceptionInfo) if (pFrame == 0 || pFrame == (Frame*) -1) break; - Frame::ETransitionType type = pFrame->GetTransitionType(); - if (type == Frame::TT_M2U || type == Frame::TT_InternalCall) + ETransitionType type = Frame_GetTransitionType(pFrame); + if (type == TT_M2U || type == TT_InternalCall) { stopPoint = pFrame; break; @@ -11511,7 +11511,7 @@ MethodDesc * GetUserMethodForILStub(Thread * pThread, UINT_PTR uStubSP, MethodDe // should be present further up the stack. Normally, the ComMethodFrame in question is // simply the next stack frame; however, there are situations where there may be other // stack frames present (such as an inlined stack frame from a QCall in the IL stub). - while (pCurFrame->GetVTablePtr() != ComMethodFrame::GetMethodFrameVPtr()) + while (pCurFrame->GetType() != FrameType::ComMethodFrame) { pCurFrame = pCurFrame->PtrNextFrame(); } @@ -11519,7 +11519,7 @@ MethodDesc * GetUserMethodForILStub(Thread * pThread, UINT_PTR uStubSP, MethodDe ComMethodFrame * pComFrame = (ComMethodFrame *)pCurFrame; _ASSERTE((UINT_PTR)pComFrame > uStubSP); - CONSISTENCY_CHECK_MSG(pComFrame->GetVTablePtr() == ComMethodFrame::GetMethodFrameVPtr(), + CONSISTENCY_CHECK_MSG(pComFrame->GetType() == FrameType::ComMethodFrame, "Expected to find a ComMethodFrame."); ComCallMethodDesc * pCMD = pComFrame->GetComCallMethodDesc(); @@ -11537,7 +11537,7 @@ MethodDesc * GetUserMethodForILStub(Thread * pThread, UINT_PTR uStubSP, MethodDe #ifdef FEATURE_EH_FUNCLETS -void SoftwareExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void SoftwareExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { LIMITED_METHOD_DAC_CONTRACT; diff --git a/src/coreclr/vm/exceptionhandling.cpp b/src/coreclr/vm/exceptionhandling.cpp index 18abf22d51a48c..da2e1e040ab83c 100644 --- a/src/coreclr/vm/exceptionhandling.cpp +++ b/src/coreclr/vm/exceptionhandling.cpp @@ -337,13 +337,13 @@ StackWalkAction UpdateObjectRefInResumeContextCallback(CrawlFrame* pCF, LPVOID p { Frame *pFrame = pCF->GetFrame(); - if (pFrame->NeedsUpdateRegDisplay()) + if (Frame_NeedsUpdateRegDisplay(pFrame)) { CONSISTENCY_CHECK(pFrame >= pState->pHighestFrameWithRegisters); pState->pHighestFrameWithRegisters = pFrame; // Is this an InlinedCallFrame? - if (pFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()) + if (pFrame->GetType() == FrameType::InlinedCallFrame) { // If we are here, then ICF is expected to be active. _ASSERTE(InlinedCallFrame::FrameHasActiveCall(pFrame)); @@ -397,7 +397,7 @@ bool ExceptionTracker::FindNonvolatileRegisterPointers(Thread* pThread, UINT_PTR while ((UINT_PTR)pFrame < uOriginalSP) { - if (pFrame->NeedsUpdateRegDisplay()) + if (Frame_NeedsUpdateRegDisplay(pFrame)) pHighestFrameWithRegisters = pFrame; pFrame = pFrame->Next(); @@ -869,7 +869,7 @@ static void PopExplicitFrames(Thread *pThread, void *targetSp, void *targetCalle Frame* pFrame = pThread->GetFrame(); while (pFrame < targetSp) { - pFrame->ExceptionUnwind(); + Frame_ExceptionUnwind(pFrame); pFrame->Pop(pThread); pFrame = pThread->GetFrame(); } @@ -898,7 +898,7 @@ static void PopExplicitFrames(Thread *pThread, void *targetSp, void *targetCalle if (ExecutionManager::IsReadyToRunCode(returnAddress)) #endif { - pFrame->ExceptionUnwind(); + Frame_ExceptionUnwind(pFrame); pFrame->Pop(pThread); } else @@ -1460,9 +1460,9 @@ void ExceptionTracker::InitializeCrawlFrameForExplicitFrame(CrawlFrame* pcfThisF pcfThisFrame->isIPadjusted = false; pcfThisFrame->pFrame = pFrame; - pcfThisFrame->pFunc = pFrame->GetFunction(); + pcfThisFrame->pFunc = Frame_GetFunction(pFrame); - if (pFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr() && + if (pFrame->GetType() == FrameType::InlinedCallFrame && !InlinedCallFrame::FrameHasActiveCall(pFrame)) { // Inactive ICFs in IL stubs contain the true interop MethodDesc which must be @@ -1963,7 +1963,7 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification( // the ICF immediately before and after a PInvoke in non-IL-stubs, like ReadyToRun. // See the usages for USE_PER_FRAME_PINVOKE_INIT for more information. - if (fTargetUnwind && (pFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr())) + if (fTargetUnwind && (pFrame->GetType() == FrameType::InlinedCallFrame)) { PTR_InlinedCallFrame pICF = (PTR_InlinedCallFrame)pFrame; // Does it live inside the current managed method? It will iff: @@ -2020,7 +2020,7 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification( // // notify Frame of unwind // - pFrame->ExceptionUnwind(); + Frame_ExceptionUnwind(pFrame); // If we have not yet set the initial explicit frame processed by this tracker, then // set it now. @@ -2384,7 +2384,7 @@ BOOL NotifyDebuggerOfStub(Thread* pThread, Frame* pCurrentFrame) // w/ the ICorDebugInternalFrame stack range. if (CORDebuggerAttached()) { - if (pCurrentFrame->GetTransitionType() == Frame::TT_M2U) + if (Frame_GetTransitionType(pCurrentFrame) == TT_M2U) { // Use -1 for the backing store pointer whenever we use the address of a frame as the stack pointer. EEToDebuggerExceptionInterfaceWrapper::FirstChanceManagedException(pThread, @@ -2417,7 +2417,7 @@ CLRUnwindStatus ExceptionTracker::ProcessExplicitFrame( Frame* pFrame = pcfThisFrame->GetFrame(); - EH_LOG((LL_INFO100, " [ ProcessExplicitFrame: pFrame: " FMT_ADDR " pMD: " FMT_ADDR " %s PASS ]\n", DBG_ADDR(pFrame), DBG_ADDR(pFrame->GetFunction()), fIsFirstPass ? "FIRST" : "SECOND")); + EH_LOG((LL_INFO100, " [ ProcessExplicitFrame: pFrame: " FMT_ADDR " pMD: " FMT_ADDR " %s PASS ]\n", DBG_ADDR(pFrame), DBG_ADDR(Frame_GetFunction(pFrame)), fIsFirstPass ? "FIRST" : "SECOND")); if (FRAME_TOP == pFrame) { @@ -6122,7 +6122,7 @@ BOOL IsSafeToUnwindFrameChain(Thread* pThread, LPVOID MemoryStackFpForFrameChain Frame* pLastFrameOfInterest = FRAME_TOP; for (Frame* pf = pThread->m_pFrame; pf < MemoryStackFpForFrameChain; pf = pf->PtrNextFrame()) { - PCODE retAddr = pf->GetReturnAddress(); + PCODE retAddr = Frame_GetReturnAddress(pf); if (retAddr != (PCODE)NULL && ExecutionManager::IsManagedCode(retAddr)) { pLastFrameOfInterest = pf; @@ -6141,7 +6141,7 @@ BOOL IsSafeToUnwindFrameChain(Thread* pThread, LPVOID MemoryStackFpForFrameChain SetIP(&ctx, 0); SetSP(&ctx, 0); FillRegDisplay(&rd, &ctx); - pLastFrameOfInterest->UpdateRegDisplay(&rd); + Frame_UpdateRegDisplay(pLastFrameOfInterest, &rd); // We're safe only if the managed method will be unwound also LPVOID managedSP = dac_cast(GetRegdisplaySP(&rd)); @@ -7588,7 +7588,7 @@ void ExceptionTracker::ResetThreadAbortStatus(PTR_Thread pThread, CrawlFrame *pC // Mark the pinvoke frame as invoking CallCatchFunclet (and similar) for collided unwind detection void MarkInlinedCallFrameAsFuncletCall(Frame* pFrame) { - _ASSERTE(pFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()); + _ASSERTE(pFrame->GetType() == FrameType::InlinedCallFrame); InlinedCallFrame* pInlinedCallFrame = (InlinedCallFrame*)pFrame; pInlinedCallFrame->m_Datum = (PTR_NDirectMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper | (TADDR)InlinedCallFrameMarker::SecondPassFuncletCaller); } @@ -7596,7 +7596,7 @@ void MarkInlinedCallFrameAsFuncletCall(Frame* pFrame) // Mark the pinvoke frame as invoking any exception handling helper void MarkInlinedCallFrameAsEHHelperCall(Frame* pFrame) { - _ASSERTE(pFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()); + _ASSERTE(pFrame->GetType() == FrameType::InlinedCallFrame); InlinedCallFrame* pInlinedCallFrame = (InlinedCallFrame*)pFrame; pInlinedCallFrame->m_Datum = (PTR_NDirectMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper); } @@ -8217,7 +8217,7 @@ void FailFastIfCorruptingStateException(ExInfo *pExInfo) static bool IsTopmostDebuggerU2MCatchHandlerFrame(Frame *pFrame) { - return (pFrame->GetVTablePtr() == DebuggerU2MCatchHandlerFrame::GetMethodFrameVPtr()) && (pFrame->PtrNextFrame() == FRAME_TOP); + return (pFrame->GetType() == FrameType::DebuggerU2MCatchHandlerFrame) && (pFrame->PtrNextFrame() == FRAME_TOP); } static void NotifyExceptionPassStarted(StackFrameIterator *pThis, Thread *pThread, ExInfo *pExInfo) @@ -8291,12 +8291,12 @@ static void NotifyExceptionPassStarted(StackFrameIterator *pThis, Thread *pThrea { Frame* pFrame = pThis->m_crawl.GetFrame(); // If the frame is ProtectValueClassFrame, move to the next one as we want to report the FuncEvalFrame - if (pFrame->GetVTablePtr() == ProtectValueClassFrame::GetMethodFrameVPtr()) + if (pFrame->GetType() == FrameType::ProtectValueClassFrame) { pFrame = pFrame->PtrNextFrame(); _ASSERTE(pFrame != FRAME_TOP); } - if ((pFrame->GetVTablePtr() == FuncEvalFrame::GetMethodFrameVPtr()) || IsTopmostDebuggerU2MCatchHandlerFrame(pFrame)) + if ((pFrame->GetType() == FrameType::FuncEvalFrame) || IsTopmostDebuggerU2MCatchHandlerFrame(pFrame)) { EEToDebuggerExceptionInterfaceWrapper::NotifyOfCHFFilter((EXCEPTION_POINTERS *)&pExInfo->m_ptrs, pFrame); } @@ -8373,7 +8373,7 @@ extern "C" bool QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStackwalk Frame *pFrame = pThis->m_crawl.GetFrame(); if (pFrame != FRAME_TOP) { - MethodDesc *pMD = pFrame->GetFunction(); + MethodDesc *pMD = Frame_GetFunction(pFrame); if (pMD != NULL) { GCX_COOP(); @@ -8401,9 +8401,9 @@ extern "C" bool QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStackwalk // a slightly different location in the managed code calling the pinvoke and the inlined // call frame doesn't update the context pointers anyways. Frame *pSkippedFrame = pThis->m_crawl.GetFrame(); - if (pSkippedFrame->NeedsUpdateRegDisplay() && (pSkippedFrame->GetVTablePtr() != InlinedCallFrame::GetMethodFrameVPtr())) + if (Frame_NeedsUpdateRegDisplay(pSkippedFrame) && (pSkippedFrame->GetType() != FrameType::InlinedCallFrame)) { - pSkippedFrame->UpdateRegDisplay(pThis->m_crawl.GetRegisterSet()); + Frame_UpdateRegDisplay(pSkippedFrame, pThis->m_crawl.GetRegisterSet()); } } } @@ -8651,7 +8651,7 @@ extern "C" bool QCALLTYPE SfiNext(StackFrameIterator* pThis, uint* uExCollideCla } else if (pTopExInfo->m_passNumber == 1) { - pMD = pFrame->GetFunction(); + pMD = Frame_GetFunction(pFrame); if (pMD != NULL) { GCX_COOP(); diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index 4479e678241908..57d03e8e82053b 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -37,6 +37,176 @@ #define CHECK_APP_DOMAIN 0 +void Frame_GcScanRoots(FrameBase *frame, promote_func *fn, ScanContext* sc) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { ((frameType*)frame)->GcScanRoots_Impl(fn, sc); return; } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return; +} + + +unsigned Frame_GetFrameAttribs(FrameBase *frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetFrameAttribs_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return 0; +} + +#ifndef DACCESS_COMPILE +void Frame_ExceptionUnwind(FrameBase *frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { ((frameType*)frame)->ExceptionUnwind_Impl(); return; } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return; +} + +#endif +BOOL Frame_NeedsUpdateRegDisplay(FrameBase *frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->NeedsUpdateRegDisplay_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return 0; +} + +BOOL Frame_IsTransitionToNativeFrame(FrameBase *frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->IsTransitionToNativeFrame_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return 0; +} + +MethodDesc *Frame_GetFunction(FrameBase* frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetFunction_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return 0; +} + +Assembly *Frame_GetAssembly(FrameBase* frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetAssembly_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return 0; +} +PTR_BYTE Frame_GetIP(FrameBase* frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetIP_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return 0; +} + +TADDR Frame_GetReturnAddressPtr(FrameBase* frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetReturnAddressPtr_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return 0; +} +PCODE Frame_GetReturnAddress(FrameBase* frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetReturnAddress_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return 0; +} + +void Frame_UpdateRegDisplay(FrameBase* frame, const PREGDISPLAY pRegDisplay, bool updateFloats) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { ((frameType*)frame)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); return; } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return; +} + +int Frame_GetFrameType(FrameBase* frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetFrameType_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return 0; +} + +ETransitionType Frame_GetTransitionType(FrameBase* frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetTransitionType_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return (ETransitionType)0; +} + +Interception Frame_GetInterception(FrameBase* frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetInterception_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return (Interception)0; +} + +void Frame_GetUnmanagedCallSite(FrameBase* frame, TADDR* ip, TADDR* returnIP, TADDR* returnSP) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { ((frameType*)frame)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); return; } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return; +} + +BOOL Frame_TraceFrame(FrameBase* frame, Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->TraceFrame_Impl(thread, fromPatch, trace, regs); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return FALSE; +} + +#ifdef DACCESS_COMPILE +void Frame_EnumMemoryRegions(FrameBase* frame, CLRDataEnumMemoryFlags flags) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { ((frameType*)frame)->EnumMemoryRegions_Impl(flags); return; } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return; +} + +#endif // DACCESS_COMPILE +#if defined(_DEBUG) && !defined(DACCESS_COMPILE) +BOOL Frame_Protects(FrameBase* frame, OBJECTREF *ppObjectRef) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->Protects_Impl(ppObjectRef); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return FALSE; +} + +#endif // defined(_DEBUG) && !defined(DACCESS_COMPILE) + +// TransitionFrame only apis +class TransitionFrame; +TADDR Frame_GetTransitionBlock(TransitionFrame* frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetTransitionBlock_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return (TADDR)0; +} + +BOOL Frame_SuppressParamTypeArg(TransitionFrame* frame) +{ +#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->SuppressParamTypeArg_Impl(); } +#include "FrameTypes.h" + _ASSERTE(!"Unexpected"); + return FALSE; +} + + + //----------------------------------------------------------------------- #if _DEBUG //----------------------------------------------------------------------- @@ -57,23 +227,23 @@ void Frame::Log() { dbgStubCtr++; // basicly a nop to put a breakpoint on. } - MethodDesc* method = GetFunction(); + MethodDesc* method = Frame_GetFunction(this); STRESS_LOG3(LF_STUBS, LL_INFO1000000, "STUBS: In Stub with Frame %p assoc Method %pM FrameType = %pV\n", this, method, *((void**) this)); char buff[64]; const char* frameType; - if (GetVTablePtr() == PrestubMethodFrame::GetMethodFrameVPtr()) + if (GetType() == FrameType::PrestubMethodFrame) frameType = "PreStub"; - else if (GetVTablePtr() == PInvokeCalliFrame::GetMethodFrameVPtr()) + else if (GetType() == FrameType::PInvokeCalliFrame) { sprintf_s(buff, ARRAY_SIZE(buff), "PInvoke CALLI target" FMT_ADDR, DBG_ADDR(((PInvokeCalliFrame*)this)->GetPInvokeCalliTarget())); frameType = buff; } - else if (GetVTablePtr() == StubDispatchFrame::GetMethodFrameVPtr()) + else if (GetType() == FrameType::StubDispatchFrame) frameType = "StubDispatch"; - else if (GetVTablePtr() == ExternalMethodFrame::GetMethodFrameVPtr()) + else if (GetType() == FrameType::ExternalMethodFrame) frameType = "ExternalMethod"; else frameType = "Unknown"; @@ -85,12 +255,12 @@ void Frame::Log() { method->m_pszDebugClassName, method->m_pszDebugMethodName, method->m_pszDebugMethodSignature, - DBG_ADDR(GetReturnAddressPtr()))); + DBG_ADDR(Frame_GetReturnAddressPtr(this)))); else LOG((LF_STUBS, LL_INFO1000000, "IN %s Stub Method UNKNOWN ESP of return" FMT_ADDR "\n", frameType, - DBG_ADDR(GetReturnAddressPtr()) )); + DBG_ADDR(Frame_GetReturnAddressPtr(this)) )); _ASSERTE(GetThread()->PreemptiveGCDisabled()); } @@ -198,7 +368,7 @@ const size_t FRAME_TYPES_COUNT = //----------------------------------------------------------------------- // Implementation of the global table of names. On the DAC side, just the global pointer. // On the runtime side, the array of names. - #define FRAME_TYPE_NAME(x) {x::GetMethodFrameVPtr(), #x} , + #define FRAME_TYPE_NAME(x) {(TADDR)FrameType::x, #x} , static FrameTypeName FrameTypeNameTable[] = { #include "frames.h" }; @@ -229,12 +399,8 @@ void Frame::LogFrame( { char buf[32]; const char *pFrameType; - pFrameType = GetFrameTypeName(); - if (pFrameType == NULL) - { - pFrameType = GetFrameTypeName(GetVTablePtr()); - } + pFrameType = GetFrameTypeName(GetVTablePtr()); if (pFrameType == NULL) { @@ -269,9 +435,6 @@ void Frame::LogFrameChain( #ifndef DACCESS_COMPILE -// This hashtable contains the vtable value of every Frame type. -static PtrHashMap* s_pFrameVTables = NULL; - // static void Frame::Init() { @@ -282,14 +445,6 @@ void Frame::Init() MODE_ANY; } CONTRACTL_END; - // create a table big enough for all the frame types, not in asynchronous mode, and with no lock owner - s_pFrameVTables = ::new PtrHashMap; - s_pFrameVTables->Init(2 * FRAME_TYPES_COUNT, FALSE, &g_lockTrustMeIAmThreadSafe); -#define FRAME_TYPE_NAME(frameType) \ - s_pFrameVTables->InsertValue(frameType::GetMethodFrameVPtr(), \ - (LPVOID) frameType::GetMethodFrameVPtr()); -#include "frames.h" - } // void Frame::Init() #endif // DACCESS_COMPILE @@ -305,21 +460,14 @@ bool Frame::HasValidVTablePtr(Frame * pFrame) return false; #ifndef DACCESS_COMPILE - TADDR vptr = pFrame->GetVTablePtr(); + FrameType vptr = pFrame->GetType(); // - // Explicitly check for the most common frames. + // Use a simple compare which is dependent on the tightly packed arrangement of FrameType // - if (vptr == HelperMethodFrame::GetMethodFrameVPtr()) - return true; - - // - // otherwise consult the hashtable - // - if (s_pFrameVTables->LookupValue(vptr, (LPVOID) vptr) == (LPVOID) INVALIDENTRY) - return false; -#endif - + return (((TADDR)vptr > (TADDR)FrameType::None) && ((TADDR)vptr < (TADDR)FrameType::CountPlusOne)); +#else return true; +#endif } // Returns the location of the expected GSCookie, @@ -497,7 +645,7 @@ PTR_VOID TransitionFrame::GetParamTypeArg() // may be another option. ENABLE_FORBID_GC_LOADER_USE_IN_THIS_SCOPE(); - MethodDesc *pFunction = GetFunction(); + MethodDesc *pFunction = Frame_GetFunction(this); _ASSERTE (pFunction->RequiresInstArg()); MetaSig msig(pFunction); @@ -505,14 +653,14 @@ PTR_VOID TransitionFrame::GetParamTypeArg() INT offs = argit.GetParamTypeArgOffset(); - TADDR taParamTypeArg = *PTR_TADDR(GetTransitionBlock() + offs); + TADDR taParamTypeArg = *PTR_TADDR(Frame_GetTransitionBlock(this) + offs); return PTR_VOID(taParamTypeArg); } TADDR TransitionFrame::GetAddrOfThis() { WRAPPER_NO_CONTRACT; - return GetTransitionBlock() + ArgIterator::GetThisOffset(); + return Frame_GetTransitionBlock(this) + ArgIterator::GetThisOffset(); } VASigCookie * TransitionFrame::GetVASigCookie() @@ -524,22 +672,22 @@ VASigCookie * TransitionFrame::GetVASigCookie() sizeof(TransitionBlock))); #else WRAPPER_NO_CONTRACT; - MetaSig msig(GetFunction()); + MetaSig msig(Frame_GetFunction(this)); ArgIterator argit(&msig); return PTR_VASigCookie( - *dac_cast(GetTransitionBlock() + argit.GetVASigCookieOffset())); + *dac_cast(Frame_GetTransitionBlock(this) + argit.GetVASigCookieOffset())); #endif } #ifndef DACCESS_COMPILE PrestubMethodFrame::PrestubMethodFrame(TransitionBlock * pTransitionBlock, MethodDesc * pMD) - : FramedMethodFrame(pTransitionBlock, pMD) + : FramedMethodFrame(FrameType::PrestubMethodFrame, pTransitionBlock, pMD) { LIMITED_METHOD_CONTRACT; } #endif // #ifndef DACCESS_COMPILE -BOOL PrestubMethodFrame::TraceFrame(Thread *thread, BOOL fromPatch, +BOOL PrestubMethodFrame::TraceFrame_Impl(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) { WRAPPER_NO_CONTRACT; @@ -558,7 +706,7 @@ BOOL PrestubMethodFrame::TraceFrame(Thread *thread, BOOL fromPatch, // native code versions, even if they aren't the one that was reported by this trace, see // DebuggerController::PatchTrace() under case TRACE_MANAGED. This alleviates the StubManager from having to prevent the // race that occurs here. - trace->InitForStub(GetFunction()->GetMethodEntryPointIfExists()); + trace->InitForStub(Frame_GetFunction(this)->GetMethodEntryPointIfExists()); } else { @@ -576,7 +724,7 @@ BOOL PrestubMethodFrame::TraceFrame(Thread *thread, BOOL fromPatch, // A rather specialized routine for the exclusive use of StubDispatch. //----------------------------------------------------------------------- StubDispatchFrame::StubDispatchFrame(TransitionBlock * pTransitionBlock) - : FramedMethodFrame(pTransitionBlock, NULL) + : FramedMethodFrame(FrameType::StubDispatchFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -591,7 +739,7 @@ StubDispatchFrame::StubDispatchFrame(TransitionBlock * pTransitionBlock) #endif // #ifndef DACCESS_COMPILE -MethodDesc* StubDispatchFrame::GetFunction() +MethodDesc* StubDispatchFrame::GetFunction_Impl() { CONTRACTL { NOTHROW; @@ -689,7 +837,7 @@ PTR_BYTE StubDispatchFrame::GetGCRefMap() return pGCRefMap; } -void StubDispatchFrame::GcScanRoots(promote_func *fn, ScanContext* sc) +void StubDispatchFrame::GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { CONTRACTL { @@ -698,7 +846,7 @@ void StubDispatchFrame::GcScanRoots(promote_func *fn, ScanContext* sc) } CONTRACTL_END - FramedMethodFrame::GcScanRoots(fn, sc); + FramedMethodFrame::GcScanRoots_Impl(fn, sc); PTR_BYTE pGCRefMap = GetGCRefMap(); if (pGCRefMap != NULL) @@ -711,7 +859,7 @@ void StubDispatchFrame::GcScanRoots(promote_func *fn, ScanContext* sc) } } -BOOL StubDispatchFrame::TraceFrame(Thread *thread, BOOL fromPatch, +BOOL StubDispatchFrame::TraceFrame_Impl(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) { WRAPPER_NO_CONTRACT; @@ -723,7 +871,7 @@ BOOL StubDispatchFrame::TraceFrame(Thread *thread, BOOL fromPatch, return FALSE; } -Frame::Interception StubDispatchFrame::GetInterception() +Interception StubDispatchFrame::GetInterception_Impl() { LIMITED_METHOD_CONTRACT; @@ -732,21 +880,21 @@ Frame::Interception StubDispatchFrame::GetInterception() #ifndef DACCESS_COMPILE CallCountingHelperFrame::CallCountingHelperFrame(TransitionBlock *pTransitionBlock, MethodDesc *pMD) - : FramedMethodFrame(pTransitionBlock, pMD) + : FramedMethodFrame(FrameType::CallCountingHelperFrame, pTransitionBlock, pMD) { WRAPPER_NO_CONTRACT; } #endif -void CallCountingHelperFrame::GcScanRoots(promote_func *fn, ScanContext *sc) +void CallCountingHelperFrame::GcScanRoots_Impl(promote_func *fn, ScanContext *sc) { WRAPPER_NO_CONTRACT; - FramedMethodFrame::GcScanRoots(fn, sc); + FramedMethodFrame::GcScanRoots_Impl(fn, sc); PromoteCallerStack(fn, sc); } -BOOL CallCountingHelperFrame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) +BOOL CallCountingHelperFrame::TraceFrame_Impl(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) { WRAPPER_NO_CONTRACT; @@ -758,7 +906,7 @@ BOOL CallCountingHelperFrame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDe #ifndef DACCESS_COMPILE ExternalMethodFrame::ExternalMethodFrame(TransitionBlock * pTransitionBlock) - : FramedMethodFrame(pTransitionBlock, NULL) + : FramedMethodFrame(FrameType::ExternalMethodFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -769,7 +917,7 @@ ExternalMethodFrame::ExternalMethodFrame(TransitionBlock * pTransitionBlock) } #endif // !DACCESS_COMPILE -void ExternalMethodFrame::GcScanRoots(promote_func *fn, ScanContext* sc) +void ExternalMethodFrame::GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { CONTRACTL { @@ -778,7 +926,7 @@ void ExternalMethodFrame::GcScanRoots(promote_func *fn, ScanContext* sc) } CONTRACTL_END - FramedMethodFrame::GcScanRoots(fn, sc); + FramedMethodFrame::GcScanRoots_Impl(fn, sc); PromoteCallerStackUsingGCRefMap(fn, sc, GetGCRefMap()); } @@ -803,14 +951,14 @@ PTR_BYTE ExternalMethodFrame::GetGCRefMap() return pGCRefMap; } -Frame::Interception ExternalMethodFrame::GetInterception() +Interception ExternalMethodFrame::GetInterception_Impl() { LIMITED_METHOD_CONTRACT; return INTERCEPTION_NONE; } -Frame::Interception PrestubMethodFrame::GetInterception() +Interception PrestubMethodFrame::GetInterception_Impl() { LIMITED_METHOD_DAC_CONTRACT; @@ -826,7 +974,7 @@ Frame::Interception PrestubMethodFrame::GetInterception() #ifndef DACCESS_COMPILE DynamicHelperFrame::DynamicHelperFrame(TransitionBlock * pTransitionBlock, int dynamicHelperFrameFlags) - : FramedMethodFrame(pTransitionBlock, NULL) + : FramedMethodFrame(FrameType::DynamicHelperFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -834,7 +982,7 @@ DynamicHelperFrame::DynamicHelperFrame(TransitionBlock * pTransitionBlock, int d } #endif // !DACCESS_COMPILE -void DynamicHelperFrame::GcScanRoots(promote_func *fn, ScanContext* sc) +void DynamicHelperFrame::GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { CONTRACTL { @@ -843,13 +991,13 @@ void DynamicHelperFrame::GcScanRoots(promote_func *fn, ScanContext* sc) } CONTRACTL_END - FramedMethodFrame::GcScanRoots(fn, sc); + FramedMethodFrame::GcScanRoots_Impl(fn, sc); - PTR_PTR_Object pArgumentRegisters = dac_cast(GetTransitionBlock() + TransitionBlock::GetOffsetOfArgumentRegisters()); + PTR_PTR_Object pArgumentRegisters = dac_cast(Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfArgumentRegisters()); if (m_dynamicHelperFrameFlags & DynamicHelperFrameFlags_ObjectArg) { - TADDR pArgument = GetTransitionBlock() + TransitionBlock::GetOffsetOfArgumentRegisters(); + TADDR pArgument = Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfArgumentRegisters(); #ifdef TARGET_X86 // x86 is special as always pArgument += offsetof(ArgumentRegisters, ECX); @@ -859,7 +1007,7 @@ void DynamicHelperFrame::GcScanRoots(promote_func *fn, ScanContext* sc) if (m_dynamicHelperFrameFlags & DynamicHelperFrameFlags_ObjectArg2) { - TADDR pArgument = GetTransitionBlock() + TransitionBlock::GetOffsetOfArgumentRegisters(); + TADDR pArgument = Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfArgumentRegisters(); #ifdef TARGET_X86 // x86 is special as always pArgument += offsetof(ArgumentRegisters, EDX); @@ -887,7 +1035,7 @@ ComPrestubMethodFrame::Init() // Initializes the frame's VPTR. This assumes C++ puts the vptr // at offset 0 for a class not using MI, but this is no different // than the assumption that COM Classic makes. - *((TADDR*)this) = GetMethodFrameVPtr(); + *((TADDR*)this) = (TADDR)FrameType::ComPrestubMethodFrame; *GetGSCookiePtr() = GetProcessGSCookie(); } #endif // FEATURE_COMINTEROP @@ -1127,7 +1275,7 @@ static StackWalkAction IsProtectedByGCFrameStackWalkFramesCallback( IsProtectedByGCFrameStruct *pd = (IsProtectedByGCFrameStruct*)pData; Frame *pFrame = pCF->GetFrame(); if (pFrame) { - if (pFrame->Protects(pd->ppObjectRef)) { + if (Frame_Protects(pFrame, pd->ppObjectRef)) { pd->count++; } } @@ -1174,7 +1322,7 @@ BOOL IsProtectedByGCFrame(OBJECTREF *ppObjectRef) #ifdef FEATURE_HIJACK #ifdef TARGET_X86 -void HijackFrame::GcScanRoots(promote_func *fn, ScanContext* sc) +void HijackFrame::GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { LIMITED_METHOD_CONTRACT; @@ -1220,7 +1368,7 @@ void HijackFrame::GcScanRoots(promote_func *fn, ScanContext* sc) #endif // TARGET_X86 #endif // FEATURE_HIJACK -void ProtectByRefsFrame::GcScanRoots(promote_func *fn, ScanContext *sc) +void ProtectByRefsFrame::GcScanRoots_Impl(promote_func *fn, ScanContext *sc) { CONTRACTL { @@ -1255,7 +1403,7 @@ void ProtectByRefsFrame::GcScanRoots(promote_func *fn, ScanContext *sc) } } -void ProtectValueClassFrame::GcScanRoots(promote_func *fn, ScanContext *sc) +void ProtectValueClassFrame::GcScanRoots_Impl(promote_func *fn, ScanContext *sc) { CONTRACTL { @@ -1299,7 +1447,7 @@ void TransitionFrame::PromoteCallerStack(promote_func* fn, ScanContext* sc) // We're going to have to look at the signature to determine // which arguments a are pointers....First we need the function - pFunction = GetFunction(); + pFunction = Frame_GetFunction(this); if (pFunction == NULL) return; @@ -1324,7 +1472,7 @@ void TransitionFrame::PromoteCallerStack(promote_func* fn, ScanContext* sc) if (fCtorOfVariableSizedObject) msig.ClearHasThis(); - if (pFunction->RequiresInstArg() && !SuppressParamTypeArg()) + if (pFunction->RequiresInstArg() && !Frame_SuppressParamTypeArg(this)) msig.SetHasParamTypeArg(); PromoteCallerStackHelper (fn, sc, pFunction, &msig); @@ -1358,7 +1506,7 @@ void TransitionFrame::PromoteCallerStackHelper(promote_func* fn, ScanContext* sc ArgIterator argit(pmsig); - TADDR pTransitionBlock = GetTransitionBlock(); + TADDR pTransitionBlock = Frame_GetTransitionBlock(this); // promote 'this' for non-static methods if (argit.HasThis() && pFunction != NULL) @@ -1423,7 +1571,7 @@ void TransitionFrame::PromoteCallerStackUsingGCRefMap(promote_func* fn, ScanCont decoder.ReadStackPop(); #endif - TADDR pTransitionBlock = GetTransitionBlock(); + TADDR pTransitionBlock = Frame_GetTransitionBlock(this); while (!decoder.AtEnd()) { @@ -1503,7 +1651,7 @@ void PInvokeCalliFrame::PromoteCallerStack(promote_func* fn, ScanContext* sc) #ifndef DACCESS_COMPILE PInvokeCalliFrame::PInvokeCalliFrame(TransitionBlock * pTransitionBlock, VASigCookie * pVASigCookie, PCODE pUnmanagedTarget) - : FramedMethodFrame(pTransitionBlock, NULL) + : FramedMethodFrame(FrameType::PInvokeCalliFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -1516,26 +1664,26 @@ PInvokeCalliFrame::PInvokeCalliFrame(TransitionBlock * pTransitionBlock, VASigCo #ifndef DACCESS_COMPILE CLRToCOMMethodFrame::CLRToCOMMethodFrame(TransitionBlock * pTransitionBlock, MethodDesc * pMD) - : FramedMethodFrame(pTransitionBlock, pMD) + : FramedMethodFrame(FrameType::CLRToCOMMethodFrame, pTransitionBlock, pMD) { LIMITED_METHOD_CONTRACT; } #endif // #ifndef DACCESS_COMPILE //virtual -void CLRToCOMMethodFrame::GcScanRoots(promote_func* fn, ScanContext* sc) +void CLRToCOMMethodFrame::GcScanRoots_Impl(promote_func* fn, ScanContext* sc) { WRAPPER_NO_CONTRACT; // CLRToCOMMethodFrame is only used in the event call / late bound call code path where we do not have IL stub // so we need to promote the arguments and return value manually. - FramedMethodFrame::GcScanRoots(fn, sc); + FramedMethodFrame::GcScanRoots_Impl(fn, sc); PromoteCallerStack(fn, sc); // Promote the returned object - MethodDesc* methodDesc = GetFunction(); + MethodDesc* methodDesc = Frame_GetFunction(this); ReturnKind returnKind = methodDesc->GetReturnKind(); if (returnKind == RT_Object) { @@ -1580,13 +1728,13 @@ void IsObjRefProtected (Object** ppObj, ScanContext* sc, uint32_t) orefProtectedSc->oref_protected = TRUE; } -BOOL TransitionFrame::Protects(OBJECTREF * ppORef) +BOOL TransitionFrame::Protects_Impl(OBJECTREF * ppORef) { WRAPPER_NO_CONTRACT; IsObjRefProtectedScanContext sc (ppORef); // Set the stack limit for the scan to the SP of the managed frame above the transition frame sc.stack_limit = GetSP(); - GcScanRoots (IsObjRefProtected, &sc); + Frame_GcScanRoots (this, IsObjRefProtected, &sc); return sc.oref_protected; } #endif //defined (_DEBUG) && !defined (DACCESS_COMPILE) @@ -1626,7 +1774,7 @@ void ComMethodFrame::DoSecondPassHandlerCleanup(Frame * pCurFrame) // Find ComMethodFrame while ((pCurFrame != FRAME_TOP) && - (pCurFrame->GetVTablePtr() != ComMethodFrame::GetMethodFrameVPtr())) + (pCurFrame->GetType() != FrameType::ComMethodFrame)) { pCurFrame = pCurFrame->PtrNextFrame(); } @@ -1643,7 +1791,7 @@ void ComMethodFrame::DoSecondPassHandlerCleanup(Frame * pCurFrame) pCurFrame = pThread->GetFrame(); while ((pCurFrame != NULL) && (pCurFrame <= pComMethodFrame)) { - pCurFrame->ExceptionUnwind(); + Frame_ExceptionUnwind(pCurFrame); pCurFrame = pCurFrame->PtrNextFrame(); } @@ -1751,7 +1899,7 @@ NOINLINE void HelperMethodFrame::PopSlowHelper() #endif // #ifndef DACCESS_COMPILE -MethodDesc* HelperMethodFrame::GetFunction() +MethodDesc* HelperMethodFrame::GetFunction_Impl() { WRAPPER_NO_CONTRACT; @@ -1876,7 +2024,7 @@ VOID InlinedCallFrame::Init() { WRAPPER_NO_CONTRACT; - *((TADDR *)this) = GetMethodFrameVPtr(); + *((TADDR *)this) = (TADDR)FrameType::InlinedCallFrame; // GetGSCookiePtr contains a virtual call and this is a perf critical method so we don't want to call it in ret builds GSCookie *ptrGS = (GSCookie *)((BYTE *)this - sizeof(GSCookie)); @@ -1891,7 +2039,7 @@ VOID InlinedCallFrame::Init() #ifdef FEATURE_COMINTEROP -void UnmanagedToManagedFrame::ExceptionUnwind() +void UnmanagedToManagedFrame::ExceptionUnwind_Impl() { WRAPPER_NO_CONTRACT; @@ -1902,14 +2050,14 @@ void UnmanagedToManagedFrame::ExceptionUnwind() #endif // !DACCESS_COMPILE #ifdef FEATURE_COMINTEROP -PCODE UnmanagedToManagedFrame::GetReturnAddress() +PCODE UnmanagedToManagedFrame::GetReturnAddress_Impl() { WRAPPER_NO_CONTRACT; - PCODE pRetAddr = Frame::GetReturnAddress(); + PCODE pRetAddr = Frame::GetReturnAddress_Impl(); if (InlinedCallFrame::FrameHasActiveCall(m_Next) && - pRetAddr == m_Next->GetReturnAddress()) + pRetAddr == Frame_GetReturnAddress(m_Next)) { // there's actually no unmanaged code involved - we were called directly // from managed code using an InlinedCallFrame @@ -2245,3 +2393,4 @@ void ComputeCallRefMap(MethodDesc* pMD, } #endif // !DACCESS_COMPILE + diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 46b435f94b8d94..da157e14027983 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -173,66 +173,7 @@ obtained from function pointers): #endif // 0 //------------------------------------------------------------------------ -#ifndef FRAME_ABSTRACT_TYPE_NAME -#define FRAME_ABSTRACT_TYPE_NAME(frameType) -#endif -#ifndef FRAME_TYPE_NAME -#define FRAME_TYPE_NAME(frameType) -#endif - -FRAME_ABSTRACT_TYPE_NAME(FrameBase) -FRAME_ABSTRACT_TYPE_NAME(Frame) -FRAME_ABSTRACT_TYPE_NAME(TransitionFrame) -#ifdef FEATURE_HIJACK -FRAME_TYPE_NAME(ResumableFrame) -FRAME_TYPE_NAME(RedirectedThreadFrame) -#endif // FEATURE_HIJACK -FRAME_TYPE_NAME(FaultingExceptionFrame) -#ifdef FEATURE_EH_FUNCLETS -FRAME_TYPE_NAME(SoftwareExceptionFrame) -#endif // FEATURE_EH_FUNCLETS -#ifdef DEBUGGING_SUPPORTED -FRAME_TYPE_NAME(FuncEvalFrame) -#endif // DEBUGGING_SUPPORTED -FRAME_TYPE_NAME(HelperMethodFrame) -FRAME_TYPE_NAME(HelperMethodFrame_1OBJ) -FRAME_TYPE_NAME(HelperMethodFrame_2OBJ) -FRAME_TYPE_NAME(HelperMethodFrame_3OBJ) -FRAME_TYPE_NAME(HelperMethodFrame_PROTECTOBJ) -FRAME_ABSTRACT_TYPE_NAME(FramedMethodFrame) -#ifdef FEATURE_COMINTEROP -FRAME_ABSTRACT_TYPE_NAME(UnmanagedToManagedFrame) -FRAME_TYPE_NAME(ComMethodFrame) -FRAME_TYPE_NAME(CLRToCOMMethodFrame) -FRAME_TYPE_NAME(ComPrestubMethodFrame) -#endif // FEATURE_COMINTEROP -FRAME_TYPE_NAME(PInvokeCalliFrame) -#ifdef FEATURE_HIJACK -FRAME_TYPE_NAME(HijackFrame) -#endif // FEATURE_HIJACK -FRAME_TYPE_NAME(PrestubMethodFrame) -FRAME_TYPE_NAME(CallCountingHelperFrame) -FRAME_TYPE_NAME(StubDispatchFrame) -FRAME_TYPE_NAME(ExternalMethodFrame) -#ifdef FEATURE_READYTORUN -FRAME_TYPE_NAME(DynamicHelperFrame) -#endif -FRAME_TYPE_NAME(ProtectByRefsFrame) -FRAME_TYPE_NAME(ProtectValueClassFrame) -FRAME_TYPE_NAME(DebuggerClassInitMarkFrame) -FRAME_TYPE_NAME(DebuggerExitFrame) -FRAME_TYPE_NAME(DebuggerU2MCatchHandlerFrame) -FRAME_TYPE_NAME(InlinedCallFrame) -#if defined(TARGET_X86) && !defined(UNIX_X86_ABI) -FRAME_TYPE_NAME(TailCallFrame) -#endif -FRAME_TYPE_NAME(ExceptionFilterFrame) -#if defined(_DEBUG) -FRAME_TYPE_NAME(AssumeByrefFromJITStack) -#endif // _DEBUG - -#undef FRAME_ABSTRACT_TYPE_NAME -#undef FRAME_TYPE_NAME +#include "FrameTypes.h" //------------------------------------------------------------------------ @@ -260,7 +201,7 @@ FRAME_TYPE_NAME(AssumeByrefFromJITStack) // Forward references class Frame; class FramedMethodFrame; -typedef VPTR(class FramedMethodFrame) PTR_FramedMethodFrame; +typedef DPTR(class FramedMethodFrame) PTR_FramedMethodFrame; struct HijackArgs; struct ResolveCacheElem; #if defined(DACCESS_COMPILE) @@ -280,63 +221,6 @@ class ComCallMethodDesc; #define FRAME_TOP_VALUE ~0 // we want to say -1 here, but gcc has trouble with the signed value #define FRAME_TOP (PTR_Frame(FRAME_TOP_VALUE)) -#ifndef DACCESS_COMPILE - -#if defined(TARGET_UNIX) - -#define DEFINE_DTOR(klass) \ - public: \ - virtual ~klass() { PopIfChained(); } - -#else - -#define DEFINE_DTOR(klass) - -#endif // TARGET_UNIX - -#define DEFINE_VTABLE_GETTER(klass) \ - public: \ - static TADDR GetMethodFrameVPtr() { \ - LIMITED_METHOD_CONTRACT; \ - klass boilerplate(false); \ - return *((TADDR*)&boilerplate); \ - } \ - klass(bool dummy) { LIMITED_METHOD_CONTRACT; } - -#define DEFINE_VTABLE_GETTER_AND_DTOR(klass) \ - DEFINE_VTABLE_GETTER(klass) \ - DEFINE_DTOR(klass) - -#define DEFINE_VTABLE_GETTER_AND_CTOR(klass) \ - DEFINE_VTABLE_GETTER(klass) \ - protected: \ - klass() { LIMITED_METHOD_CONTRACT; } - -#define DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(klass) \ - DEFINE_VTABLE_GETTER_AND_DTOR(klass) \ - protected: \ - klass() { LIMITED_METHOD_CONTRACT; } - -#else - -#define DEFINE_VTABLE_GETTER(klass) \ - public: \ - static TADDR GetMethodFrameVPtr() { \ - LIMITED_METHOD_CONTRACT; \ - return klass::VPtrTargetVTable(); \ - } \ - -#define DEFINE_VTABLE_GETTER_AND_DTOR(klass) \ - DEFINE_VTABLE_GETTER(klass) \ - -#define DEFINE_VTABLE_GETTER_AND_CTOR(klass) \ - DEFINE_VTABLE_GETTER(klass) \ - -#define DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(klass) \ - DEFINE_VTABLE_GETTER_AND_CTOR(klass) \ - -#endif // #ifndef DACCESS_COMPILE - //----------------------------------------------------------------------------- // For reporting on types of frames at runtime. class FrameTypeName @@ -347,6 +231,69 @@ class FrameTypeName }; typedef DPTR(FrameTypeName) PTR_FrameTypeName; +enum class FrameType : TADDR +{ + None = 0, +#define FRAME_TYPE_NAME(frameType) frameType, +#include "FrameTypes.h" + CountPlusOne +}; + +class FrameBase; + +enum ETransitionType +{ + TT_NONE, + TT_M2U, // we can safely cast to a FramedMethodFrame + TT_U2M, // we can safely cast to a UnmanagedToManagedFrame + TT_AppDomain, // transitioniting between AppDomains. + TT_InternalCall, // calling into the CLR (ecall/fcall). +}; + +enum Interception +{ + INTERCEPTION_NONE, + INTERCEPTION_CLASS_INIT, + INTERCEPTION_EXCEPTION, + INTERCEPTION_CONTEXT, + INTERCEPTION_SECURITY, + INTERCEPTION_PRESTUB, + INTERCEPTION_OTHER, + + INTERCEPTION_COUNT +}; + + +void Frame_GcScanRoots(FrameBase *frame, promote_func *fn, ScanContext* sc); +unsigned Frame_GetFrameAttribs(FrameBase *frame); +#ifndef DACCESS_COMPILE +void Frame_ExceptionUnwind(FrameBase *frame); +#endif +BOOL Frame_NeedsUpdateRegDisplay(FrameBase *frame); +BOOL Frame_IsTransitionToNativeFrame(FrameBase *frame); +MethodDesc *Frame_GetFunction(FrameBase* frame); +Assembly *Frame_GetAssembly(FrameBase* frame); +PTR_BYTE Frame_GetIP(FrameBase* frame); +TADDR Frame_GetReturnAddressPtr(FrameBase* frame); +PCODE Frame_GetReturnAddress(FrameBase* frame); +void Frame_UpdateRegDisplay(FrameBase* frame, const PREGDISPLAY, bool updateFloats = false); +int Frame_GetFrameType(FrameBase* frame); +ETransitionType Frame_GetTransitionType(FrameBase* frame); +Interception Frame_GetInterception(FrameBase* frame); +void Frame_GetUnmanagedCallSite(FrameBase* frame, TADDR* ip, TADDR* returnIP, TADDR* returnSP); +BOOL Frame_TraceFrame(FrameBase* frame, Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs); +#ifdef DACCESS_COMPILE +void Frame_EnumMemoryRegions(FrameBase* frame, CLRDataEnumMemoryFlags flags); +#endif // DACCESS_COMPILE +#if defined(_DEBUG) && !defined(DACCESS_COMPILE) +BOOL Frame_Protects(FrameBase* frame, OBJECTREF *ppObjectRef); +#endif // defined(_DEBUG) && !defined(DACCESS_COMPILE) + +// TransitionFrame only apis +class TransitionFrame; +TADDR Frame_GetTransitionBlock(TransitionFrame* frame); +BOOL Frame_SuppressParamTypeArg(TransitionFrame* frame); + //----------------------------------------------------------------------------- // Frame depends on the location of its vtable within the object. This // superclass ensures that the vtable for Frame objects is in the same @@ -355,19 +302,17 @@ typedef DPTR(FrameTypeName) PTR_FrameTypeName; class FrameBase { - VPTR_BASE_VTABLE_CLASS(FrameBase) + const FrameType _frameType; public: - FrameBase() {LIMITED_METHOD_CONTRACT; } + FrameBase(FrameType frameType) : _frameType(frameType) {LIMITED_METHOD_CONTRACT; } - virtual void GcScanRoots(promote_func *fn, ScanContext* sc) { + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { LIMITED_METHOD_CONTRACT; // Nothing to protect } -#ifdef DACCESS_COMPILE - virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) = 0; -#endif + FrameType GetType() { LIMITED_METHOD_DAC_CONTRACT; return _frameType; } }; //------------------------------------------------------------------------ @@ -382,10 +327,22 @@ class Frame : public FrameBase friend void Thread::EnumMemoryRegions(CLRDataEnumMemoryFlags flags); #endif - VPTR_ABSTRACT_VTABLE_CLASS(Frame, FrameBase) - public: + // Should only be called on Frames that derive from TransitionFrame + TADDR GetTransitionBlock_Impl() + { + _ASSERTE(!"Unexpected"); + return (TADDR)0; + } + + // Should only be called on Frames that derive from TransitionFrame + BOOL SuppressParamTypeArg_Impl() + { + _ASSERTE(!"Unexpected"); + return FALSE; + } + //------------------------------------------------------------------------ // Special characteristics of a frame //------------------------------------------------------------------------ @@ -398,7 +355,7 @@ class Frame : public FrameBase FRAME_ATTR_EXACT_DEPTH = 0x20, // This is a helperMethodFrame and a jit helper, but only crawl to the given depth FRAME_ATTR_NO_THREAD_ABORT = 0x40, // This is a helperMethodFrame that should not trigger thread aborts on entry }; - virtual unsigned GetFrameAttribs() + unsigned GetFrameAttribs_Impl() { LIMITED_METHOD_DAC_CONTRACT; return FRAME_ATTR_NONE; @@ -408,7 +365,7 @@ class Frame : public FrameBase // Performs cleanup on an exception unwind //------------------------------------------------------------------------ #ifndef DACCESS_COMPILE - virtual void ExceptionUnwind() + void ExceptionUnwind_Impl() { // Nothing to do here. LIMITED_METHOD_CONTRACT; @@ -417,7 +374,7 @@ class Frame : public FrameBase // Should be overridden to return TRUE if the frame contains register // state of the caller. - virtual BOOL NeedsUpdateRegDisplay() + BOOL NeedsUpdateRegDisplay_Impl() { return FALSE; } @@ -425,22 +382,22 @@ class Frame : public FrameBase //------------------------------------------------------------------------ // Is this a frame used on transition to native code from jitted code? //------------------------------------------------------------------------ - virtual BOOL IsTransitionToNativeFrame() + BOOL IsTransitionToNativeFrame_Impl() { LIMITED_METHOD_CONTRACT; return FALSE; } - virtual MethodDesc *GetFunction() + MethodDesc *GetFunction_Impl() { LIMITED_METHOD_DAC_CONTRACT; return NULL; } - virtual Assembly *GetAssembly() + Assembly *GetAssembly_Impl() { WRAPPER_NO_CONTRACT; - MethodDesc *pMethod = GetFunction(); + MethodDesc *pMethod = Frame_GetFunction(this); if (pMethod != NULL) return pMethod->GetModule()->GetAssembly(); else @@ -449,7 +406,7 @@ class Frame : public FrameBase // indicate the current X86 IP address within the current method // return 0 if the information is not available - virtual PTR_BYTE GetIP() + PTR_BYTE GetIP_Impl() { LIMITED_METHOD_CONTRACT; return NULL; @@ -457,32 +414,26 @@ class Frame : public FrameBase // DACCESS: GetReturnAddressPtr should return the // target address of the return address in the frame. - virtual TADDR GetReturnAddressPtr() + TADDR GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; return 0; } // ASAN doesn't like us messing with the return address. - virtual DISABLE_ASAN PCODE GetReturnAddress() + DISABLE_ASAN PCODE GetReturnAddress_Impl() { WRAPPER_NO_CONTRACT; - TADDR ptr = GetReturnAddressPtr(); + TADDR ptr = Frame_GetReturnAddressPtr(this); return (ptr != 0) ? *PTR_PCODE(ptr) : 0; } #ifndef DACCESS_COMPILE - virtual Object **GetReturnExecutionContextAddr() - { - LIMITED_METHOD_CONTRACT; - return NULL; - } - // ASAN doesn't like us messing with the return address. void DISABLE_ASAN SetReturnAddress(TADDR val) { WRAPPER_NO_CONTRACT; - TADDR ptr = GetReturnAddressPtr(); + TADDR ptr = Frame_GetReturnAddressPtr(this); _ASSERTE(ptr != (TADDR)NULL); *(TADDR*)ptr = val; } @@ -508,7 +459,7 @@ class Frame : public FrameBase // UpdateRegDisplay is generally used to fill out the REGDISPLAY parameter, some // overrides (e.g., code:ResumableFrame::UpdateRegDisplay) will actually READ what // you pass in. So be sure to pass in a valid or zeroed out REGDISPLAY. - virtual void UpdateRegDisplay(const PREGDISPLAY, bool updateFloats = false) + void UpdateRegDisplay_Impl(const PREGDISPLAY, bool updateFloats) { LIMITED_METHOD_DAC_CONTRACT; return; @@ -520,21 +471,12 @@ class Frame : public FrameBase public: - enum ETransitionType - { - TT_NONE, - TT_M2U, // we can safely cast to a FramedMethodFrame - TT_U2M, // we can safely cast to a UnmanagedToManagedFrame - TT_AppDomain, // transitioniting between AppDomains. - TT_InternalCall, // calling into the CLR (ecall/fcall). - }; - // Get the type of transition. // M-->U, U-->M - virtual ETransitionType GetTransitionType() + ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; - return TT_NONE; + return ETransitionType::TT_NONE; } enum @@ -555,7 +497,7 @@ class Frame : public FrameBase TYPE_COUNT }; - virtual int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_INTERNAL; @@ -566,20 +508,7 @@ class Frame : public FrameBase // with frames of various types. GetInterception() indicates whether // the frame was set up for execution of such interceptors - enum Interception - { - INTERCEPTION_NONE, - INTERCEPTION_CLASS_INIT, - INTERCEPTION_EXCEPTION, - INTERCEPTION_CONTEXT, - INTERCEPTION_SECURITY, - INTERCEPTION_PRESTUB, - INTERCEPTION_OTHER, - - INTERCEPTION_COUNT - }; - - virtual Interception GetInterception() + Interception GetInterception_Impl() { LIMITED_METHOD_DAC_CONTRACT; return INTERCEPTION_NONE; @@ -593,9 +522,9 @@ class Frame : public FrameBase // returnSP - the location returnIP is pushed onto the stack // during the call. // - virtual void GetUnmanagedCallSite(TADDR* ip, - TADDR* returnIP, - TADDR* returnSP) + void GetUnmanagedCallSite_Impl(TADDR* ip, + TADDR* returnIP, + TADDR* returnSP) { LIMITED_METHOD_CONTRACT; if (ip) @@ -611,7 +540,7 @@ class Frame : public FrameBase // Return where the frame will execute next - the result is filled // into the given "trace" structure. The frame is responsible for // detecting where it is in its execution lifetime. - virtual BOOL TraceFrame(Thread *thread, BOOL fromPatch, + BOOL TraceFrame_Impl(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) { LIMITED_METHOD_CONTRACT; @@ -621,14 +550,13 @@ class Frame : public FrameBase } #ifdef DACCESS_COMPILE - virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) + void EnumMemoryRegions_Impl(CLRDataEnumMemoryFlags flags) { WRAPPER_NO_CONTRACT; - DAC_ENUM_VTHIS(); // Many frames store a MethodDesc pointer in m_Datum // so pick that up automatically. - MethodDesc* func = GetFunction(); + MethodDesc* func = Frame_GetFunction(this); if (func) { func->EnumMemoryRegions(flags); @@ -661,7 +589,7 @@ class Frame : public FrameBase } #if defined(_DEBUG) && !defined(DACCESS_COMPILE) - virtual BOOL Protects(OBJECTREF *ppObjectRef) + BOOL Protects_Impl(OBJECTREF *ppObjectRef) { LIMITED_METHOD_CONTRACT; return FALSE; @@ -682,20 +610,9 @@ class Frame : public FrameBase static void __stdcall LogTransition(Frame* frame); void LogFrame(int LF, int LL); // General purpose logging. void LogFrameChain(int LF, int LL); // Log the whole chain. - virtual const char* GetFrameTypeName() {return NULL;} static PTR_CSTR GetFrameTypeName(TADDR vtbl); #endif - //------------------------------------------------------------------------ - // Returns the address of a security object or - // null if there is no space for an object on this frame. - //------------------------------------------------------------------------ - virtual OBJECTREF *GetAddrOfSecurityDesc() - { - LIMITED_METHOD_CONTRACT; - return NULL; - } - private: // Pointer to the next frame up the stack. @@ -741,14 +658,17 @@ class Frame : public FrameBase } protected: +#ifndef DACCESS_COMPILE // Frame is considered an abstract class: this protected constructor // causes any attempt to instantiate one to fail at compile-time. - Frame() - : m_Next(dac_cast(nullptr)) + Frame(FrameType frameType) + : FrameBase(frameType), m_Next(dac_cast(nullptr)) { LIMITED_METHOD_CONTRACT; } +#endif // DACCESS_COMPILE + #ifndef DACCESS_COMPILE #if !defined(TARGET_X86) || defined(TARGET_UNIX) static void UpdateFloatingPointRegisters(const PREGDISPLAY pRD); @@ -756,7 +676,7 @@ class Frame : public FrameBase #endif // DACCESS_COMPILE #if defined(TARGET_UNIX) && !defined(DACCESS_COMPILE) - virtual ~Frame() { LIMITED_METHOD_CONTRACT; } + ~Frame() { PopIfChained(); } void PopIfChained(); #endif // TARGET_UNIX && !DACCESS_COMPILE @@ -780,26 +700,29 @@ class Frame : public FrameBase class ResumableFrame : public Frame { - VPTR_VTABLE_CLASS(ResumableFrame, Frame) - public: #ifndef DACCESS_COMPILE - ResumableFrame(T_CONTEXT* regs) { + ResumableFrame(T_CONTEXT* regs) : Frame(FrameType::ResumableFrame) { + LIMITED_METHOD_CONTRACT; + m_Regs = regs; + } + + ResumableFrame(FrameType frameType, T_CONTEXT* regs) : Frame(frameType) { LIMITED_METHOD_CONTRACT; m_Regs = regs; } #endif - virtual TADDR GetReturnAddressPtr(); + TADDR GetReturnAddressPtr_Impl(); - virtual BOOL NeedsUpdateRegDisplay() + BOOL NeedsUpdateRegDisplay_Impl() { return TRUE; } - virtual void UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats = false); + void UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats); - virtual unsigned GetFrameAttribs() { + unsigned GetFrameAttribs_Impl() { LIMITED_METHOD_DAC_CONTRACT; return FRAME_ATTR_RESUMABLE; // Treat the next frame as the top frame. } @@ -810,15 +733,15 @@ class ResumableFrame : public Frame } #ifdef DACCESS_COMPILE - virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) + void EnumMemoryRegions_Impl(CLRDataEnumMemoryFlags flags) { WRAPPER_NO_CONTRACT; - Frame::EnumMemoryRegions(flags); + Frame::EnumMemoryRegions_Impl(flags); m_Regs.EnumMem(); } #endif - virtual void GcScanRoots(promote_func* fn, ScanContext* sc) + void GcScanRoots_Impl(promote_func* fn, ScanContext* sc) { WRAPPER_NO_CONTRACT; @@ -862,9 +785,6 @@ class ResumableFrame : public Frame protected: PTR_CONTEXT m_Regs; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(ResumableFrame) }; @@ -874,20 +794,14 @@ class ResumableFrame : public Frame class RedirectedThreadFrame : public ResumableFrame { - VPTR_VTABLE_CLASS(RedirectedThreadFrame, ResumableFrame) - VPTR_UNIQUE(VPTR_UNIQUE_RedirectedThreadFrame) - public: #ifndef DACCESS_COMPILE - RedirectedThreadFrame(T_CONTEXT *regs) : ResumableFrame(regs) { + RedirectedThreadFrame(T_CONTEXT *regs) : ResumableFrame(FrameType::RedirectedThreadFrame, regs) { LIMITED_METHOD_CONTRACT; } - virtual void ExceptionUnwind(); + void ExceptionUnwind_Impl(); #endif - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(RedirectedThreadFrame) }; typedef DPTR(RedirectedThreadFrame) PTR_RedirectedThreadFrame; @@ -896,8 +810,8 @@ inline BOOL ISREDIRECTEDTHREAD(Thread * thread) { WRAPPER_NO_CONTRACT; return (thread->GetFrame() != FRAME_TOP && - thread->GetFrame()->GetVTablePtr() == - RedirectedThreadFrame::GetMethodFrameVPtr()); + thread->GetFrame()->GetType() == + FrameType::RedirectedThreadFrame); } inline T_CONTEXT * GETREDIRECTEDCONTEXT(Thread * thread) @@ -927,17 +841,20 @@ inline CONTEXT * GETREDIRECTEDCONTEXT(Thread * thread) { LIMITED_METHOD_CONTRACT class TransitionFrame : public Frame { - VPTR_ABSTRACT_VTABLE_CLASS(TransitionFrame, Frame) +#ifndef DACCESS_COMPILE +protected: + TransitionFrame(FrameType frameType) : Frame(frameType) { + LIMITED_METHOD_CONTRACT; + } +#endif public: - virtual TADDR GetTransitionBlock() = 0; - // DACCESS: GetReturnAddressPtr should return the // target address of the return address in the frame. - virtual TADDR GetReturnAddressPtr() + TADDR GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; - return GetTransitionBlock() + TransitionBlock::GetOffsetOfReturnAddress(); + return Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfReturnAddress(); } //--------------------------------------------------------------- @@ -965,7 +882,7 @@ class TransitionFrame : public Frame // Gets value indicating whether the generic parameter type // argument should be suppressed. //--------------------------------------------------------------- - virtual BOOL SuppressParamTypeArg() + BOOL SuppressParamTypeArg_Impl() { return FALSE; } @@ -987,34 +904,34 @@ class TransitionFrame : public Frame { LIMITED_METHOD_DAC_CONTRACT; return dac_cast( - GetTransitionBlock() + TransitionBlock::GetOffsetOfCalleeSavedRegisters()); + Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfCalleeSavedRegisters()); } ArgumentRegisters *GetArgumentRegisters() { LIMITED_METHOD_DAC_CONTRACT; return dac_cast( - GetTransitionBlock() + TransitionBlock::GetOffsetOfArgumentRegisters()); + Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfArgumentRegisters()); } TADDR GetSP() { LIMITED_METHOD_DAC_CONTRACT; - return GetTransitionBlock() + sizeof(TransitionBlock); + return Frame_GetTransitionBlock(this) + sizeof(TransitionBlock); } - virtual BOOL NeedsUpdateRegDisplay() + BOOL NeedsUpdateRegDisplay_Impl() { return TRUE; } - virtual void UpdateRegDisplay(const PREGDISPLAY, bool updateFloats = false); + void UpdateRegDisplay_Impl(const PREGDISPLAY, bool updateFloats = false); #ifdef TARGET_X86 void UpdateRegDisplayHelper(const PREGDISPLAY, UINT cbStackPop); #endif #if defined (_DEBUG) && !defined (DACCESS_COMPILE) - virtual BOOL Protects(OBJECTREF *ppORef); + BOOL Protects_Impl(OBJECTREF *ppORef); #endif //defined (_DEBUG) && defined (DACCESS_COMPILE) // For use by classes deriving from FramedMethodFrame. @@ -1028,12 +945,6 @@ class TransitionFrame : public Frame #ifdef TARGET_X86 UINT CbStackPopUsingGCRefMap(PTR_BYTE pGCRefMap); #endif - -protected: - TransitionFrame() - { - LIMITED_METHOD_CONTRACT; - } }; //----------------------------------------------------------------------- @@ -1065,16 +976,14 @@ class FaultingExceptionFrame : public Frame TADDR m_SSP; #endif - VPTR_VTABLE_CLASS(FaultingExceptionFrame, Frame) - public: #ifndef DACCESS_COMPILE - FaultingExceptionFrame() { + FaultingExceptionFrame() : Frame(FrameType::FaultingExceptionFrame) { LIMITED_METHOD_CONTRACT; } #endif - virtual TADDR GetReturnAddressPtr() + TADDR GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; return PTR_HOST_MEMBER_TADDR(FaultingExceptionFrame, this, m_ReturnAddress); @@ -1083,13 +992,13 @@ class FaultingExceptionFrame : public Frame void Init(T_CONTEXT *pContext); void InitAndLink(T_CONTEXT *pContext); - Interception GetInterception() + Interception GetInterception_Impl() { LIMITED_METHOD_DAC_CONTRACT; return INTERCEPTION_EXCEPTION; } - unsigned GetFrameAttribs() + unsigned GetFrameAttribs_Impl() { LIMITED_METHOD_DAC_CONTRACT; #ifdef FEATURE_EH_FUNCLETS @@ -1132,15 +1041,12 @@ class FaultingExceptionFrame : public Frame } #endif - virtual BOOL NeedsUpdateRegDisplay() + BOOL NeedsUpdateRegDisplay_Impl() { return TRUE; } - virtual void UpdateRegDisplay(const PREGDISPLAY, bool updateFloats = false); - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_DTOR(FaultingExceptionFrame) + void UpdateRegDisplay_Impl(const PREGDISPLAY, bool updateFloats = false); }; #ifdef FEATURE_EH_FUNCLETS @@ -1151,16 +1057,14 @@ class SoftwareExceptionFrame : public Frame T_CONTEXT m_Context; T_KNONVOLATILE_CONTEXT_POINTERS m_ContextPointers; - VPTR_VTABLE_CLASS(SoftwareExceptionFrame, Frame) - public: #ifndef DACCESS_COMPILE - SoftwareExceptionFrame() { + SoftwareExceptionFrame() : Frame(FrameType::SoftwareExceptionFrame) { LIMITED_METHOD_CONTRACT; } #endif - virtual TADDR GetReturnAddressPtr() + TADDR GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; return PTR_HOST_MEMBER_TADDR(SoftwareExceptionFrame, this, m_ReturnAddress); @@ -1169,19 +1073,19 @@ class SoftwareExceptionFrame : public Frame void Init(); void InitAndLink(Thread *pThread); - Interception GetInterception() + Interception GetInterception_Impl() { LIMITED_METHOD_DAC_CONTRACT; return INTERCEPTION_EXCEPTION; } - virtual ETransitionType GetTransitionType() + ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TT_InternalCall; } - unsigned GetFrameAttribs() + unsigned GetFrameAttribs_Impl() { LIMITED_METHOD_DAC_CONTRACT; return FRAME_ATTR_EXCEPTION; @@ -1193,15 +1097,12 @@ class SoftwareExceptionFrame : public Frame return &m_Context; } - virtual BOOL NeedsUpdateRegDisplay() + BOOL NeedsUpdateRegDisplay_Impl() { return TRUE; } - virtual void UpdateRegDisplay(const PREGDISPLAY, bool updateFloats = false); - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_DTOR(SoftwareExceptionFrame) + void UpdateRegDisplay_Impl(const PREGDISPLAY, bool updateFloats = false); }; #endif // FEATURE_EH_FUNCLETS @@ -1225,8 +1126,6 @@ typedef DPTR(class DebuggerEval) PTR_DebuggerEval; class FuncEvalFrame : public Frame { - VPTR_VTABLE_CLASS(FuncEvalFrame, Frame) - TADDR m_ReturnAddress; PTR_DebuggerEval m_pDebuggerEval; @@ -1234,7 +1133,7 @@ class FuncEvalFrame : public Frame public: #ifndef DACCESS_COMPILE - FuncEvalFrame(DebuggerEval *pDebuggerEval, TADDR returnAddress, BOOL showFrame) + FuncEvalFrame(DebuggerEval *pDebuggerEval, TADDR returnAddress, BOOL showFrame) : Frame(FrameType::FuncEvalFrame) { LIMITED_METHOD_CONTRACT; m_pDebuggerEval = pDebuggerEval; @@ -1243,30 +1142,30 @@ class FuncEvalFrame : public Frame } #endif - virtual BOOL IsTransitionToNativeFrame() + BOOL IsTransitionToNativeFrame_Impl() { LIMITED_METHOD_CONTRACT; return FALSE; } - virtual int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_FUNC_EVAL; } - virtual unsigned GetFrameAttribs(); + unsigned GetFrameAttribs_Impl(); - virtual BOOL NeedsUpdateRegDisplay() + BOOL NeedsUpdateRegDisplay_Impl() { return TRUE; } - virtual void UpdateRegDisplay(const PREGDISPLAY, bool updateFloats = false); + void UpdateRegDisplay_Impl(const PREGDISPLAY, bool updateFloats = false); - virtual DebuggerEval * GetDebuggerEval(); + DebuggerEval * GetDebuggerEval(); - virtual TADDR GetReturnAddressPtr(); + TADDR GetReturnAddressPtr_Impl(); /* * ShowFrame @@ -1280,12 +1179,9 @@ class FuncEvalFrame : public Frame return m_showFrame; } - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(FuncEvalFrame) }; -typedef VPTR(FuncEvalFrame) PTR_FuncEvalFrame; +typedef DPTR(FuncEvalFrame) PTR_FuncEvalFrame; #endif // DEBUGGING_SUPPORTED //---------------------------------------------------------------------------------------------- @@ -1297,8 +1193,6 @@ typedef VPTR(FuncEvalFrame) PTR_FuncEvalFrame; class HelperMethodFrame : public Frame { - VPTR_VTABLE_CLASS(HelperMethodFrame, Frame); - public: #ifndef DACCESS_COMPILE // Lazy initialization of HelperMethodFrame. Need to @@ -1306,7 +1200,7 @@ class HelperMethodFrame : public Frame // If this is an FCall, the first param is the entry point for the FCALL. // The MethodDesc will be looked up form this (lazily), and this method // will be used in stack reporting, if this is not an FCall pass a 0 - FORCEINLINE HelperMethodFrame(void* fCallFtnEntry, unsigned attribs = 0) + FORCEINLINE HelperMethodFrame(void* fCallFtnEntry, unsigned attribs = 0, FrameType frameType = FrameType::HelperMethodFrame) : Frame(frameType) { WRAPPER_NO_CONTRACT; // Most of the initialization is actually done in HelperMethodFrame::Push() @@ -1316,13 +1210,13 @@ class HelperMethodFrame : public Frame } #endif // DACCESS_COMPILE - virtual int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_HELPER_METHOD_FRAME; }; - virtual PCODE GetReturnAddress() + PCODE GetReturnAddress_Impl() { LIMITED_METHOD_DAC_CONTRACT; @@ -1342,25 +1236,25 @@ class HelperMethodFrame : public Frame return m_MachState.GetRetAddr(); } - virtual MethodDesc* GetFunction(); + MethodDesc* GetFunction_Impl(); - virtual BOOL NeedsUpdateRegDisplay() + BOOL NeedsUpdateRegDisplay_Impl() { return TRUE; } - virtual void UpdateRegDisplay(const PREGDISPLAY, bool updateFloats = false); + void UpdateRegDisplay_Impl(const PREGDISPLAY, bool updateFloats = false); - virtual Interception GetInterception() + Interception GetInterception_Impl() { WRAPPER_NO_CONTRACT; LIMITED_METHOD_DAC_CONTRACT; - if (GetFrameAttribs() & FRAME_ATTR_EXCEPTION) + if (Frame_GetFrameAttribs(this) & FRAME_ATTR_EXCEPTION) return(INTERCEPTION_EXCEPTION); return(INTERCEPTION_NONE); } - virtual ETransitionType GetTransitionType() + ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TT_InternalCall; @@ -1387,17 +1281,17 @@ class HelperMethodFrame : public Frame } #endif - virtual unsigned GetFrameAttribs() + unsigned GetFrameAttribs_Impl() { LIMITED_METHOD_DAC_CONTRACT; return(m_Attribs); } #ifdef DACCESS_COMPILE - virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) + void EnumMemoryRegions_Impl(CLRDataEnumMemoryFlags flags) { WRAPPER_NO_CONTRACT; - Frame::EnumMemoryRegions(flags); + Frame::EnumMemoryRegions_Impl(flags); } #endif @@ -1438,9 +1332,6 @@ class HelperMethodFrame : public Frame TADDR m_FCallEntry; // used to determine our identity for stack traces LazyMachState m_MachState; // pRetAddr points to the return address and the stack arguments - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(HelperMethodFrame) }; // Restores registers saved in m_MachState @@ -1475,12 +1366,10 @@ inline void DoPromote(promote_func *fn, ScanContext* sc, OBJECTREF *address, BOO class HelperMethodFrame_1OBJ : public HelperMethodFrame { - VPTR_VTABLE_CLASS(HelperMethodFrame_1OBJ, HelperMethodFrame) - public: #if !defined(DACCESS_COMPILE) HelperMethodFrame_1OBJ(void* fCallFtnEntry, unsigned attribs, OBJECTREF* aGCPtr1) - : HelperMethodFrame(fCallFtnEntry, attribs) + : HelperMethodFrame(fCallFtnEntry, attribs, FrameType::HelperMethodFrame_1OBJ) { LIMITED_METHOD_CONTRACT; gcPtrs[0] = aGCPtr1; @@ -1496,11 +1385,11 @@ class HelperMethodFrame_1OBJ : public HelperMethodFrame INDEBUG(Thread::ObjectRefProtected(objPtr);) } - virtual void GcScanRoots(promote_func *fn, ScanContext* sc) + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { WRAPPER_NO_CONTRACT; DoPromote(fn, sc, gcPtrs[0], FALSE); - HelperMethodFrame::GcScanRoots(fn, sc); + HelperMethodFrame::GcScanRoots_Impl(fn, sc); } #ifdef _DEBUG @@ -1513,7 +1402,7 @@ class HelperMethodFrame_1OBJ : public HelperMethodFrame } #endif // DACCESS_COMPILE - BOOL Protects(OBJECTREF *ppORef) + BOOL Protects_Impl(OBJECTREF *ppORef) { LIMITED_METHOD_CONTRACT; return (ppORef == gcPtrs[0]) ? TRUE : FALSE; @@ -1523,9 +1412,6 @@ class HelperMethodFrame_1OBJ : public HelperMethodFrame private: PTR_OBJECTREF gcPtrs[1]; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(HelperMethodFrame_1OBJ) }; @@ -1535,8 +1421,6 @@ class HelperMethodFrame_1OBJ : public HelperMethodFrame class HelperMethodFrame_2OBJ : public HelperMethodFrame { - VPTR_VTABLE_CLASS(HelperMethodFrame_2OBJ, HelperMethodFrame) - public: #if !defined(DACCESS_COMPILE) HelperMethodFrame_2OBJ( @@ -1544,7 +1428,7 @@ class HelperMethodFrame_2OBJ : public HelperMethodFrame unsigned attribs, OBJECTREF* aGCPtr1, OBJECTREF* aGCPtr2) - : HelperMethodFrame(fCallFtnEntry, attribs) + : HelperMethodFrame(fCallFtnEntry, attribs, FrameType::HelperMethodFrame_2OBJ) { LIMITED_METHOD_CONTRACT; gcPtrs[0] = aGCPtr1; @@ -1556,12 +1440,12 @@ class HelperMethodFrame_2OBJ : public HelperMethodFrame } #endif - virtual void GcScanRoots(promote_func *fn, ScanContext* sc) + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { WRAPPER_NO_CONTRACT; DoPromote(fn, sc, gcPtrs[0], FALSE); DoPromote(fn, sc, gcPtrs[1], FALSE); - HelperMethodFrame::GcScanRoots(fn, sc); + HelperMethodFrame::GcScanRoots_Impl(fn, sc); } #ifdef _DEBUG @@ -1575,7 +1459,7 @@ class HelperMethodFrame_2OBJ : public HelperMethodFrame } #endif // DACCESS_COMPILE - BOOL Protects(OBJECTREF *ppORef) + BOOL Protects_Impl(OBJECTREF *ppORef) { LIMITED_METHOD_CONTRACT; return (ppORef == gcPtrs[0] || ppORef == gcPtrs[1]) ? TRUE : FALSE; @@ -1584,9 +1468,6 @@ class HelperMethodFrame_2OBJ : public HelperMethodFrame private: PTR_OBJECTREF gcPtrs[2]; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(HelperMethodFrame_2OBJ) }; //----------------------------------------------------------------------------- @@ -1595,8 +1476,6 @@ class HelperMethodFrame_2OBJ : public HelperMethodFrame class HelperMethodFrame_3OBJ : public HelperMethodFrame { - VPTR_VTABLE_CLASS(HelperMethodFrame_3OBJ, HelperMethodFrame) - public: #if !defined(DACCESS_COMPILE) HelperMethodFrame_3OBJ( @@ -1605,7 +1484,7 @@ class HelperMethodFrame_3OBJ : public HelperMethodFrame OBJECTREF* aGCPtr1, OBJECTREF* aGCPtr2, OBJECTREF* aGCPtr3) - : HelperMethodFrame(fCallFtnEntry, attribs) + : HelperMethodFrame(fCallFtnEntry, attribs, FrameType::HelperMethodFrame_3OBJ) { LIMITED_METHOD_CONTRACT; gcPtrs[0] = aGCPtr1; @@ -1620,13 +1499,13 @@ class HelperMethodFrame_3OBJ : public HelperMethodFrame } #endif - virtual void GcScanRoots(promote_func *fn, ScanContext* sc) + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { WRAPPER_NO_CONTRACT; DoPromote(fn, sc, gcPtrs[0], FALSE); DoPromote(fn, sc, gcPtrs[1], FALSE); DoPromote(fn, sc, gcPtrs[2], FALSE); - HelperMethodFrame::GcScanRoots(fn, sc); + HelperMethodFrame::GcScanRoots_Impl(fn, sc); } #ifdef _DEBUG @@ -1641,7 +1520,7 @@ class HelperMethodFrame_3OBJ : public HelperMethodFrame } #endif // DACCESS_COMPILE - BOOL Protects(OBJECTREF *ppORef) + BOOL Protects_Impl(OBJECTREF *ppORef) { LIMITED_METHOD_CONTRACT; return (ppORef == gcPtrs[0] || ppORef == gcPtrs[1] || ppORef == gcPtrs[2]) ? TRUE : FALSE; @@ -1650,9 +1529,6 @@ class HelperMethodFrame_3OBJ : public HelperMethodFrame private: PTR_OBJECTREF gcPtrs[3]; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(HelperMethodFrame_3OBJ) }; @@ -1662,12 +1538,10 @@ class HelperMethodFrame_3OBJ : public HelperMethodFrame class HelperMethodFrame_PROTECTOBJ : public HelperMethodFrame { - VPTR_VTABLE_CLASS(HelperMethodFrame_PROTECTOBJ, HelperMethodFrame) - public: #if !defined(DACCESS_COMPILE) HelperMethodFrame_PROTECTOBJ(void* fCallFtnEntry, unsigned attribs, OBJECTREF* pObjRefs, int numObjRefs) - : HelperMethodFrame(fCallFtnEntry, attribs) + : HelperMethodFrame(fCallFtnEntry, attribs, FrameType::HelperMethodFrame_PROTECTOBJ) { LIMITED_METHOD_CONTRACT; m_pObjRefs = pObjRefs; @@ -1681,13 +1555,13 @@ class HelperMethodFrame_PROTECTOBJ : public HelperMethodFrame } #endif - virtual void GcScanRoots(promote_func *fn, ScanContext* sc) + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { WRAPPER_NO_CONTRACT; for (UINT i = 0; i < m_numObjRefs; i++) { DoPromote(fn, sc, &m_pObjRefs[i], FALSE); } - HelperMethodFrame::GcScanRoots(fn, sc); + HelperMethodFrame::GcScanRoots_Impl(fn, sc); } #ifdef _DEBUG @@ -1702,7 +1576,7 @@ class HelperMethodFrame_PROTECTOBJ : public HelperMethodFrame } #endif // DACCESS_COMPILE - BOOL Protects(OBJECTREF *ppORef) + BOOL Protects_Impl(OBJECTREF *ppORef) { LIMITED_METHOD_CONTRACT; for (UINT i = 0; i < m_numObjRefs; i++) { @@ -1716,15 +1590,10 @@ class HelperMethodFrame_PROTECTOBJ : public HelperMethodFrame private: PTR_OBJECTREF m_pObjRefs; UINT m_numObjRefs; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(HelperMethodFrame_PROTECTOBJ) }; class FramedMethodFrame : public TransitionFrame { - VPTR_ABSTRACT_VTABLE_CLASS(FramedMethodFrame, TransitionFrame) - TADDR m_pTransitionBlock; protected: @@ -1732,20 +1601,20 @@ class FramedMethodFrame : public TransitionFrame public: #ifndef DACCESS_COMPILE - FramedMethodFrame(TransitionBlock * pTransitionBlock, MethodDesc * pMD) - : m_pTransitionBlock(dac_cast(pTransitionBlock)), m_pMD(pMD) + FramedMethodFrame(FrameType frameType, TransitionBlock * pTransitionBlock, MethodDesc * pMD) + : TransitionFrame(frameType), m_pTransitionBlock(dac_cast(pTransitionBlock)), m_pMD(pMD) { LIMITED_METHOD_CONTRACT; } #endif // DACCESS_COMPILE - virtual TADDR GetTransitionBlock() + TADDR GetTransitionBlock_Impl() { LIMITED_METHOD_DAC_CONTRACT; return m_pTransitionBlock; } - virtual MethodDesc *GetFunction() + MethodDesc *GetFunction_Impl() { LIMITED_METHOD_DAC_CONTRACT; return m_pMD; @@ -1766,13 +1635,13 @@ class FramedMethodFrame : public TransitionFrame } #endif - virtual ETransitionType GetTransitionType() + ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TT_M2U; // we can safely cast to a FramedMethodFrame } - int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_CALL; @@ -1804,9 +1673,9 @@ class FramedMethodFrame : public TransitionFrame { LIMITED_METHOD_DAC_CONTRACT; #ifdef COM_STUBS_SEPARATE_FP_LOCATIONS - TADDR p = GetTransitionBlock() + GetFPArgOffset(0); + TADDR p = Frame_GetTransitionBlock(this) + GetFPArgOffset(0); #else - TADDR p = GetTransitionBlock() - TransitionBlock::GetNegSpaceSize(); + TADDR p = Frame_GetTransitionBlock(this) - TransitionBlock::GetNegSpaceSize(); #endif // Return value is right before the transition block (or floating point spill area on AMD64) for frames that need it // (code:TPMethodFrame and code:CLRToCOMMethodFrame) @@ -1817,12 +1686,6 @@ class FramedMethodFrame : public TransitionFrame #endif return dac_cast(p); } - -protected: - FramedMethodFrame() - { - LIMITED_METHOD_CONTRACT; - } }; @@ -1836,20 +1699,26 @@ class UnmanagedToManagedFrame : public Frame { friend class CheckAsmOffsets; - VPTR_ABSTRACT_VTABLE_CLASS_AND_CTOR(UnmanagedToManagedFrame, Frame) +protected: +#ifndef DACCESS_COMPILE + UnmanagedToManagedFrame(FrameType frameType) : Frame(frameType) + { + LIMITED_METHOD_CONTRACT; + } +#endif // DACCESS_COMPILE public: // DACCESS: GetReturnAddressPtr should return the // target address of the return address in the frame. - virtual TADDR GetReturnAddressPtr() + TADDR GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; return PTR_HOST_MEMBER_TADDR(UnmanagedToManagedFrame, this, m_ReturnAddress); } - virtual PCODE GetReturnAddress(); + PCODE GetReturnAddress_Impl(); // Retrieves pointer to the lowest-addressed argument on // the stack. Depending on the calling convention, this @@ -1880,7 +1749,7 @@ class UnmanagedToManagedFrame : public Frame return m_pvDatum; } - int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_ENTRY; @@ -1889,7 +1758,7 @@ class UnmanagedToManagedFrame : public Frame //------------------------------------------------------------------------ // For the debugger. //------------------------------------------------------------------------ - virtual ETransitionType GetTransitionType() + ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TT_U2M; @@ -1899,7 +1768,7 @@ class UnmanagedToManagedFrame : public Frame // Performs cleanup on an exception unwind //------------------------------------------------------------------------ #ifndef DACCESS_COMPILE - virtual void ExceptionUnwind(); + void ExceptionUnwind_Impl(); #endif protected: @@ -1932,10 +1801,13 @@ class UnmanagedToManagedFrame : public Frame class ComMethodFrame : public UnmanagedToManagedFrame { - VPTR_VTABLE_CLASS(ComMethodFrame, UnmanagedToManagedFrame) - VPTR_UNIQUE(VPTR_UNIQUE_ComMethodFrame) - public: +#ifndef DACCESS_COMPILE + ComMethodFrame(FrameType frameType = FrameType::ComMethodFrame) : UnmanagedToManagedFrame(FrameType::ComMethodFrame) + { + LIMITED_METHOD_CONTRACT; + } +#endif // DACCESS_COMPILE #ifdef TARGET_X86 // Return the # of stack bytes pushed by the unmanaged caller. @@ -1951,10 +1823,6 @@ class ComMethodFrame : public UnmanagedToManagedFrame #ifndef DACCESS_COMPILE static void DoSecondPassHandlerCleanup(Frame * pCurFrame); #endif // !DACCESS_COMPILE - -protected: - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(ComMethodFrame) }; typedef DPTR(class ComMethodFrame) PTR_ComMethodFrame; @@ -1965,34 +1833,29 @@ typedef DPTR(class ComMethodFrame) PTR_ComMethodFrame; class CLRToCOMMethodFrame : public FramedMethodFrame { - VPTR_VTABLE_CLASS(CLRToCOMMethodFrame, FramedMethodFrame) - public: CLRToCOMMethodFrame(TransitionBlock * pTransitionBlock, MethodDesc * pMethodDesc); - virtual void GcScanRoots(promote_func *fn, ScanContext* sc); + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc); - virtual BOOL IsTransitionToNativeFrame() + BOOL IsTransitionToNativeFrame_Impl() { LIMITED_METHOD_CONTRACT; return TRUE; } - int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_EXIT; } - void GetUnmanagedCallSite(TADDR* ip, + void GetUnmanagedCallSite_Impl(TADDR* ip, TADDR* returnIP, TADDR* returnSP); - BOOL TraceFrame(Thread *thread, BOOL fromPatch, + BOOL TraceFrame_Impl(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs); - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(CLRToCOMMethodFrame) }; #endif // FEATURE_COMINTEROP @@ -2003,31 +1866,29 @@ class CLRToCOMMethodFrame : public FramedMethodFrame class PInvokeCalliFrame : public FramedMethodFrame { - VPTR_VTABLE_CLASS(PInvokeCalliFrame, FramedMethodFrame) - PTR_VASigCookie m_pVASigCookie; PCODE m_pUnmanagedTarget; public: PInvokeCalliFrame(TransitionBlock * pTransitionBlock, VASigCookie * pVASigCookie, PCODE pUnmanagedTarget); - virtual void GcScanRoots(promote_func *fn, ScanContext* sc) + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { WRAPPER_NO_CONTRACT; - FramedMethodFrame::GcScanRoots(fn, sc); + FramedMethodFrame::GcScanRoots_Impl(fn, sc); PromoteCallerStack(fn, sc); } void PromoteCallerStack(promote_func* fn, ScanContext* sc); // not a method - virtual MethodDesc *GetFunction() + MethodDesc *GetFunction_Impl() { LIMITED_METHOD_DAC_CONTRACT; return NULL; } - int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_INTERCEPTION; @@ -2046,10 +1907,10 @@ class PInvokeCalliFrame : public FramedMethodFrame } #ifdef TARGET_X86 - virtual void UpdateRegDisplay(const PREGDISPLAY, bool updateFloats = false); + void UpdateRegDisplay_Impl(const PREGDISPLAY, bool updateFloats = false); #endif // TARGET_X86 - BOOL TraceFrame(Thread *thread, BOOL fromPatch, + BOOL TraceFrame_Impl(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) { WRAPPER_NO_CONTRACT; @@ -2057,9 +1918,6 @@ class PInvokeCalliFrame : public FramedMethodFrame trace->InitForUnmanaged(GetPInvokeCalliTarget()); return TRUE; } - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(PInvokeCalliFrame) }; // Some context-related forwards. @@ -2071,30 +1929,27 @@ class PInvokeCalliFrame : public FramedMethodFrame //------------------------------------------------------------------------ class HijackFrame : public Frame { - VPTR_VTABLE_CLASS(HijackFrame, Frame) - VPTR_UNIQUE(VPTR_UNIQUE_HijackFrame); - public: // DACCESS: GetReturnAddressPtr should return the // target address of the return address in the frame. - virtual TADDR GetReturnAddressPtr() + TADDR GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; return PTR_HOST_MEMBER_TADDR(HijackFrame, this, m_ReturnAddress); } - virtual BOOL NeedsUpdateRegDisplay() + BOOL NeedsUpdateRegDisplay_Impl() { LIMITED_METHOD_CONTRACT; return TRUE; } - virtual void UpdateRegDisplay(const PREGDISPLAY, bool updateFloats = false); + void UpdateRegDisplay_Impl(const PREGDISPLAY, bool updateFloats = false); #ifdef TARGET_X86 // On x86 we need to specialcase return values - virtual void GcScanRoots(promote_func *fn, ScanContext* sc); + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc); #else // On non-x86 platforms HijackFrame is just a more compact form of a resumable // frame with main difference that OnHijackTripThread captures just the registers @@ -2102,7 +1957,7 @@ class HijackFrame : public Frame // The regular reporting of a top frame will report everything that is live // after the call as specified in GC info, thus we do not need to worry about // return values. - virtual unsigned GetFrameAttribs() { + unsigned GetFrameAttribs_Impl() { LIMITED_METHOD_DAC_CONTRACT; return FRAME_ATTR_RESUMABLE; // Treat the next frame as the top frame. } @@ -2118,9 +1973,6 @@ class HijackFrame : public Frame TADDR m_ReturnAddress; PTR_Thread m_Thread; DPTR(HijackArgs) m_Args; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(HijackFrame) }; #endif // FEATURE_HIJACK @@ -2133,38 +1985,33 @@ class HijackFrame : public Frame class PrestubMethodFrame : public FramedMethodFrame { - VPTR_VTABLE_CLASS(PrestubMethodFrame, FramedMethodFrame) - public: PrestubMethodFrame(TransitionBlock * pTransitionBlock, MethodDesc * pMD); - virtual void GcScanRoots(promote_func *fn, ScanContext* sc) + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { WRAPPER_NO_CONTRACT; - FramedMethodFrame::GcScanRoots(fn, sc); + FramedMethodFrame::GcScanRoots_Impl(fn, sc); PromoteCallerStack(fn, sc); } - BOOL TraceFrame(Thread *thread, BOOL fromPatch, + BOOL TraceFrame_Impl(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs); - int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_INTERCEPTION; } // Our base class is an M2U TransitionType; but we're not. So override and set us back to None. - ETransitionType GetTransitionType() + ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TT_NONE; } - Interception GetInterception(); - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(PrestubMethodFrame) + Interception GetInterception_Impl(); }; //------------------------------------------------------------------------ @@ -2177,8 +2024,6 @@ class PrestubMethodFrame : public FramedMethodFrame class StubDispatchFrame : public FramedMethodFrame { - VPTR_VTABLE_CLASS(StubDispatchFrame, FramedMethodFrame) - // Representative MethodTable * and slot. They are used to // compute the MethodDesc* lazily PTR_MethodTable m_pRepresentativeMT; @@ -2194,23 +2039,23 @@ class StubDispatchFrame : public FramedMethodFrame public: StubDispatchFrame(TransitionBlock * pTransitionBlock); - MethodDesc* GetFunction(); + MethodDesc* GetFunction_Impl(); // Returns this frame GC ref map if it has one PTR_BYTE GetGCRefMap(); #ifdef TARGET_X86 - virtual void UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats = false); - virtual PCODE GetReturnAddress(); + void UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats = false); + PCODE GetReturnAddress_Impl(); #endif // TARGET_X86 PCODE GetUnadjustedReturnAddress() { LIMITED_METHOD_DAC_CONTRACT; - return FramedMethodFrame::GetReturnAddress(); + return FramedMethodFrame::GetReturnAddress_Impl(); } - virtual void GcScanRoots(promote_func *fn, ScanContext* sc); + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc); #ifndef DACCESS_COMPILE void SetRepresentativeSlot(MethodTable * pMT, UINT32 representativeSlot) @@ -2237,18 +2082,18 @@ class StubDispatchFrame : public FramedMethodFrame } #endif - BOOL TraceFrame(Thread *thread, BOOL fromPatch, + BOOL TraceFrame_Impl(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs); - int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_CONTRACT; return TYPE_CALL; } - Interception GetInterception(); + Interception GetInterception_Impl(); - virtual BOOL SuppressParamTypeArg() + BOOL SuppressParamTypeArg_Impl() { // // Shared default interface methods (i.e. virtual interface methods with an implementation) require @@ -2260,43 +2105,35 @@ class StubDispatchFrame : public FramedMethodFrame // // See code:getMethodSigInternal // - assert(GetFunction()->GetMethodTable()->IsInterface()); + assert(Frame_GetFunction(this)->GetMethodTable()->IsInterface()); return TRUE; } private: friend class VirtualCallStubManager; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(StubDispatchFrame) }; -typedef VPTR(class StubDispatchFrame) PTR_StubDispatchFrame; +typedef DPTR(class StubDispatchFrame) PTR_StubDispatchFrame; class CallCountingHelperFrame : public FramedMethodFrame { - VPTR_VTABLE_CLASS(CallCountingHelperFrame, FramedMethodFrame); - public: CallCountingHelperFrame(TransitionBlock *pTransitionBlock, MethodDesc *pMD); - virtual void GcScanRoots(promote_func *fn, ScanContext *sc); // override - virtual BOOL TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs); // override + void GcScanRoots_Impl(promote_func *fn, ScanContext *sc); // override + BOOL TraceFrame_Impl(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs); // override - virtual int GetFrameType() // override + int GetFrameType_Impl() // override { LIMITED_METHOD_DAC_CONTRACT; return TYPE_CALL; } - virtual Interception GetInterception() // override + Interception GetInterception_Impl() // override { LIMITED_METHOD_DAC_CONTRACT; return INTERCEPTION_NONE; } - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(CallCountingHelperFrame) }; //------------------------------------------------------------------------ @@ -2307,8 +2144,6 @@ class CallCountingHelperFrame : public FramedMethodFrame class ExternalMethodFrame : public FramedMethodFrame { - VPTR_VTABLE_CLASS(ExternalMethodFrame, FramedMethodFrame) - // Indirection and containing module. Used to compute pGCRefMap lazily. PTR_Module m_pZapModule; TADDR m_pIndirection; @@ -2319,7 +2154,7 @@ class ExternalMethodFrame : public FramedMethodFrame public: ExternalMethodFrame(TransitionBlock * pTransitionBlock); - virtual void GcScanRoots(promote_func *fn, ScanContext* sc); + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc); // Returns this frame GC ref map if it has one PTR_BYTE GetGCRefMap(); @@ -2334,51 +2169,43 @@ class ExternalMethodFrame : public FramedMethodFrame } #endif - int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_CONTRACT; return TYPE_CALL; } - Interception GetInterception(); + Interception GetInterception_Impl(); #ifdef TARGET_X86 - virtual void UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats = false); + void UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats = false); #endif - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(ExternalMethodFrame) }; -typedef VPTR(class ExternalMethodFrame) PTR_ExternalMethodFrame; +typedef DPTR(class ExternalMethodFrame) PTR_ExternalMethodFrame; #ifdef FEATURE_READYTORUN class DynamicHelperFrame : public FramedMethodFrame { - VPTR_VTABLE_CLASS(DynamicHelperFrame, FramedMethodFrame) - int m_dynamicHelperFrameFlags; public: DynamicHelperFrame(TransitionBlock * pTransitionBlock, int dynamicHelperFrameFlags); - virtual void GcScanRoots(promote_func *fn, ScanContext* sc); + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc); #ifdef TARGET_X86 - virtual void UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats = false); + void UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats = false); #endif - virtual ETransitionType GetTransitionType() + ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TT_InternalCall; } - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(DynamicHelperFrame) }; -typedef VPTR(class DynamicHelperFrame) PTR_DynamicHelperFrame; +typedef DPTR(class DynamicHelperFrame) PTR_DynamicHelperFrame; #endif // FEATURE_READYTORUN #ifdef FEATURE_COMINTEROP @@ -2395,13 +2222,11 @@ class ComPrestubMethodFrame : public ComMethodFrame { friend class CheckAsmOffsets; - VPTR_VTABLE_CLASS(ComPrestubMethodFrame, ComMethodFrame) - public: // Set the vptr and GSCookie VOID Init(); - int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_INTERCEPTION; @@ -2409,26 +2234,22 @@ class ComPrestubMethodFrame : public ComMethodFrame // ComPrestubMethodFrame should return the same interception type as // code:PrestubMethodFrame.GetInterception. - virtual Interception GetInterception() + Interception GetInterception_Impl() { LIMITED_METHOD_DAC_CONTRACT; return INTERCEPTION_PRESTUB; } // Our base class is an M2U TransitionType; but we're not. So override and set us back to None. - virtual ETransitionType GetTransitionType() + ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TT_NONE; } - virtual void ExceptionUnwind() + void ExceptionUnwind_Impl() { } - -private: - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(ComPrestubMethodFrame) }; #endif // FEATURE_COMINTEROP @@ -2513,25 +2334,20 @@ struct ByRefInfo class ProtectByRefsFrame : public Frame { - VPTR_VTABLE_CLASS(ProtectByRefsFrame, Frame) - public: #ifndef DACCESS_COMPILE ProtectByRefsFrame(Thread *pThread, ByRefInfo *brInfo) - : m_brInfo(brInfo) + : Frame(FrameType::ProtectByRefsFrame), m_brInfo(brInfo) { WRAPPER_NO_CONTRACT; Frame::Push(pThread); } #endif - virtual void GcScanRoots(promote_func *fn, ScanContext *sc); + void GcScanRoots_Impl(promote_func *fn, ScanContext *sc); private: PTR_ByRefInfo m_brInfo; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(ProtectByRefsFrame) }; @@ -2559,26 +2375,24 @@ struct ValueClassInfo class ProtectValueClassFrame : public Frame { - VPTR_VTABLE_CLASS(ProtectValueClassFrame, Frame) - public: #ifndef DACCESS_COMPILE ProtectValueClassFrame() - : m_pVCInfo(NULL) + : Frame(FrameType::ProtectValueClassFrame), m_pVCInfo(NULL) { WRAPPER_NO_CONTRACT; Frame::Push(); } ProtectValueClassFrame(Thread *pThread, ValueClassInfo *vcInfo) - : m_pVCInfo(vcInfo) + : Frame(FrameType::ProtectValueClassFrame), m_pVCInfo(vcInfo) { WRAPPER_NO_CONTRACT; Frame::Push(pThread); } #endif - virtual void GcScanRoots(promote_func *fn, ScanContext *sc); + void GcScanRoots_Impl(promote_func *fn, ScanContext *sc); ValueClassInfo ** GetValueClassInfoList() { @@ -2589,9 +2403,6 @@ class ProtectValueClassFrame : public Frame private: ValueClassInfo *m_pVCInfo; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_DTOR(ProtectValueClassFrame) }; @@ -2609,32 +2420,27 @@ BOOL IsProtectedByGCFrame(OBJECTREF *ppObjectRef); class DebuggerClassInitMarkFrame : public Frame { - VPTR_VTABLE_CLASS(DebuggerClassInitMarkFrame, Frame) - public: #ifndef DACCESS_COMPILE - DebuggerClassInitMarkFrame() + DebuggerClassInitMarkFrame() : Frame(FrameType::DebuggerClassInitMarkFrame) { WRAPPER_NO_CONTRACT; Push(); }; #endif - virtual int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_INTERCEPTION; } - virtual Interception GetInterception() + Interception GetInterception_Impl() { LIMITED_METHOD_DAC_CONTRACT; return INTERCEPTION_CLASS_INIT; } - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_DTOR(DebuggerClassInitMarkFrame) }; //------------------------------------------------------------------------ @@ -2645,18 +2451,16 @@ class DebuggerClassInitMarkFrame : public Frame class DebuggerExitFrame : public Frame { - VPTR_VTABLE_CLASS(DebuggerExitFrame, Frame) - public: #ifndef DACCESS_COMPILE - DebuggerExitFrame() + DebuggerExitFrame() : Frame(FrameType::DebuggerExitFrame) { WRAPPER_NO_CONTRACT; Push(); } #endif - virtual int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_EXIT; @@ -2670,7 +2474,7 @@ class DebuggerExitFrame : public Frame // returnSP - the location returnIP is pushed onto the stack // during the call. // - virtual void GetUnmanagedCallSite(TADDR* ip, + void GetUnmanagedCallSite_Impl(TADDR* ip, TADDR* returnIP, TADDR* returnSP) { @@ -2684,9 +2488,6 @@ class DebuggerExitFrame : public Frame if (returnSP) *returnSP = 0; } - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_DTOR(DebuggerExitFrame) }; //--------------------------------------------------------------------------------------- @@ -2702,31 +2503,26 @@ class DebuggerExitFrame : public Frame class DebuggerU2MCatchHandlerFrame : public Frame { - VPTR_VTABLE_CLASS(DebuggerU2MCatchHandlerFrame, Frame) - public: #ifndef DACCESS_COMPILE - DebuggerU2MCatchHandlerFrame() + DebuggerU2MCatchHandlerFrame() : Frame(FrameType::DebuggerU2MCatchHandlerFrame) { WRAPPER_NO_CONTRACT; Frame::Push(); } - DebuggerU2MCatchHandlerFrame(Thread * pThread) + DebuggerU2MCatchHandlerFrame(Thread * pThread) : Frame(FrameType::DebuggerU2MCatchHandlerFrame) { WRAPPER_NO_CONTRACT; Frame::Push(pThread); } #endif - ETransitionType GetTransitionType() + ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TT_U2M; } - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_DTOR(DebuggerU2MCatchHandlerFrame) }; // Frame for the Reverse PInvoke (i.e. UnmanagedCallersOnlyAttribute). @@ -2749,10 +2545,8 @@ typedef DPTR(class InlinedCallFrame) PTR_InlinedCallFrame; class InlinedCallFrame : public Frame { - VPTR_VTABLE_CLASS(InlinedCallFrame, Frame) - public: - virtual MethodDesc *GetFunction() + MethodDesc *GetFunction_Impl() { WRAPPER_NO_CONTRACT; if (FrameHasActiveCall(this) && HasFunction()) @@ -2776,7 +2570,7 @@ class InlinedCallFrame : public Frame // Retrieves the return address into the code that called out // to managed code - virtual TADDR GetReturnAddressPtr() + TADDR GetReturnAddressPtr_Impl() { WRAPPER_NO_CONTRACT; @@ -2787,7 +2581,7 @@ class InlinedCallFrame : public Frame return 0; } - virtual BOOL NeedsUpdateRegDisplay() + BOOL NeedsUpdateRegDisplay_Impl() { WRAPPER_NO_CONTRACT; return FrameHasActiveCall(this); @@ -2804,7 +2598,7 @@ class InlinedCallFrame : public Frame return PTR_MethodDesc(*PTR_TADDR(addr)); } - virtual void UpdateRegDisplay(const PREGDISPLAY, bool updateFloats = false); + void UpdateRegDisplay_Impl(const PREGDISPLAY, bool updateFloats = false); // m_Datum contains MethodDesc ptr or // - on 64 bit host: CALLI target address (if lowest bit is set) @@ -2860,7 +2654,7 @@ class InlinedCallFrame : public Frame SUPPORTS_DAC; return pFrame && pFrame != FRAME_TOP && - InlinedCallFrame::GetMethodFrameVPtr() == pFrame->GetVTablePtr() && + FrameType::InlinedCallFrame == pFrame->GetType() && dac_cast(dac_cast(pFrame)->m_pCallerReturnAddress) != 0; } @@ -2870,13 +2664,13 @@ class InlinedCallFrame : public Frame m_pCallerReturnAddress = 0; } - int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_EXIT; } - virtual BOOL IsTransitionToNativeFrame() + BOOL IsTransitionToNativeFrame_Impl() { LIMITED_METHOD_CONTRACT; return TRUE; @@ -2896,9 +2690,6 @@ class InlinedCallFrame : public Frame // Set the vptr and GSCookie VOID Init(); - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(InlinedCallFrame) }; // TODO [DAVBR]: For the full fix for VsWhidbey 450273, this @@ -2929,8 +2720,6 @@ bool isRetAddr(TADDR retAddr, TADDR* whereCalled); class TailCallFrame : public Frame { - VPTR_VTABLE_CLASS(TailCallFrame, Frame) - TADDR m_CallerAddress; // the address the tailcall was initiated from CalleeSavedRegisters m_regs; // callee saved registers - the stack walk assumes that all non-JIT frames have them TADDR m_ReturnAddress; // the return address of the tailcall @@ -2951,23 +2740,19 @@ class TailCallFrame : public Frame return m_CallerAddress; } - virtual TADDR GetReturnAddressPtr() + TADDR GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; return PTR_HOST_MEMBER_TADDR(TailCallFrame, this, m_ReturnAddress); } - virtual BOOL NeedsUpdateRegDisplay() + BOOL NeedsUpdateRegDisplay_Impl() { return TRUE; } - virtual void UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats = false); - -private: - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(TailCallFrame) + void UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats = false); }; #endif // TARGET_X86 && !UNIX_X86_ABI @@ -2978,12 +2763,11 @@ class TailCallFrame : public Frame class ExceptionFilterFrame : public Frame { - VPTR_VTABLE_CLASS(ExceptionFilterFrame, Frame) size_t* m_pShadowSP; public: #ifndef DACCESS_COMPILE - ExceptionFilterFrame(size_t* pShadowSP) + ExceptionFilterFrame(size_t* pShadowSP) : Frame(FrameType::ExceptionFilterFrame) { WRAPPER_NO_CONTRACT; m_pShadowSP = pShadowSP; @@ -3011,10 +2795,6 @@ class ExceptionFilterFrame : public Frame } } #endif - -private: - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(ExceptionFilterFrame) }; #ifdef _DEBUG @@ -3024,16 +2804,15 @@ class ExceptionFilterFrame : public Frame // OBJECTRef pointer is passed from managed code to an FCall and it's in stack. class AssumeByrefFromJITStack : public Frame { - VPTR_VTABLE_CLASS(AssumeByrefFromJITStack, Frame) public: #ifndef DACCESS_COMPILE - AssumeByrefFromJITStack(OBJECTREF *pObjRef) + AssumeByrefFromJITStack(OBJECTREF *pObjRef) : Frame(FrameType::AssumeByrefFromJITStack) { m_pObjRef = pObjRef; } #endif - BOOL Protects(OBJECTREF *ppORef) + BOOL Protects_Impl(OBJECTREF *ppORef) { LIMITED_METHOD_CONTRACT; return ppORef == m_pObjRef; @@ -3041,9 +2820,6 @@ class AssumeByrefFromJITStack : public Frame private: OBJECTREF *m_pObjRef; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_DTOR(AssumeByrefFromJITStack) }; //AssumeByrefFromJITStack #endif //_DEBUG @@ -3181,7 +2957,7 @@ class FrameWithCookie void Pop() { WRAPPER_NO_CONTRACT; m_frame.Pop(); } void Push(Thread * pThread) { WRAPPER_NO_CONTRACT; m_frame.Push(pThread); } void Pop(Thread * pThread) { WRAPPER_NO_CONTRACT; m_frame.Pop(pThread); } - PCODE GetReturnAddress() { WRAPPER_NO_CONTRACT; return m_frame.GetReturnAddress(); } + PCODE GetReturnAddress() { WRAPPER_NO_CONTRACT; return Frame_GetReturnAddress(&m_frame); } T_CONTEXT * GetContext() { WRAPPER_NO_CONTRACT; return m_frame.GetContext(); } FrameType* operator&() { LIMITED_METHOD_CONTRACT; return &m_frame; } LazyMachState * MachineState() { WRAPPER_NO_CONTRACT; return m_frame.MachineState(); } diff --git a/src/coreclr/vm/gcenv.ee.common.cpp b/src/coreclr/vm/gcenv.ee.common.cpp index 6cbd83dad75bab..17f548001390cb 100644 --- a/src/coreclr/vm/gcenv.ee.common.cpp +++ b/src/coreclr/vm/gcenv.ee.common.cpp @@ -104,9 +104,9 @@ inline bool SafeToReportGenericParamContext(CrawlFrame* pCF) { LIMITED_METHOD_CONTRACT; - if (!pCF->IsFrameless() && pCF->GetFrame()->GetVTablePtr() == StubDispatchFrame::GetMethodFrameVPtr()) + if (!pCF->IsFrameless() && pCF->GetFrame()->GetType() == FrameType::StubDispatchFrame) { - return !((StubDispatchFrame*)pCF->GetFrame())->SuppressParamTypeArg(); + return !Frame_SuppressParamTypeArg((StubDispatchFrame*)pCF->GetFrame()); } if (!pCF->IsFrameless() || !(pCF->IsActiveFrame() || pCF->IsInterrupted())) @@ -370,8 +370,8 @@ StackWalkAction GcStackCrawlCallBack(CrawlFrame* pCF, VOID* pData) STRESS_LOG3(LF_GCROOTS, LL_INFO1000, "Scanning ExplicitFrame %p AssocMethod = %pM frameVTable = %pV\n", - pFrame, pFrame->GetFunction(), *((void**) pFrame)); - pFrame->GcScanRoots( gcctx->f, gcctx->sc); + pFrame, Frame_GetFunction(pFrame), *((void**) pFrame)); + Frame_GcScanRoots(pFrame, gcctx->f, gcctx->sc); } } else diff --git a/src/coreclr/vm/gcenv.ee.cpp b/src/coreclr/vm/gcenv.ee.cpp index 55329274905a5d..83f6d7eb1d1412 100644 --- a/src/coreclr/vm/gcenv.ee.cpp +++ b/src/coreclr/vm/gcenv.ee.cpp @@ -190,7 +190,7 @@ static void ScanStackRoots(Thread * pThread, promote_func* fn, ScanContext* sc) Frame *pFrame = pThread->GetFrame(); while (pFrame != FRAME_TOP) { - pFrame->GcScanRoots(fn, sc); + Frame_GcScanRoots(pFrame, fn, sc); pFrame = pFrame->PtrNextFrame(); } } diff --git a/src/coreclr/vm/i386/cgenx86.cpp b/src/coreclr/vm/i386/cgenx86.cpp index c4fe9b265ed62e..3a330f23578f49 100644 --- a/src/coreclr/vm/i386/cgenx86.cpp +++ b/src/coreclr/vm/i386/cgenx86.cpp @@ -137,7 +137,7 @@ void EHContext::UpdateFrame(PREGDISPLAY regs) } #endif // FEATURE_EH_FUNCLETS -void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void TransitionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -155,7 +155,7 @@ void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) UpdateRegDisplayHelper(pRD, pFunc->CbStackPop()); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay_Impl(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } @@ -207,7 +207,7 @@ void TransitionFrame::UpdateRegDisplayHelper(const PREGDISPLAY pRD, UINT cbStack RETURN; } -void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HelperMethodFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -386,7 +386,7 @@ EXTERN_C MachState* STDCALL HelperMethodFrameConfirmState(HelperMethodFrame* fra } #endif -void ExternalMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void ExternalMethodFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -405,7 +405,7 @@ void ExternalMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFlo } -void StubDispatchFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void StubDispatchFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -424,7 +424,7 @@ void StubDispatchFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloat else if (GetFunction() != NULL) { - FramedMethodFrame::UpdateRegDisplay(pRD); + FramedMethodFrame::UpdateRegDisplay_Impl(pRD); } else { @@ -438,7 +438,7 @@ void StubDispatchFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloat pRD->ControlPC = GetAdjustedCallAddress(pRD->ControlPC); } - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK StubDispatchFrame::UpdateRegDisplay(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK StubDispatchFrame::UpdateRegDisplay_Impl(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } @@ -461,7 +461,7 @@ PCODE StubDispatchFrame::GetReturnAddress() return retAddress; } -void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void FaultingExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -512,12 +512,12 @@ void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool update #endif // FEATURE_EH_FUNCLETS - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK FaultingExceptionFrame::UpdateRegDisplay(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK FaultingExceptionFrame::UpdateRegDisplay_Impl(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } -void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -595,7 +595,7 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats #endif // FEATURE_EH_FUNCLETS - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK InlinedCallFrame::UpdateRegDisplay(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK InlinedCallFrame::UpdateRegDisplay_Impl(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } @@ -610,7 +610,7 @@ TADDR ResumableFrame::GetReturnAddressPtr() return dac_cast(m_Regs) + offsetof(CONTEXT, Eip); } -void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void ResumableFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -683,14 +683,14 @@ void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) #endif // !FEATURE_EH_FUNCLETS - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK ResumableFrame::UpdateRegDisplay(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK ResumableFrame::UpdateRegDisplay_Impl(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } // The HijackFrame has to know the registers that are pushed by OnHijackTripThread // -> HijackFrame::UpdateRegDisplay should restore all the registers pushed by OnHijackTripThread -void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HijackFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACTL { NOTHROW; @@ -741,12 +741,12 @@ void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) #endif // FEATURE_EH_FUNCLETS - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK HijackFrame::UpdateRegDisplay(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK HijackFrame::UpdateRegDisplay_Impl(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); } #endif // FEATURE_HIJACK -void PInvokeCalliFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void PInvokeCalliFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -760,13 +760,13 @@ void PInvokeCalliFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloat VASigCookie *pVASigCookie = GetVASigCookie(); UpdateRegDisplayHelper(pRD, pVASigCookie->sizeOfArgs); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK PInvokeCalliFrame::UpdateRegDisplay(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK PInvokeCalliFrame::UpdateRegDisplay_Impl(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } #ifndef UNIX_X86_ABI -void TailCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void TailCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -806,14 +806,14 @@ void TailCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) #endif - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TailCallFrame::UpdateRegDisplay(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TailCallFrame::UpdateRegDisplay_Impl(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } #endif // !UNIX_X86_ABI #ifdef FEATURE_READYTORUN -void DynamicHelperFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void DynamicHelperFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { WRAPPER_NO_CONTRACT; UpdateRegDisplayHelper(pRD, 0); @@ -889,7 +889,7 @@ Stub *GenerateInitPInvokeFrameHelper() // mov [edi + FrameInfo.offsetOfFrameVptr], InlinedCallFrame::GetFrameVtable() psl->X86EmitOffsetModRM(0xc7, (X86Reg)0x0, kEDI, FrameInfo.offsetOfFrameVptr - negSpace); - psl->Emit32(InlinedCallFrame::GetMethodFrameVPtr()); + psl->Emit32((DWORD)FrameType::InlinedCallFrame); // mov eax, [esi + offsetof(Thread, m_pFrame)] // mov [edi + FrameInfo.offsetOfFrameLink], eax diff --git a/src/coreclr/vm/i386/excepx86.cpp b/src/coreclr/vm/i386/excepx86.cpp index 2fbae9d9e724d2..276b36a0d6f7a8 100644 --- a/src/coreclr/vm/i386/excepx86.cpp +++ b/src/coreclr/vm/i386/excepx86.cpp @@ -2167,7 +2167,7 @@ StackWalkAction COMPlusThrowCallback( // SWA value if (pData->pPrevExceptionRecord) { // FCALLS have an extra SEH record in debug because of the desctructor // associated with ForbidGC checking. This is benign, so just ignore it. - if (pFrame) _ASSERTE(pData->pPrevExceptionRecord < pFrame || pFrame->GetVTablePtr() == HelperMethodFrame::GetMethodFrameVPtr()); + if (pFrame) _ASSERTE(pData->pPrevExceptionRecord < pFrame || pFrame->GetType() == FrameType::HelperMethodFrame); if (pCf->IsFrameless()) _ASSERTE((ULONG_PTR)pData->pPrevExceptionRecord <= GetRegdisplaySP(pCf->GetRegisterSet())); } } diff --git a/src/coreclr/vm/i386/jitinterfacex86.cpp b/src/coreclr/vm/i386/jitinterfacex86.cpp index d8fcd90ba63bb7..334241e7cb1348 100644 --- a/src/coreclr/vm/i386/jitinterfacex86.cpp +++ b/src/coreclr/vm/i386/jitinterfacex86.cpp @@ -911,7 +911,7 @@ void InitJITHelpers1() #ifndef UNIX_X86_ABI // Initialize g_TailCallFrameVptr for JIT_TailCall helper - g_TailCallFrameVptr = (void*)TailCallFrame::GetMethodFrameVPtr(); + g_TailCallFrameVptr = (void*)FrameType::TailCallFrame; #endif // !UNIX_X86_ABI } #pragma warning (default : 4731) diff --git a/src/coreclr/vm/loongarch64/stubs.cpp b/src/coreclr/vm/loongarch64/stubs.cpp index c8e612ea2a9159..48892f0709a52f 100644 --- a/src/coreclr/vm/loongarch64/stubs.cpp +++ b/src/coreclr/vm/loongarch64/stubs.cpp @@ -436,7 +436,7 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState, unwoundstate->_isValid = TRUE; } -void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HelperMethodFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACTL { @@ -614,7 +614,7 @@ void UpdateRegDisplayFromCalleeSavedRegisters(REGDISPLAY * pRD, CalleeSavedRegis pContextPointers->Ra = (PDWORD64)&pCalleeSaved->ra; } -void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void TransitionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { #ifndef DACCESS_COMPILE if (updateFloats) @@ -642,10 +642,10 @@ void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) // Finally, syncup the regdisplay with the context SyncRegDisplayToCurrentContext(pRD); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); } -void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void FaultingExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { LIMITED_METHOD_DAC_CONTRACT; @@ -675,10 +675,10 @@ void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool update pRD->IsCallerContextValid = FALSE; pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK FaultingExceptionFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK FaultingExceptionFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); } -void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -735,7 +735,7 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats // Update the frame pointer in the current context. pRD->pCurrentContextPointers->Fp = &m_pCalleeSavedFP; - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK InlinedCallFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK InlinedCallFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } @@ -747,7 +747,7 @@ TADDR ResumableFrame::GetReturnAddressPtr(void) return dac_cast(m_Regs) + offsetof(T_CONTEXT, Pc); } -void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void ResumableFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -799,12 +799,12 @@ void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) pRD->IsCallerContextValid = FALSE; pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK ResumableFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK ResumableFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } -void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HijackFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { LIMITED_METHOD_CONTRACT; @@ -851,7 +851,7 @@ void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) pRD->pCurrentContextPointers->Ra = NULL; SyncRegDisplayToCurrentContext(pRD); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK HijackFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK HijackFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); } #endif // FEATURE_HIJACK diff --git a/src/coreclr/vm/prestub.cpp b/src/coreclr/vm/prestub.cpp index b78092f7156336..94b9896ce7d7bf 100644 --- a/src/coreclr/vm/prestub.cpp +++ b/src/coreclr/vm/prestub.cpp @@ -3105,7 +3105,7 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl if (pIndirection == (PCODE)NULL) { // Assume that the callsite is call [xxxxxxxx] - PCODE retAddr = pEMFrame->GetReturnAddress(); + PCODE retAddr = Frame_GetReturnAddress(pEMFrame); #ifdef TARGET_X86 pIndirection = *(((TADDR *)retAddr) - 1); #else @@ -3302,7 +3302,7 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl else token = DispatchToken::CreateDispatchToken(slot); - StubCallSite callSite(pIndirection, pEMFrame->GetReturnAddress()); + StubCallSite callSite(pIndirection, Frame_GetReturnAddress(pEMFrame)); pCode = pMgr->ResolveWorker(&callSite, protectedObj, token, STUB_CODE_BLOCK_VSD_LOOKUP_STUB); } else @@ -4062,7 +4062,7 @@ extern "C" SIZE_T STDCALL DynamicHelperWorker(TransitionBlock * pTransitionBlock if (pCell == NULL) { // Assume that the callsite is call [xxxxxxxx] - PCODE retAddr = pFrame->GetReturnAddress(); + PCODE retAddr = Frame_GetReturnAddress(pFrame); #ifdef TARGET_X86 pCell = *(((TADDR **)retAddr) - 1); #else diff --git a/src/coreclr/vm/riscv64/stubs.cpp b/src/coreclr/vm/riscv64/stubs.cpp index 3d48d68a4163f5..ca079109d1fc6e 100644 --- a/src/coreclr/vm/riscv64/stubs.cpp +++ b/src/coreclr/vm/riscv64/stubs.cpp @@ -330,7 +330,7 @@ void LazyMachState::unwindLazyState(LazyMachState* baseState, unwoundstate->_isValid = TRUE; } -void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HelperMethodFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACTL { @@ -528,7 +528,7 @@ void UpdateRegDisplayFromCalleeSavedRegisters(REGDISPLAY * pRD, CalleeSavedRegis pContextPointers->Ra = (PDWORD64)&pCalleeSaved->ra; } -void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void TransitionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { #ifndef DACCESS_COMPILE if (updateFloats) @@ -556,10 +556,10 @@ void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) // Finally, syncup the regdisplay with the context SyncRegDisplayToCurrentContext(pRD); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); } -void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void FaultingExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { LIMITED_METHOD_DAC_CONTRACT; @@ -592,10 +592,10 @@ void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool update pRD->IsCallerContextValid = FALSE; pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK FaultingExceptionFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK FaultingExceptionFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); } -void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -655,7 +655,7 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats // Update the frame pointer in the current context. pRD->pCurrentContextPointers->Fp = &m_pCalleeSavedFP; - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK InlinedCallFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK InlinedCallFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } @@ -667,7 +667,7 @@ TADDR ResumableFrame::GetReturnAddressPtr(void) return dac_cast(m_Regs) + offsetof(T_CONTEXT, Pc); } -void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void ResumableFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -719,12 +719,12 @@ void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) pRD->IsCallerContextValid = FALSE; pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK ResumableFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK ResumableFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } -void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void HijackFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { LIMITED_METHOD_CONTRACT; @@ -778,7 +778,7 @@ void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) pRD->pCurrentContextPointers->Ra = NULL; SyncRegDisplayToCurrentContext(pRD); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK HijackFrame::UpdateRegDisplay(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK HijackFrame::UpdateRegDisplay_Impl(pc:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); } #endif // FEATURE_HIJACK diff --git a/src/coreclr/vm/stackwalk.cpp b/src/coreclr/vm/stackwalk.cpp index ef81c5bd0e93af..bdd3e1b2738776 100644 --- a/src/coreclr/vm/stackwalk.cpp +++ b/src/coreclr/vm/stackwalk.cpp @@ -37,7 +37,7 @@ Assembly* CrawlFrame::GetAssembly() Frame *pF = GetFrame(); if (pF != NULL) - pAssembly = pF->GetAssembly(); + pAssembly = Frame_GetAssembly(pF); if (pAssembly == NULL && pFunc != NULL) pAssembly = pFunc->GetModule()->GetAssembly(); @@ -1245,7 +1245,7 @@ BOOL StackFrameIterator::ResetRegDisp(PREGDISPLAY pRegDisp, { #if defined(TARGET_X86) // check the IP - if (m_crawl.pFrame->GetReturnAddress() != curPc) + if (m_crawl.Frame_GetReturnAddress(pFrame)() != curPc) { break; } @@ -1265,10 +1265,10 @@ BOOL StackFrameIterator::ResetRegDisp(PREGDISPLAY pRegDisp, // if the REGDISPLAY represents the managed stack frame at a M2U transition boundary, // update the flags on the CrawlFrame and the REGDISPLAY - PCODE frameRetAddr = m_crawl.pFrame->GetReturnAddress(); + PCODE frameRetAddr = Frame_GetReturnAddress(m_crawl.pFrame); if (frameRetAddr == curPc) { - unsigned uFrameAttribs = m_crawl.pFrame->GetFrameAttribs(); + unsigned uFrameAttribs = Frame_GetFrameAttribs(m_crawl.pFrame); m_crawl.isFirst = ((uFrameAttribs & Frame::FRAME_ATTR_RESUMABLE) != 0); m_crawl.isInterrupted = ((uFrameAttribs & Frame::FRAME_ATTR_EXCEPTION) != 0); @@ -1279,7 +1279,7 @@ BOOL StackFrameIterator::ResetRegDisp(PREGDISPLAY pRegDisp, m_crawl.isIPadjusted = false; } - m_crawl.pFrame->UpdateRegDisplay(m_crawl.pRD, m_flags & UNWIND_FLOATS); + Frame_UpdateRegDisplay(m_crawl.pFrame, m_crawl.pRD, m_flags & UNWIND_FLOATS); _ASSERTE(curPc == GetControlPC(m_crawl.pRD)); } @@ -1414,11 +1414,11 @@ BOOL StackFrameIterator::IsValid(void) _ASSERTE(GCStress::IsEnabled()); _ASSERTE(m_pRealStartFrame != NULL); _ASSERTE(m_pRealStartFrame != FRAME_TOP); - _ASSERTE(m_pRealStartFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()); + _ASSERTE(m_pRealStartFrame->GetType() == FrameType::InlinedCallFrame); _ASSERTE(m_pThread->GetFrame() != NULL); _ASSERTE(m_pThread->GetFrame() != FRAME_TOP); - bIsRealStartFrameUnchanged = (m_pThread->GetFrame()->GetVTablePtr() == ResumableFrame::GetMethodFrameVPtr()) - || (m_pThread->GetFrame()->GetVTablePtr() == RedirectedThreadFrame::GetMethodFrameVPtr()); + bIsRealStartFrameUnchanged = (m_pThread->GetFrame()->GetType() == FrameType::ResumableFrame) + || (m_pThread->GetFrame()->GetType() == FrameType::RedirectedThreadFrame); } #endif // FEATURE_HIJACK @@ -2363,9 +2363,9 @@ StackWalkAction StackFrameIterator::NextRaw(void) { #if !defined(TARGET_X86) && defined(_DEBUG) // make sure we're not skipping a different transition - if (m_crawl.pFrame->NeedsUpdateRegDisplay()) + if (Frame_NeedsUpdateRegDisplay(m_crawl.pFrame)) { - if (m_crawl.pFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()) + if (m_crawl.pFrame->GetType() == FrameType::InlinedCallFrame) { // ControlPC may be different as the InlinedCallFrame stays active throughout // the STOP_FOR_GC callout but we can use the stack/frame pointer for the assert. @@ -2375,7 +2375,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) } else { - CONSISTENCY_CHECK(GetControlPC(m_crawl.pRD) == m_crawl.pFrame->GetReturnAddress()); + CONSISTENCY_CHECK(GetControlPC(m_crawl.pRD) == Frame_GetReturnAddress(m_crawl.pFrame)); } } #endif // !defined(TARGET_X86) && defined(_DEBUG) @@ -2502,7 +2502,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) // pushed on the stack after the frame is running _ASSERTE((m_crawl.pFrame == FRAME_TOP) || ((TADDR)GetRegdisplaySP(m_crawl.pRD) < dac_cast(m_crawl.pFrame)) || - (m_crawl.pFrame->GetVTablePtr() == FaultingExceptionFrame::GetMethodFrameVPtr())); + (m_crawl.pFrame->GetType() == FrameType::FaultingExceptionFrame)); #endif // !defined(ELIMINATE_FEF) // Get rid of the frame (actually, it isn't really popped) @@ -2590,7 +2590,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) pInlinedFrame = m_crawl.pFrame; } - unsigned uFrameAttribs = m_crawl.pFrame->GetFrameAttribs(); + unsigned uFrameAttribs = Frame_GetFrameAttribs(m_crawl.pFrame); // Special resumable frames make believe they are on top of the stack. m_crawl.isFirst = (uFrameAttribs & Frame::FRAME_ATTR_RESUMABLE) != 0; @@ -2605,7 +2605,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) m_crawl.isIPadjusted = false; } - PCODE adr = m_crawl.pFrame->GetReturnAddress(); + PCODE adr = Frame_GetReturnAddress(m_crawl.pFrame); _ASSERTE(adr != (PCODE)POISONC); _ASSERTE(!pInlinedFrame || adr); @@ -2618,7 +2618,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) if (m_crawl.isFrameless) { - m_crawl.pFrame->UpdateRegDisplay(m_crawl.pRD, m_flags & UNWIND_FLOATS); + Frame_UpdateRegDisplay(m_crawl.pFrame, m_crawl.pRD, m_flags & UNWIND_FLOATS); #if defined(RECORD_RESUMABLE_FRAME_SP) CONSISTENCY_CHECK(NULL == m_pvResumableFrameTargetSP); @@ -2938,7 +2938,7 @@ void StackFrameIterator::ProcessCurrentFrame(void) _ASSERTE(m_crawl.pFrame != FRAME_TOP); - m_crawl.pFunc = m_crawl.pFrame->GetFunction(); + m_crawl.pFunc = Frame_GetFunction(m_crawl.pFrame); m_frameState = SFITER_FRAME_FUNCTION; } @@ -3006,7 +3006,7 @@ BOOL StackFrameIterator::CheckForSkippedFrames(void) // Note that code:InlinedCallFrame.GetFunction may return NULL in this case because // the call is made using the CALLI instruction. m_crawl.pFrame != FRAME_TOP && - m_crawl.pFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr() && + m_crawl.pFrame->GetType() == FrameType::InlinedCallFrame && m_crawl.pFunc != NULL && m_crawl.pFunc->IsILStub() && m_crawl.pFunc->AsDynamicMethodDesc()->HasMDContextArg(); @@ -3044,7 +3044,7 @@ BOOL StackFrameIterator::CheckForSkippedFrames(void) } else { - m_crawl.pFunc = m_crawl.pFrame->GetFunction(); + m_crawl.pFunc = Frame_GetFunction(m_crawl.pFrame); } INDEBUG(m_crawl.pThread->DebugLogStackWalkInfo(&m_crawl, "CONSIDER", m_uFramesProcessed)); @@ -3288,7 +3288,7 @@ void SetUpRegdisplayForStackWalk(Thread * pThread, T_CONTEXT * pContext, REGDISP if (ISREDIRECTEDTHREAD(pThread)) { - pThread->GetFrame()->UpdateRegDisplay(pRegdisplay); + Frame_UpdateRegDisplay(pThread->GetFrame(), pRegdisplay); } } } diff --git a/src/coreclr/vm/syncblk.cpp b/src/coreclr/vm/syncblk.cpp index 3fb9089bf31c54..21c64ae431671e 100644 --- a/src/coreclr/vm/syncblk.cpp +++ b/src/coreclr/vm/syncblk.cpp @@ -2385,7 +2385,7 @@ void AwareLock::Enter() // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); int caller = (pFrame && pFrame != FRAME_TOP - ? (int)pFrame->GetReturnAddress() + ? (int)Frame_GetReturnAddress(pFrame)() : -1); pCurThread->m_pTrackSync->EnterSync(caller, this); #endif @@ -2408,7 +2408,7 @@ void AwareLock::Enter() #if defined(_DEBUG) && defined(TRACK_SYNC) // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); - int caller = (pFrame && pFrame != FRAME_TOP ? (int)pFrame->GetReturnAddress() : -1); + int caller = (pFrame && pFrame != FRAME_TOP ? (int)Frame_GetReturnAddress(pFrame)() : -1); pCurThread->m_pTrackSync->EnterSync(caller, this); #endif } @@ -2448,7 +2448,7 @@ BOOL AwareLock::TryEnter(INT32 timeOut) #if defined(_DEBUG) && defined(TRACK_SYNC) // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); - int caller = (pFrame && pFrame != FRAME_TOP ? (int)pFrame->GetReturnAddress() : -1); + int caller = (pFrame && pFrame != FRAME_TOP ? (int)Frame_GetReturnAddress(pFrame)() : -1); pCurThread->m_pTrackSync->EnterSync(caller, this); #endif return true; @@ -2474,7 +2474,7 @@ BOOL AwareLock::TryEnter(INT32 timeOut) #if defined(_DEBUG) && defined(TRACK_SYNC) // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); - int caller = (pFrame && pFrame != FRAME_TOP ? (int)pFrame->GetReturnAddress() : -1); + int caller = (pFrame && pFrame != FRAME_TOP ? (int)Frame_GetReturnAddress(pFrame)() : -1); pCurThread->m_pTrackSync->EnterSync(caller, this); #endif return true; @@ -2728,7 +2728,7 @@ BOOL AwareLock::EnterEpilogHelper(Thread* pCurThread, INT32 timeOut) #if defined(_DEBUG) && defined(TRACK_SYNC) // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); - int caller = (pFrame && pFrame != FRAME_TOP ? (int)pFrame->GetReturnAddress() : -1); + int caller = (pFrame && pFrame != FRAME_TOP ? (int)Frame_GetReturnAddress(pFrame)() : -1); pCurThread->m_pTrackSync->EnterSync(caller, this); #endif return true; diff --git a/src/coreclr/vm/syncblk.inl b/src/coreclr/vm/syncblk.inl index 4cad064c8149de..3a98417533b42f 100644 --- a/src/coreclr/vm/syncblk.inl +++ b/src/coreclr/vm/syncblk.inl @@ -696,7 +696,7 @@ FORCEINLINE AwareLock::LeaveHelperAction AwareLock::LeaveHelper(Thread* pCurThre #if defined(_DEBUG) && defined(TRACK_SYNC) // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); - int caller = (pFrame && pFrame != FRAME_TOP ? (int) pFrame->GetReturnAddress() : -1); + int caller = (pFrame && pFrame != FRAME_TOP ? (int) Frame_GetReturnAddress(pFrame)() : -1); pCurThread->m_pTrackSync->LeaveSync(caller, this); #endif diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 8951a68905a237..39ecc9fa71ca03 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -235,7 +235,7 @@ void Thread::SetFrame(Frame *pFrame) _ASSERTE(IsExecutingOnAltStack() || espVal < pFrame); _ASSERTE(IsExecutingOnAltStack() || pFrame < m_CacheStackBase); - _ASSERTE(pFrame->GetFrameType() < Frame::TYPE_COUNT); + _ASSERTE(Frame_GetFrameType(pFrame) < Frame::TYPE_COUNT); pFrame = pFrame->m_Next; } @@ -305,19 +305,19 @@ bool Thread::DetectHandleILStubsForDebugger() while (pFrame != FRAME_TOP) { // Check for HMF's. See the comment at the beginning of this function. - if (pFrame->GetVTablePtr() == HelperMethodFrame::GetMethodFrameVPtr()) + if (pFrame->GetType() == FrameType::HelperMethodFrame) { break; } // If there is an entry frame (i.e. U2M managed), we should break. - else if (pFrame->GetFrameType() == Frame::TYPE_ENTRY) + else if (Frame_GetFrameType(pFrame) == Frame::TYPE_ENTRY) { break; } // Check for M2U transition frames. See the comment at the beginning of this function. - else if (pFrame->GetFrameType() == Frame::TYPE_EXIT) + else if (Frame_GetFrameType(pFrame) == Frame::TYPE_EXIT) { - if (pFrame->GetReturnAddress() == (PCODE)NULL) + if (Frame_GetReturnAddress(pFrame) == (PCODE)NULL) { // If the return address is NULL, then the frame has not been initialized yet. // We may see InlinedCallFrame in ordinary methods as well. Have to do @@ -6025,7 +6025,7 @@ BOOL Thread::UniqueStack(void* stackStart) pFrame->GetFunction(); // This ensures that helper frames are inited - if (pFrame->GetReturnAddress() != 0) + if (Frame_GetReturnAddress(pFrame)() != 0) { stopPoint = pFrame; break; @@ -7457,7 +7457,7 @@ Frame * Thread::NotifyFrameChainOfExceptionUnwind(Frame* pStartFrame, LPVOID pvL { CONSISTENCY_CHECK(pFrame != PTR_NULL); CONSISTENCY_CHECK((pFrame) > static_cast((LPVOID)GetCurrentSP())); - pFrame->ExceptionUnwind(); + Frame_ExceptionUnwind(pFrame); pFrame = pFrame->Next(); } @@ -7955,7 +7955,7 @@ Thread::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) while (frame.IsValid() && frame.GetAddr() != dac_cast(FRAME_TOP)) { - frame->EnumMemoryRegions(flags); + Frame_EnumMemoryRegions(frame, flags); frame = frame->m_Next; } } diff --git a/src/coreclr/vm/threadsuspend.cpp b/src/coreclr/vm/threadsuspend.cpp index 2da1584cdb5da7..56b7200c00aa02 100644 --- a/src/coreclr/vm/threadsuspend.cpp +++ b/src/coreclr/vm/threadsuspend.cpp @@ -600,7 +600,7 @@ static StackWalkAction TAStackCrawlCallBackWorker(CrawlFrame* pCf, StackCrawlCon MethodDesc *pMD = pCf->GetFunction(); Frame *pFrame = pCf->GetFrame(); if (pMD == NULL && pFrame != NULL) - pMD = pFrame->GetFunction(); + pMD = Frame_GetFunction(pFrame); // Non-method frames don't interest us. if (pMD == NULL) @@ -1539,7 +1539,7 @@ Thread::UserAbort(EEPolicy::ThreadAbortTypes abortType, DWORD timeout) if (!m_fPreemptiveGCDisabled) { - if ((m_pFrame != FRAME_TOP) && m_pFrame->IsTransitionToNativeFrame() + if ((m_pFrame != FRAME_TOP) && Frame_IsTransitionToNativeFrame(m_pFrame) #if defined(TARGET_X86) && !defined(FEATURE_EH_FUNCLETS) && ((size_t) GetFirstCOMPlusSEHRecord(this) > ((size_t) m_pFrame) - 20) #endif // TARGET_X86 @@ -2512,7 +2512,7 @@ bool ThreadStore::IsTrappingThreadsForSuspension() #ifdef FEATURE_HIJACK -void RedirectedThreadFrame::ExceptionUnwind() +void RedirectedThreadFrame::ExceptionUnwind_Impl() { CONTRACTL { @@ -3766,7 +3766,7 @@ ThrowControlForThread( } #if defined(FEATURE_EH_FUNCLETS) - *(TADDR*)pfef = FaultingExceptionFrame::GetMethodFrameVPtr(); + *(TADDR*)pfef = (TADDR)FrameType::FaultingExceptionFrame; *pfef->GetGSCookiePtr() = GetProcessGSCookie(); #else // FEATURE_EH_FUNCLETS FrameWithCookie fef; @@ -4843,7 +4843,8 @@ StackWalkAction SWCB_GetExecutionState(CrawlFrame *pCF, VOID *pData) } HijackFrame::HijackFrame(LPVOID returnAddress, Thread *thread, HijackArgs *args) - : m_ReturnAddress((TADDR)returnAddress), + : Frame(FrameType::HijackFrame), + m_ReturnAddress((TADDR)returnAddress), m_Thread(thread), m_Args(args) { diff --git a/src/coreclr/vm/virtualcallstub.cpp b/src/coreclr/vm/virtualcallstub.cpp index 4ead0cadb8b5ba..e2a50496e64dcd 100644 --- a/src/coreclr/vm/virtualcallstub.cpp +++ b/src/coreclr/vm/virtualcallstub.cpp @@ -1382,7 +1382,7 @@ PCODE VSD_ResolveWorker(TransitionBlock * pTransitionBlock, if (pSDFrame->GetGCRefMap() != NULL) { GCX_PREEMP(); - _ASSERTE(CheckGCRefMapEqual(pSDFrame->GetGCRefMap(), pSDFrame->GetFunction(), true)); + _ASSERTE(CheckGCRefMapEqual(pSDFrame->GetGCRefMap(), Frame_GetFunction(pSDFrame), true)); } #endif // _DEBUG From 53cf3f4840f6f1d1030f7c39c2894d478c199f09 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Tue, 4 Feb 2025 15:28:49 -0800 Subject: [PATCH 02/17] Convert back to using member functions on Frame to reduce the delta size, and make it reviewable --- src/coreclr/debug/daccess/daccess.cpp | 6 +- src/coreclr/debug/daccess/dacdbiimpl.cpp | 2 +- .../debug/daccess/dacdbiimplstackwalk.cpp | 30 ++-- src/coreclr/debug/daccess/request.cpp | 2 +- src/coreclr/debug/daccess/stack.cpp | 2 +- src/coreclr/debug/ee/controller.cpp | 36 ++--- src/coreclr/debug/ee/debugger.cpp | 8 +- src/coreclr/debug/ee/frameinfo.cpp | 48 +++---- src/coreclr/vm/amd64/cgenamd64.cpp | 4 +- src/coreclr/vm/callsiteinspect.cpp | 10 +- src/coreclr/vm/clrtocomcall.cpp | 8 +- src/coreclr/vm/dllimport.cpp | 2 +- src/coreclr/vm/eedbginterfaceimpl.cpp | 2 +- src/coreclr/vm/eventtrace.cpp | 2 +- src/coreclr/vm/excep.cpp | 4 +- src/coreclr/vm/exceptionhandling.cpp | 28 ++-- src/coreclr/vm/frames.cpp | 130 +++++++++--------- src/coreclr/vm/frames.h | 126 ++++++++--------- src/coreclr/vm/gcenv.ee.common.cpp | 6 +- src/coreclr/vm/gcenv.ee.cpp | 2 +- src/coreclr/vm/prestub.cpp | 6 +- src/coreclr/vm/stackwalk.cpp | 26 ++-- src/coreclr/vm/syncblk.cpp | 10 +- src/coreclr/vm/syncblk.inl | 2 +- src/coreclr/vm/threads.cpp | 14 +- src/coreclr/vm/threadsuspend.cpp | 4 +- src/coreclr/vm/virtualcallstub.cpp | 2 +- 27 files changed, 261 insertions(+), 261 deletions(-) diff --git a/src/coreclr/debug/daccess/daccess.cpp b/src/coreclr/debug/daccess/daccess.cpp index 694d20406834e9..5deb0937c3acbd 100644 --- a/src/coreclr/debug/daccess/daccess.cpp +++ b/src/coreclr/debug/daccess/daccess.cpp @@ -5111,8 +5111,8 @@ ClrDataAccess::FollowStubStep( trace.InitForFramePush(CORDB_ADDRESS_TO_TADDR(inBuffer->u.addr)); DacGetThreadContext(thread, &localContext); thread->FillRegDisplay(®Disp, &localContext); - if (!Frame_TraceFrame(thread->GetFrame(), - thread, + if (!thread->GetFrame()-> + TraceFrame(thread, TRUE, &trace, ®Disp)) @@ -8043,7 +8043,7 @@ StackWalkAction DacStackReferenceWalker::Callback(CrawlFrame *pCF, VOID *pData) } else { - Frame_GcScanRoots(pFrame, gcctx->f, gcctx->sc); + pFrame->GcScanRoots(gcctx->f, gcctx->sc); } } } diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index 20a867462e7e92..eef3dc127b9206 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -5644,7 +5644,7 @@ void DacDbiInterfaceImpl::GetContext(VMPTR_Thread vmThread, DT_CONTEXT * pContex Frame *frame = pThread->GetFrame(); while (frame != NULL && frame != FRAME_TOP) { - Frame_UpdateRegDisplay(frame, &tmpRd); + frame->UpdateRegDisplay(&tmpRd); if (GetRegdisplaySP(&tmpRd) != 0 && GetControlPC(&tmpRd) != 0) { UpdateContextFromRegDisp(&tmpRd, &tmpContext); diff --git a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp index 771835d41cfaa4..908eec6f8fca28 100644 --- a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp +++ b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp @@ -536,7 +536,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread frameData.vmCurrentAppDomainToken.SetHostPtr(pAppDomain); - MethodDesc * pMD = Frame_GetFunction(pFrame); + MethodDesc * pMD = pFrame->GetFunction(); #if defined(FEATURE_COMINTEROP) if (frameData.stubFrame.frameType == STUBFRAME_U2M) { @@ -1111,26 +1111,26 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra { CorDebugInternalFrameType resultType = STUBFRAME_NONE; - ETransitionType tt = Frame_GetTransitionType(pFrame); - Interception it = Frame_GetInterception(pFrame); - int ft = Frame_GetFrameType(pFrame); + Frame::ETransitionType tt = pFrame->GetTransitionType(); + Frame::Interception it = pFrame->GetInterception(); + int ft = pFrame->GetFrameType(); switch (tt) { - case TT_NONE: - if (it == INTERCEPTION_CLASS_INIT) + case Frame::TT_NONE: + if (it == Frame::INTERCEPTION_CLASS_INIT) { resultType = STUBFRAME_CLASS_INIT; } - else if (it == INTERCEPTION_EXCEPTION) + else if (it == Frame::INTERCEPTION_EXCEPTION) { resultType = STUBFRAME_EXCEPTION; } - else if (it == INTERCEPTION_SECURITY) + else if (it == Frame::INTERCEPTION_SECURITY) { resultType = STUBFRAME_SECURITY; } - else if (it == INTERCEPTION_PRESTUB) + else if (it == Frame::INTERCEPTION_PRESTUB) { resultType = STUBFRAME_JIT_COMPILATION; } @@ -1151,11 +1151,11 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra } break; - case TT_M2U: + case Frame::TT_M2U: // Refer to the comment in DebuggerWalkStackProc() for StubDispatchFrame. if (pFrame->GetType() != ::FrameType::StubDispatchFrame) { - if (it == INTERCEPTION_SECURITY) + if (it == Frame::INTERCEPTION_SECURITY) { resultType = STUBFRAME_SECURITY; } @@ -1166,16 +1166,16 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra } break; - case TT_U2M: + case Frame::TT_U2M: resultType = STUBFRAME_U2M; break; - case TT_AppDomain: + case Frame::TT_AppDomain: resultType = STUBFRAME_APPDOMAIN_TRANSITION; break; - case TT_InternalCall: - if (it == INTERCEPTION_EXCEPTION) + case Frame::TT_InternalCall: + if (it == Frame::INTERCEPTION_EXCEPTION) { resultType = STUBFRAME_EXCEPTION; } diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp index 81d41acc1ac8e9..7a07a8c0f6c3c1 100644 --- a/src/coreclr/debug/daccess/request.cpp +++ b/src/coreclr/debug/daccess/request.cpp @@ -1393,7 +1393,7 @@ ClrDataAccess::GetMethodDescPtrFromFrame(CLRDATA_ADDRESS frameAddr, CLRDATA_ADDR SOSDacEnter(); Frame *pFrame = PTR_Frame(TO_TADDR(frameAddr)); - CLRDATA_ADDRESS methodDescAddr = HOST_CDADDR(Frame_GetFunction(pFrame)); + CLRDATA_ADDRESS methodDescAddr = HOST_CDADDR(pFrame->GetFunction()); if ((methodDescAddr == (CLRDATA_ADDRESS)NULL) || !DacValidateMD(PTR_MethodDesc(TO_TADDR(methodDescAddr)))) { hr = E_INVALIDARG; diff --git a/src/coreclr/debug/daccess/stack.cpp b/src/coreclr/debug/daccess/stack.cpp index 516bc0ba29ed4b..a0dc074ae1f67a 100644 --- a/src/coreclr/debug/daccess/stack.cpp +++ b/src/coreclr/debug/daccess/stack.cpp @@ -555,7 +555,7 @@ ClrDataStackWalk::RawGetFrameType( if (detailedType) { - if (m_frameIter.m_crawl.GetFrame() && Frame_GetFrameAttribs(m_frameIter.m_crawl.GetFrame()) & Frame::FRAME_ATTR_EXCEPTION) + if (m_frameIter.m_crawl.GetFrame() && m_frameIter.m_crawl.GetFrame()->GetFrameAttribs() & Frame::FRAME_ATTR_EXCEPTION) *detailedType = CLRDATA_DETFRAME_EXCEPTION_FILTER; else *detailedType = CLRDATA_DETFRAME_UNRECOGNIZED; diff --git a/src/coreclr/debug/ee/controller.cpp b/src/coreclr/debug/ee/controller.cpp index 7bd542a4cc9ee4..ca63a24170d127 100644 --- a/src/coreclr/debug/ee/controller.cpp +++ b/src/coreclr/debug/ee/controller.cpp @@ -3774,7 +3774,7 @@ bool DebuggerController::DispatchTraceCall(Thread *thread, { // Make sure that the frame pointer of the active frame is actually // the address of an exit frame. - _ASSERTE( Frame_GetFrameType(static_cast(info.m_activeFrame.fp.GetSPValue())) + _ASSERTE( (static_cast(info.m_activeFrame.fp.GetSPValue()))->GetFrameType() == Frame::TYPE_EXIT ); _ASSERTE(!info.GetReturnFrame().HasChainMarker()); fpToCheck = info.GetReturnFrame().fp; @@ -5360,12 +5360,12 @@ bool DebuggerStepper::DetectHandleInterceptors(ControllerStackInfo *info) { if (info->m_activeFrame.frame != NULL && info->m_activeFrame.frame != FRAME_TOP && - Frame_GetInterception(info->m_activeFrame.frame) != INTERCEPTION_NONE) + info->m_activeFrame.frame->GetInterception() != Frame::INTERCEPTION_NONE) { - if (!((CorDebugIntercept)Frame_GetInterception(info->m_activeFrame.frame) & Interception(m_rgfInterceptStop))) + if (!((CorDebugIntercept)info->m_activeFrame.frame->GetInterception() & Frame::Interception(m_rgfInterceptStop))) { LOG((LF_CORDB,LL_INFO10000,"DS::DHI: Stepping out b/c of excluded frame type:0x%x\n", - Frame_GetInterception(info->m_activeFrame.frame))); + info->m_activeFrame.frame->GetInterception())); fAttemptStepOut = true; } @@ -5381,7 +5381,7 @@ bool DebuggerStepper::DetectHandleInterceptors(ControllerStackInfo *info) (info->HasReturnFrame() && info->GetReturnFrame().frame != NULL && info->GetReturnFrame().frame != FRAME_TOP && - Frame_GetInterception(info->GetReturnFrame().frame) != INTERCEPTION_NONE)) + info->GetReturnFrame().frame->GetInterception() != Frame::INTERCEPTION_NONE)) { if (m_reason == STEP_EXCEPTION_FILTER) { @@ -5389,16 +5389,16 @@ bool DebuggerStepper::DetectHandleInterceptors(ControllerStackInfo *info) // insert an ExceptionFrame, and hence info->GetReturnFrame().frame->GetInterception() // will not be accurate. Hence we use m_reason instead - if (!(INTERCEPTION_EXCEPTION & Interception(m_rgfInterceptStop))) + if (!(Frame::INTERCEPTION_EXCEPTION & Frame::Interception(m_rgfInterceptStop))) { LOG((LF_CORDB,LL_INFO10000,"DS::DHI: Stepping out b/c of excluded INTERCEPTION_EXCEPTION\n")); fAttemptStepOut = true; } } - else if (!(Frame_GetInterception(info->GetReturnFrame().frame) & Interception(m_rgfInterceptStop))) + else if (!(info->GetReturnFrame().frame->GetInterception() & Frame::Interception(m_rgfInterceptStop))) { LOG((LF_CORDB,LL_INFO10000,"DS::DHI: Stepping out b/c of excluded return frame type:0x%x\n", - Frame_GetInterception(info->GetReturnFrame().frame))); + info->GetReturnFrame().frame->GetInterception())); fAttemptStepOut = true; } @@ -6600,7 +6600,7 @@ void DebuggerStepper::TrapStepOut(ControllerStackInfo *info, bool fForceTraditio // stepComplete message to the right side. break; } - else if (Frame_GetFrameType(info->m_activeFrame.frame) == Frame::TYPE_FUNC_EVAL) + else if (info->m_activeFrame.frame->GetFrameType() == Frame::TYPE_FUNC_EVAL) { // Note: we treat walking off the top of the stack and // walking off the top of a func eval the same way, @@ -6613,8 +6613,8 @@ void DebuggerStepper::TrapStepOut(ControllerStackInfo *info, bool fForceTraditio m_reason = STEP_EXIT; break; } - else if (Frame_GetFrameType(info->m_activeFrame.frame) == Frame::TYPE_SECURITY && - Frame_GetInterception(info->m_activeFrame.frame) == INTERCEPTION_NONE) + else if (info->m_activeFrame.frame->GetFrameType() == Frame::TYPE_SECURITY && + info->m_activeFrame.frame->GetInterception() == Frame::INTERCEPTION_NONE) { // If we're stepping out of something that was protected by (declarative) security, // the security subsystem may leave a frame on the stack to cache it's computation. @@ -8211,12 +8211,12 @@ void DebuggerJMCStepper::TriggerMethodEnter(Thread * thread, // The intercept value in EE Frame's is a 0-based enumeration (not a bitfield). // The intercept value for ICorDebug is a bitfied. //----------------------------------------------------------------------------- -CorDebugIntercept ConvertFrameBitsToDbg(Interception i) +CorDebugIntercept ConvertFrameBitsToDbg(Frame::Interception i) { - _ASSERTE(i >= 0 && i < INTERCEPTION_COUNT); + _ASSERTE(i >= 0 && i < Frame::INTERCEPTION_COUNT); // Since the ee frame is a 0-based enum, we can just use a map. - const CorDebugIntercept map[INTERCEPTION_COUNT] = + const CorDebugIntercept map[Frame::INTERCEPTION_COUNT] = { // ICorDebug EE Frame INTERCEPT_NONE, // INTERCEPTION_NONE, @@ -8299,12 +8299,12 @@ class InterceptorStackInfo // If there's an interceptor frame here, then set those // bits in our bitfield. - Interception i = INTERCEPTION_NONE; + Frame::Interception i = Frame::INTERCEPTION_NONE; Frame * pFrame = pInfo->frame; if ((pFrame != NULL) && (pFrame != FRAME_TOP)) { - i = Frame_GetInterception(pFrame); - if (i != INTERCEPTION_NONE) + i = pFrame->GetInterception(); + if (i != Frame::INTERCEPTION_NONE) { pThis->m_bits |= (int) ConvertFrameBitsToDbg(i); } @@ -8452,7 +8452,7 @@ TP_RESULT DebuggerThreadStarter::TriggerPatch(DebuggerControllerPatch *patch, CONTRACT_VIOLATION(GCViolation); traceOk = g_pEEInterface->TraceManager(thread, patch->trace.GetStubManager(), &trace, context, &dummy); } - else if ((patch->trace.GetTraceType() == TRACE_FRAME_PUSH) && (Frame_IsTransitionToNativeFrame(thread->GetFrame()))) + else if ((patch->trace.GetTraceType() == TRACE_FRAME_PUSH) && (thread->GetFrame()->IsTransitionToNativeFrame())) { // If we've got a frame that is transitioning to native, there's no reason to try to keep tracing. So we // bail early and save ourselves some effort. This also works around a problem where we deadlock trying to diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index f677dcbd08d6fd..9e907b47ca7bc5 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -7946,8 +7946,8 @@ LONG Debugger::NotifyOfCHFFilter(EXCEPTION_POINTERS* pExceptionPointers, PVOID p // Calling a virtual method will enforce that we have a valid Frame. ;) // If we got passed in a random catch address, then when we cast to a Frame // the vtable pointer will be bogus and this call will AV. - ETransitionType e; - e = Frame_GetTransitionType(pFrame); + Frame::ETransitionType e; + e = pFrame->GetTransitionType(); } #endif } @@ -12552,7 +12552,7 @@ bool Debugger::IsThreadAtSafePlaceWorker(Thread *thread) if (ISREDIRECTEDTHREAD(thread)) { - Frame_UpdateRegDisplay(thread->GetFrame(), &rd); + thread->GetFrame()->UpdateRegDisplay(&rd); } } @@ -16669,7 +16669,7 @@ Debugger::EnumMemoryRegionsIfFuncEvalFrame(CLRDataEnumMemoryFlags flags, Frame * { SUPPORTS_DAC; - if ((pFrame != NULL) && (Frame_GetFrameType(pFrame) == Frame::TYPE_FUNC_EVAL)) + if ((pFrame != NULL) && (pFrame->GetFrameType() == Frame::TYPE_FUNC_EVAL)) { FuncEvalFrame * pFEF = dac_cast(pFrame); DebuggerEval * pDE = pFEF->GetDebuggerEval(); diff --git a/src/coreclr/debug/ee/frameinfo.cpp b/src/coreclr/debug/ee/frameinfo.cpp index b3bac9cb2da7e9..669a8f62607eeb 100644 --- a/src/coreclr/debug/ee/frameinfo.cpp +++ b/src/coreclr/debug/ee/frameinfo.cpp @@ -416,7 +416,7 @@ bool HasExitRuntime(Frame *pFrame, DebuggerFrameData *pData, FramePointer *pPote NOTHROW; GC_NOTRIGGER; // Callers demand this function be GC_NOTRIGGER. MODE_ANY; - PRECONDITION(Frame_GetFrameType(pFrame) == Frame::TYPE_EXIT); + PRECONDITION(pFrame->GetFrameType() == Frame::TYPE_EXIT); } CONTRACTL_END; @@ -787,9 +787,9 @@ void FrameInfo::InitForM2UInternalFrame(CrawlFrame * pCF) { // For a M2U call, there's a managed method wrapping the unmanaged call. Use that. Frame * pFrame = pCF->GetFrame(); - _ASSERTE(Frame_GetTransitionType(pFrame) == TT_M2U); + _ASSERTE(pFrame->GetTransitionType() == Frame::TT_M2U); FramedMethodFrame * pM2U = static_cast (pFrame); - MethodDesc * pMDWrapper = Frame_GetFunction(pM2U); + MethodDesc * pMDWrapper = pM2U->GetFunction(); // Soem M2U transitions may not have a function associated w/ them, // so pMDWrapper may be NULL. PInvokeCalliFrame is an example. @@ -836,7 +836,7 @@ void FrameInfo::InitForADTransition(CrawlFrame * pCF) { Frame * pFrame; pFrame = pCF->GetFrame(); - _ASSERTE(Frame_GetTransitionType(pFrame) == TT_AppDomain); + _ASSERTE(pFrame->GetTransitionType() == Frame::TT_AppDomain); MethodDesc * pMDWrapper = NULL; InitFromStubHelper(pCF, pMDWrapper, STUBFRAME_APPDOMAIN_TRANSITION); @@ -956,7 +956,7 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) // If we encounter an ExitFrame out in the wild, then we'll convert it to an UM chain. if (!d->IsTrackingUMChain()) { - if ((frame != NULL) && (frame != FRAME_TOP) && (Frame_GetFrameType(frame) == Frame::TYPE_EXIT)) + if ((frame != NULL) && (frame != FRAME_TOP) && (frame->GetFrameType() == Frame::TYPE_EXIT)) { LOG((LF_CORDB, LL_EVERYTHING, "DWSP. ExitFrame while not tracking\n")); REGDISPLAY* pRDSrc = pCF->GetRegisterSet(); @@ -988,14 +988,14 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) d->SetUMChainEnd(FramePointer::MakeFramePointer((LPVOID)(frame))); - ETransitionType t = Frame_GetTransitionType(frame); - int ft = Frame_GetFrameType(frame); + Frame::ETransitionType t = frame->GetTransitionType(); + int ft = frame->GetFrameType(); // Sometimes we may not want to show an UM chain b/c we know it's just // code inside of mscorwks. (Eg: Funcevals & AD transitions both fall into this category). // These are perfectly valid UM chains and we could give them if we wanted to. - if ((t == TT_AppDomain) || (ft == Frame::TYPE_FUNC_EVAL)) + if ((t == Frame::TT_AppDomain) || (ft == Frame::TYPE_FUNC_EVAL)) { d->CancelUMChain(); return SWA_CONTINUE; @@ -1003,7 +1003,7 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) // If we hit an M2U frame, then go ahead and dispatch the UM chain now. // This will likely also be an exit frame. - if (t == TT_M2U) + if (t == Frame::TT_M2U) { fDispatchUMChain = true; } @@ -1085,7 +1085,7 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) // UM chain must still be in CLR internal code. // Either way, this UM chain has ended (and some new chain based off the frame has started) // so we need to either Cancel the chain or dispatch it. - if (Frame_GetInterception(frame) != INTERCEPTION_NONE) + if (frame->GetInterception() != Frame::INTERCEPTION_NONE) { // Interceptors may contain calls out to unmanaged code (such as unmanaged dllmain when // loading a new dll), so we need to dispatch these. @@ -1216,8 +1216,8 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) if (d->ShouldProvideInternalFrames() && (frame != NULL) && (frame != FRAME_TOP)) { // We want to dispatch a M2U transition right after we dispatch the UM chain. - ETransitionType t = Frame_GetTransitionType(frame); - if (t == TT_M2U) + Frame::ETransitionType t = frame->GetTransitionType(); + if (t == Frame::TT_M2U) { // Frame for a M2U transition. FrameInfo fM2U; @@ -1496,7 +1496,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) d->info.fIsLeaf = true; } else if ( (pPrevFrame != NULL) && - (Frame_GetFrameType(pPrevFrame) == Frame::TYPE_EXIT) && + (pPrevFrame->GetFrameType() == Frame::TYPE_EXIT) && !HasExitRuntime(pPrevFrame, d, NULL) ) { // This is for the inlined NDirectMethodFrameGeneric case. We have not exit the runtime yet, so the current @@ -1629,27 +1629,27 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) // CHAIN_CONTEXT_SWITCH - not used // CHAIN_FUNC_EVAL - funceval - switch (Frame_GetInterception(frame)) + switch (frame->GetInterception()) { - case INTERCEPTION_CLASS_INIT: + case Frame::INTERCEPTION_CLASS_INIT: // // Fall through // // V2 assumes that the only thing the prestub intercepts is the class constructor - case INTERCEPTION_PRESTUB: + case Frame::INTERCEPTION_PRESTUB: d->info.chainReason = CHAIN_CLASS_INIT; break; - case INTERCEPTION_EXCEPTION: + case Frame::INTERCEPTION_EXCEPTION: d->info.chainReason = CHAIN_EXCEPTION_FILTER; break; - case INTERCEPTION_CONTEXT: + case Frame::INTERCEPTION_CONTEXT: d->info.chainReason = CHAIN_CONTEXT_POLICY; break; - case INTERCEPTION_SECURITY: + case Frame::INTERCEPTION_SECURITY: d->info.chainReason = CHAIN_SECURITY; break; @@ -1663,7 +1663,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) LOG((LF_CORDB, LL_INFO100000, "DWSP: Chain reason is 0x%X.\n", d->info.chainReason)); - switch (Frame_GetFrameType(frame)) + switch (frame->GetFrameType()) { case Frame::TYPE_ENTRY: // We now ignore entry + exit frames. case Frame::TYPE_EXIT: @@ -1768,17 +1768,17 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) // These callbacks are dispatched out of band. if (d->ShouldProvideInternalFrames() && (frame != NULL) && (frame != FRAME_TOP)) { - ETransitionType t = Frame_GetTransitionType(frame); + Frame::ETransitionType t = frame->GetTransitionType(); FrameInfo f; bool fUse = false; - if (t == TT_U2M) + if (t == Frame::TT_U2M) { // We can invoke the Internal U2M frame now. f.InitForU2MInternalFrame(pCF); fUse = true; } - else if (t == TT_AppDomain) + else if (t == Frame::TT_AppDomain) { // Internal frame for an Appdomain transition. // We used to ignore frames for ADs which we hadn't sent a Create event for yet. In V3 we send AppDomain @@ -1846,7 +1846,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) if (!pCF->IsFrameless()) { LOG((LF_CORDB, LL_INFO100000, "DWSP: updating regdisplay.\n")); - Frame_UpdateRegDisplay(pCF->GetFrame(), &d->regDisplay); + pCF->GetFrame()->UpdateRegDisplay(&d->regDisplay); } return SWA_CONTINUE; diff --git a/src/coreclr/vm/amd64/cgenamd64.cpp b/src/coreclr/vm/amd64/cgenamd64.cpp index f32a5e5d508cb5..ec952dd0f6f873 100644 --- a/src/coreclr/vm/amd64/cgenamd64.cpp +++ b/src/coreclr/vm/amd64/cgenamd64.cpp @@ -66,14 +66,14 @@ void TransitionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFl if (updateFloats) { UpdateFloatingPointRegisters(pRD); - _ASSERTE(pRD->pCurrentContext->Rip == Frame_GetReturnAddress(this)); + _ASSERTE(pRD->pCurrentContext->Rip == GetReturnAddress()); } #endif // DACCESS_COMPILE pRD->IsCallerContextValid = FALSE; pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. - pRD->pCurrentContext->Rip = Frame_GetReturnAddress(this); + pRD->pCurrentContext->Rip = GetReturnAddress(); pRD->pCurrentContext->Rsp = GetSP(); UpdateRegDisplayFromCalleeSavedRegisters(pRD, GetCalleeSavedRegisters()); diff --git a/src/coreclr/vm/callsiteinspect.cpp b/src/coreclr/vm/callsiteinspect.cpp index 0854230cb9ad3b..8209e41e6a7d44 100644 --- a/src/coreclr/vm/callsiteinspect.cpp +++ b/src/coreclr/vm/callsiteinspect.cpp @@ -71,7 +71,7 @@ namespace if (!fIsByRef && (ELEMENT_TYPE_R4 == eType || ELEMENT_TYPE_R8 == eType) && frame != nullptr - && !TransitionBlock::IsStackArgumentOffset(static_cast((TADDR) val - Frame_GetTransitionBlock(frame)))) + && !TransitionBlock::IsStackArgumentOffset(static_cast((TADDR) val - frame->GetTransitionBlock()))) { if (ELEMENT_TYPE_R4 == eType) *(UINT32*)pDest = (UINT32)FPSpillToR4(val); @@ -349,7 +349,7 @@ void CallsiteInspect::GetCallsiteArgs( for (int index = 0; index < numArgs; index++) { ArgDetails details = GetArgDetails(callsite.Frame, iter); - PVOID addr = (LPBYTE)Frame_GetTransitionBlock(callsite.Frame) + details.Offset; + PVOID addr = (LPBYTE)callsite.Frame->GetTransitionBlock() + details.Offset; // How do we handle pointer types? _ASSERTE(details.ElementType != ELEMENT_TYPE_PTR); @@ -423,7 +423,7 @@ void CallsiteInspect::PropagateOutParametersBackToCallsite( // Copy from RetVal into the retBuff. INT64 retVal = CopyOBJECTREFToStack( &gc.RetVal, - *(void**)(Frame_GetTransitionBlock(frame) + argit.GetRetBuffArgOffset()), + *(void**)(frame->GetTransitionBlock() + argit.GetRetBuffArgOffset()), pSig->GetReturnType(), TypeHandle{}, pSig, @@ -488,7 +488,7 @@ void CallsiteInspect::PropagateOutParametersBackToCallsite( if (typ != ELEMENT_TYPE_BYREF) continue; - argAddr = reinterpret_cast(Frame_GetTransitionBlock(frame) + argit.GetNextOffset()); + argAddr = reinterpret_cast(frame->GetTransitionBlock() + argit.GetNextOffset()); } else { @@ -499,7 +499,7 @@ void CallsiteInspect::PropagateOutParametersBackToCallsite( if (argit.GetArgType() != ELEMENT_TYPE_BYREF) continue; - argAddr = reinterpret_cast(Frame_GetTransitionBlock(frame) + ofs); + argAddr = reinterpret_cast(frame->GetTransitionBlock() + ofs); } TypeHandle ty; diff --git a/src/coreclr/vm/clrtocomcall.cpp b/src/coreclr/vm/clrtocomcall.cpp index 377d4bca18e854..475ca5a5552c3a 100644 --- a/src/coreclr/vm/clrtocomcall.cpp +++ b/src/coreclr/vm/clrtocomcall.cpp @@ -340,7 +340,7 @@ UINT32 CLRToCOMEventCallWorker(CLRToCOMMethodFrame* pFrame, CLRToCOMCallMethodDe MethodDescCallSite eventProvider(pEvProvMD, &gc.EventProviderObj); // Retrieve the event handler passed in. - OBJECTREF EventHandlerObj = *(OBJECTREF*)(Frame_GetTransitionBlock(pFrame) + ArgItr.GetNextOffset()); + OBJECTREF EventHandlerObj = *(OBJECTREF*)(pFrame->GetTransitionBlock() + ArgItr.GetNextOffset()); ARG_SLOT EventMethArgs[] = { @@ -375,7 +375,7 @@ static CallsiteDetails CreateCallsiteDetails(_In_ FramedMethodFrame *pFrame) } CONTRACTL_END; - MethodDesc *pMD = Frame_GetFunction(pFrame); + MethodDesc *pMD = pFrame->GetFunction(); _ASSERTE(!pMD->ContainsGenericVariables() && pMD->IsRuntimeMethodHandle()); const BOOL fIsDelegate = pMD->GetMethodTable()->IsDelegate(); @@ -780,7 +780,7 @@ TADDR CLRToCOMCall::GetFrameCallIP(FramedMethodFrame *frame) } CONTRACT_END; - CLRToCOMCallMethodDesc *pCMD = dac_cast(Frame_GetFunction(frame)); + CLRToCOMCallMethodDesc *pCMD = dac_cast(frame->GetFunction()); MethodTable *pItfMT = pCMD->GetInterfaceMethodTable(); TADDR ip = NULL; #ifndef DACCESS_COMPILE @@ -909,7 +909,7 @@ BOOL CLRToCOMMethodFrame::TraceFrame_Impl(Thread *thread, BOOL fromPatch, #endif // HOST_64BIT TADDR ip, returnIP, returnSP; - Frame_GetUnmanagedCallSite(this, &ip, &returnIP, &returnSP); + GetUnmanagedCallSite(&ip, &returnIP, &returnSP); // // If we've already made the call, we can't trace any more. diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 6ef5e4fbea0221..e6ce9ce581d1b9 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -5910,7 +5910,7 @@ EXTERN_C void STDCALL VarargPInvokeStubWorker(TransitionBlock * pTransitionBlock pFrame->Push(CURRENT_THREAD); _ASSERTE(pVASigCookie == pFrame->GetVASigCookie()); - _ASSERTE(pMD == Frame_GetFunction(pFrame)); + _ASSERTE(pMD == pFrame->GetFunction()); GetILStubForCalli(pVASigCookie, pMD); diff --git a/src/coreclr/vm/eedbginterfaceimpl.cpp b/src/coreclr/vm/eedbginterfaceimpl.cpp index 45704e5f0d2b6a..1c8de12c3f3d52 100644 --- a/src/coreclr/vm/eedbginterfaceimpl.cpp +++ b/src/coreclr/vm/eedbginterfaceimpl.cpp @@ -1220,7 +1220,7 @@ bool EEDbgInterfaceImpl::TraceFrame(Thread *thread, } CONTRACTL_END; - bool fResult = Frame_TraceFrame(frame, thread, fromPatch, trace, regs) != FALSE; + bool fResult = frame->TraceFrame(thread, fromPatch, trace, regs) != FALSE; #ifdef _DEBUG StubManager::DbgWriteLog("Doing TraceFrame on frame=0x%p (fromPatch=%d), yields:\n", frame, fromPatch); diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index 7e0e44c2e39454..19c35aa9452ed7 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -2870,7 +2870,7 @@ VOID ETW::ExceptionLog::ExceptionThrown(CrawlFrame *pCf, BOOL bIsReThrownExcept } else { - exceptionEIP = (PVOID)(Frame_GetIP(pCf->GetFrame())); + exceptionEIP = (PVOID)(pCf->GetFrame()->GetIP()); } // On platforms other than IA64, we are at the instruction after the faulting instruction diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index d5735c3d076e15..98300ff222929d 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -7326,8 +7326,8 @@ LONG WINAPI CLRVectoredExceptionHandlerShim(PEXCEPTION_POINTERS pExceptionInfo) if (pFrame == 0 || pFrame == (Frame*) -1) break; - ETransitionType type = Frame_GetTransitionType(pFrame); - if (type == TT_M2U || type == TT_InternalCall) + Frame::ETransitionType type = pFrame->GetTransitionType(); + if (type == Frame::TT_M2U || type == Frame::TT_InternalCall) { stopPoint = pFrame; break; diff --git a/src/coreclr/vm/exceptionhandling.cpp b/src/coreclr/vm/exceptionhandling.cpp index da2e1e040ab83c..1ac4832e5310d8 100644 --- a/src/coreclr/vm/exceptionhandling.cpp +++ b/src/coreclr/vm/exceptionhandling.cpp @@ -337,7 +337,7 @@ StackWalkAction UpdateObjectRefInResumeContextCallback(CrawlFrame* pCF, LPVOID p { Frame *pFrame = pCF->GetFrame(); - if (Frame_NeedsUpdateRegDisplay(pFrame)) + if (pFrame->NeedsUpdateRegDisplay()) { CONSISTENCY_CHECK(pFrame >= pState->pHighestFrameWithRegisters); pState->pHighestFrameWithRegisters = pFrame; @@ -397,7 +397,7 @@ bool ExceptionTracker::FindNonvolatileRegisterPointers(Thread* pThread, UINT_PTR while ((UINT_PTR)pFrame < uOriginalSP) { - if (Frame_NeedsUpdateRegDisplay(pFrame)) + if (pFrame->NeedsUpdateRegDisplay()) pHighestFrameWithRegisters = pFrame; pFrame = pFrame->Next(); @@ -869,7 +869,7 @@ static void PopExplicitFrames(Thread *pThread, void *targetSp, void *targetCalle Frame* pFrame = pThread->GetFrame(); while (pFrame < targetSp) { - Frame_ExceptionUnwind(pFrame); + pFrame->ExceptionUnwind(); pFrame->Pop(pThread); pFrame = pThread->GetFrame(); } @@ -898,7 +898,7 @@ static void PopExplicitFrames(Thread *pThread, void *targetSp, void *targetCalle if (ExecutionManager::IsReadyToRunCode(returnAddress)) #endif { - Frame_ExceptionUnwind(pFrame); + pFrame->ExceptionUnwind(); pFrame->Pop(pThread); } else @@ -1460,7 +1460,7 @@ void ExceptionTracker::InitializeCrawlFrameForExplicitFrame(CrawlFrame* pcfThisF pcfThisFrame->isIPadjusted = false; pcfThisFrame->pFrame = pFrame; - pcfThisFrame->pFunc = Frame_GetFunction(pFrame); + pcfThisFrame->pFunc = pFrame->GetFunction(); if (pFrame->GetType() == FrameType::InlinedCallFrame && !InlinedCallFrame::FrameHasActiveCall(pFrame)) @@ -2020,7 +2020,7 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification( // // notify Frame of unwind // - Frame_ExceptionUnwind(pFrame); + pFrame->ExceptionUnwind(); // If we have not yet set the initial explicit frame processed by this tracker, then // set it now. @@ -2384,7 +2384,7 @@ BOOL NotifyDebuggerOfStub(Thread* pThread, Frame* pCurrentFrame) // w/ the ICorDebugInternalFrame stack range. if (CORDebuggerAttached()) { - if (Frame_GetTransitionType(pCurrentFrame) == TT_M2U) + if (pCurrentFrame->GetTransitionType() == Frame::TT_M2U) { // Use -1 for the backing store pointer whenever we use the address of a frame as the stack pointer. EEToDebuggerExceptionInterfaceWrapper::FirstChanceManagedException(pThread, @@ -2417,7 +2417,7 @@ CLRUnwindStatus ExceptionTracker::ProcessExplicitFrame( Frame* pFrame = pcfThisFrame->GetFrame(); - EH_LOG((LL_INFO100, " [ ProcessExplicitFrame: pFrame: " FMT_ADDR " pMD: " FMT_ADDR " %s PASS ]\n", DBG_ADDR(pFrame), DBG_ADDR(Frame_GetFunction(pFrame)), fIsFirstPass ? "FIRST" : "SECOND")); + EH_LOG((LL_INFO100, " [ ProcessExplicitFrame: pFrame: " FMT_ADDR " pMD: " FMT_ADDR " %s PASS ]\n", DBG_ADDR(pFrame), DBG_ADDR(pFrame->GetFunction()), fIsFirstPass ? "FIRST" : "SECOND")); if (FRAME_TOP == pFrame) { @@ -6122,7 +6122,7 @@ BOOL IsSafeToUnwindFrameChain(Thread* pThread, LPVOID MemoryStackFpForFrameChain Frame* pLastFrameOfInterest = FRAME_TOP; for (Frame* pf = pThread->m_pFrame; pf < MemoryStackFpForFrameChain; pf = pf->PtrNextFrame()) { - PCODE retAddr = Frame_GetReturnAddress(pf); + PCODE retAddr = pf->GetReturnAddress(); if (retAddr != (PCODE)NULL && ExecutionManager::IsManagedCode(retAddr)) { pLastFrameOfInterest = pf; @@ -6141,7 +6141,7 @@ BOOL IsSafeToUnwindFrameChain(Thread* pThread, LPVOID MemoryStackFpForFrameChain SetIP(&ctx, 0); SetSP(&ctx, 0); FillRegDisplay(&rd, &ctx); - Frame_UpdateRegDisplay(pLastFrameOfInterest, &rd); + pLastFrameOfInterest->UpdateRegDisplay(&rd); // We're safe only if the managed method will be unwound also LPVOID managedSP = dac_cast(GetRegdisplaySP(&rd)); @@ -8373,7 +8373,7 @@ extern "C" bool QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStackwalk Frame *pFrame = pThis->m_crawl.GetFrame(); if (pFrame != FRAME_TOP) { - MethodDesc *pMD = Frame_GetFunction(pFrame); + MethodDesc *pMD = pFrame->GetFunction(); if (pMD != NULL) { GCX_COOP(); @@ -8401,9 +8401,9 @@ extern "C" bool QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStackwalk // a slightly different location in the managed code calling the pinvoke and the inlined // call frame doesn't update the context pointers anyways. Frame *pSkippedFrame = pThis->m_crawl.GetFrame(); - if (Frame_NeedsUpdateRegDisplay(pSkippedFrame) && (pSkippedFrame->GetType() != FrameType::InlinedCallFrame)) + if (pSkippedFrame->NeedsUpdateRegDisplay() && (pSkippedFrame->GetType() != FrameType::InlinedCallFrame)) { - Frame_UpdateRegDisplay(pSkippedFrame, pThis->m_crawl.GetRegisterSet()); + pSkippedFrame->UpdateRegDisplay(pThis->m_crawl.GetRegisterSet()); } } } @@ -8651,7 +8651,7 @@ extern "C" bool QCALLTYPE SfiNext(StackFrameIterator* pThis, uint* uExCollideCla } else if (pTopExInfo->m_passNumber == 1) { - pMD = Frame_GetFunction(pFrame); + pMD = pFrame->GetFunction(); if (pMD != NULL) { GCX_COOP(); diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index 57d03e8e82053b..95b4915e7def06 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -37,139 +37,139 @@ #define CHECK_APP_DOMAIN 0 -void Frame_GcScanRoots(FrameBase *frame, promote_func *fn, ScanContext* sc) +void Frame::GcScanRoots(promote_func *fn, ScanContext* sc) { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { ((frameType*)frame)->GcScanRoots_Impl(fn, sc); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { ((frameType*)this)->GcScanRoots_Impl(fn, sc); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; } -unsigned Frame_GetFrameAttribs(FrameBase *frame) +unsigned Frame::GetFrameAttribs() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetFrameAttribs_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetFrameAttribs_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } #ifndef DACCESS_COMPILE -void Frame_ExceptionUnwind(FrameBase *frame) +void Frame::ExceptionUnwind() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { ((frameType*)frame)->ExceptionUnwind_Impl(); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { ((frameType*)this)->ExceptionUnwind_Impl(); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; } #endif -BOOL Frame_NeedsUpdateRegDisplay(FrameBase *frame) +BOOL Frame::NeedsUpdateRegDisplay() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->NeedsUpdateRegDisplay_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->NeedsUpdateRegDisplay_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } -BOOL Frame_IsTransitionToNativeFrame(FrameBase *frame) +BOOL Frame::IsTransitionToNativeFrame() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->IsTransitionToNativeFrame_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->IsTransitionToNativeFrame_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } -MethodDesc *Frame_GetFunction(FrameBase* frame) +MethodDesc *Frame::GetFunction() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetFunction_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetFunction_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } -Assembly *Frame_GetAssembly(FrameBase* frame) +Assembly *Frame::GetAssembly() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetAssembly_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetAssembly_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } -PTR_BYTE Frame_GetIP(FrameBase* frame) +PTR_BYTE Frame::GetIP() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetIP_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetIP_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } -TADDR Frame_GetReturnAddressPtr(FrameBase* frame) +TADDR Frame::GetReturnAddressPtr() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetReturnAddressPtr_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetReturnAddressPtr_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } -PCODE Frame_GetReturnAddress(FrameBase* frame) +PCODE Frame::GetReturnAddress() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetReturnAddress_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetReturnAddress_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } -void Frame_UpdateRegDisplay(FrameBase* frame, const PREGDISPLAY pRegDisplay, bool updateFloats) +void Frame::UpdateRegDisplay(const PREGDISPLAY pRegDisplay, bool updateFloats) { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { ((frameType*)frame)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { ((frameType*)this)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; } -int Frame_GetFrameType(FrameBase* frame) +int Frame::GetFrameType() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetFrameType_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetFrameType_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } -ETransitionType Frame_GetTransitionType(FrameBase* frame) +Frame::ETransitionType Frame::GetTransitionType() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetTransitionType_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetTransitionType_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return (ETransitionType)0; } -Interception Frame_GetInterception(FrameBase* frame) +Frame::Interception Frame::GetInterception() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetInterception_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetInterception_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return (Interception)0; } -void Frame_GetUnmanagedCallSite(FrameBase* frame, TADDR* ip, TADDR* returnIP, TADDR* returnSP) +void Frame::GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP) { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { ((frameType*)frame)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { ((frameType*)this)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; } -BOOL Frame_TraceFrame(FrameBase* frame, Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) +BOOL Frame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->TraceFrame_Impl(thread, fromPatch, trace, regs); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->TraceFrame_Impl(thread, fromPatch, trace, regs); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return FALSE; } #ifdef DACCESS_COMPILE -void Frame_EnumMemoryRegions(FrameBase* frame, CLRDataEnumMemoryFlags flags) +void Frame::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { ((frameType*)frame)->EnumMemoryRegions_Impl(flags); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { ((frameType*)this)->EnumMemoryRegions_Impl(flags); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; @@ -177,9 +177,9 @@ void Frame_EnumMemoryRegions(FrameBase* frame, CLRDataEnumMemoryFlags flags) #endif // DACCESS_COMPILE #if defined(_DEBUG) && !defined(DACCESS_COMPILE) -BOOL Frame_Protects(FrameBase* frame, OBJECTREF *ppObjectRef) +BOOL Frame::Protects(OBJECTREF *ppObjectRef) { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->Protects_Impl(ppObjectRef); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->Protects_Impl(ppObjectRef); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return FALSE; @@ -188,18 +188,17 @@ BOOL Frame_Protects(FrameBase* frame, OBJECTREF *ppObjectRef) #endif // defined(_DEBUG) && !defined(DACCESS_COMPILE) // TransitionFrame only apis -class TransitionFrame; -TADDR Frame_GetTransitionBlock(TransitionFrame* frame) +TADDR TransitionFrame::GetTransitionBlock() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->GetTransitionBlock_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetTransitionBlock_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return (TADDR)0; } -BOOL Frame_SuppressParamTypeArg(TransitionFrame* frame) +BOOL TransitionFrame::SuppressParamTypeArg() { -#define FRAME_TYPE_NAME(frameType) if (frame->GetType() == FrameType::frameType) { return ((frameType*)frame)->SuppressParamTypeArg_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->SuppressParamTypeArg_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return FALSE; @@ -227,7 +226,7 @@ void Frame::Log() { dbgStubCtr++; // basicly a nop to put a breakpoint on. } - MethodDesc* method = Frame_GetFunction(this); + MethodDesc* method = GetFunction(); STRESS_LOG3(LF_STUBS, LL_INFO1000000, "STUBS: In Stub with Frame %p assoc Method %pM FrameType = %pV\n", this, method, *((void**) this)); @@ -255,12 +254,12 @@ void Frame::Log() { method->m_pszDebugClassName, method->m_pszDebugMethodName, method->m_pszDebugMethodSignature, - DBG_ADDR(Frame_GetReturnAddressPtr(this)))); + DBG_ADDR(GetReturnAddressPtr()))); else LOG((LF_STUBS, LL_INFO1000000, "IN %s Stub Method UNKNOWN ESP of return" FMT_ADDR "\n", frameType, - DBG_ADDR(Frame_GetReturnAddressPtr(this)) )); + DBG_ADDR(GetReturnAddressPtr()) )); _ASSERTE(GetThread()->PreemptiveGCDisabled()); } @@ -645,7 +644,7 @@ PTR_VOID TransitionFrame::GetParamTypeArg() // may be another option. ENABLE_FORBID_GC_LOADER_USE_IN_THIS_SCOPE(); - MethodDesc *pFunction = Frame_GetFunction(this); + MethodDesc *pFunction = GetFunction(); _ASSERTE (pFunction->RequiresInstArg()); MetaSig msig(pFunction); @@ -653,14 +652,14 @@ PTR_VOID TransitionFrame::GetParamTypeArg() INT offs = argit.GetParamTypeArgOffset(); - TADDR taParamTypeArg = *PTR_TADDR(Frame_GetTransitionBlock(this) + offs); + TADDR taParamTypeArg = *PTR_TADDR(GetTransitionBlock() + offs); return PTR_VOID(taParamTypeArg); } TADDR TransitionFrame::GetAddrOfThis() { WRAPPER_NO_CONTRACT; - return Frame_GetTransitionBlock(this) + ArgIterator::GetThisOffset(); + return GetTransitionBlock() + ArgIterator::GetThisOffset(); } VASigCookie * TransitionFrame::GetVASigCookie() @@ -672,10 +671,10 @@ VASigCookie * TransitionFrame::GetVASigCookie() sizeof(TransitionBlock))); #else WRAPPER_NO_CONTRACT; - MetaSig msig(Frame_GetFunction(this)); + MetaSig msig(GetFunction()); ArgIterator argit(&msig); return PTR_VASigCookie( - *dac_cast(Frame_GetTransitionBlock(this) + argit.GetVASigCookieOffset())); + *dac_cast(GetTransitionBlock() + argit.GetVASigCookieOffset())); #endif } @@ -706,7 +705,7 @@ BOOL PrestubMethodFrame::TraceFrame_Impl(Thread *thread, BOOL fromPatch, // native code versions, even if they aren't the one that was reported by this trace, see // DebuggerController::PatchTrace() under case TRACE_MANAGED. This alleviates the StubManager from having to prevent the // race that occurs here. - trace->InitForStub(Frame_GetFunction(this)->GetMethodEntryPointIfExists()); + trace->InitForStub(GetFunction()->GetMethodEntryPointIfExists()); } else { @@ -871,7 +870,7 @@ BOOL StubDispatchFrame::TraceFrame_Impl(Thread *thread, BOOL fromPatch, return FALSE; } -Interception StubDispatchFrame::GetInterception_Impl() +Frame::Interception StubDispatchFrame::GetInterception_Impl() { LIMITED_METHOD_CONTRACT; @@ -951,14 +950,14 @@ PTR_BYTE ExternalMethodFrame::GetGCRefMap() return pGCRefMap; } -Interception ExternalMethodFrame::GetInterception_Impl() +Frame::Interception ExternalMethodFrame::GetInterception_Impl() { LIMITED_METHOD_CONTRACT; return INTERCEPTION_NONE; } -Interception PrestubMethodFrame::GetInterception_Impl() +Frame::Interception PrestubMethodFrame::GetInterception_Impl() { LIMITED_METHOD_DAC_CONTRACT; @@ -993,11 +992,11 @@ void DynamicHelperFrame::GcScanRoots_Impl(promote_func *fn, ScanContext* sc) FramedMethodFrame::GcScanRoots_Impl(fn, sc); - PTR_PTR_Object pArgumentRegisters = dac_cast(Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfArgumentRegisters()); + PTR_PTR_Object pArgumentRegisters = dac_cast(GetTransitionBlock() + TransitionBlock::GetOffsetOfArgumentRegisters()); if (m_dynamicHelperFrameFlags & DynamicHelperFrameFlags_ObjectArg) { - TADDR pArgument = Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfArgumentRegisters(); + TADDR pArgument = GetTransitionBlock() + TransitionBlock::GetOffsetOfArgumentRegisters(); #ifdef TARGET_X86 // x86 is special as always pArgument += offsetof(ArgumentRegisters, ECX); @@ -1007,7 +1006,7 @@ void DynamicHelperFrame::GcScanRoots_Impl(promote_func *fn, ScanContext* sc) if (m_dynamicHelperFrameFlags & DynamicHelperFrameFlags_ObjectArg2) { - TADDR pArgument = Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfArgumentRegisters(); + TADDR pArgument = GetTransitionBlock() + TransitionBlock::GetOffsetOfArgumentRegisters(); #ifdef TARGET_X86 // x86 is special as always pArgument += offsetof(ArgumentRegisters, EDX); @@ -1275,7 +1274,7 @@ static StackWalkAction IsProtectedByGCFrameStackWalkFramesCallback( IsProtectedByGCFrameStruct *pd = (IsProtectedByGCFrameStruct*)pData; Frame *pFrame = pCF->GetFrame(); if (pFrame) { - if (Frame_Protects(pFrame, pd->ppObjectRef)) { + if (pFrame->Protects(pd->ppObjectRef)) { pd->count++; } } @@ -1447,7 +1446,7 @@ void TransitionFrame::PromoteCallerStack(promote_func* fn, ScanContext* sc) // We're going to have to look at the signature to determine // which arguments a are pointers....First we need the function - pFunction = Frame_GetFunction(this); + pFunction = GetFunction(); if (pFunction == NULL) return; @@ -1472,7 +1471,7 @@ void TransitionFrame::PromoteCallerStack(promote_func* fn, ScanContext* sc) if (fCtorOfVariableSizedObject) msig.ClearHasThis(); - if (pFunction->RequiresInstArg() && !Frame_SuppressParamTypeArg(this)) + if (pFunction->RequiresInstArg() && !SuppressParamTypeArg()) msig.SetHasParamTypeArg(); PromoteCallerStackHelper (fn, sc, pFunction, &msig); @@ -1506,7 +1505,7 @@ void TransitionFrame::PromoteCallerStackHelper(promote_func* fn, ScanContext* sc ArgIterator argit(pmsig); - TADDR pTransitionBlock = Frame_GetTransitionBlock(this); + TADDR pTransitionBlock = GetTransitionBlock(); // promote 'this' for non-static methods if (argit.HasThis() && pFunction != NULL) @@ -1571,7 +1570,7 @@ void TransitionFrame::PromoteCallerStackUsingGCRefMap(promote_func* fn, ScanCont decoder.ReadStackPop(); #endif - TADDR pTransitionBlock = Frame_GetTransitionBlock(this); + TADDR pTransitionBlock = GetTransitionBlock(); while (!decoder.AtEnd()) { @@ -1683,7 +1682,7 @@ void CLRToCOMMethodFrame::GcScanRoots_Impl(promote_func* fn, ScanContext* sc) // Promote the returned object - MethodDesc* methodDesc = Frame_GetFunction(this); + MethodDesc* methodDesc = GetFunction(); ReturnKind returnKind = methodDesc->GetReturnKind(); if (returnKind == RT_Object) { @@ -1734,7 +1733,7 @@ BOOL TransitionFrame::Protects_Impl(OBJECTREF * ppORef) IsObjRefProtectedScanContext sc (ppORef); // Set the stack limit for the scan to the SP of the managed frame above the transition frame sc.stack_limit = GetSP(); - Frame_GcScanRoots (this, IsObjRefProtected, &sc); + GcScanRoots (IsObjRefProtected, &sc); return sc.oref_protected; } #endif //defined (_DEBUG) && !defined (DACCESS_COMPILE) @@ -1791,7 +1790,7 @@ void ComMethodFrame::DoSecondPassHandlerCleanup(Frame * pCurFrame) pCurFrame = pThread->GetFrame(); while ((pCurFrame != NULL) && (pCurFrame <= pComMethodFrame)) { - Frame_ExceptionUnwind(pCurFrame); + pCurFrame->ExceptionUnwind(); pCurFrame = pCurFrame->PtrNextFrame(); } @@ -2057,7 +2056,7 @@ PCODE UnmanagedToManagedFrame::GetReturnAddress_Impl() PCODE pRetAddr = Frame::GetReturnAddress_Impl(); if (InlinedCallFrame::FrameHasActiveCall(m_Next) && - pRetAddr == Frame_GetReturnAddress(m_Next)) + pRetAddr == m_Next->GetReturnAddress()) { // there's actually no unmanaged code involved - we were called directly // from managed code using an InlinedCallFrame @@ -2393,4 +2392,3 @@ void ComputeCallRefMap(MethodDesc* pMD, } #endif // !DACCESS_COMPILE - diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index da157e14027983..93f70cfa559b6e 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -241,54 +241,6 @@ enum class FrameType : TADDR class FrameBase; -enum ETransitionType -{ - TT_NONE, - TT_M2U, // we can safely cast to a FramedMethodFrame - TT_U2M, // we can safely cast to a UnmanagedToManagedFrame - TT_AppDomain, // transitioniting between AppDomains. - TT_InternalCall, // calling into the CLR (ecall/fcall). -}; - -enum Interception -{ - INTERCEPTION_NONE, - INTERCEPTION_CLASS_INIT, - INTERCEPTION_EXCEPTION, - INTERCEPTION_CONTEXT, - INTERCEPTION_SECURITY, - INTERCEPTION_PRESTUB, - INTERCEPTION_OTHER, - - INTERCEPTION_COUNT -}; - - -void Frame_GcScanRoots(FrameBase *frame, promote_func *fn, ScanContext* sc); -unsigned Frame_GetFrameAttribs(FrameBase *frame); -#ifndef DACCESS_COMPILE -void Frame_ExceptionUnwind(FrameBase *frame); -#endif -BOOL Frame_NeedsUpdateRegDisplay(FrameBase *frame); -BOOL Frame_IsTransitionToNativeFrame(FrameBase *frame); -MethodDesc *Frame_GetFunction(FrameBase* frame); -Assembly *Frame_GetAssembly(FrameBase* frame); -PTR_BYTE Frame_GetIP(FrameBase* frame); -TADDR Frame_GetReturnAddressPtr(FrameBase* frame); -PCODE Frame_GetReturnAddress(FrameBase* frame); -void Frame_UpdateRegDisplay(FrameBase* frame, const PREGDISPLAY, bool updateFloats = false); -int Frame_GetFrameType(FrameBase* frame); -ETransitionType Frame_GetTransitionType(FrameBase* frame); -Interception Frame_GetInterception(FrameBase* frame); -void Frame_GetUnmanagedCallSite(FrameBase* frame, TADDR* ip, TADDR* returnIP, TADDR* returnSP); -BOOL Frame_TraceFrame(FrameBase* frame, Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs); -#ifdef DACCESS_COMPILE -void Frame_EnumMemoryRegions(FrameBase* frame, CLRDataEnumMemoryFlags flags); -#endif // DACCESS_COMPILE -#if defined(_DEBUG) && !defined(DACCESS_COMPILE) -BOOL Frame_Protects(FrameBase* frame, OBJECTREF *ppObjectRef); -#endif // defined(_DEBUG) && !defined(DACCESS_COMPILE) - // TransitionFrame only apis class TransitionFrame; TADDR Frame_GetTransitionBlock(TransitionFrame* frame); @@ -328,6 +280,52 @@ class Frame : public FrameBase #endif public: + enum ETransitionType + { + TT_NONE, + TT_M2U, // we can safely cast to a FramedMethodFrame + TT_U2M, // we can safely cast to a UnmanagedToManagedFrame + TT_AppDomain, // transitioniting between AppDomains. + TT_InternalCall, // calling into the CLR (ecall/fcall). + }; + + enum Interception + { + INTERCEPTION_NONE, + INTERCEPTION_CLASS_INIT, + INTERCEPTION_EXCEPTION, + INTERCEPTION_CONTEXT, + INTERCEPTION_SECURITY, + INTERCEPTION_PRESTUB, + INTERCEPTION_OTHER, + + INTERCEPTION_COUNT + }; + + void GcScanRoots(promote_func *fn, ScanContext* sc); + unsigned GetFrameAttribs(); +#ifndef DACCESS_COMPILE + void ExceptionUnwind(); +#endif + BOOL NeedsUpdateRegDisplay(); + BOOL IsTransitionToNativeFrame(); + MethodDesc *GetFunction(); + Assembly *GetAssembly(); + PTR_BYTE GetIP(); + TADDR GetReturnAddressPtr(); + PCODE GetReturnAddress(); + void UpdateRegDisplay(const PREGDISPLAY, bool updateFloats = false); + int GetFrameType(); + ETransitionType GetTransitionType(); + Interception GetInterception(); + void GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP); + BOOL TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs); +#ifdef DACCESS_COMPILE + void EnumMemoryRegions(CLRDataEnumMemoryFlags flags); +#endif // DACCESS_COMPILE +#if defined(_DEBUG) && !defined(DACCESS_COMPILE) + BOOL Protects(OBJECTREF *ppObjectRef); +#endif // defined(_DEBUG) && !defined(DACCESS_COMPILE) // Should only be called on Frames that derive from TransitionFrame TADDR GetTransitionBlock_Impl() @@ -397,7 +395,7 @@ class Frame : public FrameBase Assembly *GetAssembly_Impl() { WRAPPER_NO_CONTRACT; - MethodDesc *pMethod = Frame_GetFunction(this); + MethodDesc *pMethod = GetFunction(); if (pMethod != NULL) return pMethod->GetModule()->GetAssembly(); else @@ -424,7 +422,7 @@ class Frame : public FrameBase DISABLE_ASAN PCODE GetReturnAddress_Impl() { WRAPPER_NO_CONTRACT; - TADDR ptr = Frame_GetReturnAddressPtr(this); + TADDR ptr = GetReturnAddressPtr(); return (ptr != 0) ? *PTR_PCODE(ptr) : 0; } @@ -433,7 +431,7 @@ class Frame : public FrameBase void DISABLE_ASAN SetReturnAddress(TADDR val) { WRAPPER_NO_CONTRACT; - TADDR ptr = Frame_GetReturnAddressPtr(this); + TADDR ptr = GetReturnAddressPtr(); _ASSERTE(ptr != (TADDR)NULL); *(TADDR*)ptr = val; } @@ -476,7 +474,7 @@ class Frame : public FrameBase ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; - return ETransitionType::TT_NONE; + return TT_NONE; } enum @@ -556,7 +554,7 @@ class Frame : public FrameBase // Many frames store a MethodDesc pointer in m_Datum // so pick that up automatically. - MethodDesc* func = Frame_GetFunction(this); + MethodDesc* func = GetFunction(); if (func) { func->EnumMemoryRegions(flags); @@ -849,12 +847,16 @@ class TransitionFrame : public Frame #endif public: + + TADDR GetTransitionBlock(); + BOOL SuppressParamTypeArg(); + // DACCESS: GetReturnAddressPtr should return the // target address of the return address in the frame. TADDR GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; - return Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfReturnAddress(); + return GetTransitionBlock() + TransitionBlock::GetOffsetOfReturnAddress(); } //--------------------------------------------------------------- @@ -904,20 +906,20 @@ class TransitionFrame : public Frame { LIMITED_METHOD_DAC_CONTRACT; return dac_cast( - Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfCalleeSavedRegisters()); + GetTransitionBlock() + TransitionBlock::GetOffsetOfCalleeSavedRegisters()); } ArgumentRegisters *GetArgumentRegisters() { LIMITED_METHOD_DAC_CONTRACT; return dac_cast( - Frame_GetTransitionBlock(this) + TransitionBlock::GetOffsetOfArgumentRegisters()); + GetTransitionBlock() + TransitionBlock::GetOffsetOfArgumentRegisters()); } TADDR GetSP() { LIMITED_METHOD_DAC_CONTRACT; - return Frame_GetTransitionBlock(this) + sizeof(TransitionBlock); + return GetTransitionBlock() + sizeof(TransitionBlock); } BOOL NeedsUpdateRegDisplay_Impl() @@ -1249,7 +1251,7 @@ class HelperMethodFrame : public Frame { WRAPPER_NO_CONTRACT; LIMITED_METHOD_DAC_CONTRACT; - if (Frame_GetFrameAttribs(this) & FRAME_ATTR_EXCEPTION) + if (GetFrameAttribs() & FRAME_ATTR_EXCEPTION) return(INTERCEPTION_EXCEPTION); return(INTERCEPTION_NONE); } @@ -1673,9 +1675,9 @@ class FramedMethodFrame : public TransitionFrame { LIMITED_METHOD_DAC_CONTRACT; #ifdef COM_STUBS_SEPARATE_FP_LOCATIONS - TADDR p = Frame_GetTransitionBlock(this) + GetFPArgOffset(0); + TADDR p = GetTransitionBlock() + GetFPArgOffset(0); #else - TADDR p = Frame_GetTransitionBlock(this) - TransitionBlock::GetNegSpaceSize(); + TADDR p = GetTransitionBlock() - TransitionBlock::GetNegSpaceSize(); #endif // Return value is right before the transition block (or floating point spill area on AMD64) for frames that need it // (code:TPMethodFrame and code:CLRToCOMMethodFrame) @@ -2105,7 +2107,7 @@ class StubDispatchFrame : public FramedMethodFrame // // See code:getMethodSigInternal // - assert(Frame_GetFunction(this)->GetMethodTable()->IsInterface()); + assert(GetFunction()->GetMethodTable()->IsInterface()); return TRUE; } @@ -2957,7 +2959,7 @@ class FrameWithCookie void Pop() { WRAPPER_NO_CONTRACT; m_frame.Pop(); } void Push(Thread * pThread) { WRAPPER_NO_CONTRACT; m_frame.Push(pThread); } void Pop(Thread * pThread) { WRAPPER_NO_CONTRACT; m_frame.Pop(pThread); } - PCODE GetReturnAddress() { WRAPPER_NO_CONTRACT; return Frame_GetReturnAddress(&m_frame); } + PCODE GetReturnAddress() { WRAPPER_NO_CONTRACT; return m_frame.GetReturnAddress(); } T_CONTEXT * GetContext() { WRAPPER_NO_CONTRACT; return m_frame.GetContext(); } FrameType* operator&() { LIMITED_METHOD_CONTRACT; return &m_frame; } LazyMachState * MachineState() { WRAPPER_NO_CONTRACT; return m_frame.MachineState(); } diff --git a/src/coreclr/vm/gcenv.ee.common.cpp b/src/coreclr/vm/gcenv.ee.common.cpp index 17f548001390cb..f0a84ac2d4239b 100644 --- a/src/coreclr/vm/gcenv.ee.common.cpp +++ b/src/coreclr/vm/gcenv.ee.common.cpp @@ -106,7 +106,7 @@ inline bool SafeToReportGenericParamContext(CrawlFrame* pCF) if (!pCF->IsFrameless() && pCF->GetFrame()->GetType() == FrameType::StubDispatchFrame) { - return !Frame_SuppressParamTypeArg((StubDispatchFrame*)pCF->GetFrame()); + return !((StubDispatchFrame*)pCF->GetFrame())->SuppressParamTypeArg(); } if (!pCF->IsFrameless() || !(pCF->IsActiveFrame() || pCF->IsInterrupted())) @@ -370,8 +370,8 @@ StackWalkAction GcStackCrawlCallBack(CrawlFrame* pCF, VOID* pData) STRESS_LOG3(LF_GCROOTS, LL_INFO1000, "Scanning ExplicitFrame %p AssocMethod = %pM frameVTable = %pV\n", - pFrame, Frame_GetFunction(pFrame), *((void**) pFrame)); - Frame_GcScanRoots(pFrame, gcctx->f, gcctx->sc); + pFrame, pFrame->GetFunction(), *((void**) pFrame)); + pFrame->GcScanRoots( gcctx->f, gcctx->sc); } } else diff --git a/src/coreclr/vm/gcenv.ee.cpp b/src/coreclr/vm/gcenv.ee.cpp index 83f6d7eb1d1412..55329274905a5d 100644 --- a/src/coreclr/vm/gcenv.ee.cpp +++ b/src/coreclr/vm/gcenv.ee.cpp @@ -190,7 +190,7 @@ static void ScanStackRoots(Thread * pThread, promote_func* fn, ScanContext* sc) Frame *pFrame = pThread->GetFrame(); while (pFrame != FRAME_TOP) { - Frame_GcScanRoots(pFrame, fn, sc); + pFrame->GcScanRoots(fn, sc); pFrame = pFrame->PtrNextFrame(); } } diff --git a/src/coreclr/vm/prestub.cpp b/src/coreclr/vm/prestub.cpp index 94b9896ce7d7bf..b78092f7156336 100644 --- a/src/coreclr/vm/prestub.cpp +++ b/src/coreclr/vm/prestub.cpp @@ -3105,7 +3105,7 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl if (pIndirection == (PCODE)NULL) { // Assume that the callsite is call [xxxxxxxx] - PCODE retAddr = Frame_GetReturnAddress(pEMFrame); + PCODE retAddr = pEMFrame->GetReturnAddress(); #ifdef TARGET_X86 pIndirection = *(((TADDR *)retAddr) - 1); #else @@ -3302,7 +3302,7 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl else token = DispatchToken::CreateDispatchToken(slot); - StubCallSite callSite(pIndirection, Frame_GetReturnAddress(pEMFrame)); + StubCallSite callSite(pIndirection, pEMFrame->GetReturnAddress()); pCode = pMgr->ResolveWorker(&callSite, protectedObj, token, STUB_CODE_BLOCK_VSD_LOOKUP_STUB); } else @@ -4062,7 +4062,7 @@ extern "C" SIZE_T STDCALL DynamicHelperWorker(TransitionBlock * pTransitionBlock if (pCell == NULL) { // Assume that the callsite is call [xxxxxxxx] - PCODE retAddr = Frame_GetReturnAddress(pFrame); + PCODE retAddr = pFrame->GetReturnAddress(); #ifdef TARGET_X86 pCell = *(((TADDR **)retAddr) - 1); #else diff --git a/src/coreclr/vm/stackwalk.cpp b/src/coreclr/vm/stackwalk.cpp index bdd3e1b2738776..ac394c14069b93 100644 --- a/src/coreclr/vm/stackwalk.cpp +++ b/src/coreclr/vm/stackwalk.cpp @@ -37,7 +37,7 @@ Assembly* CrawlFrame::GetAssembly() Frame *pF = GetFrame(); if (pF != NULL) - pAssembly = Frame_GetAssembly(pF); + pAssembly = pF->GetAssembly(); if (pAssembly == NULL && pFunc != NULL) pAssembly = pFunc->GetModule()->GetAssembly(); @@ -1245,7 +1245,7 @@ BOOL StackFrameIterator::ResetRegDisp(PREGDISPLAY pRegDisp, { #if defined(TARGET_X86) // check the IP - if (m_crawl.Frame_GetReturnAddress(pFrame)() != curPc) + if (m_crawl.pFrame->GetReturnAddress() != curPc) { break; } @@ -1265,10 +1265,10 @@ BOOL StackFrameIterator::ResetRegDisp(PREGDISPLAY pRegDisp, // if the REGDISPLAY represents the managed stack frame at a M2U transition boundary, // update the flags on the CrawlFrame and the REGDISPLAY - PCODE frameRetAddr = Frame_GetReturnAddress(m_crawl.pFrame); + PCODE frameRetAddr = m_crawl.pFrame->GetReturnAddress(); if (frameRetAddr == curPc) { - unsigned uFrameAttribs = Frame_GetFrameAttribs(m_crawl.pFrame); + unsigned uFrameAttribs = m_crawl.pFrame->GetFrameAttribs(); m_crawl.isFirst = ((uFrameAttribs & Frame::FRAME_ATTR_RESUMABLE) != 0); m_crawl.isInterrupted = ((uFrameAttribs & Frame::FRAME_ATTR_EXCEPTION) != 0); @@ -1279,7 +1279,7 @@ BOOL StackFrameIterator::ResetRegDisp(PREGDISPLAY pRegDisp, m_crawl.isIPadjusted = false; } - Frame_UpdateRegDisplay(m_crawl.pFrame, m_crawl.pRD, m_flags & UNWIND_FLOATS); + m_crawl.pFrame->UpdateRegDisplay(m_crawl.pRD, m_flags & UNWIND_FLOATS); _ASSERTE(curPc == GetControlPC(m_crawl.pRD)); } @@ -2363,7 +2363,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) { #if !defined(TARGET_X86) && defined(_DEBUG) // make sure we're not skipping a different transition - if (Frame_NeedsUpdateRegDisplay(m_crawl.pFrame)) + if (m_crawl.pFrame->NeedsUpdateRegDisplay()) { if (m_crawl.pFrame->GetType() == FrameType::InlinedCallFrame) { @@ -2375,7 +2375,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) } else { - CONSISTENCY_CHECK(GetControlPC(m_crawl.pRD) == Frame_GetReturnAddress(m_crawl.pFrame)); + CONSISTENCY_CHECK(GetControlPC(m_crawl.pRD) == m_crawl.pFrame->GetReturnAddress()); } } #endif // !defined(TARGET_X86) && defined(_DEBUG) @@ -2590,7 +2590,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) pInlinedFrame = m_crawl.pFrame; } - unsigned uFrameAttribs = Frame_GetFrameAttribs(m_crawl.pFrame); + unsigned uFrameAttribs = m_crawl.pFrame->GetFrameAttribs(); // Special resumable frames make believe they are on top of the stack. m_crawl.isFirst = (uFrameAttribs & Frame::FRAME_ATTR_RESUMABLE) != 0; @@ -2605,7 +2605,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) m_crawl.isIPadjusted = false; } - PCODE adr = Frame_GetReturnAddress(m_crawl.pFrame); + PCODE adr = m_crawl.pFrame->GetReturnAddress(); _ASSERTE(adr != (PCODE)POISONC); _ASSERTE(!pInlinedFrame || adr); @@ -2618,7 +2618,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) if (m_crawl.isFrameless) { - Frame_UpdateRegDisplay(m_crawl.pFrame, m_crawl.pRD, m_flags & UNWIND_FLOATS); + m_crawl.pFrame->UpdateRegDisplay(m_crawl.pRD, m_flags & UNWIND_FLOATS); #if defined(RECORD_RESUMABLE_FRAME_SP) CONSISTENCY_CHECK(NULL == m_pvResumableFrameTargetSP); @@ -2938,7 +2938,7 @@ void StackFrameIterator::ProcessCurrentFrame(void) _ASSERTE(m_crawl.pFrame != FRAME_TOP); - m_crawl.pFunc = Frame_GetFunction(m_crawl.pFrame); + m_crawl.pFunc = m_crawl.pFrame->GetFunction(); m_frameState = SFITER_FRAME_FUNCTION; } @@ -3044,7 +3044,7 @@ BOOL StackFrameIterator::CheckForSkippedFrames(void) } else { - m_crawl.pFunc = Frame_GetFunction(m_crawl.pFrame); + m_crawl.pFunc = m_crawl.pFrame->GetFunction(); } INDEBUG(m_crawl.pThread->DebugLogStackWalkInfo(&m_crawl, "CONSIDER", m_uFramesProcessed)); @@ -3288,7 +3288,7 @@ void SetUpRegdisplayForStackWalk(Thread * pThread, T_CONTEXT * pContext, REGDISP if (ISREDIRECTEDTHREAD(pThread)) { - Frame_UpdateRegDisplay(pThread->GetFrame(), pRegdisplay); + pThread->GetFrame()->UpdateRegDisplay(pRegdisplay); } } } diff --git a/src/coreclr/vm/syncblk.cpp b/src/coreclr/vm/syncblk.cpp index 21c64ae431671e..3fb9089bf31c54 100644 --- a/src/coreclr/vm/syncblk.cpp +++ b/src/coreclr/vm/syncblk.cpp @@ -2385,7 +2385,7 @@ void AwareLock::Enter() // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); int caller = (pFrame && pFrame != FRAME_TOP - ? (int)Frame_GetReturnAddress(pFrame)() + ? (int)pFrame->GetReturnAddress() : -1); pCurThread->m_pTrackSync->EnterSync(caller, this); #endif @@ -2408,7 +2408,7 @@ void AwareLock::Enter() #if defined(_DEBUG) && defined(TRACK_SYNC) // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); - int caller = (pFrame && pFrame != FRAME_TOP ? (int)Frame_GetReturnAddress(pFrame)() : -1); + int caller = (pFrame && pFrame != FRAME_TOP ? (int)pFrame->GetReturnAddress() : -1); pCurThread->m_pTrackSync->EnterSync(caller, this); #endif } @@ -2448,7 +2448,7 @@ BOOL AwareLock::TryEnter(INT32 timeOut) #if defined(_DEBUG) && defined(TRACK_SYNC) // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); - int caller = (pFrame && pFrame != FRAME_TOP ? (int)Frame_GetReturnAddress(pFrame)() : -1); + int caller = (pFrame && pFrame != FRAME_TOP ? (int)pFrame->GetReturnAddress() : -1); pCurThread->m_pTrackSync->EnterSync(caller, this); #endif return true; @@ -2474,7 +2474,7 @@ BOOL AwareLock::TryEnter(INT32 timeOut) #if defined(_DEBUG) && defined(TRACK_SYNC) // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); - int caller = (pFrame && pFrame != FRAME_TOP ? (int)Frame_GetReturnAddress(pFrame)() : -1); + int caller = (pFrame && pFrame != FRAME_TOP ? (int)pFrame->GetReturnAddress() : -1); pCurThread->m_pTrackSync->EnterSync(caller, this); #endif return true; @@ -2728,7 +2728,7 @@ BOOL AwareLock::EnterEpilogHelper(Thread* pCurThread, INT32 timeOut) #if defined(_DEBUG) && defined(TRACK_SYNC) // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); - int caller = (pFrame && pFrame != FRAME_TOP ? (int)Frame_GetReturnAddress(pFrame)() : -1); + int caller = (pFrame && pFrame != FRAME_TOP ? (int)pFrame->GetReturnAddress() : -1); pCurThread->m_pTrackSync->EnterSync(caller, this); #endif return true; diff --git a/src/coreclr/vm/syncblk.inl b/src/coreclr/vm/syncblk.inl index 3a98417533b42f..4cad064c8149de 100644 --- a/src/coreclr/vm/syncblk.inl +++ b/src/coreclr/vm/syncblk.inl @@ -696,7 +696,7 @@ FORCEINLINE AwareLock::LeaveHelperAction AwareLock::LeaveHelper(Thread* pCurThre #if defined(_DEBUG) && defined(TRACK_SYNC) // The best place to grab this is from the ECall frame Frame *pFrame = pCurThread->GetFrame(); - int caller = (pFrame && pFrame != FRAME_TOP ? (int) Frame_GetReturnAddress(pFrame)() : -1); + int caller = (pFrame && pFrame != FRAME_TOP ? (int) pFrame->GetReturnAddress() : -1); pCurThread->m_pTrackSync->LeaveSync(caller, this); #endif diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 39ecc9fa71ca03..64099e15ecb1f8 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -235,7 +235,7 @@ void Thread::SetFrame(Frame *pFrame) _ASSERTE(IsExecutingOnAltStack() || espVal < pFrame); _ASSERTE(IsExecutingOnAltStack() || pFrame < m_CacheStackBase); - _ASSERTE(Frame_GetFrameType(pFrame) < Frame::TYPE_COUNT); + _ASSERTE(pFrame->GetFrameType() < Frame::TYPE_COUNT); pFrame = pFrame->m_Next; } @@ -310,14 +310,14 @@ bool Thread::DetectHandleILStubsForDebugger() break; } // If there is an entry frame (i.e. U2M managed), we should break. - else if (Frame_GetFrameType(pFrame) == Frame::TYPE_ENTRY) + else if (pFrame->GetFrameType() == Frame::TYPE_ENTRY) { break; } // Check for M2U transition frames. See the comment at the beginning of this function. - else if (Frame_GetFrameType(pFrame) == Frame::TYPE_EXIT) + else if (pFrame->GetFrameType() == Frame::TYPE_EXIT) { - if (Frame_GetReturnAddress(pFrame) == (PCODE)NULL) + if (pFrame->GetReturnAddress() == (PCODE)NULL) { // If the return address is NULL, then the frame has not been initialized yet. // We may see InlinedCallFrame in ordinary methods as well. Have to do @@ -6025,7 +6025,7 @@ BOOL Thread::UniqueStack(void* stackStart) pFrame->GetFunction(); // This ensures that helper frames are inited - if (Frame_GetReturnAddress(pFrame)() != 0) + if (pFrame->GetReturnAddress() != 0) { stopPoint = pFrame; break; @@ -7457,7 +7457,7 @@ Frame * Thread::NotifyFrameChainOfExceptionUnwind(Frame* pStartFrame, LPVOID pvL { CONSISTENCY_CHECK(pFrame != PTR_NULL); CONSISTENCY_CHECK((pFrame) > static_cast((LPVOID)GetCurrentSP())); - Frame_ExceptionUnwind(pFrame); + pFrame->ExceptionUnwind(); pFrame = pFrame->Next(); } @@ -7955,7 +7955,7 @@ Thread::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) while (frame.IsValid() && frame.GetAddr() != dac_cast(FRAME_TOP)) { - Frame_EnumMemoryRegions(frame, flags); + frame->EnumMemoryRegions(flags); frame = frame->m_Next; } } diff --git a/src/coreclr/vm/threadsuspend.cpp b/src/coreclr/vm/threadsuspend.cpp index 56b7200c00aa02..9620d7279aa21b 100644 --- a/src/coreclr/vm/threadsuspend.cpp +++ b/src/coreclr/vm/threadsuspend.cpp @@ -600,7 +600,7 @@ static StackWalkAction TAStackCrawlCallBackWorker(CrawlFrame* pCf, StackCrawlCon MethodDesc *pMD = pCf->GetFunction(); Frame *pFrame = pCf->GetFrame(); if (pMD == NULL && pFrame != NULL) - pMD = Frame_GetFunction(pFrame); + pMD = pFrame->GetFunction(); // Non-method frames don't interest us. if (pMD == NULL) @@ -1539,7 +1539,7 @@ Thread::UserAbort(EEPolicy::ThreadAbortTypes abortType, DWORD timeout) if (!m_fPreemptiveGCDisabled) { - if ((m_pFrame != FRAME_TOP) && Frame_IsTransitionToNativeFrame(m_pFrame) + if ((m_pFrame != FRAME_TOP) && m_pFrame->IsTransitionToNativeFrame() #if defined(TARGET_X86) && !defined(FEATURE_EH_FUNCLETS) && ((size_t) GetFirstCOMPlusSEHRecord(this) > ((size_t) m_pFrame) - 20) #endif // TARGET_X86 diff --git a/src/coreclr/vm/virtualcallstub.cpp b/src/coreclr/vm/virtualcallstub.cpp index e2a50496e64dcd..4ead0cadb8b5ba 100644 --- a/src/coreclr/vm/virtualcallstub.cpp +++ b/src/coreclr/vm/virtualcallstub.cpp @@ -1382,7 +1382,7 @@ PCODE VSD_ResolveWorker(TransitionBlock * pTransitionBlock, if (pSDFrame->GetGCRefMap() != NULL) { GCX_PREEMP(); - _ASSERTE(CheckGCRefMapEqual(pSDFrame->GetGCRefMap(), Frame_GetFunction(pSDFrame), true)); + _ASSERTE(CheckGCRefMapEqual(pSDFrame->GetGCRefMap(), pSDFrame->GetFunction(), true)); } #endif // _DEBUG From 7fb5c3a218ef15c65991fa3ea471d98ffe930e95 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Tue, 4 Feb 2025 15:41:50 -0800 Subject: [PATCH 03/17] Handle more multi-arch scenarios --- src/coreclr/vm/amd64/pinvokestubs.S | 6 ++---- src/coreclr/vm/arm/asmconstants.h | 3 +++ src/coreclr/vm/arm/pinvokestubs.S | 10 ++-------- src/coreclr/vm/arm64/PInvokeStubs.asm | 4 ++-- src/coreclr/vm/arm64/asmconstants.h | 3 +++ src/coreclr/vm/arm64/pinvokestubs.S | 5 ++--- src/coreclr/vm/frames.h | 2 +- src/coreclr/vm/i386/PInvokeStubs.asm | 5 ++--- src/coreclr/vm/i386/asmconstants.h | 3 +++ src/coreclr/vm/loongarch64/asmconstants.h | 3 +++ src/coreclr/vm/loongarch64/pinvokestubs.S | 5 ++--- src/coreclr/vm/riscv64/asmconstants.h | 3 +++ src/coreclr/vm/riscv64/pinvokestubs.S | 5 ++--- 13 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/coreclr/vm/amd64/pinvokestubs.S b/src/coreclr/vm/amd64/pinvokestubs.S index 6c57f8713831b6..576ce9616bf220 100644 --- a/src/coreclr/vm/amd64/pinvokestubs.S +++ b/src/coreclr/vm/amd64/pinvokestubs.S @@ -143,10 +143,8 @@ NESTED_ENTRY JIT_PInvokeBegin, _TEXT, NoHandler mov qword ptr [rdi], rax add rdi, SIZEOF_GSCookie - // set first slot to the value of InlinedCallFrame vftable (checked by runtime code) - PREPARE_EXTERNAL_VAR _ZTV16InlinedCallFrame, rax - add rax, 0x10 - mov qword ptr [rdi], rax + // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) + mov qword ptr [rdi], FRAMETYPE_InlinedCallFrame mov qword ptr [rdi + OFFSETOF__InlinedCallFrame__m_Datum], 0 diff --git a/src/coreclr/vm/arm/asmconstants.h b/src/coreclr/vm/arm/asmconstants.h index dbd83bd6a947a2..e5cf09efc538eb 100644 --- a/src/coreclr/vm/arm/asmconstants.h +++ b/src/coreclr/vm/arm/asmconstants.h @@ -29,6 +29,9 @@ #define DBG_FRE(dbg,fre) fre #endif +#define FRAMETYPE_InlinedCallFrame 1 +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) + #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 #define DynamicHelperFrameFlags_ObjectArg2 2 diff --git a/src/coreclr/vm/arm/pinvokestubs.S b/src/coreclr/vm/arm/pinvokestubs.S index 5875a58749492a..57c6e8723d28b8 100644 --- a/src/coreclr/vm/arm/pinvokestubs.S +++ b/src/coreclr/vm/arm/pinvokestubs.S @@ -92,14 +92,8 @@ // r4 = pFrame - // set first slot to the value of InlinedCallFrame::`vftable' (checked by runtime code) -#if defined(__clang__) - ldr r1, =_ZTV16InlinedCallFrame+8-(2f+4) -2: - add r1, pc -#else - ldr r1, =_ZTV16InlinedCallFrame+8 -#endif + // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) + ldr r1, #FRAMETYPE_InlinedCallFrame str r1, [r4] mov r1, 0 diff --git a/src/coreclr/vm/arm64/PInvokeStubs.asm b/src/coreclr/vm/arm64/PInvokeStubs.asm index 37699e790b241e..5263ec772647f0 100644 --- a/src/coreclr/vm/arm64/PInvokeStubs.asm +++ b/src/coreclr/vm/arm64/PInvokeStubs.asm @@ -124,8 +124,8 @@ __PInvokeStubWorkerName SETS "$FuncPrefix":CC:"StubWorker" str x9, [x0] add x10, x0, SIZEOF__GSCookie - ;; set first slot to the value of InlinedCallFrame::`vftable' (checked by runtime code) - ldr x9, =$InlinedCallFrame_vftable + ;; set first slot to the value of InlinedCallFrame identifier (checked by runtime code) + ldr x9, #FRAMETYPE_InlinedCallFrame str x9, [x10] str xzr, [x10, #InlinedCallFrame__m_Datum] diff --git a/src/coreclr/vm/arm64/asmconstants.h b/src/coreclr/vm/arm64/asmconstants.h index 9c263b945a84f9..6aa1ad9563fbeb 100644 --- a/src/coreclr/vm/arm64/asmconstants.h +++ b/src/coreclr/vm/arm64/asmconstants.h @@ -29,6 +29,9 @@ #define DBG_FRE(dbg,fre) fre #endif +#define FRAMETYPE_InlinedCallFrame 1 +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) + #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 #define DynamicHelperFrameFlags_ObjectArg2 2 diff --git a/src/coreclr/vm/arm64/pinvokestubs.S b/src/coreclr/vm/arm64/pinvokestubs.S index e2eacde16a4ff8..a4a233cbd789d3 100644 --- a/src/coreclr/vm/arm64/pinvokestubs.S +++ b/src/coreclr/vm/arm64/pinvokestubs.S @@ -98,9 +98,8 @@ LOCAL_LABEL(\__PInvokeStubFuncName\()_0): // x19 = pFrame - // set first slot to the value of InlinedCallFrame::`vftable' (checked by runtime code) - PREPARE_EXTERNAL_VAR _ZTV16InlinedCallFrame, x9 - add x9, x9, 16 + // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) + ldr x9, #FRAMETYPE_InlinedCallFrame str x9, [x19] str xzr, [x19, #InlinedCallFrame__m_Datum] diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 93f70cfa559b6e..486db0a85173fd 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -2731,7 +2731,7 @@ class TailCallFrame : public Frame { LIMITED_METHOD_CONTRACT; // loop through the frame chain - while (pFrame->GetVTablePtr() != TailCallFrame::GetMethodFrameVPtr()) + while (pFrame->GetType() != FrameType::TailCallFrame) pFrame = pFrame->m_Next; return (TailCallFrame*)pFrame; } diff --git a/src/coreclr/vm/i386/PInvokeStubs.asm b/src/coreclr/vm/i386/PInvokeStubs.asm index 6f9ec4526a7ead..b2e79e19b8ed26 100644 --- a/src/coreclr/vm/i386/PInvokeStubs.asm +++ b/src/coreclr/vm/i386/PInvokeStubs.asm @@ -41,9 +41,8 @@ _JIT_PInvokeBegin@4 PROC public mov dword ptr [ecx], eax add ecx, SIZEOF_GSCookie - ;; set first slot to the value of InlinedCallFrame::`vftable' (checked by runtime code) - lea eax,[??_7InlinedCallFrame@@6B@] - mov dword ptr [ecx], eax + ;; set first slot to the value of InlinedCallFrame identifier (checked by runtime code) + mov dword ptr [ecx], FRAMETYPE_InlinedCallFrame mov dword ptr [ecx + InlinedCallFrame__m_Datum], edx diff --git a/src/coreclr/vm/i386/asmconstants.h b/src/coreclr/vm/i386/asmconstants.h index 396381f6c1f539..f8edeef2248a06 100644 --- a/src/coreclr/vm/i386/asmconstants.h +++ b/src/coreclr/vm/i386/asmconstants.h @@ -32,6 +32,9 @@ #define DBG_FRE(dbg,fre) fre #endif +#define FRAMETYPE_InlinedCallFrame 0x1 +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) + #define INITIAL_SUCCESS_COUNT 0x100 #define DynamicHelperFrameFlags_Default 0 diff --git a/src/coreclr/vm/loongarch64/asmconstants.h b/src/coreclr/vm/loongarch64/asmconstants.h index df3924465c6ce1..3067ee041eeb7e 100644 --- a/src/coreclr/vm/loongarch64/asmconstants.h +++ b/src/coreclr/vm/loongarch64/asmconstants.h @@ -30,6 +30,9 @@ #define DBG_FRE(dbg,fre) fre #endif +#define FRAMETYPE_InlinedCallFrame 0x1 +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) + #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 #define DynamicHelperFrameFlags_ObjectArg2 2 diff --git a/src/coreclr/vm/loongarch64/pinvokestubs.S b/src/coreclr/vm/loongarch64/pinvokestubs.S index 15d4398785b614..a9c01a674fa4a4 100644 --- a/src/coreclr/vm/loongarch64/pinvokestubs.S +++ b/src/coreclr/vm/loongarch64/pinvokestubs.S @@ -93,9 +93,8 @@ NESTED_ENTRY JIT_PInvokeBegin, _TEXT, NoHandler addi.d $s0, $a0, SIZEOF__GSCookie // s0 = pFrame - // set first slot to the value of InlinedCallFrame::`vftable' (checked by runtime code) - PREPARE_EXTERNAL_VAR _ZTV16InlinedCallFrame, $t0 - addi.d $t4, $t0, 16 + // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) + li $t0, FRAMETYPE_InlinedCallFrame st.d $t4, $s0, 0 st.d $zero, $s0, InlinedCallFrame__m_Datum diff --git a/src/coreclr/vm/riscv64/asmconstants.h b/src/coreclr/vm/riscv64/asmconstants.h index a79476b33eda27..695ba3c0feabec 100644 --- a/src/coreclr/vm/riscv64/asmconstants.h +++ b/src/coreclr/vm/riscv64/asmconstants.h @@ -25,6 +25,9 @@ #define DBG_FRE(dbg,fre) fre #endif +#define FRAMETYPE_InlinedCallFrame 0x1 +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) + #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 #define DynamicHelperFrameFlags_ObjectArg2 2 diff --git a/src/coreclr/vm/riscv64/pinvokestubs.S b/src/coreclr/vm/riscv64/pinvokestubs.S index 9f8cecb3bff43b..16b3fa53c5864d 100644 --- a/src/coreclr/vm/riscv64/pinvokestubs.S +++ b/src/coreclr/vm/riscv64/pinvokestubs.S @@ -88,9 +88,8 @@ addi s1, a0, SIZEOF__GSCookie // s1 = pFrame - // set first slot to the value of InlinedCallFrame::`vftable' (checked by runtime code) - PREPARE_EXTERNAL_VAR _ZTV16InlinedCallFrame, t0 - addi t4, t0, 16 + // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) + ld.d t4, FRAMETYPE_InlinedCallFrame sd t4, 0(s1) sd zero, (InlinedCallFrame__m_Datum)(s1) From 8fedbb6015a8414bf20bd725b190e7747a26c8d7 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Tue, 4 Feb 2025 15:55:24 -0800 Subject: [PATCH 04/17] Rename FrameType to FrameIdentifier --- .../debug/daccess/dacdbiimplstackwalk.cpp | 6 +- src/coreclr/debug/ee/frameinfo.cpp | 10 +-- src/coreclr/vm/amd64/asmconstants.h | 2 +- src/coreclr/vm/arm/asmconstants.h | 2 +- src/coreclr/vm/arm/stubs.cpp | 4 +- src/coreclr/vm/arm64/PInvokeStubs.asm | 4 - src/coreclr/vm/arm64/asmconstants.h | 2 +- src/coreclr/vm/comtoclrcall.cpp | 2 +- src/coreclr/vm/dllimport.cpp | 2 +- src/coreclr/vm/excep.cpp | 4 +- src/coreclr/vm/exceptionhandling.cpp | 18 ++--- src/coreclr/vm/frames.cpp | 76 +++++++++---------- src/coreclr/vm/frames.h | 68 ++++++++--------- src/coreclr/vm/gcenv.ee.common.cpp | 2 +- src/coreclr/vm/i386/PInvokeStubs.asm | 1 - src/coreclr/vm/i386/asmconstants.h | 2 +- src/coreclr/vm/i386/cgenx86.cpp | 6 +- src/coreclr/vm/i386/excepx86.cpp | 6 +- src/coreclr/vm/i386/jitinterfacex86.cpp | 2 +- src/coreclr/vm/loongarch64/asmconstants.h | 2 +- src/coreclr/vm/riscv64/asmconstants.h | 2 +- src/coreclr/vm/stackwalk.cpp | 14 ++-- src/coreclr/vm/threads.cpp | 2 +- src/coreclr/vm/threadsuspend.cpp | 4 +- 24 files changed, 119 insertions(+), 124 deletions(-) diff --git a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp index 908eec6f8fca28..7644e221763c41 100644 --- a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp +++ b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp @@ -558,7 +558,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread // it. In this case, pMD will remain NULL. EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY { - if (pFrame->GetType() == ::FrameType::ComMethodFrame) + if (pFrame->GetType() == FrameIdentifier::ComMethodFrame) { ComMethodFrame * pCOMFrame = dac_cast(pFrame); PTR_VOID pUnkStackSlot = pCOMFrame->GetPointerToArguments(); @@ -1142,7 +1142,7 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra } else if (ft == Frame::TYPE_EXIT) { - if ((pFrame->GetType() != ::FrameType::InlinedCallFrame) || + if ((pFrame->GetType() != FrameIdentifier::InlinedCallFrame) || InlinedCallFrame::FrameHasActiveCall(pFrame)) { resultType = STUBFRAME_M2U; @@ -1153,7 +1153,7 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra case Frame::TT_M2U: // Refer to the comment in DebuggerWalkStackProc() for StubDispatchFrame. - if (pFrame->GetType() != ::FrameType::StubDispatchFrame) + if (pFrame->GetType() != FrameIdentifier::StubDispatchFrame) { if (it == Frame::INTERCEPTION_SECURITY) { diff --git a/src/coreclr/debug/ee/frameinfo.cpp b/src/coreclr/debug/ee/frameinfo.cpp index 669a8f62607eeb..c6137c8c7eefd3 100644 --- a/src/coreclr/debug/ee/frameinfo.cpp +++ b/src/coreclr/debug/ee/frameinfo.cpp @@ -454,7 +454,7 @@ bool HasExitRuntime(Frame *pFrame, DebuggerFrameData *pData, FramePointer *pPote #else // TARGET_X86 // DebuggerExitFrame always return a NULL returnSP on x86. - if (pFrame->GetType() == ::FrameType::DebuggerExitFrame) + if (pFrame->GetType() == FrameIdentifier::DebuggerExitFrame) { if (pPotentialFP != NULL) { @@ -462,7 +462,7 @@ bool HasExitRuntime(Frame *pFrame, DebuggerFrameData *pData, FramePointer *pPote } return true; } - else if (pFrame->GetType() == ::FrameType::InlinedCallFrame) + else if (pFrame->GetType() == FrameIdentifier::InlinedCallFrame) { InlinedCallFrame *pInlinedFrame = static_cast(pFrame); LPVOID sp = (LPVOID)pInlinedFrame->GetCallSiteSP(); @@ -814,7 +814,7 @@ void FrameInfo::InitForU2MInternalFrame(CrawlFrame * pCF) // For regular U2M PInvoke cases, we don't care about MD b/c it's just going to // be the next frame. // If we're a COM2CLR call, perhaps we can get the MD for the interface. - if (pFrame->GetType() == FrameType::ComMethodFrame) + if (pFrame->GetType() == FrameIdentifier::ComMethodFrame) { ComMethodFrame* pCOMFrame = static_cast (pFrame); ComCallMethodDesc* pCMD = reinterpret_cast (pCOMFrame->ComMethodFrame::GetDatum()); @@ -1190,7 +1190,7 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) #ifdef FEATURE_COMINTEROP if ((frame != NULL) && - (frame->GetType() == FrameType::CLRToCOMMethodFrame)) + (frame->GetType() == FrameIdentifier::CLRToCOMMethodFrame)) { // This condition is part of the fix for 650903. (See // code:ControllerStackInfo::WalkStack and code:DebuggerStepper::TrapStepOut @@ -1717,7 +1717,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) // The jitted code on X64 behaves differently. // // Note that there is a corresponding change in DacDbiInterfaceImpl::GetInternalFrameType(). - if (frame->GetType() == FrameType::StubDispatchFrame) + if (frame->GetType() == FrameIdentifier::StubDispatchFrame) { use = false; } diff --git a/src/coreclr/vm/amd64/asmconstants.h b/src/coreclr/vm/amd64/asmconstants.h index cb19b495cdac89..59b04d8c0f189e 100644 --- a/src/coreclr/vm/amd64/asmconstants.h +++ b/src/coreclr/vm/amd64/asmconstants.h @@ -79,7 +79,7 @@ ASMCONSTANTS_C_ASSERT(SIZEOF_CalleeSavedRegisters == sizeof(CalleeSavedRegisters #endif #define FRAMETYPE_InlinedCallFrame 0x1 -ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameIdentifier::InlinedCallFrame) #define SIZEOF_GSCookie 0x8 ASMCONSTANTS_C_ASSERT(SIZEOF_GSCookie == sizeof(GSCookie)); diff --git a/src/coreclr/vm/arm/asmconstants.h b/src/coreclr/vm/arm/asmconstants.h index e5cf09efc538eb..0adc93cc988353 100644 --- a/src/coreclr/vm/arm/asmconstants.h +++ b/src/coreclr/vm/arm/asmconstants.h @@ -30,7 +30,7 @@ #endif #define FRAMETYPE_InlinedCallFrame 1 -ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameIdentifier::InlinedCallFrame) #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 diff --git a/src/coreclr/vm/arm/stubs.cpp b/src/coreclr/vm/arm/stubs.cpp index b55b48bc77ff27..f36beef13b37f0 100644 --- a/src/coreclr/vm/arm/stubs.cpp +++ b/src/coreclr/vm/arm/stubs.cpp @@ -1143,8 +1143,8 @@ Stub *GenerateInitPInvokeFrameHelper() psl->ThumbEmitMovConstant(regScratch, GetProcessGSCookie()); psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfGSCookie - negSpace); - // mov [regFrame + FrameInfo.offsetOfFrameVptr], InlinedCallFrame::GetMethodFrameVPtr() - psl->ThumbEmitMovConstant(regScratch, (DWORD)FrameType::InlinedCallFrame); + // mov [regFrame + FrameInfo.offsetOfFrameVptr], FrameIdentifier::InlinedCallFrame + psl->ThumbEmitMovConstant(regScratch, (DWORD)FrameIdentifier::InlinedCallFrame); psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfFrameVptr - negSpace); // ldr regScratch, [regThread + offsetof(Thread, m_pFrame)] diff --git a/src/coreclr/vm/arm64/PInvokeStubs.asm b/src/coreclr/vm/arm64/PInvokeStubs.asm index 5263ec772647f0..9833dd053d60c1 100644 --- a/src/coreclr/vm/arm64/PInvokeStubs.asm +++ b/src/coreclr/vm/arm64/PInvokeStubs.asm @@ -15,10 +15,6 @@ IMPORT s_gsCookie IMPORT g_TrapReturningThreads - SETALIAS InlinedCallFrame_vftable, ??_7InlinedCallFrame@@6B@ - IMPORT $InlinedCallFrame_vftable - - ; ------------------------------------------------------------------ ; Macro to generate PInvoke Stubs. ; $__PInvokeStubFuncName : function which calls the actual stub obtained from VASigCookie diff --git a/src/coreclr/vm/arm64/asmconstants.h b/src/coreclr/vm/arm64/asmconstants.h index 6aa1ad9563fbeb..e8daf48245f369 100644 --- a/src/coreclr/vm/arm64/asmconstants.h +++ b/src/coreclr/vm/arm64/asmconstants.h @@ -30,7 +30,7 @@ #endif #define FRAMETYPE_InlinedCallFrame 1 -ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameIdentifier::InlinedCallFrame) #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 diff --git a/src/coreclr/vm/comtoclrcall.cpp b/src/coreclr/vm/comtoclrcall.cpp index 640a0a7993340b..67cc42ed5bffba 100644 --- a/src/coreclr/vm/comtoclrcall.cpp +++ b/src/coreclr/vm/comtoclrcall.cpp @@ -471,7 +471,7 @@ extern "C" UINT64 __stdcall COMToCLRWorker(ComMethodFrame* pFrame) } // Initialize the frame's VPTR and GS cookie. - *((TADDR*)pFrame) = (TADDR)FrameType::ComMethodFrame; + *((TADDR*)pFrame) = (TADDR)FrameIdentifier::ComMethodFrame; *pFrame->GetGSCookiePtr() = GetProcessGSCookie(); // Link frame into the chain. pFrame->Push(pThread); diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index e6ce9ce581d1b9..eb385f425992ec 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -5859,7 +5859,7 @@ EXTERN_C LPVOID STDCALL NDirectImportWorker(NDirectMethodDesc* pMD) // INDEBUG(Thread *pThread = GetThread()); { - _ASSERTE((pThread->GetFrame() != FRAME_TOP && pThread->GetFrame()->GetType() == FrameType::InlinedCallFrame) + _ASSERTE((pThread->GetFrame() != FRAME_TOP && pThread->GetFrame()->GetType() == FrameIdentifier::InlinedCallFrame) || pMD->ShouldSuppressGCTransition()); CONSISTENCY_CHECK(pMD->IsNDirect()); diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index 98300ff222929d..c4d6a18a422c88 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -11511,7 +11511,7 @@ MethodDesc * GetUserMethodForILStub(Thread * pThread, UINT_PTR uStubSP, MethodDe // should be present further up the stack. Normally, the ComMethodFrame in question is // simply the next stack frame; however, there are situations where there may be other // stack frames present (such as an inlined stack frame from a QCall in the IL stub). - while (pCurFrame->GetType() != FrameType::ComMethodFrame) + while (pCurFrame->GetType() != FrameIdentifier::ComMethodFrame) { pCurFrame = pCurFrame->PtrNextFrame(); } @@ -11519,7 +11519,7 @@ MethodDesc * GetUserMethodForILStub(Thread * pThread, UINT_PTR uStubSP, MethodDe ComMethodFrame * pComFrame = (ComMethodFrame *)pCurFrame; _ASSERTE((UINT_PTR)pComFrame > uStubSP); - CONSISTENCY_CHECK_MSG(pComFrame->GetType() == FrameType::ComMethodFrame, + CONSISTENCY_CHECK_MSG(pComFrame->GetType() == FrameIdentifier::ComMethodFrame, "Expected to find a ComMethodFrame."); ComCallMethodDesc * pCMD = pComFrame->GetComCallMethodDesc(); diff --git a/src/coreclr/vm/exceptionhandling.cpp b/src/coreclr/vm/exceptionhandling.cpp index 1ac4832e5310d8..87655e9d8bb7ec 100644 --- a/src/coreclr/vm/exceptionhandling.cpp +++ b/src/coreclr/vm/exceptionhandling.cpp @@ -343,7 +343,7 @@ StackWalkAction UpdateObjectRefInResumeContextCallback(CrawlFrame* pCF, LPVOID p pState->pHighestFrameWithRegisters = pFrame; // Is this an InlinedCallFrame? - if (pFrame->GetType() == FrameType::InlinedCallFrame) + if (pFrame->GetType() == FrameIdentifier::InlinedCallFrame) { // If we are here, then ICF is expected to be active. _ASSERTE(InlinedCallFrame::FrameHasActiveCall(pFrame)); @@ -1462,7 +1462,7 @@ void ExceptionTracker::InitializeCrawlFrameForExplicitFrame(CrawlFrame* pcfThisF pcfThisFrame->pFrame = pFrame; pcfThisFrame->pFunc = pFrame->GetFunction(); - if (pFrame->GetType() == FrameType::InlinedCallFrame && + if (pFrame->GetType() == FrameIdentifier::InlinedCallFrame && !InlinedCallFrame::FrameHasActiveCall(pFrame)) { // Inactive ICFs in IL stubs contain the true interop MethodDesc which must be @@ -1963,7 +1963,7 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification( // the ICF immediately before and after a PInvoke in non-IL-stubs, like ReadyToRun. // See the usages for USE_PER_FRAME_PINVOKE_INIT for more information. - if (fTargetUnwind && (pFrame->GetType() == FrameType::InlinedCallFrame)) + if (fTargetUnwind && (pFrame->GetType() == FrameIdentifier::InlinedCallFrame)) { PTR_InlinedCallFrame pICF = (PTR_InlinedCallFrame)pFrame; // Does it live inside the current managed method? It will iff: @@ -7588,7 +7588,7 @@ void ExceptionTracker::ResetThreadAbortStatus(PTR_Thread pThread, CrawlFrame *pC // Mark the pinvoke frame as invoking CallCatchFunclet (and similar) for collided unwind detection void MarkInlinedCallFrameAsFuncletCall(Frame* pFrame) { - _ASSERTE(pFrame->GetType() == FrameType::InlinedCallFrame); + _ASSERTE(pFrame->GetType() == FrameIdentifier::InlinedCallFrame); InlinedCallFrame* pInlinedCallFrame = (InlinedCallFrame*)pFrame; pInlinedCallFrame->m_Datum = (PTR_NDirectMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper | (TADDR)InlinedCallFrameMarker::SecondPassFuncletCaller); } @@ -7596,7 +7596,7 @@ void MarkInlinedCallFrameAsFuncletCall(Frame* pFrame) // Mark the pinvoke frame as invoking any exception handling helper void MarkInlinedCallFrameAsEHHelperCall(Frame* pFrame) { - _ASSERTE(pFrame->GetType() == FrameType::InlinedCallFrame); + _ASSERTE(pFrame->GetType() == FrameIdentifier::InlinedCallFrame); InlinedCallFrame* pInlinedCallFrame = (InlinedCallFrame*)pFrame; pInlinedCallFrame->m_Datum = (PTR_NDirectMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper); } @@ -8217,7 +8217,7 @@ void FailFastIfCorruptingStateException(ExInfo *pExInfo) static bool IsTopmostDebuggerU2MCatchHandlerFrame(Frame *pFrame) { - return (pFrame->GetType() == FrameType::DebuggerU2MCatchHandlerFrame) && (pFrame->PtrNextFrame() == FRAME_TOP); + return (pFrame->GetType() == FrameIdentifier::DebuggerU2MCatchHandlerFrame) && (pFrame->PtrNextFrame() == FRAME_TOP); } static void NotifyExceptionPassStarted(StackFrameIterator *pThis, Thread *pThread, ExInfo *pExInfo) @@ -8291,12 +8291,12 @@ static void NotifyExceptionPassStarted(StackFrameIterator *pThis, Thread *pThrea { Frame* pFrame = pThis->m_crawl.GetFrame(); // If the frame is ProtectValueClassFrame, move to the next one as we want to report the FuncEvalFrame - if (pFrame->GetType() == FrameType::ProtectValueClassFrame) + if (pFrame->GetType() == FrameIdentifier::ProtectValueClassFrame) { pFrame = pFrame->PtrNextFrame(); _ASSERTE(pFrame != FRAME_TOP); } - if ((pFrame->GetType() == FrameType::FuncEvalFrame) || IsTopmostDebuggerU2MCatchHandlerFrame(pFrame)) + if ((pFrame->GetType() == FrameIdentifier::FuncEvalFrame) || IsTopmostDebuggerU2MCatchHandlerFrame(pFrame)) { EEToDebuggerExceptionInterfaceWrapper::NotifyOfCHFFilter((EXCEPTION_POINTERS *)&pExInfo->m_ptrs, pFrame); } @@ -8401,7 +8401,7 @@ extern "C" bool QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStackwalk // a slightly different location in the managed code calling the pinvoke and the inlined // call frame doesn't update the context pointers anyways. Frame *pSkippedFrame = pThis->m_crawl.GetFrame(); - if (pSkippedFrame->NeedsUpdateRegDisplay() && (pSkippedFrame->GetType() != FrameType::InlinedCallFrame)) + if (pSkippedFrame->NeedsUpdateRegDisplay() && (pSkippedFrame->GetType() != FrameIdentifier::InlinedCallFrame)) { pSkippedFrame->UpdateRegDisplay(pThis->m_crawl.GetRegisterSet()); } diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index 95b4915e7def06..cce0c97770c4a7 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -39,7 +39,7 @@ void Frame::GcScanRoots(promote_func *fn, ScanContext* sc) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { ((frameType*)this)->GcScanRoots_Impl(fn, sc); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { ((frameType*)this)->GcScanRoots_Impl(fn, sc); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; @@ -48,7 +48,7 @@ void Frame::GcScanRoots(promote_func *fn, ScanContext* sc) unsigned Frame::GetFrameAttribs() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetFrameAttribs_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFrameAttribs_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -57,7 +57,7 @@ unsigned Frame::GetFrameAttribs() #ifndef DACCESS_COMPILE void Frame::ExceptionUnwind() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { ((frameType*)this)->ExceptionUnwind_Impl(); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { ((frameType*)this)->ExceptionUnwind_Impl(); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; @@ -66,7 +66,7 @@ void Frame::ExceptionUnwind() #endif BOOL Frame::NeedsUpdateRegDisplay() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->NeedsUpdateRegDisplay_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->NeedsUpdateRegDisplay_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -74,7 +74,7 @@ BOOL Frame::NeedsUpdateRegDisplay() BOOL Frame::IsTransitionToNativeFrame() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->IsTransitionToNativeFrame_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->IsTransitionToNativeFrame_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -82,7 +82,7 @@ BOOL Frame::IsTransitionToNativeFrame() MethodDesc *Frame::GetFunction() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetFunction_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFunction_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -90,14 +90,14 @@ MethodDesc *Frame::GetFunction() Assembly *Frame::GetAssembly() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetAssembly_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetAssembly_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } PTR_BYTE Frame::GetIP() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetIP_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetIP_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -105,14 +105,14 @@ PTR_BYTE Frame::GetIP() TADDR Frame::GetReturnAddressPtr() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetReturnAddressPtr_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetReturnAddressPtr_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } PCODE Frame::GetReturnAddress() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetReturnAddress_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetReturnAddress_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -120,7 +120,7 @@ PCODE Frame::GetReturnAddress() void Frame::UpdateRegDisplay(const PREGDISPLAY pRegDisplay, bool updateFloats) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { ((frameType*)this)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { ((frameType*)this)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; @@ -128,7 +128,7 @@ void Frame::UpdateRegDisplay(const PREGDISPLAY pRegDisplay, bool updateFloats) int Frame::GetFrameType() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetFrameType_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFrameType_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -136,7 +136,7 @@ int Frame::GetFrameType() Frame::ETransitionType Frame::GetTransitionType() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetTransitionType_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetTransitionType_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return (ETransitionType)0; @@ -144,7 +144,7 @@ Frame::ETransitionType Frame::GetTransitionType() Frame::Interception Frame::GetInterception() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetInterception_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetInterception_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return (Interception)0; @@ -152,7 +152,7 @@ Frame::Interception Frame::GetInterception() void Frame::GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { ((frameType*)this)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { ((frameType*)this)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; @@ -160,7 +160,7 @@ void Frame::GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP) BOOL Frame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->TraceFrame_Impl(thread, fromPatch, trace, regs); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->TraceFrame_Impl(thread, fromPatch, trace, regs); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return FALSE; @@ -169,7 +169,7 @@ BOOL Frame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, #ifdef DACCESS_COMPILE void Frame::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { ((frameType*)this)->EnumMemoryRegions_Impl(flags); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { ((frameType*)this)->EnumMemoryRegions_Impl(flags); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; @@ -179,7 +179,7 @@ void Frame::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) #if defined(_DEBUG) && !defined(DACCESS_COMPILE) BOOL Frame::Protects(OBJECTREF *ppObjectRef) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->Protects_Impl(ppObjectRef); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->Protects_Impl(ppObjectRef); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return FALSE; @@ -190,7 +190,7 @@ BOOL Frame::Protects(OBJECTREF *ppObjectRef) // TransitionFrame only apis TADDR TransitionFrame::GetTransitionBlock() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->GetTransitionBlock_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetTransitionBlock_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return (TADDR)0; @@ -198,7 +198,7 @@ TADDR TransitionFrame::GetTransitionBlock() BOOL TransitionFrame::SuppressParamTypeArg() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameType::frameType) { return ((frameType*)this)->SuppressParamTypeArg_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->SuppressParamTypeArg_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return FALSE; @@ -232,17 +232,17 @@ void Frame::Log() { char buff[64]; const char* frameType; - if (GetType() == FrameType::PrestubMethodFrame) + if (GetType() == FrameIdentifier::PrestubMethodFrame) frameType = "PreStub"; - else if (GetType() == FrameType::PInvokeCalliFrame) + else if (GetType() == FrameIdentifier::PInvokeCalliFrame) { sprintf_s(buff, ARRAY_SIZE(buff), "PInvoke CALLI target" FMT_ADDR, DBG_ADDR(((PInvokeCalliFrame*)this)->GetPInvokeCalliTarget())); frameType = buff; } - else if (GetType() == FrameType::StubDispatchFrame) + else if (GetType() == FrameIdentifier::StubDispatchFrame) frameType = "StubDispatch"; - else if (GetType() == FrameType::ExternalMethodFrame) + else if (GetType() == FrameIdentifier::ExternalMethodFrame) frameType = "ExternalMethod"; else frameType = "Unknown"; @@ -367,7 +367,7 @@ const size_t FRAME_TYPES_COUNT = //----------------------------------------------------------------------- // Implementation of the global table of names. On the DAC side, just the global pointer. // On the runtime side, the array of names. - #define FRAME_TYPE_NAME(x) {(TADDR)FrameType::x, #x} , + #define FRAME_TYPE_NAME(x) {(TADDR)FrameIdentifier::x, #x} , static FrameTypeName FrameTypeNameTable[] = { #include "frames.h" }; @@ -459,11 +459,11 @@ bool Frame::HasValidVTablePtr(Frame * pFrame) return false; #ifndef DACCESS_COMPILE - FrameType vptr = pFrame->GetType(); + FrameIdentifier vptr = pFrame->GetType(); // - // Use a simple compare which is dependent on the tightly packed arrangement of FrameType + // Use a simple compare which is dependent on the tightly packed arrangement of FrameIdentifier // - return (((TADDR)vptr > (TADDR)FrameType::None) && ((TADDR)vptr < (TADDR)FrameType::CountPlusOne)); + return (((TADDR)vptr > (TADDR)FrameIdentifier::None) && ((TADDR)vptr < (TADDR)FrameIdentifier::CountPlusOne)); #else return true; #endif @@ -680,7 +680,7 @@ VASigCookie * TransitionFrame::GetVASigCookie() #ifndef DACCESS_COMPILE PrestubMethodFrame::PrestubMethodFrame(TransitionBlock * pTransitionBlock, MethodDesc * pMD) - : FramedMethodFrame(FrameType::PrestubMethodFrame, pTransitionBlock, pMD) + : FramedMethodFrame(FrameIdentifier::PrestubMethodFrame, pTransitionBlock, pMD) { LIMITED_METHOD_CONTRACT; } @@ -723,7 +723,7 @@ BOOL PrestubMethodFrame::TraceFrame_Impl(Thread *thread, BOOL fromPatch, // A rather specialized routine for the exclusive use of StubDispatch. //----------------------------------------------------------------------- StubDispatchFrame::StubDispatchFrame(TransitionBlock * pTransitionBlock) - : FramedMethodFrame(FrameType::StubDispatchFrame, pTransitionBlock, NULL) + : FramedMethodFrame(FrameIdentifier::StubDispatchFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -879,7 +879,7 @@ Frame::Interception StubDispatchFrame::GetInterception_Impl() #ifndef DACCESS_COMPILE CallCountingHelperFrame::CallCountingHelperFrame(TransitionBlock *pTransitionBlock, MethodDesc *pMD) - : FramedMethodFrame(FrameType::CallCountingHelperFrame, pTransitionBlock, pMD) + : FramedMethodFrame(FrameIdentifier::CallCountingHelperFrame, pTransitionBlock, pMD) { WRAPPER_NO_CONTRACT; } @@ -905,7 +905,7 @@ BOOL CallCountingHelperFrame::TraceFrame_Impl(Thread *thread, BOOL fromPatch, Tr #ifndef DACCESS_COMPILE ExternalMethodFrame::ExternalMethodFrame(TransitionBlock * pTransitionBlock) - : FramedMethodFrame(FrameType::ExternalMethodFrame, pTransitionBlock, NULL) + : FramedMethodFrame(FrameIdentifier::ExternalMethodFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -973,7 +973,7 @@ Frame::Interception PrestubMethodFrame::GetInterception_Impl() #ifndef DACCESS_COMPILE DynamicHelperFrame::DynamicHelperFrame(TransitionBlock * pTransitionBlock, int dynamicHelperFrameFlags) - : FramedMethodFrame(FrameType::DynamicHelperFrame, pTransitionBlock, NULL) + : FramedMethodFrame(FrameIdentifier::DynamicHelperFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -1034,7 +1034,7 @@ ComPrestubMethodFrame::Init() // Initializes the frame's VPTR. This assumes C++ puts the vptr // at offset 0 for a class not using MI, but this is no different // than the assumption that COM Classic makes. - *((TADDR*)this) = (TADDR)FrameType::ComPrestubMethodFrame; + *((TADDR*)this) = (TADDR)FrameIdentifier::ComPrestubMethodFrame; *GetGSCookiePtr() = GetProcessGSCookie(); } #endif // FEATURE_COMINTEROP @@ -1650,7 +1650,7 @@ void PInvokeCalliFrame::PromoteCallerStack(promote_func* fn, ScanContext* sc) #ifndef DACCESS_COMPILE PInvokeCalliFrame::PInvokeCalliFrame(TransitionBlock * pTransitionBlock, VASigCookie * pVASigCookie, PCODE pUnmanagedTarget) - : FramedMethodFrame(FrameType::PInvokeCalliFrame, pTransitionBlock, NULL) + : FramedMethodFrame(FrameIdentifier::PInvokeCalliFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -1663,7 +1663,7 @@ PInvokeCalliFrame::PInvokeCalliFrame(TransitionBlock * pTransitionBlock, VASigCo #ifndef DACCESS_COMPILE CLRToCOMMethodFrame::CLRToCOMMethodFrame(TransitionBlock * pTransitionBlock, MethodDesc * pMD) - : FramedMethodFrame(FrameType::CLRToCOMMethodFrame, pTransitionBlock, pMD) + : FramedMethodFrame(FrameIdentifier::CLRToCOMMethodFrame, pTransitionBlock, pMD) { LIMITED_METHOD_CONTRACT; } @@ -1773,7 +1773,7 @@ void ComMethodFrame::DoSecondPassHandlerCleanup(Frame * pCurFrame) // Find ComMethodFrame while ((pCurFrame != FRAME_TOP) && - (pCurFrame->GetType() != FrameType::ComMethodFrame)) + (pCurFrame->GetType() != FrameIdentifier::ComMethodFrame)) { pCurFrame = pCurFrame->PtrNextFrame(); } @@ -2023,7 +2023,7 @@ VOID InlinedCallFrame::Init() { WRAPPER_NO_CONTRACT; - *((TADDR *)this) = (TADDR)FrameType::InlinedCallFrame; + *((TADDR *)this) = (TADDR)FrameIdentifier::InlinedCallFrame; // GetGSCookiePtr contains a virtual call and this is a perf critical method so we don't want to call it in ret builds GSCookie *ptrGS = (GSCookie *)((BYTE *)this - sizeof(GSCookie)); diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 486db0a85173fd..facfc7124e5811 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -231,7 +231,7 @@ class FrameTypeName }; typedef DPTR(FrameTypeName) PTR_FrameTypeName; -enum class FrameType : TADDR +enum class FrameIdentifier : TADDR { None = 0, #define FRAME_TYPE_NAME(frameType) frameType, @@ -254,17 +254,17 @@ BOOL Frame_SuppressParamTypeArg(TransitionFrame* frame); class FrameBase { - const FrameType _frameType; + const FrameIdentifier _frameIdentifier; public: - FrameBase(FrameType frameType) : _frameType(frameType) {LIMITED_METHOD_CONTRACT; } + FrameBase(FrameIdentifier frameIdentifier) : _frameIdentifier(frameIdentifier) {LIMITED_METHOD_CONTRACT; } void GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { LIMITED_METHOD_CONTRACT; // Nothing to protect } - FrameType GetType() { LIMITED_METHOD_DAC_CONTRACT; return _frameType; } + FrameIdentifier GetType() { LIMITED_METHOD_DAC_CONTRACT; return _frameIdentifier; } }; //------------------------------------------------------------------------ @@ -659,8 +659,8 @@ class Frame : public FrameBase #ifndef DACCESS_COMPILE // Frame is considered an abstract class: this protected constructor // causes any attempt to instantiate one to fail at compile-time. - Frame(FrameType frameType) - : FrameBase(frameType), m_Next(dac_cast(nullptr)) + Frame(FrameIdentifier frameIdentifier) + : FrameBase(frameIdentifier), m_Next(dac_cast(nullptr)) { LIMITED_METHOD_CONTRACT; } @@ -700,12 +700,12 @@ class ResumableFrame : public Frame { public: #ifndef DACCESS_COMPILE - ResumableFrame(T_CONTEXT* regs) : Frame(FrameType::ResumableFrame) { + ResumableFrame(T_CONTEXT* regs) : Frame(FrameIdentifier::ResumableFrame) { LIMITED_METHOD_CONTRACT; m_Regs = regs; } - ResumableFrame(FrameType frameType, T_CONTEXT* regs) : Frame(frameType) { + ResumableFrame(FrameIdentifier frameIdentifier, T_CONTEXT* regs) : Frame(frameIdentifier) { LIMITED_METHOD_CONTRACT; m_Regs = regs; } @@ -794,7 +794,7 @@ class RedirectedThreadFrame : public ResumableFrame { public: #ifndef DACCESS_COMPILE - RedirectedThreadFrame(T_CONTEXT *regs) : ResumableFrame(FrameType::RedirectedThreadFrame, regs) { + RedirectedThreadFrame(T_CONTEXT *regs) : ResumableFrame(FrameIdentifier::RedirectedThreadFrame, regs) { LIMITED_METHOD_CONTRACT; } @@ -809,7 +809,7 @@ inline BOOL ISREDIRECTEDTHREAD(Thread * thread) WRAPPER_NO_CONTRACT; return (thread->GetFrame() != FRAME_TOP && thread->GetFrame()->GetType() == - FrameType::RedirectedThreadFrame); + FrameIdentifier::RedirectedThreadFrame); } inline T_CONTEXT * GETREDIRECTEDCONTEXT(Thread * thread) @@ -841,7 +841,7 @@ class TransitionFrame : public Frame { #ifndef DACCESS_COMPILE protected: - TransitionFrame(FrameType frameType) : Frame(frameType) { + TransitionFrame(FrameIdentifier frameIdentifier) : Frame(frameIdentifier) { LIMITED_METHOD_CONTRACT; } #endif @@ -980,7 +980,7 @@ class FaultingExceptionFrame : public Frame public: #ifndef DACCESS_COMPILE - FaultingExceptionFrame() : Frame(FrameType::FaultingExceptionFrame) { + FaultingExceptionFrame() : Frame(FrameIdentifier::FaultingExceptionFrame) { LIMITED_METHOD_CONTRACT; } #endif @@ -1061,7 +1061,7 @@ class SoftwareExceptionFrame : public Frame public: #ifndef DACCESS_COMPILE - SoftwareExceptionFrame() : Frame(FrameType::SoftwareExceptionFrame) { + SoftwareExceptionFrame() : Frame(FrameIdentifier::SoftwareExceptionFrame) { LIMITED_METHOD_CONTRACT; } #endif @@ -1135,7 +1135,7 @@ class FuncEvalFrame : public Frame public: #ifndef DACCESS_COMPILE - FuncEvalFrame(DebuggerEval *pDebuggerEval, TADDR returnAddress, BOOL showFrame) : Frame(FrameType::FuncEvalFrame) + FuncEvalFrame(DebuggerEval *pDebuggerEval, TADDR returnAddress, BOOL showFrame) : Frame(FrameIdentifier::FuncEvalFrame) { LIMITED_METHOD_CONTRACT; m_pDebuggerEval = pDebuggerEval; @@ -1202,7 +1202,7 @@ class HelperMethodFrame : public Frame // If this is an FCall, the first param is the entry point for the FCALL. // The MethodDesc will be looked up form this (lazily), and this method // will be used in stack reporting, if this is not an FCall pass a 0 - FORCEINLINE HelperMethodFrame(void* fCallFtnEntry, unsigned attribs = 0, FrameType frameType = FrameType::HelperMethodFrame) : Frame(frameType) + FORCEINLINE HelperMethodFrame(void* fCallFtnEntry, unsigned attribs = 0, FrameIdentifier frameIdentifier = FrameIdentifier::HelperMethodFrame) : Frame(frameIdentifier) { WRAPPER_NO_CONTRACT; // Most of the initialization is actually done in HelperMethodFrame::Push() @@ -1371,7 +1371,7 @@ class HelperMethodFrame_1OBJ : public HelperMethodFrame public: #if !defined(DACCESS_COMPILE) HelperMethodFrame_1OBJ(void* fCallFtnEntry, unsigned attribs, OBJECTREF* aGCPtr1) - : HelperMethodFrame(fCallFtnEntry, attribs, FrameType::HelperMethodFrame_1OBJ) + : HelperMethodFrame(fCallFtnEntry, attribs, FrameIdentifier::HelperMethodFrame_1OBJ) { LIMITED_METHOD_CONTRACT; gcPtrs[0] = aGCPtr1; @@ -1430,7 +1430,7 @@ class HelperMethodFrame_2OBJ : public HelperMethodFrame unsigned attribs, OBJECTREF* aGCPtr1, OBJECTREF* aGCPtr2) - : HelperMethodFrame(fCallFtnEntry, attribs, FrameType::HelperMethodFrame_2OBJ) + : HelperMethodFrame(fCallFtnEntry, attribs, FrameIdentifier::HelperMethodFrame_2OBJ) { LIMITED_METHOD_CONTRACT; gcPtrs[0] = aGCPtr1; @@ -1486,7 +1486,7 @@ class HelperMethodFrame_3OBJ : public HelperMethodFrame OBJECTREF* aGCPtr1, OBJECTREF* aGCPtr2, OBJECTREF* aGCPtr3) - : HelperMethodFrame(fCallFtnEntry, attribs, FrameType::HelperMethodFrame_3OBJ) + : HelperMethodFrame(fCallFtnEntry, attribs, FrameIdentifier::HelperMethodFrame_3OBJ) { LIMITED_METHOD_CONTRACT; gcPtrs[0] = aGCPtr1; @@ -1543,7 +1543,7 @@ class HelperMethodFrame_PROTECTOBJ : public HelperMethodFrame public: #if !defined(DACCESS_COMPILE) HelperMethodFrame_PROTECTOBJ(void* fCallFtnEntry, unsigned attribs, OBJECTREF* pObjRefs, int numObjRefs) - : HelperMethodFrame(fCallFtnEntry, attribs, FrameType::HelperMethodFrame_PROTECTOBJ) + : HelperMethodFrame(fCallFtnEntry, attribs, FrameIdentifier::HelperMethodFrame_PROTECTOBJ) { LIMITED_METHOD_CONTRACT; m_pObjRefs = pObjRefs; @@ -1603,8 +1603,8 @@ class FramedMethodFrame : public TransitionFrame public: #ifndef DACCESS_COMPILE - FramedMethodFrame(FrameType frameType, TransitionBlock * pTransitionBlock, MethodDesc * pMD) - : TransitionFrame(frameType), m_pTransitionBlock(dac_cast(pTransitionBlock)), m_pMD(pMD) + FramedMethodFrame(FrameIdentifier frameIdentifier, TransitionBlock * pTransitionBlock, MethodDesc * pMD) + : TransitionFrame(frameIdentifier), m_pTransitionBlock(dac_cast(pTransitionBlock)), m_pMD(pMD) { LIMITED_METHOD_CONTRACT; } @@ -1703,7 +1703,7 @@ class UnmanagedToManagedFrame : public Frame protected: #ifndef DACCESS_COMPILE - UnmanagedToManagedFrame(FrameType frameType) : Frame(frameType) + UnmanagedToManagedFrame(FrameIdentifier frameIdentifier) : Frame(frameIdentifier) { LIMITED_METHOD_CONTRACT; } @@ -1805,7 +1805,7 @@ class ComMethodFrame : public UnmanagedToManagedFrame { public: #ifndef DACCESS_COMPILE - ComMethodFrame(FrameType frameType = FrameType::ComMethodFrame) : UnmanagedToManagedFrame(FrameType::ComMethodFrame) + ComMethodFrame(FrameIdentifier frameIdentifier = FrameIdentifier::ComMethodFrame) : UnmanagedToManagedFrame(FrameIdentifier::ComMethodFrame) { LIMITED_METHOD_CONTRACT; } @@ -2339,7 +2339,7 @@ class ProtectByRefsFrame : public Frame public: #ifndef DACCESS_COMPILE ProtectByRefsFrame(Thread *pThread, ByRefInfo *brInfo) - : Frame(FrameType::ProtectByRefsFrame), m_brInfo(brInfo) + : Frame(FrameIdentifier::ProtectByRefsFrame), m_brInfo(brInfo) { WRAPPER_NO_CONTRACT; Frame::Push(pThread); @@ -2380,14 +2380,14 @@ class ProtectValueClassFrame : public Frame public: #ifndef DACCESS_COMPILE ProtectValueClassFrame() - : Frame(FrameType::ProtectValueClassFrame), m_pVCInfo(NULL) + : Frame(FrameIdentifier::ProtectValueClassFrame), m_pVCInfo(NULL) { WRAPPER_NO_CONTRACT; Frame::Push(); } ProtectValueClassFrame(Thread *pThread, ValueClassInfo *vcInfo) - : Frame(FrameType::ProtectValueClassFrame), m_pVCInfo(vcInfo) + : Frame(FrameIdentifier::ProtectValueClassFrame), m_pVCInfo(vcInfo) { WRAPPER_NO_CONTRACT; Frame::Push(pThread); @@ -2425,7 +2425,7 @@ class DebuggerClassInitMarkFrame : public Frame public: #ifndef DACCESS_COMPILE - DebuggerClassInitMarkFrame() : Frame(FrameType::DebuggerClassInitMarkFrame) + DebuggerClassInitMarkFrame() : Frame(FrameIdentifier::DebuggerClassInitMarkFrame) { WRAPPER_NO_CONTRACT; Push(); @@ -2455,7 +2455,7 @@ class DebuggerExitFrame : public Frame { public: #ifndef DACCESS_COMPILE - DebuggerExitFrame() : Frame(FrameType::DebuggerExitFrame) + DebuggerExitFrame() : Frame(FrameIdentifier::DebuggerExitFrame) { WRAPPER_NO_CONTRACT; Push(); @@ -2507,13 +2507,13 @@ class DebuggerU2MCatchHandlerFrame : public Frame { public: #ifndef DACCESS_COMPILE - DebuggerU2MCatchHandlerFrame() : Frame(FrameType::DebuggerU2MCatchHandlerFrame) + DebuggerU2MCatchHandlerFrame() : Frame(FrameIdentifier::DebuggerU2MCatchHandlerFrame) { WRAPPER_NO_CONTRACT; Frame::Push(); } - DebuggerU2MCatchHandlerFrame(Thread * pThread) : Frame(FrameType::DebuggerU2MCatchHandlerFrame) + DebuggerU2MCatchHandlerFrame(Thread * pThread) : Frame(FrameIdentifier::DebuggerU2MCatchHandlerFrame) { WRAPPER_NO_CONTRACT; Frame::Push(pThread); @@ -2656,7 +2656,7 @@ class InlinedCallFrame : public Frame SUPPORTS_DAC; return pFrame && pFrame != FRAME_TOP && - FrameType::InlinedCallFrame == pFrame->GetType() && + FrameIdentifier::InlinedCallFrame == pFrame->GetType() && dac_cast(dac_cast(pFrame)->m_pCallerReturnAddress) != 0; } @@ -2731,7 +2731,7 @@ class TailCallFrame : public Frame { LIMITED_METHOD_CONTRACT; // loop through the frame chain - while (pFrame->GetType() != FrameType::TailCallFrame) + while (pFrame->GetType() != FrameIdentifier::TailCallFrame) pFrame = pFrame->m_Next; return (TailCallFrame*)pFrame; } @@ -2769,7 +2769,7 @@ class ExceptionFilterFrame : public Frame public: #ifndef DACCESS_COMPILE - ExceptionFilterFrame(size_t* pShadowSP) : Frame(FrameType::ExceptionFilterFrame) + ExceptionFilterFrame(size_t* pShadowSP) : Frame(FrameIdentifier::ExceptionFilterFrame) { WRAPPER_NO_CONTRACT; m_pShadowSP = pShadowSP; @@ -2808,7 +2808,7 @@ class AssumeByrefFromJITStack : public Frame { public: #ifndef DACCESS_COMPILE - AssumeByrefFromJITStack(OBJECTREF *pObjRef) : Frame(FrameType::AssumeByrefFromJITStack) + AssumeByrefFromJITStack(OBJECTREF *pObjRef) : Frame(FrameIdentifier::AssumeByrefFromJITStack) { m_pObjRef = pObjRef; } diff --git a/src/coreclr/vm/gcenv.ee.common.cpp b/src/coreclr/vm/gcenv.ee.common.cpp index f0a84ac2d4239b..a25c0aaf460af6 100644 --- a/src/coreclr/vm/gcenv.ee.common.cpp +++ b/src/coreclr/vm/gcenv.ee.common.cpp @@ -104,7 +104,7 @@ inline bool SafeToReportGenericParamContext(CrawlFrame* pCF) { LIMITED_METHOD_CONTRACT; - if (!pCF->IsFrameless() && pCF->GetFrame()->GetType() == FrameType::StubDispatchFrame) + if (!pCF->IsFrameless() && pCF->GetFrame()->GetType() == FrameIdentifier::StubDispatchFrame) { return !((StubDispatchFrame*)pCF->GetFrame())->SuppressParamTypeArg(); } diff --git a/src/coreclr/vm/i386/PInvokeStubs.asm b/src/coreclr/vm/i386/PInvokeStubs.asm index b2e79e19b8ed26..7b3536b9a54822 100644 --- a/src/coreclr/vm/i386/PInvokeStubs.asm +++ b/src/coreclr/vm/i386/PInvokeStubs.asm @@ -21,7 +21,6 @@ .code extern _s_gsCookie:DWORD -extern ??_7InlinedCallFrame@@6B@:DWORD extern _g_TrapReturningThreads:DWORD extern @JIT_PInvokeEndRarePath@0:proc diff --git a/src/coreclr/vm/i386/asmconstants.h b/src/coreclr/vm/i386/asmconstants.h index f8edeef2248a06..ed8753702489a3 100644 --- a/src/coreclr/vm/i386/asmconstants.h +++ b/src/coreclr/vm/i386/asmconstants.h @@ -33,7 +33,7 @@ #endif #define FRAMETYPE_InlinedCallFrame 0x1 -ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameIdentifier::InlinedCallFrame) #define INITIAL_SUCCESS_COUNT 0x100 diff --git a/src/coreclr/vm/i386/cgenx86.cpp b/src/coreclr/vm/i386/cgenx86.cpp index 3a330f23578f49..fded538130b98a 100644 --- a/src/coreclr/vm/i386/cgenx86.cpp +++ b/src/coreclr/vm/i386/cgenx86.cpp @@ -443,7 +443,7 @@ void StubDispatchFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool update RETURN; } -PCODE StubDispatchFrame::GetReturnAddress() +PCODE StubDispatchFrame::GetReturnAddress_Impl() { CONTRACTL { @@ -604,7 +604,7 @@ void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateF //========================== // Resumable Exception Frame // -TADDR ResumableFrame::GetReturnAddressPtr() +TADDR ResumableFrame::GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; return dac_cast(m_Regs) + offsetof(CONTEXT, Eip); @@ -889,7 +889,7 @@ Stub *GenerateInitPInvokeFrameHelper() // mov [edi + FrameInfo.offsetOfFrameVptr], InlinedCallFrame::GetFrameVtable() psl->X86EmitOffsetModRM(0xc7, (X86Reg)0x0, kEDI, FrameInfo.offsetOfFrameVptr - negSpace); - psl->Emit32((DWORD)FrameType::InlinedCallFrame); + psl->Emit32((DWORD)FrameIdentifier::InlinedCallFrame); // mov eax, [esi + offsetof(Thread, m_pFrame)] // mov [edi + FrameInfo.offsetOfFrameLink], eax diff --git a/src/coreclr/vm/i386/excepx86.cpp b/src/coreclr/vm/i386/excepx86.cpp index 276b36a0d6f7a8..b8f5d1e42f0ba0 100644 --- a/src/coreclr/vm/i386/excepx86.cpp +++ b/src/coreclr/vm/i386/excepx86.cpp @@ -690,7 +690,7 @@ CPFH_RealFirstPassHandler( // ExceptionContinueSearch, etc. if (fIsManagedCode && fPGCDisabledOnEntry && (pThread->m_pFrame == FRAME_TOP || - pThread->m_pFrame->GetVTablePtr() != FaultingExceptionFrame::GetMethodFrameVPtr() || + pThread->m_pFrame->GetType() != FrameIdentifier::FaultingExceptionFrame || (size_t)pThread->m_pFrame > (size_t)pEstablisherFrame)) { // setup interrupted frame so that GC during calls to init won't collect the frames @@ -2167,7 +2167,7 @@ StackWalkAction COMPlusThrowCallback( // SWA value if (pData->pPrevExceptionRecord) { // FCALLS have an extra SEH record in debug because of the desctructor // associated with ForbidGC checking. This is benign, so just ignore it. - if (pFrame) _ASSERTE(pData->pPrevExceptionRecord < pFrame || pFrame->GetType() == FrameType::HelperMethodFrame); + if (pFrame) _ASSERTE(pData->pPrevExceptionRecord < pFrame || pFrame->GetType() == FrameIdentifier::HelperMethodFrame); if (pCf->IsFrameless()) _ASSERTE((ULONG_PTR)pData->pPrevExceptionRecord <= GetRegdisplaySP(pCf->GetRegisterSet())); } } @@ -2668,7 +2668,7 @@ StackWalkAction COMPlusUnwindCallback (CrawlFrame *pCf, ThrowCallbackType *pData // Make the filter as done. See comment in CallJitEHFilter // on why we have to do it here. Frame* pFilterFrame = pThread->GetFrame(); - _ASSERTE(pFilterFrame->GetVTablePtr() == ExceptionFilterFrame::GetMethodFrameVPtr()); + _ASSERTE(pFilterFrame->GetType() == FrameIdentifier::ExceptionFilterFrame); ((ExceptionFilterFrame*)pFilterFrame)->SetFilterDone(); // Inform the profiler that we're leaving, and what pass we're on diff --git a/src/coreclr/vm/i386/jitinterfacex86.cpp b/src/coreclr/vm/i386/jitinterfacex86.cpp index 334241e7cb1348..436f3810563f6f 100644 --- a/src/coreclr/vm/i386/jitinterfacex86.cpp +++ b/src/coreclr/vm/i386/jitinterfacex86.cpp @@ -911,7 +911,7 @@ void InitJITHelpers1() #ifndef UNIX_X86_ABI // Initialize g_TailCallFrameVptr for JIT_TailCall helper - g_TailCallFrameVptr = (void*)FrameType::TailCallFrame; + g_TailCallFrameVptr = (void*)FrameIdentifier::TailCallFrame; #endif // !UNIX_X86_ABI } #pragma warning (default : 4731) diff --git a/src/coreclr/vm/loongarch64/asmconstants.h b/src/coreclr/vm/loongarch64/asmconstants.h index 3067ee041eeb7e..edd5b7098a638e 100644 --- a/src/coreclr/vm/loongarch64/asmconstants.h +++ b/src/coreclr/vm/loongarch64/asmconstants.h @@ -31,7 +31,7 @@ #endif #define FRAMETYPE_InlinedCallFrame 0x1 -ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameIdentifier::InlinedCallFrame) #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 diff --git a/src/coreclr/vm/riscv64/asmconstants.h b/src/coreclr/vm/riscv64/asmconstants.h index 695ba3c0feabec..125907e69d4b16 100644 --- a/src/coreclr/vm/riscv64/asmconstants.h +++ b/src/coreclr/vm/riscv64/asmconstants.h @@ -26,7 +26,7 @@ #endif #define FRAMETYPE_InlinedCallFrame 0x1 -ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameType::InlinedCallFrame) +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameIdentifier::InlinedCallFrame) #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 diff --git a/src/coreclr/vm/stackwalk.cpp b/src/coreclr/vm/stackwalk.cpp index ac394c14069b93..e508f026405ab7 100644 --- a/src/coreclr/vm/stackwalk.cpp +++ b/src/coreclr/vm/stackwalk.cpp @@ -1414,11 +1414,11 @@ BOOL StackFrameIterator::IsValid(void) _ASSERTE(GCStress::IsEnabled()); _ASSERTE(m_pRealStartFrame != NULL); _ASSERTE(m_pRealStartFrame != FRAME_TOP); - _ASSERTE(m_pRealStartFrame->GetType() == FrameType::InlinedCallFrame); + _ASSERTE(m_pRealStartFrame->GetType() == FrameIdentifier::InlinedCallFrame); _ASSERTE(m_pThread->GetFrame() != NULL); _ASSERTE(m_pThread->GetFrame() != FRAME_TOP); - bIsRealStartFrameUnchanged = (m_pThread->GetFrame()->GetType() == FrameType::ResumableFrame) - || (m_pThread->GetFrame()->GetType() == FrameType::RedirectedThreadFrame); + bIsRealStartFrameUnchanged = (m_pThread->GetFrame()->GetType() == FrameIdentifier::ResumableFrame) + || (m_pThread->GetFrame()->GetType() == FrameIdentifier::RedirectedThreadFrame); } #endif // FEATURE_HIJACK @@ -2365,7 +2365,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) // make sure we're not skipping a different transition if (m_crawl.pFrame->NeedsUpdateRegDisplay()) { - if (m_crawl.pFrame->GetType() == FrameType::InlinedCallFrame) + if (m_crawl.pFrame->GetType() == FrameIdentifier::InlinedCallFrame) { // ControlPC may be different as the InlinedCallFrame stays active throughout // the STOP_FOR_GC callout but we can use the stack/frame pointer for the assert. @@ -2502,7 +2502,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) // pushed on the stack after the frame is running _ASSERTE((m_crawl.pFrame == FRAME_TOP) || ((TADDR)GetRegdisplaySP(m_crawl.pRD) < dac_cast(m_crawl.pFrame)) || - (m_crawl.pFrame->GetType() == FrameType::FaultingExceptionFrame)); + (m_crawl.pFrame->GetType() == FrameIdentifier::FaultingExceptionFrame)); #endif // !defined(ELIMINATE_FEF) // Get rid of the frame (actually, it isn't really popped) @@ -2847,7 +2847,7 @@ void StackFrameIterator::ProcessCurrentFrame(void) // the next frame is one of them, we don't want to override it. THIS IS PROBABLY BAD!!! if ( (pContextSP < dac_cast(m_crawl.pFrame)) && ((m_crawl.GetFrame() == FRAME_TOP) || - (m_crawl.GetFrame()->GetVTablePtr() != FaultingExceptionFrame::GetMethodFrameVPtr() ) ) ) + (m_crawl.GetFrame()->GetType() != FrameIdentifier::FaultingExceptionFrame ) ) ) { // // If the REGDISPLAY represents an unmanaged stack frame above (closer to the leaf than) an @@ -3006,7 +3006,7 @@ BOOL StackFrameIterator::CheckForSkippedFrames(void) // Note that code:InlinedCallFrame.GetFunction may return NULL in this case because // the call is made using the CALLI instruction. m_crawl.pFrame != FRAME_TOP && - m_crawl.pFrame->GetType() == FrameType::InlinedCallFrame && + m_crawl.pFrame->GetType() == FrameIdentifier::InlinedCallFrame && m_crawl.pFunc != NULL && m_crawl.pFunc->IsILStub() && m_crawl.pFunc->AsDynamicMethodDesc()->HasMDContextArg(); diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 64099e15ecb1f8..390e1e543bb030 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -305,7 +305,7 @@ bool Thread::DetectHandleILStubsForDebugger() while (pFrame != FRAME_TOP) { // Check for HMF's. See the comment at the beginning of this function. - if (pFrame->GetType() == FrameType::HelperMethodFrame) + if (pFrame->GetType() == FrameIdentifier::HelperMethodFrame) { break; } diff --git a/src/coreclr/vm/threadsuspend.cpp b/src/coreclr/vm/threadsuspend.cpp index 9620d7279aa21b..d732f3cfd95737 100644 --- a/src/coreclr/vm/threadsuspend.cpp +++ b/src/coreclr/vm/threadsuspend.cpp @@ -3766,7 +3766,7 @@ ThrowControlForThread( } #if defined(FEATURE_EH_FUNCLETS) - *(TADDR*)pfef = (TADDR)FrameType::FaultingExceptionFrame; + *(TADDR*)pfef = (TADDR)FrameIdentifier::FaultingExceptionFrame; *pfef->GetGSCookiePtr() = GetProcessGSCookie(); #else // FEATURE_EH_FUNCLETS FrameWithCookie fef; @@ -4843,7 +4843,7 @@ StackWalkAction SWCB_GetExecutionState(CrawlFrame *pCF, VOID *pData) } HijackFrame::HijackFrame(LPVOID returnAddress, Thread *thread, HijackArgs *args) - : Frame(FrameType::HijackFrame), + : Frame(FrameIdentifier::HijackFrame), m_ReturnAddress((TADDR)returnAddress), m_Thread(thread), m_Args(args) From 589263cf8b68730ef6f047415f8a81e501a5fa61 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Tue, 4 Feb 2025 15:59:42 -0800 Subject: [PATCH 05/17] Rename the GetType api I added on Frame to GetFrameIdentifier which is easier to search for --- .../debug/daccess/dacdbiimplstackwalk.cpp | 6 +-- src/coreclr/debug/ee/frameinfo.cpp | 10 ++-- src/coreclr/vm/dllimport.cpp | 2 +- src/coreclr/vm/excep.cpp | 4 +- src/coreclr/vm/exceptionhandling.cpp | 18 +++---- src/coreclr/vm/frames.cpp | 52 +++++++++---------- src/coreclr/vm/frames.h | 8 +-- src/coreclr/vm/gcenv.ee.common.cpp | 2 +- src/coreclr/vm/i386/excepx86.cpp | 6 +-- src/coreclr/vm/stackwalk.cpp | 14 ++--- src/coreclr/vm/threads.cpp | 2 +- 11 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp index 7644e221763c41..c0fe7343e1617b 100644 --- a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp +++ b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp @@ -558,7 +558,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread // it. In this case, pMD will remain NULL. EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY { - if (pFrame->GetType() == FrameIdentifier::ComMethodFrame) + if (pFrame->GetFrameIdentifier() == FrameIdentifier::ComMethodFrame) { ComMethodFrame * pCOMFrame = dac_cast(pFrame); PTR_VOID pUnkStackSlot = pCOMFrame->GetPointerToArguments(); @@ -1142,7 +1142,7 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra } else if (ft == Frame::TYPE_EXIT) { - if ((pFrame->GetType() != FrameIdentifier::InlinedCallFrame) || + if ((pFrame->GetFrameIdentifier() != FrameIdentifier::InlinedCallFrame) || InlinedCallFrame::FrameHasActiveCall(pFrame)) { resultType = STUBFRAME_M2U; @@ -1153,7 +1153,7 @@ CorDebugInternalFrameType DacDbiInterfaceImpl::GetInternalFrameType(Frame * pFra case Frame::TT_M2U: // Refer to the comment in DebuggerWalkStackProc() for StubDispatchFrame. - if (pFrame->GetType() != FrameIdentifier::StubDispatchFrame) + if (pFrame->GetFrameIdentifier() != FrameIdentifier::StubDispatchFrame) { if (it == Frame::INTERCEPTION_SECURITY) { diff --git a/src/coreclr/debug/ee/frameinfo.cpp b/src/coreclr/debug/ee/frameinfo.cpp index c6137c8c7eefd3..a38420771eb2cc 100644 --- a/src/coreclr/debug/ee/frameinfo.cpp +++ b/src/coreclr/debug/ee/frameinfo.cpp @@ -454,7 +454,7 @@ bool HasExitRuntime(Frame *pFrame, DebuggerFrameData *pData, FramePointer *pPote #else // TARGET_X86 // DebuggerExitFrame always return a NULL returnSP on x86. - if (pFrame->GetType() == FrameIdentifier::DebuggerExitFrame) + if (pFrame->GetFrameIdentifier() == FrameIdentifier::DebuggerExitFrame) { if (pPotentialFP != NULL) { @@ -462,7 +462,7 @@ bool HasExitRuntime(Frame *pFrame, DebuggerFrameData *pData, FramePointer *pPote } return true; } - else if (pFrame->GetType() == FrameIdentifier::InlinedCallFrame) + else if (pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame) { InlinedCallFrame *pInlinedFrame = static_cast(pFrame); LPVOID sp = (LPVOID)pInlinedFrame->GetCallSiteSP(); @@ -814,7 +814,7 @@ void FrameInfo::InitForU2MInternalFrame(CrawlFrame * pCF) // For regular U2M PInvoke cases, we don't care about MD b/c it's just going to // be the next frame. // If we're a COM2CLR call, perhaps we can get the MD for the interface. - if (pFrame->GetType() == FrameIdentifier::ComMethodFrame) + if (pFrame->GetFrameIdentifier() == FrameIdentifier::ComMethodFrame) { ComMethodFrame* pCOMFrame = static_cast (pFrame); ComCallMethodDesc* pCMD = reinterpret_cast (pCOMFrame->ComMethodFrame::GetDatum()); @@ -1190,7 +1190,7 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) #ifdef FEATURE_COMINTEROP if ((frame != NULL) && - (frame->GetType() == FrameIdentifier::CLRToCOMMethodFrame)) + (frame->GetFrameIdentifier() == FrameIdentifier::CLRToCOMMethodFrame)) { // This condition is part of the fix for 650903. (See // code:ControllerStackInfo::WalkStack and code:DebuggerStepper::TrapStepOut @@ -1717,7 +1717,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) // The jitted code on X64 behaves differently. // // Note that there is a corresponding change in DacDbiInterfaceImpl::GetInternalFrameType(). - if (frame->GetType() == FrameIdentifier::StubDispatchFrame) + if (frame->GetFrameIdentifier() == FrameIdentifier::StubDispatchFrame) { use = false; } diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index eb385f425992ec..4aa300584c19f9 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -5859,7 +5859,7 @@ EXTERN_C LPVOID STDCALL NDirectImportWorker(NDirectMethodDesc* pMD) // INDEBUG(Thread *pThread = GetThread()); { - _ASSERTE((pThread->GetFrame() != FRAME_TOP && pThread->GetFrame()->GetType() == FrameIdentifier::InlinedCallFrame) + _ASSERTE((pThread->GetFrame() != FRAME_TOP && pThread->GetFrame()->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame) || pMD->ShouldSuppressGCTransition()); CONSISTENCY_CHECK(pMD->IsNDirect()); diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index c4d6a18a422c88..a1740a6b1db13b 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -11511,7 +11511,7 @@ MethodDesc * GetUserMethodForILStub(Thread * pThread, UINT_PTR uStubSP, MethodDe // should be present further up the stack. Normally, the ComMethodFrame in question is // simply the next stack frame; however, there are situations where there may be other // stack frames present (such as an inlined stack frame from a QCall in the IL stub). - while (pCurFrame->GetType() != FrameIdentifier::ComMethodFrame) + while (pCurFrame->GetFrameIdentifier() != FrameIdentifier::ComMethodFrame) { pCurFrame = pCurFrame->PtrNextFrame(); } @@ -11519,7 +11519,7 @@ MethodDesc * GetUserMethodForILStub(Thread * pThread, UINT_PTR uStubSP, MethodDe ComMethodFrame * pComFrame = (ComMethodFrame *)pCurFrame; _ASSERTE((UINT_PTR)pComFrame > uStubSP); - CONSISTENCY_CHECK_MSG(pComFrame->GetType() == FrameIdentifier::ComMethodFrame, + CONSISTENCY_CHECK_MSG(pComFrame->GetFrameIdentifier() == FrameIdentifier::ComMethodFrame, "Expected to find a ComMethodFrame."); ComCallMethodDesc * pCMD = pComFrame->GetComCallMethodDesc(); diff --git a/src/coreclr/vm/exceptionhandling.cpp b/src/coreclr/vm/exceptionhandling.cpp index 87655e9d8bb7ec..fdcc295d010ab0 100644 --- a/src/coreclr/vm/exceptionhandling.cpp +++ b/src/coreclr/vm/exceptionhandling.cpp @@ -343,7 +343,7 @@ StackWalkAction UpdateObjectRefInResumeContextCallback(CrawlFrame* pCF, LPVOID p pState->pHighestFrameWithRegisters = pFrame; // Is this an InlinedCallFrame? - if (pFrame->GetType() == FrameIdentifier::InlinedCallFrame) + if (pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame) { // If we are here, then ICF is expected to be active. _ASSERTE(InlinedCallFrame::FrameHasActiveCall(pFrame)); @@ -1462,7 +1462,7 @@ void ExceptionTracker::InitializeCrawlFrameForExplicitFrame(CrawlFrame* pcfThisF pcfThisFrame->pFrame = pFrame; pcfThisFrame->pFunc = pFrame->GetFunction(); - if (pFrame->GetType() == FrameIdentifier::InlinedCallFrame && + if (pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame && !InlinedCallFrame::FrameHasActiveCall(pFrame)) { // Inactive ICFs in IL stubs contain the true interop MethodDesc which must be @@ -1963,7 +1963,7 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification( // the ICF immediately before and after a PInvoke in non-IL-stubs, like ReadyToRun. // See the usages for USE_PER_FRAME_PINVOKE_INIT for more information. - if (fTargetUnwind && (pFrame->GetType() == FrameIdentifier::InlinedCallFrame)) + if (fTargetUnwind && (pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame)) { PTR_InlinedCallFrame pICF = (PTR_InlinedCallFrame)pFrame; // Does it live inside the current managed method? It will iff: @@ -7588,7 +7588,7 @@ void ExceptionTracker::ResetThreadAbortStatus(PTR_Thread pThread, CrawlFrame *pC // Mark the pinvoke frame as invoking CallCatchFunclet (and similar) for collided unwind detection void MarkInlinedCallFrameAsFuncletCall(Frame* pFrame) { - _ASSERTE(pFrame->GetType() == FrameIdentifier::InlinedCallFrame); + _ASSERTE(pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame); InlinedCallFrame* pInlinedCallFrame = (InlinedCallFrame*)pFrame; pInlinedCallFrame->m_Datum = (PTR_NDirectMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper | (TADDR)InlinedCallFrameMarker::SecondPassFuncletCaller); } @@ -7596,7 +7596,7 @@ void MarkInlinedCallFrameAsFuncletCall(Frame* pFrame) // Mark the pinvoke frame as invoking any exception handling helper void MarkInlinedCallFrameAsEHHelperCall(Frame* pFrame) { - _ASSERTE(pFrame->GetType() == FrameIdentifier::InlinedCallFrame); + _ASSERTE(pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame); InlinedCallFrame* pInlinedCallFrame = (InlinedCallFrame*)pFrame; pInlinedCallFrame->m_Datum = (PTR_NDirectMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper); } @@ -8217,7 +8217,7 @@ void FailFastIfCorruptingStateException(ExInfo *pExInfo) static bool IsTopmostDebuggerU2MCatchHandlerFrame(Frame *pFrame) { - return (pFrame->GetType() == FrameIdentifier::DebuggerU2MCatchHandlerFrame) && (pFrame->PtrNextFrame() == FRAME_TOP); + return (pFrame->GetFrameIdentifier() == FrameIdentifier::DebuggerU2MCatchHandlerFrame) && (pFrame->PtrNextFrame() == FRAME_TOP); } static void NotifyExceptionPassStarted(StackFrameIterator *pThis, Thread *pThread, ExInfo *pExInfo) @@ -8291,12 +8291,12 @@ static void NotifyExceptionPassStarted(StackFrameIterator *pThis, Thread *pThrea { Frame* pFrame = pThis->m_crawl.GetFrame(); // If the frame is ProtectValueClassFrame, move to the next one as we want to report the FuncEvalFrame - if (pFrame->GetType() == FrameIdentifier::ProtectValueClassFrame) + if (pFrame->GetFrameIdentifier() == FrameIdentifier::ProtectValueClassFrame) { pFrame = pFrame->PtrNextFrame(); _ASSERTE(pFrame != FRAME_TOP); } - if ((pFrame->GetType() == FrameIdentifier::FuncEvalFrame) || IsTopmostDebuggerU2MCatchHandlerFrame(pFrame)) + if ((pFrame->GetFrameIdentifier() == FrameIdentifier::FuncEvalFrame) || IsTopmostDebuggerU2MCatchHandlerFrame(pFrame)) { EEToDebuggerExceptionInterfaceWrapper::NotifyOfCHFFilter((EXCEPTION_POINTERS *)&pExInfo->m_ptrs, pFrame); } @@ -8401,7 +8401,7 @@ extern "C" bool QCALLTYPE SfiInit(StackFrameIterator* pThis, CONTEXT* pStackwalk // a slightly different location in the managed code calling the pinvoke and the inlined // call frame doesn't update the context pointers anyways. Frame *pSkippedFrame = pThis->m_crawl.GetFrame(); - if (pSkippedFrame->NeedsUpdateRegDisplay() && (pSkippedFrame->GetType() != FrameIdentifier::InlinedCallFrame)) + if (pSkippedFrame->NeedsUpdateRegDisplay() && (pSkippedFrame->GetFrameIdentifier() != FrameIdentifier::InlinedCallFrame)) { pSkippedFrame->UpdateRegDisplay(pThis->m_crawl.GetRegisterSet()); } diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index cce0c97770c4a7..21aa8ce7045f40 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -39,7 +39,7 @@ void Frame::GcScanRoots(promote_func *fn, ScanContext* sc) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { ((frameType*)this)->GcScanRoots_Impl(fn, sc); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { ((frameType*)this)->GcScanRoots_Impl(fn, sc); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; @@ -48,7 +48,7 @@ void Frame::GcScanRoots(promote_func *fn, ScanContext* sc) unsigned Frame::GetFrameAttribs() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFrameAttribs_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFrameAttribs_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -57,7 +57,7 @@ unsigned Frame::GetFrameAttribs() #ifndef DACCESS_COMPILE void Frame::ExceptionUnwind() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { ((frameType*)this)->ExceptionUnwind_Impl(); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { ((frameType*)this)->ExceptionUnwind_Impl(); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; @@ -66,7 +66,7 @@ void Frame::ExceptionUnwind() #endif BOOL Frame::NeedsUpdateRegDisplay() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->NeedsUpdateRegDisplay_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->NeedsUpdateRegDisplay_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -74,7 +74,7 @@ BOOL Frame::NeedsUpdateRegDisplay() BOOL Frame::IsTransitionToNativeFrame() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->IsTransitionToNativeFrame_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->IsTransitionToNativeFrame_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -82,7 +82,7 @@ BOOL Frame::IsTransitionToNativeFrame() MethodDesc *Frame::GetFunction() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFunction_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFunction_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -90,14 +90,14 @@ MethodDesc *Frame::GetFunction() Assembly *Frame::GetAssembly() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetAssembly_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetAssembly_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } PTR_BYTE Frame::GetIP() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetIP_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetIP_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -105,14 +105,14 @@ PTR_BYTE Frame::GetIP() TADDR Frame::GetReturnAddressPtr() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetReturnAddressPtr_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetReturnAddressPtr_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; } PCODE Frame::GetReturnAddress() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetReturnAddress_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetReturnAddress_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -120,7 +120,7 @@ PCODE Frame::GetReturnAddress() void Frame::UpdateRegDisplay(const PREGDISPLAY pRegDisplay, bool updateFloats) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { ((frameType*)this)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { ((frameType*)this)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; @@ -128,7 +128,7 @@ void Frame::UpdateRegDisplay(const PREGDISPLAY pRegDisplay, bool updateFloats) int Frame::GetFrameType() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFrameType_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFrameType_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return 0; @@ -136,7 +136,7 @@ int Frame::GetFrameType() Frame::ETransitionType Frame::GetTransitionType() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetTransitionType_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetTransitionType_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return (ETransitionType)0; @@ -144,7 +144,7 @@ Frame::ETransitionType Frame::GetTransitionType() Frame::Interception Frame::GetInterception() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetInterception_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetInterception_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return (Interception)0; @@ -152,7 +152,7 @@ Frame::Interception Frame::GetInterception() void Frame::GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { ((frameType*)this)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { ((frameType*)this)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; @@ -160,7 +160,7 @@ void Frame::GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP) BOOL Frame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->TraceFrame_Impl(thread, fromPatch, trace, regs); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->TraceFrame_Impl(thread, fromPatch, trace, regs); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return FALSE; @@ -169,7 +169,7 @@ BOOL Frame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, #ifdef DACCESS_COMPILE void Frame::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { ((frameType*)this)->EnumMemoryRegions_Impl(flags); return; } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { ((frameType*)this)->EnumMemoryRegions_Impl(flags); return; } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return; @@ -179,7 +179,7 @@ void Frame::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) #if defined(_DEBUG) && !defined(DACCESS_COMPILE) BOOL Frame::Protects(OBJECTREF *ppObjectRef) { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->Protects_Impl(ppObjectRef); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->Protects_Impl(ppObjectRef); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return FALSE; @@ -190,7 +190,7 @@ BOOL Frame::Protects(OBJECTREF *ppObjectRef) // TransitionFrame only apis TADDR TransitionFrame::GetTransitionBlock() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->GetTransitionBlock_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetTransitionBlock_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return (TADDR)0; @@ -198,7 +198,7 @@ TADDR TransitionFrame::GetTransitionBlock() BOOL TransitionFrame::SuppressParamTypeArg() { -#define FRAME_TYPE_NAME(frameType) if (this->GetType() == FrameIdentifier::frameType) { return ((frameType*)this)->SuppressParamTypeArg_Impl(); } +#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->SuppressParamTypeArg_Impl(); } #include "FrameTypes.h" _ASSERTE(!"Unexpected"); return FALSE; @@ -232,17 +232,17 @@ void Frame::Log() { char buff[64]; const char* frameType; - if (GetType() == FrameIdentifier::PrestubMethodFrame) + if (GetFrameIdentifier() == FrameIdentifier::PrestubMethodFrame) frameType = "PreStub"; - else if (GetType() == FrameIdentifier::PInvokeCalliFrame) + else if (GetFrameIdentifier() == FrameIdentifier::PInvokeCalliFrame) { sprintf_s(buff, ARRAY_SIZE(buff), "PInvoke CALLI target" FMT_ADDR, DBG_ADDR(((PInvokeCalliFrame*)this)->GetPInvokeCalliTarget())); frameType = buff; } - else if (GetType() == FrameIdentifier::StubDispatchFrame) + else if (GetFrameIdentifier() == FrameIdentifier::StubDispatchFrame) frameType = "StubDispatch"; - else if (GetType() == FrameIdentifier::ExternalMethodFrame) + else if (GetFrameIdentifier() == FrameIdentifier::ExternalMethodFrame) frameType = "ExternalMethod"; else frameType = "Unknown"; @@ -459,7 +459,7 @@ bool Frame::HasValidVTablePtr(Frame * pFrame) return false; #ifndef DACCESS_COMPILE - FrameIdentifier vptr = pFrame->GetType(); + FrameIdentifier vptr = pFrame->GetFrameIdentifier(); // // Use a simple compare which is dependent on the tightly packed arrangement of FrameIdentifier // @@ -1773,7 +1773,7 @@ void ComMethodFrame::DoSecondPassHandlerCleanup(Frame * pCurFrame) // Find ComMethodFrame while ((pCurFrame != FRAME_TOP) && - (pCurFrame->GetType() != FrameIdentifier::ComMethodFrame)) + (pCurFrame->GetFrameIdentifier() != FrameIdentifier::ComMethodFrame)) { pCurFrame = pCurFrame->PtrNextFrame(); } diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index facfc7124e5811..db0ebbbf0cc951 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -264,7 +264,7 @@ class FrameBase // Nothing to protect } - FrameIdentifier GetType() { LIMITED_METHOD_DAC_CONTRACT; return _frameIdentifier; } + FrameIdentifier GetFrameIdentifier() { LIMITED_METHOD_DAC_CONTRACT; return _frameIdentifier; } }; //------------------------------------------------------------------------ @@ -808,7 +808,7 @@ inline BOOL ISREDIRECTEDTHREAD(Thread * thread) { WRAPPER_NO_CONTRACT; return (thread->GetFrame() != FRAME_TOP && - thread->GetFrame()->GetType() == + thread->GetFrame()->GetFrameIdentifier() == FrameIdentifier::RedirectedThreadFrame); } @@ -2656,7 +2656,7 @@ class InlinedCallFrame : public Frame SUPPORTS_DAC; return pFrame && pFrame != FRAME_TOP && - FrameIdentifier::InlinedCallFrame == pFrame->GetType() && + FrameIdentifier::InlinedCallFrame == pFrame->GetFrameIdentifier() && dac_cast(dac_cast(pFrame)->m_pCallerReturnAddress) != 0; } @@ -2731,7 +2731,7 @@ class TailCallFrame : public Frame { LIMITED_METHOD_CONTRACT; // loop through the frame chain - while (pFrame->GetType() != FrameIdentifier::TailCallFrame) + while (pFrame->GetFrameIdentifier() != FrameIdentifier::TailCallFrame) pFrame = pFrame->m_Next; return (TailCallFrame*)pFrame; } diff --git a/src/coreclr/vm/gcenv.ee.common.cpp b/src/coreclr/vm/gcenv.ee.common.cpp index a25c0aaf460af6..2f35079e037e32 100644 --- a/src/coreclr/vm/gcenv.ee.common.cpp +++ b/src/coreclr/vm/gcenv.ee.common.cpp @@ -104,7 +104,7 @@ inline bool SafeToReportGenericParamContext(CrawlFrame* pCF) { LIMITED_METHOD_CONTRACT; - if (!pCF->IsFrameless() && pCF->GetFrame()->GetType() == FrameIdentifier::StubDispatchFrame) + if (!pCF->IsFrameless() && pCF->GetFrame()->GetFrameIdentifier() == FrameIdentifier::StubDispatchFrame) { return !((StubDispatchFrame*)pCF->GetFrame())->SuppressParamTypeArg(); } diff --git a/src/coreclr/vm/i386/excepx86.cpp b/src/coreclr/vm/i386/excepx86.cpp index b8f5d1e42f0ba0..47c6cd85993b57 100644 --- a/src/coreclr/vm/i386/excepx86.cpp +++ b/src/coreclr/vm/i386/excepx86.cpp @@ -690,7 +690,7 @@ CPFH_RealFirstPassHandler( // ExceptionContinueSearch, etc. if (fIsManagedCode && fPGCDisabledOnEntry && (pThread->m_pFrame == FRAME_TOP || - pThread->m_pFrame->GetType() != FrameIdentifier::FaultingExceptionFrame || + pThread->m_pFrame->GetFrameIdentifier() != FrameIdentifier::FaultingExceptionFrame || (size_t)pThread->m_pFrame > (size_t)pEstablisherFrame)) { // setup interrupted frame so that GC during calls to init won't collect the frames @@ -2167,7 +2167,7 @@ StackWalkAction COMPlusThrowCallback( // SWA value if (pData->pPrevExceptionRecord) { // FCALLS have an extra SEH record in debug because of the desctructor // associated with ForbidGC checking. This is benign, so just ignore it. - if (pFrame) _ASSERTE(pData->pPrevExceptionRecord < pFrame || pFrame->GetType() == FrameIdentifier::HelperMethodFrame); + if (pFrame) _ASSERTE(pData->pPrevExceptionRecord < pFrame || pFrame->GetFrameIdentifier() == FrameIdentifier::HelperMethodFrame); if (pCf->IsFrameless()) _ASSERTE((ULONG_PTR)pData->pPrevExceptionRecord <= GetRegdisplaySP(pCf->GetRegisterSet())); } } @@ -2668,7 +2668,7 @@ StackWalkAction COMPlusUnwindCallback (CrawlFrame *pCf, ThrowCallbackType *pData // Make the filter as done. See comment in CallJitEHFilter // on why we have to do it here. Frame* pFilterFrame = pThread->GetFrame(); - _ASSERTE(pFilterFrame->GetType() == FrameIdentifier::ExceptionFilterFrame); + _ASSERTE(pFilterFrame->GetFrameIdentifier() == FrameIdentifier::ExceptionFilterFrame); ((ExceptionFilterFrame*)pFilterFrame)->SetFilterDone(); // Inform the profiler that we're leaving, and what pass we're on diff --git a/src/coreclr/vm/stackwalk.cpp b/src/coreclr/vm/stackwalk.cpp index e508f026405ab7..2e1c13f6750f80 100644 --- a/src/coreclr/vm/stackwalk.cpp +++ b/src/coreclr/vm/stackwalk.cpp @@ -1414,11 +1414,11 @@ BOOL StackFrameIterator::IsValid(void) _ASSERTE(GCStress::IsEnabled()); _ASSERTE(m_pRealStartFrame != NULL); _ASSERTE(m_pRealStartFrame != FRAME_TOP); - _ASSERTE(m_pRealStartFrame->GetType() == FrameIdentifier::InlinedCallFrame); + _ASSERTE(m_pRealStartFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame); _ASSERTE(m_pThread->GetFrame() != NULL); _ASSERTE(m_pThread->GetFrame() != FRAME_TOP); - bIsRealStartFrameUnchanged = (m_pThread->GetFrame()->GetType() == FrameIdentifier::ResumableFrame) - || (m_pThread->GetFrame()->GetType() == FrameIdentifier::RedirectedThreadFrame); + bIsRealStartFrameUnchanged = (m_pThread->GetFrame()->GetFrameIdentifier() == FrameIdentifier::ResumableFrame) + || (m_pThread->GetFrame()->GetFrameIdentifier() == FrameIdentifier::RedirectedThreadFrame); } #endif // FEATURE_HIJACK @@ -2365,7 +2365,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) // make sure we're not skipping a different transition if (m_crawl.pFrame->NeedsUpdateRegDisplay()) { - if (m_crawl.pFrame->GetType() == FrameIdentifier::InlinedCallFrame) + if (m_crawl.pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame) { // ControlPC may be different as the InlinedCallFrame stays active throughout // the STOP_FOR_GC callout but we can use the stack/frame pointer for the assert. @@ -2502,7 +2502,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) // pushed on the stack after the frame is running _ASSERTE((m_crawl.pFrame == FRAME_TOP) || ((TADDR)GetRegdisplaySP(m_crawl.pRD) < dac_cast(m_crawl.pFrame)) || - (m_crawl.pFrame->GetType() == FrameIdentifier::FaultingExceptionFrame)); + (m_crawl.pFrame->GetFrameIdentifier() == FrameIdentifier::FaultingExceptionFrame)); #endif // !defined(ELIMINATE_FEF) // Get rid of the frame (actually, it isn't really popped) @@ -2847,7 +2847,7 @@ void StackFrameIterator::ProcessCurrentFrame(void) // the next frame is one of them, we don't want to override it. THIS IS PROBABLY BAD!!! if ( (pContextSP < dac_cast(m_crawl.pFrame)) && ((m_crawl.GetFrame() == FRAME_TOP) || - (m_crawl.GetFrame()->GetType() != FrameIdentifier::FaultingExceptionFrame ) ) ) + (m_crawl.GetFrame()->GetFrameIdentifier() != FrameIdentifier::FaultingExceptionFrame ) ) ) { // // If the REGDISPLAY represents an unmanaged stack frame above (closer to the leaf than) an @@ -3006,7 +3006,7 @@ BOOL StackFrameIterator::CheckForSkippedFrames(void) // Note that code:InlinedCallFrame.GetFunction may return NULL in this case because // the call is made using the CALLI instruction. m_crawl.pFrame != FRAME_TOP && - m_crawl.pFrame->GetType() == FrameIdentifier::InlinedCallFrame && + m_crawl.pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame && m_crawl.pFunc != NULL && m_crawl.pFunc->IsILStub() && m_crawl.pFunc->AsDynamicMethodDesc()->HasMDContextArg(); diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 390e1e543bb030..ab2411a0f00493 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -305,7 +305,7 @@ bool Thread::DetectHandleILStubsForDebugger() while (pFrame != FRAME_TOP) { // Check for HMF's. See the comment at the beginning of this function. - if (pFrame->GetType() == FrameIdentifier::HelperMethodFrame) + if (pFrame->GetFrameIdentifier() == FrameIdentifier::HelperMethodFrame) { break; } From 496472e0786cd1eb9dfe8aa3c53c459953b35eca Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Tue, 4 Feb 2025 16:36:48 -0800 Subject: [PATCH 06/17] Fix issues on more architectures --- src/coreclr/vm/arm/pinvokestubs.S | 2 +- src/coreclr/vm/arm/stubs.cpp | 2 +- src/coreclr/vm/arm64/PInvokeStubs.asm | 2 +- src/coreclr/vm/arm64/pinvokestubs.S | 2 +- src/coreclr/vm/arm64/stubs.cpp | 2 +- src/coreclr/vm/loongarch64/stubs.cpp | 2 +- src/coreclr/vm/riscv64/stubs.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/coreclr/vm/arm/pinvokestubs.S b/src/coreclr/vm/arm/pinvokestubs.S index 57c6e8723d28b8..c4e4a42383f009 100644 --- a/src/coreclr/vm/arm/pinvokestubs.S +++ b/src/coreclr/vm/arm/pinvokestubs.S @@ -93,7 +93,7 @@ // r4 = pFrame // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) - ldr r1, #FRAMETYPE_InlinedCallFrame + mov r1, #FRAMETYPE_InlinedCallFrame str r1, [r4] mov r1, 0 diff --git a/src/coreclr/vm/arm/stubs.cpp b/src/coreclr/vm/arm/stubs.cpp index f36beef13b37f0..e4a164aec42e4b 100644 --- a/src/coreclr/vm/arm/stubs.cpp +++ b/src/coreclr/vm/arm/stubs.cpp @@ -1618,7 +1618,7 @@ void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateF } #ifdef FEATURE_HIJACK -TADDR ResumableFrame::GetReturnAddressPtr(void) +TADDR ResumableFrame::GetReturnAddressPtr_Impl(void) { LIMITED_METHOD_DAC_CONTRACT; return dac_cast(m_Regs) + offsetof(T_CONTEXT, Pc); diff --git a/src/coreclr/vm/arm64/PInvokeStubs.asm b/src/coreclr/vm/arm64/PInvokeStubs.asm index 9833dd053d60c1..e8f43b7add2c67 100644 --- a/src/coreclr/vm/arm64/PInvokeStubs.asm +++ b/src/coreclr/vm/arm64/PInvokeStubs.asm @@ -121,7 +121,7 @@ __PInvokeStubWorkerName SETS "$FuncPrefix":CC:"StubWorker" add x10, x0, SIZEOF__GSCookie ;; set first slot to the value of InlinedCallFrame identifier (checked by runtime code) - ldr x9, #FRAMETYPE_InlinedCallFrame + mov x9, #FRAMETYPE_InlinedCallFrame str x9, [x10] str xzr, [x10, #InlinedCallFrame__m_Datum] diff --git a/src/coreclr/vm/arm64/pinvokestubs.S b/src/coreclr/vm/arm64/pinvokestubs.S index a4a233cbd789d3..dfc3f79831beb0 100644 --- a/src/coreclr/vm/arm64/pinvokestubs.S +++ b/src/coreclr/vm/arm64/pinvokestubs.S @@ -99,7 +99,7 @@ LOCAL_LABEL(\__PInvokeStubFuncName\()_0): // x19 = pFrame // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) - ldr x9, #FRAMETYPE_InlinedCallFrame + mov x9, #FRAMETYPE_InlinedCallFrame str x9, [x19] str xzr, [x19, #InlinedCallFrame__m_Datum] diff --git a/src/coreclr/vm/arm64/stubs.cpp b/src/coreclr/vm/arm64/stubs.cpp index 5e479e2e3a1738..427bf342003389 100644 --- a/src/coreclr/vm/arm64/stubs.cpp +++ b/src/coreclr/vm/arm64/stubs.cpp @@ -728,7 +728,7 @@ void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateF } #ifdef FEATURE_HIJACK -TADDR ResumableFrame::GetReturnAddressPtr(void) +TADDR ResumableFrame::GetReturnAddressPtr_Impl(void) { LIMITED_METHOD_DAC_CONTRACT; return dac_cast(m_Regs) + offsetof(T_CONTEXT, Pc); diff --git a/src/coreclr/vm/loongarch64/stubs.cpp b/src/coreclr/vm/loongarch64/stubs.cpp index d8f8d980e2f85a..36ff741d279d3b 100644 --- a/src/coreclr/vm/loongarch64/stubs.cpp +++ b/src/coreclr/vm/loongarch64/stubs.cpp @@ -741,7 +741,7 @@ void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateF } #ifdef FEATURE_HIJACK -TADDR ResumableFrame::GetReturnAddressPtr(void) +TADDR ResumableFrame::GetReturnAddressPtr_Impl(void) { LIMITED_METHOD_DAC_CONTRACT; return dac_cast(m_Regs) + offsetof(T_CONTEXT, Pc); diff --git a/src/coreclr/vm/riscv64/stubs.cpp b/src/coreclr/vm/riscv64/stubs.cpp index 114550f27fcf29..1f98212b231771 100644 --- a/src/coreclr/vm/riscv64/stubs.cpp +++ b/src/coreclr/vm/riscv64/stubs.cpp @@ -661,7 +661,7 @@ void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateF } #ifdef FEATURE_HIJACK -TADDR ResumableFrame::GetReturnAddressPtr(void) +TADDR ResumableFrame::GetReturnAddressPtr_Impl(void) { LIMITED_METHOD_DAC_CONTRACT; return dac_cast(m_Regs) + offsetof(T_CONTEXT, Pc); From 115d235d9f1c9fb2f84ef8ee5c9b2cd915498db6 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Wed, 5 Feb 2025 11:32:58 -0800 Subject: [PATCH 07/17] Fix issues found in testing --- src/coreclr/vm/i386/cgenx86.cpp | 4 ++-- src/coreclr/vm/loongarch64/pinvokestubs.S | 2 +- src/coreclr/vm/riscv64/pinvokestubs.S | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/vm/i386/cgenx86.cpp b/src/coreclr/vm/i386/cgenx86.cpp index fded538130b98a..1d13b59dd14bd6 100644 --- a/src/coreclr/vm/i386/cgenx86.cpp +++ b/src/coreclr/vm/i386/cgenx86.cpp @@ -399,7 +399,7 @@ void ExternalMethodFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool upda UpdateRegDisplayHelper(pRD, CbStackPopUsingGCRefMap(GetGCRefMap())); - LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK ExternalMethodFrane::UpdateRegDisplay(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); + LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK ExternalMethodFrane::UpdateRegDisplay_Impl(ip:%p, sp:%p)\n", pRD->ControlPC, pRD->SP)); RETURN; } @@ -452,7 +452,7 @@ PCODE StubDispatchFrame::GetReturnAddress_Impl() } CONTRACTL_END; - PCODE retAddress = FramedMethodFrame::GetReturnAddress(); + PCODE retAddress = FramedMethodFrame::GetReturnAddress_Impl(); if (GetFunction() == NULL && GetGCRefMap() == NULL) { // See comment in code:StubDispatchFrame::UpdateRegDisplay diff --git a/src/coreclr/vm/loongarch64/pinvokestubs.S b/src/coreclr/vm/loongarch64/pinvokestubs.S index a9c01a674fa4a4..b2531cfd34bf2b 100644 --- a/src/coreclr/vm/loongarch64/pinvokestubs.S +++ b/src/coreclr/vm/loongarch64/pinvokestubs.S @@ -94,7 +94,7 @@ NESTED_ENTRY JIT_PInvokeBegin, _TEXT, NoHandler // s0 = pFrame // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) - li $t0, FRAMETYPE_InlinedCallFrame + li.d $t0, FRAMETYPE_InlinedCallFrame st.d $t4, $s0, 0 st.d $zero, $s0, InlinedCallFrame__m_Datum diff --git a/src/coreclr/vm/riscv64/pinvokestubs.S b/src/coreclr/vm/riscv64/pinvokestubs.S index 6179c14aa375e4..4fd1980066bbed 100644 --- a/src/coreclr/vm/riscv64/pinvokestubs.S +++ b/src/coreclr/vm/riscv64/pinvokestubs.S @@ -89,7 +89,7 @@ // s1 = pFrame // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) - ld.d t4, FRAMETYPE_InlinedCallFrame + ld t4, FRAMETYPE_InlinedCallFrame sd t4, 0(s1) sd zero, (InlinedCallFrame__m_Datum)(s1) From e3cfc5aac80538cf4ae8e832f1a822e1d9baedc2 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Wed, 5 Feb 2025 15:13:03 -0800 Subject: [PATCH 08/17] Remove GS Cookies --- src/coreclr/debug/ee/debugger.cpp | 5 +- src/coreclr/debug/ee/funceval.cpp | 4 +- src/coreclr/jit/lower.cpp | 19 +- src/coreclr/vm/amd64/ComCallPreStub.asm | 16 -- src/coreclr/vm/amd64/GenericComCallStubs.asm | 16 +- src/coreclr/vm/amd64/PInvokeStubs.asm | 13 +- .../vm/amd64/RedirectedHandledJITCase.asm | 4 +- src/coreclr/vm/amd64/asmconstants.h | 2 +- src/coreclr/vm/amd64/pinvokestubs.S | 12 +- .../vm/amd64/redirectedhandledjitcase.S | 6 +- src/coreclr/vm/arm/ehhelpers.S | 4 +- src/coreclr/vm/arm/pinvokestubs.S | 12 +- src/coreclr/vm/arm/stubs.cpp | 4 - src/coreclr/vm/arm64/PInvokeStubs.asm | 28 +-- src/coreclr/vm/arm64/asmhelpers.S | 4 +- src/coreclr/vm/arm64/asmhelpers.asm | 10 +- src/coreclr/vm/arm64/pinvokestubs.S | 12 +- src/coreclr/vm/assembly.cpp | 2 +- src/coreclr/vm/callcounting.cpp | 4 +- src/coreclr/vm/clrtocomcall.cpp | 2 +- src/coreclr/vm/comtoclrcall.cpp | 3 +- src/coreclr/vm/dispatchinfo.cpp | 2 +- src/coreclr/vm/dllimport.cpp | 4 +- src/coreclr/vm/eepolicy.cpp | 5 +- src/coreclr/vm/encee.cpp | 2 +- src/coreclr/vm/excep.cpp | 16 +- src/coreclr/vm/exceptionhandling.cpp | 8 +- src/coreclr/vm/fcall.h | 2 +- src/coreclr/vm/frames.cpp | 47 +---- src/coreclr/vm/frames.h | 184 +----------------- src/coreclr/vm/gccover.cpp | 4 +- src/coreclr/vm/i386/PInvokeStubs.asm | 7 - src/coreclr/vm/i386/asmhelpers.asm | 10 +- src/coreclr/vm/i386/cgenx86.cpp | 4 - src/coreclr/vm/i386/excepx86.cpp | 4 +- src/coreclr/vm/i386/jithelp.asm | 38 ++-- src/coreclr/vm/jithelpers.cpp | 6 +- src/coreclr/vm/jitinterface.cpp | 24 +-- src/coreclr/vm/loongarch64/asmhelpers.S | 4 +- src/coreclr/vm/loongarch64/pinvokestubs.S | 9 +- src/coreclr/vm/prestub.cpp | 6 +- src/coreclr/vm/reflectioninvocation.cpp | 6 +- src/coreclr/vm/riscv64/asmhelpers.S | 4 +- src/coreclr/vm/riscv64/pinvokestubs.S | 14 +- src/coreclr/vm/runtimecallablewrapper.cpp | 6 +- src/coreclr/vm/stackwalk.cpp | 15 -- src/coreclr/vm/threads.cpp | 2 +- src/coreclr/vm/threadsuspend.cpp | 9 +- src/coreclr/vm/virtualcallstub.cpp | 2 +- 49 files changed, 126 insertions(+), 500 deletions(-) diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 9e907b47ca7bc5..7491c1f276ad19 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -13475,10 +13475,7 @@ void Debugger::UnhandledHijackWorker(CONTEXT * pContext, EXCEPTION_RECORD * pRec fSOException)) { - FrameWithCookie fef; -#if defined(FEATURE_EH_FUNCLETS) - *((&fef)->GetGSCookiePtr()) = GetProcessGSCookie(); -#endif // FEATURE_EH_FUNCLETS + FaultingExceptionFrame fef; if ((pContext != NULL) && fSOException) { GCX_COOP(); // Must be cooperative to modify frame chain. diff --git a/src/coreclr/debug/ee/funceval.cpp b/src/coreclr/debug/ee/funceval.cpp index 287f6f11e51778..66a85ab0d239da 100644 --- a/src/coreclr/debug/ee/funceval.cpp +++ b/src/coreclr/debug/ee/funceval.cpp @@ -3525,7 +3525,7 @@ static void GCProtectArgsAndDoNormalFuncEval(DebuggerEval *pDE, INT64 *pBufferForArgsArray = (INT64*)_alloca(cbAllocSize); memset(pBufferForArgsArray, 0, cbAllocSize); - FrameWithCookie protectValueClassFrame; + ProtectValueClassFrame protectValueClassFrame; // // Initialize our tracking array @@ -3858,7 +3858,7 @@ void * STDCALL FuncEvalHijackWorker(DebuggerEval *pDE) // Push our FuncEvalFrame. The return address is equal to the IP in the saved context in the DebuggerEval. The // m_Datum becomes the ptr to the DebuggerEval. The frame address also serves as the address of the catch-handler-found. // - FrameWithCookie FEFrame(pDE, GetIP(&pDE->m_context), true); + FuncEvalFrame FEFrame(pDE, GetIP(&pDE->m_context), true); FEFrame.Push(); // On ARM/ARM64 the single step flag is per-thread and not per context. We need to make sure that the SS flag is cleared diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index eee9a5859ecb43..f0ab60766812e8 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -5889,20 +5889,19 @@ GenTree* Lowering::CreateFrameLinkUpdate(FrameLinkAction action) // 64-bit 32-bit CORINFO_EE_INFO // offset offset field name offset when set // ----------------------------------------------------------------------------------------- -// +00h +00h GS cookie offsetOfGSCookie -// +08h +04h vptr for class InlinedCallFrame offsetOfFrameVptr method prolog -// +10h +08h m_Next offsetOfFrameLink method prolog -// +18h +0Ch m_Datum offsetOfCallTarget call site -// +20h +10h m_pCallSiteSP offsetOfCallSiteSP x86: call site, and zeroed in method +// +00h +00h vptr for class InlinedCallFrame offsetOfFrameVptr method prolog +// +08h +04h m_Next offsetOfFrameLink method prolog +// +10h +08h m_Datum offsetOfCallTarget call site +// +18h +0Ch m_pCallSiteSP offsetOfCallSiteSP x86: call site, and zeroed in method // prolog; // non-x86: method prolog (SP remains // constant in function, after prolog: no // localloc and PInvoke in same function) -// +28h +14h m_pCallerReturnAddress offsetOfReturnAddress call site -// +30h +18h m_pCalleeSavedFP offsetOfCalleeSavedFP not set by JIT -// +38h +1Ch m_pThread -// +20h m_pSPAfterProlog offsetOfSPAfterProlog arm only -// +40h +20/24h m_StubSecretArg offsetOfSecretStubArg method prolog of IL stubs with secret arg +// +20h +10h m_pCallerReturnAddress offsetOfReturnAddress call site +// +28h +14h m_pCalleeSavedFP offsetOfCalleeSavedFP not set by JIT +// +30h +18h m_pThread +// +1Ch m_pSPAfterProlog offsetOfSPAfterProlog arm only +// +38h +1C/20h m_StubSecretArg offsetOfSecretStubArg method prolog of IL stubs with secret arg // // Note that in the VM, InlinedCallFrame is a C++ class whose objects have a 'this' pointer that points // to the InlinedCallFrame vptr (the 2nd field listed above), and the GS cookie is stored *before* diff --git a/src/coreclr/vm/amd64/ComCallPreStub.asm b/src/coreclr/vm/amd64/ComCallPreStub.asm index 8057d86a078071..5fe6231c4054fb 100644 --- a/src/coreclr/vm/amd64/ComCallPreStub.asm +++ b/src/coreclr/vm/amd64/ComCallPreStub.asm @@ -9,7 +9,6 @@ include asmconstants.inc ; extern "C" const BYTE* ComPreStubWorker(ComPrestubMethodFrame *pPFrame, UINT64 *pErrorResult) extern ComPreStubWorker:proc extern JIT_FailFast:proc -extern s_gsCookie:qword ; extern "C" VOID ComCallPreStub() @@ -28,7 +27,6 @@ NESTED_ENTRY ComCallPreStub, _TEXT ; ComPrestubMethodFrame::m_pFuncDesc ; Frame::m_Next ; __VFN_table <-- rsp + ComCallPreStub_ComPrestubMethodFrame_OFFSET -; gsCookie ; HRESULT <-- rsp + ComCallPreStub_HRESULT_OFFSET ; (optional padding to qword align xmm save area) ; xmm3 @@ -52,9 +50,6 @@ ComCallPreStub_ComPrestubMethodFrame_NEGOFFSET = ComCallPreStub_STACK_FRAME_SIZE ComCallPreStub_STACK_FRAME_SIZE = ComCallPreStub_STACK_FRAME_SIZE + 8*8 ComCallPreStub_CalleeSavedRegisters_NEGOFFSET = ComCallPreStub_STACK_FRAME_SIZE -; GSCookie MUST be immediately below CalleeSavedRegisters -ComCallPreStub_STACK_FRAME_SIZE = ComCallPreStub_STACK_FRAME_SIZE + SIZEOF_GSCookie - ; UINT64 (out param to ComPreStubWorker) ComCallPreStub_STACK_FRAME_SIZE = ComCallPreStub_STACK_FRAME_SIZE + 8 ComCallPreStub_ERRORRETVAL_NEGOFFSET = ComCallPreStub_STACK_FRAME_SIZE @@ -74,7 +69,6 @@ ComCallPreStub_STACK_FRAME_SIZE = ComCallPreStub_STACK_FRAME_SIZE + 20h ; Now we have the full size of the stack frame. The offsets have been computed relative to the ; top, so negate them to make them relative to the post-prologue rsp. ComCallPreStub_ComPrestubMethodFrame_OFFSET = ComCallPreStub_STACK_FRAME_SIZE - ComCallPreStub_ComPrestubMethodFrame_NEGOFFSET -OFFSETOF_GSCookie = ComCallPreStub_ComPrestubMethodFrame_OFFSET - SIZEOF_GSCookie ComCallPreStub_ERRORRETVAL_OFFSET = ComCallPreStub_STACK_FRAME_SIZE - ComCallPreStub_ERRORRETVAL_NEGOFFSET ComCallPreStub_XMM_SAVE_OFFSET = ComCallPreStub_STACK_FRAME_SIZE - ComCallPreStub_XMM_SAVE_NEGOFFSET @@ -104,8 +98,6 @@ ComCallPreStub_XMM_SAVE_OFFSET = ComCallPreStub_STACK_FRAME_SIZE - END_PROLOGUE - mov rcx, s_gsCookie - mov [rsp + OFFSETOF_GSCookie], rcx ; ; Resolve target. ; @@ -115,14 +107,6 @@ ComCallPreStub_XMM_SAVE_OFFSET = ComCallPreStub_STACK_FRAME_SIZE - test rax, rax jz ExitError -ifdef _DEBUG - mov rcx, s_gsCookie - cmp [rsp + OFFSETOF_GSCookie], rcx - je GoodGSCookie - call JIT_FailFast -GoodGSCookie: -endif ; _DEBUG - ; ; Restore FP parameters ; diff --git a/src/coreclr/vm/amd64/GenericComCallStubs.asm b/src/coreclr/vm/amd64/GenericComCallStubs.asm index f4e6eccc666ffa..ecdba9eee05d84 100644 --- a/src/coreclr/vm/amd64/GenericComCallStubs.asm +++ b/src/coreclr/vm/amd64/GenericComCallStubs.asm @@ -10,7 +10,6 @@ extern CallDescrWorkerUnwindFrameChainHandler:proc extern ReverseComUnwindFrameChainHandler:proc extern COMToCLRWorker:proc extern JIT_FailFast:proc -extern s_gsCookie:qword NESTED_ENTRY GenericComCallStub, _TEXT, ReverseComUnwindFrameChainHandler @@ -30,7 +29,6 @@ NESTED_ENTRY GenericComCallStub, _TEXT, ReverseComUnwindFrameChainHandler ; UnmanagedToManagedFrame::m_Datum ; Frame::m_Next ; __VFN_table <-- rsp + GenericComCallStub_ComMethodFrame_OFFSET -; GSCookie ; (optional padding to qword align xmm save area) ; xmm3 ; xmm2 @@ -54,7 +52,7 @@ GenericComCallStub_STACK_FRAME_SIZE = 0 GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE + (SIZEOF__ComMethodFrame - 8) GenericComCallStub_ComMethodFrame_NEGOFFSET = GenericComCallStub_STACK_FRAME_SIZE -GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE + SIZEOF_GSCookie +GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE ; Ensure that the offset of the XMM save area will be 16-byte aligned. if ((GenericComCallStub_STACK_FRAME_SIZE + 8) MOD 16) ne 0 @@ -74,7 +72,6 @@ GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE + Gene ; top, so negate them to make them relative to the post-prologue rsp. GenericComCallStub_ComMethodFrame_OFFSET = GenericComCallStub_STACK_FRAME_SIZE - GenericComCallStub_ComMethodFrame_NEGOFFSET GenericComCallStub_XMM_SAVE_OFFSET = GenericComCallStub_STACK_FRAME_SIZE - GenericComCallStub_XMM_SAVE_NEGOFFSET -OFFSETOF_GSCookie = GenericComCallStub_ComMethodFrame_OFFSET - SIZEOF_GSCookie .allocstack 8 ; UnmanagedToManagedFrame::m_Datum, pushed by prepad @@ -103,9 +100,6 @@ OFFSETOF_GSCookie = GenericComCallStub_ComMethodFrame_OFFSET - SIZEOF_GSCookie END_PROLOGUE - mov rcx, s_gsCookie - mov [rsp + OFFSETOF_GSCookie], rcx - ; ; Call COMToCLRWorker. ; @@ -113,14 +107,6 @@ OFFSETOF_GSCookie = GenericComCallStub_ComMethodFrame_OFFSET - SIZEOF_GSCookie mov rcx, r10 call COMToCLRWorker -ifdef _DEBUG - mov rcx, s_gsCookie - cmp [rsp + OFFSETOF_GSCookie], rcx - je GoodGSCookie - call JIT_FailFast -GoodGSCookie: -endif ; _DEBUG - ; ; epilogue ; diff --git a/src/coreclr/vm/amd64/PInvokeStubs.asm b/src/coreclr/vm/amd64/PInvokeStubs.asm index 142831053463af..a18ed56b752d3c 100644 --- a/src/coreclr/vm/amd64/PInvokeStubs.asm +++ b/src/coreclr/vm/amd64/PInvokeStubs.asm @@ -8,7 +8,6 @@ extern GenericPInvokeCalliStubWorker:proc extern VarargPInvokeStubWorker:proc extern JIT_PInvokeEndRarePath:proc -extern s_gsCookie:QWORD extern g_TrapReturningThreads:DWORD ; @@ -134,16 +133,11 @@ NESTED_END VarargPInvokeGenILStub, _TEXT ; ; in: -; InlinedCallFrame (rcx) = pointer to the InlinedCallFrame data, including the GS cookie slot (GS cookie right -; before actual InlinedCallFrame data) +; InlinedCallFrame (rcx) = pointer to the InlinedCallFrame data ; ; LEAF_ENTRY JIT_PInvokeBegin, _TEXT - mov rax, qword ptr [s_gsCookie] - mov qword ptr [rcx], rax - add rcx, SIZEOF_GSCookie - ;; set first slot to the value of InlinedCallFrame::`vftable' (checked by runtime code) mov qword ptr [rcx], FRAMETYPE_InlinedCallFrame @@ -174,14 +168,11 @@ LEAF_END JIT_PInvokeBegin, _TEXT ; ; in: -; InlinedCallFrame (rcx) = pointer to the InlinedCallFrame data, including the GS cookie slot (GS cookie right -; before actual InlinedCallFrame data) +; InlinedCallFrame (rcx) = pointer to the InlinedCallFrame data ; ; LEAF_ENTRY JIT_PInvokeEnd, _TEXT - add rcx, SIZEOF_GSCookie - INLINE_GETTHREAD rdx ;; rcx = pFrame diff --git a/src/coreclr/vm/amd64/RedirectedHandledJITCase.asm b/src/coreclr/vm/amd64/RedirectedHandledJITCase.asm index 47b1ecfd50fb33..15a33bdce0bc18 100644 --- a/src/coreclr/vm/amd64/RedirectedHandledJITCase.asm +++ b/src/coreclr/vm/amd64/RedirectedHandledJITCase.asm @@ -97,8 +97,8 @@ endif endif -; scratch area; padding; GSCookie -OFFSET_OF_FRAME = SIZEOF_MAX_OUTGOING_ARGUMENT_HOMES + 8 + SIZEOF_GSCookie +; scratch area +OFFSET_OF_FRAME = SIZEOF_MAX_OUTGOING_ARGUMENT_HOMES ; force evaluation to avoid "expression is too complex errors" SIZEOF__FaultingExceptionFrame = SIZEOF__FaultingExceptionFrame diff --git a/src/coreclr/vm/amd64/asmconstants.h b/src/coreclr/vm/amd64/asmconstants.h index 59b04d8c0f189e..35c8ec685c15cd 100644 --- a/src/coreclr/vm/amd64/asmconstants.h +++ b/src/coreclr/vm/amd64/asmconstants.h @@ -436,7 +436,7 @@ ASMCONSTANTS_C_ASSERT(OFFSET__TEB__ThreadLocalStoragePointer == offsetof(TEB, Th #define REDIRECTSTUB_ESTABLISHER_OFFSET_RBP 0 #define REDIRECTSTUB_RBP_OFFSET_CONTEXT 0x20 -#define THROWSTUB_ESTABLISHER_OFFSET_FaultingExceptionFrame 0x30 +#define THROWSTUB_ESTABLISHER_OFFSET_FaultingExceptionFrame 0x20 #ifdef FEATURE_SPECIAL_USER_MODE_APC #define OFFSETOF__APC_CALLBACK_DATA__ContextRecord 0x8 diff --git a/src/coreclr/vm/amd64/pinvokestubs.S b/src/coreclr/vm/amd64/pinvokestubs.S index 576ce9616bf220..3d33a63d8a0862 100644 --- a/src/coreclr/vm/amd64/pinvokestubs.S +++ b/src/coreclr/vm/amd64/pinvokestubs.S @@ -129,8 +129,7 @@ NESTED_END VarargPInvokeGenILStub, _TEXT // // IN: -// InlinedCallFrame (rdi) = pointer to the InlinedCallFrame data, including the GS cookie slot (GS cookie right -// before actual InlinedCallFrame data) +// InlinedCallFrame (rdi) = pointer to the InlinedCallFrame data // // NESTED_ENTRY JIT_PInvokeBegin, _TEXT, NoHandler @@ -138,11 +137,6 @@ NESTED_ENTRY JIT_PInvokeBegin, _TEXT, NoHandler push_nonvol_reg r14 END_PROLOGUE - PREPARE_EXTERNAL_VAR s_gsCookie, rax - mov rax, qword ptr [rax] - mov qword ptr [rdi], rax - add rdi, SIZEOF_GSCookie - // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) mov qword ptr [rdi], FRAMETYPE_InlinedCallFrame @@ -179,13 +173,11 @@ NESTED_END JIT_PInvokeBegin, _TEXT // // IN: -// InlinedCallFrame (rdi) = pointer to the InlinedCallFrame data, including the GS cookie slot (GS cookie right -// before actual InlinedCallFrame data) +// InlinedCallFrame (rdi) = pointer to the InlinedCallFrame data // // LEAF_ENTRY JIT_PInvokeEnd, _TEXT - add rdi, SIZEOF_GSCookie mov rsi, qword ptr [rdi + OFFSETOF__InlinedCallFrame__m_pThread] // rdi = pFrame diff --git a/src/coreclr/vm/amd64/redirectedhandledjitcase.S b/src/coreclr/vm/amd64/redirectedhandledjitcase.S index 23de3d6fee93ca..5adce24b21fbad 100644 --- a/src/coreclr/vm/amd64/redirectedhandledjitcase.S +++ b/src/coreclr/vm/amd64/redirectedhandledjitcase.S @@ -5,9 +5,9 @@ #include "unixasmmacros.inc" #include "asmconstants.h" -#define FaultingExceptionFrame_StackAlloc (SIZEOF__GSCookie + SIZEOF__FaultingExceptionFrame) -#define FaultingExceptionFrame_FrameOffset SIZEOF__GSCookie -#define OFFSET_OF_FRAME (8 + SIZEOF_GSCookie) +#define FaultingExceptionFrame_StackAlloc (SIZEOF__FaultingExceptionFrame) +#define FaultingExceptionFrame_FrameOffset 0 +#define OFFSET_OF_FRAME 0 .macro GenerateRedirectedStubWithFrame stub, target diff --git a/src/coreclr/vm/arm/ehhelpers.S b/src/coreclr/vm/arm/ehhelpers.S index 6f44931ebe2be8..eeb6e3894a575e 100644 --- a/src/coreclr/vm/arm/ehhelpers.S +++ b/src/coreclr/vm/arm/ehhelpers.S @@ -17,8 +17,8 @@ // WARNING!! to occur when the stack is unwalkable // - // GSCookie + alignment padding -OFFSET_OF_FRAME=(4 + SIZEOF__GSCookie) + // alignment padding +OFFSET_OF_FRAME=0 .macro GenerateRedirectedStubWithFrame STUB, TARGET diff --git a/src/coreclr/vm/arm/pinvokestubs.S b/src/coreclr/vm/arm/pinvokestubs.S index c4e4a42383f009..cc84c541a183bb 100644 --- a/src/coreclr/vm/arm/pinvokestubs.S +++ b/src/coreclr/vm/arm/pinvokestubs.S @@ -79,16 +79,7 @@ PROLOG_PUSH "{r4, lr}" -#if defined(__clang__) - ldr r1, =s_gsCookie-(1f+4) -1: - add r1, pc -#else - ldr r1, =s_gsCookie -#endif - ldr r1, [r1] - str r1, [r0] - add r4, r0, SIZEOF__GSCookie + mov r4, r0 // r4 = pFrame @@ -132,7 +123,6 @@ // LEAF_ENTRY JIT_PInvokeEnd, _TEXT - add r0, r0, SIZEOF__GSCookie ldr r1, [r0, #InlinedCallFrame__m_pThread] // r0 = pFrame diff --git a/src/coreclr/vm/arm/stubs.cpp b/src/coreclr/vm/arm/stubs.cpp index e4a164aec42e4b..3c65ec5fab2e40 100644 --- a/src/coreclr/vm/arm/stubs.cpp +++ b/src/coreclr/vm/arm/stubs.cpp @@ -1139,10 +1139,6 @@ Stub *GenerateInitPInvokeFrameHelper() for (int reg = 0; reg < 4; reg++) psl->ThumbEmitLoadRegIndirect(ThumbReg(reg), thumbRegSp, offsetof(ArgumentRegisters, r) + sizeof(*ArgumentRegisters::r) * reg); - // mov [regFrame + FrameInfo.offsetOfGSCookie], GetProcessGSCookie() - psl->ThumbEmitMovConstant(regScratch, GetProcessGSCookie()); - psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfGSCookie - negSpace); - // mov [regFrame + FrameInfo.offsetOfFrameVptr], FrameIdentifier::InlinedCallFrame psl->ThumbEmitMovConstant(regScratch, (DWORD)FrameIdentifier::InlinedCallFrame); psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfFrameVptr - negSpace); diff --git a/src/coreclr/vm/arm64/PInvokeStubs.asm b/src/coreclr/vm/arm64/PInvokeStubs.asm index e8f43b7add2c67..05e21ae22d16e4 100644 --- a/src/coreclr/vm/arm64/PInvokeStubs.asm +++ b/src/coreclr/vm/arm64/PInvokeStubs.asm @@ -12,7 +12,6 @@ IMPORT GenericPInvokeCalliStubWorker IMPORT JIT_PInvokeEndRarePath - IMPORT s_gsCookie IMPORT g_TrapReturningThreads ; ------------------------------------------------------------------ @@ -115,34 +114,29 @@ __PInvokeStubWorkerName SETS "$FuncPrefix":CC:"StubWorker" ; LEAF_ENTRY JIT_PInvokeBegin - ldr x9, =s_gsCookie - ldr x9, [x9] - str x9, [x0] - add x10, x0, SIZEOF__GSCookie - ;; set first slot to the value of InlinedCallFrame identifier (checked by runtime code) mov x9, #FRAMETYPE_InlinedCallFrame - str x9, [x10] + str x9, [x0] - str xzr, [x10, #InlinedCallFrame__m_Datum] + str xzr, [x0, #InlinedCallFrame__m_Datum] mov x9, sp - str x9, [x10, #InlinedCallFrame__m_pCallSiteSP] - str fp, [x10, #InlinedCallFrame__m_pCalleeSavedFP] - str lr, [x10, #InlinedCallFrame__m_pCallerReturnAddress] + str x9, [x0, #InlinedCallFrame__m_pCallSiteSP] + str fp, [x0, #InlinedCallFrame__m_pCalleeSavedFP] + str lr, [x0, #InlinedCallFrame__m_pCallerReturnAddress] ;; x0 = GetThread(), TRASHES x9 - INLINE_GETTHREAD x0, x9 + INLINE_GETTHREAD x10, x9 ;; pFrame->m_Next = pThread->m_pFrame; - ldr x9, [x0, #Thread_m_pFrame] - str x9, [x10, #Frame__m_Next] + ldr x9, [x10, #Thread_m_pFrame] + str x9, [x0, #Frame__m_Next] ;; pThread->m_pFrame = pFrame; - str x10, [x0, #Thread_m_pFrame] + str x0, [x10, #Thread_m_pFrame] ;; pThread->m_fPreemptiveGCDisabled = 0 - str wzr, [x0, #Thread_m_fPreemptiveGCDisabled] + str wzr, [x10, #Thread_m_fPreemptiveGCDisabled] ret @@ -156,8 +150,6 @@ __PInvokeStubWorkerName SETS "$FuncPrefix":CC:"StubWorker" ; LEAF_ENTRY JIT_PInvokeEnd - add x0, x0, SIZEOF__GSCookie - ;; x1 = GetThread(), TRASHES x2 INLINE_GETTHREAD x1, x2 diff --git a/src/coreclr/vm/arm64/asmhelpers.S b/src/coreclr/vm/arm64/asmhelpers.S index a6801090ad9b25..e38f5822efa6c4 100644 --- a/src/coreclr/vm/arm64/asmhelpers.S +++ b/src/coreclr/vm/arm64/asmhelpers.S @@ -426,8 +426,8 @@ NESTED_ENTRY CallEHFilterFunclet, _TEXT, NoHandler NESTED_END CallEHFilterFunclet, _TEXT -#define FaultingExceptionFrame_StackAlloc (SIZEOF__GSCookie + SIZEOF__FaultingExceptionFrame) -#define FaultingExceptionFrame_FrameOffset SIZEOF__GSCookie +#define FaultingExceptionFrame_StackAlloc (SIZEOF__FaultingExceptionFrame) +#define FaultingExceptionFrame_FrameOffset 0 .macro GenerateRedirectedStubWithFrame stub, target diff --git a/src/coreclr/vm/arm64/asmhelpers.asm b/src/coreclr/vm/arm64/asmhelpers.asm index e240919a7395f0..3176224cef4d53 100644 --- a/src/coreclr/vm/arm64/asmhelpers.asm +++ b/src/coreclr/vm/arm64/asmhelpers.asm @@ -432,7 +432,7 @@ NoFloatingPointRetVal GBLA ComCallPreStub_ErrorReturnOffset GBLA ComCallPreStub_FirstStackAdjust -ComCallPreStub_FrameSize SETA (SIZEOF__GSCookie + SIZEOF__ComMethodFrame) +ComCallPreStub_FrameSize SETA (SIZEOF__ComMethodFrame) ComCallPreStub_FirstStackAdjust SETA (8 + SIZEOF__ArgumentRegisters + 2 * 8) ; x8, reg args , fp & lr already pushed ComCallPreStub_StackAlloc SETA ComCallPreStub_FrameSize - ComCallPreStub_FirstStackAdjust ComCallPreStub_StackAlloc SETA ComCallPreStub_StackAlloc + SIZEOF__FloatArgumentRegisters + 8; 8 for ErrorReturn @@ -502,7 +502,7 @@ ComCallPreStub_ErrorExit GBLA GenericComCallStub_FrameOffset GBLA GenericComCallStub_FirstStackAdjust -GenericComCallStub_FrameSize SETA (SIZEOF__GSCookie + SIZEOF__ComMethodFrame) +GenericComCallStub_FrameSize SETA (SIZEOF__ComMethodFrame) GenericComCallStub_FirstStackAdjust SETA (8 + SIZEOF__ArgumentRegisters + 2 * 8) GenericComCallStub_StackAlloc SETA GenericComCallStub_FrameSize - GenericComCallStub_FirstStackAdjust GenericComCallStub_StackAlloc SETA GenericComCallStub_StackAlloc + SIZEOF__FloatArgumentRegisters @@ -513,7 +513,7 @@ GenericComCallStub_StackAlloc SETA GenericComCallStub_StackAlloc + 8 GenericComCallStub_FrameOffset SETA (GenericComCallStub_StackAlloc - (SIZEOF__ComMethodFrame - GenericComCallStub_FirstStackAdjust)) - IF (GenericComCallStub_FirstStackAdjust):MOD:16 != 0 + IF (GenericComCallStu_bFirstStackAdjust):MOD:16 != 0 GenericComCallStub_FirstStackAdjust SETA GenericComCallStub_FirstStackAdjust + 8 ENDIF @@ -762,8 +762,8 @@ COMToCLRDispatchHelper_RegSetup GBLA FaultingExceptionFrame_StackAlloc GBLA FaultingExceptionFrame_FrameOffset -FaultingExceptionFrame_StackAlloc SETA (SIZEOF__GSCookie + SIZEOF__FaultingExceptionFrame) -FaultingExceptionFrame_FrameOffset SETA SIZEOF__GSCookie +FaultingExceptionFrame_StackAlloc SETA (SIZEOF__FaultingExceptionFrame) +FaultingExceptionFrame_FrameOffset SETA 0 MACRO GenerateRedirectedStubWithFrame $STUB, $TARGET diff --git a/src/coreclr/vm/arm64/pinvokestubs.S b/src/coreclr/vm/arm64/pinvokestubs.S index dfc3f79831beb0..84bb08bac1463a 100644 --- a/src/coreclr/vm/arm64/pinvokestubs.S +++ b/src/coreclr/vm/arm64/pinvokestubs.S @@ -82,8 +82,7 @@ LOCAL_LABEL(\__PInvokeStubFuncName\()_0): // ------------------------------------------------------------------ // IN: -// InlinedCallFrame (x0) = pointer to the InlinedCallFrame data, including the GS cookie slot (GS cookie right -// before actual InlinedCallFrame data) +// InlinedCallFrame (x0) = pointer to the InlinedCallFrame data // // NESTED_ENTRY JIT_PInvokeBegin, _TEXT, NoHandler @@ -91,10 +90,7 @@ LOCAL_LABEL(\__PInvokeStubFuncName\()_0): PROLOG_SAVE_REG_PAIR_INDEXED fp, lr, -32 PROLOG_SAVE_REG x19, 16 //the stack slot at sp+24 is empty for 16 byte alignment - PREPARE_EXTERNAL_VAR s_gsCookie, x9 - ldr x9, [x9] - str x9, [x0] - add x19, x0, SIZEOF__GSCookie + mov x19, x0 // x19 = pFrame @@ -133,13 +129,11 @@ LOCAL_LABEL(\__PInvokeStubFuncName\()_0): // ------------------------------------------------------------------ // IN: -// InlinedCallFrame (x0) = pointer to the InlinedCallFrame data, including the GS cookie slot (GS cookie right -// before actual InlinedCallFrame data) +// InlinedCallFrame (x0) = pointer to the InlinedCallFrame data // // LEAF_ENTRY JIT_PInvokeEnd, _TEXT - add x0, x0, SIZEOF__GSCookie ldr x1, [x0, #InlinedCallFrame__m_pThread] // x0 = pFrame diff --git a/src/coreclr/vm/assembly.cpp b/src/coreclr/vm/assembly.cpp index e124702167889b..0b4c0f2598aa36 100644 --- a/src/coreclr/vm/assembly.cpp +++ b/src/coreclr/vm/assembly.cpp @@ -1513,7 +1513,7 @@ MethodDesc* Assembly::GetEntryPoint() // This code needs a class init frame, because without it, the // debugger will assume any code that results from searching for a // type handle (ie, loading an assembly) is the first line of a program. - FrameWithCookie __dcimf; + DebuggerClassInitMarkFrame __dcimf; MethodTable * pInitialMT = ClassLoader::LoadTypeDefOrRefThrowing(pModule, mdParent, ClassLoader::ThrowIfNotFound, diff --git a/src/coreclr/vm/callcounting.cpp b/src/coreclr/vm/callcounting.cpp index 33b0839b5213c2..3b2df30ed4cfcc 100644 --- a/src/coreclr/vm/callcounting.cpp +++ b/src/coreclr/vm/callcounting.cpp @@ -774,8 +774,8 @@ PCODE CallCountingManager::OnCallCountThresholdReached(TransitionBlock *transiti CallCountingInfo::From(CallCountingStub::From(stubIdentifyingToken)->GetRemainingCallCountCell())->GetCodeVersion(); MethodDesc *methodDesc = codeVersion.GetMethodDesc(); - FrameWithCookie frameWithCookie(transitionBlock, methodDesc); - CallCountingHelperFrame *frame = &frameWithCookie; + CallCountingHelperFrame callCountingFrame(transitionBlock, methodDesc); + CallCountingHelperFrame *frame = &callCountingFrame; frame->Push(CURRENT_THREAD); INSTALL_MANAGED_EXCEPTION_DISPATCHER; diff --git a/src/coreclr/vm/clrtocomcall.cpp b/src/coreclr/vm/clrtocomcall.cpp index 475ca5a5552c3a..a9505696385123 100644 --- a/src/coreclr/vm/clrtocomcall.cpp +++ b/src/coreclr/vm/clrtocomcall.cpp @@ -713,7 +713,7 @@ UINT32 STDCALL CLRToCOMWorker(TransitionBlock * pTransitionBlock, CLRToCOMCallMe MAKE_CURRENT_THREAD_AVAILABLE(); - FrameWithCookie frame(pTransitionBlock, pMD); + CLRToCOMMethodFrame frame(pTransitionBlock, pMD); CLRToCOMMethodFrame * pFrame = &frame; //we need to zero out the return value buffer because we will report it during GC diff --git a/src/coreclr/vm/comtoclrcall.cpp b/src/coreclr/vm/comtoclrcall.cpp index 67cc42ed5bffba..0f51af428e8b04 100644 --- a/src/coreclr/vm/comtoclrcall.cpp +++ b/src/coreclr/vm/comtoclrcall.cpp @@ -470,9 +470,8 @@ extern "C" UINT64 __stdcall COMToCLRWorker(ComMethodFrame* pFrame) goto ErrorExit; } - // Initialize the frame's VPTR and GS cookie. + // Initialize the frame's identifier. *((TADDR*)pFrame) = (TADDR)FrameIdentifier::ComMethodFrame; - *pFrame->GetGSCookiePtr() = GetProcessGSCookie(); // Link frame into the chain. pFrame->Push(pThread); diff --git a/src/coreclr/vm/dispatchinfo.cpp b/src/coreclr/vm/dispatchinfo.cpp index a0c684b3f97915..652d0927097299 100644 --- a/src/coreclr/vm/dispatchinfo.cpp +++ b/src/coreclr/vm/dispatchinfo.cpp @@ -2164,7 +2164,7 @@ HRESULT DispatchInfo::InvokeMember(SimpleComCallWrapper *pSimpleWrap, DISPID id, // The sole purpose of having this frame is to tell the debugger that we have a catch handler here // which may swallow managed exceptions. The debugger needs this in order to send a // CatchHandlerFound (CHF) notification. - FrameWithCookie catchFrame; + DebuggerU2MCatchHandlerFrame catchFrame; EX_TRY { InvokeMemberDebuggerWrapper(pDispMemberInfo, diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 4aa300584c19f9..24d7461e3d02b9 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -5904,7 +5904,7 @@ EXTERN_C void STDCALL VarargPInvokeStubWorker(TransitionBlock * pTransitionBlock Thread::ObjectRefFlush(CURRENT_THREAD); #endif - FrameWithCookie frame(pTransitionBlock, pMD); + PrestubMethodFrame frame(pTransitionBlock, pMD); PrestubMethodFrame * pFrame = &frame; pFrame->Push(CURRENT_THREAD); @@ -5934,7 +5934,7 @@ EXTERN_C void STDCALL GenericPInvokeCalliStubWorker(TransitionBlock * pTransitio Thread::ObjectRefFlush(CURRENT_THREAD); #endif - FrameWithCookie frame(pTransitionBlock, pVASigCookie, pUnmanagedTarget); + PInvokeCalliFrame frame(pTransitionBlock, pVASigCookie, pUnmanagedTarget); PInvokeCalliFrame * pFrame = &frame; pFrame->Push(CURRENT_THREAD); diff --git a/src/coreclr/vm/eepolicy.cpp b/src/coreclr/vm/eepolicy.cpp index 14157b1f77e697..62909498efe387 100644 --- a/src/coreclr/vm/eepolicy.cpp +++ b/src/coreclr/vm/eepolicy.cpp @@ -615,10 +615,7 @@ void DECLSPEC_NORETURN EEPolicy::HandleFatalStackOverflow(EXCEPTION_POINTERS *pE STRESS_LOG0(LF_EH, LL_INFO100, "In EEPolicy::HandleFatalStackOverflow\n"); - FrameWithCookie fef; -#if defined(FEATURE_EH_FUNCLETS) - *((&fef)->GetGSCookiePtr()) = GetProcessGSCookie(); -#endif // FEATURE_EH_FUNCLETS + FaultingExceptionFrame fef; if (pExceptionInfo->ContextRecord) { GCX_COOP(); diff --git a/src/coreclr/vm/encee.cpp b/src/coreclr/vm/encee.cpp index 250a90eb51eae8..b61b8acdc8bfe2 100644 --- a/src/coreclr/vm/encee.cpp +++ b/src/coreclr/vm/encee.cpp @@ -551,7 +551,7 @@ PCODE EditAndContinueModule::JitUpdatedFunction( MethodDesc *pMD, // so that gc can crawl the stack and do the right thing. _ASSERTE(pOrigContext); Thread *pCurThread = GetThread(); - FrameWithCookie resFrame(pOrigContext); + ResumableFrame resFrame(pOrigContext); resFrame.Push(pCurThread); CONTEXT *pCtxTemp = NULL; diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index a1740a6b1db13b..985310c640a942 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -6258,11 +6258,8 @@ void HandleManagedFaultNew(EXCEPTION_RECORD* pExceptionRecord, CONTEXT* pContext { WRAPPER_NO_CONTRACT; - FrameWithCookie frameWithCookie; - FaultingExceptionFrame *frame = &frameWithCookie; -#if defined(FEATURE_EH_FUNCLETS) - *frame->GetGSCookiePtr() = GetProcessGSCookie(); -#endif // FEATURE_EH_FUNCLETS + FaultingExceptionFrame fef; + FaultingExceptionFrame *frame = &fef; frame->InitAndLink(pContext); Thread *pThread = GetThread(); @@ -6297,11 +6294,8 @@ void HandleManagedFault(EXCEPTION_RECORD* pExceptionRecord, CONTEXT* pContext) WRAPPER_NO_CONTRACT; // Ok. Now we have a brand new fault in jitted code. - FrameWithCookie frameWithCookie; - FaultingExceptionFrame *frame = &frameWithCookie; -#if defined(FEATURE_EH_FUNCLETS) - *frame->GetGSCookiePtr() = GetProcessGSCookie(); -#endif // FEATURE_EH_FUNCLETS + FaultingExceptionFrame fef; + FaultingExceptionFrame *frame = &fef; frame->InitAndLink(pContext); HandleManagedFaultFilterParam param; @@ -6527,7 +6521,7 @@ VEH_ACTION WINAPI CLRVectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo // That IP is an interruptible safe point, so we can suspend right there. interruptedContext->Rip = (uintptr_t)pThread->GetHijackedReturnAddress(); - FrameWithCookie frame(pExceptionInfo->ContextRecord); + ResumableFrame frame(pExceptionInfo->ContextRecord); frame.Push(pThread); CommonTripThread(); frame.Pop(pThread); diff --git a/src/coreclr/vm/exceptionhandling.cpp b/src/coreclr/vm/exceptionhandling.cpp index 4a5ce2504f7f2c..54963e0e2995d2 100644 --- a/src/coreclr/vm/exceptionhandling.cpp +++ b/src/coreclr/vm/exceptionhandling.cpp @@ -1900,11 +1900,6 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification( MethodDesc *pMD = cfThisFrame.GetFunction(); Frame* pFrame = GetLimitFrame(); // next frame to process - if (pFrame != FRAME_TOP) - { - // The following function call sets the GS cookie pointers and checks the cookie. - cfThisFrame.SetCurGSCookie(Frame::SafeGetGSCookiePtr(pFrame)); - } while (((UINT_PTR)pFrame) < uCallerSP) { @@ -5516,8 +5511,7 @@ BOOL HandleHardwareException(PAL_SEHException* ex) #endif // TARGET_AMD64 || TARGET_X86 // Create frame necessary for the exception handling - FrameWithCookie fef; - *((&fef)->GetGSCookiePtr()) = GetProcessGSCookie(); + FaultingExceptionFrame fef; { GCX_COOP(); // Must be cooperative to modify frame chain. diff --git a/src/coreclr/vm/fcall.h b/src/coreclr/vm/fcall.h index fb641548741777..0b362c0cc71696 100644 --- a/src/coreclr/vm/fcall.h +++ b/src/coreclr/vm/fcall.h @@ -525,7 +525,7 @@ LPVOID __FCThrow(LPVOID me, enum RuntimeExceptionKind reKind, UINT resID, LPCWST #endif // !SWIZZLE_STKARG_ORDER -#define HELPER_FRAME_DECL(x) FrameWithCookie __helperframe +#define HELPER_FRAME_DECL(x) HelperMethodFrame_##x##OBJ __helperframe // use the capture state machinery if the architecture has one // diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index 21aa8ce7045f40..f3868971585816 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -280,14 +280,6 @@ void __stdcall Frame::LogTransition(Frame* frame) GC_NOTRIGGER; } CONTRACTL_END; -#ifdef TARGET_X86 - // On x86, StubLinkerCPU::EmitMethodStubProlog calls Frame::LogTransition - // but the caller of EmitMethodStubProlog sets the GSCookie later on. - // So the cookie is not initialized by the point we get here. -#else - _ASSERTE(*frame->GetGSCookiePtr() == GetProcessGSCookie()); -#endif - if (Frame::ShouldLogTransitions()) frame->Log(); } // void Frame::Log() @@ -469,26 +461,6 @@ bool Frame::HasValidVTablePtr(Frame * pFrame) #endif } -// Returns the location of the expected GSCookie, -// Return NULL if the frame's vtable pointer is corrupt -// -// Note that Frame::GetGSCookiePtr is a virtual method, -// and so it cannot be used without first checking if -// the vtable is valid. - -// static -PTR_GSCookie Frame::SafeGetGSCookiePtr(Frame * pFrame) -{ - WRAPPER_NO_CONTRACT; - - _ASSERTE(pFrame != FRAME_TOP); - - if (Frame::HasValidVTablePtr(pFrame)) - return pFrame->GetGSCookiePtr(); - else - return NULL; -} - //----------------------------------------------------------------------- #ifndef DACCESS_COMPILE //----------------------------------------------------------------------- @@ -518,8 +490,6 @@ VOID Frame::Push(Thread *pThread) } CONTRACTL_END; - _ASSERTE(*GetGSCookiePtr() == GetProcessGSCookie()); - m_Next = pThread->GetFrame(); // GetOsPageSize() is used to relax the assert for cases where two Frames are @@ -539,7 +509,7 @@ VOID Frame::Push(Thread *pThread) // during stack-walking. !g_pConfig->fAssertOnFailFast() || (m_Next == FRAME_TOP) || - (*m_Next->GetGSCookiePtr() == GetProcessGSCookie())); + (Frame::HasValidVTablePtr(m_Next))); pThread->SetFrame(this); } @@ -568,7 +538,6 @@ VOID Frame::Pop(Thread *pThread) CONTRACTL_END; _ASSERTE(pThread->GetFrame() == this && "Popping a frame out of order ?"); - _ASSERTE(*GetGSCookiePtr() == GetProcessGSCookie()); _ASSERTE(// If AssertOnFailFast is set, the test expects to do stack overrun // corruptions. In that case, the Frame chain may be corrupted, // and the rest of the assert is not valid. @@ -576,7 +545,7 @@ VOID Frame::Pop(Thread *pThread) // during stack-walking. !g_pConfig->fAssertOnFailFast() || (m_Next == FRAME_TOP) || - (*m_Next->GetGSCookiePtr() == GetProcessGSCookie())); + (Frame::HasValidVTablePtr(m_Next))); pThread->SetFrame(m_Next); m_Next = NULL; @@ -1035,7 +1004,6 @@ ComPrestubMethodFrame::Init() // at offset 0 for a class not using MI, but this is no different // than the assumption that COM Classic makes. *((TADDR*)this) = (TADDR)FrameIdentifier::ComPrestubMethodFrame; - *GetGSCookiePtr() = GetProcessGSCookie(); } #endif // FEATURE_COMINTEROP @@ -1822,11 +1790,6 @@ void HelperMethodFrame::Push() // Finish initialization // - // Compiler would not inline GetGSCookiePtr() because of it is virtual method. - // Inline it manually and verify that it gives same result. - _ASSERTE(GetGSCookiePtr() == (((GSCookie *)(this)) - 1)); - *(((GSCookie *)(this)) - 1) = GetProcessGSCookie(); - _ASSERTE(!m_MachState.isValid()); Thread * pThread = ::GetThread(); @@ -2025,12 +1988,6 @@ VOID InlinedCallFrame::Init() *((TADDR *)this) = (TADDR)FrameIdentifier::InlinedCallFrame; - // GetGSCookiePtr contains a virtual call and this is a perf critical method so we don't want to call it in ret builds - GSCookie *ptrGS = (GSCookie *)((BYTE *)this - sizeof(GSCookie)); - _ASSERTE(ptrGS == GetGSCookiePtr()); - - *ptrGS = GetProcessGSCookie(); - m_Datum = NULL; m_pCallSiteSP = NULL; m_pCallerReturnAddress = (TADDR)NULL; diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index cfbc859d1fd43b..447208e8255aa3 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -437,20 +437,7 @@ class Frame : public FrameBase } #endif // #ifndef DACCESS_COMPILE - PTR_GSCookie GetGSCookiePtr() - { - WRAPPER_NO_CONTRACT; - return dac_cast(dac_cast(this) + GetOffsetOfGSCookie()); - } - - static int GetOffsetOfGSCookie() - { - LIMITED_METHOD_DAC_CONTRACT; - return -(int)sizeof(GSCookie); - } - static bool HasValidVTablePtr(Frame * pFrame); - static PTR_GSCookie SafeGetGSCookiePtr(Frame * pFrame); static void Init(); // Callers, note that the REGDISPLAY parameter is actually in/out. While @@ -559,12 +546,6 @@ class Frame : public FrameBase { func->EnumMemoryRegions(flags); } - - // Include the NegSpace - GSCookie * pGSCookie = GetGSCookiePtr(); - _ASSERTE(FitsIn(PBYTE(pGSCookie) - PBYTE(this))); - ULONG32 negSpaceSize = static_cast(PBYTE(pGSCookie) - PBYTE(this)); - DacEnumMemoryRegion(dac_cast(this) - negSpaceSize, negSpaceSize); } #endif @@ -2825,169 +2806,6 @@ class AssumeByrefFromJITStack : public Frame #endif //_DEBUG -//----------------------------------------------------------------------------- -// FrameWithCookie is used to declare a Frame in source code with a cookie -// immediately preceding it. -// This is just a specialized version of GSCookieFor -// -// For Frames that are set up by stubs, the stub is responsible for setting up -// the GSCookie. -// -// Note that we have to play all these games for the GSCookie as the GSCookie -// needs to precede the vtable pointer, so that the GSCookie is guaranteed to -// catch any stack-buffer-overrun corruptions that overwrite the Frame data. -// -//----------------------------------------------------------------------------- - -class DebuggerEval; - -class GCSafeCollection; - -template -class FrameWithCookie -{ -protected: - - GSCookie m_gsCookie; - FrameType m_frame; - -public: - - // - // Overload all the required constructors - // - - FrameWithCookie() : - m_gsCookie(GetProcessGSCookie()), m_frame() { WRAPPER_NO_CONTRACT; } - - FrameWithCookie(Thread * pThread) : - m_gsCookie(GetProcessGSCookie()), m_frame(pThread) { WRAPPER_NO_CONTRACT; } - - FrameWithCookie(T_CONTEXT * pContext) : - m_gsCookie(GetProcessGSCookie()), m_frame(pContext) { WRAPPER_NO_CONTRACT; } - - FrameWithCookie(TransitionBlock * pTransitionBlock) : - m_gsCookie(GetProcessGSCookie()), m_frame(pTransitionBlock) { WRAPPER_NO_CONTRACT; } - - FrameWithCookie(TransitionBlock * pTransitionBlock, MethodDesc * pMD) : - m_gsCookie(GetProcessGSCookie()), m_frame(pTransitionBlock, pMD) { WRAPPER_NO_CONTRACT; } - - FrameWithCookie(TransitionBlock * pTransitionBlock, VASigCookie * pVASigCookie, PCODE pUnmanagedTarget) : - m_gsCookie(GetProcessGSCookie()), m_frame(pTransitionBlock, pVASigCookie, pUnmanagedTarget) { WRAPPER_NO_CONTRACT; } - - FrameWithCookie(TransitionBlock * pTransitionBlock, int frameFlags) : - m_gsCookie(GetProcessGSCookie()), m_frame(pTransitionBlock, frameFlags) { WRAPPER_NO_CONTRACT; } - - - // GCFrame - FrameWithCookie(Thread * pThread, OBJECTREF *pObjRefs, UINT numObjRefs, BOOL maybeInterior) : - m_gsCookie(GetProcessGSCookie()), m_frame(pThread, pObjRefs, numObjRefs, maybeInterior) { WRAPPER_NO_CONTRACT; } - - FrameWithCookie(OBJECTREF *pObjRefs, UINT numObjRefs, BOOL maybeInterior) : - m_gsCookie(GetProcessGSCookie()), m_frame(pObjRefs, numObjRefs, maybeInterior) { WRAPPER_NO_CONTRACT; } - - // GCSafeCollectionFrame - FrameWithCookie(GCSafeCollection *gcSafeCollection) : - m_gsCookie(GetProcessGSCookie()), m_frame(gcSafeCollection) { WRAPPER_NO_CONTRACT; } - - // HijackFrame - FrameWithCookie(LPVOID returnAddress, Thread *thread, HijackArgs *args) : - m_gsCookie(GetProcessGSCookie()), m_frame(returnAddress, thread, args) { WRAPPER_NO_CONTRACT; } - -#ifdef DEBUGGING_SUPPORTED - // FuncEvalFrame - FrameWithCookie(DebuggerEval *pDebuggerEval, TADDR returnAddress, BOOL showFrame) : - m_gsCookie(GetProcessGSCookie()), m_frame(pDebuggerEval, returnAddress, showFrame) { WRAPPER_NO_CONTRACT; } -#endif // DEBUGGING_SUPPORTED - -#ifndef DACCESS_COMPILE - // GSCookie for HelperMethodFrames is initialized in a common HelperMethodFrame init method - - // HelperMethodFrame - FORCEINLINE FrameWithCookie(void* fCallFtnEntry, unsigned attribs = 0) : - m_frame(fCallFtnEntry, attribs) { WRAPPER_NO_CONTRACT; } - - // HelperMethodFrame_1OBJ - FORCEINLINE FrameWithCookie(void* fCallFtnEntry, unsigned attribs, OBJECTREF * aGCPtr1) : - m_frame(fCallFtnEntry, attribs, aGCPtr1) { WRAPPER_NO_CONTRACT; } - - // HelperMethodFrame_2OBJ - FORCEINLINE FrameWithCookie(void* fCallFtnEntry, unsigned attribs, OBJECTREF * aGCPtr1, OBJECTREF * aGCPtr2) : - m_frame(fCallFtnEntry, attribs, aGCPtr1, aGCPtr2) { WRAPPER_NO_CONTRACT; } - - // HelperMethodFrame_3OBJ - FORCEINLINE FrameWithCookie(void* fCallFtnEntry, unsigned attribs, OBJECTREF * aGCPtr1, OBJECTREF * aGCPtr2, OBJECTREF * aGCPtr3) : - m_frame(fCallFtnEntry, attribs, aGCPtr1, aGCPtr2, aGCPtr3) { WRAPPER_NO_CONTRACT; } - - // HelperMethodFrame_PROTECTOBJ - FORCEINLINE FrameWithCookie(void* fCallFtnEntry, unsigned attribs, OBJECTREF* pObjRefs, int numObjRefs) : - m_frame(fCallFtnEntry, attribs, pObjRefs, numObjRefs) { WRAPPER_NO_CONTRACT; } - -#endif // DACCESS_COMPILE - - // ProtectByRefsFrame - FrameWithCookie(Thread * pThread, ByRefInfo * pByRefs) : - m_gsCookie(GetProcessGSCookie()), m_frame(pThread, pByRefs) { WRAPPER_NO_CONTRACT; } - - // ProtectValueClassFrame - FrameWithCookie(Thread * pThread, ValueClassInfo * pValueClasses) : - m_gsCookie(GetProcessGSCookie()), m_frame(pThread, pValueClasses) { WRAPPER_NO_CONTRACT; } - - // ExceptionFilterFrame - FrameWithCookie(size_t* pShadowSP) : - m_gsCookie(GetProcessGSCookie()), m_frame(pShadowSP) { WRAPPER_NO_CONTRACT; } - -#ifdef _DEBUG - // AssumeByrefFromJITStack - FrameWithCookie(OBJECTREF *pObjRef) : - m_gsCookie(GetProcessGSCookie()), m_frame(pObjRef) { WRAPPER_NO_CONTRACT; } - - void SetAddrOfHaveCheckedRestoreState(BOOL* pDoneCheck) - { - WRAPPER_NO_CONTRACT; - m_frame.SetAddrOfHaveCheckedRestoreState(pDoneCheck); - } - -#endif //_DEBUG - - // - // Overload some common Frame methods for easy redirection - // - - void Push() { WRAPPER_NO_CONTRACT; m_frame.Push(); } - void Pop() { WRAPPER_NO_CONTRACT; m_frame.Pop(); } - void Push(Thread * pThread) { WRAPPER_NO_CONTRACT; m_frame.Push(pThread); } - void Pop(Thread * pThread) { WRAPPER_NO_CONTRACT; m_frame.Pop(pThread); } - PCODE GetReturnAddress() { WRAPPER_NO_CONTRACT; return m_frame.GetReturnAddress(); } - T_CONTEXT * GetContext() { WRAPPER_NO_CONTRACT; return m_frame.GetContext(); } - FrameType* operator&() { LIMITED_METHOD_CONTRACT; return &m_frame; } - LazyMachState * MachineState() { WRAPPER_NO_CONTRACT; return m_frame.MachineState(); } - Thread * GetThread() { WRAPPER_NO_CONTRACT; return m_frame.GetThread(); } - BOOL EnsureInit(struct MachState* unwindState) - { WRAPPER_NO_CONTRACT; return m_frame.EnsureInit(unwindState); } - void Poll() { WRAPPER_NO_CONTRACT; m_frame.Poll(); } - void SetStackPointerPtr(TADDR sp) { WRAPPER_NO_CONTRACT; m_frame.SetStackPointerPtr(sp); } - void InitAndLink(T_CONTEXT *pContext) { WRAPPER_NO_CONTRACT; m_frame.InitAndLink(pContext); } - void InitAndLink(Thread *pThread) { WRAPPER_NO_CONTRACT; m_frame.InitAndLink(pThread); } - void Init(Thread *pThread, OBJECTREF *pObjRefs, UINT numObjRefs, BOOL maybeInterior) - { WRAPPER_NO_CONTRACT; m_frame.Init(pThread, pObjRefs, numObjRefs, maybeInterior); } - ValueClassInfo ** GetValueClassInfoList() { WRAPPER_NO_CONTRACT; return m_frame.GetValueClassInfoList(); } - -#if 0 - // - // Access to the underlying Frame - // You should only need to use this if none of the above overloads work for you - // Consider adding the required overload to the list above - // - - FrameType& operator->() { LIMITED_METHOD_CONTRACT; return m_frame; } -#endif - - // Since the "&" operator is overloaded, use this function to get to the - // address of FrameWithCookie, rather than that of FrameWithCookie::m_frame. - GSCookie * GetGSCookiePtr() { LIMITED_METHOD_CONTRACT; return &m_gsCookie; } -}; - //------------------------------------------------------------------------ // These macros GC-protect OBJECTREF pointers on the EE's behalf. // In between these macros, the GC can move but not discard the protected @@ -3124,7 +2942,7 @@ class FrameWithCookie /*pointer points to GC heap, the FCall still needs to protect it explicitly */ \ ASSERT_ADDRESS_IN_STACK (__objRef); \ do { \ - FrameWithCookie __dummyAssumeByrefFromJITStack ((__objRef)); \ + AssumeByrefFromJITStack __dummyAssumeByrefFromJITStack ((__objRef)); \ __dummyAssumeByrefFromJITStack.Push (); \ /* work around unreachable code warning */ \ if (true) { DEBUG_ASSURE_NO_RETURN_BEGIN(GC_PROTECT) diff --git a/src/coreclr/vm/gccover.cpp b/src/coreclr/vm/gccover.cpp index 3df7fe4448322f..0ab784723c291b 100644 --- a/src/coreclr/vm/gccover.cpp +++ b/src/coreclr/vm/gccover.cpp @@ -864,7 +864,7 @@ void DoGcStress (PCONTEXT regs, NativeCodeVersion nativeCodeVersion) // If we redirect for gc stress, we don't need this frame on the stack, // the redirection will push a resumable frame. // - FrameWithCookie frame(regs); + ResumableFrame frame(regs); if (!Thread::UseRedirectForGcStress()) { frame.Push(pThread); @@ -1179,7 +1179,7 @@ void DoGcStress (PCONTEXT regs, NativeCodeVersion nativeCodeVersion) // If we redirect for gc stress, we don't need this frame on the stack, // the redirection will push a resumable frame. // - FrameWithCookie frame(regs); + ResumableFrame frame(regs); if (!Thread::UseRedirectForGcStress()) { frame.Push(pThread); diff --git a/src/coreclr/vm/i386/PInvokeStubs.asm b/src/coreclr/vm/i386/PInvokeStubs.asm index b014f150a45fd2..67262c8b093b9a 100644 --- a/src/coreclr/vm/i386/PInvokeStubs.asm +++ b/src/coreclr/vm/i386/PInvokeStubs.asm @@ -20,7 +20,6 @@ option casemap:none .code -extern _s_gsCookie:DWORD extern _g_TrapReturningThreads:DWORD extern _JIT_PInvokeEndRarePath@0:proc @@ -36,10 +35,6 @@ extern _JIT_PInvokeEndRarePath@0:proc ; _JIT_PInvokeBegin@4 PROC public - mov eax, dword ptr [_s_gsCookie] - mov dword ptr [ecx], eax - add ecx, SIZEOF_GSCookie - ;; set first slot to the value of InlinedCallFrame identifier (checked by runtime code) mov dword ptr [ecx], FRAMETYPE_InlinedCallFrame @@ -79,8 +74,6 @@ _JIT_PInvokeBegin@4 ENDP ; _JIT_PInvokeEnd@4 PROC public - add ecx, SIZEOF_GSCookie - ;; edx = GetThread(). Trashes eax INLINE_GETTHREAD edx, eax diff --git a/src/coreclr/vm/i386/asmhelpers.asm b/src/coreclr/vm/i386/asmhelpers.asm index 2f1d12c6d9a71e..a9bdb330f6b644 100644 --- a/src/coreclr/vm/i386/asmhelpers.asm +++ b/src/coreclr/vm/i386/asmhelpers.asm @@ -1222,14 +1222,12 @@ _GenericComCallStub@0 proc public push edi push eax ; UnmanagedToManagedFrame::m_pvDatum = ComCallMethodDesc* - sub esp, (SIZEOF_GSCookie + OFFSETOF__UnmanagedToManagedFrame__m_pvDatum) + sub esp, OFFSETOF__UnmanagedToManagedFrame__m_pvDatum - lea eax, [esp+SIZEOF_GSCookie] - - push eax + push esp call _COMToCLRWorker@4 - add esp, (SIZEOF_GSCookie + OFFSETOF__UnmanagedToManagedFrame__m_pvDatum) + add esp, OFFSETOF__UnmanagedToManagedFrame__m_pvDatum ; pop the ComCallMethodDesc* pop ecx @@ -1272,7 +1270,7 @@ _ComCallPreStub@0 proc public push edi push eax ; ComCallMethodDesc* - sub esp, 5*4 ; next, vtable, gscookie, 64-bit error return + sub esp, 4*4 ; next, vtable, 64-bit error return lea edi, [esp] lea esi, [esp+3*4] diff --git a/src/coreclr/vm/i386/cgenx86.cpp b/src/coreclr/vm/i386/cgenx86.cpp index 1d13b59dd14bd6..9ddd7c4b3e6833 100644 --- a/src/coreclr/vm/i386/cgenx86.cpp +++ b/src/coreclr/vm/i386/cgenx86.cpp @@ -883,10 +883,6 @@ Stub *GenerateInitPInvokeFrameHelper() // mov esi, GetThread() psl->X86EmitCurrentThreadFetch(kESI, (1 << kEDI) | (1 << kEBX) | (1 << kECX) | (1 << kEDX)); - // mov [edi + FrameInfo.offsetOfGSCookie], GetProcessGSCookie() - psl->X86EmitOffsetModRM(0xc7, (X86Reg)0x0, kEDI, FrameInfo.offsetOfGSCookie - negSpace); - psl->Emit32(GetProcessGSCookie()); - // mov [edi + FrameInfo.offsetOfFrameVptr], InlinedCallFrame::GetFrameVtable() psl->X86EmitOffsetModRM(0xc7, (X86Reg)0x0, kEDI, FrameInfo.offsetOfFrameVptr - negSpace); psl->Emit32((DWORD)FrameIdentifier::InlinedCallFrame); diff --git a/src/coreclr/vm/i386/excepx86.cpp b/src/coreclr/vm/i386/excepx86.cpp index 47c6cd85993b57..84410a0937bc8a 100644 --- a/src/coreclr/vm/i386/excepx86.cpp +++ b/src/coreclr/vm/i386/excepx86.cpp @@ -651,7 +651,7 @@ CPFH_RealFirstPassHandler( // ExceptionContinueSearch, etc. #if defined(USE_FEF) BOOL bPopFaultingExceptionFrame = FALSE; - FrameWithCookie faultingExceptionFrame; + FaultingExceptionFrame faultingExceptionFrame; #endif // USE_FEF ExInfo* pExInfo = &(pThread->GetExceptionState()->m_currentExInfo); @@ -3115,7 +3115,7 @@ int CallJitEHFilter(CrawlFrame* pCf, BYTE* startPC, EE_ILEXCEPTION_CLAUSE *EHCla // GC holes. The stack would be in inconsistent state when we trigger gc just before // returning from UnwindFrames. - FrameWithCookie exceptionFilterFrame(pShadowSP); + ExceptionFilterFrame exceptionFilterFrame(pShadowSP); ETW::ExceptionLog::ExceptionFilterBegin(pCf->GetCodeInfo()->GetMethodDesc(), (PVOID)pCf->GetCodeInfo()->GetStartAddress()); diff --git a/src/coreclr/vm/i386/jithelp.asm b/src/coreclr/vm/i386/jithelp.asm index 54fce3385044c9..49be25decdb992 100644 --- a/src/coreclr/vm/i386/jithelp.asm +++ b/src/coreclr/vm/i386/jithelp.asm @@ -60,7 +60,6 @@ EXTERN JIT_TailCallHelper:PROC endif EXTERN _g_TailCallFrameVptr:DWORD EXTERN @JIT_FailFast@0:PROC -EXTERN _s_gsCookie:DWORD EXTERN g_pPollGC:DWORD EXTERN g_TrapReturningThreads:DWORD @@ -724,25 +723,17 @@ VSDHelperLabel: ; m_CallerAddress ; m_pThread ; vtbl -; GSCookie ; &VSDHelperLabel OffsetOfTailCallFrame = 8 ; ebx = pThread -ifdef _DEBUG - mov esi, _s_gsCookie ; GetProcessGSCookie() - cmp dword ptr [esp+OffsetOfTailCallFrame-SIZEOF_GSCookie], esi - je TailCallFrameGSCookieIsValid - call @JIT_FailFast@0 - TailCallFrameGSCookieIsValid: -endif ; remove the padding frame from the chain mov esi, dword ptr [esp+OffsetOfTailCallFrame+4] ; esi = TailCallFrame::m_Next mov dword ptr [ebx + Thread_m_pFrame], esi ; skip the frame - add esp, 20 ; &VSDHelperLabel, GSCookie, vtbl, m_Next, m_CallerAddress + add esp, 16 ; &VSDHelperLabel, vtbl, m_Next, m_CallerAddress pop edi ; restore callee saved registers pop esi @@ -914,7 +905,7 @@ VSDTailCall: ; If there is sufficient space, we will setup the frame and then slide ; the arguments up the stack. Else, we first need to slide the arguments ; down the stack to make space for the TailCallFrame - sub edi, (SIZEOF_GSCookie + SIZEOF_TailCallFrame) + sub edi, (SIZEOF_TailCallFrame) cmp edi, esi jae VSDSpaceForFrameChecked @@ -954,29 +945,26 @@ VSDSpaceForFrameChecked: ; At this point, we have enough space on the stack for the TailCallFrame, ; and we may already have slided down the arguments - mov eax, _s_gsCookie ; GetProcessGSCookie() - mov dword ptr [edi], eax ; set GSCookie mov eax, _g_TailCallFrameVptr ; vptr mov edx, dword ptr [esp+OrigRetAddr] ; orig return address - mov dword ptr [edi+SIZEOF_GSCookie], eax ; TailCallFrame::vptr - mov dword ptr [edi+SIZEOF_GSCookie+28], edx ; TailCallFrame::m_ReturnAddress + mov dword ptr [edi], eax ; TailCallFrame::vptr + mov dword ptr [edi+28], edx ; TailCallFrame::m_ReturnAddress mov eax, dword ptr [esp+CallersEdi] ; restored edi mov edx, dword ptr [esp+CallersEsi] ; restored esi - mov dword ptr [edi+SIZEOF_GSCookie+12], eax ; TailCallFrame::m_regs::edi - mov dword ptr [edi+SIZEOF_GSCookie+16], edx ; TailCallFrame::m_regs::esi - mov dword ptr [edi+SIZEOF_GSCookie+20], ebx ; TailCallFrame::m_regs::ebx - mov dword ptr [edi+SIZEOF_GSCookie+24], ebp ; TailCallFrame::m_regs::ebp + mov dword ptr [edi+12], eax ; TailCallFrame::m_regs::edi + mov dword ptr [edi+16], edx ; TailCallFrame::m_regs::esi + mov dword ptr [edi+20], ebx ; TailCallFrame::m_regs::ebx + mov dword ptr [edi+24], ebp ; TailCallFrame::m_regs::ebp mov ebx, dword ptr [esp+pThread] ; ebx = pThread mov eax, dword ptr [ebx+Thread_m_pFrame] - lea edx, [edi+SIZEOF_GSCookie] - mov dword ptr [edi+SIZEOF_GSCookie+4], eax ; TailCallFrame::m_pNext - mov dword ptr [ebx+Thread_m_pFrame], edx ; hook the new frame into the chain + mov dword ptr [edi+4], eax ; TailCallFrame::m_pNext + mov dword ptr [ebx+Thread_m_pFrame], edi ; hook the new frame into the chain ; setup ebp chain - lea ebp, [edi+SIZEOF_GSCookie+24] ; TailCallFrame::m_regs::ebp + lea ebp, [edi+24] ; TailCallFrame::m_regs::ebp ; Do not copy arguments again if they are in place already ; Otherwise, we will need to slide the new arguments up the stack @@ -987,7 +975,7 @@ VSDSpaceForFrameChecked: ; or the TailCallFrame is a perfect fit ; set the caller address mov edx, dword ptr [esp+ExtraSpace+RetAddr] ; caller address - mov dword ptr [edi+SIZEOF_GSCookie+8], edx ; TailCallFrame::m_CallerAddress + mov dword ptr [edi+8], edx ; TailCallFrame::m_CallerAddress ; adjust edi as it would by copying neg ecx @@ -998,7 +986,7 @@ VSDSpaceForFrameChecked: VSDTailCallFrameInserted_DoSlideUpArgs: ; set the caller address mov edx, dword ptr [esp+ExtraSpace+RetAddr] ; caller address - mov dword ptr [edi+SIZEOF_GSCookie+8], edx ; TailCallFrame::m_CallerAddress + mov dword ptr [edi+8], edx ; TailCallFrame::m_CallerAddress ; copy the arguments to the final destination test ecx, ecx diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index eeac550b3c0979..23d9b68f34370f 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -1826,8 +1826,7 @@ HCIMPL1(void, IL_Throw, Object* obj) { Thread *pThread = GetThread(); - FrameWithCookie exceptionFrame; - *(&exceptionFrame)->GetGSCookiePtr() = GetProcessGSCookie(); + SoftwareExceptionFrame exceptionFrame; RtlCaptureContext(exceptionFrame.GetContext()); exceptionFrame.InitAndLink(pThread); @@ -1917,8 +1916,7 @@ HCIMPL0(void, IL_Rethrow) { Thread *pThread = GetThread(); - FrameWithCookie exceptionFrame; - *(&exceptionFrame)->GetGSCookiePtr() = GetProcessGSCookie(); + SoftwareExceptionFrame exceptionFrame; RtlCaptureContext(exceptionFrame.GetContext()); exceptionFrame.InitAndLink(pThread); diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index e284b74639202c..c62f93fcc1eedb 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -10132,19 +10132,19 @@ void InlinedCallFrame::GetEEInfo(CORINFO_EE_INFO::InlinedCallFrameInfo *pInfo) { LIMITED_METHOD_CONTRACT; - pInfo->size = sizeof(GSCookie) + sizeof(InlinedCallFrame); - pInfo->sizeWithSecretStubArg = sizeof(GSCookie) + sizeof(InlinedCallFrame) + sizeof(PTR_VOID); - - pInfo->offsetOfGSCookie = 0; - pInfo->offsetOfFrameVptr = sizeof(GSCookie); - pInfo->offsetOfFrameLink = sizeof(GSCookie) + Frame::GetOffsetOfNextLink(); - pInfo->offsetOfCallSiteSP = sizeof(GSCookie) + offsetof(InlinedCallFrame, m_pCallSiteSP); - pInfo->offsetOfCalleeSavedFP = sizeof(GSCookie) + offsetof(InlinedCallFrame, m_pCalleeSavedFP); - pInfo->offsetOfCallTarget = sizeof(GSCookie) + offsetof(InlinedCallFrame, m_Datum); - pInfo->offsetOfReturnAddress = sizeof(GSCookie) + offsetof(InlinedCallFrame, m_pCallerReturnAddress); - pInfo->offsetOfSecretStubArg = sizeof(GSCookie) + sizeof(InlinedCallFrame); + pInfo->size = sizeof(InlinedCallFrame); + pInfo->sizeWithSecretStubArg = sizeof(InlinedCallFrame) + sizeof(PTR_VOID); + + pInfo->offsetOfGSCookie = 0; // We no longer have a GS Cookie on coreclr for InlinedCallFrame + pInfo->offsetOfFrameVptr = 0; + pInfo->offsetOfFrameLink = Frame::GetOffsetOfNextLink(); + pInfo->offsetOfCallSiteSP = offsetof(InlinedCallFrame, m_pCallSiteSP); + pInfo->offsetOfCalleeSavedFP = offsetof(InlinedCallFrame, m_pCalleeSavedFP); + pInfo->offsetOfCallTarget = offsetof(InlinedCallFrame, m_Datum); + pInfo->offsetOfReturnAddress = offsetof(InlinedCallFrame, m_pCallerReturnAddress); + pInfo->offsetOfSecretStubArg = sizeof(InlinedCallFrame); #ifdef TARGET_ARM - pInfo->offsetOfSPAfterProlog = sizeof(GSCookie) + offsetof(InlinedCallFrame, m_pSPAfterProlog); + pInfo->offsetOfSPAfterProlog = offsetof(InlinedCallFrame, m_pSPAfterProlog); #endif // TARGET_ARM } diff --git a/src/coreclr/vm/loongarch64/asmhelpers.S b/src/coreclr/vm/loongarch64/asmhelpers.S index 6be20320f9850c..e6c70e9638bfa4 100644 --- a/src/coreclr/vm/loongarch64/asmhelpers.S +++ b/src/coreclr/vm/loongarch64/asmhelpers.S @@ -599,8 +599,8 @@ NESTED_ENTRY TheUMEntryPrestub, _TEXT, UnhandledExceptionHandlerUnix NESTED_END TheUMEntryPrestub, _TEXT // Make sure the `FaultingExceptionFrame_StackAlloc` is 16-byte aligned. -#define FaultingExceptionFrame_StackAlloc (SIZEOF__GSCookie + SIZEOF__FaultingExceptionFrame + 0x8) -#define FaultingExceptionFrame_FrameOffset SIZEOF__GSCookie +#define FaultingExceptionFrame_StackAlloc (SIZEOF__FaultingExceptionFrame) +#define FaultingExceptionFrame_FrameOffset 0 .macro GenerateRedirectedStubWithFrame stub, target diff --git a/src/coreclr/vm/loongarch64/pinvokestubs.S b/src/coreclr/vm/loongarch64/pinvokestubs.S index b2531cfd34bf2b..edd2672525f2c2 100644 --- a/src/coreclr/vm/loongarch64/pinvokestubs.S +++ b/src/coreclr/vm/loongarch64/pinvokestubs.S @@ -76,8 +76,7 @@ // ------------------------------------------------------------------ // IN: -// InlinedCallFrame ($a0) = pointer to the InlinedCallFrame data, including the GS cookie slot (GS cookie right -// before actual InlinedCallFrame data) +// InlinedCallFrame ($a0) = pointer to the InlinedCallFrame data // // NESTED_ENTRY JIT_PInvokeBegin, _TEXT, NoHandler @@ -87,10 +86,7 @@ NESTED_ENTRY JIT_PInvokeBegin, _TEXT, NoHandler // $s0=23. PROLOG_SAVE_REG 23, 16 //the stack slot at $sp+24 is empty for 16 byte alignment - PREPARE_EXTERNAL_VAR s_gsCookie, $t0 - ld.d $t4, $t0, 0 - st.d $t4, $a0, 0 - addi.d $s0, $a0, SIZEOF__GSCookie + mv.d $s0, $a0 // s0 = pFrame // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) @@ -135,7 +131,6 @@ NESTED_END JIT_PInvokeBegin, _TEXT // LEAF_ENTRY JIT_PInvokeEnd, _TEXT - addi.d $a0, $a0, SIZEOF__GSCookie ld.d $a1, $a0, InlinedCallFrame__m_pThread // $a0 = pFrame // $a1 = pThread diff --git a/src/coreclr/vm/prestub.cpp b/src/coreclr/vm/prestub.cpp index a816f93b50c13b..bc5b2381bb7d05 100644 --- a/src/coreclr/vm/prestub.cpp +++ b/src/coreclr/vm/prestub.cpp @@ -2613,7 +2613,7 @@ extern "C" PCODE STDCALL PreStubWorker(TransitionBlock* pTransitionBlock, Method Thread::ObjectRefFlush(CURRENT_THREAD); #endif - FrameWithCookie frame(pTransitionBlock, pMD); + PrestubMethodFrame frame(pTransitionBlock, pMD); PrestubMethodFrame* pPFrame = &frame; pPFrame->Push(CURRENT_THREAD); @@ -3104,7 +3104,7 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl Thread::ObjectRefFlush(CURRENT_THREAD); #endif - FrameWithCookie frame(pTransitionBlock); + ExternalMethodFrame frame(pTransitionBlock); ExternalMethodFrame * pEMFrame = &frame; #if defined(TARGET_X86) || defined(TARGET_AMD64) @@ -4056,7 +4056,7 @@ extern "C" SIZE_T STDCALL DynamicHelperWorker(TransitionBlock * pTransitionBlock Thread::ObjectRefFlush(CURRENT_THREAD); #endif - FrameWithCookie frame(pTransitionBlock, frameFlags); + DynamicHelperFrame frame(pTransitionBlock, frameFlags); DynamicHelperFrame * pFrame = &frame; pFrame->Push(CURRENT_THREAD); diff --git a/src/coreclr/vm/reflectioninvocation.cpp b/src/coreclr/vm/reflectioninvocation.cpp index 8fa0bbd817d55c..4637d307e0e384 100644 --- a/src/coreclr/vm/reflectioninvocation.cpp +++ b/src/coreclr/vm/reflectioninvocation.cpp @@ -416,7 +416,7 @@ extern "C" void QCALLTYPE RuntimeMethodHandle_InvokeMethod( GCStress::MaybeTrigger(); - FrameWithCookie *pProtectValueClassFrame = NULL; + ProtectValueClassFrame *pProtectValueClassFrame = NULL; ValueClassInfo *pValueClasses = NULL; // if we have the magic Value Class return, we need to allocate that class @@ -565,8 +565,8 @@ extern "C" void QCALLTYPE RuntimeMethodHandle_InvokeMethod( if (pValueClasses != NULL) { - pProtectValueClassFrame = new (_alloca (sizeof (FrameWithCookie))) - FrameWithCookie(pThread, pValueClasses); + pProtectValueClassFrame = new (_alloca (sizeof (ProtectValueClassFrame))) + ProtectValueClassFrame(pThread, pValueClasses); } // Call the method diff --git a/src/coreclr/vm/riscv64/asmhelpers.S b/src/coreclr/vm/riscv64/asmhelpers.S index 12b2918ae31e63..f7c58b533e185b 100644 --- a/src/coreclr/vm/riscv64/asmhelpers.S +++ b/src/coreclr/vm/riscv64/asmhelpers.S @@ -508,8 +508,8 @@ NESTED_ENTRY TheUMEntryPrestub, _TEXT, UnhandledExceptionHandlerUnix NESTED_END TheUMEntryPrestub, _TEXT // Make sure the `FaultingExceptionFrame_StackAlloc` is 16-byte aligned. -#define FaultingExceptionFrame_StackAlloc (SIZEOF__GSCookie + SIZEOF__FaultingExceptionFrame + 0x8) -#define FaultingExceptionFrame_FrameOffset SIZEOF__GSCookie +#define FaultingExceptionFrame_StackAlloc (SIZEOF__FaultingExceptionFrame) +#define FaultingExceptionFrame_FrameOffset 0 .macro GenerateRedirectedStubWithFrame stub, target diff --git a/src/coreclr/vm/riscv64/pinvokestubs.S b/src/coreclr/vm/riscv64/pinvokestubs.S index 4fd1980066bbed..9f065a37e474d1 100644 --- a/src/coreclr/vm/riscv64/pinvokestubs.S +++ b/src/coreclr/vm/riscv64/pinvokestubs.S @@ -74,22 +74,18 @@ // ------------------------------------------------------------------ // IN: -// InlinedCallFrame (x0) = pointer to the InlinedCallFrame data, including the GS cookie slot (GS cookie right -// before actual InlinedCallFrame data) +// InlinedCallFrame (x0) = pointer to the InlinedCallFrame data // // NESTED_ENTRY JIT_PInvokeBegin, _TEXT, NoHandler PROLOG_SAVE_REG_PAIR_INDEXED fp, ra, 32 PROLOG_SAVE_REG s1, 16 // the stack slot at sp+24 is empty for 16 byte alignment - PREPARE_EXTERNAL_VAR s_gsCookie, t0 - ld t4, 0(t0) - sd t4, 0(a0) - addi s1, a0, SIZEOF__GSCookie + mv s1, a0 // s1 = pFrame // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) - ld t4, FRAMETYPE_InlinedCallFrame + li t4, FRAMETYPE_InlinedCallFrame sd t4, 0(s1) sd zero, (InlinedCallFrame__m_Datum)(s1) @@ -124,13 +120,11 @@ // ------------------------------------------------------------------ // IN: -// InlinedCallFrame (x0) = pointer to the InlinedCallFrame data, including the GS cookie slot (GS cookie right -// before actual InlinedCallFrame data) +// InlinedCallFrame (x0) = pointer to the InlinedCallFrame data // // LEAF_ENTRY JIT_PInvokeEnd, _TEXT - addi a0, a0, SIZEOF__GSCookie ld a1, (InlinedCallFrame__m_pThread)(a0) // a0 = pFrame // a1 = pThread diff --git a/src/coreclr/vm/runtimecallablewrapper.cpp b/src/coreclr/vm/runtimecallablewrapper.cpp index ca442078ade3f9..04eff1d909f30f 100644 --- a/src/coreclr/vm/runtimecallablewrapper.cpp +++ b/src/coreclr/vm/runtimecallablewrapper.cpp @@ -110,7 +110,7 @@ IUnknown *ComClassFactory::CreateInstanceFromClassFactory(IClassFactory *pClassF if (FAILED(SafeQueryInterface(pClassFact, IID_IClassFactory2, (IUnknown**)&pClassFact2)) || m_pClassMT == NULL) { - FrameWithCookie __def; + DebuggerExitFrame __def; { GCX_PREEMP(); hr = pClassFact->CreateInstance(punkOuter, IID_IUnknown, (void **)&pUnk); @@ -196,7 +196,7 @@ IUnknown *ComClassFactory::CreateInstanceFromClassFactory(IClassFactory *pClassF // Create the instance if (SUCCEEDED(hr)) { - FrameWithCookie __def; + DebuggerExitFrame __def; { GCX_PREEMP(); if (fDesignTime || bstrKey == NULL) @@ -322,7 +322,7 @@ OBJECTREF ComClassFactory::CreateAggregatedInstance(MethodTable* pMTClass, BOOL if (pCallbackMT && !pCallbackMT->IsComImport()) bUseDelegate = TRUE; - FrameWithCookie __def; + DebuggerExitFrame __def; // get the IUnknown interface for the managed object pOuter = ComCallWrapper::GetComIPFromCCW(pComWrap, IID_IUnknown, NULL); diff --git a/src/coreclr/vm/stackwalk.cpp b/src/coreclr/vm/stackwalk.cpp index 2e1c13f6750f80..144507c5e43c12 100644 --- a/src/coreclr/vm/stackwalk.cpp +++ b/src/coreclr/vm/stackwalk.cpp @@ -231,11 +231,6 @@ inline void CrawlFrame::GotoNextFrame() // pFrame = pFrame->Next(); - - if (pFrame != FRAME_TOP) - { - SetCurGSCookie(Frame::SafeGetGSCookiePtr(pFrame)); - } } //****************************************************************************** @@ -1067,11 +1062,6 @@ BOOL StackFrameIterator::Init(Thread * pThread, } INDEBUG(m_pRealStartFrame = m_crawl.pFrame); - if (m_crawl.pFrame != FRAME_TOP && !(m_flags & SKIP_GSCOOKIE_CHECK)) - { - m_crawl.SetCurGSCookie(Frame::SafeGetGSCookiePtr(m_crawl.pFrame)); - } - m_crawl.pRD = pRegDisp; m_codeManFlags = (ICodeManagerFlags) @@ -1173,11 +1163,6 @@ BOOL StackFrameIterator::ResetRegDisp(PREGDISPLAY pRegDisp, _ASSERTE(m_crawl.pFrame != NULL); } - if (m_crawl.pFrame != FRAME_TOP && !(m_flags & SKIP_GSCOOKIE_CHECK)) - { - m_crawl.SetCurGSCookie(Frame::SafeGetGSCookiePtr(m_crawl.pFrame)); - } - m_crawl.pRD = pRegDisp; m_codeManFlags = (ICodeManagerFlags) diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index ab2411a0f00493..51462ddd278a02 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -7206,7 +7206,7 @@ static void ManagedThreadBase_DispatchOuter(ManagedThreadCallState *pCallState) // The sole purpose of having this frame is to tell the debugger that we have a catch handler here // which may swallow managed exceptions. The debugger needs this in order to send a // CatchHandlerFound (CHF) notification. - FrameWithCookie catchFrame; + DebuggerU2MCatchHandlerFrame catchFrame; TryParam param(pCallState); param.pFrame = &catchFrame; diff --git a/src/coreclr/vm/threadsuspend.cpp b/src/coreclr/vm/threadsuspend.cpp index d732f3cfd95737..21b197484b9d3f 100644 --- a/src/coreclr/vm/threadsuspend.cpp +++ b/src/coreclr/vm/threadsuspend.cpp @@ -2699,7 +2699,7 @@ void __stdcall Thread::RedirectedHandledJITCase(RedirectReason reason) INDEBUG(Thread::ObjectRefFlush(pThread)); // Create a frame on the stack - FrameWithCookie frame(pCtx); + RedirectedThreadFrame frame(pCtx); STRESS_LOG5(LF_SYNC, LL_INFO1000, "In RedirectedHandledJITcase reason 0x%x pFrame = %p pc = %p sp = %p fp = %p", reason, &frame, GetIP(pCtx), GetSP(pCtx), GetFP(pCtx)); @@ -3767,9 +3767,8 @@ ThrowControlForThread( #if defined(FEATURE_EH_FUNCLETS) *(TADDR*)pfef = (TADDR)FrameIdentifier::FaultingExceptionFrame; - *pfef->GetGSCookiePtr() = GetProcessGSCookie(); #else // FEATURE_EH_FUNCLETS - FrameWithCookie fef; + FaultingExceptionFrame fef; FaultingExceptionFrame *pfef = &fef; #endif // FEATURE_EH_FUNCLETS pfef->InitAndLink(pThread->m_OSContext); @@ -4880,7 +4879,7 @@ void STDCALL OnHijackWorker(HijackArgs * pArgs) // Build a frame so that stack crawling can proceed from here back to where // we will resume execution. - FrameWithCookie frame((void *)pArgs->ReturnAddress, thread, pArgs); + HijackFrame frame((void *)pArgs->ReturnAddress, thread, pArgs); #ifdef _DEBUG BOOL GCOnTransition = FALSE; @@ -5806,7 +5805,7 @@ void HandleSuspensionForInterruptedThread(CONTEXT *interruptedContext) { // If the thread is at a GC safe point, push a RedirectedThreadFrame with // the interrupted context and pulse the GC mode so that GC can proceed. - FrameWithCookie frame(interruptedContext); + RedirectedThreadFrame frame(interruptedContext); frame.Push(pThread); diff --git a/src/coreclr/vm/virtualcallstub.cpp b/src/coreclr/vm/virtualcallstub.cpp index 4ead0cadb8b5ba..c22fbaedd7e53d 100644 --- a/src/coreclr/vm/virtualcallstub.cpp +++ b/src/coreclr/vm/virtualcallstub.cpp @@ -1296,7 +1296,7 @@ PCODE VSD_ResolveWorker(TransitionBlock * pTransitionBlock, Thread::ObjectRefFlush(CURRENT_THREAD); #endif - FrameWithCookie frame(pTransitionBlock); + StubDispatchFrame frame(pTransitionBlock); StubDispatchFrame * pSDFrame = &frame; PCODE returnAddress = pSDFrame->GetUnadjustedReturnAddress(); From 967934c871ca05833c982b8fb17a07e2a4098dbd Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Wed, 5 Feb 2025 16:01:58 -0800 Subject: [PATCH 09/17] Get rid of FrameBase --- src/coreclr/vm/frames.h | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 447208e8255aa3..551ec8e6c5be19 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -239,40 +239,17 @@ enum class FrameIdentifier : TADDR CountPlusOne }; -class FrameBase; - // TransitionFrame only apis class TransitionFrame; TADDR Frame_GetTransitionBlock(TransitionFrame* frame); BOOL Frame_SuppressParamTypeArg(TransitionFrame* frame); -//----------------------------------------------------------------------------- -// Frame depends on the location of its vtable within the object. This -// superclass ensures that the vtable for Frame objects is in the same -// location under both MSVC and GCC. -//----------------------------------------------------------------------------- - -class FrameBase -{ - const FrameIdentifier _frameIdentifier; - -public: - FrameBase(FrameIdentifier frameIdentifier) : _frameIdentifier(frameIdentifier) {LIMITED_METHOD_CONTRACT; } - - void GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { - LIMITED_METHOD_CONTRACT; - // Nothing to protect - } - - FrameIdentifier GetFrameIdentifier() { LIMITED_METHOD_DAC_CONTRACT; return _frameIdentifier; } -}; - //------------------------------------------------------------------------ // Frame defines methods common to all frame types. There are no actual // instances of root frames. //------------------------------------------------------------------------ -class Frame : public FrameBase +class Frame { friend class CheckAsmOffsets; #ifdef DACCESS_COMPILE @@ -280,6 +257,8 @@ class Frame : public FrameBase #endif public: + FrameIdentifier GetFrameIdentifier() { LIMITED_METHOD_DAC_CONTRACT; return _frameIdentifier; } + enum ETransitionType { TT_NONE, @@ -327,6 +306,11 @@ class Frame : public FrameBase BOOL Protects(OBJECTREF *ppObjectRef); #endif // defined(_DEBUG) && !defined(DACCESS_COMPILE) + void GcScanRoots_Impl(promote_func *fn, ScanContext* sc) { + LIMITED_METHOD_CONTRACT; + // Nothing to protect + } + // Should only be called on Frames that derive from TransitionFrame TADDR GetTransitionBlock_Impl() { @@ -593,9 +577,10 @@ class Frame : public FrameBase #endif private: - // Pointer to the next frame up the stack. + FrameIdentifier _frameIdentifier; protected: + // Pointer to the next frame up the stack. PTR_Frame m_Next; // offset +4 public: @@ -640,7 +625,7 @@ class Frame : public FrameBase // Frame is considered an abstract class: this protected constructor // causes any attempt to instantiate one to fail at compile-time. Frame(FrameIdentifier frameIdentifier) - : FrameBase(frameIdentifier), m_Next(dac_cast(nullptr)) + : _frameIdentifier(frameIdentifier), m_Next(dac_cast(nullptr)) { LIMITED_METHOD_CONTRACT; } From dc2464d6f00163eb11657e76b9178693ad2130bb Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Thu, 6 Feb 2025 12:12:50 -0800 Subject: [PATCH 10/17] Fix build errors --- src/coreclr/vm/jithelpers.cpp | 4 ++-- src/coreclr/vm/loongarch64/pinvokestubs.S | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 5d564f62b8f65c..fe5564e299060d 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -2468,7 +2468,7 @@ static PCODE PatchpointOptimizationPolicy(TransitionBlock* pTransitionBlock, int Thread::ObjectRefFlush(CURRENT_THREAD); #endif - FrameWithCookie frame(pTransitionBlock, 0); + DynamicHelperFrame frame(pTransitionBlock, 0); DynamicHelperFrame * pFrame = &frame; pFrame->Push(CURRENT_THREAD); @@ -2554,7 +2554,7 @@ static PCODE PatchpointRequiredPolicy(TransitionBlock* pTransitionBlock, int* co Thread::ObjectRefFlush(CURRENT_THREAD); #endif - FrameWithCookie frame(pTransitionBlock, 0); + DynamicHelperFrame frame(pTransitionBlock, 0); DynamicHelperFrame * pFrame = &frame; pFrame->Push(CURRENT_THREAD); diff --git a/src/coreclr/vm/loongarch64/pinvokestubs.S b/src/coreclr/vm/loongarch64/pinvokestubs.S index edd2672525f2c2..e902c74d8278f3 100644 --- a/src/coreclr/vm/loongarch64/pinvokestubs.S +++ b/src/coreclr/vm/loongarch64/pinvokestubs.S @@ -86,7 +86,7 @@ NESTED_ENTRY JIT_PInvokeBegin, _TEXT, NoHandler // $s0=23. PROLOG_SAVE_REG 23, 16 //the stack slot at $sp+24 is empty for 16 byte alignment - mv.d $s0, $a0 + move $s0, $a0 // s0 = pFrame // set first slot to the value of InlinedCallFrame identifier (checked by runtime code) From 7fe3e81cbaa36090fa083367eae1df2a9c96ea2c Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Thu, 6 Feb 2025 13:30:03 -0800 Subject: [PATCH 11/17] Fix windows arm64 build failure --- src/coreclr/vm/arm64/asmhelpers.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/arm64/asmhelpers.asm b/src/coreclr/vm/arm64/asmhelpers.asm index 2d61e9729a778b..085497778442dd 100644 --- a/src/coreclr/vm/arm64/asmhelpers.asm +++ b/src/coreclr/vm/arm64/asmhelpers.asm @@ -513,7 +513,7 @@ GenericComCallStub_StackAlloc SETA GenericComCallStub_StackAlloc + 8 GenericComCallStub_FrameOffset SETA (GenericComCallStub_StackAlloc - (SIZEOF__ComMethodFrame - GenericComCallStub_FirstStackAdjust)) - IF (GenericComCallStu_bFirstStackAdjust):MOD:16 != 0 + IF (GenericComCallStub_FirstStackAdjust):MOD:16 != 0 GenericComCallStub_FirstStackAdjust SETA GenericComCallStub_FirstStackAdjust + 8 ENDIF From ba80e02115bd3df06a308e8e957cc9b43ccaadec Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Thu, 6 Feb 2025 14:53:48 -0800 Subject: [PATCH 12/17] Fix issues noted in X86 testing --- src/coreclr/vm/i386/asmhelpers.asm | 8 ++++---- src/coreclr/vm/i386/jithelp.asm | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coreclr/vm/i386/asmhelpers.asm b/src/coreclr/vm/i386/asmhelpers.asm index a9bdb330f6b644..6bbd62a31624dc 100644 --- a/src/coreclr/vm/i386/asmhelpers.asm +++ b/src/coreclr/vm/i386/asmhelpers.asm @@ -1272,8 +1272,8 @@ _ComCallPreStub@0 proc public push eax ; ComCallMethodDesc* sub esp, 4*4 ; next, vtable, 64-bit error return - lea edi, [esp] - lea esi, [esp+3*4] + lea edi, [esp] ; Point at the 64-bit error return + lea esi, [esp+2*4] ; Leave space for the 64-bit error return push edi ; pErrorReturn push esi ; pFrame @@ -1283,7 +1283,7 @@ _ComCallPreStub@0 proc public cmp eax, 0 je nostub ; oops we could not create a stub - add esp, 6*4 + add esp, 5*4 ; Pop off 64-bit error return, vtable, next and ComCallMethodDesc* ; pop CalleeSavedRegisters pop edi @@ -1306,7 +1306,7 @@ nostub: mov eax, [edi] mov edx, [edi+4] - add esp, 6*4 + add esp, 5*4 ; Pop off 64-bit error return, vtable, next and ComCallMethodDesc* ; pop CalleeSavedRegisters pop edi diff --git a/src/coreclr/vm/i386/jithelp.asm b/src/coreclr/vm/i386/jithelp.asm index 49be25decdb992..cd386d2cd2ad3a 100644 --- a/src/coreclr/vm/i386/jithelp.asm +++ b/src/coreclr/vm/i386/jithelp.asm @@ -722,9 +722,9 @@ VSDHelperLabel: ; m_regs ; m_CallerAddress ; m_pThread -; vtbl +; frame identifier ; &VSDHelperLabel -OffsetOfTailCallFrame = 8 +OffsetOfTailCallFrame = 4 ; Offset to start of TailCallFrame, includes only the &VSDHelperLabel ; ebx = pThread From 8577534e7a9865a745205ab80bf8d92283268a6b Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Fri, 7 Feb 2025 12:02:19 -0800 Subject: [PATCH 13/17] Most of Jan's feedback --- .../debug/daccess/dacdbiimplstackwalk.cpp | 4 +- src/coreclr/debug/ee/frameinfo.cpp | 10 ++--- src/coreclr/inc/corinfo.h | 2 - src/coreclr/inc/jiteeversionguid.h | 12 +++--- src/coreclr/jit/importercalls.cpp | 7 +++- src/coreclr/jit/lower.cpp | 6 +-- .../tools/Common/JitInterface/CorInfoTypes.cs | 2 - .../tools/superpmi/superpmi-shared/agnostic.h | 2 - .../superpmi-shared/methodcontext.cpp | 9 +---- src/coreclr/vm/FrameTypes.h | 15 ++----- src/coreclr/vm/amd64/asmconstants.h | 3 -- src/coreclr/vm/arm/asmconstants.h | 3 -- src/coreclr/vm/arm/stubs.cpp | 17 ++++---- src/coreclr/vm/arm64/asmconstants.h | 3 -- src/coreclr/vm/ceemain.cpp | 5 --- src/coreclr/vm/frames.cpp | 39 +++++++------------ src/coreclr/vm/frames.h | 36 ++++++++--------- src/coreclr/vm/gcenv.ee.common.cpp | 2 +- src/coreclr/vm/gcenv.ee.cpp | 2 +- src/coreclr/vm/i386/asmconstants.h | 7 +++- src/coreclr/vm/i386/cgenx86.cpp | 13 +++---- src/coreclr/vm/i386/jithelp.asm | 4 +- src/coreclr/vm/i386/jitinterfacex86.cpp | 10 ----- src/coreclr/vm/jitinterface.cpp | 2 - src/coreclr/vm/loongarch64/asmconstants.h | 3 -- src/coreclr/vm/proftoeeinterfaceimpl.cpp | 4 +- src/coreclr/vm/riscv64/asmconstants.h | 3 -- src/coreclr/vm/stackwalk.cpp | 4 +- src/coreclr/vm/threadsuspend.cpp | 4 +- 29 files changed, 84 insertions(+), 149 deletions(-) diff --git a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp index c0fe7343e1617b..90158d237ba5a9 100644 --- a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp +++ b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp @@ -465,7 +465,7 @@ ULONG32 DacDbiInterfaceImpl::GetCountOfInternalFrames(VMPTR_Thread vmThread) if (g_isNewExceptionHandlingEnabled && InlinedCallFrame::FrameHasActiveCall(pFrame)) { // Skip new exception handling helpers - InlinedCallFrame *pInlinedCallFrame = (InlinedCallFrame *)pFrame; + InlinedCallFrame *pInlinedCallFrame = dac_cast(pFrame); PTR_NDirectMethodDesc pMD = pInlinedCallFrame->m_Datum; TADDR datum = dac_cast(pMD); if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper) @@ -518,7 +518,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread if (g_isNewExceptionHandlingEnabled && InlinedCallFrame::FrameHasActiveCall(pFrame)) { // Skip new exception handling helpers - InlinedCallFrame *pInlinedCallFrame = (InlinedCallFrame *)pFrame; + InlinedCallFrame *pInlinedCallFrame = dac_cast(pFrame); PTR_NDirectMethodDesc pMD = pInlinedCallFrame->m_Datum; TADDR datum = dac_cast(pMD); if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper) diff --git a/src/coreclr/debug/ee/frameinfo.cpp b/src/coreclr/debug/ee/frameinfo.cpp index a38420771eb2cc..d2a73fbd9b8e1b 100644 --- a/src/coreclr/debug/ee/frameinfo.cpp +++ b/src/coreclr/debug/ee/frameinfo.cpp @@ -464,7 +464,7 @@ bool HasExitRuntime(Frame *pFrame, DebuggerFrameData *pData, FramePointer *pPote } else if (pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame) { - InlinedCallFrame *pInlinedFrame = static_cast(pFrame); + InlinedCallFrame *pInlinedFrame = dac_cast(pFrame); LPVOID sp = (LPVOID)pInlinedFrame->GetCallSiteSP(); // The sp returned below is the sp of the caller, which is either an IL stub in the normal case @@ -485,7 +485,7 @@ bool HasExitRuntime(Frame *pFrame, DebuggerFrameData *pData, FramePointer *pPote { // It'll be nice if there's a way to assert that the current frame is indeed of a // derived class of TransitionFrame. - TransitionFrame *pTransFrame = static_cast(pFrame); + TransitionFrame *pTransFrame = dac_cast(pFrame); LPVOID sp = (LPVOID)pTransFrame->GetSP(); // The sp returned below is the sp of the caller, which is either an IL stub in the normal case @@ -788,7 +788,7 @@ void FrameInfo::InitForM2UInternalFrame(CrawlFrame * pCF) // For a M2U call, there's a managed method wrapping the unmanaged call. Use that. Frame * pFrame = pCF->GetFrame(); _ASSERTE(pFrame->GetTransitionType() == Frame::TT_M2U); - FramedMethodFrame * pM2U = static_cast (pFrame); + FramedMethodFrame * pM2U = dac_cast (pFrame); MethodDesc * pMDWrapper = pM2U->GetFunction(); // Soem M2U transitions may not have a function associated w/ them, @@ -816,7 +816,7 @@ void FrameInfo::InitForU2MInternalFrame(CrawlFrame * pCF) // If we're a COM2CLR call, perhaps we can get the MD for the interface. if (pFrame->GetFrameIdentifier() == FrameIdentifier::ComMethodFrame) { - ComMethodFrame* pCOMFrame = static_cast (pFrame); + ComMethodFrame* pCOMFrame = dac_cast (pFrame); ComCallMethodDesc* pCMD = reinterpret_cast (pCOMFrame->ComMethodFrame::GetDatum()); pMDHint = pCMD->GetInterfaceMethodDesc(); @@ -1739,7 +1739,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) { // We only show a FuncEvalFrame if the funceval is not trying to abort the thread. - FuncEvalFrame *pFuncEvalFrame = static_cast(frame); + FuncEvalFrame *pFuncEvalFrame = dac_cast(frame); use = pFuncEvalFrame->ShowFrame() ? true : false; } diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 9d01304c6639d8..858379bfabd7ea 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -1650,8 +1650,6 @@ struct CORINFO_EE_INFO // Size of the Frame structure when it also contains the secret stub arg unsigned sizeWithSecretStubArg; - unsigned offsetOfGSCookie; - unsigned offsetOfFrameVptr; unsigned offsetOfFrameLink; unsigned offsetOfCallSiteSP; unsigned offsetOfCalleeSavedFP; diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h index 2db16d00df135b..9383fceebc29b2 100644 --- a/src/coreclr/inc/jiteeversionguid.h +++ b/src/coreclr/inc/jiteeversionguid.h @@ -43,12 +43,12 @@ typedef const GUID *LPCGUID; #define GUID_DEFINED #endif // !GUID_DEFINED -constexpr GUID JITEEVersionIdentifier = { /* cc0e7adf-e397-40b6-9d14-a7149815c991 */ - 0xcc0e7adf, - 0xe397, - 0x40b6, - {0x9d, 0x14, 0xa7, 0x14, 0x98, 0x15, 0xc9, 0x91} - }; +constexpr GUID JITEEVersionIdentifier = { /* a116647a-3f80-4fd6-9c80-95156c7e9923 */ + 0xa116647a, + 0x3f80, + 0x4fd6, + {0x9c, 0x80, 0x95, 0x15, 0x6c, 0x7e, 0x99, 0x23} +}; ////////////////////////////////////////////////////////////////////////////////////////////////////////// // diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 319466fd94071d..408b3653f948e0 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -6387,7 +6387,12 @@ bool Compiler::impCanPInvokeInline() // unmanaged code, we cannot reuse the inlined stub (we still need // the original state until we are in the catch handler) // -// * We disable pinvoke inlining inside handlers since the GSCookie +// TODO-CQ: The inlining frame no longer has a GSCookie, so the common on this +// restriction is out of date. However, given that there is a comment +// about protecting the framelet, I'm not confident about what this +// is actually protecteing, so I don't want to remove this +// restriction without further analysis analysis. +// * We disable pinvoke inlini1ng inside handlers since the GSCookie // is in the inlined Frame (see // CORINFO_EE_INFO::InlinedCallFrameInfo::offsetOfGSCookie), but // this would not protect framelets/return-address of handlers. diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index f0ab60766812e8..1366e6e28f56a1 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -5861,7 +5861,7 @@ GenTree* Lowering::CreateFrameLinkUpdate(FrameLinkAction action) if (action == PushFrame) { // Thread->m_pFrame = &inlinedCallFrame; - data = comp->gtNewLclAddrNode(comp->lvaInlinedPInvokeFrameVar, callFrameInfo.offsetOfFrameVptr); + data = comp->gtNewLclVarAddrNode(comp->lvaInlinedPInvokeFrameVar); } else { @@ -5889,7 +5889,7 @@ GenTree* Lowering::CreateFrameLinkUpdate(FrameLinkAction action) // 64-bit 32-bit CORINFO_EE_INFO // offset offset field name offset when set // ----------------------------------------------------------------------------------------- -// +00h +00h vptr for class InlinedCallFrame offsetOfFrameVptr method prolog +// +00h +00h _frameIdentifier 0 method prolog // +08h +04h m_Next offsetOfFrameLink method prolog // +10h +08h m_Datum offsetOfCallTarget call site // +18h +0Ch m_pCallSiteSP offsetOfCallSiteSP x86: call site, and zeroed in method @@ -5945,7 +5945,7 @@ void Lowering::InsertPInvokeMethodProlog() // Call runtime helper to fill in our InlinedCallFrame and push it on the Frame list: // TCB = CORINFO_HELP_INIT_PINVOKE_FRAME(&symFrameStart); - GenTree* frameAddr = comp->gtNewLclAddrNode(comp->lvaInlinedPInvokeFrameVar, callFrameInfo.offsetOfFrameVptr); + GenTree* frameAddr = comp->gtNewLclVarAddrNode(comp->lvaInlinedPInvokeFrameVar); NewCallArg frameAddrArg = NewCallArg::Primitive(frameAddr).WellKnown(WellKnownArg::PInvokeFrame); GenTreeCall* call = comp->gtNewHelperCallNode(CORINFO_HELP_INIT_PINVOKE_FRAME, TYP_I_IMPL); diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs index 03dff074620ac2..08d7df78c946d8 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs @@ -836,8 +836,6 @@ public struct InlinedCallFrameInfo // Size of the Frame structure inside IL stubs that include secret stub arg in the frame public uint sizeWithSecretStubArg; - public uint offsetOfGSCookie; - public uint offsetOfFrameVptr; public uint offsetOfFrameLink; public uint offsetOfCallSiteSP; public uint offsetOfCalleeSavedFP; diff --git a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h index 771951a68baea8..18fd918a7a5cea 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h @@ -173,8 +173,6 @@ struct Agnostic_CORINFO_EE_INFO { DWORD size; DWORD sizeWithSecretStubArg; - DWORD offsetOfGSCookie; - DWORD offsetOfFrameVptr; DWORD offsetOfFrameLink; DWORD offsetOfCallSiteSP; DWORD offsetOfCalleeSavedFP; diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index cb831838f21756..351622b6a61cab 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -4365,8 +4365,6 @@ void MethodContext::recGetEEInfo(CORINFO_EE_INFO* pEEInfoOut) value.inlinedCallFrameInfo.size = (DWORD)pEEInfoOut->inlinedCallFrameInfo.size; value.inlinedCallFrameInfo.sizeWithSecretStubArg = (DWORD)pEEInfoOut->inlinedCallFrameInfo.sizeWithSecretStubArg; - value.inlinedCallFrameInfo.offsetOfGSCookie = (DWORD)pEEInfoOut->inlinedCallFrameInfo.offsetOfGSCookie; - value.inlinedCallFrameInfo.offsetOfFrameVptr = (DWORD)pEEInfoOut->inlinedCallFrameInfo.offsetOfFrameVptr; value.inlinedCallFrameInfo.offsetOfFrameLink = (DWORD)pEEInfoOut->inlinedCallFrameInfo.offsetOfFrameLink; value.inlinedCallFrameInfo.offsetOfCallSiteSP = (DWORD)pEEInfoOut->inlinedCallFrameInfo.offsetOfCallSiteSP; value.inlinedCallFrameInfo.offsetOfCalleeSavedFP = (DWORD)pEEInfoOut->inlinedCallFrameInfo.offsetOfCalleeSavedFP; @@ -4390,11 +4388,10 @@ void MethodContext::recGetEEInfo(CORINFO_EE_INFO* pEEInfoOut) } void MethodContext::dmpGetEEInfo(DWORD key, const Agnostic_CORINFO_EE_INFO& value) { - printf("GetEEInfo key %u, value icfi{sz-%u sz-witharg-%u ogs-%u ofv-%u ofl-%u ocsp-%u ocsfp-%u oct-%u ora-%u ossa-%u osap-%u} " + printf("GetEEInfo key %u, value icfi{sz-%u sz-witharg-%u ofl-%u ocsp-%u ocsfp-%u oct-%u ora-%u ossa-%u osap-%u} " "otf-%u ogcs-%u odi-%u odft-%u osdic-%u srpf-%u osps-%u muono-%u tabi-%u osType-%u", key, value.inlinedCallFrameInfo.size, value.inlinedCallFrameInfo.sizeWithSecretStubArg, - value.inlinedCallFrameInfo.offsetOfGSCookie, - value.inlinedCallFrameInfo.offsetOfFrameVptr, value.inlinedCallFrameInfo.offsetOfFrameLink, + value.inlinedCallFrameInfo.offsetOfFrameLink, value.inlinedCallFrameInfo.offsetOfCallSiteSP, value.inlinedCallFrameInfo.offsetOfCalleeSavedFP, value.inlinedCallFrameInfo.offsetOfCallTarget, value.inlinedCallFrameInfo.offsetOfReturnAddress, value.inlinedCallFrameInfo.offsetOfSecretStubArg, value.inlinedCallFrameInfo.offsetOfSPAfterProlog, @@ -4411,8 +4408,6 @@ void MethodContext::repGetEEInfo(CORINFO_EE_INFO* pEEInfoOut) pEEInfoOut->inlinedCallFrameInfo.size = (unsigned)value.inlinedCallFrameInfo.size; pEEInfoOut->inlinedCallFrameInfo.sizeWithSecretStubArg = (unsigned)value.inlinedCallFrameInfo.sizeWithSecretStubArg; - pEEInfoOut->inlinedCallFrameInfo.offsetOfGSCookie = (unsigned)value.inlinedCallFrameInfo.offsetOfGSCookie; - pEEInfoOut->inlinedCallFrameInfo.offsetOfFrameVptr = (unsigned)value.inlinedCallFrameInfo.offsetOfFrameVptr; pEEInfoOut->inlinedCallFrameInfo.offsetOfFrameLink = (unsigned)value.inlinedCallFrameInfo.offsetOfFrameLink; pEEInfoOut->inlinedCallFrameInfo.offsetOfCallSiteSP = (unsigned)value.inlinedCallFrameInfo.offsetOfCallSiteSP; pEEInfoOut->inlinedCallFrameInfo.offsetOfCalleeSavedFP = diff --git a/src/coreclr/vm/FrameTypes.h b/src/coreclr/vm/FrameTypes.h index 6659423b44d521..1efca951a3ba3b 100644 --- a/src/coreclr/vm/FrameTypes.h +++ b/src/coreclr/vm/FrameTypes.h @@ -1,17 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#ifndef FRAME_ABSTRACT_TYPE_NAME -#define FRAME_ABSTRACT_TYPE_NAME(frameType) -#endif #ifndef FRAME_TYPE_NAME #define FRAME_TYPE_NAME(frameType) #endif -FRAME_ABSTRACT_TYPE_NAME(FrameBase) -FRAME_ABSTRACT_TYPE_NAME(Frame) -FRAME_ABSTRACT_TYPE_NAME(TransitionFrame) FRAME_TYPE_NAME(InlinedCallFrame) +#if defined(TARGET_X86) && !defined(UNIX_X86_ABI) +FRAME_TYPE_NAME(TailCallFrame) +#endif #ifdef FEATURE_HIJACK FRAME_TYPE_NAME(ResumableFrame) FRAME_TYPE_NAME(RedirectedThreadFrame) @@ -28,9 +25,7 @@ FRAME_TYPE_NAME(HelperMethodFrame_1OBJ) FRAME_TYPE_NAME(HelperMethodFrame_2OBJ) FRAME_TYPE_NAME(HelperMethodFrame_3OBJ) FRAME_TYPE_NAME(HelperMethodFrame_PROTECTOBJ) -FRAME_ABSTRACT_TYPE_NAME(FramedMethodFrame) #ifdef FEATURE_COMINTEROP -FRAME_ABSTRACT_TYPE_NAME(UnmanagedToManagedFrame) FRAME_TYPE_NAME(ComMethodFrame) FRAME_TYPE_NAME(CLRToCOMMethodFrame) FRAME_TYPE_NAME(ComPrestubMethodFrame) @@ -51,13 +46,9 @@ FRAME_TYPE_NAME(ProtectValueClassFrame) FRAME_TYPE_NAME(DebuggerClassInitMarkFrame) FRAME_TYPE_NAME(DebuggerExitFrame) FRAME_TYPE_NAME(DebuggerU2MCatchHandlerFrame) -#if defined(TARGET_X86) && !defined(UNIX_X86_ABI) -FRAME_TYPE_NAME(TailCallFrame) -#endif FRAME_TYPE_NAME(ExceptionFilterFrame) #if defined(_DEBUG) FRAME_TYPE_NAME(AssumeByrefFromJITStack) #endif // _DEBUG -#undef FRAME_ABSTRACT_TYPE_NAME #undef FRAME_TYPE_NAME diff --git a/src/coreclr/vm/amd64/asmconstants.h b/src/coreclr/vm/amd64/asmconstants.h index 35c8ec685c15cd..bd86950467f495 100644 --- a/src/coreclr/vm/amd64/asmconstants.h +++ b/src/coreclr/vm/amd64/asmconstants.h @@ -81,9 +81,6 @@ ASMCONSTANTS_C_ASSERT(SIZEOF_CalleeSavedRegisters == sizeof(CalleeSavedRegisters #define FRAMETYPE_InlinedCallFrame 0x1 ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameIdentifier::InlinedCallFrame) -#define SIZEOF_GSCookie 0x8 -ASMCONSTANTS_C_ASSERT(SIZEOF_GSCookie == sizeof(GSCookie)); - #define OFFSETOF__Frame____VFN_table 0 #define OFFSETOF__Frame__m_Next 0x8 diff --git a/src/coreclr/vm/arm/asmconstants.h b/src/coreclr/vm/arm/asmconstants.h index 0adc93cc988353..4495b42dca78ca 100644 --- a/src/coreclr/vm/arm/asmconstants.h +++ b/src/coreclr/vm/arm/asmconstants.h @@ -82,9 +82,6 @@ ASMCONSTANTS_C_ASSERT(PtrArray__m_Array == offsetof(PtrArray, m_Array)); #define TypeHandle_CanCast 0x1 // TypeHandle::CanCast -#define SIZEOF__GSCookie 0x4 -ASMCONSTANTS_C_ASSERT(SIZEOF__GSCookie == sizeof(GSCookie)); - #define SIZEOF__Frame 0x8 ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame)); diff --git a/src/coreclr/vm/arm/stubs.cpp b/src/coreclr/vm/arm/stubs.cpp index 3c65ec5fab2e40..08448a0ab0d555 100644 --- a/src/coreclr/vm/arm/stubs.cpp +++ b/src/coreclr/vm/arm/stubs.cpp @@ -1119,9 +1119,6 @@ Stub *GenerateInitPInvokeFrameHelper() CORINFO_EE_INFO::InlinedCallFrameInfo FrameInfo; InlinedCallFrame::GetEEInfo(&FrameInfo); - // R4 contains address of the frame on stack (the frame ptr, not its neg space) - unsigned negSpace = FrameInfo.offsetOfFrameVptr; - ThumbReg regFrame = ThumbReg(4); ThumbReg regThread = ThumbReg(5); ThumbReg regScratch = ThumbReg(6); @@ -1139,28 +1136,28 @@ Stub *GenerateInitPInvokeFrameHelper() for (int reg = 0; reg < 4; reg++) psl->ThumbEmitLoadRegIndirect(ThumbReg(reg), thumbRegSp, offsetof(ArgumentRegisters, r) + sizeof(*ArgumentRegisters::r) * reg); - // mov [regFrame + FrameInfo.offsetOfFrameVptr], FrameIdentifier::InlinedCallFrame + // mov [regFrame], FrameIdentifier::InlinedCallFrame psl->ThumbEmitMovConstant(regScratch, (DWORD)FrameIdentifier::InlinedCallFrame); - psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfFrameVptr - negSpace); + psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, 0); // ldr regScratch, [regThread + offsetof(Thread, m_pFrame)] // str regScratch, [regFrame + FrameInfo.offsetOfFrameLink] psl->ThumbEmitLoadRegIndirect(regScratch, regThread, offsetof(Thread, m_pFrame)); - psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfFrameLink - negSpace); + psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfFrameLink); // str FP, [regFrame + FrameInfo.offsetOfCalleeSavedFP] - psl->ThumbEmitStoreRegIndirect(thumbRegFp, regFrame, FrameInfo.offsetOfCalleeSavedFP - negSpace); + psl->ThumbEmitStoreRegIndirect(thumbRegFp, regFrame, FrameInfo.offsetOfCalleeSavedFP); // str R9, [regFrame + FrameInfo.offsetOfSPAfterProlog] - psl->ThumbEmitStoreRegIndirect(regR9, regFrame, FrameInfo.offsetOfSPAfterProlog - negSpace); + psl->ThumbEmitStoreRegIndirect(regR9, regFrame, FrameInfo.offsetOfSPAfterProlog); // mov [regFrame + FrameInfo.offsetOfReturnAddress], 0 psl->ThumbEmitMovConstant(regScratch, 0); - psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfReturnAddress - negSpace); + psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfReturnAddress); DWORD cbSavedRegs = sizeof(ArgumentRegisters) + 2 * 4; // r0-r3, r4, lr psl->ThumbEmitAdd(regScratch, thumbRegSp, cbSavedRegs); - psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfCallSiteSP - negSpace); + psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfCallSiteSP); // mov [regThread + offsetof(Thread, m_pFrame)], regFrame psl->ThumbEmitStoreRegIndirect(regFrame, regThread, offsetof(Thread, m_pFrame)); diff --git a/src/coreclr/vm/arm64/asmconstants.h b/src/coreclr/vm/arm64/asmconstants.h index e8daf48245f369..87003693b87164 100644 --- a/src/coreclr/vm/arm64/asmconstants.h +++ b/src/coreclr/vm/arm64/asmconstants.h @@ -103,9 +103,6 @@ ASMCONSTANTS_C_ASSERT(LazyMachState_captureIp == offsetof(LazyMachState, capture #define VASigCookie__pNDirectILStub 0x8 ASMCONSTANTS_C_ASSERT(VASigCookie__pNDirectILStub == offsetof(VASigCookie, pNDirectILStub)) -#define SIZEOF__GSCookie 0x8 -ASMCONSTANTS_C_ASSERT(SIZEOF__GSCookie == sizeof(GSCookie)); - #define SIZEOF__Frame 0x10 ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame)); diff --git a/src/coreclr/vm/ceemain.cpp b/src/coreclr/vm/ceemain.cpp index 9251ef02c916c8..58f1544146f9e4 100644 --- a/src/coreclr/vm/ceemain.cpp +++ b/src/coreclr/vm/ceemain.cpp @@ -729,11 +729,6 @@ void EEStartupHelper() InitGSCookie(); - Frame::Init(); - - - - #ifdef LOGGING InitializeLogging(); #endif diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index f3868971585816..9dfe7f9469b291 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -359,19 +359,19 @@ const size_t FRAME_TYPES_COUNT = //----------------------------------------------------------------------- // Implementation of the global table of names. On the DAC side, just the global pointer. // On the runtime side, the array of names. - #define FRAME_TYPE_NAME(x) {(TADDR)FrameIdentifier::x, #x} , + #define FRAME_TYPE_NAME(x) {FrameIdentifier::x, #x} , static FrameTypeName FrameTypeNameTable[] = { #include "frames.h" }; /* static */ -PTR_CSTR Frame::GetFrameTypeName(TADDR vtbl) +PTR_CSTR Frame::GetFrameTypeName(FrameIdentifier frameIdentifier) { LIMITED_METHOD_CONTRACT; for (size_t i=0; iGetFrameIdentifier(); // // Use a simple compare which is dependent on the tightly packed arrangement of FrameIdentifier // return (((TADDR)vptr > (TADDR)FrameIdentifier::None) && ((TADDR)vptr < (TADDR)FrameIdentifier::CountPlusOne)); -#else - return true; -#endif } //----------------------------------------------------------------------- @@ -509,7 +500,7 @@ VOID Frame::Push(Thread *pThread) // during stack-walking. !g_pConfig->fAssertOnFailFast() || (m_Next == FRAME_TOP) || - (Frame::HasValidVTablePtr(m_Next))); + (Frame::HasFrameIdentifier(m_Next))); pThread->SetFrame(this); } @@ -545,7 +536,7 @@ VOID Frame::Pop(Thread *pThread) // during stack-walking. !g_pConfig->fAssertOnFailFast() || (m_Next == FRAME_TOP) || - (Frame::HasValidVTablePtr(m_Next))); + (Frame::HasFrameIdentifier(m_Next))); pThread->SetFrame(m_Next); m_Next = NULL; @@ -1000,10 +991,8 @@ ComPrestubMethodFrame::Init() { WRAPPER_NO_CONTRACT; - // Initializes the frame's VPTR. This assumes C++ puts the vptr - // at offset 0 for a class not using MI, but this is no different - // than the assumption that COM Classic makes. - *((TADDR*)this) = (TADDR)FrameIdentifier::ComPrestubMethodFrame; + // Initializes the frame's identifier. + Frame::Init(FrameIdentifier::ComPrestubMethodFrame); } #endif // FEATURE_COMINTEROP @@ -1986,7 +1975,7 @@ VOID InlinedCallFrame::Init() { WRAPPER_NO_CONTRACT; - *((TADDR *)this) = (TADDR)FrameIdentifier::InlinedCallFrame; + Frame::Init(FrameIdentifier::InlinedCallFrame); m_Datum = NULL; m_pCallSiteSP = NULL; diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index c74720b226e835..6853f8866e3f50 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -221,15 +221,6 @@ class ComCallMethodDesc; #define FRAME_TOP_VALUE ~0 // we want to say -1 here, but gcc has trouble with the signed value #define FRAME_TOP (PTR_Frame(FRAME_TOP_VALUE)) -//----------------------------------------------------------------------------- -// For reporting on types of frames at runtime. -class FrameTypeName -{ -public: - TADDR vtbl; - PTR_CSTR name; -}; -typedef DPTR(FrameTypeName) PTR_FrameTypeName; enum class FrameIdentifier : TADDR { @@ -239,6 +230,16 @@ enum class FrameIdentifier : TADDR CountPlusOne }; +//----------------------------------------------------------------------------- +// For reporting on types of frames at runtime. +class FrameTypeName +{ +public: + FrameIdentifier id; + PTR_CSTR name; +}; +typedef DPTR(FrameTypeName) PTR_FrameTypeName; + // TransitionFrame only apis class TransitionFrame; TADDR Frame_GetTransitionBlock(TransitionFrame* frame); @@ -421,8 +422,8 @@ class Frame } #endif // #ifndef DACCESS_COMPILE - static bool HasValidVTablePtr(Frame * pFrame); - static void Init(); + static bool HasFrameIdentifier(Frame * pFrame); + void Init(FrameIdentifier frameIdentifier); // Callers, note that the REGDISPLAY parameter is actually in/out. While // UpdateRegDisplay is generally used to fill out the REGDISPLAY parameter, some @@ -544,13 +545,6 @@ class Frame return (BYTE)ofs; } - // get your VTablePointer (can be used to check what type the frame is) - TADDR GetVTablePtr() - { - LIMITED_METHOD_DAC_CONTRACT; - return VPTR_HOST_VTABLE_TO_TADDR(*(LPVOID*)this); - } - #if defined(_DEBUG) && !defined(DACCESS_COMPILE) BOOL Protects_Impl(OBJECTREF *ppObjectRef) { @@ -573,7 +567,7 @@ class Frame static void __stdcall LogTransition(Frame* frame); void LogFrame(int LF, int LL); // General purpose logging. void LogFrameChain(int LF, int LL); // Log the whole chain. - static PTR_CSTR GetFrameTypeName(TADDR vtbl); + static PTR_CSTR GetFrameTypeName(FrameIdentifier frameIdentifier); #endif private: @@ -802,6 +796,8 @@ inline CONTEXT * GETREDIRECTEDCONTEXT(Thread * thread) { LIMITED_METHOD_CONTRACT // getting lost. //------------------------------------------------------------------------ +typedef DPTR(class TransitionFrame) PTR_TransitionFrame; + class TransitionFrame : public Frame { #ifndef DACCESS_COMPILE @@ -2698,7 +2694,7 @@ class TailCallFrame : public Frame // loop through the frame chain while (pFrame->GetFrameIdentifier() != FrameIdentifier::TailCallFrame) pFrame = pFrame->m_Next; - return (TailCallFrame*)pFrame; + return dac_cast(pFrame); } TADDR GetCallerAddress() diff --git a/src/coreclr/vm/gcenv.ee.common.cpp b/src/coreclr/vm/gcenv.ee.common.cpp index ba747b45a00eb1..34d40e85a2e5dd 100644 --- a/src/coreclr/vm/gcenv.ee.common.cpp +++ b/src/coreclr/vm/gcenv.ee.common.cpp @@ -106,7 +106,7 @@ inline bool SafeToReportGenericParamContext(CrawlFrame* pCF) if (!pCF->IsFrameless() && pCF->GetFrame()->GetFrameIdentifier() == FrameIdentifier::StubDispatchFrame) { - return !((StubDispatchFrame*)pCF->GetFrame())->SuppressParamTypeArg(); + return !(dac_cast(pCF->GetFrame()))->SuppressParamTypeArg(); } if (!pCF->IsFrameless() || !(pCF->IsActiveFrame() || pCF->IsInterrupted())) diff --git a/src/coreclr/vm/gcenv.ee.cpp b/src/coreclr/vm/gcenv.ee.cpp index 55329274905a5d..9525de49fd83b2 100644 --- a/src/coreclr/vm/gcenv.ee.cpp +++ b/src/coreclr/vm/gcenv.ee.cpp @@ -143,7 +143,7 @@ static void ScanStackRoots(Thread * pThread, promote_func* fn, ScanContext* sc) if (InlinedCallFrame::FrameHasActiveCall(pTopFrame)) { // It is an InlinedCallFrame with active call. Get SP from it. - InlinedCallFrame* pInlinedFrame = (InlinedCallFrame*)pTopFrame; + InlinedCallFrame* pInlinedFrame = dac_cast(pTopFrame); topStack = (Object **)pInlinedFrame->GetCallSiteSP(); } #endif // FEATURE_CONSERVATIVE_GC || USE_FEF diff --git a/src/coreclr/vm/i386/asmconstants.h b/src/coreclr/vm/i386/asmconstants.h index ed8753702489a3..280f4f6c51904e 100644 --- a/src/coreclr/vm/i386/asmconstants.h +++ b/src/coreclr/vm/i386/asmconstants.h @@ -35,6 +35,11 @@ #define FRAMETYPE_InlinedCallFrame 0x1 ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameIdentifier::InlinedCallFrame) +#if defined(TARGET_X86) && !defined(UNIX_X86_ABI) +#define FRAMETYPE_TailCallFrame 0x2 +ASMCONSTANTS_C_ASSERT(FRAMETYPE_TailCallFrame == (int)FrameIdentifier::TailCallFrame) +#endif + #define INITIAL_SUCCESS_COUNT 0x100 #define DynamicHelperFrameFlags_Default 0 @@ -150,8 +155,6 @@ ASMCONSTANTS_C_ASSERT(VASigCookie__StubOffset == offsetof(VASigCookie, pNDirectI ASMCONSTANTS_C_ASSERT(SIZEOF_TailCallFrame == sizeof(TailCallFrame)) #endif // !UNIX_X86_ABI -#define SIZEOF_GSCookie 4 - // ICodeManager::SHADOW_SP_IN_FILTER from clr/src/inc/eetwain.h #define SHADOW_SP_IN_FILTER_ASM 0x1 ASMCONSTANTS_C_ASSERT(SHADOW_SP_IN_FILTER_ASM == ICodeManager::SHADOW_SP_IN_FILTER) diff --git a/src/coreclr/vm/i386/cgenx86.cpp b/src/coreclr/vm/i386/cgenx86.cpp index 9ddd7c4b3e6833..86325672575d64 100644 --- a/src/coreclr/vm/i386/cgenx86.cpp +++ b/src/coreclr/vm/i386/cgenx86.cpp @@ -877,26 +877,25 @@ Stub *GenerateInitPInvokeFrameHelper() CORINFO_EE_INFO::InlinedCallFrameInfo FrameInfo; InlinedCallFrame::GetEEInfo(&FrameInfo); - // EDI contains address of the frame on stack (the frame ptr, not its negspace) - unsigned negSpace = FrameInfo.offsetOfFrameVptr; + // EDI contains address of the frame on stack // mov esi, GetThread() psl->X86EmitCurrentThreadFetch(kESI, (1 << kEDI) | (1 << kEBX) | (1 << kECX) | (1 << kEDX)); - // mov [edi + FrameInfo.offsetOfFrameVptr], InlinedCallFrame::GetFrameVtable() - psl->X86EmitOffsetModRM(0xc7, (X86Reg)0x0, kEDI, FrameInfo.offsetOfFrameVptr - negSpace); + // mov [edi], InlinedCallFrame::GetFrameVtable() + psl->X86EmitOffsetModRM(0xc7, (X86Reg)0x0, kEDI, 0); psl->Emit32((DWORD)FrameIdentifier::InlinedCallFrame); // mov eax, [esi + offsetof(Thread, m_pFrame)] // mov [edi + FrameInfo.offsetOfFrameLink], eax psl->X86EmitIndexRegLoad(kEAX, kESI, offsetof(Thread, m_pFrame)); - psl->X86EmitIndexRegStore(kEDI, FrameInfo.offsetOfFrameLink - negSpace, kEAX); + psl->X86EmitIndexRegStore(kEDI, FrameInfo.offsetOfFrameLink, kEAX); // mov [edi + FrameInfo.offsetOfCalleeSavedEbp], ebp - psl->X86EmitIndexRegStore(kEDI, FrameInfo.offsetOfCalleeSavedFP - negSpace, kEBP); + psl->X86EmitIndexRegStore(kEDI, FrameInfo.offsetOfCalleeSavedFP, kEBP); // mov [edi + FrameInfo.offsetOfReturnAddress], 0 - psl->X86EmitOffsetModRM(0xc7, (X86Reg)0x0, kEDI, FrameInfo.offsetOfReturnAddress - negSpace); + psl->X86EmitOffsetModRM(0xc7, (X86Reg)0x0, kEDI, FrameInfo.offsetOfReturnAddress); psl->Emit32(0); // mov [esi + offsetof(Thread, m_pFrame)], edi diff --git a/src/coreclr/vm/i386/jithelp.asm b/src/coreclr/vm/i386/jithelp.asm index cd386d2cd2ad3a..58b4200a871b62 100644 --- a/src/coreclr/vm/i386/jithelp.asm +++ b/src/coreclr/vm/i386/jithelp.asm @@ -58,7 +58,6 @@ endif ; _DEBUG ifdef FEATURE_HIJACK EXTERN JIT_TailCallHelper:PROC endif -EXTERN _g_TailCallFrameVptr:DWORD EXTERN @JIT_FailFast@0:PROC EXTERN g_pPollGC:DWORD @@ -945,9 +944,8 @@ VSDSpaceForFrameChecked: ; At this point, we have enough space on the stack for the TailCallFrame, ; and we may already have slided down the arguments - mov eax, _g_TailCallFrameVptr ; vptr mov edx, dword ptr [esp+OrigRetAddr] ; orig return address - mov dword ptr [edi], eax ; TailCallFrame::vptr + mov dword ptr [edi], FRAMETYPE_TailCallFrame ; FrameIdentifier::TailCallFrame mov dword ptr [edi+28], edx ; TailCallFrame::m_ReturnAddress mov eax, dword ptr [esp+CallersEdi] ; restored edi diff --git a/src/coreclr/vm/i386/jitinterfacex86.cpp b/src/coreclr/vm/i386/jitinterfacex86.cpp index 436f3810563f6f..ba5273606fedcd 100644 --- a/src/coreclr/vm/i386/jitinterfacex86.cpp +++ b/src/coreclr/vm/i386/jitinterfacex86.cpp @@ -97,11 +97,6 @@ extern "C" void STDCALL WriteBarrierAssert(BYTE* ptr, Object* obj) #endif // _DEBUG /*********************************************************************/ -#ifndef UNIX_X86_ABI -extern "C" void* g_TailCallFrameVptr; -void* g_TailCallFrameVptr; -#endif // !UNI_X86_ABI - #ifdef FEATURE_HIJACK extern "C" void STDCALL JIT_TailCallHelper(Thread * pThread); void STDCALL JIT_TailCallHelper(Thread * pThread) @@ -908,11 +903,6 @@ void InitJITHelpers1() #endif // Leave the patched region writable for StompWriteBarrierEphemeral(), StompWriteBarrierResize() - -#ifndef UNIX_X86_ABI - // Initialize g_TailCallFrameVptr for JIT_TailCall helper - g_TailCallFrameVptr = (void*)FrameIdentifier::TailCallFrame; -#endif // !UNIX_X86_ABI } #pragma warning (default : 4731) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 56830ec3cfd6a9..b27c0f10ead130 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -10135,8 +10135,6 @@ void InlinedCallFrame::GetEEInfo(CORINFO_EE_INFO::InlinedCallFrameInfo *pInfo) pInfo->size = sizeof(InlinedCallFrame); pInfo->sizeWithSecretStubArg = sizeof(InlinedCallFrame) + sizeof(PTR_VOID); - pInfo->offsetOfGSCookie = 0; // We no longer have a GS Cookie on coreclr for InlinedCallFrame - pInfo->offsetOfFrameVptr = 0; pInfo->offsetOfFrameLink = Frame::GetOffsetOfNextLink(); pInfo->offsetOfCallSiteSP = offsetof(InlinedCallFrame, m_pCallSiteSP); pInfo->offsetOfCalleeSavedFP = offsetof(InlinedCallFrame, m_pCalleeSavedFP); diff --git a/src/coreclr/vm/loongarch64/asmconstants.h b/src/coreclr/vm/loongarch64/asmconstants.h index fa9b566ab75f6a..cd786de16827a6 100644 --- a/src/coreclr/vm/loongarch64/asmconstants.h +++ b/src/coreclr/vm/loongarch64/asmconstants.h @@ -101,9 +101,6 @@ ASMCONSTANTS_C_ASSERT(LazyMachState_captureIp == offsetof(LazyMachState, capture #define VASigCookie__pNDirectILStub 0x8 ASMCONSTANTS_C_ASSERT(VASigCookie__pNDirectILStub == offsetof(VASigCookie, pNDirectILStub)) -#define SIZEOF__GSCookie 0x8 -ASMCONSTANTS_C_ASSERT(SIZEOF__GSCookie == sizeof(GSCookie)); - #define SIZEOF__Frame 0x10 ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame)); diff --git a/src/coreclr/vm/proftoeeinterfaceimpl.cpp b/src/coreclr/vm/proftoeeinterfaceimpl.cpp index fb86e2770b6cd9..4889972ad18913 100644 --- a/src/coreclr/vm/proftoeeinterfaceimpl.cpp +++ b/src/coreclr/vm/proftoeeinterfaceimpl.cpp @@ -8088,7 +8088,7 @@ StackWalkAction ProfilerStackWalkCallback(CrawlFrame *pCf, PROFILER_STACK_WALK_D if (g_isNewExceptionHandlingEnabled && !pCf->IsFrameless() && InlinedCallFrame::FrameHasActiveCall(pCf->GetFrame())) { // Skip new exception handling helpers - InlinedCallFrame *pInlinedCallFrame = (InlinedCallFrame *)pCf->GetFrame(); + InlinedCallFrame *pInlinedCallFrame = dac_cast(pCf->GetFrame()); PTR_NDirectMethodDesc pMD = pInlinedCallFrame->m_Datum; TADDR datum = dac_cast(pMD); if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper) @@ -8199,7 +8199,7 @@ static BOOL EnsureFrameInitialized(Frame * pFrame) return TRUE; } - HelperMethodFrame * pHMF = (HelperMethodFrame *) pFrame; + HelperMethodFrame * pHMF = dac_cast(pFrame); if (pHMF->EnsureInit( NULL // unwindState diff --git a/src/coreclr/vm/riscv64/asmconstants.h b/src/coreclr/vm/riscv64/asmconstants.h index 125907e69d4b16..47f02c8a75cdfc 100644 --- a/src/coreclr/vm/riscv64/asmconstants.h +++ b/src/coreclr/vm/riscv64/asmconstants.h @@ -96,9 +96,6 @@ ASMCONSTANTS_C_ASSERT(LazyMachState_captureIp == offsetof(LazyMachState, capture #define VASigCookie__pNDirectILStub 0x8 ASMCONSTANTS_C_ASSERT(VASigCookie__pNDirectILStub == offsetof(VASigCookie, pNDirectILStub)) -#define SIZEOF__GSCookie 0x8 -ASMCONSTANTS_C_ASSERT(SIZEOF__GSCookie == sizeof(GSCookie)); - #define SIZEOF__Frame 0x10 ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame)); diff --git a/src/coreclr/vm/stackwalk.cpp b/src/coreclr/vm/stackwalk.cpp index 144507c5e43c12..c84c6105fcff30 100644 --- a/src/coreclr/vm/stackwalk.cpp +++ b/src/coreclr/vm/stackwalk.cpp @@ -696,13 +696,13 @@ void Thread::DebugLogStackWalkInfo(CrawlFrame* pCF, _In_z_ LPCSTR pszTag, UINT32 } else { - LOG((LF_GCROOTS, LL_INFO10000, "STACKWALK: [%03x] %s: EXPLICIT : PC=" FMT_ADDR " SP=" FMT_ADDR " Frame=" FMT_ADDR" vtbl=" FMT_ADDR "\n", + LOG((LF_GCROOTS, LL_INFO10000, "STACKWALK: [%03x] %s: EXPLICIT : PC=" FMT_ADDR " SP=" FMT_ADDR " Frame=" FMT_ADDR" FrameId=" FMT_ADDR "\n", uFramesProcessed, pszTag, DBG_ADDR(GetControlPC(pCF->pRD)), DBG_ADDR(GetRegdisplaySP(pCF->pRD)), DBG_ADDR(pCF->pFrame), - DBG_ADDR((pCF->pFrame != FRAME_TOP) ? pCF->pFrame->GetVTablePtr() : (TADDR)NULL))); + DBG_ADDR((pCF->pFrame != FRAME_TOP) ? (TADDR)pCF->pFrame->GetFrameIdentifier() : (TADDR)NULL))); } } #endif // _DEBUG diff --git a/src/coreclr/vm/threadsuspend.cpp b/src/coreclr/vm/threadsuspend.cpp index 21b197484b9d3f..42ce5cbb355863 100644 --- a/src/coreclr/vm/threadsuspend.cpp +++ b/src/coreclr/vm/threadsuspend.cpp @@ -2671,7 +2671,7 @@ void Thread::RestoreContextSimulated(Thread* pThread, CONTEXT* pCtx, void* pFram RaiseException(EXCEPTION_HIJACK, 0, 0, NULL); } __except (++filter_count == 1 - ? RedirectedHandledJITCaseExceptionFilter(GetExceptionInformation(), (RedirectedThreadFrame*)pFrame, pCtx, dwLastError) + ? RedirectedHandledJITCaseExceptionFilter(GetExceptionInformation(), dac_cast(pFrame), pCtx, dwLastError) : EXCEPTION_CONTINUE_SEARCH) { _ASSERTE(!"Reached body of __except in Thread::RedirectedHandledJITCase"); @@ -3766,7 +3766,7 @@ ThrowControlForThread( } #if defined(FEATURE_EH_FUNCLETS) - *(TADDR*)pfef = (TADDR)FrameIdentifier::FaultingExceptionFrame; + ((Frame*)pfef)->Init(FrameIdentifier::FaultingExceptionFrame); #else // FEATURE_EH_FUNCLETS FaultingExceptionFrame fef; FaultingExceptionFrame *pfef = &fef; From a7d805792f958ec024f58cf0d727306d64644e40 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Fri, 7 Feb 2025 12:30:46 -0800 Subject: [PATCH 14/17] Convert to switch statements --- src/coreclr/vm/FrameTypes.h | 2 +- src/coreclr/vm/frames.cpp | 200 +++++++++++++++++++++++++----------- src/coreclr/vm/frames.h | 57 ++++++++-- 3 files changed, 191 insertions(+), 68 deletions(-) diff --git a/src/coreclr/vm/FrameTypes.h b/src/coreclr/vm/FrameTypes.h index 1efca951a3ba3b..59e1c56356e80e 100644 --- a/src/coreclr/vm/FrameTypes.h +++ b/src/coreclr/vm/FrameTypes.h @@ -48,7 +48,7 @@ FRAME_TYPE_NAME(DebuggerExitFrame) FRAME_TYPE_NAME(DebuggerU2MCatchHandlerFrame) FRAME_TYPE_NAME(ExceptionFilterFrame) #if defined(_DEBUG) -FRAME_TYPE_NAME(AssumeByrefFromJITStack) +FRAME_TYPE_NAME(AssumeByrefFromJITStackFrame) #endif // _DEBUG #undef FRAME_TYPE_NAME diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index 9dfe7f9469b291..9ee726e19bfdc6 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -39,150 +39,222 @@ void Frame::GcScanRoots(promote_func *fn, ScanContext* sc) { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { ((frameType*)this)->GcScanRoots_Impl(fn, sc); return; } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GcScanRoots_Impl(fn, sc); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return; + default: + _ASSERTE(!"Unexpected"); + return; + } } unsigned Frame::GetFrameAttribs() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFrameAttribs_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFrameAttribs_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return 0; + default: + _ASSERTE(!"Unexpected"); + return 0; + } } #ifndef DACCESS_COMPILE void Frame::ExceptionUnwind() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { ((frameType*)this)->ExceptionUnwind_Impl(); return; } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->ExceptionUnwind_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return; + default: + _ASSERTE(!"Unexpected"); + return; + } } #endif BOOL Frame::NeedsUpdateRegDisplay() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->NeedsUpdateRegDisplay_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->NeedsUpdateRegDisplay_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return 0; + default: + _ASSERTE(!"Unexpected"); + return FALSE; + } } BOOL Frame::IsTransitionToNativeFrame() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->IsTransitionToNativeFrame_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->IsTransitionToNativeFrame_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return 0; + default: + _ASSERTE(!"Unexpected"); + return FALSE; + } } MethodDesc *Frame::GetFunction() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFunction_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFunction_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return 0; + default: + _ASSERTE(!"Unexpected"); + return NULL; + } } Assembly *Frame::GetAssembly() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetAssembly_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetAssembly_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return 0; + default: + _ASSERTE(!"Unexpected"); + return NULL; + } } PTR_BYTE Frame::GetIP() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetIP_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetIP_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return 0; + default: + _ASSERTE(!"Unexpected"); + return NULL; + } } TADDR Frame::GetReturnAddressPtr() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetReturnAddressPtr_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetReturnAddressPtr_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return 0; + default: + _ASSERTE(!"Unexpected"); + return (TADDR)0; + } } PCODE Frame::GetReturnAddress() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetReturnAddress_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetReturnAddress_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return 0; + default: + _ASSERTE(!"Unexpected"); + return (PCODE)NULL; + } } void Frame::UpdateRegDisplay(const PREGDISPLAY pRegDisplay, bool updateFloats) { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { ((frameType*)this)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); return; } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return; + default: + _ASSERTE(!"Unexpected"); + return; + } } int Frame::GetFrameType() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetFrameType_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFrameType_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return 0; + default: + _ASSERTE(!"Unexpected"); + return 0; + } } Frame::ETransitionType Frame::GetTransitionType() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetTransitionType_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetTransitionType_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return (ETransitionType)0; + default: + _ASSERTE(!"Unexpected"); + return (ETransitionType)0; + } } Frame::Interception Frame::GetInterception() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetInterception_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetInterception_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return (Interception)0; + default: + _ASSERTE(!"Unexpected"); + return (Interception)0; + } } void Frame::GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP) { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { ((frameType*)this)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); return; } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return; + default: + _ASSERTE(!"Unexpected"); + return; + } } BOOL Frame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->TraceFrame_Impl(thread, fromPatch, trace, regs); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->TraceFrame_Impl(thread, fromPatch, trace, regs); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return FALSE; + default: + _ASSERTE(!"Unexpected"); + return FALSE; + } } #ifdef DACCESS_COMPILE void Frame::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { ((frameType*)this)->EnumMemoryRegions_Impl(flags); return; } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->EnumMemoryRegions_Impl(flags); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return; + default: + _ASSERTE(!"Unexpected"); + return; + } } #endif // DACCESS_COMPILE #if defined(_DEBUG) && !defined(DACCESS_COMPILE) BOOL Frame::Protects(OBJECTREF *ppObjectRef) { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->Protects_Impl(ppObjectRef); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->Protects_Impl(ppObjectRef); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return FALSE; + default: + _ASSERTE(!"Unexpected"); + return FALSE; + } } #endif // defined(_DEBUG) && !defined(DACCESS_COMPILE) @@ -190,18 +262,26 @@ BOOL Frame::Protects(OBJECTREF *ppObjectRef) // TransitionFrame only apis TADDR TransitionFrame::GetTransitionBlock() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->GetTransitionBlock_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetTransitionBlock_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return (TADDR)0; + default: + _ASSERTE(!"Unexpected"); + return (TADDR)0; + } } BOOL TransitionFrame::SuppressParamTypeArg() { -#define FRAME_TYPE_NAME(frameType) if (this->GetFrameIdentifier() == FrameIdentifier::frameType) { return ((frameType*)this)->SuppressParamTypeArg_Impl(); } + switch (this->GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->SuppressParamTypeArg_Impl(); } #include "FrameTypes.h" - _ASSERTE(!"Unexpected"); - return FALSE; + default: + _ASSERTE(!"Unexpected"); + return FALSE; + } } diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 6853f8866e3f50..ee9704f7e4b87e 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -655,6 +655,8 @@ class Frame #ifdef FEATURE_HIJACK //----------------------------------------------------------------------------- +typedef DPTR(class ResumableFrame) PTR_ResumableFrame; + class ResumableFrame : public Frame { public: @@ -916,6 +918,7 @@ class TransitionFrame : public Frame // The define USE_FEF controls how this class is used. Look for occurrences // of USE_FEF. +typedef DPTR(class FaultingExceptionFrame) PTR_FaultingExceptionFrame; class FaultingExceptionFrame : public Frame { @@ -1014,6 +1017,8 @@ class FaultingExceptionFrame : public Frame #ifdef FEATURE_EH_FUNCLETS +typedef DPTR(class SoftwareExceptionFrame) PTR_SoftwareExceptionFrame; + class SoftwareExceptionFrame : public Frame { TADDR m_ReturnAddress; @@ -1154,6 +1159,8 @@ typedef DPTR(FuncEvalFrame) PTR_FuncEvalFrame; // subclases. (see JitInterface for sample use, YOU CAN'T RETURN WHILE IN THE PROTECTED STATE!) //---------------------------------------------------------------------------------------------- +typedef DPTR(class HelperMethodFrame) PTR_HelperMethodFrame; + class HelperMethodFrame : public Frame { public: @@ -1327,6 +1334,8 @@ inline void DoPromote(promote_func *fn, ScanContext* sc, OBJECTREF *address, BOO // a HelplerMethodFrames that also report additional object references //----------------------------------------------------------------------------- +typedef DPTR(class HelperMethodFrame_1OBJ) PTR_HelperMethodFrame_1OBJ; + class HelperMethodFrame_1OBJ : public HelperMethodFrame { public: @@ -1382,6 +1391,8 @@ class HelperMethodFrame_1OBJ : public HelperMethodFrame // HelperMethodFrame_2OBJ //----------------------------------------------------------------------------- +typedef DPTR(class HelperMethodFrame_2OBJ) PTR_HelperMethodFrame_2OBJ; + class HelperMethodFrame_2OBJ : public HelperMethodFrame { public: @@ -1437,6 +1448,8 @@ class HelperMethodFrame_2OBJ : public HelperMethodFrame // HelperMethodFrame_3OBJ //----------------------------------------------------------------------------- +typedef DPTR(class HelperMethodFrame_3OBJ) PTR_HelperMethodFrame_3OBJ; + class HelperMethodFrame_3OBJ : public HelperMethodFrame { public: @@ -1499,6 +1512,8 @@ class HelperMethodFrame_3OBJ : public HelperMethodFrame // HelperMethodFrame_PROTECTOBJ //----------------------------------------------------------------------------- +typedef DPTR(class HelperMethodFrame_PROTECTOBJ) PTR_HelperMethodFrame_PROTECTOBJ; + class HelperMethodFrame_PROTECTOBJ : public HelperMethodFrame { public: @@ -1794,6 +1809,8 @@ typedef DPTR(class ComMethodFrame) PTR_ComMethodFrame; // This represents a generic call from CLR to COM //------------------------------------------------------------------------ +typedef DPTR(class CLRToCOMMethodFrame) PTR_CLRToCOMMethodFrame; + class CLRToCOMMethodFrame : public FramedMethodFrame { public: @@ -1827,6 +1844,8 @@ class CLRToCOMMethodFrame : public FramedMethodFrame // This represents a call from a helper to GetILStubForCalli //------------------------------------------------------------------------ +typedef DPTR(class PInvokeCalliFrame) PTR_PInvokeCalliFrame; + class PInvokeCalliFrame : public FramedMethodFrame { PTR_VASigCookie m_pVASigCookie; @@ -1890,6 +1909,9 @@ class PInvokeCalliFrame : public FramedMethodFrame // it gets us back to where the return should have gone (and eventually will // go). //------------------------------------------------------------------------ + +typedef DPTR(class HijackFrame) PTR_HijackFrame; + class HijackFrame : public Frame { public: @@ -1946,6 +1968,8 @@ class HijackFrame : public Frame // stub, we need this frame to keep things straight. //------------------------------------------------------------------------ +typedef DPTR(class PrestubMethodFrame) PTR_PrestubMethodFrame; + class PrestubMethodFrame : public FramedMethodFrame { public: @@ -2078,6 +2102,8 @@ class StubDispatchFrame : public FramedMethodFrame typedef DPTR(class StubDispatchFrame) PTR_StubDispatchFrame; +typedef DPTR(class CallCountingHelperFrame) PTR_CallCountingHelperFrame; + class CallCountingHelperFrame : public FramedMethodFrame { public: @@ -2181,6 +2207,9 @@ typedef DPTR(class DynamicHelperFrame) PTR_DynamicHelperFrame; // which pinvoke-inlined a call to a COM interface, which happenned to be // implemented by a managed function via COM-interop. //------------------------------------------------------------------------ + +typedef DPTR(class ComPrestubMethodFrame) PTR_ComPrestubMethodFrame; + class ComPrestubMethodFrame : public ComMethodFrame { friend class CheckAsmOffsets; @@ -2295,6 +2324,8 @@ struct ByRefInfo // ProtectByRefsFrame //----------------------------------------------------------------------------- +typedef DPTR(class ProtectByRefsFrame) PTR_ProtectByRefsFrame; + class ProtectByRefsFrame : public Frame { public: @@ -2335,6 +2366,7 @@ struct ValueClassInfo // ProtectValueClassFrame //----------------------------------------------------------------------------- +typedef DPTR(class ProtectValueClassFrame) PTR_ProtectValueClassFrame; class ProtectValueClassFrame : public Frame { @@ -2381,6 +2413,8 @@ BOOL IsProtectedByGCFrame(OBJECTREF *ppObjectRef); // GetFrameType and GetInterception. //------------------------------------------------------------------------ +typedef DPTR(class DebuggerClassInitMarkFrame) PTR_DebuggerClassInitMarkFrame; + class DebuggerClassInitMarkFrame : public Frame { public: @@ -2412,6 +2446,8 @@ class DebuggerClassInitMarkFrame : public Frame // the stack. //------------------------------------------------------------------------ +typedef DPTR(class DebuggerExitFrame) PTR_DebuggerExitFrame; + class DebuggerExitFrame : public Frame { public: @@ -2464,6 +2500,8 @@ class DebuggerExitFrame : public Frame // Currently this frame is only used in code:DispatchInfo.InvokeMember, which is an U2M transition. // +typedef DPTR(class DebuggerU2MCatchHandlerFrame) PTR_DebuggerU2MCatchHandlerFrame; + class DebuggerU2MCatchHandlerFrame : public Frame { public: @@ -2724,6 +2762,8 @@ class TailCallFrame : public Frame // life is to set SHADOW_SP_FILTER_DONE during unwind from exception filter. //------------------------------------------------------------------------ +typedef DPTR(class ExceptionFilterFrame) PTR_ExceptionFilterFrame; + class ExceptionFilterFrame : public Frame { size_t* m_pShadowSP; @@ -2763,13 +2803,16 @@ class ExceptionFilterFrame : public Frame #ifdef _DEBUG // We use IsProtectedByGCFrame to check if some OBJECTREF pointers are protected // against GC. That function doesn't know if a byref is from managed stack thus -// protected by JIT. AssumeByrefFromJITStack is used to bypass that check if an +// protected by JIT. AssumeByrefFromJITStackFrame is used to bypass that check if an // OBJECTRef pointer is passed from managed code to an FCall and it's in stack. -class AssumeByrefFromJITStack : public Frame + +typedef DPTR(class AssumeByrefFromJITStackFrame) PTR_AssumeByrefFromJITStackFrame; + +class AssumeByrefFromJITStackFrame : public Frame { public: #ifndef DACCESS_COMPILE - AssumeByrefFromJITStack(OBJECTREF *pObjRef) : Frame(FrameIdentifier::AssumeByrefFromJITStack) + AssumeByrefFromJITStackFrame(OBJECTREF *pObjRef) : Frame(FrameIdentifier::AssumeByrefFromJITStackFrame) { m_pObjRef = pObjRef; } @@ -2783,7 +2826,7 @@ class AssumeByrefFromJITStack : public Frame private: OBJECTREF *m_pObjRef; -}; //AssumeByrefFromJITStack +}; //AssumeByrefFromJITStackFrame #endif //_DEBUG @@ -2923,14 +2966,14 @@ class AssumeByrefFromJITStack : public Frame /*pointer points to GC heap, the FCall still needs to protect it explicitly */ \ ASSERT_ADDRESS_IN_STACK (__objRef); \ do { \ - AssumeByrefFromJITStack __dummyAssumeByrefFromJITStack ((__objRef)); \ - __dummyAssumeByrefFromJITStack.Push (); \ + AssumeByrefFromJITStackFrame __dummyAssumeByrefFromJITStackFrame ((__objRef)); \ + __dummyAssumeByrefFromJITStackFrame.Push (); \ /* work around unreachable code warning */ \ if (true) { DEBUG_ASSURE_NO_RETURN_BEGIN(GC_PROTECT) #define ASSUME_BYREF_FROM_JIT_STACK_END() \ DEBUG_ASSURE_NO_RETURN_END(GC_PROTECT) } \ - __dummyAssumeByrefFromJITStack.Pop(); } while(0) + __dummyAssumeByrefFromJITStackFrame.Pop(); } while(0) #else //defined (_DEBUG) && !defined (DACCESS_COMPILE) #define ASSUME_BYREF_FROM_JIT_STACK_BEGIN(__objRef) #define ASSUME_BYREF_FROM_JIT_STACK_END() From c01630f40aa2801d9f05c3aacc6b1af0ce160c79 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Fri, 7 Feb 2025 12:43:09 -0800 Subject: [PATCH 15/17] Use UNREACHABLE to potentially make stuff faster --- src/coreclr/vm/frames.cpp | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index 9ee726e19bfdc6..d997d929e66100 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -44,7 +44,7 @@ void Frame::GcScanRoots(promote_func *fn, ScanContext* sc) #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GcScanRoots_Impl(fn, sc); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return; } } @@ -57,7 +57,7 @@ unsigned Frame::GetFrameAttribs() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFrameAttribs_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return 0; } } @@ -70,7 +70,7 @@ void Frame::ExceptionUnwind() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->ExceptionUnwind_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return; } } @@ -83,7 +83,7 @@ BOOL Frame::NeedsUpdateRegDisplay() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->NeedsUpdateRegDisplay_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return FALSE; } } @@ -95,7 +95,7 @@ BOOL Frame::IsTransitionToNativeFrame() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->IsTransitionToNativeFrame_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return FALSE; } } @@ -107,7 +107,7 @@ MethodDesc *Frame::GetFunction() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFunction_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return NULL; } } @@ -119,7 +119,7 @@ Assembly *Frame::GetAssembly() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetAssembly_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return NULL; } } @@ -130,7 +130,7 @@ PTR_BYTE Frame::GetIP() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetIP_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return NULL; } } @@ -142,7 +142,7 @@ TADDR Frame::GetReturnAddressPtr() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetReturnAddressPtr_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return (TADDR)0; } } @@ -153,7 +153,7 @@ PCODE Frame::GetReturnAddress() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetReturnAddress_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return (PCODE)NULL; } } @@ -165,7 +165,7 @@ void Frame::UpdateRegDisplay(const PREGDISPLAY pRegDisplay, bool updateFloats) #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return; } } @@ -177,7 +177,7 @@ int Frame::GetFrameType() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFrameType_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return 0; } } @@ -189,7 +189,7 @@ Frame::ETransitionType Frame::GetTransitionType() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetTransitionType_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return (ETransitionType)0; } } @@ -201,7 +201,7 @@ Frame::Interception Frame::GetInterception() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetInterception_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return (Interception)0; } } @@ -213,7 +213,7 @@ void Frame::GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP) #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return; } } @@ -225,7 +225,7 @@ BOOL Frame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->TraceFrame_Impl(thread, fromPatch, trace, regs); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return FALSE; } } @@ -238,7 +238,7 @@ void Frame::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->EnumMemoryRegions_Impl(flags); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return; } } @@ -252,7 +252,7 @@ BOOL Frame::Protects(OBJECTREF *ppObjectRef) #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->Protects_Impl(ppObjectRef); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return FALSE; } } @@ -267,7 +267,7 @@ TADDR TransitionFrame::GetTransitionBlock() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetTransitionBlock_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return (TADDR)0; } } @@ -279,7 +279,7 @@ BOOL TransitionFrame::SuppressParamTypeArg() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->SuppressParamTypeArg_Impl(); } #include "FrameTypes.h" default: - _ASSERTE(!"Unexpected"); + UNREACHABLE(); return FALSE; } } From 0cbc4191587060d8f7f76bfb42ec0c91293967c4 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Fri, 7 Feb 2025 14:30:45 -0800 Subject: [PATCH 16/17] Address more feedback --- src/coreclr/vm/amd64/ComCallPreStub.asm | 4 +- src/coreclr/vm/amd64/GenericComCallStubs.asm | 2 - .../vm/amd64/redirectedhandledjitcase.S | 2 - src/coreclr/vm/frames.cpp | 46 +++++++++++-------- src/coreclr/vm/frames.h | 2 + 5 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/coreclr/vm/amd64/ComCallPreStub.asm b/src/coreclr/vm/amd64/ComCallPreStub.asm index 5fe6231c4054fb..237fcd954f10f0 100644 --- a/src/coreclr/vm/amd64/ComCallPreStub.asm +++ b/src/coreclr/vm/amd64/ComCallPreStub.asm @@ -26,8 +26,8 @@ NESTED_ENTRY ComCallPreStub, _TEXT ; ComPrestubMethodFrame::m_ReturnAddress ; ComPrestubMethodFrame::m_pFuncDesc ; Frame::m_Next -; __VFN_table <-- rsp + ComCallPreStub_ComPrestubMethodFrame_OFFSET -; HRESULT <-- rsp + ComCallPreStub_HRESULT_OFFSET +; FrameIdentifier::ComPrestubMethodFrame <-- rsp + ComCallPreStub_ComPrestubMethodFrame_OFFSET +; HRESULT <-- rsp + ComCallPreStub_ERRORRETVAL_OFFSET ; (optional padding to qword align xmm save area) ; xmm3 ; xmm2 diff --git a/src/coreclr/vm/amd64/GenericComCallStubs.asm b/src/coreclr/vm/amd64/GenericComCallStubs.asm index ecdba9eee05d84..355c6baae2dd4c 100644 --- a/src/coreclr/vm/amd64/GenericComCallStubs.asm +++ b/src/coreclr/vm/amd64/GenericComCallStubs.asm @@ -52,8 +52,6 @@ GenericComCallStub_STACK_FRAME_SIZE = 0 GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE + (SIZEOF__ComMethodFrame - 8) GenericComCallStub_ComMethodFrame_NEGOFFSET = GenericComCallStub_STACK_FRAME_SIZE -GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE - ; Ensure that the offset of the XMM save area will be 16-byte aligned. if ((GenericComCallStub_STACK_FRAME_SIZE + 8) MOD 16) ne 0 GenericComCallStub_STACK_FRAME_SIZE = GenericComCallStub_STACK_FRAME_SIZE + 8 diff --git a/src/coreclr/vm/amd64/redirectedhandledjitcase.S b/src/coreclr/vm/amd64/redirectedhandledjitcase.S index 5adce24b21fbad..c326de58571240 100644 --- a/src/coreclr/vm/amd64/redirectedhandledjitcase.S +++ b/src/coreclr/vm/amd64/redirectedhandledjitcase.S @@ -5,8 +5,6 @@ #include "unixasmmacros.inc" #include "asmconstants.h" -#define FaultingExceptionFrame_StackAlloc (SIZEOF__FaultingExceptionFrame) -#define FaultingExceptionFrame_FrameOffset 0 #define OFFSET_OF_FRAME 0 .macro GenerateRedirectedStubWithFrame stub, target diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index d997d929e66100..44d217803c0b58 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -37,6 +37,12 @@ #define CHECK_APP_DOMAIN 0 +#ifdef DACCESS_COMPILE +#define FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE() _ASSERTE("!Unexpected value in Frame") +#else +#define FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE() DoJITFailFast() +#endif + void Frame::GcScanRoots(promote_func *fn, ScanContext* sc) { switch (this->GetFrameIdentifier()) @@ -44,7 +50,7 @@ void Frame::GcScanRoots(promote_func *fn, ScanContext* sc) #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GcScanRoots_Impl(fn, sc); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return; } } @@ -57,7 +63,7 @@ unsigned Frame::GetFrameAttribs() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFrameAttribs_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return 0; } } @@ -70,7 +76,7 @@ void Frame::ExceptionUnwind() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->ExceptionUnwind_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return; } } @@ -83,7 +89,7 @@ BOOL Frame::NeedsUpdateRegDisplay() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->NeedsUpdateRegDisplay_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return FALSE; } } @@ -95,7 +101,7 @@ BOOL Frame::IsTransitionToNativeFrame() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->IsTransitionToNativeFrame_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return FALSE; } } @@ -107,7 +113,7 @@ MethodDesc *Frame::GetFunction() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFunction_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return NULL; } } @@ -119,7 +125,7 @@ Assembly *Frame::GetAssembly() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetAssembly_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return NULL; } } @@ -130,7 +136,7 @@ PTR_BYTE Frame::GetIP() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetIP_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return NULL; } } @@ -142,7 +148,7 @@ TADDR Frame::GetReturnAddressPtr() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetReturnAddressPtr_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return (TADDR)0; } } @@ -153,7 +159,7 @@ PCODE Frame::GetReturnAddress() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetReturnAddress_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return (PCODE)NULL; } } @@ -165,7 +171,7 @@ void Frame::UpdateRegDisplay(const PREGDISPLAY pRegDisplay, bool updateFloats) #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return; } } @@ -177,7 +183,7 @@ int Frame::GetFrameType() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFrameType_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return 0; } } @@ -189,7 +195,7 @@ Frame::ETransitionType Frame::GetTransitionType() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetTransitionType_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return (ETransitionType)0; } } @@ -201,7 +207,7 @@ Frame::Interception Frame::GetInterception() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetInterception_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return (Interception)0; } } @@ -213,7 +219,7 @@ void Frame::GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP) #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return; } } @@ -225,7 +231,7 @@ BOOL Frame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->TraceFrame_Impl(thread, fromPatch, trace, regs); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return FALSE; } } @@ -238,7 +244,7 @@ void Frame::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->EnumMemoryRegions_Impl(flags); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return; } } @@ -252,7 +258,7 @@ BOOL Frame::Protects(OBJECTREF *ppObjectRef) #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->Protects_Impl(ppObjectRef); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return FALSE; } } @@ -267,7 +273,7 @@ TADDR TransitionFrame::GetTransitionBlock() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetTransitionBlock_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return (TADDR)0; } } @@ -279,7 +285,7 @@ BOOL TransitionFrame::SuppressParamTypeArg() #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->SuppressParamTypeArg_Impl(); } #include "FrameTypes.h" default: - UNREACHABLE(); + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); return FALSE; } } diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index ee9704f7e4b87e..137cd43009a56e 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -2719,6 +2719,8 @@ bool isRetAddr(TADDR retAddr, TADDR* whereCalled); // as tail calls on interface calls are uncommon. //------------------------------------------------------------------------ +typedef DPTR(class TailCallFrame) PTR_TailCallFrame; + class TailCallFrame : public Frame { TADDR m_CallerAddress; // the address the tailcall was initiated from From cc5d9ede8a0ff6fba5211b2c4e8ed4c47e0b4a12 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Mon, 10 Feb 2025 14:12:08 -0800 Subject: [PATCH 17/17] Hopefully final nits --- src/coreclr/vm/frames.cpp | 80 ++++++++++++++++----------------------- src/coreclr/vm/frames.h | 12 +----- 2 files changed, 34 insertions(+), 58 deletions(-) diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index 44d217803c0b58..f5628896728d2d 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -45,7 +45,7 @@ void Frame::GcScanRoots(promote_func *fn, ScanContext* sc) { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GcScanRoots_Impl(fn, sc); } #include "FrameTypes.h" @@ -55,10 +55,9 @@ void Frame::GcScanRoots(promote_func *fn, ScanContext* sc) } } - unsigned Frame::GetFrameAttribs() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFrameAttribs_Impl(); } #include "FrameTypes.h" @@ -71,7 +70,7 @@ unsigned Frame::GetFrameAttribs() #ifndef DACCESS_COMPILE void Frame::ExceptionUnwind() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->ExceptionUnwind_Impl(); } #include "FrameTypes.h" @@ -80,11 +79,11 @@ void Frame::ExceptionUnwind() return; } } - #endif + BOOL Frame::NeedsUpdateRegDisplay() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->NeedsUpdateRegDisplay_Impl(); } #include "FrameTypes.h" @@ -96,7 +95,7 @@ BOOL Frame::NeedsUpdateRegDisplay() BOOL Frame::IsTransitionToNativeFrame() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->IsTransitionToNativeFrame_Impl(); } #include "FrameTypes.h" @@ -108,7 +107,7 @@ BOOL Frame::IsTransitionToNativeFrame() MethodDesc *Frame::GetFunction() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFunction_Impl(); } #include "FrameTypes.h" @@ -120,7 +119,7 @@ MethodDesc *Frame::GetFunction() Assembly *Frame::GetAssembly() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetAssembly_Impl(); } #include "FrameTypes.h" @@ -129,9 +128,10 @@ Assembly *Frame::GetAssembly() return NULL; } } + PTR_BYTE Frame::GetIP() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetIP_Impl(); } #include "FrameTypes.h" @@ -143,7 +143,7 @@ PTR_BYTE Frame::GetIP() TADDR Frame::GetReturnAddressPtr() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetReturnAddressPtr_Impl(); } #include "FrameTypes.h" @@ -152,9 +152,10 @@ TADDR Frame::GetReturnAddressPtr() return (TADDR)0; } } + PCODE Frame::GetReturnAddress() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetReturnAddress_Impl(); } #include "FrameTypes.h" @@ -166,7 +167,7 @@ PCODE Frame::GetReturnAddress() void Frame::UpdateRegDisplay(const PREGDISPLAY pRegDisplay, bool updateFloats) { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); } #include "FrameTypes.h" @@ -178,7 +179,7 @@ void Frame::UpdateRegDisplay(const PREGDISPLAY pRegDisplay, bool updateFloats) int Frame::GetFrameType() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFrameType_Impl(); } #include "FrameTypes.h" @@ -190,7 +191,7 @@ int Frame::GetFrameType() Frame::ETransitionType Frame::GetTransitionType() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetTransitionType_Impl(); } #include "FrameTypes.h" @@ -202,7 +203,7 @@ Frame::ETransitionType Frame::GetTransitionType() Frame::Interception Frame::GetInterception() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetInterception_Impl(); } #include "FrameTypes.h" @@ -214,7 +215,7 @@ Frame::Interception Frame::GetInterception() void Frame::GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP) { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); } #include "FrameTypes.h" @@ -226,7 +227,7 @@ void Frame::GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP) BOOL Frame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->TraceFrame_Impl(thread, fromPatch, trace, regs); } #include "FrameTypes.h" @@ -239,7 +240,7 @@ BOOL Frame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, #ifdef DACCESS_COMPILE void Frame::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->EnumMemoryRegions_Impl(flags); } #include "FrameTypes.h" @@ -248,12 +249,12 @@ void Frame::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) return; } } - #endif // DACCESS_COMPILE + #if defined(_DEBUG) && !defined(DACCESS_COMPILE) BOOL Frame::Protects(OBJECTREF *ppObjectRef) { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->Protects_Impl(ppObjectRef); } #include "FrameTypes.h" @@ -262,13 +263,12 @@ BOOL Frame::Protects(OBJECTREF *ppObjectRef) return FALSE; } } - #endif // defined(_DEBUG) && !defined(DACCESS_COMPILE) // TransitionFrame only apis TADDR TransitionFrame::GetTransitionBlock() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetTransitionBlock_Impl(); } #include "FrameTypes.h" @@ -280,7 +280,7 @@ TADDR TransitionFrame::GetTransitionBlock() BOOL TransitionFrame::SuppressParamTypeArg() { - switch (this->GetFrameIdentifier()) + switch (GetFrameIdentifier()) { #define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->SuppressParamTypeArg_Impl(); } #include "FrameTypes.h" @@ -290,8 +290,6 @@ BOOL TransitionFrame::SuppressParamTypeArg() } } - - //----------------------------------------------------------------------- #if _DEBUG //----------------------------------------------------------------------- @@ -433,20 +431,13 @@ bool isLegalManagedCodeCaller(PCODE retAddr) { #endif //0 -//----------------------------------------------------------------------- -// Count of the number of frame types -const size_t FRAME_TYPES_COUNT = -#define FRAME_TYPE_NAME(frameType) +1 -#include "frames.h" -; - #if defined (_DEBUG_IMPL) // _DEBUG and !DAC //----------------------------------------------------------------------- // Implementation of the global table of names. On the DAC side, just the global pointer. // On the runtime side, the array of names. - #define FRAME_TYPE_NAME(x) {FrameIdentifier::x, #x} , - static FrameTypeName FrameTypeNameTable[] = { + #define FRAME_TYPE_NAME(x) #x, + static PTR_CSTR FrameTypeNameTable[] = { #include "frames.h" }; @@ -455,15 +446,11 @@ const size_t FRAME_TYPES_COUNT = PTR_CSTR Frame::GetFrameTypeName(FrameIdentifier frameIdentifier) { LIMITED_METHOD_CONTRACT; - for (size_t i=0; i= FrameIdentifier::CountPlusOne) { - if (frameIdentifier == FrameTypeNameTable[(int)i].id) - { - return FrameTypeNameTable[(int)i].name; - } + return NULL; } - - return NULL; + return FrameTypeNameTable[(int)frameIdentifier - 1]; } // char* Frame::FrameTypeName() @@ -512,7 +499,6 @@ void Frame::LogFrameChain( #ifndef DACCESS_COMPILE -// static void Frame::Init(FrameIdentifier frameIdentifier) { LIMITED_METHOD_CONTRACT; @@ -521,10 +507,10 @@ void Frame::Init(FrameIdentifier frameIdentifier) #endif // DACCESS_COMPILE -// Returns true if the Frame's VTablePtr is valid +// Returns true if the Frame has a valid FrameIdentifier // static -bool Frame::HasFrameIdentifier(Frame * pFrame) +bool Frame::HasValidFrameIdentifier(Frame * pFrame) { WRAPPER_NO_CONTRACT; @@ -586,7 +572,7 @@ VOID Frame::Push(Thread *pThread) // during stack-walking. !g_pConfig->fAssertOnFailFast() || (m_Next == FRAME_TOP) || - (Frame::HasFrameIdentifier(m_Next))); + (Frame::HasValidFrameIdentifier(m_Next))); pThread->SetFrame(this); } @@ -622,7 +608,7 @@ VOID Frame::Pop(Thread *pThread) // during stack-walking. !g_pConfig->fAssertOnFailFast() || (m_Next == FRAME_TOP) || - (Frame::HasFrameIdentifier(m_Next))); + (Frame::HasValidFrameIdentifier(m_Next))); pThread->SetFrame(m_Next); m_Next = NULL; diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 137cd43009a56e..faf0e660e03541 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -230,16 +230,6 @@ enum class FrameIdentifier : TADDR CountPlusOne }; -//----------------------------------------------------------------------------- -// For reporting on types of frames at runtime. -class FrameTypeName -{ -public: - FrameIdentifier id; - PTR_CSTR name; -}; -typedef DPTR(FrameTypeName) PTR_FrameTypeName; - // TransitionFrame only apis class TransitionFrame; TADDR Frame_GetTransitionBlock(TransitionFrame* frame); @@ -422,7 +412,7 @@ class Frame } #endif // #ifndef DACCESS_COMPILE - static bool HasFrameIdentifier(Frame * pFrame); + static bool HasValidFrameIdentifier(Frame * pFrame); void Init(FrameIdentifier frameIdentifier); // Callers, note that the REGDISPLAY parameter is actually in/out. While