Skip to content
Open
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
7 changes: 0 additions & 7 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,6 @@ enum CorInfoHelpFunc
CORINFO_HELP_ALLOC_CONTINUATION_METHOD,
CORINFO_HELP_ALLOC_CONTINUATION_CLASS,

CORINFO_HELP_ASYNC_CAPTURE_CONTEXTS,
CORINFO_HELP_ASYNC_RESTORE_CONTEXTS,
CORINFO_HELP_ASYNC_CAPTURE_EXECUTION_CONTEXT,
CORINFO_HELP_ASYNC_RESTORE_EXECUTION_CONTEXT,
CORINFO_HELP_ASYNC_RESTORE_CONTEXTS_ON_SUSPENSION,
CORINFO_HELP_ASYNC_CAPTURE_CONTINUATION_CONTEXT,

CORINFO_HELP_COUNT,
};

Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/inc/jithelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,6 @@
DYNAMICJITHELPER(CORINFO_HELP_ALLOC_CONTINUATION_METHOD, NULL, METHOD__ASYNC_HELPERS__ALLOC_CONTINUATION_METHOD)
DYNAMICJITHELPER(CORINFO_HELP_ALLOC_CONTINUATION_CLASS, NULL, METHOD__ASYNC_HELPERS__ALLOC_CONTINUATION_CLASS)

DYNAMICJITHELPER(CORINFO_HELP_ASYNC_CAPTURE_CONTEXTS, NULL, METHOD__ASYNC_HELPERS__CAPTURE_CONTEXTS)
DYNAMICJITHELPER(CORINFO_HELP_ASYNC_RESTORE_CONTEXTS, NULL, METHOD__ASYNC_HELPERS__RESTORE_CONTEXTS)
DYNAMICJITHELPER(CORINFO_HELP_ASYNC_CAPTURE_EXECUTION_CONTEXT, NULL, METHOD__ASYNC_HELPERS__CAPTURE_EXECUTION_CONTEXT)
DYNAMICJITHELPER(CORINFO_HELP_ASYNC_RESTORE_EXECUTION_CONTEXT, NULL, METHOD__ASYNC_HELPERS__RESTORE_EXECUTION_CONTEXT)
DYNAMICJITHELPER(CORINFO_HELP_ASYNC_RESTORE_CONTEXTS_ON_SUSPENSION, NULL, METHOD__ASYNC_HELPERS__RESTORE_CONTEXTS_ON_SUSPENSION)
DYNAMICJITHELPER(CORINFO_HELP_ASYNC_CAPTURE_CONTINUATION_CONTEXT, NULL, METHOD__ASYNC_HELPERS__CAPTURE_CONTINUATION_CONTEXT)

#undef JITHELPER
#undef DYNAMICJITHELPER
#undef JITHELPER
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/inc/readytorun.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,6 @@ enum ReadyToRunHelper
READYTORUN_HELPER_AllocContinuation = 0x120,
READYTORUN_HELPER_AllocContinuationClass = 0x121,
READYTORUN_HELPER_AllocContinuationMethod = 0x122,
READYTORUN_HELPER_AsyncCaptureContexts = 0x123,
READYTORUN_HELPER_AsyncRestoreContexts = 0x124,
READYTORUN_HELPER_AsyncCaptureExecutionContext = 0x125,
READYTORUN_HELPER_AsyncRestoreExecutionContext = 0x126,
READYTORUN_HELPER_AsyncRestoreContextsOnSuspension = 0x127,
READYTORUN_HELPER_AsyncCaptureContinuationContext = 0x128,
};

#include "readytoruninstructionset.h"
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/inc/readytorunhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ HELPER(READYTORUN_HELPER_GetCurrentManagedThreadId, CORINFO_HELP_GETCURRENTMANAG
HELPER(READYTORUN_HELPER_AllocContinuation, CORINFO_HELP_ALLOC_CONTINUATION, )
HELPER(READYTORUN_HELPER_AllocContinuationClass, CORINFO_HELP_ALLOC_CONTINUATION_CLASS, )
HELPER(READYTORUN_HELPER_AllocContinuationMethod, CORINFO_HELP_ALLOC_CONTINUATION_METHOD, )
HELPER(READYTORUN_HELPER_AsyncCaptureContexts, CORINFO_HELP_ASYNC_CAPTURE_CONTEXTS, )
HELPER(READYTORUN_HELPER_AsyncRestoreContexts, CORINFO_HELP_ASYNC_RESTORE_CONTEXTS, )
HELPER(READYTORUN_HELPER_AsyncCaptureExecutionContext, CORINFO_HELP_ASYNC_CAPTURE_EXECUTION_CONTEXT, )
HELPER(READYTORUN_HELPER_AsyncRestoreExecutionContext, CORINFO_HELP_ASYNC_RESTORE_EXECUTION_CONTEXT, )
HELPER(READYTORUN_HELPER_AsyncRestoreContextsOnSuspension, CORINFO_HELP_ASYNC_RESTORE_CONTEXTS_ON_SUSPENSION, )
HELPER(READYTORUN_HELPER_AsyncCaptureContinuationContext, CORINFO_HELP_ASYNC_CAPTURE_CONTINUATION_CONTEXT, )

HELPER(READYTORUN_HELPER_InitClass, CORINFO_HELP_INITCLASS, )
HELPER(READYTORUN_HELPER_InitInstClass, CORINFO_HELP_INITINSTCLASS, )

Expand Down
79 changes: 72 additions & 7 deletions src/coreclr/jit/async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,24 @@ PhaseStatus Compiler::SaveAsyncContexts()
// For OSR, we did this in the tier0 method.
if (!opts.IsOSR())
{
GenTreeCall* captureCall = gtNewHelperCallNode(CORINFO_HELP_ASYNC_CAPTURE_CONTEXTS, TYP_VOID);
GenTreeCall* captureCall = gtNewCallNode(CT_USER_FUNC, asyncInfo->captureContextsMethHnd, TYP_VOID);
captureCall->gtArgs.PushFront(this,
NewCallArg::Primitive(gtNewLclAddrNode(lvaAsyncSynchronizationContextVar, 0)));
captureCall->gtArgs.PushFront(this, NewCallArg::Primitive(gtNewLclAddrNode(lvaAsyncExecutionContextVar, 0)));
lvaGetDesc(lvaAsyncSynchronizationContextVar)->lvHasLdAddrOp = true;
lvaGetDesc(lvaAsyncExecutionContextVar)->lvHasLdAddrOp = true;

#ifdef FEATURE_READYTORUN
CORINFO_CONST_LOOKUP captureEntryPoint;
info.compCompHnd->getFunctionEntryPoint(asyncInfo->captureContextsMethHnd, &captureEntryPoint);
captureCall->setEntryPoint(captureEntryPoint);
#endif

CORINFO_CALL_INFO callInfo = {};
callInfo.hMethod = captureCall->gtCallMethHnd;
callInfo.methodFlags = info.compCompHnd->getMethodAttribs(callInfo.hMethod);
impMarkInlineCandidate(captureCall, MAKE_METHODCONTEXT(callInfo.hMethod), false, &callInfo, compInlineContext);

Statement* captureStmt = fgNewStmtFromTree(captureCall);
fgInsertStmtAtBeg(fgFirstBB, captureStmt);

Expand All @@ -191,12 +202,20 @@ PhaseStatus Compiler::SaveAsyncContexts()
resumed = gtNewOperNode(GT_NE, TYP_INT, continuation, null);
}

GenTreeCall* restoreCall = gtNewHelperCallNode(CORINFO_HELP_ASYNC_RESTORE_CONTEXTS, TYP_VOID);
GenTreeCall* restoreCall = gtNewCallNode(CT_USER_FUNC, asyncInfo->restoreContextsMethHnd, TYP_VOID);
restoreCall->gtArgs.PushFront(this,
NewCallArg::Primitive(gtNewLclVarNode(lvaAsyncSynchronizationContextVar, TYP_REF)));
restoreCall->gtArgs.PushFront(this, NewCallArg::Primitive(gtNewLclVarNode(lvaAsyncExecutionContextVar, TYP_REF)));
restoreCall->gtArgs.PushFront(this, NewCallArg::Primitive(resumed));

#ifdef FEATURE_READYTORUN
{
CORINFO_CONST_LOOKUP restoreEntryPoint;
info.compCompHnd->getFunctionEntryPoint(asyncInfo->restoreContextsMethHnd, &restoreEntryPoint);
restoreCall->setEntryPoint(restoreEntryPoint);
}
#endif

Statement* restoreStmt = fgNewStmtFromTree(restoreCall);
fgInsertStmtAtEnd(faultBB, restoreStmt);

Expand Down Expand Up @@ -357,12 +376,26 @@ BasicBlock* Compiler::CreateReturnBB(unsigned* mergedReturnLcl)
resumed = gtNewOperNode(GT_NE, TYP_INT, continuation, null);
}

GenTreeCall* restoreCall = gtNewHelperCallNode(CORINFO_HELP_ASYNC_RESTORE_CONTEXTS, TYP_VOID);
GenTreeCall* restoreCall = gtNewCallNode(CT_USER_FUNC, asyncInfo->restoreContextsMethHnd, TYP_VOID);
restoreCall->gtArgs.PushFront(this,
NewCallArg::Primitive(gtNewLclVarNode(lvaAsyncSynchronizationContextVar, TYP_REF)));
restoreCall->gtArgs.PushFront(this, NewCallArg::Primitive(gtNewLclVarNode(lvaAsyncExecutionContextVar, TYP_REF)));
restoreCall->gtArgs.PushFront(this, NewCallArg::Primitive(resumed));

#ifdef FEATURE_READYTORUN
{
CORINFO_CONST_LOOKUP restoreEntryPoint;
info.compCompHnd->getFunctionEntryPoint(asyncInfo->restoreContextsMethHnd, &restoreEntryPoint);
restoreCall->setEntryPoint(restoreEntryPoint);
}
#endif

// This restore is an inline candidate (unlike the fault one)
CORINFO_CALL_INFO callInfo = {};
callInfo.hMethod = restoreCall->gtCallMethHnd;
callInfo.methodFlags = info.compCompHnd->getMethodAttribs(callInfo.hMethod);
impMarkInlineCandidate(restoreCall, MAKE_METHODCONTEXT(callInfo.hMethod), false, &callInfo, compInlineContext);

Statement* restoreStmt = fgNewStmtFromTree(restoreCall);
fgInsertStmtAtEnd(newReturnBB, restoreStmt);
JITDUMP("Inserted restore statement in return block\n");
Expand Down Expand Up @@ -2105,11 +2138,19 @@ void AsyncTransformation::FillInDataOnSuspension(GenTreeCall* call,
GenTree* contContextElementPlaceholder = m_compiler->gtNewZeroConNode(TYP_BYREF);
GenTree* flagsPlaceholder = m_compiler->gtNewZeroConNode(TYP_BYREF);
GenTreeCall* captureCall =
m_compiler->gtNewHelperCallNode(CORINFO_HELP_ASYNC_CAPTURE_CONTINUATION_CONTEXT, TYP_VOID);
m_compiler->gtNewCallNode(CT_USER_FUNC, m_asyncInfo->captureContinuationContextMethHnd, TYP_VOID);

captureCall->gtArgs.PushFront(m_compiler, NewCallArg::Primitive(flagsPlaceholder));
captureCall->gtArgs.PushFront(m_compiler, NewCallArg::Primitive(contContextElementPlaceholder));

#ifdef FEATURE_READYTORUN
{
CORINFO_CONST_LOOKUP entryPoint;
m_compiler->info.compCompHnd->getFunctionEntryPoint(m_asyncInfo->captureContinuationContextMethHnd, &entryPoint);
captureCall->setEntryPoint(entryPoint);
}
#endif

m_compiler->compCurBB = suspendBB;
m_compiler->fgMorphTree(captureCall);

Expand Down Expand Up @@ -2149,7 +2190,15 @@ void AsyncTransformation::FillInDataOnSuspension(GenTreeCall* call,
if (layout.ExecutionContextOffset != UINT_MAX)
{
GenTreeCall* captureExecContext =
m_compiler->gtNewHelperCallNode(CORINFO_HELP_ASYNC_CAPTURE_EXECUTION_CONTEXT, TYP_REF);
m_compiler->gtNewCallNode(CT_USER_FUNC, m_asyncInfo->captureExecutionContextMethHnd, TYP_REF);

#ifdef FEATURE_READYTORUN
{
CORINFO_CONST_LOOKUP entryPoint;
m_compiler->info.compCompHnd->getFunctionEntryPoint(m_asyncInfo->captureExecutionContextMethHnd, &entryPoint);
captureExecContext->setEntryPoint(entryPoint);
}
#endif

m_compiler->compCurBB = suspendBB;
m_compiler->fgMorphTree(captureExecContext);
Expand Down Expand Up @@ -2191,12 +2240,20 @@ void AsyncTransformation::RestoreContexts(BasicBlock* block, GenTreeCall* call,
GenTree* execContextPlaceholder = m_compiler->gtNewNull();
GenTree* syncContextPlaceholder = m_compiler->gtNewNull();
GenTreeCall* restoreCall =
m_compiler->gtNewHelperCallNode(CORINFO_HELP_ASYNC_RESTORE_CONTEXTS_ON_SUSPENSION, TYP_VOID);
m_compiler->gtNewCallNode(CT_USER_FUNC, m_asyncInfo->restoreContextsOnSuspensionMethHnd, TYP_VOID);

restoreCall->gtArgs.PushFront(m_compiler, NewCallArg::Primitive(syncContextPlaceholder));
restoreCall->gtArgs.PushFront(m_compiler, NewCallArg::Primitive(execContextPlaceholder));
restoreCall->gtArgs.PushFront(m_compiler, NewCallArg::Primitive(resumedPlaceholder));

#ifdef FEATURE_READYTORUN
{
CORINFO_CONST_LOOKUP entryPoint;
m_compiler->info.compCompHnd->getFunctionEntryPoint(m_asyncInfo->restoreContextsOnSuspensionMethHnd, &entryPoint);
restoreCall->setEntryPoint(entryPoint);
}
#endif

m_compiler->compCurBB = suspendBB;
m_compiler->fgMorphTree(restoreCall);

Expand Down Expand Up @@ -2394,9 +2451,17 @@ void AsyncTransformation::RestoreFromDataOnResumption(const ContinuationLayout&
{
GenTree* valuePlaceholder = m_compiler->gtNewZeroConNode(TYP_REF);
GenTreeCall* restoreCall =
m_compiler->gtNewHelperCallNode(CORINFO_HELP_ASYNC_RESTORE_EXECUTION_CONTEXT, TYP_VOID);
m_compiler->gtNewCallNode(CT_USER_FUNC, m_asyncInfo->restoreExecutionContextMethHnd, TYP_VOID);
restoreCall->gtArgs.PushFront(m_compiler, NewCallArg::Primitive(valuePlaceholder));

#ifdef FEATURE_READYTORUN
{
CORINFO_CONST_LOOKUP entryPoint;
m_compiler->info.compCompHnd->getFunctionEntryPoint(m_asyncInfo->restoreExecutionContextMethHnd, &entryPoint);
restoreCall->setEntryPoint(entryPoint);
}
#endif

m_compiler->compCurBB = resumeBB;
m_compiler->fgMorphTree(restoreCall);

Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/jit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1770,15 +1770,6 @@ void HelperCallProperties::init()
isAllocator = true;
break;

case CORINFO_HELP_ASYNC_CAPTURE_CONTEXTS:
case CORINFO_HELP_ASYNC_RESTORE_CONTEXTS:
case CORINFO_HELP_ASYNC_CAPTURE_EXECUTION_CONTEXT:
case CORINFO_HELP_ASYNC_RESTORE_EXECUTION_CONTEXT:
case CORINFO_HELP_ASYNC_RESTORE_CONTEXTS_ON_SUSPENSION:
case CORINFO_HELP_ASYNC_CAPTURE_CONTINUATION_CONTEXT:
mutatesHeap = true;
break;

default:
// The most pessimistic results are returned for these helpers.
mutatesHeap = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,6 @@ public enum ReadyToRunHelper
AllocContinuation = 0x120,
AllocContinuationClass = 0x121,
AllocContinuationMethod = 0x122,
AsyncCaptureContexts = 0x123,
AsyncRestoreContexts = 0x124,
AsyncCaptureExecutionContext = 0x125,
AsyncRestoreExecutionContext = 0x126,
AsyncRestoreContextsOnSuspension = 0x127,
AsyncCaptureContinuationContext = 0x128,

// **********************************************************************************************
//
// These are not actually part of the R2R file format. We have them here because it's convenient.
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,6 @@ which is the right helper to use to allocate an object of a given type. */
CORINFO_HELP_ALLOC_CONTINUATION_METHOD,
CORINFO_HELP_ALLOC_CONTINUATION_CLASS,

CORINFO_HELP_ASYNC_CAPTURE_CONTEXTS,
CORINFO_HELP_ASYNC_RESTORE_CONTEXTS,
CORINFO_HELP_ASYNC_CAPTURE_EXECUTION_CONTEXT,
CORINFO_HELP_ASYNC_RESTORE_EXECUTION_CONTEXT,
CORINFO_HELP_ASYNC_RESTORE_CONTEXTS_ON_SUSPENSION,
CORINFO_HELP_ASYNC_CAPTURE_CONTINUATION_CONTEXT,

CORINFO_HELP_COUNT,
}
}
24 changes: 0 additions & 24 deletions src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,30 +342,6 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id,
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "AllocContinuation"u8, null);
break;

case ReadyToRunHelper.AsyncCaptureContexts:
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "CaptureContexts"u8, null);
break;

case ReadyToRunHelper.AsyncRestoreContexts:
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "RestoreContexts"u8, null);
break;

case ReadyToRunHelper.AsyncCaptureExecutionContext:
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "CaptureExecutionContext"u8, null);
break;

case ReadyToRunHelper.AsyncRestoreExecutionContext:
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "RestoreExecutionContext"u8, null);
break;

case ReadyToRunHelper.AsyncRestoreContextsOnSuspension:
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "RestoreContextsOnSuspension"u8, null);
break;

case ReadyToRunHelper.AsyncCaptureContinuationContext:
methodDesc = context.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "CaptureContinuationContext"u8, null);
break;

default:
throw new NotImplementedException(id.ToString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,10 @@ private void ImportCall(ILOpcode opcode, int token)
_dependencies.Add(_factory.ConstructedTypeSymbol(_compilation.TypeSystemContext.ContinuationType), asyncReason);

_dependencies.Add(_compilation.GetHelperEntrypoint(ReadyToRunHelper.AllocContinuation), asyncReason);
_dependencies.Add(_compilation.GetHelperEntrypoint(ReadyToRunHelper.AsyncCaptureExecutionContext), asyncReason);
_dependencies.Add(_compilation.GetHelperEntrypoint(ReadyToRunHelper.AsyncRestoreExecutionContext), asyncReason);
_dependencies.Add(_compilation.GetHelperEntrypoint(ReadyToRunHelper.AsyncCaptureContinuationContext), asyncReason);
_dependencies.Add(_compilation.GetHelperEntrypoint(ReadyToRunHelper.AsyncRestoreContextsOnSuspension), asyncReason);
_dependencies.Add(_compilation.TypeSystemContext.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "CaptureExecutionContext"u8, null), asyncReason);
_dependencies.Add(_compilation.TypeSystemContext.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "RestoreExecutionContext"u8, null), asyncReason);
_dependencies.Add(_compilation.TypeSystemContext.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "CaptureContinuationContext"u8, null), asyncReason);
_dependencies.Add(_compilation.TypeSystemContext.GetCoreLibEntryPoint("System.Runtime.CompilerServices"u8, "AsyncHelpers"u8, "RestoreContextsOnSuspension"u8, null), asyncReason);
}

// If this is the task await pattern, we're actually going to call the variant
Expand Down
Loading