From f54acc8e36a99cd958c0c5e99722d3d3178f1e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 14 Nov 2025 09:09:51 +0100 Subject: [PATCH] Report `CORINFO_ASYNC_SAVE_CONTEXTS` when needed This was added in #121448 on the VM side, managed side needs a matching change (I actually found this because we had a newly failing test, yay). --- src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | 10 ++++++++++ src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs | 1 + 2 files changed, 11 insertions(+) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index cdd7525905158b..f53e57b1898659 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -807,6 +807,16 @@ private bool Get_CORINFO_METHOD_INFO(MethodDesc method, MethodIL methodIL, CORIN { methodInfo->options |= CorInfoOptions.CORINFO_GENERICS_CTXT_FROM_METHODTABLE; } + + // Indicate this is an async method that requires save and restore + // of async contexts. Regular user implemented runtime async methods + // require this behavior, but thunks should be transparent and should not + // come with this behavior. + if (method.IsAsyncVariant() && method.IsAsync) + { + methodInfo->options |= CorInfoOptions.CORINFO_ASYNC_SAVE_CONTEXTS; + } + methodInfo->regionKind = CorInfoRegionKind.CORINFO_REGION_NONE; Get_CORINFO_SIG_INFO(method, sig: &methodInfo->args, methodIL); Get_CORINFO_SIG_INFO(methodIL.GetLocals(), &methodInfo->locals); diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs index 3350e184d6de16..1139de42d70b3c 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs @@ -438,6 +438,7 @@ public enum CorInfoOptions CORINFO_GENERICS_CTXT_FROM_METHODDESC | CORINFO_GENERICS_CTXT_FROM_METHODTABLE), CORINFO_GENERICS_CTXT_KEEP_ALIVE = 0x00000100, // Keep the generics context alive throughout the method even if there is no explicit use, and report its location to the CLR + CORINFO_ASYNC_SAVE_CONTEXTS = 0x00000200, // Runtime async method must save and restore contexts } // These are used to detect array methods as NamedIntrinsic in JIT importer,