diff options
author | Ben Adams <thundercat@illyriad.co.uk> | 2018-10-26 22:12:13 +0100 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2018-10-26 14:12:13 -0700 |
commit | 0844953a0c75a01cf3c85ae7b4c971dd8e20da51 (patch) | |
tree | f5d0ff3baa5f5f65280371713784c96ededc0d5d /src/System.Private.CoreLib/shared/System/Buffers | |
parent | 65c397a4d2bd4f142fdad1b6a25ab482887dd026 (diff) | |
download | coreclr-0844953a0c75a01cf3c85ae7b4c971dd8e20da51.tar.gz coreclr-0844953a0c75a01cf3c85ae7b4c971dd8e20da51.tar.bz2 coreclr-0844953a0c75a01cf3c85ae7b4c971dd8e20da51.zip |
Allow ArrayPool.Shared devirtualization (redux) (#20637)
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Buffers')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Buffers/ArrayPool.cs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Buffers/ArrayPool.cs b/src/System.Private.CoreLib/shared/System/Buffers/ArrayPool.cs index 22ad7821f0..5e01399a33 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 /// </remarks> public abstract class ArrayPool<T> { + // 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<T> s_shared = new TlsOverPerCoreLockedStacksArrayPool<T>(); + /// <summary> /// Retrieves a shared <see cref="ArrayPool{T}"/> instance. /// </summary> @@ -33,7 +37,7 @@ namespace System.Buffers /// optimized for very fast access speeds, at the expense of more memory consumption. /// The shared pool instance is created lazily on first access. /// </remarks> - public static ArrayPool<T> Shared { get; } = new TlsOverPerCoreLockedStacksArrayPool<T>(); + public static ArrayPool<T> Shared => s_shared; /// <summary> /// Creates a new <see cref="ArrayPool{T}"/> instance using default configuration options. |