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

[Runtime Async] Add support for shared generics #2755

Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Current support in the prototypes looks like the following:

| **Feature/characteristic** | **JIT based state machines** | **Unwinder based state machines** |
|------------------------------------------|:------------------------------:|:-----------------------------------:|
| **Generics** | | ❌ |
| **Generics** | | ❌ |
| **Byrefs live across suspension points** | ❌ | ✅ |
| **Exception handling** | ✅ | ❌ |
| **Returns via return buffers** | ✅ | ❌ |
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/callhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments, ARG_SLOT *

#ifndef FEATURE_INTERPRETER
_ASSERTE(isCallConv(m_methodSig.GetCallingConvention(), IMAGE_CEE_CS_CALLCONV_DEFAULT));
_ASSERTE(!(m_methodSig.GetCallingConventionInfo() & CORINFO_CALLCONV_PARAMTYPE));
_ASSERTE(!m_methodSig.HasGenericContextArg());
#endif

#ifdef DEBUGGING_SUPPORTED
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/gcenv.ee.common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ StackWalkAction GcStackCrawlCallBack(CrawlFrame* pCF, VOID* pData)
if (paramContextType == GENERIC_PARAM_CONTEXT_METHODDESC)
{
MethodDesc *pMDReal = dac_cast<PTR_MethodDesc>(pCF->GetParamTypeArg());
_ASSERTE((pMDReal != NULL) || !pCF->IsFrameless());
_ASSERTE((pMDReal != NULL) || !pCF->IsFrameless() || pMD->IsAsync2Method());
if (pMDReal != NULL)
{
GcReportLoaderAllocator(gcctx->f, gcctx->sc, pMDReal->GetLoaderAllocator());
Expand All @@ -457,7 +457,7 @@ StackWalkAction GcStackCrawlCallBack(CrawlFrame* pCF, VOID* pData)
else if (paramContextType == GENERIC_PARAM_CONTEXT_METHODTABLE)
{
MethodTable *pMTReal = dac_cast<PTR_MethodTable>(pCF->GetParamTypeArg());
_ASSERTE((pMTReal != NULL) || !pCF->IsFrameless());
_ASSERTE((pMTReal != NULL) || !pCF->IsFrameless() || pMD->IsAsync2Method());
if (pMTReal != NULL)
{
GcReportLoaderAllocator(gcctx->f, gcctx->sc, pMTReal->GetLoaderAllocator());
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ CorJitResult Interpreter::GenerateInterpreterStub(CEEInfo* comp,
totalArgs++;
}

if (sig.GetCallingConventionInfo() & CORINFO_CALLCONV_PARAMTYPE)
if (sig.HasGenericContextArg())
{
_ASSERTE(info->args.callConv & CORINFO_CALLCONV_PARAMTYPE);
hasGenericsContextArg = true;
Expand Down
20 changes: 12 additions & 8 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14374,7 +14374,7 @@ static Signature BuildResumptionStubCalliSignature(MetaSig& msig, LoaderAllocato
numArgs++;
}

if ((msig.GetCallingConvention() & CORINFO_CALLCONV_PARAMTYPE) != 0)
if (msig.HasGenericContextArg())
{
numArgs++;
}
Expand Down Expand Up @@ -14412,7 +14412,7 @@ static Signature BuildResumptionStubCalliSignature(MetaSig& msig, LoaderAllocato
sigBuilder.AppendElementType(ELEMENT_TYPE_OBJECT);
}
#ifndef TARGET_X86
if ((msig.GetCallingConvention() & CORINFO_CALLCONV_PARAMTYPE) != 0)
if (msig.HasGenericContextArg())
{
sigBuilder.AppendElementType(ELEMENT_TYPE_I);
}
Expand All @@ -14429,7 +14429,7 @@ static Signature BuildResumptionStubCalliSignature(MetaSig& msig, LoaderAllocato
}

#ifdef TARGET_X86
if ((msig.GetCallingConvention() & CORINFO_CALLCONV_PARAMTYPE) != 0)
if (msig.HasGenericContextArg())
{
sigBuilder.AppendElementType(ELEMENT_TYPE_I);
}
Expand All @@ -14449,7 +14449,6 @@ CORINFO_METHOD_HANDLE CEEJitInfo::getAsyncResumptionStub()
} CONTRACTL_END;

MethodDesc* md = m_pMethodBeingCompiled;
_ASSERTE(!md->IsSharedByGenericInstantiations());

LoaderAllocator* loaderAlloc = md->GetLoaderAllocator();

Expand All @@ -14473,10 +14472,9 @@ CORINFO_METHOD_HANDLE CEEJitInfo::getAsyncResumptionStub()
}

#ifndef TARGET_X86
if ((msig.GetCallingConvention() & CORINFO_CALLCONV_PARAMTYPE) != 0)
if (msig.HasGenericContextArg())
{
_ASSERTE(!"Generic context currently unhandled");
// Will need JIT to store this in an agreed upon place.
pCode->EmitLDC(0);
numArgs++;
}

Expand All @@ -14498,9 +14496,15 @@ CORINFO_METHOD_HANDLE CEEJitInfo::getAsyncResumptionStub()
}

#ifdef TARGET_X86
if (msig.HasGenericContextArg())
{
pCode->EmitLDC(0);
numArgs++;
}

// Continuation
pCode->EmitLDARG(0);
nmArgs++;
numArgs++;
#endif

// Resumption stubs are uniquely coupled to the code version (since the
Expand Down
7 changes: 4 additions & 3 deletions src/coreclr/vm/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ class MethodDesc
PTR_PCODE GetAddrOfNativeCodeSlot();
PTR_AsyncMethodData GetAddrOfAsyncMethodData();
#ifndef DACCESS_COMPILE
const AsyncMethodData& GetAsyncMethodData() { _ASSERTE(IsAsyncThunkMethod()); return *GetAddrOfAsyncMethodData(); }
const AsyncMethodData& GetAsyncMethodData() { _ASSERTE(HasAsyncMethodData()); return *GetAddrOfAsyncMethodData(); }
#endif

BOOL MayHaveNativeCode();
Expand Down Expand Up @@ -1615,8 +1615,7 @@ class MethodDesc

MethodDesc* GetAsyncOtherVariant()
{
// TODO This should be FindOrCreateAssociatedMethodDesc with some set of params
return GetMethodTable()->GetParallelMethodDesc(this, AsyncVariantLookup::AsyncOtherVariant);
return FindOrCreateAssociatedMethodDesc(this, GetMethodTable(), FALSE, GetMethodInstantiation(), TRUE, FALSE, TRUE, AsyncVariantLookup::AsyncOtherVariant);
}

// True if a MD is an funny BoxedEntryPointStub (not from the method table) or
Expand Down Expand Up @@ -1995,6 +1994,8 @@ class MethodDesc
bool TryGenerateUnsafeAccessor(DynamicResolver** resolver, COR_ILMETHOD_DECODER** methodILDecoder);
void EmitJitStateMachineBasedRuntimeAsyncThunk(MethodDesc* pAsyncOtherVariant, MetaSig& thunkMsig, ILStubLinker* pSL);
void EmitAsync2MethodThunk(MethodDesc* pAsyncOtherVariant, MetaSig& msig, ILStubLinker* pSL);
SigPointer GetAsync2ThunkResultTypeSig();
int GetTokenForGenericMethodCallWithAsyncReturnType(ILCodeStream* pCode, MethodDesc* md);
public:
static void CreateDerivedTargetSigWithExtraParams(MetaSig& msig, SigBuilder* stubSigBuilder);
bool TryGenerateTransientILImplementation(DynamicResolver** resolver, COR_ILMETHOD_DECODER** methodILDecoder);
Expand Down
Loading