Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove isCompatibleDelegate
  • Loading branch information
BruceForstall committed Jun 15, 2023
commit d74006ae998134c95d4c2bcd781a852414370e72
11 changes: 0 additions & 11 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2178,17 +2178,6 @@ class ICorStaticInfo
CORINFO_METHOD_HANDLE method
) = 0;

// Given a delegate target class, a target method parent class, a target method,
// a delegate class, check if the method signature is compatible with the Invoke method of the delegate
// (under the typical instantiation of any free type variables in the memberref signatures).
virtual bool isCompatibleDelegate(
CORINFO_CLASS_HANDLE objCls, /* type of the delegate target, if any */
CORINFO_CLASS_HANDLE methodParentCls, /* exact parent of the target method, if any */
CORINFO_METHOD_HANDLE method, /* (representative) target method, if any */
CORINFO_CLASS_HANDLE delegateCls, /* exact type of the delegate */
bool *pfIsOpenDelegate /* is the delegate open */
) = 0;

// load and restore the method
virtual void methodMustBeLoadedBeforeCodeIsRun(
CORINFO_METHOD_HANDLE method
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ bool satisfiesMethodConstraints(
CORINFO_CLASS_HANDLE parent,
CORINFO_METHOD_HANDLE method) override;

bool isCompatibleDelegate(
CORINFO_CLASS_HANDLE objCls,
CORINFO_CLASS_HANDLE methodParentCls,
CORINFO_METHOD_HANDLE method,
CORINFO_CLASS_HANDLE delegateCls,
bool* pfIsOpenDelegate) override;

void methodMustBeLoadedBeforeCodeIsRun(
CORINFO_METHOD_HANDLE method) override;

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/ICorJitInfo_names_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ DEF_CLR_API(isIntrinsicType)
DEF_CLR_API(getUnmanagedCallConv)
DEF_CLR_API(pInvokeMarshalingRequired)
DEF_CLR_API(satisfiesMethodConstraints)
DEF_CLR_API(isCompatibleDelegate)
DEF_CLR_API(methodMustBeLoadedBeforeCodeIsRun)
DEF_CLR_API(mapMethodDeclToMethodImpl)
DEF_CLR_API(getGSCookie)
Expand Down
13 changes: 0 additions & 13 deletions src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,6 @@ bool WrapICorJitInfo::satisfiesMethodConstraints(
return temp;
}

bool WrapICorJitInfo::isCompatibleDelegate(
CORINFO_CLASS_HANDLE objCls,
CORINFO_CLASS_HANDLE methodParentCls,
CORINFO_METHOD_HANDLE method,
CORINFO_CLASS_HANDLE delegateCls,
bool* pfIsOpenDelegate)
{
API_ENTER(isCompatibleDelegate);
bool temp = wrapHnd->isCompatibleDelegate(objCls, methodParentCls, method, delegateCls, pfIsOpenDelegate);
API_LEAVE(isCompatibleDelegate);
return temp;
}

void WrapICorJitInfo::methodMustBeLoadedBeforeCodeIsRun(
CORINFO_METHOD_HANDLE method)
{
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,8 +1565,6 @@ private static CorInfoCallConvExtension ToCorInfoCallConvExtension(UnmanagedCall

private bool satisfiesMethodConstraints(CORINFO_CLASS_STRUCT_* parent, CORINFO_METHOD_STRUCT_* method)
{ throw new NotImplementedException("satisfiesMethodConstraints"); }
private bool isCompatibleDelegate(CORINFO_CLASS_STRUCT_* objCls, CORINFO_CLASS_STRUCT_* methodParentCls, CORINFO_METHOD_STRUCT_* method, CORINFO_CLASS_STRUCT_* delegateCls, ref bool pfIsOpenDelegate)
{ throw new NotImplementedException("isCompatibleDelegate"); }
private void setPatchpointInfo(PatchpointInfo* patchpointInfo)
{ throw new NotImplementedException("setPatchpointInfo"); }
private PatchpointInfo* getOSRInfo(ref uint ilOffset)
Expand Down
328 changes: 156 additions & 172 deletions src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ FUNCTIONS
CorInfoCallConvExtension getUnmanagedCallConv( CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* callSiteSig, bool* pSuppressGCTransition);
bool pInvokeMarshalingRequired( CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* callSiteSig );
bool satisfiesMethodConstraints( CORINFO_CLASS_HANDLE parent, CORINFO_METHOD_HANDLE method );
bool isCompatibleDelegate( CORINFO_CLASS_HANDLE objCls, CORINFO_CLASS_HANDLE methodParentCls, CORINFO_METHOD_HANDLE method, CORINFO_CLASS_HANDLE delegateCls, bool *pfIsOpenDelegate );
void methodMustBeLoadedBeforeCodeIsRun( CORINFO_METHOD_HANDLE method );
CORINFO_METHOD_HANDLE mapMethodDeclToMethodImpl( CORINFO_METHOD_HANDLE method );
void getGSCookie( GSCookie * pCookieVal, GSCookie ** ppCookieVal );
Expand Down
14 changes: 0 additions & 14 deletions src/coreclr/tools/aot/jitinterface/jitinterface_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct JitInterfaceCallbacks
CorInfoCallConvExtension (* getUnmanagedCallConv)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* callSiteSig, bool* pSuppressGCTransition);
bool (* pInvokeMarshalingRequired)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* callSiteSig);
bool (* satisfiesMethodConstraints)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE parent, CORINFO_METHOD_HANDLE method);
bool (* isCompatibleDelegate)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE objCls, CORINFO_CLASS_HANDLE methodParentCls, CORINFO_METHOD_HANDLE method, CORINFO_CLASS_HANDLE delegateCls, bool* pfIsOpenDelegate);
void (* methodMustBeLoadedBeforeCodeIsRun)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE method);
CORINFO_METHOD_HANDLE (* mapMethodDeclToMethodImpl)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE method);
void (* getGSCookie)(void * thisHandle, CorInfoExceptionClass** ppException, GSCookie* pCookieVal, GSCookie** ppCookieVal);
Expand Down Expand Up @@ -431,19 +430,6 @@ class JitInterfaceWrapper : public ICorJitInfo
return temp;
}

virtual bool isCompatibleDelegate(
CORINFO_CLASS_HANDLE objCls,
CORINFO_CLASS_HANDLE methodParentCls,
CORINFO_METHOD_HANDLE method,
CORINFO_CLASS_HANDLE delegateCls,
bool* pfIsOpenDelegate)
{
CorInfoExceptionClass* pException = nullptr;
bool temp = _callbacks->isCompatibleDelegate(_thisHandle, &pException, objCls, methodParentCls, method, delegateCls, pfIsOpenDelegate);
if (pException != nullptr) throw pException;
return temp;
}

virtual void methodMustBeLoadedBeforeCodeIsRun(
CORINFO_METHOD_HANDLE method)
{
Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/tools/superpmi/superpmi-shared/agnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,6 @@ struct Agnostic_GetStaticBaseAddress
DWORD result;
};

struct Agnostic_IsCompatibleDelegate
{
DWORDLONG objCls;
DWORDLONG methodParentCls;
DWORDLONG method;
DWORDLONG delegateCls;
};

struct Agnostic_PgoInstrumentationSchema
{
DWORDLONG Offset; // size_t
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ LWM(GetObjectType, DWORDLONG, DWORDLONG)
LWM(GetVarArgsHandle, GetVarArgsHandleValue, DLDL)
LWM(GetVars, DWORDLONG, Agnostic_GetVars)
LWM(InitClass, Agnostic_InitClass, DWORD)
LWM(IsCompatibleDelegate, Agnostic_IsCompatibleDelegate, DD)
LWM(IsDelegateCreationAllowed, DLDL, DWORD)
LWM(IsFieldStatic, DWORDLONG, DWORD)
LWM(GetArrayOrStringLength, DWORDLONG, DWORD)
Expand Down
51 changes: 0 additions & 51 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5248,57 +5248,6 @@ bool MethodContext::repCanTailCall(CORINFO_METHOD_HANDLE callerHnd,
return value != 0;
}

void MethodContext::recIsCompatibleDelegate(CORINFO_CLASS_HANDLE objCls,
CORINFO_CLASS_HANDLE methodParentCls,
CORINFO_METHOD_HANDLE method,
CORINFO_CLASS_HANDLE delegateCls,
bool* pfIsOpenDelegate,
bool result)
{
if (IsCompatibleDelegate == nullptr)
IsCompatibleDelegate = new LightWeightMap<Agnostic_IsCompatibleDelegate, DD>();

Agnostic_IsCompatibleDelegate key;
ZeroMemory(&key, sizeof(key)); // Zero key including any struct padding
key.objCls = CastHandle(objCls);
key.methodParentCls = CastHandle(methodParentCls);
key.method = CastHandle(method);
key.delegateCls = CastHandle(delegateCls);

DD value;
value.A = (DWORD)*pfIsOpenDelegate;
value.B = (DWORD)result;

IsCompatibleDelegate->Add(key, value);
DEBUG_REC(dmpIsCompatibleDelegate(key, value));
}
void MethodContext::dmpIsCompatibleDelegate(const Agnostic_IsCompatibleDelegate& key, DD value)
{
printf("IsCompatibleDelegate key objCls-%016" PRIX64 " methodParentCls-%016" PRIX64 " method-%016" PRIX64 " delegateCls-%016" PRIX64 ", value "
"pfIsOpenDelegate-%08X result-%08X",
key.objCls, key.methodParentCls, key.method, key.delegateCls, value.A, value.B);
}
bool MethodContext::repIsCompatibleDelegate(CORINFO_CLASS_HANDLE objCls,
CORINFO_CLASS_HANDLE methodParentCls,
CORINFO_METHOD_HANDLE method,
CORINFO_CLASS_HANDLE delegateCls,
bool* pfIsOpenDelegate)
{
Agnostic_IsCompatibleDelegate key;
ZeroMemory(&key, sizeof(key)); // Zero key including any struct padding
key.objCls = CastHandle(objCls);
key.methodParentCls = CastHandle(methodParentCls);
key.method = CastHandle(method);
key.delegateCls = CastHandle(delegateCls);

DD value = LookupByKeyOrMissNoMessage(IsCompatibleDelegate, key);

DEBUG_REP(dmpIsCompatibleDelegate(key, value));

*pfIsOpenDelegate = value.A != 0;
return value.B != 0;
}

void MethodContext::recIsDelegateCreationAllowed(CORINFO_CLASS_HANDLE delegateHnd,
CORINFO_METHOD_HANDLE calleeHnd,
bool result)
Expand Down
15 changes: 1 addition & 14 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -675,19 +675,6 @@ class MethodContext
CORINFO_METHOD_HANDLE exactCalleeHnd,
bool fIsTailPrefix);

void recIsCompatibleDelegate(CORINFO_CLASS_HANDLE objCls,
CORINFO_CLASS_HANDLE methodParentCls,
CORINFO_METHOD_HANDLE method,
CORINFO_CLASS_HANDLE delegateCls,
bool* pfIsOpenDelegate,
bool result);
void dmpIsCompatibleDelegate(const Agnostic_IsCompatibleDelegate& key, DD value);
bool repIsCompatibleDelegate(CORINFO_CLASS_HANDLE objCls,
CORINFO_CLASS_HANDLE methodParentCls,
CORINFO_METHOD_HANDLE method,
CORINFO_CLASS_HANDLE delegateCls,
bool* pfIsOpenDelegate);

void recIsDelegateCreationAllowed(CORINFO_CLASS_HANDLE delegateHnd, CORINFO_METHOD_HANDLE calleeHnd, bool result);
void dmpIsDelegateCreationAllowed(DLDL key, DWORD value);
bool repIsDelegateCreationAllowed(CORINFO_CLASS_HANDLE delegateHnd, CORINFO_METHOD_HANDLE calleeHnd);
Expand Down Expand Up @@ -1061,7 +1048,7 @@ enum mcPackets
Packet_GetVars = 96,
Packet_InitClass = 97,
//Packet_InitConstraintsForVerification = 98,
Packet_IsCompatibleDelegate = 99,
//Packet_IsCompatibleDelegate = 99,
//Packet_IsInstantiationOfVerifiedGeneric = 100,
Packet_IsSDArray = 101,
//Packet_IsStructRequiringStackAllocRetBuf = 102,
Expand Down
18 changes: 0 additions & 18 deletions src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,24 +298,6 @@ bool interceptor_ICJI::satisfiesMethodConstraints(CORINFO_CLASS_HANDLE parent,
return temp;
}

// Given a delegate target class, a target method parent class, a target method,
// a delegate class, check if the method signature is compatible with the Invoke method of the delegate
// (under the typical instantiation of any free type variables in the memberref signatures).
bool interceptor_ICJI::isCompatibleDelegate(
CORINFO_CLASS_HANDLE objCls, /* type of the delegate target, if any */
CORINFO_CLASS_HANDLE methodParentCls, /* exact parent of the target method, if any */
CORINFO_METHOD_HANDLE method, /* (representative) target method, if any */
CORINFO_CLASS_HANDLE delegateCls, /* exact type of the delegate */
bool* pfIsOpenDelegate /* is the delegate open */
)
{
mc->cr->AddCall("isCompatibleDelegate");
bool temp =
original_ICorJitInfo->isCompatibleDelegate(objCls, methodParentCls, method, delegateCls, pfIsOpenDelegate);
mc->recIsCompatibleDelegate(objCls, methodParentCls, method, delegateCls, pfIsOpenDelegate, temp);
return temp;
}

// load and restore the method
void interceptor_ICJI::methodMustBeLoadedBeforeCodeIsRun(CORINFO_METHOD_HANDLE method)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,6 @@ bool interceptor_ICJI::satisfiesMethodConstraints(
return original_ICorJitInfo->satisfiesMethodConstraints(parent, method);
}

bool interceptor_ICJI::isCompatibleDelegate(
CORINFO_CLASS_HANDLE objCls,
CORINFO_CLASS_HANDLE methodParentCls,
CORINFO_METHOD_HANDLE method,
CORINFO_CLASS_HANDLE delegateCls,
bool* pfIsOpenDelegate)
{
mcs->AddCall("isCompatibleDelegate");
return original_ICorJitInfo->isCompatibleDelegate(objCls, methodParentCls, method, delegateCls, pfIsOpenDelegate);
}

void interceptor_ICJI::methodMustBeLoadedBeforeCodeIsRun(
CORINFO_METHOD_HANDLE method)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,6 @@ bool interceptor_ICJI::satisfiesMethodConstraints(
return original_ICorJitInfo->satisfiesMethodConstraints(parent, method);
}

bool interceptor_ICJI::isCompatibleDelegate(
CORINFO_CLASS_HANDLE objCls,
CORINFO_CLASS_HANDLE methodParentCls,
CORINFO_METHOD_HANDLE method,
CORINFO_CLASS_HANDLE delegateCls,
bool* pfIsOpenDelegate)
{
return original_ICorJitInfo->isCompatibleDelegate(objCls, methodParentCls, method, delegateCls, pfIsOpenDelegate);
}

void interceptor_ICJI::methodMustBeLoadedBeforeCodeIsRun(
CORINFO_METHOD_HANDLE method)
{
Expand Down
14 changes: 0 additions & 14 deletions src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,6 @@ bool MyICJI::satisfiesMethodConstraints(CORINFO_CLASS_HANDLE parent, // the exa
return jitInstance->mc->repSatisfiesMethodConstraints(parent, method);
}

// Given a delegate target class, a target method parent class, a target method,
// a delegate class, check if the method signature is compatible with the Invoke method of the delegate
// (under the typical instantiation of any free type variables in the memberref signatures).
bool MyICJI::isCompatibleDelegate(CORINFO_CLASS_HANDLE objCls, /* type of the delegate target, if any */
CORINFO_CLASS_HANDLE methodParentCls, /* exact parent of the target method, if any */
CORINFO_METHOD_HANDLE method, /* (representative) target method, if any */
CORINFO_CLASS_HANDLE delegateCls, /* exact type of the delegate */
bool* pfIsOpenDelegate /* is the delegate open */
)
{
jitInstance->mc->cr->AddCall("isCompatibleDelegate");
return jitInstance->mc->repIsCompatibleDelegate(objCls, methodParentCls, method, delegateCls, pfIsOpenDelegate);
}

// load and restore the method
void MyICJI::methodMustBeLoadedBeforeCodeIsRun(CORINFO_METHOD_HANDLE method)
{
Expand Down
62 changes: 0 additions & 62 deletions src/coreclr/vm/comdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3020,68 +3020,6 @@ MethodDesc* COMDelegate::GetDelegateCtor(TypeHandle delegateType, MethodDesc *pT
}


/*@GENERICSVER: new (works for generics too)
Does a static validation of parameters passed into a delegate constructor.


For "new Delegate(obj.method)" where method is statically typed as "C::m" and
the static type of obj is D (some subclass of C)...

Params:
instHnd : Static type of the instance, from which pFtn is obtained. Ignored if pFtn
is static (i.e. D)
ftnParentHnd: Parent of the MethodDesc, pFtn, used to create the delegate (i.e. type C)
pFtn : (possibly shared) MethodDesc of the function pointer used to create the delegate (i.e. C::m)
pDlgt : The delegate type (i.e. Delegate)
module: The module scoping methodMemberRef and delegateConstructorMemberRef
methodMemberRef: the MemberRef, MemberDef or MemberSpec of the target method (i.e. a mdToken for C::m)
delegateConstructorMemberRef: the MemberRef, MemberDef or MemberSpec of the delegate constructor (i.e. a mdToken for Delegate::.ctor)

Validates the following conditions:
1. If the function (pFtn) is not static, pInst should be equal to the type where
pFtn is defined or pInst should be a parent of pFtn's type.
2. The signature of the function should be compatible with the signature
of the Invoke method of the delegate type.
The signature is retrieved from module, methodMemberRef and delegateConstructorMemberRef

NB: Although some of these arguments are redundant, we pass them in to avoid looking up
information that should already be available.
Instead of comparing type handles modulo some context, the method directly compares metadata to avoid
loading classes referenced in the method signatures (hence the need for the module and member refs).
Also, because this method works directly on metadata, without allowing any additional instantiation of the
free type variables in the signature of the method or delegate constructor, this code
will *only* verify a constructor application at the typical (ie. formal) instantiation.
*/
/* static */
bool COMDelegate::ValidateCtor(TypeHandle instHnd,
TypeHandle ftnParentHnd,
MethodDesc *pFtn,
TypeHandle dlgtHnd,
bool *pfIsOpenDelegate)

{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_ANY;

PRECONDITION(CheckPointer(pFtn));
PRECONDITION(!dlgtHnd.IsNull());
PRECONDITION(!ftnParentHnd.IsNull());

INJECT_FAULT(COMPlusThrowOM()); // from MetaSig::CompareElementType
}
CONTRACTL_END;

DelegateEEClass *pdlgEEClass = (DelegateEEClass*)dlgtHnd.AsMethodTable()->GetClass();
PREFIX_ASSUME(pdlgEEClass != NULL);
MethodDesc *pDlgtInvoke = pdlgEEClass->GetInvokeMethod();
if (pDlgtInvoke == NULL)
return false;
return IsMethodDescCompatible(instHnd, ftnParentHnd, pFtn, dlgtHnd, pDlgtInvoke, DBF_RelaxedSignature, pfIsOpenDelegate);
}

BOOL COMDelegate::IsWrapperDelegate(DELEGATEREF dRef)
{
CONTRACTL
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/vm/comdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ class COMDelegate
int flags,
bool *pfIsOpenDelegate);
static MethodDesc* GetDelegateCtor(TypeHandle delegateType, MethodDesc *pTargetMethod, DelegateCtorArgs *pCtorData);
//@GENERICSVER: new (suitable for generics)
// Method to do static validation of delegate .ctor
static bool ValidateCtor(TypeHandle objHnd, TypeHandle ftnParentHnd, MethodDesc *pFtn, TypeHandle dlgtHnd, bool *pfIsOpenDelegate);

private:
static void BindToMethod(DELEGATEREF *pRefThis,
Expand Down
Loading