diff --git a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp index 3f60dec6a9b1ad..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) @@ -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->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->GetVTablePtr() != InlinedCallFrame::GetMethodFrameVPtr()) || + 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->GetVTablePtr() != StubDispatchFrame::GetMethodFrameVPtr()) + if (pFrame->GetFrameIdentifier() != FrameIdentifier::StubDispatchFrame) { if (it == Frame::INTERCEPTION_SECURITY) { diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 6c494e29922628..0345218e861b45 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. @@ -16799,4 +16796,256 @@ 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->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 f16227820451ac..4f69164a292f9f 100644 --- a/src/coreclr/debug/ee/debugger.inl +++ b/src/coreclr/debug/ee/debugger.inl @@ -132,256 +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->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..d2a73fbd9b8e1b 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->GetVTablePtr() == DebuggerExitFrame::GetMethodFrameVPtr()) + if (pFrame->GetFrameIdentifier() == FrameIdentifier::DebuggerExitFrame) { if (pPotentialFP != NULL) { @@ -462,9 +462,9 @@ bool HasExitRuntime(Frame *pFrame, DebuggerFrameData *pData, FramePointer *pPote } return true; } - else if (pFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()) + 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, @@ -814,9 +814,9 @@ 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->GetFrameIdentifier() == FrameIdentifier::ComMethodFrame) { - ComMethodFrame* pCOMFrame = static_cast (pFrame); + ComMethodFrame* pCOMFrame = dac_cast (pFrame); ComCallMethodDesc* pCMD = reinterpret_cast (pCOMFrame->ComMethodFrame::GetDatum()); pMDHint = pCMD->GetInterfaceMethodDesc(); @@ -1190,7 +1190,7 @@ StackWalkAction TrackUMChain(CrawlFrame *pCF, DebuggerFrameData *d) #ifdef FEATURE_COMINTEROP if ((frame != NULL) && - (frame->GetVTablePtr() == CLRToCOMMethodFrame::GetMethodFrameVPtr())) + (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->GetVTablePtr() == StubDispatchFrame::GetMethodFrameVPtr()) + if (frame->GetFrameIdentifier() == FrameIdentifier::StubDispatchFrame) { use = false; } @@ -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/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/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/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/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/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/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 eee9a5859ecb43..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,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 _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 // 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* @@ -5946,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 new file mode 100644 index 00000000000000..59e1c56356e80e --- /dev/null +++ b/src/coreclr/vm/FrameTypes.h @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#ifndef FRAME_TYPE_NAME +#define FRAME_TYPE_NAME(frameType) +#endif + +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) +#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) +#ifdef FEATURE_COMINTEROP +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(ExceptionFilterFrame) +#if defined(_DEBUG) +FRAME_TYPE_NAME(AssumeByrefFromJITStackFrame) +#endif // _DEBUG + +#undef FRAME_TYPE_NAME diff --git a/src/coreclr/vm/amd64/ComCallPreStub.asm b/src/coreclr/vm/amd64/ComCallPreStub.asm index 8057d86a078071..237fcd954f10f0 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() @@ -27,9 +26,8 @@ NESTED_ENTRY ComCallPreStub, _TEXT ; ComPrestubMethodFrame::m_ReturnAddress ; ComPrestubMethodFrame::m_pFuncDesc ; Frame::m_Next -; __VFN_table <-- rsp + ComCallPreStub_ComPrestubMethodFrame_OFFSET -; gsCookie -; 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 @@ -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..355c6baae2dd4c 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,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 + SIZEOF_GSCookie - ; 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 @@ -74,7 +70,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 +98,6 @@ OFFSETOF_GSCookie = GenericComCallStub_ComMethodFrame_OFFSET - SIZEOF_GSCookie END_PROLOGUE - mov rcx, s_gsCookie - mov [rsp + OFFSETOF_GSCookie], rcx - ; ; Call COMToCLRWorker. ; @@ -113,14 +105,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 4f19cb7d032a21..a18ed56b752d3c 100644 --- a/src/coreclr/vm/amd64/PInvokeStubs.asm +++ b/src/coreclr/vm/amd64/PInvokeStubs.asm @@ -8,8 +8,6 @@ extern GenericPInvokeCalliStubWorker:proc extern VarargPInvokeStubWorker:proc extern JIT_PInvokeEndRarePath:proc -extern s_gsCookie:QWORD -extern ??_7InlinedCallFrame@@6B@:QWORD extern g_TrapReturningThreads:DWORD ; @@ -135,19 +133,13 @@ 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) - lea rax,[??_7InlinedCallFrame@@6B@] - mov qword ptr [rcx], rax + mov qword ptr [rcx], FRAMETYPE_InlinedCallFrame mov qword ptr [rcx + OFFSETOF__InlinedCallFrame__m_Datum], 0 @@ -176,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 4b38aeeaca52d7..bd86950467f495 100644 --- a/src/coreclr/vm/amd64/asmconstants.h +++ b/src/coreclr/vm/amd64/asmconstants.h @@ -78,8 +78,8 @@ ASMCONSTANTS_C_ASSERT(SIZEOF_CalleeSavedRegisters == sizeof(CalleeSavedRegisters ASMCONSTANTS_C_ASSERT(SIZEOF_CalleeSavedRegisters == sizeof(CalleeSavedRegisters)); #endif -#define SIZEOF_GSCookie 0x8 -ASMCONSTANTS_C_ASSERT(SIZEOF_GSCookie == sizeof(GSCookie)); +#define FRAMETYPE_InlinedCallFrame 0x1 +ASMCONSTANTS_C_ASSERT(FRAMETYPE_InlinedCallFrame == (int)FrameIdentifier::InlinedCallFrame) #define OFFSETOF__Frame____VFN_table 0 @@ -433,7 +433,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/cgenamd64.cpp b/src/coreclr/vm/amd64/cgenamd64.cpp index 7548cd8a1742b5..ec952dd0f6f873 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; @@ -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/amd64/pinvokestubs.S b/src/coreclr/vm/amd64/pinvokestubs.S index 6c57f8713831b6..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,15 +137,8 @@ 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 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 @@ -181,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..c326de58571240 100644 --- a/src/coreclr/vm/amd64/redirectedhandledjitcase.S +++ b/src/coreclr/vm/amd64/redirectedhandledjitcase.S @@ -5,9 +5,7 @@ #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 OFFSET_OF_FRAME 0 .macro GenerateRedirectedStubWithFrame stub, target diff --git a/src/coreclr/vm/arm/asmconstants.h b/src/coreclr/vm/arm/asmconstants.h index dbd83bd6a947a2..4495b42dca78ca 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)FrameIdentifier::InlinedCallFrame) + #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 #define DynamicHelperFrameFlags_ObjectArg2 2 @@ -79,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/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 5875a58749492a..cc84c541a183bb 100644 --- a/src/coreclr/vm/arm/pinvokestubs.S +++ b/src/coreclr/vm/arm/pinvokestubs.S @@ -79,27 +79,12 @@ 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 - // 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) + mov r1, #FRAMETYPE_InlinedCallFrame str r1, [r4] mov r1, 0 @@ -138,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 57594beb859d82..08448a0ab0d555 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 { @@ -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,32 +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.offsetOfGSCookie], GetProcessGSCookie() - psl->ThumbEmitMovConstant(regScratch, GetProcessGSCookie()); - psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfGSCookie - negSpace); - - // mov [regFrame + FrameInfo.offsetOfFrameVptr], InlinedCallFrame::GetMethodFrameVPtr() - psl->ThumbEmitMovConstant(regScratch, InlinedCallFrame::GetMethodFrameVPtr()); - psl->ThumbEmitStoreRegIndirect(regScratch, regFrame, FrameInfo.offsetOfFrameVptr - negSpace); + // mov [regFrame], FrameIdentifier::InlinedCallFrame + psl->ThumbEmitMovConstant(regScratch, (DWORD)FrameIdentifier::InlinedCallFrame); + 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)); @@ -1497,7 +1490,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 +1524,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 +1553,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 { @@ -1618,13 +1611,13 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats } #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); } -void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void ResumableFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -1660,7 +1653,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/PInvokeStubs.asm b/src/coreclr/vm/arm64/PInvokeStubs.asm index 37699e790b241e..05e21ae22d16e4 100644 --- a/src/coreclr/vm/arm64/PInvokeStubs.asm +++ b/src/coreclr/vm/arm64/PInvokeStubs.asm @@ -12,13 +12,8 @@ IMPORT GenericPInvokeCalliStubWorker IMPORT JIT_PInvokeEndRarePath - 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 @@ -119,34 +114,29 @@ __PInvokeStubWorkerName SETS "$FuncPrefix":CC:"StubWorker" ; LEAF_ENTRY JIT_PInvokeBegin - ldr x9, =s_gsCookie - ldr x9, [x9] + ;; set first slot to the value of InlinedCallFrame identifier (checked by runtime code) + mov x9, #FRAMETYPE_InlinedCallFrame 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 - str x9, [x10] - - 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 @@ -160,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/asmconstants.h b/src/coreclr/vm/arm64/asmconstants.h index 9c263b945a84f9..87003693b87164 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)FrameIdentifier::InlinedCallFrame) + #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 #define DynamicHelperFrameFlags_ObjectArg2 2 @@ -100,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/arm64/asmhelpers.S b/src/coreclr/vm/arm64/asmhelpers.S index fdfa833d250f7b..223186f4dcf18a 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 cd7c06500ee315..085497778442dd 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 @@ -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 e2eacde16a4ff8..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,16 +90,12 @@ 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 - // 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) + mov x9, #FRAMETYPE_InlinedCallFrame str x9, [x19] str xzr, [x19, #InlinedCallFrame__m_Datum] @@ -134,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/arm64/stubs.cpp b/src/coreclr/vm/arm64/stubs.cpp index fdc54c5815918a..427bf342003389 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,19 +722,19 @@ 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; } #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); } -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/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/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/clrtocomcall.cpp b/src/coreclr/vm/clrtocomcall.cpp index b7e3fc8ca06b56..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 @@ -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 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..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. - *((TADDR*)pFrame) = ComMethodFrame::GetMethodFrameVPtr(); - *pFrame->GetGSCookiePtr() = GetProcessGSCookie(); + // Initialize the frame's identifier. + *((TADDR*)pFrame) = (TADDR)FrameIdentifier::ComMethodFrame; // 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 55ba8dc4151bdd..24d7461e3d02b9 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()->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame) || pMD->ShouldSuppressGCTransition()); CONSISTENCY_CHECK(pMD->IsNDirect()); @@ -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 d4441504c0811e..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); @@ -11511,7 +11505,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->GetFrameIdentifier() != FrameIdentifier::ComMethodFrame) { pCurFrame = pCurFrame->PtrNextFrame(); } @@ -11519,7 +11513,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->GetFrameIdentifier() == FrameIdentifier::ComMethodFrame, "Expected to find a ComMethodFrame."); ComCallMethodDesc * pCMD = pComFrame->GetComCallMethodDesc(); @@ -11537,7 +11531,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 f57a3ee9918230..54963e0e2995d2 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->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()) + 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->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr() && + if (pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame && !InlinedCallFrame::FrameHasActiveCall(pFrame)) { // Inactive ICFs in IL stubs contain the true interop MethodDesc which must be @@ -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) { @@ -1963,7 +1958,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->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame)) { PTR_InlinedCallFrame pICF = (PTR_InlinedCallFrame)pFrame; // Does it live inside the current managed method? It will iff: @@ -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. @@ -7595,7 +7589,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->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame); InlinedCallFrame* pInlinedCallFrame = (InlinedCallFrame*)pFrame; pInlinedCallFrame->m_Datum = (PTR_NDirectMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper | (TADDR)InlinedCallFrameMarker::SecondPassFuncletCaller); } @@ -7603,7 +7597,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->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame); InlinedCallFrame* pInlinedCallFrame = (InlinedCallFrame*)pFrame; pInlinedCallFrame->m_Datum = (PTR_NDirectMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper); } @@ -8258,7 +8252,7 @@ void FailFastIfCorruptingStateException(ExInfo *pExInfo) static bool IsTopmostDebuggerU2MCatchHandlerFrame(Frame *pFrame) { - return (pFrame->GetVTablePtr() == DebuggerU2MCatchHandlerFrame::GetMethodFrameVPtr()) && (pFrame->PtrNextFrame() == FRAME_TOP); + return (pFrame->GetFrameIdentifier() == FrameIdentifier::DebuggerU2MCatchHandlerFrame) && (pFrame->PtrNextFrame() == FRAME_TOP); } static void NotifyExceptionPassStarted(StackFrameIterator *pThis, Thread *pThread, ExInfo *pExInfo) @@ -8332,12 +8326,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->GetFrameIdentifier() == FrameIdentifier::ProtectValueClassFrame) { pFrame = pFrame->PtrNextFrame(); _ASSERTE(pFrame != FRAME_TOP); } - if ((pFrame->GetVTablePtr() == FuncEvalFrame::GetMethodFrameVPtr()) || IsTopmostDebuggerU2MCatchHandlerFrame(pFrame)) + if ((pFrame->GetFrameIdentifier() == FrameIdentifier::FuncEvalFrame) || IsTopmostDebuggerU2MCatchHandlerFrame(pFrame)) { EEToDebuggerExceptionInterfaceWrapper::NotifyOfCHFFilter((EXCEPTION_POINTERS *)&pExInfo->m_ptrs, pFrame); } @@ -8442,7 +8436,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->GetVTablePtr() != InlinedCallFrame::GetMethodFrameVPtr())) + if (pSkippedFrame->NeedsUpdateRegDisplay() && (pSkippedFrame->GetFrameIdentifier() != FrameIdentifier::InlinedCallFrame)) { pSkippedFrame->UpdateRegDisplay(pThis->m_crawl.GetRegisterSet()); } 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 4479e678241908..f5628896728d2d 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -37,6 +37,259 @@ #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 (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GcScanRoots_Impl(fn, sc); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return; + } +} + +unsigned Frame::GetFrameAttribs() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFrameAttribs_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return 0; + } +} + +#ifndef DACCESS_COMPILE +void Frame::ExceptionUnwind() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->ExceptionUnwind_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return; + } +} +#endif + +BOOL Frame::NeedsUpdateRegDisplay() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->NeedsUpdateRegDisplay_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return FALSE; + } +} + +BOOL Frame::IsTransitionToNativeFrame() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->IsTransitionToNativeFrame_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return FALSE; + } +} + +MethodDesc *Frame::GetFunction() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFunction_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return NULL; + } +} + +Assembly *Frame::GetAssembly() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetAssembly_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return NULL; + } +} + +PTR_BYTE Frame::GetIP() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetIP_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return NULL; + } +} + +TADDR Frame::GetReturnAddressPtr() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetReturnAddressPtr_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return (TADDR)0; + } +} + +PCODE Frame::GetReturnAddress() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetReturnAddress_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return (PCODE)NULL; + } +} + +void Frame::UpdateRegDisplay(const PREGDISPLAY pRegDisplay, bool updateFloats) +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->UpdateRegDisplay_Impl(pRegDisplay, updateFloats); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return; + } +} + +int Frame::GetFrameType() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetFrameType_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return 0; + } +} + +Frame::ETransitionType Frame::GetTransitionType() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetTransitionType_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return (ETransitionType)0; + } +} + +Frame::Interception Frame::GetInterception() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetInterception_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return (Interception)0; + } +} + +void Frame::GetUnmanagedCallSite(TADDR* ip, TADDR* returnIP, TADDR* returnSP) +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetUnmanagedCallSite_Impl(ip, returnIP, returnSP); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return; + } +} + +BOOL Frame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDestination *trace, REGDISPLAY *regs) +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->TraceFrame_Impl(thread, fromPatch, trace, regs); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return FALSE; + } +} + +#ifdef DACCESS_COMPILE +void Frame::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->EnumMemoryRegions_Impl(flags); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return; + } +} +#endif // DACCESS_COMPILE + +#if defined(_DEBUG) && !defined(DACCESS_COMPILE) +BOOL Frame::Protects(OBJECTREF *ppObjectRef) +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->Protects_Impl(ppObjectRef); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return FALSE; + } +} +#endif // defined(_DEBUG) && !defined(DACCESS_COMPILE) + +// TransitionFrame only apis +TADDR TransitionFrame::GetTransitionBlock() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->GetTransitionBlock_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return (TADDR)0; + } +} + +BOOL TransitionFrame::SuppressParamTypeArg() +{ + switch (GetFrameIdentifier()) + { +#define FRAME_TYPE_NAME(frameType) case FrameIdentifier::frameType: { return dac_cast(this)->SuppressParamTypeArg_Impl(); } +#include "FrameTypes.h" + default: + FRAME_POLYMORPHIC_DISPATCH_UNREACHABLE(); + return FALSE; + } +} + //----------------------------------------------------------------------- #if _DEBUG //----------------------------------------------------------------------- @@ -63,17 +316,17 @@ void Frame::Log() { char buff[64]; const char* frameType; - if (GetVTablePtr() == PrestubMethodFrame::GetMethodFrameVPtr()) + if (GetFrameIdentifier() == FrameIdentifier::PrestubMethodFrame) frameType = "PreStub"; - else if (GetVTablePtr() == PInvokeCalliFrame::GetMethodFrameVPtr()) + 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 (GetVTablePtr() == StubDispatchFrame::GetMethodFrameVPtr()) + else if (GetFrameIdentifier() == FrameIdentifier::StubDispatchFrame) frameType = "StubDispatch"; - else if (GetVTablePtr() == ExternalMethodFrame::GetMethodFrameVPtr()) + else if (GetFrameIdentifier() == FrameIdentifier::ExternalMethodFrame) frameType = "ExternalMethod"; else frameType = "Unknown"; @@ -111,14 +364,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() @@ -186,37 +431,26 @@ 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) {x::GetMethodFrameVPtr(), #x} , - static FrameTypeName FrameTypeNameTable[] = { + #define FRAME_TYPE_NAME(x) #x, + static PTR_CSTR 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; i= FrameIdentifier::CountPlusOne) { - if (vtbl == FrameTypeNameTable[(int)i].vtbl) - { - return FrameTypeNameTable[(int)i].name; - } + return NULL; } - - return NULL; + return FrameTypeNameTable[(int)frameIdentifier - 1]; } // char* Frame::FrameTypeName() @@ -229,18 +463,14 @@ void Frame::LogFrame( { char buf[32]; const char *pFrameType; - pFrameType = GetFrameTypeName(); - if (pFrameType == NULL) - { - pFrameType = GetFrameTypeName(GetVTablePtr()); - } + pFrameType = GetFrameTypeName(GetFrameIdentifier()); if (pFrameType == NULL) { _ASSERTE(!"New Frame type needs to be added to FrameTypeName()"); // Pointer is up to 17chars + vtbl@ = 22 chars - sprintf_s(buf, ARRAY_SIZE(buf), "vtbl@%p", (VOID *)GetVTablePtr()); + sprintf_s(buf, ARRAY_SIZE(buf), "frameIdentifier@%p", (VOID *)GetFrameIdentifier()); pFrameType = buf; } @@ -269,77 +499,29 @@ 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() +void Frame::Init(FrameIdentifier frameIdentifier) { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - 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" - + LIMITED_METHOD_CONTRACT; + _frameIdentifier = frameIdentifier; } // void Frame::Init() #endif // DACCESS_COMPILE -// Returns true if the Frame's VTablePtr is valid +// Returns true if the Frame has a valid FrameIdentifier // static -bool Frame::HasValidVTablePtr(Frame * pFrame) +bool Frame::HasValidFrameIdentifier(Frame * pFrame) { WRAPPER_NO_CONTRACT; if (pFrame == NULL || pFrame == FRAME_TOP) return false; -#ifndef DACCESS_COMPILE - TADDR vptr = pFrame->GetVTablePtr(); - // - // Explicitly check for the most common frames. + FrameIdentifier vptr = pFrame->GetFrameIdentifier(); // - if (vptr == HelperMethodFrame::GetMethodFrameVPtr()) - return true; - + // Use a simple compare which is dependent on the tightly packed arrangement of FrameIdentifier // - // otherwise consult the hashtable - // - if (s_pFrameVTables->LookupValue(vptr, (LPVOID) vptr) == (LPVOID) INVALIDENTRY) - return false; -#endif - - return true; -} - -// 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; + return (((TADDR)vptr > (TADDR)FrameIdentifier::None) && ((TADDR)vptr < (TADDR)FrameIdentifier::CountPlusOne)); } //----------------------------------------------------------------------- @@ -371,8 +553,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 @@ -392,7 +572,7 @@ VOID Frame::Push(Thread *pThread) // during stack-walking. !g_pConfig->fAssertOnFailFast() || (m_Next == FRAME_TOP) || - (*m_Next->GetGSCookiePtr() == GetProcessGSCookie())); + (Frame::HasValidFrameIdentifier(m_Next))); pThread->SetFrame(this); } @@ -421,7 +601,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. @@ -429,7 +608,7 @@ VOID Frame::Pop(Thread *pThread) // during stack-walking. !g_pConfig->fAssertOnFailFast() || (m_Next == FRAME_TOP) || - (*m_Next->GetGSCookiePtr() == GetProcessGSCookie())); + (Frame::HasValidFrameIdentifier(m_Next))); pThread->SetFrame(m_Next); m_Next = NULL; @@ -533,13 +712,13 @@ VASigCookie * TransitionFrame::GetVASigCookie() #ifndef DACCESS_COMPILE PrestubMethodFrame::PrestubMethodFrame(TransitionBlock * pTransitionBlock, MethodDesc * pMD) - : FramedMethodFrame(pTransitionBlock, pMD) + : FramedMethodFrame(FrameIdentifier::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; @@ -576,7 +755,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(FrameIdentifier::StubDispatchFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -591,7 +770,7 @@ StubDispatchFrame::StubDispatchFrame(TransitionBlock * pTransitionBlock) #endif // #ifndef DACCESS_COMPILE -MethodDesc* StubDispatchFrame::GetFunction() +MethodDesc* StubDispatchFrame::GetFunction_Impl() { CONTRACTL { NOTHROW; @@ -689,7 +868,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 +877,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 +890,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 +902,7 @@ BOOL StubDispatchFrame::TraceFrame(Thread *thread, BOOL fromPatch, return FALSE; } -Frame::Interception StubDispatchFrame::GetInterception() +Frame::Interception StubDispatchFrame::GetInterception_Impl() { LIMITED_METHOD_CONTRACT; @@ -732,21 +911,21 @@ Frame::Interception StubDispatchFrame::GetInterception() #ifndef DACCESS_COMPILE CallCountingHelperFrame::CallCountingHelperFrame(TransitionBlock *pTransitionBlock, MethodDesc *pMD) - : FramedMethodFrame(pTransitionBlock, pMD) + : FramedMethodFrame(FrameIdentifier::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 +937,7 @@ BOOL CallCountingHelperFrame::TraceFrame(Thread *thread, BOOL fromPatch, TraceDe #ifndef DACCESS_COMPILE ExternalMethodFrame::ExternalMethodFrame(TransitionBlock * pTransitionBlock) - : FramedMethodFrame(pTransitionBlock, NULL) + : FramedMethodFrame(FrameIdentifier::ExternalMethodFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -769,7 +948,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 +957,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 +982,14 @@ PTR_BYTE ExternalMethodFrame::GetGCRefMap() return pGCRefMap; } -Frame::Interception ExternalMethodFrame::GetInterception() +Frame::Interception ExternalMethodFrame::GetInterception_Impl() { LIMITED_METHOD_CONTRACT; return INTERCEPTION_NONE; } -Frame::Interception PrestubMethodFrame::GetInterception() +Frame::Interception PrestubMethodFrame::GetInterception_Impl() { LIMITED_METHOD_DAC_CONTRACT; @@ -826,7 +1005,7 @@ Frame::Interception PrestubMethodFrame::GetInterception() #ifndef DACCESS_COMPILE DynamicHelperFrame::DynamicHelperFrame(TransitionBlock * pTransitionBlock, int dynamicHelperFrameFlags) - : FramedMethodFrame(pTransitionBlock, NULL) + : FramedMethodFrame(FrameIdentifier::DynamicHelperFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -834,7 +1013,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,7 +1022,7 @@ 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()); @@ -884,11 +1063,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) = GetMethodFrameVPtr(); - *GetGSCookiePtr() = GetProcessGSCookie(); + // Initializes the frame's identifier. + Frame::Init(FrameIdentifier::ComPrestubMethodFrame); } #endif // FEATURE_COMINTEROP @@ -1174,7 +1350,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 +1396,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 +1431,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 { @@ -1503,7 +1679,7 @@ void PInvokeCalliFrame::PromoteCallerStack(promote_func* fn, ScanContext* sc) #ifndef DACCESS_COMPILE PInvokeCalliFrame::PInvokeCalliFrame(TransitionBlock * pTransitionBlock, VASigCookie * pVASigCookie, PCODE pUnmanagedTarget) - : FramedMethodFrame(pTransitionBlock, NULL) + : FramedMethodFrame(FrameIdentifier::PInvokeCalliFrame, pTransitionBlock, NULL) { LIMITED_METHOD_CONTRACT; @@ -1516,21 +1692,21 @@ PInvokeCalliFrame::PInvokeCalliFrame(TransitionBlock * pTransitionBlock, VASigCo #ifndef DACCESS_COMPILE CLRToCOMMethodFrame::CLRToCOMMethodFrame(TransitionBlock * pTransitionBlock, MethodDesc * pMD) - : FramedMethodFrame(pTransitionBlock, pMD) + : FramedMethodFrame(FrameIdentifier::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); @@ -1580,7 +1756,7 @@ 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); @@ -1626,7 +1802,7 @@ void ComMethodFrame::DoSecondPassHandlerCleanup(Frame * pCurFrame) // Find ComMethodFrame while ((pCurFrame != FRAME_TOP) && - (pCurFrame->GetVTablePtr() != ComMethodFrame::GetMethodFrameVPtr())) + (pCurFrame->GetFrameIdentifier() != FrameIdentifier::ComMethodFrame)) { pCurFrame = pCurFrame->PtrNextFrame(); } @@ -1675,11 +1851,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(); @@ -1751,7 +1922,7 @@ NOINLINE void HelperMethodFrame::PopSlowHelper() #endif // #ifndef DACCESS_COMPILE -MethodDesc* HelperMethodFrame::GetFunction() +MethodDesc* HelperMethodFrame::GetFunction_Impl() { WRAPPER_NO_CONTRACT; @@ -1876,13 +2047,7 @@ VOID InlinedCallFrame::Init() { WRAPPER_NO_CONTRACT; - *((TADDR *)this) = GetMethodFrameVPtr(); - - // 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(); + Frame::Init(FrameIdentifier::InlinedCallFrame); m_Datum = NULL; m_pCallSiteSP = NULL; @@ -1891,7 +2056,7 @@ VOID InlinedCallFrame::Init() #ifdef FEATURE_COMINTEROP -void UnmanagedToManagedFrame::ExceptionUnwind() +void UnmanagedToManagedFrame::ExceptionUnwind_Impl() { WRAPPER_NO_CONTRACT; @@ -1902,11 +2067,11 @@ 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()) diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 8ca02f5061d528..faf0e660e03541 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,111 +221,100 @@ 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 +enum class FrameIdentifier : TADDR { -public: - TADDR vtbl; - PTR_CSTR name; + None = 0, +#define FRAME_TYPE_NAME(frameType) frameType, +#include "FrameTypes.h" + CountPlusOne }; -typedef DPTR(FrameTypeName) PTR_FrameTypeName; -//----------------------------------------------------------------------------- -// 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 -{ - VPTR_BASE_VTABLE_CLASS(FrameBase) - -public: - FrameBase() {LIMITED_METHOD_CONTRACT; } - - virtual void GcScanRoots(promote_func *fn, ScanContext* sc) { - LIMITED_METHOD_CONTRACT; - // Nothing to protect - } - -#ifdef DACCESS_COMPILE - virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) = 0; -#endif -}; +// TransitionFrame only apis +class TransitionFrame; +TADDR Frame_GetTransitionBlock(TransitionFrame* frame); +BOOL Frame_SuppressParamTypeArg(TransitionFrame* frame); //------------------------------------------------------------------------ // 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 friend void Thread::EnumMemoryRegions(CLRDataEnumMemoryFlags flags); #endif - VPTR_ABSTRACT_VTABLE_CLASS(Frame, FrameBase) - public: + FrameIdentifier GetFrameIdentifier() { LIMITED_METHOD_DAC_CONTRACT; return _frameIdentifier; } + + 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) + + 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() + { + _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 +328,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 +338,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 +347,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,19 +355,19 @@ 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(); @@ -449,7 +379,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,14 +387,14 @@ 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(); @@ -472,12 +402,6 @@ class Frame : public FrameBase } #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) { @@ -488,27 +412,14 @@ 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(); + static bool HasValidFrameIdentifier(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 // 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,18 +431,9 @@ 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; @@ -555,7 +457,7 @@ class Frame : public FrameBase TYPE_COUNT }; - virtual int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_INTERNAL; @@ -566,20 +468,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 +482,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 +500,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,10 +510,9 @@ 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. @@ -633,12 +521,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 @@ -653,15 +535,8 @@ class Frame : public FrameBase 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) - virtual BOOL Protects(OBJECTREF *ppObjectRef) + BOOL Protects_Impl(OBJECTREF *ppObjectRef) { LIMITED_METHOD_CONTRACT; return FALSE; @@ -682,24 +557,14 @@ 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); + static PTR_CSTR GetFrameTypeName(FrameIdentifier frameIdentifier); #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. + FrameIdentifier _frameIdentifier; protected: + // Pointer to the next frame up the stack. PTR_Frame m_Next; // offset +4 public: @@ -740,14 +605,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(FrameIdentifier frameIdentifier) + : _frameIdentifier(frameIdentifier), 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); @@ -755,7 +623,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 @@ -777,28 +645,33 @@ class Frame : public FrameBase #ifdef FEATURE_HIJACK //----------------------------------------------------------------------------- +typedef DPTR(class ResumableFrame) PTR_ResumableFrame; + class ResumableFrame : public Frame { - VPTR_VTABLE_CLASS(ResumableFrame, Frame) - public: #ifndef DACCESS_COMPILE - ResumableFrame(T_CONTEXT* regs) { + ResumableFrame(T_CONTEXT* regs) : Frame(FrameIdentifier::ResumableFrame) { + LIMITED_METHOD_CONTRACT; + m_Regs = regs; + } + + ResumableFrame(FrameIdentifier frameIdentifier, T_CONTEXT* regs) : Frame(frameIdentifier) { 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. } @@ -809,15 +682,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; @@ -861,9 +734,6 @@ class ResumableFrame : public Frame protected: PTR_CONTEXT m_Regs; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(ResumableFrame) }; @@ -873,20 +743,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(FrameIdentifier::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; @@ -895,8 +759,8 @@ inline BOOL ISREDIRECTEDTHREAD(Thread * thread) { WRAPPER_NO_CONTRACT; return (thread->GetFrame() != FRAME_TOP && - thread->GetFrame()->GetVTablePtr() == - RedirectedThreadFrame::GetMethodFrameVPtr()); + thread->GetFrame()->GetFrameIdentifier() == + FrameIdentifier::RedirectedThreadFrame); } inline T_CONTEXT * GETREDIRECTEDCONTEXT(Thread * thread) @@ -924,16 +788,25 @@ inline CONTEXT * GETREDIRECTEDCONTEXT(Thread * thread) { LIMITED_METHOD_CONTRACT // getting lost. //------------------------------------------------------------------------ +typedef DPTR(class TransitionFrame) PTR_TransitionFrame; + class TransitionFrame : public Frame { - VPTR_ABSTRACT_VTABLE_CLASS(TransitionFrame, Frame) +#ifndef DACCESS_COMPILE +protected: + TransitionFrame(FrameIdentifier frameIdentifier) : Frame(frameIdentifier) { + LIMITED_METHOD_CONTRACT; + } +#endif public: - virtual TADDR GetTransitionBlock() = 0; + + TADDR GetTransitionBlock(); + BOOL SuppressParamTypeArg(); // 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(); @@ -964,7 +837,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; } @@ -1002,18 +875,18 @@ class TransitionFrame : public Frame return GetTransitionBlock() + 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. @@ -1027,12 +900,6 @@ class TransitionFrame : public Frame #ifdef TARGET_X86 UINT CbStackPopUsingGCRefMap(PTR_BYTE pGCRefMap); #endif - -protected: - TransitionFrame() - { - LIMITED_METHOD_CONTRACT; - } }; //----------------------------------------------------------------------- @@ -1041,6 +908,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 { @@ -1064,16 +932,14 @@ class FaultingExceptionFrame : public Frame TADDR m_SSP; #endif - VPTR_VTABLE_CLASS(FaultingExceptionFrame, Frame) - public: #ifndef DACCESS_COMPILE - FaultingExceptionFrame() { + FaultingExceptionFrame() : Frame(FrameIdentifier::FaultingExceptionFrame) { LIMITED_METHOD_CONTRACT; } #endif - virtual TADDR GetReturnAddressPtr() + TADDR GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; return PTR_HOST_MEMBER_TADDR(FaultingExceptionFrame, this, m_ReturnAddress); @@ -1082,13 +948,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 @@ -1131,35 +997,32 @@ 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 +typedef DPTR(class SoftwareExceptionFrame) PTR_SoftwareExceptionFrame; + class SoftwareExceptionFrame : public Frame { TADDR m_ReturnAddress; T_CONTEXT m_Context; T_KNONVOLATILE_CONTEXT_POINTERS m_ContextPointers; - VPTR_VTABLE_CLASS(SoftwareExceptionFrame, Frame) - public: #ifndef DACCESS_COMPILE - SoftwareExceptionFrame() { + SoftwareExceptionFrame() : Frame(FrameIdentifier::SoftwareExceptionFrame) { LIMITED_METHOD_CONTRACT; } #endif - virtual TADDR GetReturnAddressPtr() + TADDR GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; return PTR_HOST_MEMBER_TADDR(SoftwareExceptionFrame, this, m_ReturnAddress); @@ -1168,19 +1031,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; @@ -1192,15 +1055,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 @@ -1224,8 +1084,6 @@ typedef DPTR(class DebuggerEval) PTR_DebuggerEval; class FuncEvalFrame : public Frame { - VPTR_VTABLE_CLASS(FuncEvalFrame, Frame) - TADDR m_ReturnAddress; PTR_DebuggerEval m_pDebuggerEval; @@ -1233,7 +1091,7 @@ class FuncEvalFrame : public Frame public: #ifndef DACCESS_COMPILE - FuncEvalFrame(DebuggerEval *pDebuggerEval, TADDR returnAddress, BOOL showFrame) + FuncEvalFrame(DebuggerEval *pDebuggerEval, TADDR returnAddress, BOOL showFrame) : Frame(FrameIdentifier::FuncEvalFrame) { LIMITED_METHOD_CONTRACT; m_pDebuggerEval = pDebuggerEval; @@ -1242,30 +1100,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 @@ -1279,12 +1137,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 //---------------------------------------------------------------------------------------------- @@ -1294,10 +1149,10 @@ typedef VPTR(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 { - VPTR_VTABLE_CLASS(HelperMethodFrame, Frame); - public: #ifndef DACCESS_COMPILE // Lazy initialization of HelperMethodFrame. Need to @@ -1305,7 +1160,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, FrameIdentifier frameIdentifier = FrameIdentifier::HelperMethodFrame) : Frame(frameIdentifier) { WRAPPER_NO_CONTRACT; // Most of the initialization is actually done in HelperMethodFrame::Push() @@ -1315,13 +1170,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; @@ -1341,16 +1196,16 @@ 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; @@ -1359,7 +1214,7 @@ class HelperMethodFrame : public Frame return(INTERCEPTION_NONE); } - virtual ETransitionType GetTransitionType() + ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TT_InternalCall; @@ -1386,17 +1241,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 @@ -1437,9 +1292,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 @@ -1472,14 +1324,14 @@ 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 { - 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, FrameIdentifier::HelperMethodFrame_1OBJ) { LIMITED_METHOD_CONTRACT; gcPtrs[0] = aGCPtr1; @@ -1495,11 +1347,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 @@ -1512,7 +1364,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; @@ -1522,9 +1374,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) }; @@ -1532,10 +1381,10 @@ class HelperMethodFrame_1OBJ : public HelperMethodFrame // HelperMethodFrame_2OBJ //----------------------------------------------------------------------------- +typedef DPTR(class HelperMethodFrame_2OBJ) PTR_HelperMethodFrame_2OBJ; + class HelperMethodFrame_2OBJ : public HelperMethodFrame { - VPTR_VTABLE_CLASS(HelperMethodFrame_2OBJ, HelperMethodFrame) - public: #if !defined(DACCESS_COMPILE) HelperMethodFrame_2OBJ( @@ -1543,7 +1392,7 @@ class HelperMethodFrame_2OBJ : public HelperMethodFrame unsigned attribs, OBJECTREF* aGCPtr1, OBJECTREF* aGCPtr2) - : HelperMethodFrame(fCallFtnEntry, attribs) + : HelperMethodFrame(fCallFtnEntry, attribs, FrameIdentifier::HelperMethodFrame_2OBJ) { LIMITED_METHOD_CONTRACT; gcPtrs[0] = aGCPtr1; @@ -1555,12 +1404,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 @@ -1574,7 +1423,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; @@ -1583,19 +1432,16 @@ 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) }; //----------------------------------------------------------------------------- // HelperMethodFrame_3OBJ //----------------------------------------------------------------------------- +typedef DPTR(class HelperMethodFrame_3OBJ) PTR_HelperMethodFrame_3OBJ; + class HelperMethodFrame_3OBJ : public HelperMethodFrame { - VPTR_VTABLE_CLASS(HelperMethodFrame_3OBJ, HelperMethodFrame) - public: #if !defined(DACCESS_COMPILE) HelperMethodFrame_3OBJ( @@ -1604,7 +1450,7 @@ class HelperMethodFrame_3OBJ : public HelperMethodFrame OBJECTREF* aGCPtr1, OBJECTREF* aGCPtr2, OBJECTREF* aGCPtr3) - : HelperMethodFrame(fCallFtnEntry, attribs) + : HelperMethodFrame(fCallFtnEntry, attribs, FrameIdentifier::HelperMethodFrame_3OBJ) { LIMITED_METHOD_CONTRACT; gcPtrs[0] = aGCPtr1; @@ -1619,13 +1465,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 @@ -1640,7 +1486,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; @@ -1649,9 +1495,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) }; @@ -1659,14 +1502,14 @@ class HelperMethodFrame_3OBJ : public HelperMethodFrame // HelperMethodFrame_PROTECTOBJ //----------------------------------------------------------------------------- +typedef DPTR(class HelperMethodFrame_PROTECTOBJ) PTR_HelperMethodFrame_PROTECTOBJ; + 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, FrameIdentifier::HelperMethodFrame_PROTECTOBJ) { LIMITED_METHOD_CONTRACT; m_pObjRefs = pObjRefs; @@ -1680,13 +1523,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 @@ -1701,7 +1544,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++) { @@ -1715,15 +1558,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: @@ -1731,20 +1569,20 @@ class FramedMethodFrame : public TransitionFrame public: #ifndef DACCESS_COMPILE - FramedMethodFrame(TransitionBlock * pTransitionBlock, MethodDesc * pMD) - : 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; } #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; @@ -1765,13 +1603,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; @@ -1816,12 +1654,6 @@ class FramedMethodFrame : public TransitionFrame #endif return dac_cast(p); } - -protected: - FramedMethodFrame() - { - LIMITED_METHOD_CONTRACT; - } }; @@ -1835,20 +1667,26 @@ class UnmanagedToManagedFrame : public Frame { friend class CheckAsmOffsets; - VPTR_ABSTRACT_VTABLE_CLASS_AND_CTOR(UnmanagedToManagedFrame, Frame) +protected: +#ifndef DACCESS_COMPILE + UnmanagedToManagedFrame(FrameIdentifier frameIdentifier) : Frame(frameIdentifier) + { + 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 @@ -1879,7 +1717,7 @@ class UnmanagedToManagedFrame : public Frame return m_pvDatum; } - int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_ENTRY; @@ -1888,7 +1726,7 @@ class UnmanagedToManagedFrame : public Frame //------------------------------------------------------------------------ // For the debugger. //------------------------------------------------------------------------ - virtual ETransitionType GetTransitionType() + ETransitionType GetTransitionType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TT_U2M; @@ -1898,7 +1736,7 @@ class UnmanagedToManagedFrame : public Frame // Performs cleanup on an exception unwind //------------------------------------------------------------------------ #ifndef DACCESS_COMPILE - virtual void ExceptionUnwind(); + void ExceptionUnwind_Impl(); #endif protected: @@ -1931,10 +1769,13 @@ class UnmanagedToManagedFrame : public Frame class ComMethodFrame : public UnmanagedToManagedFrame { - VPTR_VTABLE_CLASS(ComMethodFrame, UnmanagedToManagedFrame) - VPTR_UNIQUE(VPTR_UNIQUE_ComMethodFrame) - public: +#ifndef DACCESS_COMPILE + ComMethodFrame(FrameIdentifier frameIdentifier = FrameIdentifier::ComMethodFrame) : UnmanagedToManagedFrame(FrameIdentifier::ComMethodFrame) + { + LIMITED_METHOD_CONTRACT; + } +#endif // DACCESS_COMPILE #ifdef TARGET_X86 // Return the # of stack bytes pushed by the unmanaged caller. @@ -1950,10 +1791,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; @@ -1962,36 +1799,33 @@ 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 { - 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 @@ -2000,33 +1834,33 @@ class CLRToCOMMethodFrame : public FramedMethodFrame // This represents a call from a helper to GetILStubForCalli //------------------------------------------------------------------------ +typedef DPTR(class PInvokeCalliFrame) PTR_PInvokeCalliFrame; + 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; @@ -2045,10 +1879,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; @@ -2056,9 +1890,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. @@ -2068,32 +1899,32 @@ 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 { - 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 @@ -2101,7 +1932,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. } @@ -2117,9 +1948,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 @@ -2130,40 +1958,37 @@ class HijackFrame : public Frame // stub, we need this frame to keep things straight. //------------------------------------------------------------------------ +typedef DPTR(class PrestubMethodFrame) PTR_PrestubMethodFrame; + 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(); }; //------------------------------------------------------------------------ @@ -2176,8 +2001,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; @@ -2193,23 +2016,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) @@ -2236,18 +2059,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 @@ -2265,37 +2088,31 @@ class StubDispatchFrame : public FramedMethodFrame 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; + +typedef DPTR(class CallCountingHelperFrame) PTR_CallCountingHelperFrame; 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) }; //------------------------------------------------------------------------ @@ -2306,8 +2123,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; @@ -2318,7 +2133,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(); @@ -2333,51 +2148,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 @@ -2390,17 +2197,18 @@ typedef VPTR(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; - 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; @@ -2408,26 +2216,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 @@ -2510,27 +2314,24 @@ struct ByRefInfo // ProtectByRefsFrame //----------------------------------------------------------------------------- +typedef DPTR(class ProtectByRefsFrame) PTR_ProtectByRefsFrame; + class ProtectByRefsFrame : public Frame { - VPTR_VTABLE_CLASS(ProtectByRefsFrame, Frame) - public: #ifndef DACCESS_COMPILE ProtectByRefsFrame(Thread *pThread, ByRefInfo *brInfo) - : m_brInfo(brInfo) + : Frame(FrameIdentifier::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) }; @@ -2555,29 +2356,28 @@ struct ValueClassInfo // ProtectValueClassFrame //----------------------------------------------------------------------------- +typedef DPTR(class ProtectValueClassFrame) PTR_ProtectValueClassFrame; class ProtectValueClassFrame : public Frame { - VPTR_VTABLE_CLASS(ProtectValueClassFrame, Frame) - public: #ifndef DACCESS_COMPILE ProtectValueClassFrame() - : m_pVCInfo(NULL) + : Frame(FrameIdentifier::ProtectValueClassFrame), m_pVCInfo(NULL) { WRAPPER_NO_CONTRACT; Frame::Push(); } ProtectValueClassFrame(Thread *pThread, ValueClassInfo *vcInfo) - : m_pVCInfo(vcInfo) + : Frame(FrameIdentifier::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() { @@ -2588,9 +2388,6 @@ class ProtectValueClassFrame : public Frame private: ValueClassInfo *m_pVCInfo; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_DTOR(ProtectValueClassFrame) }; @@ -2606,34 +2403,31 @@ BOOL IsProtectedByGCFrame(OBJECTREF *ppObjectRef); // GetFrameType and GetInterception. //------------------------------------------------------------------------ +typedef DPTR(class DebuggerClassInitMarkFrame) PTR_DebuggerClassInitMarkFrame; + class DebuggerClassInitMarkFrame : public Frame { - VPTR_VTABLE_CLASS(DebuggerClassInitMarkFrame, Frame) - public: #ifndef DACCESS_COMPILE - DebuggerClassInitMarkFrame() + DebuggerClassInitMarkFrame() : Frame(FrameIdentifier::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) }; //------------------------------------------------------------------------ @@ -2642,20 +2436,20 @@ class DebuggerClassInitMarkFrame : public Frame // the stack. //------------------------------------------------------------------------ +typedef DPTR(class DebuggerExitFrame) PTR_DebuggerExitFrame; + class DebuggerExitFrame : public Frame { - VPTR_VTABLE_CLASS(DebuggerExitFrame, Frame) - public: #ifndef DACCESS_COMPILE - DebuggerExitFrame() + DebuggerExitFrame() : Frame(FrameIdentifier::DebuggerExitFrame) { WRAPPER_NO_CONTRACT; Push(); } #endif - virtual int GetFrameType() + int GetFrameType_Impl() { LIMITED_METHOD_DAC_CONTRACT; return TYPE_EXIT; @@ -2669,7 +2463,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) { @@ -2683,9 +2477,6 @@ class DebuggerExitFrame : public Frame if (returnSP) *returnSP = 0; } - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_DTOR(DebuggerExitFrame) }; //--------------------------------------------------------------------------------------- @@ -2699,33 +2490,30 @@ 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 { - VPTR_VTABLE_CLASS(DebuggerU2MCatchHandlerFrame, Frame) - public: #ifndef DACCESS_COMPILE - DebuggerU2MCatchHandlerFrame() + DebuggerU2MCatchHandlerFrame() : Frame(FrameIdentifier::DebuggerU2MCatchHandlerFrame) { WRAPPER_NO_CONTRACT; Frame::Push(); } - DebuggerU2MCatchHandlerFrame(Thread * pThread) + DebuggerU2MCatchHandlerFrame(Thread * pThread) : Frame(FrameIdentifier::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). @@ -2748,10 +2536,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()) @@ -2775,7 +2561,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; @@ -2786,7 +2572,7 @@ class InlinedCallFrame : public Frame return 0; } - virtual BOOL NeedsUpdateRegDisplay() + BOOL NeedsUpdateRegDisplay_Impl() { WRAPPER_NO_CONTRACT; return FrameHasActiveCall(this); @@ -2803,7 +2589,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) @@ -2859,7 +2645,7 @@ class InlinedCallFrame : public Frame SUPPORTS_DAC; return pFrame && pFrame != FRAME_TOP && - InlinedCallFrame::GetMethodFrameVPtr() == pFrame->GetVTablePtr() && + FrameIdentifier::InlinedCallFrame == pFrame->GetFrameIdentifier() && dac_cast(dac_cast(pFrame)->m_pCallerReturnAddress) != 0; } @@ -2869,13 +2655,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; @@ -2895,9 +2681,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 @@ -2926,10 +2709,10 @@ bool isRetAddr(TADDR retAddr, TADDR* whereCalled); // as tail calls on interface calls are uncommon. //------------------------------------------------------------------------ +typedef DPTR(class TailCallFrame) PTR_TailCallFrame; + 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 @@ -2939,9 +2722,9 @@ class TailCallFrame : public Frame { LIMITED_METHOD_CONTRACT; // loop through the frame chain - while (pFrame->GetVTablePtr() != TailCallFrame::GetMethodFrameVPtr()) + while (pFrame->GetFrameIdentifier() != FrameIdentifier::TailCallFrame) pFrame = pFrame->m_Next; - return (TailCallFrame*)pFrame; + return dac_cast(pFrame); } TADDR GetCallerAddress() @@ -2950,23 +2733,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 @@ -2975,14 +2754,15 @@ 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 { - VPTR_VTABLE_CLASS(ExceptionFilterFrame, Frame) size_t* m_pShadowSP; public: #ifndef DACCESS_COMPILE - ExceptionFilterFrame(size_t* pShadowSP) + ExceptionFilterFrame(size_t* pShadowSP) : Frame(FrameIdentifier::ExceptionFilterFrame) { WRAPPER_NO_CONTRACT; m_pShadowSP = pShadowSP; @@ -3010,29 +2790,27 @@ class ExceptionFilterFrame : public Frame } } #endif - -private: - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_CTOR_AND_DTOR(ExceptionFilterFrame) }; #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 { - VPTR_VTABLE_CLASS(AssumeByrefFromJITStack, Frame) public: #ifndef DACCESS_COMPILE - AssumeByrefFromJITStack(OBJECTREF *pObjRef) + AssumeByrefFromJITStackFrame(OBJECTREF *pObjRef) : Frame(FrameIdentifier::AssumeByrefFromJITStackFrame) { m_pObjRef = pObjRef; } #endif - BOOL Protects(OBJECTREF *ppORef) + BOOL Protects_Impl(OBJECTREF *ppORef) { LIMITED_METHOD_CONTRACT; return ppORef == m_pObjRef; @@ -3040,176 +2818,10 @@ class AssumeByrefFromJITStack : public Frame private: OBJECTREF *m_pObjRef; - - // Keep as last entry in class - DEFINE_VTABLE_GETTER_AND_DTOR(AssumeByrefFromJITStack) -}; //AssumeByrefFromJITStack - -#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); - } +}; //AssumeByrefFromJITStackFrame #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 @@ -3346,14 +2958,14 @@ class FrameWithCookie /*pointer points to GC heap, the FCall still needs to protect it explicitly */ \ ASSERT_ADDRESS_IN_STACK (__objRef); \ do { \ - FrameWithCookie __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() 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/gcenv.ee.common.cpp b/src/coreclr/vm/gcenv.ee.common.cpp index 43373bc591c5c6..34d40e85a2e5dd 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()->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/PInvokeStubs.asm b/src/coreclr/vm/i386/PInvokeStubs.asm index a0bc18d616bce1..67262c8b093b9a 100644 --- a/src/coreclr/vm/i386/PInvokeStubs.asm +++ b/src/coreclr/vm/i386/PInvokeStubs.asm @@ -20,8 +20,6 @@ option casemap:none .code -extern _s_gsCookie:DWORD -extern ??_7InlinedCallFrame@@6B@:DWORD extern _g_TrapReturningThreads:DWORD extern _JIT_PInvokeEndRarePath@0:proc @@ -37,13 +35,8 @@ 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::`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 @@ -81,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/asmconstants.h b/src/coreclr/vm/i386/asmconstants.h index 396381f6c1f539..280f4f6c51904e 100644 --- a/src/coreclr/vm/i386/asmconstants.h +++ b/src/coreclr/vm/i386/asmconstants.h @@ -32,6 +32,14 @@ #define DBG_FRE(dbg,fre) fre #endif +#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 @@ -147,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/asmhelpers.asm b/src/coreclr/vm/i386/asmhelpers.asm index 2f1d12c6d9a71e..6bbd62a31624dc 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,10 +1270,10 @@ _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] + 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 @@ -1285,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 @@ -1308,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/cgenx86.cpp b/src/coreclr/vm/i386/cgenx86.cpp index c4fe9b265ed62e..86325672575d64 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 { @@ -399,13 +399,13 @@ void ExternalMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFlo 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; } -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,12 +438,12 @@ 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; } -PCODE StubDispatchFrame::GetReturnAddress() +PCODE StubDispatchFrame::GetReturnAddress_Impl() { CONTRACTL { @@ -452,7 +452,7 @@ PCODE StubDispatchFrame::GetReturnAddress() } CONTRACTL_END; - PCODE retAddress = FramedMethodFrame::GetReturnAddress(); + PCODE retAddress = FramedMethodFrame::GetReturnAddress_Impl(); if (GetFunction() == NULL && GetGCRefMap() == NULL) { // See comment in code:StubDispatchFrame::UpdateRegDisplay @@ -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; } @@ -604,13 +604,13 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats //========================== // Resumable Exception Frame // -TADDR ResumableFrame::GetReturnAddressPtr() +TADDR ResumableFrame::GetReturnAddressPtr_Impl() { LIMITED_METHOD_DAC_CONTRACT; 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); @@ -877,30 +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.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(InlinedCallFrame::GetMethodFrameVPtr()); + // 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/excepx86.cpp b/src/coreclr/vm/i386/excepx86.cpp index 2fbae9d9e724d2..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); @@ -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->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->GetVTablePtr() == HelperMethodFrame::GetMethodFrameVPtr()); + 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->GetVTablePtr() == ExceptionFilterFrame::GetMethodFrameVPtr()); + _ASSERTE(pFilterFrame->GetFrameIdentifier() == FrameIdentifier::ExceptionFilterFrame); ((ExceptionFilterFrame*)pFilterFrame)->SetFilterDone(); // Inform the profiler that we're leaving, and what pass we're on @@ -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..58b4200a871b62 100644 --- a/src/coreclr/vm/i386/jithelp.asm +++ b/src/coreclr/vm/i386/jithelp.asm @@ -58,9 +58,7 @@ endif ; _DEBUG ifdef FEATURE_HIJACK 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 @@ -723,26 +721,18 @@ VSDHelperLabel: ; m_regs ; m_CallerAddress ; m_pThread -; vtbl -; GSCookie +; frame identifier ; &VSDHelperLabel -OffsetOfTailCallFrame = 8 +OffsetOfTailCallFrame = 4 ; Offset to start of TailCallFrame, includes only the &VSDHelperLabel ; 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 +904,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 +944,25 @@ 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], FRAMETYPE_TailCallFrame ; FrameIdentifier::TailCallFrame + 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 +973,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 +984,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/i386/jitinterfacex86.cpp b/src/coreclr/vm/i386/jitinterfacex86.cpp index d8fcd90ba63bb7..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*)TailCallFrame::GetMethodFrameVPtr(); -#endif // !UNIX_X86_ABI } #pragma warning (default : 4731) diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 81d3481124ef1a..fe5564e299060d 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); @@ -2470,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); @@ -2556,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/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 35e06c4041e482..b27c0f10ead130 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -10132,19 +10132,17 @@ 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->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/asmconstants.h b/src/coreclr/vm/loongarch64/asmconstants.h index bc78b33707f9f2..cd786de16827a6 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)FrameIdentifier::InlinedCallFrame) + #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 #define DynamicHelperFrameFlags_ObjectArg2 2 @@ -98,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/loongarch64/asmhelpers.S b/src/coreclr/vm/loongarch64/asmhelpers.S index 951807d9305f20..b2abecbafb5f31 100644 --- a/src/coreclr/vm/loongarch64/asmhelpers.S +++ b/src/coreclr/vm/loongarch64/asmhelpers.S @@ -597,8 +597,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 15d4398785b614..e902c74d8278f3 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,15 +86,11 @@ 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 + move $s0, $a0 // 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.d $t0, FRAMETYPE_InlinedCallFrame st.d $t4, $s0, 0 st.d $zero, $s0, InlinedCallFrame__m_Datum @@ -136,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/loongarch64/stubs.cpp b/src/coreclr/vm/loongarch64/stubs.cpp index d636410940a704..aaeea378333349 100644 --- a/src/coreclr/vm/loongarch64/stubs.cpp +++ b/src/coreclr/vm/loongarch64/stubs.cpp @@ -431,7 +431,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 { @@ -602,7 +602,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) @@ -630,10 +630,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; @@ -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 { @@ -721,19 +721,19 @@ 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; } #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); } -void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD, bool updateFloats) +void ResumableFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { CONTRACT_VOID { @@ -784,12 +784,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; @@ -834,7 +834,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 ce0e1049654fe9..07b03c2d2040cc 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) @@ -4045,7 +4045,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/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/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/asmconstants.h b/src/coreclr/vm/riscv64/asmconstants.h index a79476b33eda27..47f02c8a75cdfc 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)FrameIdentifier::InlinedCallFrame) + #define DynamicHelperFrameFlags_Default 0 #define DynamicHelperFrameFlags_ObjectArg 1 #define DynamicHelperFrameFlags_ObjectArg2 2 @@ -93,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/riscv64/asmhelpers.S b/src/coreclr/vm/riscv64/asmhelpers.S index 75c5f7609c93bf..d28639f6ff862f 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 d96a581b8d8570..9f065a37e474d1 100644 --- a/src/coreclr/vm/riscv64/pinvokestubs.S +++ b/src/coreclr/vm/riscv64/pinvokestubs.S @@ -74,23 +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::`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) + li t4, FRAMETYPE_InlinedCallFrame sd t4, 0(s1) sd zero, (InlinedCallFrame__m_Datum)(s1) @@ -125,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/riscv64/stubs.cpp b/src/coreclr/vm/riscv64/stubs.cpp index 0d3d0e2f80d7cd..1f98212b231771 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,19 +655,19 @@ 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; } #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); } -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/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 ef81c5bd0e93af..c84c6105fcff30 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)); - } } //****************************************************************************** @@ -701,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 @@ -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) @@ -1414,11 +1399,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->GetFrameIdentifier() == FrameIdentifier::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()->GetFrameIdentifier() == FrameIdentifier::ResumableFrame) + || (m_pThread->GetFrame()->GetFrameIdentifier() == FrameIdentifier::RedirectedThreadFrame); } #endif // FEATURE_HIJACK @@ -2365,7 +2350,7 @@ StackWalkAction StackFrameIterator::NextRaw(void) // make sure we're not skipping a different transition if (m_crawl.pFrame->NeedsUpdateRegDisplay()) { - if (m_crawl.pFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()) + 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 +2487,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->GetFrameIdentifier() == FrameIdentifier::FaultingExceptionFrame)); #endif // !defined(ELIMINATE_FEF) // Get rid of the frame (actually, it isn't really popped) @@ -2847,7 +2832,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()->GetFrameIdentifier() != FrameIdentifier::FaultingExceptionFrame ) ) ) { // // If the REGDISPLAY represents an unmanaged stack frame above (closer to the leaf than) an @@ -3006,7 +2991,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->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 8951a68905a237..51462ddd278a02 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->GetVTablePtr() == HelperMethodFrame::GetMethodFrameVPtr()) + if (pFrame->GetFrameIdentifier() == FrameIdentifier::HelperMethodFrame) { break; } @@ -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 2da1584cdb5da7..42ce5cbb355863 100644 --- a/src/coreclr/vm/threadsuspend.cpp +++ b/src/coreclr/vm/threadsuspend.cpp @@ -2512,7 +2512,7 @@ bool ThreadStore::IsTrappingThreadsForSuspension() #ifdef FEATURE_HIJACK -void RedirectedThreadFrame::ExceptionUnwind() +void RedirectedThreadFrame::ExceptionUnwind_Impl() { CONTRACTL { @@ -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"); @@ -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)); @@ -3766,10 +3766,9 @@ ThrowControlForThread( } #if defined(FEATURE_EH_FUNCLETS) - *(TADDR*)pfef = FaultingExceptionFrame::GetMethodFrameVPtr(); - *pfef->GetGSCookiePtr() = GetProcessGSCookie(); + ((Frame*)pfef)->Init(FrameIdentifier::FaultingExceptionFrame); #else // FEATURE_EH_FUNCLETS - FrameWithCookie fef; + FaultingExceptionFrame fef; FaultingExceptionFrame *pfef = &fef; #endif // FEATURE_EH_FUNCLETS pfef->InitAndLink(pThread->m_OSContext); @@ -4843,7 +4842,8 @@ StackWalkAction SWCB_GetExecutionState(CrawlFrame *pCF, VOID *pData) } HijackFrame::HijackFrame(LPVOID returnAddress, Thread *thread, HijackArgs *args) - : m_ReturnAddress((TADDR)returnAddress), + : Frame(FrameIdentifier::HijackFrame), + m_ReturnAddress((TADDR)returnAddress), m_Thread(thread), m_Args(args) { @@ -4879,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; @@ -5805,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();