AsyncMethodBuilderCore is implemented with the assumption that value type state machines will not be boxed for a runtime comparison with null:
|
if (stateMachine == null) // TStateMachines are generally non-nullable value types, so this check will be elided |
|
{ |
|
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.stateMachine); |
|
} |
This assumption does not hold for Tier 0 compilation. For a release build of Roslyn, execution of analyzers on Roslyn.sln produces 20% (70GB) of its total allocations boxing state machines for this null check.
AsyncMethodBuilderCoreis implemented with the assumption that value type state machines will not be boxed for a runtime comparison with null:runtime/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs
Lines 23 to 26 in f05dee0
This assumption does not hold for Tier 0 compilation. For a release build of Roslyn, execution of analyzers on Roslyn.sln produces 20% (70GB) of its total allocations boxing state machines for this null check.