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 tryResolveToken
  • Loading branch information
BruceForstall committed Jun 16, 2023
commit 1c198e5d0fb061d773c7b7c202af4ed81aef3f31
6 changes: 0 additions & 6 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2214,12 +2214,6 @@ class ICorStaticInfo
// failures during token resolution.
virtual void resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken) = 0;

// Attempt to resolve a metadata token into a runtime method handle. Returns true
// if resolution succeeded and false otherwise (e.g. if it encounters invalid metadata
// during token reoslution). This method should be used instead of `resolveToken` in
// situations that need to be resilient to invalid metadata.
virtual bool tryResolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken) = 0;

// Signature information about the call sig
virtual void findSig (
CORINFO_MODULE_HANDLE module, /* IN */
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ PatchpointInfo* getOSRInfo(
void resolveToken(
CORINFO_RESOLVED_TOKEN* pResolvedToken) override;

bool tryResolveToken(
CORINFO_RESOLVED_TOKEN* pResolvedToken) override;

void findSig(
CORINFO_MODULE_HANDLE module,
unsigned sigTOK,
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 @@ -33,7 +33,6 @@ DEF_CLR_API(getGSCookie)
DEF_CLR_API(setPatchpointInfo)
DEF_CLR_API(getOSRInfo)
DEF_CLR_API(resolveToken)
DEF_CLR_API(tryResolveToken)
DEF_CLR_API(findSig)
DEF_CLR_API(findCallSiteSig)
DEF_CLR_API(getTokenTypeAsHandle)
Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,6 @@ void WrapICorJitInfo::resolveToken(
API_LEAVE(resolveToken);
}

bool WrapICorJitInfo::tryResolveToken(
CORINFO_RESOLVED_TOKEN* pResolvedToken)
{
API_ENTER(tryResolveToken);
bool temp = wrapHnd->tryResolveToken(pResolvedToken);
API_LEAVE(tryResolveToken);
return temp;
}

void WrapICorJitInfo::findSig(
CORINFO_MODULE_HANDLE module,
unsigned sigTOK,
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8072,9 +8072,7 @@ class Compiler

WORD eeGetRelocTypeHint(void* target);

// ICorStaticInfo wrapper functions

bool eeTryResolveToken(CORINFO_RESOLVED_TOKEN* resolvedToken);
// ICorStaticInfo wrapper functions

#if defined(UNIX_AMD64_ABI)
#ifdef DEBUG
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/jit/ee_il_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,11 +1361,6 @@ void Compiler::eeGetSystemVAmd64PassStructInRegisterDescriptor(

#endif // UNIX_AMD64_ABI

bool Compiler::eeTryResolveToken(CORINFO_RESOLVED_TOKEN* resolvedToken)
{
return info.compCompHnd->tryResolveToken(resolvedToken);
}

bool Compiler::eeRunWithErrorTrapImp(void (*function)(void*), void* param)
{
return info.compCompHnd->runWithErrorTrap(function, param);
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1811,12 +1811,6 @@ private void resolveToken(ref CORINFO_RESOLVED_TOKEN pResolvedToken)
pResolvedToken.cbMethodSpec = 0;
}

private bool tryResolveToken(ref CORINFO_RESOLVED_TOKEN pResolvedToken)
{
resolveToken(ref pResolvedToken);
return true;
}

private void findSig(CORINFO_MODULE_STRUCT_* module, uint sigTOK, CORINFO_CONTEXT_STRUCT* context, CORINFO_SIG_INFO* sig)
{
var methodIL = HandleToObject(module);
Expand Down
302 changes: 143 additions & 159 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 @@ -188,7 +188,6 @@ FUNCTIONS
void setPatchpointInfo(PatchpointInfo* patchpointInfo);
PatchpointInfo* getOSRInfo(unsigned * ilOffset);
void resolveToken(CORINFO_RESOLVED_TOKEN * pResolvedToken);
bool tryResolveToken(CORINFO_RESOLVED_TOKEN * pResolvedToken);
void findSig( CORINFO_MODULE_HANDLE module, unsigned sigTOK, CORINFO_CONTEXT_HANDLE context, CORINFO_SIG_INFO *sig );
void findCallSiteSig( CORINFO_MODULE_HANDLE module,unsigned methTOK, CORINFO_CONTEXT_HANDLE context, CORINFO_SIG_INFO *sig)
CORINFO_CLASS_HANDLE getTokenTypeAsHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken)
Expand Down
10 changes: 0 additions & 10 deletions src/coreclr/tools/aot/jitinterface/jitinterface_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ struct JitInterfaceCallbacks
void (* setPatchpointInfo)(void * thisHandle, CorInfoExceptionClass** ppException, PatchpointInfo* patchpointInfo);
PatchpointInfo* (* getOSRInfo)(void * thisHandle, CorInfoExceptionClass** ppException, unsigned* ilOffset);
void (* resolveToken)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken);
bool (* tryResolveToken)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken);
void (* findSig)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_MODULE_HANDLE module, unsigned sigTOK, CORINFO_CONTEXT_HANDLE context, CORINFO_SIG_INFO* sig);
void (* findCallSiteSig)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_MODULE_HANDLE module, unsigned methTOK, CORINFO_CONTEXT_HANDLE context, CORINFO_SIG_INFO* sig);
CORINFO_CLASS_HANDLE (* getTokenTypeAsHandle)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken);
Expand Down Expand Up @@ -475,15 +474,6 @@ class JitInterfaceWrapper : public ICorJitInfo
if (pException != nullptr) throw pException;
}

virtual bool tryResolveToken(
CORINFO_RESOLVED_TOKEN* pResolvedToken)
{
CorInfoExceptionClass* pException = nullptr;
bool temp = _callbacks->tryResolveToken(_thisHandle, &pException, pResolvedToken);
if (pException != nullptr) throw pException;
return temp;
}

virtual void findSig(
CORINFO_MODULE_HANDLE module,
unsigned sigTOK,
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/tools/superpmi/superpmi-shared/agnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,12 +602,6 @@ struct ResolveTokenValue
DWORD exceptionCode;
};

struct TryResolveTokenValue
{
Agnostic_CORINFO_RESOLVED_TOKENout tokenOut;
DWORD success;
};

struct GetTokenTypeAsHandleValue
{
DWORDLONG hMethod;
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 @@ -160,7 +160,6 @@ LWM(IsEnum, DWORDLONG, DLD)
LWM(PInvokeMarshalingRequired, MethodOrSigInfoValue, DWORD)
LWM(ResolveToken, Agnostic_CORINFO_RESOLVED_TOKENin, ResolveTokenValue)
LWM(ResolveVirtualMethod, Agnostic_ResolveVirtualMethodKey, Agnostic_ResolveVirtualMethodResult)
LWM(TryResolveToken, Agnostic_CORINFO_RESOLVED_TOKENin, TryResolveTokenValue)
LWM(SatisfiesMethodConstraints, DLDL, DWORD)
LWM(GetUnmanagedCallConv, MethodOrSigInfoValue, DD)
LWM(DoesFieldBelongToClass, DLDL, DWORD)
Expand Down
36 changes: 0 additions & 36 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,42 +1425,6 @@ void MethodContext::repResolveToken(CORINFO_RESOLVED_TOKEN* pResolvedToken, DWOR
*exceptionCode = (DWORD)value.exceptionCode;
}

void MethodContext::recTryResolveToken(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool success)
{
if (TryResolveToken == nullptr)
TryResolveToken = new LightWeightMap<Agnostic_CORINFO_RESOLVED_TOKENin, TryResolveTokenValue>();

Agnostic_CORINFO_RESOLVED_TOKENin key;
ZeroMemory(&key, sizeof(key)); // Zero key including any struct padding
key = SpmiRecordsHelper::CreateAgnostic_CORINFO_RESOLVED_TOKENin(pResolvedToken);

TryResolveTokenValue value;

value.tokenOut = SpmiRecordsHelper::StoreAgnostic_CORINFO_RESOLVED_TOKENout(pResolvedToken, ResolveToken);
value.success = success ? 0 : 1;

TryResolveToken->Add(key, value);
DEBUG_REC(dmpTryResolveToken(key, value));
}
void MethodContext::dmpTryResolveToken(const Agnostic_CORINFO_RESOLVED_TOKENin& key, const TryResolveTokenValue& value)
{
printf("TryResolveToken key: %s\n", SpmiDumpHelper::DumpAgnostic_CORINFO_RESOLVED_TOKENin(key).c_str());
printf(", value: %s failed-%u", SpmiDumpHelper::DumpAgnostic_CORINFO_RESOLVED_TOKENout(value.tokenOut).c_str(),
value.success);
}
bool MethodContext::repTryResolveToken(CORINFO_RESOLVED_TOKEN* pResolvedToken)
{
Agnostic_CORINFO_RESOLVED_TOKENin key;
ZeroMemory(&key, sizeof(key)); // Zero key including any struct padding
key = SpmiRecordsHelper::CreateAgnostic_CORINFO_RESOLVED_TOKENin(pResolvedToken);

TryResolveTokenValue value = LookupByKeyOrMiss(TryResolveToken, key, ": token %x", pResolvedToken->token);
DEBUG_REP(dmpTryResolveToken(key, value));

SpmiRecordsHelper::Restore_CORINFO_RESOLVED_TOKENout(pResolvedToken, value.tokenOut, ResolveToken);
return (DWORD)value.success == 0; // recTryResolveToken encodes success as 0
}

void MethodContext::recGetCallInfo(CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken,
CORINFO_METHOD_HANDLE callerHandle,
Expand Down
6 changes: 1 addition & 5 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,6 @@ class MethodContext
void dmpResolveToken(const Agnostic_CORINFO_RESOLVED_TOKENin& key, const ResolveTokenValue& value);
void repResolveToken(CORINFO_RESOLVED_TOKEN* pResolvedToken, DWORD* exceptionCode);

void recTryResolveToken(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool success);
void dmpTryResolveToken(const Agnostic_CORINFO_RESOLVED_TOKENin& key, const TryResolveTokenValue& value);
bool repTryResolveToken(CORINFO_RESOLVED_TOKEN* pResolvedToken);

void recGetCallInfo(CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken,
CORINFO_METHOD_HANDLE callerHandle,
Expand Down Expand Up @@ -1086,7 +1082,7 @@ enum mcPackets
Packet_IsDelegateCreationAllowed = 155,
Packet_GetSystemVAmd64PassStructInRegisterDescriptor = 156,
Packet_GetReadyToRunDelegateCtorHelper = 157,
Packet_TryResolveToken = 158,
//Packet_TryResolveToken = 158,
Packet_GetHFAType = 159,
Packet_ResolveVirtualMethod = 160,
Packet_GetMethodNameFromMetadata = 161,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,6 @@ void interceptor_ICJI::resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN* pResol
});
}

bool interceptor_ICJI::tryResolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN* pResolvedToken)
{
mc->cr->AddCall("tryResolveToken");
bool success = original_ICorJitInfo->tryResolveToken(pResolvedToken);
mc->recResolveToken(pResolvedToken, success);
return success;
}

// Signature information about the call sig
void interceptor_ICJI::findSig(CORINFO_MODULE_HANDLE module, /* IN */
unsigned sigTOK, /* IN */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,6 @@ void interceptor_ICJI::resolveToken(
original_ICorJitInfo->resolveToken(pResolvedToken);
}

bool interceptor_ICJI::tryResolveToken(
CORINFO_RESOLVED_TOKEN* pResolvedToken)
{
mcs->AddCall("tryResolveToken");
return original_ICorJitInfo->tryResolveToken(pResolvedToken);
}

void interceptor_ICJI::findSig(
CORINFO_MODULE_HANDLE module,
unsigned sigTOK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,6 @@ void interceptor_ICJI::resolveToken(
original_ICorJitInfo->resolveToken(pResolvedToken);
}

bool interceptor_ICJI::tryResolveToken(
CORINFO_RESOLVED_TOKEN* pResolvedToken)
{
return original_ICorJitInfo->tryResolveToken(pResolvedToken);
}

void interceptor_ICJI::findSig(
CORINFO_MODULE_HANDLE module,
unsigned sigTOK,
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,6 @@ void MyICJI::resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN* pResolvedToken)
ThrowException(exceptionCode);
}

// Resolve metadata token into runtime method handles.
bool MyICJI::tryResolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN* pResolvedToken)
{
jitInstance->mc->cr->AddCall("tryResolveToken");
return jitInstance->mc->repTryResolveToken(pResolvedToken);
}

// Signature information about the call sig
void MyICJI::findSig(CORINFO_MODULE_HANDLE module, /* IN */
unsigned sigTOK, /* IN */
Expand Down
111 changes: 0 additions & 111 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,117 +1198,6 @@ void CEEInfo::resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken
EE_TO_JIT_TRANSITION();
}

/*********************************************************************/
struct TryResolveTokenFilterParam
{
CEEInfo* m_this;
CORINFO_RESOLVED_TOKEN* m_resolvedToken;
EXCEPTION_POINTERS m_exceptionPointers;
bool m_success;
};

bool isValidTokenForTryResolveToken(CEEInfo* info, CORINFO_RESOLVED_TOKEN* resolvedToken)
{
CONTRACTL {
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
} CONTRACTL_END;

if (!info->isValidToken(resolvedToken->tokenScope, resolvedToken->token))
{
return false;
}

CorInfoTokenKind tokenType = resolvedToken->tokenType;
switch (TypeFromToken(resolvedToken->token))
{
case mdtModuleRef:
case mdtTypeDef:
case mdtTypeRef:
case mdtTypeSpec:
if ((tokenType & CORINFO_TOKENKIND_Class) == 0)
return false;
break;

case mdtMethodDef:
case mdtMethodSpec:
if ((tokenType & CORINFO_TOKENKIND_Method) == 0)
return false;
break;

case mdtFieldDef:
if ((tokenType & CORINFO_TOKENKIND_Field) == 0)
return false;
break;

case mdtMemberRef:
if ((tokenType & (CORINFO_TOKENKIND_Method | CORINFO_TOKENKIND_Field)) == 0)
return false;
break;

default:
return false;
}

return true;
}

LONG EEFilterException(struct _EXCEPTION_POINTERS* exceptionPointers, void* unused);

LONG TryResolveTokenFilter(struct _EXCEPTION_POINTERS* exceptionPointers, void* theParam)
{
CONTRACTL {
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
} CONTRACTL_END;

// Backward compatibility: Convert bad image format exceptions thrown while resolving tokens
// to simple true/false successes. This is done for backward compatibility only. Ideally,
// we would always treat bad tokens in the IL stream as fatal errors.
if (exceptionPointers->ExceptionRecord->ExceptionCode == EXCEPTION_COMPLUS)
{
auto* param = reinterpret_cast<TryResolveTokenFilterParam*>(theParam);
if (!isValidTokenForTryResolveToken(param->m_this, param->m_resolvedToken))
{
param->m_exceptionPointers = *exceptionPointers;
return EEFilterException(exceptionPointers, nullptr);
}
}

return EXCEPTION_CONTINUE_SEARCH;
}

bool CEEInfo::tryResolveToken(CORINFO_RESOLVED_TOKEN* resolvedToken)
{
// No dynamic contract here because SEH is used
STATIC_CONTRACT_THROWS;
STATIC_CONTRACT_GC_TRIGGERS;
STATIC_CONTRACT_MODE_PREEMPTIVE;

TryResolveTokenFilterParam param;
param.m_this = this;
param.m_resolvedToken = resolvedToken;
param.m_success = true;

PAL_TRY(TryResolveTokenFilterParam*, pParam, &param)
{
pParam->m_this->resolveToken(pParam->m_resolvedToken);
}
PAL_EXCEPT_FILTER(TryResolveTokenFilter)
{
if (param.m_exceptionPointers.ExceptionRecord->ExceptionCode == EXCEPTION_COMPLUS)
{
HandleException(&param.m_exceptionPointers);
}

param.m_success = false;
}
PAL_ENDTRY

return param.m_success;
}

/*********************************************************************/
// We have a few frequently used constants in CoreLib that are defined as
Expand Down