Skip to content
Merged
64 changes: 31 additions & 33 deletions docs/design/features/runtime-handled-tasks.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/functioninfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2022,7 +2022,7 @@ void DebuggerMethodInfo::CreateDJIsForNativeBlobs(AppDomain * pAppDomain, Method
// have DJIs for every verision of a method that was EnCed.
// This also handles the possibility of getting the same methoddesc back from the iterator.
// It also lets EnC + generics play nice together (including if an generic method was EnC-ed)
LoadedMethodDescIterator it(pAppDomain, m_module, m_token, /* fIsAsync2Variant */false); // TODO! Debugger doesn't handle async2 variants now
LoadedMethodDescIterator it(pAppDomain, m_module, m_token);
CollectibleAssemblyHolder<Assembly *> pAssembly;
while (it.Next(pAssembly.This()))
{
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/inc/eetwain.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ enum ICodeManagerFlags
ReportFPBasedSlotsOnly
= 0x0200, // EnumGCRefs/EnumerateLiveSlots should only include
// slots that are based on the frame pointer
NoGcDecoderValidation
= 0x0400, // Turn off GCDecoder validation
};

//*****************************************************************************
Expand Down
40 changes: 25 additions & 15 deletions src/coreclr/jit/codegenloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ void CodeGen::genFnEpilog(BasicBlock* block)
0, // argSize
EA_UNKNOWN // retSize
MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(EA_UNKNOWN), // secondRetSize
false, // hasAsyncRet
gcInfo.gcVarPtrSetCur,
gcInfo.gcRegGCrefSetCur,
gcInfo.gcRegByrefSetCur,
Expand Down Expand Up @@ -2891,11 +2892,13 @@ void CodeGen::genCodeForReturnTrap(GenTreeOp* tree)

// TODO-LOONGARCH64: can optimize further !!!
GetEmitter()->emitIns_Call(callType, compiler->eeFindHelper(CORINFO_HELP_STOP_FOR_GC),
INDEBUG_LDISASM_COMMA(nullptr) addr, 0, EA_UNKNOWN, EA_UNKNOWN, gcInfo.gcVarPtrSetCur,
gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur, DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
INDEBUG_LDISASM_COMMA(nullptr) addr, 0, EA_UNKNOWN, EA_UNKNOWN,
false, // hasAsyncRet
gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur,
DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
);

regMaskTP killMask = compiler->compHelperCallKillSet(CORINFO_HELP_STOP_FOR_GC);
Expand Down Expand Up @@ -3982,11 +3985,13 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize,
}

GetEmitter()->emitIns_Call(callType, compiler->eeFindHelper(helper), INDEBUG_LDISASM_COMMA(nullptr) addr, argSize,
retSize, EA_UNKNOWN, gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur,
gcInfo.gcRegByrefSetCur, DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
retSize, EA_UNKNOWN,
false, // hasAsyncRet
gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur,
DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
);

regMaskTP killMask = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);
Expand Down Expand Up @@ -6117,6 +6122,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
nullptr, // addr
retSize
MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(secondRetSize),
false, // hasAsyncRet
di,
target->GetRegNum(),
call->IsFastTailCall());
Expand Down Expand Up @@ -6165,6 +6171,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
nullptr, // addr
retSize
MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(secondRetSize),
false, // hasAsyncRet
di,
targetAddrReg,
call->IsFastTailCall());
Expand Down Expand Up @@ -6208,6 +6215,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
addr,
retSize
MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(secondRetSize),
false, // hasAsyncRet
di,
REG_NA,
call->IsFastTailCall());
Expand Down Expand Up @@ -6972,11 +6980,13 @@ inline void CodeGen::genJumpToThrowHlpBlk_la(
BasicBlock* skipLabel = genCreateTempLabel();

emit->emitIns_Call(callType, compiler->eeFindHelper(compiler->acdHelper(codeKind)),
INDEBUG_LDISASM_COMMA(nullptr) addr, 0, EA_UNKNOWN, EA_UNKNOWN, gcInfo.gcVarPtrSetCur,
gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur, DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
INDEBUG_LDISASM_COMMA(nullptr) addr, 0, EA_UNKNOWN, EA_UNKNOWN,
false, // hasAsyncRet
gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur,
DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
);

regMaskTP killMask = compiler->compHelperCallKillSet((CorInfoHelpFunc)(compiler->acdHelper(codeKind)));
Expand Down
40 changes: 25 additions & 15 deletions src/coreclr/jit/codegenriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ void CodeGen::genFnEpilog(BasicBlock* block)
0, // argSize
EA_UNKNOWN // retSize
MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(EA_UNKNOWN), // secondRetSize
false, // hasAsyncRet
gcInfo.gcVarPtrSetCur,
gcInfo.gcRegGCrefSetCur,
gcInfo.gcRegByrefSetCur,
Expand Down Expand Up @@ -2823,11 +2824,13 @@ void CodeGen::genCodeForReturnTrap(GenTreeOp* tree)

// TODO-RISCV64: can optimize further !!!
GetEmitter()->emitIns_Call(callType, compiler->eeFindHelper(CORINFO_HELP_STOP_FOR_GC),
INDEBUG_LDISASM_COMMA(nullptr) addr, 0, EA_UNKNOWN, EA_UNKNOWN, gcInfo.gcVarPtrSetCur,
gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur, DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
INDEBUG_LDISASM_COMMA(nullptr) addr, 0, EA_UNKNOWN, EA_UNKNOWN,
false, // hasAsyncRet
gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur,
DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
);

regMaskTP killMask = compiler->compHelperCallKillSet(CORINFO_HELP_STOP_FOR_GC);
Expand Down Expand Up @@ -3844,11 +3847,13 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize,
}

GetEmitter()->emitIns_Call(callType, compiler->eeFindHelper(helper), INDEBUG_LDISASM_COMMA(nullptr) addr, argSize,
retSize, EA_UNKNOWN, gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur,
gcInfo.gcRegByrefSetCur, DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
retSize, EA_UNKNOWN,
false, // hasAsyncRet
gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur,
DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
);

regMaskTP killMask = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);
Expand Down Expand Up @@ -6141,6 +6146,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
nullptr, // addr
retSize
MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(secondRetSize),
false, // hasAsyncRet
di,
target->GetRegNum(),
call->IsFastTailCall());
Expand Down Expand Up @@ -6189,6 +6195,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
nullptr, // addr
retSize
MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(secondRetSize),
false, // hasAsyncRet
di,
targetAddrReg,
call->IsFastTailCall());
Expand Down Expand Up @@ -6232,6 +6239,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
addr,
retSize
MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(secondRetSize),
false, // hasAsyncRet
di,
REG_NA,
call->IsFastTailCall());
Expand Down Expand Up @@ -6818,11 +6826,13 @@ void CodeGen::genJumpToThrowHlpBlk_la(
BasicBlock* skipLabel = genCreateTempLabel();

emit->emitIns_Call(callType, compiler->eeFindHelper(compiler->acdHelper(codeKind)),
INDEBUG_LDISASM_COMMA(nullptr) addr, 0, EA_UNKNOWN, EA_UNKNOWN, gcInfo.gcVarPtrSetCur,
gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur, DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
INDEBUG_LDISASM_COMMA(nullptr) addr, 0, EA_UNKNOWN, EA_UNKNOWN,
false, // hasAsyncRet
gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur,
DebugInfo(), /* IL offset */
callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
);

regMaskTP killMask = compiler->compHelperCallKillSet((CorInfoHelpFunc)(compiler->acdHelper(codeKind)));
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/targetloongarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@
#define REG_VALIDATE_INDIRECT_CALL_ADDR REG_T3
#define REG_DISPATCH_INDIRECT_CALL_ADDR REG_T0

#define REG_ASYNC_CONTINUATION_RET REG_A2
#define RBM_ASYNC_CONTINUATION_RET RBM_A2

#define REG_FPBASE REG_FP
#define RBM_FPBASE RBM_FP
#define STR_FPBASE "fp"
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/targetriscv64.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@
#define REG_VALIDATE_INDIRECT_CALL_ADDR REG_T3
#define REG_DISPATCH_INDIRECT_CALL_ADDR REG_T0

#define REG_ASYNC_CONTINUATION_RET REG_A2
#define RBM_ASYNC_CONTINUATION_RET RBM_A2

#define REG_FPBASE REG_FP
#define RBM_FPBASE RBM_FP
#define STR_FPBASE "fp"
Expand Down
9 changes: 4 additions & 5 deletions src/coreclr/vm/arm/asmhelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -884,20 +884,19 @@ DelayLoad_Helper\suffix:
// ------------------------------------------------------------------
// Hijack function for functions which return a value type
NESTED_ENTRY OnHijackTripThread, _TEXT, NoHandler
PROLOG_PUSH "{r0,r2,r4-r11,lr}"
// saving r1 as well, as it can have partial return value when return is > 32 bits
PROLOG_PUSH "{r0,r1,r2,r4-r11,lr}"

PROLOG_VPUSH "{d0-d3}" // saving as d0-d3 can have the floating point return value
PROLOG_PUSH "{r1}" // saving as r1 can have partial return value when return is > 32 bits

CHECK_STACK_ALIGNMENT

add r0, sp, #40
add r0, sp, #32
bl C_FUNC(OnHijackWorker)

EPILOG_POP "{r1}"
EPILOG_VPOP "{d0-d3}"

EPILOG_POP "{r0,r2,r4-r11,pc}"
EPILOG_POP "{r0,r1,r2,r4-r11,pc}"
NESTED_END OnHijackTripThread, _TEXT
#endif

Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/vm/arm/cgencpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,10 @@ struct HijackArgs
// this is only used by functions OnHijackWorker()
};

// saving r1 as well, as it can have partial return value when return is > 32 bits
// also keeps the struct size 8-byte aligned.
DWORD R1;

union
{
DWORD R2;
Expand Down
9 changes: 8 additions & 1 deletion src/coreclr/vm/arm/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1592,10 +1592,17 @@ void HijackFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats
pRD->IsCallerSPValid = FALSE;

pRD->pCurrentContext->Pc = m_ReturnAddress;
pRD->pCurrentContext->Sp = PTR_TO_TADDR(m_Args) + sizeof(struct HijackArgs);
size_t s = sizeof(struct HijackArgs);
_ASSERTE(s%4 == 0); // HijackArgs contains register values and hence will be a multiple of 4
// stack must be multiple of 8. So if s is not multiple of 8 then there must be padding of 4 bytes
s = s + s%8;
pRD->pCurrentContext->Sp = PTR_TO_TADDR(m_Args) + s ;

pRD->pCurrentContext->R0 = m_Args->R0;
pRD->pCurrentContext->R2 = m_Args->R2;

pRD->volatileCurrContextPointers.R0 = &m_Args->R0;
pRD->volatileCurrContextPointers.R2 = &m_Args->R2;

pRD->pCurrentContext->R4 = m_Args->R4;
pRD->pCurrentContext->R5 = m_Args->R5;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/arm64/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ void HijackFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats

pRD->volatileCurrContextPointers.X0 = &m_Args->X0;
pRD->volatileCurrContextPointers.X1 = &m_Args->X1;
pRD->volatileCurrContextPointers.X1 = &m_Args->X2;

pRD->pCurrentContext->X19 = m_Args->X19;
pRD->pCurrentContext->X20 = m_Args->X20;
Expand Down
10 changes: 8 additions & 2 deletions src/coreclr/vm/commodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,13 @@ extern "C" INT32 QCALLTYPE ModuleBuilder_GetMemberRefOfMethodInfo(QCall::ModuleH
COMPlusThrow(kNotSupportedException);
}

if ((pMeth->GetMethodTable()->GetModule() == pModule) && !pMeth->IsAsync2VariantMethod())
if (pMeth->IsAsync2VariantMethod())
{
_ASSERTE(!"Should not have come here!");
COMPlusThrow(kNotSupportedException);
}

if ((pMeth->GetMethodTable()->GetModule() == pModule))
{
// If the passed in method is defined in the same module, just return the MethodDef token
memberRefE = pMeth->GetMemberDef();
Expand All @@ -317,7 +323,7 @@ extern "C" INT32 QCALLTYPE ModuleBuilder_GetMemberRefOfMethodInfo(QCall::ModuleH

ULONG cbComSig;
PCCOR_SIGNATURE pvComSig;
pMeth->GetSig(&pvComSig, &cbComSig);
IfFailThrow(pMeth->GetMDImport()->GetSigOfMethodDef(pMeth->GetMemberDef(), &cbComSig, &pvComSig));

// Translate the method sig into this scope
Assembly * pRefedAssembly = pMeth->GetModule()->GetAssembly();
Expand Down
12 changes: 1 addition & 11 deletions src/coreclr/vm/eetwain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1401,19 +1401,9 @@ bool EECodeManager::EnumGcRefs( PREGDISPLAY pRD,
reportScratchSlots = (flags & ActiveStackFrame) != 0;


GcInfoDecoderFlags decoderFlags;
if (flags & NoGcDecoderValidation)
{
decoderFlags = GcInfoDecoderFlags (DECODE_GC_LIFETIMES | DECODE_SECURITY_OBJECT | DECODE_VARARG | DECODE_NO_VALIDATION);
}
else
{
decoderFlags = GcInfoDecoderFlags (DECODE_GC_LIFETIMES | DECODE_SECURITY_OBJECT | DECODE_VARARG);
}

GcInfoDecoder gcInfoDecoder(
gcInfoToken,
decoderFlags,
GcInfoDecoderFlags (DECODE_GC_LIFETIMES | DECODE_SECURITY_OBJECT | DECODE_VARARG),
curOffs
);

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/encee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ HRESULT EditAndContinueModule::UpdateMethod(MethodDesc *pMethod)
AppDomain::GetCurrentDomain(),
module,
tkMethod,
pMethod->IsAsync2VariantMethod(),
AssemblyIterationFlags(kIncludeLoaded | kIncludeExecution));
CollectibleAssemblyHolder<Assembly *> pAssembly;
while (it.Next(pAssembly.This()))
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/gcinfodecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ inline size_t GET_CALLER_SP(PREGDISPLAY pREGDISPLAY)

#ifndef LOG_PIPTR
#define LOG_PIPTR(pObjRef, gcFlags, hCallBack) \
if (!(m_Flags & DECODE_NO_VALIDATION)) { \
{ \
GCCONTEXT* pGCCtx = (GCCONTEXT*)(hCallBack); \
if (pGCCtx->sc->promotion) \
{ \
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ enum ConvToJitSigFlags : int
CONV_TO_JITSIG_FLAGS_LOCALSIG = 0x1,
};

AsyncMethodSignatureKind ClassifyAsyncMethodSignatureCore(SigPointer sig, Module* pModule, PCCOR_SIGNATURE initialSig, ULONG* offsetOfAsyncDetails, bool *isValueTask);

//---------------------------------------------------------------------------------------
//
//@GENERICS:
Expand All @@ -432,8 +434,6 @@ enum ConvToJitSigFlags : int
// localSig - Is it a local variables declaration, or a method signature (with return type, etc).
// contextType - The type with any instantiaton information
//
AsyncMethodSignatureKind ClassifyAsyncMethodSignatureCore(SigPointer sig, Module* pModule, PCCOR_SIGNATURE initialSig, ULONG* offsetOfAsyncDetails, bool *isValueTask);

static void ConvToJitSig(
SigPointer sig,
CORINFO_MODULE_HANDLE scopeHnd,
Expand Down
Loading