From 6658d8b6653e7fd0554397b939438ceda3a1416c Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Wed, 15 Oct 2025 14:05:40 -0700 Subject: [PATCH 1/5] Pass async jit flag to jit in aot tools --- src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | 7 ++++++- .../tools/Common/JitInterface/CorInfoTypes.cs | 1 + .../tools/Common/TypeSystem/Common/MethodDesc.cs | 8 ++++++++ .../tools/Common/TypeSystem/Ecma/EcmaMethod.cs | 12 ++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 7538a26ef002ff..2d994466e0bb97 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -3713,7 +3713,7 @@ private bool getTailCallHelpers(ref CORINFO_RESOLVED_TOKEN callToken, CORINFO_SI private CORINFO_METHOD_STRUCT_* getAsyncResumptionStub() #pragma warning restore CA1822 // Mark members as static { - return null; + throw new NotImplementedException("Crossgen2 does not support runtime-async yet"); } private byte[] _code; @@ -4297,6 +4297,11 @@ private uint getJitFlags(ref CORJIT_FLAGS flags, uint sizeInBytes) flags.Set(CorJitFlag.CORJIT_FLAG_SOFTFP_ABI); } + if (this.MethodBeingCompiled.IsRuntimeAsync) + { + flags.Set(CorJitFlag.CORJIT_FLAG_ASYNC); + } + return (uint)sizeof(CORJIT_FLAGS); } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs index 797ae1c7d3061e..f2688c585b0e52 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs @@ -1414,6 +1414,7 @@ public enum CorJitFlag : uint // ARM only CORJIT_FLAG_RELATIVE_CODE_RELOCS = 29, // JIT should generate PC-relative address computations instead of EE relocation records CORJIT_FLAG_SOFTFP_ABI = 30, // Enable armel calling convention + CORJIT_FLAG_ASYNC = 31, // Generate code for use as an async function } public struct CORJIT_FLAGS diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs index 2075c60ea21713..20fd7f40299e54 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs @@ -658,6 +658,14 @@ public virtual bool IsPublic } } + public virtual bool IsRuntimeAsync + { + get + { + return false; + } + } + public abstract bool HasCustomAttribute(string attributeNamespace, string attributeName); /// diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index 28cb1192ea4889..a37c8ba0f90503 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -32,6 +32,7 @@ private static class MethodFlags public const int AttributeMetadataCache = 0x02000; public const int Intrinsic = 0x04000; public const int UnmanagedCallersOnly = 0x08000; + public const int Async = 0x10000; }; private EcmaType _type; @@ -167,6 +168,9 @@ private int InitializeMethodFlags(int mask) if ((methodImplAttributes & MethodImplAttributes.Synchronized) != 0) flags |= MethodFlags.Synchronized; + if ((methodImplAttributes & MethodImplAttributes.Async) != 0) + flags |= MethodFlags.Async; + flags |= MethodFlags.BasicMetadataCache; } @@ -367,6 +371,14 @@ public override bool IsStaticConstructor } } + public override bool IsRuntimeAsync + { + get + { + return (GetMethodFlags(MethodFlags.BasicMetadataCache | MethodFlags.Async) & MethodFlags.Async) != 0; + } + } + public MethodAttributes Attributes { get From 1f917e9a94c6965dec13d9218c13be9378f86581 Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Wed, 15 Oct 2025 15:47:00 -0700 Subject: [PATCH 2/5] Add IsRuntimeAsync override to instantiated MethodDescs --- .../tools/Common/TypeSystem/Common/InstantiatedMethod.cs | 9 +++++++++ .../TypeSystem/Common/MethodForInstantiatedType.cs | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs index 0fd68eef059f82..1b9ffbc3e5bd45 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs @@ -126,6 +126,15 @@ public override bool IsPublic } } + public override bool IRuntimeAsync + { + get + { + return _methodDef.IsRuntimeAsync; + } + } + + public override bool HasCustomAttribute(string attributeNamespace, string attributeName) { return _methodDef.HasCustomAttribute(attributeNamespace, attributeName); diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs index 4a1cf836e17466..d22179aeb3934e 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs @@ -119,6 +119,14 @@ public override bool IsPublic } } + public override bool IsRuntimeAsync + { + get + { + return _typicalMethodDef.IsRuntimeAsync; + } + } + public override bool HasCustomAttribute(string attributeNamespace, string attributeName) { return _typicalMethodDef.HasCustomAttribute(attributeNamespace, attributeName); From 431bfaaeb25e59f225b98d1fc01a646a4aad4650 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 15 Oct 2025 15:48:11 -0700 Subject: [PATCH 3/5] Update src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs --- .../tools/Common/TypeSystem/Common/InstantiatedMethod.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs index 1b9ffbc3e5bd45..7609855b3b0e96 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs @@ -126,7 +126,7 @@ public override bool IsPublic } } - public override bool IRuntimeAsync + public override bool IsRuntimeAsync { get { From 3a4ffbc68beaf430679a3157dc5ba5cdb8474343 Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Thu, 16 Oct 2025 09:23:22 -0700 Subject: [PATCH 4/5] Rename IsRuntimeAsync to IsAsync, add override in MethodDelegator --- .../tools/Common/TypeSystem/Common/InstantiatedMethod.cs | 4 ++-- src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs | 2 ++ src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs | 2 +- .../Common/TypeSystem/Common/MethodForInstantiatedType.cs | 4 ++-- src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs index 7609855b3b0e96..6024dcc6cc335d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs @@ -126,11 +126,11 @@ public override bool IsPublic } } - public override bool IsRuntimeAsync + public override bool IsAsync { get { - return _methodDef.IsRuntimeAsync; + return _methodDef.IsAsync; } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs index 918bb5e62a88a8..55dba7ed9cead9 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs @@ -38,6 +38,8 @@ public MethodDelegator(MethodDesc wrappedMethod) public override bool IsFinal => _wrappedMethod.IsFinal; + public override bool IsAsync => _wrappedMethod.IsAsync; + public override bool HasCustomAttribute(string attributeNamespace, string attributeName) { return _wrappedMethod.HasCustomAttribute(attributeNamespace, attributeName); diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs index 20fd7f40299e54..96d4c0b163507e 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs @@ -658,7 +658,7 @@ public virtual bool IsPublic } } - public virtual bool IsRuntimeAsync + public virtual bool IsAsync { get { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs index d22179aeb3934e..b5c7195b483e14 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs @@ -119,11 +119,11 @@ public override bool IsPublic } } - public override bool IsRuntimeAsync + public override bool IsAsync { get { - return _typicalMethodDef.IsRuntimeAsync; + return _typicalMethodDef.IsAsync; } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index a37c8ba0f90503..09fb19a982fd79 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -371,7 +371,7 @@ public override bool IsStaticConstructor } } - public override bool IsRuntimeAsync + public override bool IsAsync { get { From 8e8f9e30eed916a45476d5c271df9d05e518f88c Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Fri, 17 Oct 2025 09:24:55 -0700 Subject: [PATCH 5/5] Rename missed a reference --- src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 2d994466e0bb97..ab43b57640a4a5 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -4297,7 +4297,7 @@ private uint getJitFlags(ref CORJIT_FLAGS flags, uint sizeInBytes) flags.Set(CorJitFlag.CORJIT_FLAG_SOFTFP_ABI); } - if (this.MethodBeingCompiled.IsRuntimeAsync) + if (this.MethodBeingCompiled.IsAsync) { flags.Set(CorJitFlag.CORJIT_FLAG_ASYNC); }