From 95e693609c24954b043a2d9e40388af6e798b23d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 06:56:50 +0000 Subject: [PATCH 1/4] Remove BypassReadyToRun attributes from AsyncHelpers files Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com> --- .../Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs | 8 -------- .../System/Runtime/CompilerServices/AsyncHelpers.cs | 12 ------------ 2 files changed, 20 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs index 64169a699065f4..5cd0a8e4298491 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs @@ -349,7 +349,6 @@ private static unsafe Continuation AllocContinuationClass(Continuation prevConti } #endif - [BypassReadyToRun] [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void AwaitTask(Task task, ConfigureAwaitOptions options) { @@ -384,7 +383,6 @@ private static unsafe void AwaitTask(Task task, ConfigureAwaitOptions options) AsyncSuspend(taskCont); } - [BypassReadyToRun] [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T AwaitTask(Task task, ConfigureAwaitOptions options) { @@ -430,7 +428,6 @@ private static unsafe T AwaitTask(Task task, ConfigureAwaitOptions options /// awaiting a completion of an underlying Task or ValueTaskSource. /// /// ValueTask whose completion we are awaiting. - [BypassReadyToRun] [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void TransparentAwaitValueTask(ValueTask valueTask) { @@ -479,7 +476,6 @@ private static unsafe void TransparentAwaitValueTask(ValueTask valueTask) AsyncSuspend(nextCont); } - [BypassReadyToRun] [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void AwaitValueTaskSource(IValueTaskSource source, short token, bool continueOnCapturedContext) { @@ -516,7 +512,6 @@ private static unsafe void AwaitValueTaskSource(IValueTaskSource source, short t AsyncSuspend(vtsCont); } - [BypassReadyToRun] [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T TransparentAwaitValueTaskOfT(ValueTask valueTask) { @@ -565,7 +560,6 @@ private static unsafe T TransparentAwaitValueTaskOfT(ValueTask valueTask) return default!; } - [BypassReadyToRun] [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T AwaitValueTaskSource(IValueTaskSource source, short token, bool continueOnCapturedContext) { @@ -607,7 +601,6 @@ private static unsafe T AwaitValueTaskSource(IValueTaskSource source, shor /// Used by internal thunks that implement awaiting on Task. /// /// Task whose completion we are awaiting. - [BypassReadyToRun] [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void TransparentAwait(Task task) { @@ -637,7 +630,6 @@ private static unsafe void TransparentAwait(Task task) /// Used by internal thunks that implement awaiting on Task. /// /// Task whose completion we are awaiting. - [BypassReadyToRun] [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T TransparentAwaitOfT(Task task) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs index daa89fb6a7a225..63212fdfe6f07e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs @@ -14,7 +14,6 @@ namespace System.Runtime.CompilerServices public static partial class AsyncHelpers { #if CORECLR || NATIVEAOT - // "BypassReadyToRun" is until AOT/R2R typesystem has support for MethodImpl.Async // Must be NoInlining because we use AsyncSuspend to manufacture an explicit suspension point. // It will not capture/restore any local state that is live across it. @@ -23,7 +22,6 @@ public static partial class AsyncHelpers /// /// The awaiter type. /// The awaiter to await. - [BypassReadyToRun] [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] [StackTraceHidden] public static unsafe void AwaitAwaiter(TAwaiter awaiter) where TAwaiter : INotifyCompletion @@ -43,7 +41,6 @@ public static unsafe void AwaitAwaiter(TAwaiter awaiter) where TAwaite /// /// The awaiter type. /// The awaiter to await. - [BypassReadyToRun] [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] [StackTraceHidden] public static unsafe void UnsafeAwaitAwaiter(TAwaiter awaiter) where TAwaiter : ICriticalNotifyCompletion @@ -61,7 +58,6 @@ public static unsafe void UnsafeAwaitAwaiter(TAwaiter awaiter) where T /// The result type produced by the task. /// The task to await. [Intrinsic] - [BypassReadyToRun] [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(Task task) @@ -81,7 +77,6 @@ public static T Await(Task task) /// /// The task to await. [Intrinsic] - [BypassReadyToRun] [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(Task task) @@ -102,7 +97,6 @@ public static void Await(Task task) /// The result type produced by the value task. /// The value task to await. [Intrinsic] - [BypassReadyToRun] [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(ValueTask task) @@ -141,7 +135,6 @@ public static T Await(ValueTask task) /// /// The value task to await. [Intrinsic] - [BypassReadyToRun] [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(ValueTask task) @@ -182,7 +175,6 @@ public static void Await(ValueTask task) /// /// The configured awaitable to await. [Intrinsic] - [BypassReadyToRun] [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(ConfiguredTaskAwaitable configuredAwaitable) @@ -206,7 +198,6 @@ public static void Await(ConfiguredTaskAwaitable configuredAwaitable) } [Intrinsic] - [BypassReadyToRun] [MethodImpl(MethodImplOptions.Async | MethodImplOptions.NoInlining)] [StackTraceHidden] private static void AwaitTaskWithRareOptions(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter awaiter) @@ -224,7 +215,6 @@ private static void AwaitTaskWithRareOptions(ConfiguredTaskAwaitable.ConfiguredT /// /// The configured value task awaitable to await. [Intrinsic] - [BypassReadyToRun] [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(ConfiguredValueTaskAwaitable configuredAwaitable) @@ -267,7 +257,6 @@ public static void Await(ConfiguredValueTaskAwaitable configuredAwaitable) /// The result type produced by the awaitable. /// The configured awaitable to await. [Intrinsic] - [BypassReadyToRun] [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(ConfiguredTaskAwaitable configuredAwaitable) @@ -292,7 +281,6 @@ public static T Await(ConfiguredTaskAwaitable configuredAwaitable) /// The result type produced by the awaitable. /// The configured awaitable to await. [Intrinsic] - [BypassReadyToRun] [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(ConfiguredValueTaskAwaitable configuredAwaitable) From d8f73a3332c3bb35be4c66ae96aba9010e4a85de Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 18:20:09 +0000 Subject: [PATCH 2/4] Fix crossgen2 assertion for non-task-returning async methods Co-authored-by: jtschuster <36744439+jtschuster@users.noreply.github.com> --- .../tools/Common/Compiler/AsyncMethodVariant.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/coreclr/tools/Common/Compiler/AsyncMethodVariant.cs b/src/coreclr/tools/Common/Compiler/AsyncMethodVariant.cs index 78b0c9c76b174b..ad0c94de6626d7 100644 --- a/src/coreclr/tools/Common/Compiler/AsyncMethodVariant.cs +++ b/src/coreclr/tools/Common/Compiler/AsyncMethodVariant.cs @@ -152,9 +152,20 @@ public static bool IsReturnDroppingAsyncThunk(this MethodDesc method) public static bool IsAsyncThunk(this MethodDesc method) { + if (method.IsNonTaskReturningAsyncMethod()) + return false; + return (method.IsAsyncVariant() ^ method.IsAsync) || method.IsReturnDroppingAsyncThunk(); } + public static bool IsNonTaskReturningAsyncMethod(this MethodDesc method) + { + bool isNonTaskReturningAsyncMethod = method.GetTypicalMethodDefinition() is EcmaMethod && method.IsAsync && !method.Signature.ReturnsTaskOrValueTask(); + // non-task-returning async methods should only be in corelib + Debug.Assert(!isNonTaskReturningAsyncMethod || (method.GetTypicalMethodDefinition() is EcmaMethod methodDef && methodDef.Context.SystemModule == methodDef.Module)); + return isNonTaskReturningAsyncMethod; + } + public static bool IsCompilerGeneratedILBodyForAsync(this MethodDesc method) { return method.IsAsyncThunk() || method is AsyncResumptionStub; @@ -163,6 +174,7 @@ public static bool IsCompilerGeneratedILBodyForAsync(this MethodDesc method) public static MethodDesc GetAsyncVariant(this MethodDesc method) { Debug.Assert(!method.IsAsyncVariant()); + Debug.Assert(!method.IsNonTaskReturningAsyncMethod()); return ((CompilerTypeSystemContext)method.Context).GetAsyncVariantMethod(method); } From e51d2f4f6aab34a29798a1d8af186dc2f8bb7a0a Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Fri, 29 May 2026 13:33:32 -0700 Subject: [PATCH 3/4] Gate BypassReadyToRun on AsyncHelpers by runtime-async support Removing [BypassReadyToRun] crashed crossgen2 on browser-wasm: REG_ASYNC_CONTINUATION_RET == REG_NA there, so zeroing the continuation register on a synchronous return tripped genIsValidIntOrFakeReg (instr.cpp). Keep the attributes on platforms that don't support runtime-async, and remove them where it is supported. Mirror the RuntimeAsyncSupported predicate (from src/libraries/Directory.Build.targets, which the corelib build does not import) into both corelib csprojs and define RUNTIME_ASYNC_SUPPORTED when it is true. Wrap each [BypassReadyToRun] in #if !RUNTIME_ASYNC_SUPPORTED. Verified by building clr.corelib for browser/wasm (attributes retained) and linux/x64 (attributes removed) and inspecting the emitted metadata. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../System.Private.CoreLib.csproj | 14 ++++++++ .../CompilerServices/AsyncHelpers.CoreCLR.cs | 24 +++++++++++++ .../src/System.Private.CoreLib.csproj | 14 ++++++++ .../Runtime/CompilerServices/AsyncHelpers.cs | 36 +++++++++++++++++++ 4 files changed, 88 insertions(+) diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index 9e02584f4c34f1..6f15ca9dd88e85 100644 --- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -54,6 +54,20 @@ $(OutputPath)$(MSBuildProjectName).xml + + + true + + + + $(DefineConstants);RUNTIME_ASYNC_SUPPORTED + + $(DefineConstants);TARGET_AMD64 diff --git a/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs index 5cd0a8e4298491..edcedc14c4ef43 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs @@ -349,6 +349,9 @@ private static unsafe Continuation AllocContinuationClass(Continuation prevConti } #endif +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void AwaitTask(Task task, ConfigureAwaitOptions options) { @@ -383,6 +386,9 @@ private static unsafe void AwaitTask(Task task, ConfigureAwaitOptions options) AsyncSuspend(taskCont); } +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T AwaitTask(Task task, ConfigureAwaitOptions options) { @@ -428,6 +434,9 @@ private static unsafe T AwaitTask(Task task, ConfigureAwaitOptions options /// awaiting a completion of an underlying Task or ValueTaskSource. /// /// ValueTask whose completion we are awaiting. +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void TransparentAwaitValueTask(ValueTask valueTask) { @@ -476,6 +485,9 @@ private static unsafe void TransparentAwaitValueTask(ValueTask valueTask) AsyncSuspend(nextCont); } +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void AwaitValueTaskSource(IValueTaskSource source, short token, bool continueOnCapturedContext) { @@ -512,6 +524,9 @@ private static unsafe void AwaitValueTaskSource(IValueTaskSource source, short t AsyncSuspend(vtsCont); } +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T TransparentAwaitValueTaskOfT(ValueTask valueTask) { @@ -560,6 +575,9 @@ private static unsafe T TransparentAwaitValueTaskOfT(ValueTask valueTask) return default!; } +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T AwaitValueTaskSource(IValueTaskSource source, short token, bool continueOnCapturedContext) { @@ -601,6 +619,9 @@ private static unsafe T AwaitValueTaskSource(IValueTaskSource source, shor /// Used by internal thunks that implement awaiting on Task. /// /// Task whose completion we are awaiting. +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void TransparentAwait(Task task) { @@ -630,6 +651,9 @@ private static unsafe void TransparentAwait(Task task) /// Used by internal thunks that implement awaiting on Task. /// /// Task whose completion we are awaiting. +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T TransparentAwaitOfT(Task task) { diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj index ffa900b4b08198..fd996d3adf5658 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -46,6 +46,20 @@ $(Features);runtime-async=on + + + true + + + + $(DefineConstants);RUNTIME_ASYNC_SUPPORTED + + diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs index 63212fdfe6f07e..c38f104620d8dc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs @@ -14,6 +14,9 @@ namespace System.Runtime.CompilerServices public static partial class AsyncHelpers { #if CORECLR || NATIVEAOT + // "BypassReadyToRun" keeps these MethodImpl.Async helpers out of AOT/R2R images on platforms + // that don't support runtime-async (RUNTIME_ASYNC_SUPPORTED is not defined there). On those + // platforms the JIT cannot emit code for runtime-async returns, so the helpers must be JITted. // Must be NoInlining because we use AsyncSuspend to manufacture an explicit suspension point. // It will not capture/restore any local state that is live across it. @@ -22,6 +25,9 @@ public static partial class AsyncHelpers /// /// The awaiter type. /// The awaiter to await. +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] [StackTraceHidden] public static unsafe void AwaitAwaiter(TAwaiter awaiter) where TAwaiter : INotifyCompletion @@ -41,6 +47,9 @@ public static unsafe void AwaitAwaiter(TAwaiter awaiter) where TAwaite /// /// The awaiter type. /// The awaiter to await. +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] [StackTraceHidden] public static unsafe void UnsafeAwaitAwaiter(TAwaiter awaiter) where TAwaiter : ICriticalNotifyCompletion @@ -58,6 +67,9 @@ public static unsafe void UnsafeAwaitAwaiter(TAwaiter awaiter) where T /// The result type produced by the task. /// The task to await. [Intrinsic] +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(Task task) @@ -77,6 +89,9 @@ public static T Await(Task task) /// /// The task to await. [Intrinsic] +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(Task task) @@ -97,6 +112,9 @@ public static void Await(Task task) /// The result type produced by the value task. /// The value task to await. [Intrinsic] +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(ValueTask task) @@ -135,6 +153,9 @@ public static T Await(ValueTask task) /// /// The value task to await. [Intrinsic] +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(ValueTask task) @@ -175,6 +196,9 @@ public static void Await(ValueTask task) /// /// The configured awaitable to await. [Intrinsic] +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(ConfiguredTaskAwaitable configuredAwaitable) @@ -198,6 +222,9 @@ public static void Await(ConfiguredTaskAwaitable configuredAwaitable) } [Intrinsic] +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.Async | MethodImplOptions.NoInlining)] [StackTraceHidden] private static void AwaitTaskWithRareOptions(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter awaiter) @@ -215,6 +242,9 @@ private static void AwaitTaskWithRareOptions(ConfiguredTaskAwaitable.ConfiguredT /// /// The configured value task awaitable to await. [Intrinsic] +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(ConfiguredValueTaskAwaitable configuredAwaitable) @@ -257,6 +287,9 @@ public static void Await(ConfiguredValueTaskAwaitable configuredAwaitable) /// The result type produced by the awaitable. /// The configured awaitable to await. [Intrinsic] +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(ConfiguredTaskAwaitable configuredAwaitable) @@ -281,6 +314,9 @@ public static T Await(ConfiguredTaskAwaitable configuredAwaitable) /// The result type produced by the awaitable. /// The configured awaitable to await. [Intrinsic] +#if !RUNTIME_ASYNC_SUPPORTED + [BypassReadyToRun] +#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(ConfiguredValueTaskAwaitable configuredAwaitable) From 0d320a2d04389ba0b86a3ff63d523de86b1edf69 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Jun 2026 15:17:33 +0000 Subject: [PATCH 4/4] Revert runtime-async gating and disable crossgen for InvalidCSharp Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com> --- .../System.Private.CoreLib.csproj | 14 -------- .../CompilerServices/AsyncHelpers.CoreCLR.cs | 24 ------------- .../src/System.Private.CoreLib.csproj | 14 -------- .../Runtime/CompilerServices/AsyncHelpers.cs | 36 ------------------- .../UnmanagedCallersOnly/InvalidCSharp.ilproj | 2 ++ 5 files changed, 2 insertions(+), 88 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index 6f15ca9dd88e85..9e02584f4c34f1 100644 --- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -54,20 +54,6 @@ $(OutputPath)$(MSBuildProjectName).xml - - - true - - - - $(DefineConstants);RUNTIME_ASYNC_SUPPORTED - - $(DefineConstants);TARGET_AMD64 diff --git a/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs index edcedc14c4ef43..5cd0a8e4298491 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs @@ -349,9 +349,6 @@ private static unsafe Continuation AllocContinuationClass(Continuation prevConti } #endif -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void AwaitTask(Task task, ConfigureAwaitOptions options) { @@ -386,9 +383,6 @@ private static unsafe void AwaitTask(Task task, ConfigureAwaitOptions options) AsyncSuspend(taskCont); } -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T AwaitTask(Task task, ConfigureAwaitOptions options) { @@ -434,9 +428,6 @@ private static unsafe T AwaitTask(Task task, ConfigureAwaitOptions options /// awaiting a completion of an underlying Task or ValueTaskSource. /// /// ValueTask whose completion we are awaiting. -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void TransparentAwaitValueTask(ValueTask valueTask) { @@ -485,9 +476,6 @@ private static unsafe void TransparentAwaitValueTask(ValueTask valueTask) AsyncSuspend(nextCont); } -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void AwaitValueTaskSource(IValueTaskSource source, short token, bool continueOnCapturedContext) { @@ -524,9 +512,6 @@ private static unsafe void AwaitValueTaskSource(IValueTaskSource source, short t AsyncSuspend(vtsCont); } -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T TransparentAwaitValueTaskOfT(ValueTask valueTask) { @@ -575,9 +560,6 @@ private static unsafe T TransparentAwaitValueTaskOfT(ValueTask valueTask) return default!; } -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T AwaitValueTaskSource(IValueTaskSource source, short token, bool continueOnCapturedContext) { @@ -619,9 +601,6 @@ private static unsafe T AwaitValueTaskSource(IValueTaskSource source, shor /// Used by internal thunks that implement awaiting on Task. /// /// Task whose completion we are awaiting. -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe void TransparentAwait(Task task) { @@ -651,9 +630,6 @@ private static unsafe void TransparentAwait(Task task) /// Used by internal thunks that implement awaiting on Task. /// /// Task whose completion we are awaiting. -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] private static unsafe T TransparentAwaitOfT(Task task) { diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj index fd996d3adf5658..ffa900b4b08198 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -46,20 +46,6 @@ $(Features);runtime-async=on - - - true - - - - $(DefineConstants);RUNTIME_ASYNC_SUPPORTED - - diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs index c38f104620d8dc..63212fdfe6f07e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.cs @@ -14,9 +14,6 @@ namespace System.Runtime.CompilerServices public static partial class AsyncHelpers { #if CORECLR || NATIVEAOT - // "BypassReadyToRun" keeps these MethodImpl.Async helpers out of AOT/R2R images on platforms - // that don't support runtime-async (RUNTIME_ASYNC_SUPPORTED is not defined there). On those - // platforms the JIT cannot emit code for runtime-async returns, so the helpers must be JITted. // Must be NoInlining because we use AsyncSuspend to manufacture an explicit suspension point. // It will not capture/restore any local state that is live across it. @@ -25,9 +22,6 @@ public static partial class AsyncHelpers /// /// The awaiter type. /// The awaiter to await. -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] [StackTraceHidden] public static unsafe void AwaitAwaiter(TAwaiter awaiter) where TAwaiter : INotifyCompletion @@ -47,9 +41,6 @@ public static unsafe void AwaitAwaiter(TAwaiter awaiter) where TAwaite /// /// The awaiter type. /// The awaiter to await. -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.Async)] [StackTraceHidden] public static unsafe void UnsafeAwaitAwaiter(TAwaiter awaiter) where TAwaiter : ICriticalNotifyCompletion @@ -67,9 +58,6 @@ public static unsafe void UnsafeAwaitAwaiter(TAwaiter awaiter) where T /// The result type produced by the task. /// The task to await. [Intrinsic] -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(Task task) @@ -89,9 +77,6 @@ public static T Await(Task task) /// /// The task to await. [Intrinsic] -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(Task task) @@ -112,9 +97,6 @@ public static void Await(Task task) /// The result type produced by the value task. /// The value task to await. [Intrinsic] -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(ValueTask task) @@ -153,9 +135,6 @@ public static T Await(ValueTask task) /// /// The value task to await. [Intrinsic] -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(ValueTask task) @@ -196,9 +175,6 @@ public static void Await(ValueTask task) /// /// The configured awaitable to await. [Intrinsic] -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(ConfiguredTaskAwaitable configuredAwaitable) @@ -222,9 +198,6 @@ public static void Await(ConfiguredTaskAwaitable configuredAwaitable) } [Intrinsic] -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.Async | MethodImplOptions.NoInlining)] [StackTraceHidden] private static void AwaitTaskWithRareOptions(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter awaiter) @@ -242,9 +215,6 @@ private static void AwaitTaskWithRareOptions(ConfiguredTaskAwaitable.ConfiguredT /// /// The configured value task awaitable to await. [Intrinsic] -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static void Await(ConfiguredValueTaskAwaitable configuredAwaitable) @@ -287,9 +257,6 @@ public static void Await(ConfiguredValueTaskAwaitable configuredAwaitable) /// The result type produced by the awaitable. /// The configured awaitable to await. [Intrinsic] -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(ConfiguredTaskAwaitable configuredAwaitable) @@ -314,9 +281,6 @@ public static T Await(ConfiguredTaskAwaitable configuredAwaitable) /// The result type produced by the awaitable. /// The configured awaitable to await. [Intrinsic] -#if !RUNTIME_ASYNC_SUPPORTED - [BypassReadyToRun] -#endif [MethodImpl(MethodImplOptions.Async)] [StackTraceHidden] public static T Await(ConfiguredValueTaskAwaitable configuredAwaitable) diff --git a/src/tests/Interop/UnmanagedCallersOnly/InvalidCSharp.ilproj b/src/tests/Interop/UnmanagedCallersOnly/InvalidCSharp.ilproj index b7b8b4d7665382..046255dbd56116 100644 --- a/src/tests/Interop/UnmanagedCallersOnly/InvalidCSharp.ilproj +++ b/src/tests/Interop/UnmanagedCallersOnly/InvalidCSharp.ilproj @@ -1,6 +1,8 @@ library + + false