Skip to content
Draft
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
8 changes: 8 additions & 0 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,14 @@ void DacDbiInterfaceImpl::GetNativeCodeInfo(VMPTR_DomainAssembly vmDomai
Module * pModule = pDomainAssembly->GetAssembly()->GetModule();

MethodDesc* pMethodDesc = FindLoadedMethodRefOrDef(pModule, functionToken);
if (pMethodDesc != NULL && pMethodDesc->IsAsyncThunkMethod())
{
MethodDesc* pAsyncVariant = pMethodDesc->GetAsyncOtherVariantNoCreate();
if (pAsyncVariant != NULL)
{
pMethodDesc = pAsyncVariant;
}
}
pCodeInfo->vmNativeCodeMethodDescToken.SetHostPtr(pMethodDesc);

// if we are loading a module and trying to bind a previously set breakpoint, we may not have
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ set(VM_SOURCES_DAC_AND_WKS_COMMON
gchandleutilities.cpp
genericdict.cpp
generics.cpp
genmeth.cpp
hash.cpp
ilinstrumentation.cpp
ilstubcache.cpp
Expand Down Expand Up @@ -333,7 +334,6 @@ set(VM_SOURCES_WKS
gcenv.ee.common.cpp
gchelpers.cpp
genanalysis.cpp
genmeth.cpp
hosting.cpp
hostinformation.cpp
ilmarshalers.cpp
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/vm/generics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ ClassLoader::CreateTypeHandleForNonCanonicalGenericInstantiation(
RETURN(TypeHandle(pMT));
} // ClassLoader::CreateTypeHandleForNonCanonicalGenericInstantiation

#endif // !DACCESS_COMPILE

namespace Generics
{

Expand Down Expand Up @@ -532,6 +534,13 @@ BOOL CheckInstantiation(Instantiation inst)
return TRUE;
}

} // namespace Generics

#ifndef DACCESS_COMPILE

namespace Generics
{

// Just records the owner and links to the previous graph.
RecursionGraph::RecursionGraph(RecursionGraph *pPrev, TypeHandle thOwner)
{
Expand Down
36 changes: 32 additions & 4 deletions src/coreclr/vm/genmeth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include "instmethhash.h"
#include "typestring.h"
#include "typedesc.h"
#ifndef DACCESS_COMPILE
#include "comdelegate.h"
#endif // !DACCESS_COMPILE

// Instantiated generic methods
//
Expand Down Expand Up @@ -61,6 +63,8 @@
//


#ifndef DACCESS_COMPILE

// Helper method that creates a method-desc off a template method desc
static MethodDesc* CreateMethodDesc(LoaderAllocator *pAllocator,
Module* pLoaderModule,
Expand Down Expand Up @@ -150,6 +154,8 @@ static MethodDesc* CreateMethodDesc(LoaderAllocator *pAllocator,
return pMD;
}

#endif // !DACCESS_COMPILE

//
// The following methods map between tightly bound boxing and unboxing MethodDesc.
// We always layout boxing and unboxing MethodDescs next to each other in same
Expand All @@ -167,6 +173,7 @@ static MethodDesc * FindTightlyBoundWrappedMethodDesc(MethodDesc * pMD)
NOTHROW;
GC_NOTRIGGER;
PRECONDITION(CheckPointer(pMD));
SUPPORTS_DAC;
}
CONTRACTL_END

Expand Down Expand Up @@ -196,6 +203,7 @@ static MethodDesc * FindTightlyBoundUnboxingStub(MethodDesc * pMD)
NOTHROW;
GC_NOTRIGGER;
PRECONDITION(CheckPointer(pMD));
SUPPORTS_DAC;
}
CONTRACTL_END

Expand Down Expand Up @@ -227,7 +235,7 @@ static MethodDesc * FindTightlyBoundUnboxingStub(MethodDesc * pMD)
return pCurMD->IsUnboxingStub() ? pCurMD : NULL;
}

#ifdef _DEBUG
#if defined(_DEBUG) && !defined(DACCESS_COMPILE)
//
// Alternative brute-force implementation of FindTightlyBoundWrappedMethodDesc for debug-only check.
//
Expand Down Expand Up @@ -304,7 +312,9 @@ static MethodDesc * FindTightlyBoundUnboxingStub_DEBUG(MethodDesc * pMD)
}
return NULL;
}
#endif // _DEBUG
#endif // _DEBUG && !DACCESS_COMPILE

#ifndef DACCESS_COMPILE

/* static */
InstantiatedMethodDesc *
Expand Down Expand Up @@ -574,6 +584,8 @@ InstantiatedMethodDesc::FindOrCreateExactClassMethod(MethodTable *pExactMT,
return pInstMD;
}

#endif // !DACCESS_COMPILE

// N.B. it is not guarantee that the returned InstantiatedMethodDesc is restored.
// It is the caller's responsibility to call CheckRestore on the returned value.
/* static */
Expand All @@ -590,6 +602,7 @@ InstantiatedMethodDesc::FindLoadedInstantiatedMethodDesc(MethodTable *pExactOrRe
GC_NOTRIGGER;
FORBID_FAULT;
PRECONDITION(CheckPointer(pExactOrRepMT));
SUPPORTS_DAC;

// All wrapped method descriptors (except BoxedEntryPointStubs, which don't use this path) are
// canonical and exhibit some kind of code sharing.
Expand Down Expand Up @@ -744,6 +757,7 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
{
THROWS;
if (allowCreate) { GC_TRIGGERS; } else { GC_NOTRIGGER; }
if (!allowCreate) { SUPPORTS_DAC; }
INJECT_FAULT(COMPlusThrowOM(););

PRECONDITION(CheckPointer(pDefMD));
Expand Down Expand Up @@ -868,8 +882,10 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
// that there is no associated unboxing stub, and FindTightlyBoundUnboxingStub takes
// this into account but the _DEBUG version does not, so only use it if the method
// returned is actually different.
#ifndef DACCESS_COMPILE
_ASSERTE(pResultMD == pMDescInCanonMT ||
pResultMD == FindTightlyBoundUnboxingStub_DEBUG(pMDescInCanonMT));
#endif // !DACCESS_COMPILE

if (pResultMD != NULL)
{
Expand Down Expand Up @@ -901,6 +917,7 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
RETURN(NULL);
}

#ifndef DACCESS_COMPILE
CrstHolder ch(&pLoaderModule->m_InstMethodHashTableCrst);

// Check whether another thread beat us to it!
Expand Down Expand Up @@ -939,6 +956,7 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
}

// CrstHolder goes out of scope here
#endif // !DACCESS_COMPILE
}

}
Expand Down Expand Up @@ -966,6 +984,7 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
RETURN(NULL);
}

#ifndef DACCESS_COMPILE
// Recursively get the non-unboxing instantiating stub. Thus we chain an unboxing
// stub with an instantiating stub.
MethodDesc* pNonUnboxingStub=
Expand Down Expand Up @@ -1023,6 +1042,7 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
}

// CrstHolder goes out of scope here
#endif // !DACCESS_COMPILE
}
}
_ASSERTE(pResultMD);
Expand Down Expand Up @@ -1071,8 +1091,10 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
// that this is not an unboxing stub, and FindTightlyBoundWrappedMethodDesc takes
// this into account but the _DEBUG version does not, so only use it if the method
// returned is actually different.
#ifndef DACCESS_COMPILE
_ASSERTE(pResultMD == pMDescInCanonMT ||
pResultMD == FindTightlyBoundWrappedMethodDesc_DEBUG(pMDescInCanonMT));
#endif // !DACCESS_COMPILE

if (pResultMD != NULL)
{
Expand Down Expand Up @@ -1143,11 +1165,13 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
RETURN(NULL);
}

#ifndef DACCESS_COMPILE
pInstMD = InstantiatedMethodDesc::NewInstantiatedMethodDesc(pExactMT->GetCanonicalMethodTable(),
pMDescInCanonMT,
NULL,
Instantiation(repInst, methodInst.GetNumArgs()),
TRUE);
#endif // !DACCESS_COMPILE
}
}
else if (getWrappedThenStub)
Expand All @@ -1168,6 +1192,7 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
RETURN(NULL);
}

#ifndef DACCESS_COMPILE
// This always returns the shared code. Repeat the original call except with
// approximate params and allowInstParam=true
MethodDesc* pWrappedMD = FindOrCreateAssociatedMethodDesc(pDefMD,
Expand All @@ -1188,6 +1213,7 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
pWrappedMD,
methodInst,
FALSE);
#endif // !DACCESS_COMPILE
}
}
else
Expand All @@ -1209,11 +1235,13 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
RETURN(NULL);
}

#ifndef DACCESS_COMPILE
pInstMD = InstantiatedMethodDesc::NewInstantiatedMethodDesc(pExactMT,
pMDescInCanonMT,
NULL,
methodInst,
FALSE);
#endif // !DACCESS_COMPILE
}
}
_ASSERTE(pInstMD);
Expand All @@ -1229,6 +1257,8 @@ MethodDesc::FindOrCreateAssociatedMethodDesc(MethodDesc* pDefMD,
}
}

#ifndef DACCESS_COMPILE

// Normalize the methoddesc for reflection
/*static*/ MethodDesc* MethodDesc::FindOrCreateAssociatedMethodDescForReflection(
MethodDesc *pMethod,
Expand Down Expand Up @@ -1589,8 +1619,6 @@ void MethodDesc::CheckConstraintMetadataValidity(BOOL *pfHasCircularMethodConstr
}


#ifndef DACCESS_COMPILE

BOOL MethodDesc::SatisfiesMethodConstraints(TypeHandle thParent, BOOL fThrowIfNotSatisfied/* = FALSE*/)
{
CONTRACTL
Expand Down
7 changes: 5 additions & 2 deletions src/coreclr/vm/instmethhash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ PTR_LoaderAllocator InstMethodHashTable::GetLoaderAllocator()
}
}

#endif // #ifndef DACCESS_COMPILE

// Calculate a hash value for a method-desc key
static DWORD Hash(TypeHandle declaringType, mdMethodDef token, Instantiation inst)
Expand All @@ -97,9 +98,9 @@ static DWORD Hash(TypeHandle declaringType, mdMethodDef token, Instantiation ins
DWORD dwHash = 0x87654321;
#define INST_HASH_ADD(_value) dwHash = ((dwHash << 5) + dwHash) ^ (_value)
#ifdef TARGET_64BIT
#define INST_HASH_ADDPOINTER(_value) INST_HASH_ADD((uint32_t)(uintptr_t)_value); INST_HASH_ADD((uint32_t)(((uintptr_t)_value) >> 32))
#define INST_HASH_ADDPOINTER(_value) INST_HASH_ADD((uint32_t)dac_cast<TADDR>(_value)); INST_HASH_ADD((uint32_t)((dac_cast<TADDR>(_value)) >> 32))
#else
#define INST_HASH_ADDPOINTER(_value) INST_HASH_ADD((uint32_t)(uintptr_t)_value);
#define INST_HASH_ADDPOINTER(_value) INST_HASH_ADD((uint32_t)dac_cast<TADDR>(_value));
#endif

INST_HASH_ADDPOINTER(declaringType.AsPtr());
Expand Down Expand Up @@ -196,6 +197,8 @@ MethodDesc* InstMethodHashTable::FindMethodDesc(TypeHandle declaringType,
return pMDResult;
}

#ifndef DACCESS_COMPILE

BOOL InstMethodHashTable::ContainsMethodDesc(MethodDesc* pMD)
{
CONTRACTL
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/vm/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,11 @@ class MethodDesc
return FindOrCreateAssociatedMethodDesc(this, GetMethodTable(), FALSE, GetMethodInstantiation(), allowInstParam, FALSE, TRUE, AsyncVariantLookup::AsyncOtherVariant);
}

MethodDesc* GetAsyncOtherVariantNoCreate(BOOL allowInstParam = TRUE)
{
return FindOrCreateAssociatedMethodDesc(this, GetMethodTable(), FALSE, GetMethodInstantiation(), allowInstParam, FALSE, FALSE, AsyncVariantLookup::AsyncOtherVariant);
}

MethodDesc* GetAsyncVariant(BOOL allowInstParam = TRUE)
{
_ASSERT(!IsAsyncVariantMethod());
Expand Down
Loading