From c56cc86d6ed1533e4b95e25449037782f7c498dd Mon Sep 17 00:00:00 2001 From: Jonghyun Park Date: Tue, 31 Jan 2017 11:08:12 +0900 Subject: [PATCH] Unify ReadXXX/LocateXXX into GetXXXLocation, and RestoreXXX/TrashXXX into SetXXXLocation --- src/debug/daccess/dacdbiimplstackwalk.cpp | 14 ++--- src/debug/ee/debugger.inl | 14 ++--- src/debug/ee/i386/x86walker.cpp | 14 ++--- src/debug/shared/i386/primitives.cpp | 12 ++-- src/inc/regdisp.h | 36 +++++------ src/vm/eetwain.cpp | 76 +++++++++++------------ src/vm/frames.cpp | 4 +- src/vm/gccover.cpp | 8 +-- src/vm/i386/cgenx86.cpp | 74 +++++++++++----------- src/vm/proftoeeinterfaceimpl.cpp | 4 +- 10 files changed, 127 insertions(+), 129 deletions(-) diff --git a/src/debug/daccess/dacdbiimplstackwalk.cpp b/src/debug/daccess/dacdbiimplstackwalk.cpp index cf91faf51776..29c9626db840 100644 --- a/src/debug/daccess/dacdbiimplstackwalk.cpp +++ b/src/debug/daccess/dacdbiimplstackwalk.cpp @@ -1156,13 +1156,13 @@ void DacDbiInterfaceImpl::UpdateContextFromRegDisp(REGDISPLAY * pRegDisp, // Do a partial copy first. pContext->ContextFlags = (CONTEXT_INTEGER | CONTEXT_CONTROL); - pContext->Edi = pRegDisp->ReadEdi(); - pContext->Esi = pRegDisp->ReadEsi(); - pContext->Ebx = pRegDisp->ReadEbx(); - pContext->Ebp = pRegDisp->ReadEbp(); - pContext->Eax = pRegDisp->ReadEax(); - pContext->Ecx = pRegDisp->ReadEcx(); - pContext->Edx = pRegDisp->ReadEdx(); + pContext->Edi = *pRegDisp->GetEdiLocation(); + pContext->Esi = *pRegDisp->GetEsiLocation(); + pContext->Ebx = *pRegDisp->GetEbxLocation(); + pContext->Ebp = *pRegDisp->GetEbpLocation(); + pContext->Eax = *pRegDisp->GetEaxLocation(); + pContext->Ecx = *pRegDisp->GetEcxLocation(); + pContext->Edx = *pRegDisp->GetEdxLocation(); pContext->Esp = pRegDisp->SP; pContext->Eip = pRegDisp->ControlPC; diff --git a/src/debug/ee/debugger.inl b/src/debug/ee/debugger.inl index 1ee83160e24a..57372868c0e5 100644 --- a/src/debug/ee/debugger.inl +++ b/src/debug/ee/debugger.inl @@ -235,13 +235,13 @@ inline void FuncEvalFrame::UpdateRegDisplay(const PREGDISPLAY pRD) // 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->RestoreEdi(&(pDE->m_context.Edi)); - pRD->RestoreEsi(&(pDE->m_context.Esi)); - pRD->RestoreEbx(&(pDE->m_context.Ebx)); - pRD->RestoreEdx(&(pDE->m_context.Edx)); - pRD->RestoreEcx(&(pDE->m_context.Ecx)); - pRD->RestoreEax(&(pDE->m_context.Eax)); - pRD->RestoreEbp(&(pDE->m_context.Ebp)); + 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->SP = (DWORD)GetSP(&pDE->m_context); pRD->PCTAddr = GetReturnAddressPtr(); pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr); diff --git a/src/debug/ee/i386/x86walker.cpp b/src/debug/ee/i386/x86walker.cpp index 28e14b5d231e..8b6279748412 100644 --- a/src/debug/ee/i386/x86walker.cpp +++ b/src/debug/ee/i386/x86walker.cpp @@ -292,28 +292,28 @@ DWORD NativeWalker::GetRegisterValue(int registerNumber) switch (registerNumber) { case 0: - return m_registers->ReadEax(); + return *m_registers->GetEaxLocation(); break; case 1: - return m_registers->ReadEcx(); + return *m_registers->GetEcxLocation(); break; case 2: - return m_registers->ReadEdx(); + return *m_registers->GetEdxLocation(); break; case 3: - return m_registers->ReadEbx(); + return *m_registers->GetEbxLocation(); break; case 4: return m_registers->SP; break; case 5: - return m_registers->ReadEbp(); + return *m_registers->GetEbpLocation(); break; case 6: - return m_registers->ReadEsi(); + return *m_registers->GetEsiLocation(); break; case 7: - return m_registers->ReadEdi(); + return *m_registers->GetEdiLocation(); break; default: _ASSERTE(!"Invalid register number!"); diff --git a/src/debug/shared/i386/primitives.cpp b/src/debug/shared/i386/primitives.cpp index aa16a8d20cd0..ab22a5d4b12b 100644 --- a/src/debug/shared/i386/primitives.cpp +++ b/src/debug/shared/i386/primitives.cpp @@ -88,12 +88,12 @@ void SetDebuggerREGDISPLAYFromREGDISPLAY(DebuggerREGDISPLAY* pDRD, REGDISPLAY* p // Frame pointer LPVOID FPAddress = GetRegdisplayFPAddress(pRD); pDRD->FP = (FPAddress == NULL ? 0 : *((SIZE_T *)FPAddress)); - pDRD->Edi = (pRD->LocateEdi() == NULL ? 0 : pRD->ReadEdi()); - pDRD->Esi = (pRD->LocateEsi() == NULL ? 0 : pRD->ReadEsi()); - pDRD->Ebx = (pRD->LocateEbx() == NULL ? 0 : pRD->ReadEbx()); - pDRD->Edx = (pRD->LocateEdx() == NULL ? 0 : pRD->ReadEdx()); - pDRD->Ecx = (pRD->LocateEcx() == NULL ? 0 : pRD->ReadEcx()); - pDRD->Eax = (pRD->LocateEax() == NULL ? 0 : pRD->ReadEax()); + pDRD->Edi = (pRD->GetEdiLocation() == NULL ? 0 : *pRD->GetEdiLocation()); + pDRD->Esi = (pRD->GetEsiLocation() == NULL ? 0 : *pRD->GetEsiLocation()); + pDRD->Ebx = (pRD->GetEbxLocation() == NULL ? 0 : *pRD->GetEbxLocation()); + pDRD->Edx = (pRD->GetEdxLocation() == NULL ? 0 : *pRD->GetEdxLocation()); + pDRD->Ecx = (pRD->GetEcxLocation() == NULL ? 0 : *pRD->GetEcxLocation()); + pDRD->Eax = (pRD->GetEsiLocation() == NULL ? 0 : *pRD->GetEaxLocation()); #if defined(USE_REMOTE_REGISTER_ADDRESS) pDRD->pFP = PushedRegAddr(pRD, FPAddress); diff --git a/src/inc/regdisp.h b/src/inc/regdisp.h index fcebc0794658..ee70bba0af44 100644 --- a/src/inc/regdisp.h +++ b/src/inc/regdisp.h @@ -71,28 +71,26 @@ struct REGDISPLAY : public REGDISPLAY_BASE { DWORD * pEsi; DWORD * pEdi; DWORD * pEbp; +#endif // !WIN64EXCEPTIONS + +#ifndef WIN64EXCEPTIONS #define VOLATILE_REG_METHODS(reg) \ - inline DWORD Read##reg(void) { return *p##reg; } \ - inline PDWORD Locate##reg(void) { return p##reg; } \ - inline void Restore##reg(PDWORD p##reg) { this->p##reg = p##reg; } \ - inline void Trash##reg(PDWORD p##reg) { this->p##reg = p##reg; } + inline PDWORD Get##reg##Location(void) { return p##reg; } \ + inline void Set##reg##Location(PDWORD p##reg) { this->p##reg = p##reg; } #define NONVOLATILE_REG_METHODS(reg) VOLATILE_REG_METHODS(reg) #else // !WIN64EXCEPTIONS #define VOLATILE_REG_METHODS(reg) \ - inline DWORD Read##reg(void) { return pCurrentContext->reg; } \ - inline PDWORD Locate##reg(void) { return NULL; } \ - inline void Restore##reg(PDWORD p##reg) { pCurrentContext->reg = *p##reg; } \ - inline void Trash##reg(PDWORD p##reg) { pCurrentContext->reg = *p##reg; } + inline PDWORD Get##reg##Location(void) { return &pCurrentContext->reg; } \ + inline void Set##reg##Location(PDWORD p##reg) { pCurrentContext->reg = *p##reg; } #define NONVOLATILE_REG_METHODS(reg) \ - inline DWORD Read##reg(void) { return pCurrentContext->reg; } \ - inline PDWORD Locate##reg(void) { return (pCurrentContextPointers) ? pCurrentContextPointers->reg : NULL; } \ - inline void Restore##reg(PDWORD p##reg) { if (pCurrentContextPointers) { pCurrentContextPointers->reg = p##reg; } pCurrentContext->reg = *p##reg; } \ - inline void Trash##reg(PDWORD p##reg) { if (pCurrentContextPointers) { pCurrentContextPointers->reg = NULL; } pCurrentContext->reg = *p##reg; } + inline PDWORD Get##reg##Location(void) { return (pCurrentContextPointers) ? pCurrentContextPointers->reg : &pCurrentContext->reg; } \ + inline void Set##reg##Location(PDWORD p##reg) { if (pCurrentContextPointers) { pCurrentContextPointers->reg = p##reg; } pCurrentContext->reg = *p##reg; } + #endif // WIN64EXCEPTIONS VOLATILE_REG_METHODS(Eax) @@ -117,21 +115,21 @@ struct REGDISPLAY : public REGDISPLAY_BASE { TAG_EBP }; - inline void Restore(TAG tag, PDWORD pReg) + inline void SetLocation(TAG tag, PDWORD pReg) { switch (tag) { case TAG_EBX: - RestoreEbx(pReg); + SetEbxLocation(pReg); break; case TAG_ESI: - RestoreEsi(pReg); + SetEsiLocation(pReg); break; case TAG_EDI: - RestoreEdi(pReg); + SetEdiLocation(pReg); break; case TAG_EBP: - RestoreEbp(pReg); + SetEbpLocation(pReg); break; default: _ASSERTE(!"Invalid register"); @@ -155,13 +153,13 @@ inline void SetRegdisplaySP(REGDISPLAY *display, LPVOID sp ) { inline TADDR GetRegdisplayFP(REGDISPLAY *display) { LIMITED_METHOD_DAC_CONTRACT; - return (TADDR)display->ReadEbp(); + return (TADDR)*display->GetEbpLocation(); } inline LPVOID GetRegdisplayFPAddress(REGDISPLAY *display) { LIMITED_METHOD_CONTRACT; - return (LPVOID)display->LocateEbp(); + return (LPVOID)display->GetEbpLocation(); } inline PCODE GetControlPC(REGDISPLAY *display) { diff --git a/src/vm/eetwain.cpp b/src/vm/eetwain.cpp index 6dfd93eb3c74..7ada2147e834 100644 --- a/src/vm/eetwain.cpp +++ b/src/vm/eetwain.cpp @@ -1642,10 +1642,10 @@ void * getCalleeSavedReg(PREGDISPLAY pContext, regNum reg) switch (reg) { - case REGI_EBP: return pContext->LocateEbp(); - case REGI_EBX: return pContext->LocateEbx(); - case REGI_ESI: return pContext->LocateEsi(); - case REGI_EDI: return pContext->LocateEdi(); + case REGI_EBP: return pContext->GetEbpLocation(); + case REGI_EBX: return pContext->GetEbxLocation(); + case REGI_ESI: return pContext->GetEsiLocation(); + case REGI_EDI: return pContext->GetEdiLocation(); default: _ASSERTE(!"bad info.thisPtrResult"); return NULL; } @@ -2840,9 +2840,9 @@ void TRASH_CALLEE_UNSAVED_REGS(PREGDISPLAY pContext) /* This is not completely correct as we lose the current value, but it should not really be useful to anyone. */ static DWORD s_badData = 0xDEADBEEF; - pContext->TrashEax(&s_badData); - pContext->TrashEcx(&s_badData); - pContext->TrashEdx(&s_badData); + pContext->SetEaxLocation(&s_badData); + pContext->SetEcxLocation(&s_badData); + pContext->SetEdxLocation(&s_badData); #endif //_DEBUG } @@ -3132,10 +3132,10 @@ void EECodeManager::QuickUnwindStackFrame(PREGDISPLAY pRD, StackwalkCacheEntry * if (pCacheEntry->fUseEbpAsFrameReg) { _ASSERTE(pCacheEntry->fUseEbp); - TADDR curEBP = (TADDR)pRD->ReadEbp(); + TADDR curEBP = (TADDR)*pRD->GetEbpLocation(); // EBP frame, update ESP through EBP, since ESPOffset may vary - pRD->RestoreEbp(PTR_DWORD(curEBP)); + pRD->SetEbpLocation(PTR_DWORD(curEBP)); pRD->SP = curEBP + sizeof(void*); } else @@ -3283,7 +3283,7 @@ void UnwindEspFrameEpilog( Get the value from the stack if needed */ if ((flags & UpdateAllRegs) || (regMask == RM_EBP)) { - pContext->Restore(CALLEE_SAVED_REGISTERS_TAG[i - 1], PTR_DWORD((TADDR)ESP)); + pContext->SetLocation(CALLEE_SAVED_REGISTERS_TAG[i - 1], PTR_DWORD((TADDR)ESP)); } /* Adjust ESP */ @@ -3388,7 +3388,7 @@ void UnwindEbpDoubleAlignFrameEpilog( unsigned calleeSavedRegsSize = info->savedRegsCountExclFP * sizeof(void*); if (!InstructionAlreadyExecuted(offset, info->epilogOffs)) - ESP = pContext->ReadEbp() - calleeSavedRegsSize; + ESP = *pContext->GetEbpLocation() - calleeSavedRegsSize; offset = SKIP_LEA_ESP_EBP(-int(calleeSavedRegsSize), epilogBase, offset); } @@ -3406,7 +3406,7 @@ void UnwindEbpDoubleAlignFrameEpilog( { if (flags & UpdateAllRegs) { - pContext->Restore(CALLEE_SAVED_REGISTERS_TAG[i - 1], PTR_DWORD((TADDR)ESP)); + pContext->SetLocation(CALLEE_SAVED_REGISTERS_TAG[i - 1], PTR_DWORD((TADDR)ESP)); } ESP += sizeof(void*); } @@ -3417,7 +3417,7 @@ void UnwindEbpDoubleAlignFrameEpilog( if (needMovEspEbp) { if (!InstructionAlreadyExecuted(offset, info->epilogOffs)) - ESP = pContext->ReadEbp(); + ESP = *pContext->GetEbpLocation(); offset = SKIP_MOV_REG_REG(epilogBase, offset); } @@ -3425,7 +3425,7 @@ void UnwindEbpDoubleAlignFrameEpilog( // Have we executed the pop EBP? if (!InstructionAlreadyExecuted(offset, info->epilogOffs)) { - pContext->RestoreEbp(PTR_DWORD(TADDR(ESP))); + pContext->SetEbpLocation(PTR_DWORD(TADDR(ESP))); ESP += sizeof(void*); } offset = SKIP_POP_REG(epilogBase, offset); @@ -3553,16 +3553,16 @@ void UnwindEspFrameProlog( // Always restore EBP if (regsMask & RM_EBP) - pContext->RestoreEbp(savedRegPtr++); + pContext->SetEbpLocation(savedRegPtr++); if (flags & UpdateAllRegs) { if (regsMask & RM_EBX) - pContext->RestoreEbx(savedRegPtr++); + pContext->SetEbxLocation(savedRegPtr++); if (regsMask & RM_ESI) - pContext->RestoreEsi(savedRegPtr++); + pContext->SetEsiLocation(savedRegPtr++); if (regsMask & RM_EDI) - pContext->RestoreEdi(savedRegPtr++); + pContext->SetEdiLocation(savedRegPtr++); TRASH_CALLEE_UNSAVED_REGS(pContext); } @@ -3628,7 +3628,7 @@ void UnwindEspFrame( if ((regMask & regsMask) == 0) continue; - pContext->Restore(CALLEE_SAVED_REGISTERS_TAG[i - 1], PTR_DWORD((TADDR)ESP)); + pContext->SetLocation(CALLEE_SAVED_REGISTERS_TAG[i - 1], PTR_DWORD((TADDR)ESP)); ESP += sizeof(unsigned); } @@ -3706,7 +3706,7 @@ void UnwindEbpDoubleAlignFrameProlog( can be determined using EBP. Since we are still in the prolog, we need to know our exact location to determine the callee-saved registers */ - const unsigned curEBP = pContext->ReadEbp(); + const unsigned curEBP = *pContext->GetEbpLocation(); if (flags & UpdateAllRegs) { @@ -3739,7 +3739,7 @@ void UnwindEbpDoubleAlignFrameProlog( if (InstructionAlreadyExecuted(offset, curOffs)) { - pContext->Restore(CALLEE_SAVED_REGISTERS_TAG[i], PTR_DWORD(--pSavedRegs)); + pContext->SetLocation(CALLEE_SAVED_REGISTERS_TAG[i], PTR_DWORD(--pSavedRegs)); } // "push reg" @@ -3751,7 +3751,7 @@ void UnwindEbpDoubleAlignFrameProlog( /* The caller's saved EBP is pointed to by our EBP */ - pContext->RestoreEbp(PTR_DWORD((TADDR)curEBP)); + pContext->SetEbpLocation(PTR_DWORD((TADDR)curEBP)); pContext->SP = DWORD((TADDR)(curEBP + sizeof(void *))); /* Stack pointer points to return address */ @@ -3775,7 +3775,7 @@ bool UnwindEbpDoubleAlignFrame( _ASSERTE(info->ebpFrame || info->doubleAlign); const unsigned curESP = pContext->SP; - const unsigned curEBP = pContext->ReadEbp(); + const unsigned curEBP = *pContext->GetEbpLocation(); /* First check if we are in a filter (which is obviously after the prolog) */ @@ -3818,13 +3818,13 @@ bool UnwindEbpDoubleAlignFrame( { static DWORD s_badData = 0xDEADBEEF; - pContext->TrashEax(&s_badData); - pContext->TrashEcx(&s_badData); - pContext->TrashEdx(&s_badData); + pContext->SetEaxLocation(&s_badData); + pContext->SetEcxLocation(&s_badData); + pContext->SetEdxLocation(&s_badData); - pContext->TrashEbx(&s_badData); - pContext->TrashEsi(&s_badData); - pContext->TrashEdi(&s_badData); + pContext->SetEbxLocation(&s_badData); + pContext->SetEsiLocation(&s_badData); + pContext->SetEdiLocation(&s_badData); } #endif @@ -3867,7 +3867,7 @@ bool UnwindEbpDoubleAlignFrame( if ((info->savedRegMask & regMask) == 0) continue; - pContext->Restore(CALLEE_SAVED_REGISTERS_TAG[i], --pSavedRegs); + pContext->SetLocation(CALLEE_SAVED_REGISTERS_TAG[i], --pSavedRegs); } } @@ -3882,7 +3882,7 @@ bool UnwindEbpDoubleAlignFrame( /* The caller's saved EBP is pointed to by our EBP */ - pContext->RestoreEbp(PTR_DWORD((TADDR)curEBP)); + pContext->SetEbpLocation(PTR_DWORD((TADDR)curEBP)); return true; } @@ -4121,7 +4121,7 @@ bool EECodeManager::EnumGcRefs( PREGDISPLAY pContext, GCInfoToken gcInfoToken = pCodeInfo->GetGCInfoToken(); unsigned curOffs = pCodeInfo->GetRelOffset(); - unsigned EBP = pContext->ReadEbp(); + unsigned EBP = *pContext->GetEbpLocation(); unsigned ESP = pContext->SP; unsigned ptrOffs; @@ -4188,7 +4188,7 @@ bool EECodeManager::EnumGcRefs( PREGDISPLAY pContext, if (dspPtr) \ printf(" Live pointer register %s: ", #regName); \ pCallBack(hCallBack, \ - (OBJECTREF*)(pContext->Locate##regName()), \ + (OBJECTREF*)(pContext->Get##regName##Location()), \ (iptr ? GC_CALL_INTERIOR : 0) \ | CHECK_APP_DOMAIN \ DAC_ARG(DacSlotLocation(reg, 0, false))); \ @@ -4197,7 +4197,7 @@ bool EECodeManager::EnumGcRefs( PREGDISPLAY pContext, #define CHK_AND_REPORT_REG(reg, doIt, iptr, regName) \ if (doIt) \ pCallBack(hCallBack, \ - (OBJECTREF*)(pContext->Locate##regName()), \ + (OBJECTREF*)(pContext->Get##regName##Location()), \ (iptr ? GC_CALL_INTERIOR : 0) \ | CHECK_APP_DOMAIN \ DAC_ARG(DacSlotLocation(reg, 0, false))); @@ -5022,7 +5022,7 @@ OBJECTREF* EECodeManager::GetAddrOfSecurityObjectFromCachedInfo(PREGDISPLAY pRD, // We pretend that filters are ESP-based methods in UnwindEbpDoubleAlignFrame(). // Hence we cannot enforce this assert. // _ASSERTE(stackwalkCacheUnwindInfo->fUseEbpAsFrameReg); - return (OBJECTREF *) (size_t) (pRD->ReadEbp() - (securityObjectOffset * sizeof(void*))); + return (OBJECTREF *) (size_t) (*pRD->GetEbpLocation() - (securityObjectOffset * sizeof(void*))); #else PORTABILITY_ASSERT("EECodeManager::GetAddrOfSecurityObjectFromContext is not implemented on this platform."); return NULL; @@ -5062,7 +5062,7 @@ OBJECTREF* EECodeManager::GetAddrOfSecurityObject(CrawlFrame *pCF) if(stateBuf->hdrInfoBody.prologOffs == hdrInfo::NOT_IN_PROLOG && stateBuf->hdrInfoBody.epilogOffs == hdrInfo::NOT_IN_EPILOG) { - return (OBJECTREF *)(size_t)(pRD->ReadEbp() - GetSecurityObjectOffset(&stateBuf->hdrInfoBody)); + return (OBJECTREF *)(size_t)(*pRD->GetEbpLocation() - GetSecurityObjectOffset(&stateBuf->hdrInfoBody)); } } #elif defined(USE_GC_INFO_DECODER) && !defined(CROSSGEN_COMPILE) @@ -5164,7 +5164,7 @@ OBJECTREF EECodeManager::GetInstance( PREGDISPLAY pContext, if (info.ebpFrame) { _ASSERTE(stackDepth == 0); - taArgBase = pContext->ReadEbp(); + taArgBase = *pContext->GetEbpLocation(); } else { @@ -5467,7 +5467,7 @@ void * EECodeManager::GetGSCookieAddr(PREGDISPLAY pContext, if (info->ebpFrame) { - return PVOID(SIZE_T(pContext->ReadEbp() - info->gsCookieOffset)); + return PVOID(SIZE_T(*pContext->GetEbpLocation() - info->gsCookieOffset)); } else { diff --git a/src/vm/frames.cpp b/src/vm/frames.cpp index 7e1e7de935eb..ae3cfdbc7563 100644 --- a/src/vm/frames.cpp +++ b/src/vm/frames.cpp @@ -2006,8 +2006,8 @@ BOOL MulticastFrame::TraceFrame(Thread *thread, BOOL fromPatch, #if defined(_TARGET_X86_) // At this point the counter hasn't been incremented yet. - delegateCount = regs->ReadEdi() + 1; - pbDel = *(BYTE **)( (size_t)regs->ReadEsi() + GetOffsetOfTransitionBlock() + ArgIterator::GetThisOffset()); + delegateCount = *regs->GetEdiLocation() + 1; + pbDel = *(BYTE **)( (size_t)*regs->GetEsiLocation() + GetOffsetOfTransitionBlock() + ArgIterator::GetThisOffset()); #elif defined(_TARGET_AMD64_) // At this point the counter hasn't been incremented yet. delegateCount = (int)regs->pCurrentContext->Rdi + 1; diff --git a/src/vm/gccover.cpp b/src/vm/gccover.cpp index b832e3b9559f..02bb0de5e001 100644 --- a/src/vm/gccover.cpp +++ b/src/vm/gccover.cpp @@ -1565,10 +1565,10 @@ void DoGcStress (PCONTEXT regs, MethodDesc *pMD) _ASSERTE(pThread->PreemptiveGCDisabled()); // Epilogs should be in cooperative mode, no GC can happen right now. bool gcHappened = gcCover->gcCount != GCHeapUtilities::GetGCHeap()->GetGcCount(); - checkAndUpdateReg(gcCover->callerRegs.Edi, regDisp.ReadEdi(), gcHappened); - checkAndUpdateReg(gcCover->callerRegs.Esi, regDisp.ReadEsi(), gcHappened); - checkAndUpdateReg(gcCover->callerRegs.Ebx, regDisp.ReadEbx(), gcHappened); - checkAndUpdateReg(gcCover->callerRegs.Ebp, regDisp.ReadEbp(), gcHappened); + checkAndUpdateReg(gcCover->callerRegs.Edi, *regDisp.GetEdiLocation(), gcHappened); + checkAndUpdateReg(gcCover->callerRegs.Esi, *regDisp.GetEsiLocation(), gcHappened); + checkAndUpdateReg(gcCover->callerRegs.Ebx, *regDisp.GetEbxLocation(), gcHappened); + checkAndUpdateReg(gcCover->callerRegs.Ebp, *regDisp.GetEbpLocation(), gcHappened); gcCover->gcCount = GCHeapUtilities::GetGCHeap()->GetGcCount(); diff --git a/src/vm/i386/cgenx86.cpp b/src/vm/i386/cgenx86.cpp index 8a80d376ea5a..23fc017f06d1 100644 --- a/src/vm/i386/cgenx86.cpp +++ b/src/vm/i386/cgenx86.cpp @@ -214,10 +214,10 @@ void EHContext::Setup(PCODE resumePC, PREGDISPLAY regs) // EAX ECX EDX are scratch this->Esp = regs->SP; - this->Ebx = regs->ReadEbx(); - this->Esi = regs->ReadEsi(); - this->Edi = regs->ReadEdi(); - this->Ebp = regs->ReadEbp(); + this->Ebx = *regs->GetEbxLocation(); + this->Esi = *regs->GetEsiLocation(); + this->Edi = *regs->GetEdiLocation(); + this->Ebp = *regs->GetEbpLocation(); this->Eip = (ULONG)(size_t)resumePC; } @@ -246,15 +246,15 @@ void EHContext::UpdateFrame(PREGDISPLAY regs) // EAX ECX EDX are scratch. // No need to update ESP as unwinder takes care of that for us - LOG((LF_EH, LL_INFO1000, "Updating saved EBX: *%p= %p\n", regs->LocateEbx(), this->Ebx)); - LOG((LF_EH, LL_INFO1000, "Updating saved ESI: *%p= %p\n", regs->LocateEsi(), this->Esi)); - LOG((LF_EH, LL_INFO1000, "Updating saved EDI: *%p= %p\n", regs->LocateEdi(), this->Edi)); - LOG((LF_EH, LL_INFO1000, "Updating saved EBP: *%p= %p\n", regs->LocateEbp(), this->Ebp)); + LOG((LF_EH, LL_INFO1000, "Updating saved EBX: *%p= %p\n", regs->GetEbxLocation(), this->Ebx)); + LOG((LF_EH, LL_INFO1000, "Updating saved ESI: *%p= %p\n", regs->GetEsiLocation(), this->Esi)); + LOG((LF_EH, LL_INFO1000, "Updating saved EDI: *%p= %p\n", regs->GetEdiLocation(), this->Edi)); + LOG((LF_EH, LL_INFO1000, "Updating saved EBP: *%p= %p\n", regs->GetEbpLocation(), this->Ebp)); - *regs->LocateEbx() = this->Ebx; - *regs->LocateEsi() = this->Esi; - *regs->LocateEdi() = this->Edi; - *regs->LocateEbp() = this->Ebp; + *regs->GetEbxLocation() = this->Ebx; + *regs->GetEsiLocation() = this->Esi; + *regs->GetEdiLocation() = this->Edi; + *regs->GetEbpLocation() = this->Ebp; } void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD) @@ -298,7 +298,7 @@ void TransitionFrame::UpdateRegDisplayHelper(const PREGDISPLAY pRD, UINT cbStack pRD->pContext = NULL; -#define CALLEE_SAVED_REGISTER(regname) pRD->Restore##regname(PDWORD(®s->regname)); +#define CALLEE_SAVED_REGISTER(regname) pRD->Set##regname##Location(PDWORD(®s->regname)); ENUM_CALLEE_SAVED_REGISTERS(); #undef CALLEE_SAVED_REGISTER pRD->PCTAddr = GetReturnAddressPtr(); @@ -369,13 +369,13 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD) DacAllocHostOnlyInstance(sizeof(*thisState), true); thisState->_edi = unwindState._edi; - pRD->RestoreEdi((DWORD *)&thisState->_edi); + pRD->SetEdiLocation((DWORD *)&thisState->_edi); thisState->_esi = unwindState._esi; - pRD->RestoreEsi((DWORD *)&thisState->_esi); + pRD->SetEsiLocation((DWORD *)&thisState->_esi); thisState->_ebx = unwindState._ebx; - pRD->RestoreEbx((DWORD *)&thisState->_ebx); + pRD->SetEbxLocation((DWORD *)&thisState->_ebx); thisState->_ebp = unwindState._ebp; - pRD->RestoreEbp((DWORD *)&thisState->_ebp); + pRD->SetEbpLocation((DWORD *)&thisState->_ebp); // InsureInit always sets m_RegArgs to zero // in the real code. I'm not sure exactly @@ -393,10 +393,10 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD) // DACCESS: The MachState pointers are kept as PTR_TADDR so // the host pointers here refer to the appropriate size and // these casts are not a problem. - pRD->RestoreEdi((DWORD*) m_MachState.pEdi()); - pRD->RestoreEsi((DWORD*) m_MachState.pEsi()); - pRD->RestoreEbx((DWORD*) m_MachState.pEbx()); - pRD->RestoreEbp((DWORD*) m_MachState.pEbp()); + pRD->SetEdiLocation((DWORD*) m_MachState.pEdi()); + pRD->SetEsiLocation((DWORD*) m_MachState.pEsi()); + pRD->SetEbxLocation((DWORD*) m_MachState.pEbx()); + pRD->SetEbpLocation((DWORD*) m_MachState.pEbp()); pRD->PCTAddr = dac_cast(m_MachState.pRetAddr()); pRD->ControlPC = m_MachState.GetRetAddr(); pRD->SP = (DWORD) m_MachState.esp(); @@ -628,7 +628,7 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD) #undef CALLEE_SAVED_REGISTER #endif - pRD->RestoreEbp(PDWORD(&m_pCalleeSavedFP)); + pRD->SetEbpLocation(PDWORD(&m_pCalleeSavedFP)); /* The return address is just above the "ESP" */ pRD->PCTAddr = PTR_HOST_MEMBER_TADDR(InlinedCallFrame, this, @@ -699,14 +699,14 @@ void ResumableFrame::UpdateRegDisplay(const PREGDISPLAY pRD) #endif // !defined(DACCESS_COMPILE) #endif // !WIN64EXCEPTIONS - pRD->RestoreEax(&pUnwoundContext->Eax); - pRD->RestoreEcx(&pUnwoundContext->Ecx); - pRD->RestoreEdx(&pUnwoundContext->Edx); + pRD->SetEaxLocation(&pUnwoundContext->Eax); + pRD->SetEcxLocation(&pUnwoundContext->Ecx); + pRD->SetEdxLocation(&pUnwoundContext->Edx); - pRD->RestoreEdi(&pUnwoundContext->Edi); - pRD->RestoreEsi(&pUnwoundContext->Esi); - pRD->RestoreEbx(&pUnwoundContext->Ebx); - pRD->RestoreEbp(&pUnwoundContext->Ebp); + pRD->SetEdiLocation(&pUnwoundContext->Edi); + pRD->SetEsiLocation(&pUnwoundContext->Esi); + pRD->SetEbxLocation(&pUnwoundContext->Ebx); + pRD->SetEbpLocation(&pUnwoundContext->Ebp); pRD->ControlPC = pUnwoundContext->Eip; pRD->PCTAddr = dac_cast(m_Regs) + offsetof(CONTEXT, Eip); @@ -730,14 +730,14 @@ void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD) // This only describes the top-most frame pRD->pContext = NULL; - pRD->RestoreEdi(&m_Args->Edi); - pRD->RestoreEsi(&m_Args->Esi); - pRD->RestoreEbx(&m_Args->Ebx); - pRD->RestoreEdx(&m_Args->Edx); - pRD->RestoreEcx(&m_Args->Ecx); - pRD->RestoreEax(&m_Args->Eax); + pRD->SetEdiLocation(&m_Args->Edi); + pRD->SetEsiLocation(&m_Args->Esi); + pRD->SetEbxLocation(&m_Args->Ebx); + pRD->SetEdxLocation(&m_Args->Edx); + pRD->SetEcxLocation(&m_Args->Ecx); + pRD->SetEaxLocation(&m_Args->Eax); - pRD->RestoreEbp(&m_Args->Ebp); + pRD->SetEbpLocation(&m_Args->Ebp); pRD->PCTAddr = dac_cast(m_Args) + offsetof(HijackArgs, Eip); pRD->ControlPC = *PTR_PCODE(pRD->PCTAddr); pRD->SP = (DWORD)(pRD->PCTAddr + sizeof(TADDR)); @@ -778,7 +778,7 @@ void TailCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD) // reset pContext; it's only valid for active (top-most) frame pRD->pContext = NULL; -#define CALLEE_SAVED_REGISTER(regname) pRD->Restore##regname(PDWORD(&m_regs.regname)); +#define CALLEE_SAVED_REGISTER(regname) pRD->Set##regname##Location(PDWORD(&m_regs.regname)); ENUM_CALLEE_SAVED_REGISTERS(); #undef CALLEE_SAVED_REGISTER diff --git a/src/vm/proftoeeinterfaceimpl.cpp b/src/vm/proftoeeinterfaceimpl.cpp index 21bdce9d8169..da66dbde449c 100644 --- a/src/vm/proftoeeinterfaceimpl.cpp +++ b/src/vm/proftoeeinterfaceimpl.cpp @@ -7411,7 +7411,7 @@ HRESULT ProfToEEInterfaceImpl::ProfilerEbpWalker( REGDISPLAY rd; ZeroMemory(&rd, sizeof(rd)); - rd.RestoreEbp(&ctxCur.Ebp); + rd.SetEbpLocation(&ctxCur.Ebp); rd.SP = ctxCur.Esp; rd.ControlPC = ctxCur.Eip; @@ -7422,7 +7422,7 @@ HRESULT ProfToEEInterfaceImpl::ProfilerEbpWalker( &codeManState, NULL); - ctxCur.Ebp = rd.ReadEbp(); + ctxCur.Ebp = *rd.GetEbpLocation(); ctxCur.Esp = rd.SP; ctxCur.Eip = rd.ControlPC; }