diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 7538a26ef002ff..ab43b57640a4a5 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.IsAsync) + { + 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/InstantiatedMethod.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs index 0fd68eef059f82..6024dcc6cc335d 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 IsAsync + { + get + { + return _methodDef.IsAsync; + } + } + + public override bool HasCustomAttribute(string attributeNamespace, string attributeName) { return _methodDef.HasCustomAttribute(attributeNamespace, attributeName); 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 2075c60ea21713..96d4c0b163507e 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 IsAsync + { + get + { + return false; + } + } + public abstract bool HasCustomAttribute(string attributeNamespace, string attributeName); /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs index 4a1cf836e17466..b5c7195b483e14 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 IsAsync + { + get + { + return _typicalMethodDef.IsAsync; + } + } + public override bool HasCustomAttribute(string attributeNamespace, string attributeName) { return _typicalMethodDef.HasCustomAttribute(attributeNamespace, attributeName); diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index 28cb1192ea4889..09fb19a982fd79 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 IsAsync + { + get + { + return (GetMethodFlags(MethodFlags.BasicMetadataCache | MethodFlags.Async) & MethodFlags.Async) != 0; + } + } + public MethodAttributes Attributes { get