From: Marek Safar Date: Thu, 21 Mar 2019 15:30:11 +0000 (+0100) Subject: Move Buffer constants to platform specific files (#23352) X-Git-Tag: accepted/tizen/unified/20190813.215958~55^2~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad30997d41d9652a644f6a2fe1b73bd8416d87b2;p=platform%2Fupstream%2Fcoreclr.git Move Buffer constants to platform specific files (#23352) * Move Buffer constants to platform specific files * Add explicit access modifier --- diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems index 4b5bd02..5da4cc2 100644 --- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems @@ -1051,6 +1051,7 @@ + @@ -1203,6 +1204,7 @@ + diff --git a/src/System.Private.CoreLib/shared/System/Buffer.Unix.cs b/src/System.Private.CoreLib/shared/System/Buffer.Unix.cs new file mode 100644 index 0000000..fee3ccb --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Buffer.Unix.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#if BIT64 +using nuint = System.UInt64; +#else +using nuint = System.UInt32; +#endif + +namespace System +{ + public static partial class Buffer + { +#if ARM64 + // Managed code is currently faster than glibc unoptimized memmove + // TODO-ARM64-UNIX-OPT revisit when glibc optimized memmove is in Linux distros + // https://github.com/dotnet/coreclr/issues/13844 + private const nuint MemmoveNativeThreshold = ulong.MaxValue; +#elif ARM + private const nuint MemmoveNativeThreshold = 512; +#else + private const nuint MemmoveNativeThreshold = 2048; +#endif + } +} \ No newline at end of file diff --git a/src/System.Private.CoreLib/shared/System/Buffer.Windows.cs b/src/System.Private.CoreLib/shared/System/Buffer.Windows.cs new file mode 100644 index 0000000..4de884d --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Buffer.Windows.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#if BIT64 +using nuint = System.UInt64; +#else +using nuint = System.UInt32; +#endif + +namespace System +{ + public static partial class Buffer + { +#if ARM64 + // Determine optimal value for Windows. + // https://github.com/dotnet/coreclr/issues/13843 + private const nuint MemmoveNativeThreshold = ulong.MaxValue; +#else + private const nuint MemmoveNativeThreshold = 2048; +#endif + } +} \ No newline at end of file diff --git a/src/System.Private.CoreLib/shared/System/Buffer.cs b/src/System.Private.CoreLib/shared/System/Buffer.cs index dda25b8..f2ffaae 100644 --- a/src/System.Private.CoreLib/shared/System/Buffer.cs +++ b/src/System.Private.CoreLib/shared/System/Buffer.cs @@ -142,23 +142,6 @@ namespace System // This method has different signature for x64 and other platforms and is done for performance reasons. internal static unsafe void Memmove(byte* dest, byte* src, nuint len) { -#if AMD64 || (BIT32 && !ARM) - const nuint CopyThreshold = 2048; -#elif ARM64 -#if PLATFORM_WINDOWS - // Determined optimal value for Windows. - // https://github.com/dotnet/coreclr/issues/13843 - const nuint CopyThreshold = ulong.MaxValue; -#else // PLATFORM_WINDOWS - // Managed code is currently faster than glibc unoptimized memmove - // TODO-ARM64-UNIX-OPT revisit when glibc optimized memmove is in Linux distros - // https://github.com/dotnet/coreclr/issues/13844 - const nuint CopyThreshold = ulong.MaxValue; -#endif // PLATFORM_WINDOWS -#else - const nuint CopyThreshold = 512; -#endif // AMD64 || (BIT32 && !ARM) - // P/Invoke into the native version when the buffers are overlapping. if (((nuint)dest - (nuint)src < len) || ((nuint)src - (nuint)dest < len)) { @@ -260,14 +243,14 @@ namespace System MCPY05: // PInvoke to the native version when the copy length exceeds the threshold. - if (len > CopyThreshold) + if (len > MemmoveNativeThreshold) { goto PInvoke; } // Copy 64-bytes at a time until the remainder is less than 64. // If remainder is greater than 16 bytes, then jump to MCPY00. Otherwise, unconditionally copy the last 16 bytes and return. - Debug.Assert(len > 64 && len <= CopyThreshold); + Debug.Assert(len > 64 && len <= MemmoveNativeThreshold); nuint n = len >> 6; MCPY06: @@ -356,23 +339,6 @@ namespace System // This method has different signature for x64 and other platforms and is done for performance reasons. private static void Memmove(ref byte dest, ref byte src, nuint len) { -#if AMD64 || (BIT32 && !ARM) - const nuint CopyThreshold = 2048; -#elif ARM64 -#if PLATFORM_WINDOWS - // Determined optimal value for Windows. - // https://github.com/dotnet/coreclr/issues/13843 - const nuint CopyThreshold = ulong.MaxValue; -#else // PLATFORM_WINDOWS - // Managed code is currently faster than glibc unoptimized memmove - // TODO-ARM64-UNIX-OPT revisit when glibc optimized memmove is in Linux distros - // https://github.com/dotnet/coreclr/issues/13844 - const nuint CopyThreshold = ulong.MaxValue; -#endif // PLATFORM_WINDOWS -#else - const nuint CopyThreshold = 512; -#endif // AMD64 || (BIT32 && !ARM) - // P/Invoke into the native version when the buffers are overlapping. if (((nuint)Unsafe.ByteOffset(ref src, ref dest) < len) || ((nuint)Unsafe.ByteOffset(ref dest, ref src) < len)) { @@ -484,14 +450,14 @@ namespace System MCPY05: // PInvoke to the native version when the copy length exceeds the threshold. - if (len > CopyThreshold) + if (len > MemmoveNativeThreshold) { goto PInvoke; } // Copy 64-bytes at a time until the remainder is less than 64. // If remainder is greater than 16 bytes, then jump to MCPY00. Otherwise, unconditionally copy the last 16 bytes and return. - Debug.Assert(len > 64 && len <= CopyThreshold); + Debug.Assert(len > 64 && len <= MemmoveNativeThreshold); nuint n = len >> 6; MCPY06: