Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove DelegateInvokeStubManager #88683

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/coreclr/inc/dacvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ DEFINE_DACVAR(PTR_StubLinkStubManager, StubLinkStubManager__g_pManager, StubLink
DEFINE_DACVAR(PTR_ThunkHeapStubManager, ThunkHeapStubManager__g_pManager, ThunkHeapStubManager::g_pManager)
DEFINE_DACVAR(PTR_JumpStubStubManager, JumpStubStubManager__g_pManager, JumpStubStubManager::g_pManager)
DEFINE_DACVAR(PTR_RangeSectionStubManager, RangeSectionStubManager__g_pManager, RangeSectionStubManager::g_pManager)
DEFINE_DACVAR(PTR_DelegateInvokeStubManager, DelegateInvokeStubManager__g_pManager, DelegateInvokeStubManager::g_pManager)
DEFINE_DACVAR(PTR_VirtualCallStubManagerManager, VirtualCallStubManagerManager__g_pManager, VirtualCallStubManagerManager::g_pManager)
DEFINE_DACVAR(PTR_CallCountingStubManager, CallCountingStubManager__g_pManager, CallCountingStubManager::g_pManager)

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/inc/vptr_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ VPTR_CLASS(JumpStubStubManager)
VPTR_CLASS(RangeSectionStubManager)
VPTR_CLASS(ILStubManager)
VPTR_CLASS(InteropDispatchStubManager)
VPTR_CLASS(DelegateInvokeStubManager)
#if defined(TARGET_X86) && !defined(UNIX_X86_ABI)
VPTR_CLASS(TailCallStubManager)
#endif
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,6 @@ void SystemDomain::Attach()

// Initialize stub managers
PrecodeStubManager::Init();
DelegateInvokeStubManager::Init();
JumpStubStubManager::Init();
RangeSectionStubManager::Init();
ILStubManager::Init();
Expand Down
5 changes: 3 additions & 2 deletions src/coreclr/vm/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ void GenerateArrayOpScript(ArrayMethodDesc *pMD, ArrayOpScript *paos)
//---------------------------------------------------------
class ArrayStubCache : public StubCacheBase
{
virtual void CompileStub(const BYTE *pRawStub,
virtual DWORD CompileStub(const BYTE *pRawStub,
StubLinker *psl);
virtual UINT Length(const BYTE *pRawStub);

Expand Down Expand Up @@ -1169,12 +1169,13 @@ Stub *GenerateArrayOpStub(ArrayMethodDesc* pMD)
return pArrayOpStub;
}

void ArrayStubCache::CompileStub(const BYTE *pRawStub,
DWORD ArrayStubCache::CompileStub(const BYTE *pRawStub,
StubLinker *psl)
{
STANDARD_VM_CONTRACT;

((CPUSTUBLINKER*)psl)->EmitArrayOpStub((ArrayOpScript*)pRawStub);
return NEWSTUB_FL_NONE;
}

UINT ArrayStubCache::Length(const BYTE *pRawStub)
Expand Down
8 changes: 6 additions & 2 deletions src/coreclr/vm/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,16 @@ void EEClass::Destruct(MethodTable * pOwningMT)

if (pDelegateEEClass->m_pStaticCallStub)
{
// Collect data to remove stub entry from StubManager if
// stub is deleted.
BYTE* entry = (BYTE*)pDelegateEEClass->m_pStaticCallStub->GetEntryPoint();
UINT length = pDelegateEEClass->m_pStaticCallStub->GetNumCodeBytes();

ExecutableWriterHolder<Stub> stubWriterHolder(pDelegateEEClass->m_pStaticCallStub, sizeof(Stub));
BOOL fStubDeleted = stubWriterHolder.GetRW()->DecRef();

if (fStubDeleted)
{
DelegateInvokeStubManager::g_pManager->RemoveStub(pDelegateEEClass->m_pStaticCallStub);
StubLinkStubManager::g_pManager->RemoveStubRange(entry, length);
}
}
if (pDelegateEEClass->m_pInstRetBuffCallStub)
Expand Down
17 changes: 2 additions & 15 deletions src/coreclr/vm/comdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class COMDelegate
// friend VOID CPUSTUBLINKER::EmitMulticastInvoke(...);
// friend VOID CPUSTUBLINKER::EmitShuffleThunk(...);
friend class CPUSTUBLINKER;
friend class DelegateInvokeStubManager;
friend BOOL MulticastFrame::TraceFrame(Thread *thread, BOOL fromPatch,
TraceDestination *trace, REGDISPLAY *regs);

Expand Down Expand Up @@ -213,12 +212,13 @@ class ShuffleThunkCache : public StubCacheBase
// Compile a static delegate shufflethunk. Always returns
// STANDALONE since we don't interpret these things.
//---------------------------------------------------------
virtual void CompileStub(const BYTE *pRawStub,
virtual DWORD CompileStub(const BYTE *pRawStub,
StubLinker *pstublinker)
{
STANDARD_VM_CONTRACT;

((CPUSTUBLINKER*)pstublinker)->EmitShuffleThunk((ShuffleEntry*)pRawStub);
return NEWSTUB_FL_THUNK;
}

//---------------------------------------------------------
Expand All @@ -234,19 +234,6 @@ class ShuffleThunkCache : public StubCacheBase
}
return sizeof(ShuffleEntry) * (UINT)(1 + (pse - (ShuffleEntry*)pRawStub));
}

virtual void AddStub(const BYTE* pRawStub, Stub* pNewStub)
{
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;

DelegateInvokeStubManager::g_pManager->AddStub(pNewStub);
}
};

#endif // _COMDELEGATE_H_
2 changes: 1 addition & 1 deletion src/coreclr/vm/frames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ BOOL MulticastFrame::TraceFrame(Thread *thread, BOOL fromPatch,
((ArrayBase *)pbDelInvocationList)->GetComponentSize()*delegateCount);

_ASSERTE(pbDel);
return DelegateInvokeStubManager::TraceDelegateObject(pbDel, trace);
return StubLinkStubManager::TraceDelegateObject(pbDel, trace);
}
#endif // !DACCESS_COMPILE
}
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/stubcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ Stub *StubCacheBase::Canonicalize(const BYTE * pRawStub)
// Couldn't find it, let's try to compile it.
CPUSTUBLINKER sl;
CPUSTUBLINKER *psl = &sl;
CompileStub(pRawStub, psl);
DWORD linkFlags = CompileStub(pRawStub, psl);

// Append the raw stub to the native stub
// and link up the stub.
CodeLabel *plabel = psl->EmitNewCodeLabel();
psl->EmitBytes(pRawStub, Length(pRawStub));
StubHolder<Stub> pstub;
pstub = psl->Link(m_heap);
pstub = psl->Link(m_heap, linkFlags);
UINT32 offset = psl->GetLabelOffset(plabel);

if (offset > 0xffff)
Expand Down
8 changes: 2 additions & 6 deletions src/coreclr/vm/stubcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,9 @@ class StubCacheBase : private CClosedHashBase
// This method should compile into the provided stublinker (but
// not call the Link method.)
//
// It should return the chosen compilation mode.
//
// If the method fails for some reason, it should return
// INTERPRETED so that the EE can fall back on the already
// created ML code.
// It can return flags that will be passed to StubLinker::Link().
//---------------------------------------------------------
virtual void CompileStub(const BYTE *pRawStub,
virtual DWORD CompileStub(const BYTE *pRawStub,
StubLinker *psl) = 0;

//---------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/stublink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2231,6 +2231,8 @@ void Stub::SetupStub(int numCodeBytes, DWORD flags
m_numCodeBytesAndFlags |= EXTERNAL_ENTRY_BIT;
if ((flags & NEWSTUB_FL_INSTANTIATING_METHOD) != 0)
m_numCodeBytesAndFlags |= INSTANTIATING_STUB_BIT;
if ((flags & NEWSTUB_FL_THUNK) != 0)
m_numCodeBytesAndFlags |= THUNK_BIT;
}

#ifdef STUBLINKER_GENERATES_UNWIND_INFO
Expand Down
13 changes: 12 additions & 1 deletion src/coreclr/vm/stublink.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ enum NewStubFlags
NEWSTUB_FL_INSTANTIATING_METHOD = 0x00000001,
NEWSTUB_FL_MULTICAST = 0x00000002,
NEWSTUB_FL_EXTERNAL = 0x00000004,
NEWSTUB_FL_LOADERHEAP = 0x00000008
NEWSTUB_FL_LOADERHEAP = 0x00000008,
NEWSTUB_FL_THUNK = 0x00000010
};


Expand All @@ -464,6 +465,7 @@ class Stub
LOADER_HEAP_BIT = 0x20000000,
INSTANTIATING_STUB_BIT = 0x10000000,
UNWIND_INFO_BIT = 0x08000000,
THUNK_BIT = 0x04000000,

CODEBYTES_MASK = UNWIND_INFO_BIT - 1,
AaronRobinsonMSFT marked this conversation as resolved.
Show resolved Hide resolved
MAX_CODEBYTES = CODEBYTES_MASK + 1,
Expand Down Expand Up @@ -513,6 +515,15 @@ class Stub
return (m_numCodeBytesAndFlags & INSTANTIATING_STUB_BIT) != 0;
}

//-------------------------------------------------------------------
// Used by the debugger to help step through stubs
//-------------------------------------------------------------------
BOOL IsManagedThunk()
{
LIMITED_METHOD_CONTRACT;
return (m_numCodeBytesAndFlags & THUNK_BIT) != 0;
}

//-------------------------------------------------------------------
// For stubs which execute user code, a patch offset needs to be set
// to tell the debugger how far into the stub code the debugger has
Expand Down
Loading