Skip to content
Draft
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
33 changes: 33 additions & 0 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,39 @@ CallArg* CallArgs::InsertInstParam(Compiler* comp, GenTree* node)
}
}

//---------------------------------------------------------------
// InsertAsyncContinuation: Insert async continuation argument.
//
// Parameters:
// comp - The compiler.
// node - The IR node for the async continuation argument.
//
// Returns:
// The created representative for the argument.
//
CallArg* CallArgs::InsertAsyncContinuation(Compiler* comp, GenTree* node)
{
NewCallArg newArg = NewCallArg::Primitive(node).WellKnown(WellKnownArg::AsyncContinuation);
assert(FindWellKnownArg(WellKnownArg::InstParam) == nullptr);

if (Target::g_tgtArgOrder == Target::ARG_ORDER_R2L)
{
CallArg* retBufferArg = GetRetBufferArg();
Comment on lines +1797 to +1804
if (retBufferArg != nullptr)
{
return InsertAfter(comp, retBufferArg, newArg);
}
else
{
return InsertAfterThisOrFirst(comp, newArg);
}
}
else
{
return PushBack(comp, newArg);
}
}

//---------------------------------------------------------------
// InsertAfterThisOrFirst: Insert an argument after 'this' if the call has a
// 'this' argument, or otherwise first.
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4992,6 +4992,7 @@ class CallArgs
CallArg* InsertAfter(Compiler* comp, CallArg* after, const NewCallArg& arg);
CallArg* InsertAfterUnchecked(Compiler* comp, CallArg* after, const NewCallArg& arg);
CallArg* InsertInstParam(Compiler* comp, GenTree* node);
CallArg* InsertAsyncContinuation(Compiler* comp, GenTree* node);
CallArg* InsertAfterThisOrFirst(Compiler* comp, const NewCallArg& arg);
void PushLateBack(CallArg* arg);
void Remove(CallArg* arg);
Expand Down
18 changes: 2 additions & 16 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7049,24 +7049,10 @@ void Compiler::impSetupAsyncCall(GenTreeCall* call, OPCODE opcode, unsigned pref
// Arguments:
// call - The call
//
// Remarks:
// Should be called before the 'this' arg is inserted, but after other IL args
// have been inserted.
//
void Compiler::impInsertAsyncContinuationForLdvirtftnCall(GenTreeCall* call)
{
assert(call->AsCall()->IsAsync());

if (Target::g_tgtArgOrder == Target::ARG_ORDER_R2L)
{
call->AsCall()->gtArgs.PushFront(this, NewCallArg::Primitive(gtNewNull(), TYP_REF)
.WellKnown(WellKnownArg::AsyncContinuation));
}
else
{
call->AsCall()->gtArgs.PushBack(this, NewCallArg::Primitive(gtNewNull(), TYP_REF)
.WellKnown(WellKnownArg::AsyncContinuation));
}
assert(call->IsAsync());
call->gtArgs.InsertAsyncContinuation(this, gtNewNull());
}

//------------------------------------------------------------------------
Expand Down
Loading
Loading