Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ jobs:
DOTNET_TieredCompilation: '0'
DOTNET_ReadyToRun: '0'
run: dotnet run --project tests/Clockwork.Conformance.Tests/Clockwork.Conformance.Tests.csproj --configuration Debug --no-build -- --timeout 300s --filter-class Orleans.Testing.Simulation.Conformance.Tests.ChannelConformanceTests
- name: Test awaiter conformance sequentially without tiered compilation
# Fully optimized Release runtime code is what a long sequential run reaches through tiering: the controlled
# ConfigureAwait(options) awaitables must keep the BCL's validation frame instead of inlining it into a hidden
# frame (#79).
env:
DOTNET_TieredCompilation: '0'
DOTNET_ReadyToRun: '0'
run: dotnet run --project tests/Clockwork.Conformance.Tests/Clockwork.Conformance.Tests.csproj --configuration Release --no-build -- --timeout 300s --parallel none --filter-class Orleans.Testing.Simulation.Conformance.Tests.ControlledAwaiterConformanceTests
- name: Package smoke tests
# Exercises all seven real packed NuGet artifacts end-to-end in an isolated feed,
# verifies evaluated/restored/packed dependency boundaries and the source-build map,
Expand Down
3 changes: 2 additions & 1 deletion docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ through which an async `Main` returns (`task.GetAwaiter().GetResult()`), waits t
`Task.ConfigureAwait(ConfigureAwaitOptions)` and `Task<T>.ConfigureAwait(ConfigureAwaitOptions)` build
the same controlled awaitables: `SuppressThrowing` completes the await normally for a faulted or
canceled `Task`, `ForceYielding` always yields through the coordinator, and invalid options (including
`SuppressThrowing` on `Task<T>`) throw the BCL's `ArgumentOutOfRangeException`. As in the BCL,
`SuppressThrowing` on `Task<T>`) throw the BCL's `ArgumentOutOfRangeException` from the BCL's
`ConfigureAwait` frame, as a call the JIT does not inline does. As in the BCL,
`GetAwaiter()` or `ConfigureAwait` on a null task throws `NullReferenceException` and the controlled
awaiters keep their frames out of a rethrown exception's stack trace. A synchronous
`GetAwaiter().GetResult()` on an incomplete task or value task pumps the coordinator until it completes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ public ControlledConfiguredTaskAwaitable(Task task, bool continueOnCapturedConte
/// </param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="options"/> is invalid for <see cref="Task"/>.</exception>
[StackTraceHidden]
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public ControlledConfiguredTaskAwaitable(Task task, ConfigureAwaitOptions options)
{
SimulationRuntimeDispatch.RequireActiveSimulation(ApiName);

// The BCL call dereferences the task and validates the options, so a null task and invalid options
// throw the BCL's own exceptions.
// throw the BCL's own exceptions. This frame is hidden, so the JIT must not inline the BCL call into
// it: invalid options are thrown from the BCL's ConfigureAwait frame, as from a non-inlined call.
_ = task.ConfigureAwait(options);
_task = task;
_options = options;
Expand Down Expand Up @@ -146,12 +148,14 @@ public ControlledConfiguredTaskAwaitable(Task<TResult> task, bool continueOnCapt
/// <paramref name="options"/> is invalid for <see cref="Task{TResult}"/>, including <see cref="ConfigureAwaitOptions.SuppressThrowing"/>.
/// </exception>
[StackTraceHidden]
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public ControlledConfiguredTaskAwaitable(Task<TResult> task, ConfigureAwaitOptions options)
{
SimulationRuntimeDispatch.RequireActiveSimulation(ApiName);

// The BCL call dereferences the task and validates the options, so a null task and invalid options
// throw the BCL's own exceptions.
// throw the BCL's own exceptions. This frame is hidden, so the JIT must not inline the BCL call into
// it: invalid options are thrown from the BCL's ConfigureAwait frame, as from a non-inlined call.
_ = task.ConfigureAwait(options);
_task = task;
_options = options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ public sealed class ControlledAwaiterConformanceTests : IDisposable
{
private static readonly DateTimeOffset Start = new(2024, 1, 1, 0, 0, 0, TimeSpan.Zero);

// An optimizing JIT may inline the BCL's ConfigureAwait into its caller, removing that frame from the BCL's
// trace depending on the caller's tier. The probe disables JIT optimization so the BCL trace has the frames
// of a non-inlined call in every run, as the controlled awaitable produces.
private const string Source = """
using System.Diagnostics;
using System.Threading.Tasks;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations)]
namespace Conf { public static class AwaiterProbe {
public static async Task<int> Fail()
{
Expand Down
Loading