diff options
author | Stephen Toub <stoub@microsoft.com> | 2018-10-09 14:52:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-09 14:52:34 -0400 |
commit | efe3c451fbd2a788f51340c28cd36777ef60b49d (patch) | |
tree | 93669bf3a87b4ce39d10f43fc4494bc49787baf6 /src | |
parent | 8aebd79e8cc3820875457471a543a5fc7cbe0cc4 (diff) | |
download | coreclr-efe3c451fbd2a788f51340c28cd36777ef60b49d.tar.gz coreclr-efe3c451fbd2a788f51340c28cd36777ef60b49d.tar.bz2 coreclr-efe3c451fbd2a788f51340c28cd36777ef60b49d.zip |
Avoid building DebugFinalizableAsyncStateMachineBox unless necessary (#20318)
Diffstat (limited to 'src')
-rw-r--r-- | src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs index fc37ca7b4b..acfbd1464b 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs @@ -485,7 +485,7 @@ namespace System.Runtime.CompilerServices // object's identity to track this specific builder/state machine. As such, we proceed to // overwrite whatever's there anyway, even if it's non-null. var box = AsyncMethodBuilderCore.TrackAsyncMethodCompletion ? - new DebugFinalizableAsyncStateMachineBox<TStateMachine>() : + CreateDebugFinalizableAsyncStateMachineBox<TStateMachine>() : new AsyncStateMachineBox<TStateMachine>(); m_task = box; // important: this must be done before storing stateMachine into box.StateMachine! box.StateMachine = stateMachine; @@ -493,6 +493,12 @@ namespace System.Runtime.CompilerServices return box; } + // Avoid forcing the JIT to build DebugFinalizableAsyncStateMachineBox<TStateMachine> unless it's actually needed. + [MethodImpl(MethodImplOptions.NoInlining)] + private static AsyncStateMachineBox<TStateMachine> CreateDebugFinalizableAsyncStateMachineBox<TStateMachine>() + where TStateMachine : IAsyncStateMachine => + new DebugFinalizableAsyncStateMachineBox<TStateMachine>(); + /// <summary> /// Provides an async state machine box with a finalizer that will fire an EventSource /// event about the state machine if it's being finalized without having been completed. @@ -617,7 +623,7 @@ namespace System.Runtime.CompilerServices { Debug.Assert(m_task == null); return (m_task = AsyncMethodBuilderCore.TrackAsyncMethodCompletion ? - new DebugFinalizableAsyncStateMachineBox<IAsyncStateMachine>() : + CreateDebugFinalizableAsyncStateMachineBox<IAsyncStateMachine>() : new AsyncStateMachineBox<IAsyncStateMachine>()); } |