Skip to content

Commit f690f1d

Browse files
committed
PR feedback
* Refactored GC and EH info allocation * Added Interpreter-TODO at some places * Reverted some changes that were not needed anymore
1 parent 5998460 commit f690f1d

File tree

4 files changed

+52
-163
lines changed

4 files changed

+52
-163
lines changed

src/coreclr/inc/eetwain.h

+14-58
Original file line numberDiff line numberDiff line change
@@ -625,10 +625,6 @@ class InterpreterCodeManager : public ICodeManager {
625625

626626
#ifndef DACCESS_COMPILE
627627
#ifndef FEATURE_EH_FUNCLETS
628-
/*
629-
Last chance for the runtime support to do fixups in the context
630-
before execution continues inside a filter, catch handler, or finally
631-
*/
632628
virtual
633629
void FixContext(ContextType ctxType,
634630
EHContext *ctx,
@@ -640,6 +636,7 @@ void FixContext(ContextType ctxType,
640636
size_t ** ppShadowSP, // OUT
641637
size_t ** ppEndRegion) // OUT
642638
{
639+
// Interpreter-TODO: Implement this if needed
643640
_ASSERTE(FALSE);
644641
}
645642
#endif // !FEATURE_EH_FUNCLETS
@@ -657,41 +654,27 @@ TADDR GetAmbientSP(PREGDISPLAY pContext,
657654
DWORD nestingLevel,
658655
CodeManState *pState)
659656
{
657+
// Interpreter-TODO: Implement this if needed
660658
_ASSERTE(FALSE);
661659
return NULL;
662660
}
663661
#endif // TARGET_X86
664662

665-
/*
666-
Get the number of bytes used for stack parameters.
667-
This is currently only used on x86.
668-
*/
669663
virtual
670664
ULONG32 GetStackParameterSize(EECodeInfo* pCodeInfo)
671665
{
666+
// Interpreter-TODO: Implement this if needed
672667
_ASSERTE(FALSE);
673668
return 0;
674669
}
675670

676-
/*
677-
Unwind the current stack frame, i.e. update the virtual register
678-
set in pContext. This will be similar to the state after the function
679-
returns back to caller (IP points to after the call, Frame and Stack
680-
pointer has been reset, callee-saved registers restored
681-
(if UpdateAllRegs), callee-UNsaved registers are trashed)
682-
Returns success of operation.
683-
*/
684671
virtual
685672
bool UnwindStackFrame(
686673
PREGDISPLAY pContext,
687674
EECodeInfo *pCodeInfo,
688675
unsigned flags,
689676
CodeManState *pState);
690677

691-
/*
692-
Is the function currently at a "GC safe point" ?
693-
Can call EnumGcRefs() successfully
694-
*/
695678
virtual
696679
bool IsGcSafe( EECodeInfo *pCodeInfo,
697680
DWORD dwRelOffset);
@@ -705,13 +688,6 @@ bool HasTailCalls(EECodeInfo *pCodeInfo)
705688
}
706689
#endif // TARGET_ARM || TARGET_ARM64 || TARGET_LOONGARCH64 || defined(TARGET_RISCV64)
707690

708-
/*
709-
Enumerate all live object references in that function using
710-
the virtual register set. Same reference location cannot be enumerated
711-
multiple times (but all differenct references pointing to the same
712-
object have to be individually enumerated).
713-
Returns success of operation.
714-
*/
715691
virtual
716692
bool EnumGcRefs(PREGDISPLAY pContext,
717693
EECodeInfo *pCodeInfo,
@@ -725,86 +701,65 @@ OBJECTREF GetInstance(
725701
PREGDISPLAY pContext,
726702
EECodeInfo * pCodeInfo);
727703

728-
/*
729-
Returns the extra argument passed to shared generic code if it is still alive.
730-
Returns NULL in all other cases.
731-
*/
732704
virtual
733705
PTR_VOID GetParamTypeArg(PREGDISPLAY pContext,
734706
EECodeInfo * pCodeInfo);
735707

736-
// Returns the type of the context parameter (this, methodtable, methoddesc, or none)
737708
virtual GenericParamContextType GetParamContextType(PREGDISPLAY pContext,
738709
EECodeInfo * pCodeInfo);
739710

740-
/*
741-
Returns the offset of the GuardStack cookie if it exists.
742-
Returns NULL if there is no cookie.
743-
*/
744711
virtual
745712
void * GetGSCookieAddr(PREGDISPLAY pContext,
746713
EECodeInfo * pCodeInfo,
747714
unsigned flags,
748715
CodeManState * pState)
749716
{
717+
// Interpreter-TODO: Implement this if needed
750718
_ASSERTE(FALSE);
751719
return NULL;
752720
}
753721

754722

755723
#ifndef USE_GC_INFO_DECODER
756-
/*
757-
Returns true if the given IP is in the given method's prolog or an epilog.
758-
*/
759724
virtual
760725
bool IsInPrologOrEpilog(
761726
DWORD relOffset,
762727
GCInfoToken gcInfoToken,
763728
size_t* prologSize)
764729
{
730+
// Interpreter-TODO: Implement this if needed
765731
_ASSERTE(FALSE);
766732
return false;
767733
}
768734

769-
/*
770-
Returns true if the given IP is in the synchronized region of the method (valid for synchronized functions only)
771-
*/
772735
virtual
773736
bool IsInSynchronizedRegion(
774737
DWORD relOffset,
775738
GCInfoToken gcInfoToken,
776739
unsigned flags)
777740
{
741+
// Interpreter-TODO: Implement this if needed
778742
_ASSERTE(FALSE);
779743
return false;
780744
}
781745
#endif // !USE_GC_INFO_DECODER
782746

783-
/*
784-
Returns the size of a given function.
785-
*/
786747
virtual
787748
size_t GetFunctionSize(GCInfoToken gcInfoToken);
788749

789-
/*
790-
* Get information necessary for return address hijacking of the method represented by the gcInfoToken.
791-
* If it can be hijacked, it sets the returnKind output parameter to the kind of the return value and
792-
* returns true.
793-
* If hijacking is not possible for some reason, it return false.
794-
*/
795750
virtual bool GetReturnAddressHijackInfo(GCInfoToken gcInfoToken X86_ARG(ReturnKind * returnKind))
796751
{
752+
// Interpreter-TODO: Implement this if needed
797753
_ASSERTE(FALSE);
798754
return false;
799755
}
800756

801757
#ifndef USE_GC_INFO_DECODER
802-
/*
803-
Returns the size of the frame (barring localloc)
804-
*/
758+
805759
virtual
806760
unsigned int GetFrameSize(GCInfoToken gcInfoToken)
807761
{
762+
// Interpreter-TODO: Implement this if needed
808763
_ASSERTE(FALSE);
809764
return 0;
810765
}
@@ -815,6 +770,7 @@ unsigned int GetFrameSize(GCInfoToken gcInfoToken)
815770
#ifndef FEATURE_EH_FUNCLETS
816771
virtual const BYTE* GetFinallyReturnAddr(PREGDISPLAY pReg)
817772
{
773+
// Interpreter-TODO: Implement this if needed
818774
_ASSERTE(FALSE);
819775
return NULL;
820776
}
@@ -823,6 +779,7 @@ virtual BOOL LeaveFinally(GCInfoToken gcInfoToken,
823779
unsigned offset,
824780
PCONTEXT pCtx)
825781
{
782+
// Interpreter-TODO: Implement this if needed
826783
_ASSERTE(FALSE);
827784
return FALSE;
828785
}
@@ -831,15 +788,13 @@ virtual void LeaveCatch(GCInfoToken gcInfoToken,
831788
unsigned offset,
832789
PCONTEXT pCtx)
833790
{
791+
// Interpreter-TODO: Implement this if needed
834792
_ASSERTE(FALSE);
835793
}
836794
#endif // FEATURE_EH_FUNCLETS
837795

838796
#ifdef FEATURE_REMAP_FUNCTION
839-
/*
840-
Last chance for the runtime support to do fixups in the context
841-
before execution continues inside an EnC updated function.
842-
*/
797+
843798
virtual
844799
HRESULT FixContextForEnC(PCONTEXT pCtx,
845800
EECodeInfo * pOldCodeInfo,
@@ -849,6 +804,7 @@ HRESULT FixContextForEnC(PCONTEXT pCtx,
849804
const ICorDebugInfo::NativeVarInfo * newMethodVars,
850805
SIZE_T newMethodVarsCount)
851806
{
807+
// Interpreter-TODO: Implement this
852808
_ASSERTE(FALSE);
853809
return E_NOTIMPL;
854810
}

src/coreclr/vm/codeman.cpp

+9-75
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void UnwindInfoTable::AddToUnwindInfoTable(UnwindInfoTable** unwindInfoPtr, PT_R
422422
{
423423
// This cast is justified because only EEJitManager's have the code type above.
424424
EEJitManager* pJitMgr = (EEJitManager*)(pRS->_pjit);
425-
CodeHeader * pHeader = dac_cast<PTR_CodeHeader>(pJitMgr->GetCodeHeaderFromStartAddress(entryPoint));
425+
CodeHeader * pHeader = pJitMgr->GetCodeHeaderFromStartAddress(entryPoint);
426426
for(ULONG i = 0; i < pHeader->GetNumberOfUnwindInfos(); i++)
427427
RemoveFromUnwindInfoTable(&pRS->_pUnwindInfoTable, pRS->_range.RangeStart(), pRS->_range.RangeStart() + pHeader->GetUnwindInfo(i)->BeginAddress);
428428
}
@@ -461,7 +461,7 @@ void UnwindInfoTable::AddToUnwindInfoTable(UnwindInfoTable** unwindInfoPtr, PT_R
461461
{
462462
// This cast is justified because only EEJitManager's have the code type above.
463463
EEJitManager* pJitMgr = (EEJitManager*)(pRS->_pjit);
464-
CodeHeader * pHeader = dac_cast<PTR_CodeHeader>(pJitMgr->GetCodeHeaderFromStartAddress(methodEntry));
464+
CodeHeader * pHeader = pJitMgr->GetCodeHeaderFromStartAddress(methodEntry);
465465
int unwindInfoCount = pHeader->GetNumberOfUnwindInfos();
466466
for(int i = 0; i < unwindInfoCount; i++)
467467
AddToUnwindInfoTable(&pRS->_pUnwindInfoTable, pHeader->GetUnwindInfo(i), pRS->_range.RangeStart(), pRS->_range.RangeEndOpen());
@@ -519,8 +519,7 @@ void UnwindInfoTable::AddToUnwindInfoTable(UnwindInfoTable** unwindInfoPtr, PT_R
519519
Setters of EECodeGenManager::m_CodeHeapCritSec
520520
-----------------------------------------------
521521
allocCode
522-
allocGCInfo
523-
allocEHInfo
522+
allocFromJitMetaHeap
524523
allocJumpStubBlock
525524
ResolveEHClause
526525
RemoveJitData
@@ -2916,7 +2915,6 @@ void EECodeGenManager::allocCode(MethodDesc* pMD, size_t blockSize, size_t reser
29162915
#endif
29172916
_ASSERTE(reserveForJumpStubs == 0);
29182917
requestInfo.SetInterpreted();
2919-
requestInfo.SetDynamicDomain();
29202918
realHeaderSize = sizeof(InterpreterRealCodeHeader);
29212919
}
29222920
else
@@ -3198,33 +3196,6 @@ LoaderHeap *EECodeGenManager::GetJitMetaHeap(MethodDesc *pMD)
31983196
return pAllocator->GetLowFrequencyHeap();
31993197
}
32003198

3201-
void* EECodeGenManager::allocEHInfoRaw(MethodDesc* pMD, DWORD blockSize, size_t * pAllocationSize)
3202-
{
3203-
CONTRACTL {
3204-
THROWS;
3205-
GC_NOTRIGGER;
3206-
} CONTRACTL_END;
3207-
3208-
void * mem = NULL;
3209-
3210-
// sadly for light code gen I need the check in here. We should change GetJitMetaHeap
3211-
if (pMD->IsLCGMethod())
3212-
{
3213-
CrstHolder ch(&m_CodeHeapCritSec);
3214-
mem = (void*)pMD->AsDynamicMethodDesc()->GetResolver()->GetJitMetaHeap()->New(blockSize);
3215-
}
3216-
else
3217-
{
3218-
mem = (void*)GetJitMetaHeap(pMD)->AllocMem(S_SIZE_T(blockSize));
3219-
}
3220-
_ASSERTE(mem); // AllocMem throws if there's not enough memory
3221-
3222-
* pAllocationSize = blockSize; // Store the allocation size so we can backout later.
3223-
3224-
return(mem);
3225-
}
3226-
3227-
32283199
JumpStubBlockHeader * EEJitManager::allocJumpStubBlock(MethodDesc* pMD, DWORD numJumps,
32293200
BYTE * loAddr, BYTE * hiAddr,
32303201
LoaderAllocator *pLoaderAllocator,
@@ -3326,53 +3297,27 @@ void * EEJitManager::allocCodeFragmentBlock(size_t blockSize, unsigned alignment
33263297
RETURN((void *)mem);
33273298
}
33283299

3329-
template<typename TCodeHeader>
3330-
BYTE* EECodeGenManager::allocGCInfo(TCodeHeader* pCodeHeader, DWORD blockSize, size_t * pAllocationSize)
3300+
BYTE* EECodeGenManager::allocFromJitMetaHeap(MethodDesc* pMD, DWORD blockSize, size_t * pAllocationSize)
33313301
{
33323302
CONTRACTL {
33333303
THROWS;
33343304
GC_NOTRIGGER;
33353305
} CONTRACTL_END;
33363306

3337-
MethodDesc* pMD = pCodeHeader->GetMethodDesc();
3338-
// sadly for light code gen I need the check in here. We should change GetJitMetaHeap
3307+
BYTE *pMem = NULL;
33393308
if (pMD->IsLCGMethod())
33403309
{
33413310
CrstHolder ch(&m_CodeHeapCritSec);
3342-
pCodeHeader->SetGCInfo((BYTE*)(void*)pMD->AsDynamicMethodDesc()->GetResolver()->GetJitMetaHeap()->New(blockSize));
3311+
pMem = (BYTE*)(void*)pMD->AsDynamicMethodDesc()->GetResolver()->GetJitMetaHeap()->New(blockSize);
33433312
}
33443313
else
33453314
{
3346-
pCodeHeader->SetGCInfo((BYTE*) (void*)GetJitMetaHeap(pMD)->AllocMem(S_SIZE_T(blockSize)));
3315+
pMem = (BYTE*) (void*)GetJitMetaHeap(pMD)->AllocMem(S_SIZE_T(blockSize));
33473316
}
3348-
_ASSERTE(pCodeHeader->GetGCInfo()); // AllocMem throws if there's not enough memory
3349-
3350-
* pAllocationSize = blockSize; // Store the allocation size so we can backout later.
3351-
3352-
return(pCodeHeader->GetGCInfo());
3353-
}
3354-
3355-
template<typename TCodeHeader>
3356-
EE_ILEXCEPTION* EECodeGenManager::allocEHInfo(TCodeHeader* pCodeHeader, unsigned numClauses, size_t * pAllocationSize)
3357-
{
3358-
CONTRACTL {
3359-
THROWS;
3360-
GC_NOTRIGGER;
3361-
} CONTRACTL_END;
3362-
3363-
// Note - pCodeHeader->phdrJitEHInfo - sizeof(size_t) contains the number of EH clauses
3364-
3365-
DWORD temp = EE_ILEXCEPTION::Size(numClauses);
3366-
DWORD blockSize = 0;
3367-
if (!ClrSafeInt<DWORD>::addition(temp, sizeof(size_t), blockSize))
3368-
COMPlusThrowOM();
33693317

3370-
BYTE *EHInfo = (BYTE*)allocEHInfoRaw(pCodeHeader->GetMethodDesc(), blockSize, pAllocationSize);
3318+
*pAllocationSize = blockSize; // Store the allocation size so we can backout later.
33713319

3372-
pCodeHeader->SetEHInfo((EE_ILEXCEPTION*) (EHInfo + sizeof(size_t)));
3373-
pCodeHeader->GetEHInfo()->Init(numClauses);
3374-
*((size_t *)EHInfo) = numClauses;
3375-
return(pCodeHeader->GetEHInfo());
3320+
return pMem;
33763321
}
33773322

33783323
template<typename TCodeHeader>
@@ -3469,21 +3414,10 @@ void EECodeGenManager::RemoveJitData(TCodeHeader * pCHdr, size_t GCinfo_len, siz
34693414
// being in the header file. The bodies call methods of multiple data types that cannot be reasonably defined
34703415
// before the codeman.h is included.
34713416

3472-
template
3473-
BYTE* EECodeGenManager::allocGCInfo<CodeHeader>(CodeHeader* pCodeHeader, DWORD blockSize, size_t * pAllocationSize);
3474-
3475-
template
3476-
EE_ILEXCEPTION* EECodeGenManager::allocEHInfo<CodeHeader>(CodeHeader* pCodeHeader, unsigned numClauses, size_t * pAllocationSize);
3477-
34783417
template
34793418
void EECodeGenManager::RemoveJitData<CodeHeader>(CodeHeader * pCHdr, size_t GCinfo_len, size_t EHinfo_len);
34803419

34813420
#ifdef FEATURE_INTERPRETER
3482-
template
3483-
BYTE* EECodeGenManager::allocGCInfo<InterpreterCodeHeader>(InterpreterCodeHeader* pCodeHeader, DWORD blockSize, size_t * pAllocationSize);
3484-
3485-
template
3486-
EE_ILEXCEPTION* EECodeGenManager::allocEHInfo<InterpreterCodeHeader>(InterpreterCodeHeader* pCodeHeader, unsigned numClauses, size_t * pAllocationSize);
34873421

34883422
template
34893423
void EECodeGenManager::RemoveJitData<InterpreterCodeHeader>(InterpreterCodeHeader * pCHdr, size_t GCinfo_len, size_t EHinfo_len);

0 commit comments

Comments
 (0)