diff --git a/src/System.Private.CoreLib/shared/System/Buffers/ArrayPool.cs b/src/System.Private.CoreLib/shared/System/Buffers/ArrayPool.cs index 22ad7821f02d..5e01399a3330 100644 --- a/src/System.Private.CoreLib/shared/System/Buffers/ArrayPool.cs +++ b/src/System.Private.CoreLib/shared/System/Buffers/ArrayPool.cs @@ -19,6 +19,10 @@ namespace System.Buffers /// public abstract class ArrayPool { + // Store the shared ArrayPool in a field of its derived sealed type so the Jit can "see" the exact type + // when the Shared property is inlined which will allow it to devirtualize calls made on it. + private readonly static TlsOverPerCoreLockedStacksArrayPool s_shared = new TlsOverPerCoreLockedStacksArrayPool(); + /// /// Retrieves a shared instance. /// @@ -33,7 +37,7 @@ public abstract class ArrayPool /// optimized for very fast access speeds, at the expense of more memory consumption. /// The shared pool instance is created lazily on first access. /// - public static ArrayPool Shared { get; } = new TlsOverPerCoreLockedStacksArrayPool(); + public static ArrayPool Shared => s_shared; /// /// Creates a new instance using default configuration options.