@@ -2198,6 +2198,8 @@ PCODE MethodDesc::GetCallTarget(OBJECTREF* pThisObj, TypeHandle ownerType)
21982198 return pTarget;
21992199}
22002200
2201+ #endif // !DACCESS_COMPILE
2202+
22012203MethodDesc* NonVirtualEntry2MethodDesc (PCODE entryPoint)
22022204{
22032205 CONTRACTL {
@@ -2213,38 +2215,37 @@ MethodDesc* NonVirtualEntry2MethodDesc(PCODE entryPoint)
22132215 return NULL ;
22142216 }
22152217
2216- // Inlined fast path for fixup precode and stub precode from RangeList implementation
2217- if (pRS->_flags == RangeSection::RANGE_SECTION_RANGELIST)
2218+ if (pRS->_flags & RangeSection::RANGE_SECTION_RANGELIST)
22182219 {
2220+ Precode* pPrecode = Precode::GetPrecodeFromEntryPoint (entryPoint);
2221+ #ifdef DACCESS_COMPILE
2222+ // GetPrecodeFromEntryPoint can return NULL under DAC
2223+ if (pPrecode == NULL )
2224+ return NULL ;
2225+ #endif
22192226 if (pRS->_pRangeList ->GetCodeBlockKind () == STUB_CODE_BLOCK_FIXUPPRECODE)
22202227 {
2221- return (MethodDesc*)((FixupPrecode*) PCODEToPINSTR (entryPoint)) ->GetMethodDesc ();
2228+ return dac_cast<PTR_MethodDesc>(pPrecode-> AsFixupPrecode () ->GetMethodDesc () );
22222229 }
22232230 if (pRS->_pRangeList ->GetCodeBlockKind () == STUB_CODE_BLOCK_STUBPRECODE)
22242231 {
2225- return (MethodDesc*)((StubPrecode*) PCODEToPINSTR (entryPoint)) ->GetMethodDesc ();
2232+ return dac_cast<PTR_MethodDesc>(pPrecode-> AsStubPrecode () ->GetMethodDesc () );
22262233 }
22272234 }
2228-
2229- MethodDesc* pMD;
2230- if (pRS->_pjit ->JitCodeToMethodInfo (pRS, entryPoint, &pMD, NULL ))
2231- return pMD;
2232-
2233- auto stubCodeBlockKind = pRS->_pjit ->GetStubCodeBlockKind (pRS, entryPoint);
2234-
2235- switch (stubCodeBlockKind)
2235+ else
22362236 {
2237- case STUB_CODE_BLOCK_FIXUPPRECODE:
2238- return (MethodDesc*)((FixupPrecode*)PCODEToPINSTR (entryPoint))->GetMethodDesc ();
2239- case STUB_CODE_BLOCK_STUBPRECODE:
2240- return (MethodDesc*)((StubPrecode*)PCODEToPINSTR (entryPoint))->GetMethodDesc ();
2241- default :
2242- // We should never get here
2243- _ASSERTE (!" NonVirtualEntry2MethodDesc failed for RangeSection" );
2244- return NULL ;
2237+ MethodDesc* pMD;
2238+ if (pRS->_pjit ->JitCodeToMethodInfo (pRS, entryPoint, &pMD, NULL ))
2239+ return pMD;
22452240 }
2241+
2242+ // We should never get here
2243+ _ASSERTE (!" NonVirtualEntry2MethodDesc failed" );
2244+ return NULL ;
22462245}
22472246
2247+ #ifndef DACCESS_COMPILE
2248+
22482249static void GetNameOfTypeDefOrRef (Module* pModule, mdToken tk, LPCSTR* pName, LPCSTR* pNamespace)
22492250{
22502251 *pName = " " ;
@@ -2624,7 +2625,7 @@ void MethodDesc::CheckRestore(ClassLoadLevel level)
26242625}
26252626
26262627// static
2627- MethodDesc* MethodDesc::GetMethodDescFromStubAddr (PCODE addr, BOOL fSpeculative /* =FALSE*/ )
2628+ MethodDesc* MethodDesc::GetMethodDescFromPrecode (PCODE addr, BOOL fSpeculative /* =FALSE*/ )
26282629{
26292630 CONTRACT (MethodDesc *)
26302631 {
@@ -2635,8 +2636,6 @@ MethodDesc* MethodDesc::GetMethodDescFromStubAddr(PCODE addr, BOOL fSpeculative
26352636
26362637 MethodDesc* pMD = NULL ;
26372638
2638- // Otherwise this must be some kind of precode
2639- //
26402639 PTR_Precode pPrecode = Precode::GetPrecodeFromEntryPoint (addr, fSpeculative );
26412640 _ASSERTE (fSpeculative || (pPrecode != NULL ));
26422641 if (pPrecode != NULL )
@@ -2670,7 +2669,7 @@ PCODE MethodDesc::GetTemporaryEntryPoint()
26702669 _ASSERTE (pEntryPoint != (PCODE)NULL );
26712670
26722671#ifdef _DEBUG
2673- MethodDesc * pMD = MethodDesc::GetMethodDescFromStubAddr (pEntryPoint);
2672+ MethodDesc * pMD = MethodDesc::GetMethodDescFromPrecode (pEntryPoint);
26742673 _ASSERTE (PTR_HOST_TO_TADDR (this ) == PTR_HOST_TO_TADDR (pMD));
26752674#endif
26762675
0 commit comments