1010#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
1111#if BIT64
1212using nuint = System . UInt64 ;
13- using nint = System . UInt64 ;
1413#else
1514using nuint = System . UInt32 ;
16- using nint = System . UInt32 ;
1715#endif
1816
1917namespace System
@@ -39,53 +37,8 @@ internal static unsafe void _ZeroMemory(ref byte b, nuint byteLength)
3937 [ DllImport ( RuntimeHelpers . QCall , CharSet = CharSet . Unicode ) ]
4038 private static extern unsafe void __ZeroMemory ( void * b , nuint byteLength ) ;
4139
42- // The maximum block size to for __BulkMoveWithWriteBarrier FCall. This is required to avoid GC starvation.
43- private const uint BulkMoveWithWriteBarrierChunk = 0x4000 ;
44-
45- internal static void BulkMoveWithWriteBarrier ( ref byte destination , ref byte source , nuint byteCount )
46- {
47- if ( byteCount <= BulkMoveWithWriteBarrierChunk )
48- __BulkMoveWithWriteBarrier ( ref destination , ref source , byteCount ) ;
49- else
50- _BulkMoveWithWriteBarrier ( ref destination , ref source , byteCount ) ;
51- }
52-
53- // Non-inlinable wrapper around the loop for copying large blocks in chunks
54- [ MethodImpl ( MethodImplOptions . NoInlining ) ]
55- private static void _BulkMoveWithWriteBarrier ( ref byte destination , ref byte source , nuint byteCount )
56- {
57- Debug . Assert ( byteCount > BulkMoveWithWriteBarrierChunk ) ;
58-
59- if ( Unsafe . AreSame ( ref destination , ref source ) )
60- return ;
61-
62- if ( ( nuint ) ( nint ) Unsafe . ByteOffset ( ref destination , ref source ) >= byteCount )
63- {
64- // Copy forwards
65- do
66- {
67- byteCount -= BulkMoveWithWriteBarrierChunk ;
68- __BulkMoveWithWriteBarrier ( ref destination , ref source , BulkMoveWithWriteBarrierChunk ) ;
69- destination = ref Unsafe . AddByteOffset ( ref destination , BulkMoveWithWriteBarrierChunk ) ;
70- source = ref Unsafe . AddByteOffset ( ref source , BulkMoveWithWriteBarrierChunk ) ;
71- }
72- while ( byteCount > BulkMoveWithWriteBarrierChunk ) ;
73- }
74- else
75- {
76- // Copy backwards
77- do
78- {
79- byteCount -= BulkMoveWithWriteBarrierChunk ;
80- __BulkMoveWithWriteBarrier ( ref Unsafe . AddByteOffset ( ref destination , byteCount ) , ref Unsafe . AddByteOffset ( ref source , byteCount ) , BulkMoveWithWriteBarrierChunk ) ;
81- }
82- while ( byteCount > BulkMoveWithWriteBarrierChunk ) ;
83- }
84- __BulkMoveWithWriteBarrier ( ref destination , ref source , byteCount ) ;
85- }
86-
8740 [ MethodImpl ( MethodImplOptions . InternalCall ) ]
88- private static extern void __BulkMoveWithWriteBarrier ( ref byte destination , ref byte source , nuint byteCount ) ;
41+ internal static extern void BulkMoveWithWriteBarrier ( ref byte destination , ref byte source , nuint byteCount ) ;
8942
9043 [ DllImport ( RuntimeHelpers . QCall , CharSet = CharSet . Unicode ) ]
9144 private static extern unsafe void __Memmove ( byte * dest , byte * src , nuint len ) ;
0 commit comments