6478 references to Unsafe
GenerateDocumentationAndConfigFiles (55)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (7)
23return Unsafe.SizeOf<T>() switch 40_ => InlineCalculateSegmentSize(Unsafe.SizeOf<T>()), 50return Unsafe.SizeOf<T>() switch 67_ => InlineCalculateSegmentShift(Unsafe.SizeOf<T>()), 77return Unsafe.SizeOf<T>() switch 94_ => InlineCalculateOffsetMask(Unsafe.SizeOf<T>()), 175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\ModifierExtensions.cs (1)
16return Unsafe.As<Modifiers, DeclarationModifiers>(ref modifiers);
http2cat (3)
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
IIS.FunctionalTests (3)
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
IIS.LongTests (3)
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
IIS.NewHandler.FunctionalTests (3)
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
IIS.NewShim.FunctionalTests (3)
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
IIS.ShadowCopy.Tests (3)
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
IISExpress.FunctionalTests (3)
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
InMemory.FunctionalTests (26)
src\Servers\Kestrel\shared\TransportConnection.Generated.cs (26)
263feature = Unsafe.As<IConnectionIdFeature?, TFeature?>(ref _currentIConnectionIdFeature); 267feature = Unsafe.As<IConnectionTransportFeature?, TFeature?>(ref _currentIConnectionTransportFeature); 271feature = Unsafe.As<IConnectionItemsFeature?, TFeature?>(ref _currentIConnectionItemsFeature); 275feature = Unsafe.As<IPersistentStateFeature?, TFeature?>(ref _currentIPersistentStateFeature); 279feature = Unsafe.As<IMemoryPoolFeature?, TFeature?>(ref _currentIMemoryPoolFeature); 283feature = Unsafe.As<IConnectionLifetimeFeature?, TFeature?>(ref _currentIConnectionLifetimeFeature); 287feature = Unsafe.As<IConnectionSocketFeature?, TFeature?>(ref _currentIConnectionSocketFeature); 291feature = Unsafe.As<IProtocolErrorCodeFeature?, TFeature?>(ref _currentIProtocolErrorCodeFeature); 295feature = Unsafe.As<IStreamDirectionFeature?, TFeature?>(ref _currentIStreamDirectionFeature); 299feature = Unsafe.As<IStreamIdFeature?, TFeature?>(ref _currentIStreamIdFeature); 303feature = Unsafe.As<IStreamAbortFeature?, TFeature?>(ref _currentIStreamAbortFeature); 307feature = Unsafe.As<IStreamClosedFeature?, TFeature?>(ref _currentIStreamClosedFeature); 311feature = Unsafe.As<IConnectionMetricsTagsFeature?, TFeature?>(ref _currentIConnectionMetricsTagsFeature); 335_currentIConnectionIdFeature = Unsafe.As<TFeature?, IConnectionIdFeature?>(ref feature); 339_currentIConnectionTransportFeature = Unsafe.As<TFeature?, IConnectionTransportFeature?>(ref feature); 343_currentIConnectionItemsFeature = Unsafe.As<TFeature?, IConnectionItemsFeature?>(ref feature); 347_currentIPersistentStateFeature = Unsafe.As<TFeature?, IPersistentStateFeature?>(ref feature); 351_currentIMemoryPoolFeature = Unsafe.As<TFeature?, IMemoryPoolFeature?>(ref feature); 355_currentIConnectionLifetimeFeature = Unsafe.As<TFeature?, IConnectionLifetimeFeature?>(ref feature); 359_currentIConnectionSocketFeature = Unsafe.As<TFeature?, IConnectionSocketFeature?>(ref feature); 363_currentIProtocolErrorCodeFeature = Unsafe.As<TFeature?, IProtocolErrorCodeFeature?>(ref feature); 367_currentIStreamDirectionFeature = Unsafe.As<TFeature?, IStreamDirectionFeature?>(ref feature); 371_currentIStreamIdFeature = Unsafe.As<TFeature?, IStreamIdFeature?>(ref feature); 375_currentIStreamAbortFeature = Unsafe.As<TFeature?, IStreamAbortFeature?>(ref feature); 379_currentIStreamClosedFeature = Unsafe.As<TFeature?, IStreamClosedFeature?>(ref feature); 383_currentIConnectionMetricsTagsFeature = Unsafe.As<TFeature?, IConnectionMetricsTagsFeature?>(ref feature);
Interop.FunctionalTests (2)
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
59return (T*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(alloc)); 101return (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(buffer));
Metrics (51)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
Metrics.Legacy (51)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
Microsoft.AspNetCore.Components.Server (2)
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\SequenceReaderExtensions.cs (2)
40value = Unsafe.ReadUnaligned<T>(ref MemoryMarshal.GetReference(span)); 84value = Unsafe.ReadUnaligned<T>(ref MemoryMarshal.GetReference(tempSpan));
Microsoft.AspNetCore.Components.WebAssembly (1)
Rendering\WebAssemblyRenderer.cs (1)
152RenderBatch(RendererId, Unsafe.AsPointer(ref batchCopy));
Microsoft.AspNetCore.Grpc.JsonTranscoding (6)
Internal\Json\EnumConverter.cs (6)
90if (Unsafe.SizeOf<int>() == Unsafe.SizeOf<TEnum>()) 92integer = Unsafe.As<TEnum, int>(ref value); 102if (Unsafe.SizeOf<int>() == Unsafe.SizeOf<TEnum>()) 104value = Unsafe.As<int, TEnum>(ref integer);
Microsoft.AspNetCore.OutputCaching (10)
FormatterBinaryReader.cs (3)
40return Unsafe.Add(ref _root, _offset++); 143var s = Encoding.UTF8.GetString(MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Add(ref _root, _offset), bytes)); 170var result = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Add(ref _root, _offset), count);
FormatterBinaryWriter.cs (7)
28root = ref Unsafe.NullRef<byte>(); // no buffer initially 39return MemoryMarshal.CreateSpan(ref Unsafe.Add(ref root, offset), length - offset); 47if (Unsafe.IsNullRef(ref root)) 68Unsafe.Add(ref root, offset++) = value; 125if (!Unsafe.IsNullRef(ref root)) 129root = ref Unsafe.NullRef<byte>(); 137Unsafe.Add(ref root, offset++) = value;
Microsoft.AspNetCore.Routing (14)
Matching\ILEmitTrieFactory.cs (14)
546ref var p = ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(span)); 547return Unsafe.ReadUnaligned<ulong>(ref p); 661Add = typeof(Unsafe).GetMethod( 662nameof(Unsafe.Add), 675As = typeof(Unsafe).GetMethod( 676nameof(Unsafe.As), 714ReadUnalignedUInt64 = typeof(Unsafe).GetMethod( 715nameof(Unsafe.ReadUnaligned), 726ReadUnalignedUInt16 = typeof(Unsafe).GetMethod( 727nameof(Unsafe.ReadUnaligned), 740/// <see cref="Unsafe.Add{T}(ref T, int)"/> - Add[ref byte] 745/// <see cref="Unsafe.As{TFrom, TTo}(ref TFrom)"/> - As[char, byte] 760/// <see cref="Unsafe.ReadUnaligned{T}(ref readonly byte)"/> - ReadUnaligned[ulong] 765/// <see cref="Unsafe.ReadUnaligned{T}(ref readonly byte)"/> - ReadUnaligned[ushort]
Microsoft.AspNetCore.Server.HttpSys (7)
RequestProcessing\Response.cs (1)
620Unsafe.SkipInit(out dataChunk);
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
59return (T*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(alloc)); 101return (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(buffer));
src\Shared\HttpSys\RequestProcessing\NativeRequestContext.cs (1)
113ref Unsafe.As<byte, long>(ref MemoryMarshal.GetReference(timingInfo.Span[sizeof(long)..])),
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
Microsoft.AspNetCore.Server.IIS (6)
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
59return (T*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(alloc)); 101return (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(buffer));
src\Shared\HttpSys\RequestProcessing\NativeRequestContext.cs (1)
113ref Unsafe.As<byte, long>(ref MemoryMarshal.GetReference(timingInfo.Span[sizeof(long)..])),
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
Microsoft.AspNetCore.Server.Kestrel.Core (159)
Internal\Http\HttpHeaders.Generated.cs (84)
7486ushort result = Unsafe.ReadUnaligned<ushort>(ref source); 7496uint result = Unsafe.ReadUnaligned<uint>(ref source); 7506ulong result = Unsafe.ReadUnaligned<ulong>(ref source); 7518ref StringValues values = ref Unsafe.NullRef<StringValues>(); 7533if (((ReadUnalignedLittleEndian_ushort(ref nameStart) & 0xdfdfu) == 0x4956u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)2) & 0xdfu) == 0x41u)) 7562if (((ReadUnalignedLittleEndian_uint(ref nameStart) & 0xdfdfdfffu) == 0x5441503au) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)4) & 0xdfu) == 0x48u)) 7568else if (((ReadUnalignedLittleEndian_uint(ref nameStart) & 0xdfdfdfdfu) == 0x474e4152u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)4) & 0xdfu) == 0x45u)) 7577if ((firstTerm6 == 0x45434341u) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x5450u)) 7583else if ((firstTerm6 == 0x4b4f4f43u) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4549u)) 7589else if ((firstTerm6 == 0x45505845u) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x5443u)) 7595else if ((firstTerm6 == 0x4749524fu) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4e49u)) 7601else if ((firstTerm6 == 0x47415250u) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x414du)) 7609if (((ReadUnalignedLittleEndian_uint(ref nameStart) & 0xdfdfdfffu) == 0x54454d3au) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4f48u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x44u)) 7615else if (((ReadUnalignedLittleEndian_uint(ref nameStart) & 0xdfdfdfffu) == 0x4843533au) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4d45u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x45u)) 7621else if (((ReadUnalignedLittleEndian_uint(ref nameStart) & 0xdfdfdfdfu) == 0x47474142u) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4741u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x45u)) 7627else if (((ReadUnalignedLittleEndian_uint(ref nameStart) & 0xdfdfdfdfu) == 0x45464552u) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4552u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x52u)) 7633else if (((ReadUnalignedLittleEndian_uint(ref nameStart) & 0xdfdfdfdfu) == 0x52475055u) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4441u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x45u)) 7639else if (((ReadUnalignedLittleEndian_uint(ref nameStart) & 0xdfdfdfdfu) == 0x4e524157u) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4e49u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x47u)) 7667if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfdfdfdfffuL) == 0x4f434f544f52503auL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)8) & 0xdfu) == 0x4cu)) 7673else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x54414c534e415254uL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)8) & 0xdfu) == 0x45u)) 7681if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x495443454e4e4f43uL) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4e4fu)) 7687else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfffdfdfdfdfuL) == 0x4547412d52455355uL) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x544eu)) 7693else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfdfdfdfffuL) == 0x49524f485455413auL) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x5954u)) 7699else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfffdfdfdfdfuL) == 0x494c412d5045454buL) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4556u)) 7705else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d54534555514552uL) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4449u)) 7711else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x4154534543415254uL) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4554u)) 7719if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x5241504543415254uL) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4e45u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)10) & 0xdfu) == 0x54u)) 7727if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d544e45544e4f43uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x45505954u)) 7733else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfffdfdfdfdfuL) == 0x4d49542d43505247uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x54554f45u)) 7739else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfffdfdfdfuL) == 0x57524f462d58414duL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x53445241u)) 7747if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x5a49524f48545541uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4f495441u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x4eu)) 7753else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfffdfdfdfdfdfuL) == 0x4f432d4548434143uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4f52544eu) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x4cu)) 7759else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfffdfdfdfdfuL) == 0x434e452d43505247uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4e49444fu) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x47u)) 7765else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xffdfdfdfdfffdfdfuL) == 0x2d454e4f4e2d4649uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4354414du) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x48u)) 7773if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfffdfdfdfdfdfdfuL) == 0x432d545045434341uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x53524148u) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x5445u)) 7779else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d544e45544e4f43uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x474e454cu) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x4854u)) 7796if ((firstTerm15 == 0x452d545045434341uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x444f434eu) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x4e49u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)14) & 0xdfu) == 0x47u)) 7802else if ((firstTerm15 == 0x4c2d545045434341uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x55474e41u) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x4741u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)14) & 0xdfu) == 0x45u)) 7810if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfdfffdfdfuL) == 0x4649444f4d2d4649uL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfffdfdfdfuL) == 0x434e49532d444549uL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)16) & 0xdfu) == 0x45u)) 7816else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x524546534e415254uL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfffuL) == 0x4e49444f434e452duL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)16) & 0xdfu) == 0x47u)) 7824if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x54414c4552524f43uL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfffdfdfdfuL) == 0x544e4f432d4e4f49uL) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(8 * sizeof(ushort)))) & 0xdfdfu) == 0x5845u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)18) & 0xdfu) == 0x54u)) 7830else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfdfdfffdfdfuL) == 0x444f4d4e552d4649uL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfffdfdfdfdfdfuL) == 0x49532d4445494649uL) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(8 * sizeof(ushort)))) & 0xdfdfu) == 0x434eu) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)18) & 0xdfu) == 0x45u)) 7836else if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfffdfdfdfdfdfuL) == 0x55412d59584f5250uL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x54415a49524f4854uL) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(8 * sizeof(ushort)))) & 0xdfdfu) == 0x4f49u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)18) & 0xdfu) == 0x4eu)) 7844if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfdfdfffdfdfdfdfuL) == 0x4343412d43505247uL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfffdfdfdfuL) == 0x4f434e452d545045uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x474e4944u)) 7852if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d45444152475055uL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x4552554345534e49uL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ulong)))) & 0xdfdfdfdfdfdfdfffuL) == 0x545345555145522duL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)24) & 0xdfu) == 0x53u)) 7860if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfffdfdfdfdfdfdfuL) == 0x432d535345434341uL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfffdfdfdfdfdfdfuL) == 0x522d4c4f52544e4fuL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ulong)))) & 0xdfffdfdfdfdfdfdfuL) == 0x4d2d545345555145uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4f485445u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)28) & 0xdfu) == 0x44u)) 7868if (((ReadUnalignedLittleEndian_ulong(ref nameStart) & 0xdfffdfdfdfdfdfdfuL) == 0x432d535345434341uL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfffdfdfdfdfdfdfuL) == 0x522d4c4f52544e4fuL) && ((ReadUnalignedLittleEndian_ulong(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ulong)))) & 0xdfffdfdfdfdfdfdfuL) == 0x482d545345555145uL) && ((ReadUnalignedLittleEndian_uint(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x45444145u) && ((ReadUnalignedLittleEndian_ushort(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(14 * sizeof(ushort)))) & 0xdfdfu) == 0x5352u)) 7929ref StringValues values = ref Unsafe.NullRef<StringValues>(); 8141ref StringValues values = ref Unsafe.NullRef<StringValues>(); 14826ref readonly StringValues values = ref Unsafe.NullRef<StringValues>();
Internal\Http\HttpProtocol.Generated.cs (70)
500feature = Unsafe.As<IHttpRequestFeature?, TFeature?>(ref _currentIHttpRequestFeature); 504feature = Unsafe.As<IHttpResponseFeature?, TFeature?>(ref _currentIHttpResponseFeature); 508feature = Unsafe.As<IHttpResponseBodyFeature?, TFeature?>(ref _currentIHttpResponseBodyFeature); 512feature = Unsafe.As<IRouteValuesFeature?, TFeature?>(ref _currentIRouteValuesFeature); 516feature = Unsafe.As<IEndpointFeature?, TFeature?>(ref _currentIEndpointFeature); 520feature = Unsafe.As<IServiceProvidersFeature?, TFeature?>(ref _currentIServiceProvidersFeature); 524feature = Unsafe.As<IHttpActivityFeature?, TFeature?>(ref _currentIHttpActivityFeature); 528feature = Unsafe.As<IHttpMetricsTagsFeature?, TFeature?>(ref _currentIHttpMetricsTagsFeature); 532feature = Unsafe.As<IItemsFeature?, TFeature?>(ref _currentIItemsFeature); 536feature = Unsafe.As<IQueryFeature?, TFeature?>(ref _currentIQueryFeature); 540feature = Unsafe.As<IRequestBodyPipeFeature?, TFeature?>(ref _currentIRequestBodyPipeFeature); 544feature = Unsafe.As<IFormFeature?, TFeature?>(ref _currentIFormFeature); 548feature = Unsafe.As<IHttpAuthenticationFeature?, TFeature?>(ref _currentIHttpAuthenticationFeature); 552feature = Unsafe.As<IHttpRequestIdentifierFeature?, TFeature?>(ref _currentIHttpRequestIdentifierFeature); 556feature = Unsafe.As<IHttpConnectionFeature?, TFeature?>(ref _currentIHttpConnectionFeature); 560feature = Unsafe.As<ISessionFeature?, TFeature?>(ref _currentISessionFeature); 564feature = Unsafe.As<IResponseCookiesFeature?, TFeature?>(ref _currentIResponseCookiesFeature); 568feature = Unsafe.As<IHttpRequestTrailersFeature?, TFeature?>(ref _currentIHttpRequestTrailersFeature); 572feature = Unsafe.As<IHttpResponseTrailersFeature?, TFeature?>(ref _currentIHttpResponseTrailersFeature); 576feature = Unsafe.As<ITlsConnectionFeature?, TFeature?>(ref _currentITlsConnectionFeature); 580feature = Unsafe.As<IHttpExtendedConnectFeature?, TFeature?>(ref _currentIHttpExtendedConnectFeature); 584feature = Unsafe.As<IHttpUpgradeFeature?, TFeature?>(ref _currentIHttpUpgradeFeature); 588feature = Unsafe.As<IHttpWebSocketFeature?, TFeature?>(ref _currentIHttpWebSocketFeature); 592feature = Unsafe.As<IHttpWebTransportFeature?, TFeature?>(ref _currentIHttpWebTransportFeature); 596feature = Unsafe.As<IBadRequestExceptionFeature?, TFeature?>(ref _currentIBadRequestExceptionFeature); 600feature = Unsafe.As<IHttpRequestTimeoutFeature?, TFeature?>(ref _currentIHttpRequestTimeoutFeature); 604feature = Unsafe.As<IHttp2StreamIdFeature?, TFeature?>(ref _currentIHttp2StreamIdFeature); 608feature = Unsafe.As<IHttpRequestLifetimeFeature?, TFeature?>(ref _currentIHttpRequestLifetimeFeature); 612feature = Unsafe.As<IHttpMaxRequestBodySizeFeature?, TFeature?>(ref _currentIHttpMaxRequestBodySizeFeature); 616feature = Unsafe.As<IHttpMinRequestBodyDataRateFeature?, TFeature?>(ref _currentIHttpMinRequestBodyDataRateFeature); 620feature = Unsafe.As<IHttpMinResponseDataRateFeature?, TFeature?>(ref _currentIHttpMinResponseDataRateFeature); 624feature = Unsafe.As<IHttpBodyControlFeature?, TFeature?>(ref _currentIHttpBodyControlFeature); 628feature = Unsafe.As<IHttpRequestBodyDetectionFeature?, TFeature?>(ref _currentIHttpRequestBodyDetectionFeature); 632feature = Unsafe.As<IHttpResetFeature?, TFeature?>(ref _currentIHttpResetFeature); 636feature = Unsafe.As<IPersistentStateFeature?, TFeature?>(ref _currentIPersistentStateFeature); 660_currentIHttpRequestFeature = Unsafe.As<TFeature?, IHttpRequestFeature?>(ref feature); 664_currentIHttpResponseFeature = Unsafe.As<TFeature?, IHttpResponseFeature?>(ref feature); 668_currentIHttpResponseBodyFeature = Unsafe.As<TFeature?, IHttpResponseBodyFeature?>(ref feature); 672_currentIRouteValuesFeature = Unsafe.As<TFeature?, IRouteValuesFeature?>(ref feature); 676_currentIEndpointFeature = Unsafe.As<TFeature?, IEndpointFeature?>(ref feature); 680_currentIServiceProvidersFeature = Unsafe.As<TFeature?, IServiceProvidersFeature?>(ref feature); 684_currentIHttpActivityFeature = Unsafe.As<TFeature?, IHttpActivityFeature?>(ref feature); 688_currentIHttpMetricsTagsFeature = Unsafe.As<TFeature?, IHttpMetricsTagsFeature?>(ref feature); 692_currentIItemsFeature = Unsafe.As<TFeature?, IItemsFeature?>(ref feature); 696_currentIQueryFeature = Unsafe.As<TFeature?, IQueryFeature?>(ref feature); 700_currentIRequestBodyPipeFeature = Unsafe.As<TFeature?, IRequestBodyPipeFeature?>(ref feature); 704_currentIFormFeature = Unsafe.As<TFeature?, IFormFeature?>(ref feature); 708_currentIHttpAuthenticationFeature = Unsafe.As<TFeature?, IHttpAuthenticationFeature?>(ref feature); 712_currentIHttpRequestIdentifierFeature = Unsafe.As<TFeature?, IHttpRequestIdentifierFeature?>(ref feature); 716_currentIHttpConnectionFeature = Unsafe.As<TFeature?, IHttpConnectionFeature?>(ref feature); 720_currentISessionFeature = Unsafe.As<TFeature?, ISessionFeature?>(ref feature); 724_currentIResponseCookiesFeature = Unsafe.As<TFeature?, IResponseCookiesFeature?>(ref feature); 728_currentIHttpRequestTrailersFeature = Unsafe.As<TFeature?, IHttpRequestTrailersFeature?>(ref feature); 732_currentIHttpResponseTrailersFeature = Unsafe.As<TFeature?, IHttpResponseTrailersFeature?>(ref feature); 736_currentITlsConnectionFeature = Unsafe.As<TFeature?, ITlsConnectionFeature?>(ref feature); 740_currentIHttpExtendedConnectFeature = Unsafe.As<TFeature?, IHttpExtendedConnectFeature?>(ref feature); 744_currentIHttpUpgradeFeature = Unsafe.As<TFeature?, IHttpUpgradeFeature?>(ref feature); 748_currentIHttpWebSocketFeature = Unsafe.As<TFeature?, IHttpWebSocketFeature?>(ref feature); 752_currentIHttpWebTransportFeature = Unsafe.As<TFeature?, IHttpWebTransportFeature?>(ref feature); 756_currentIBadRequestExceptionFeature = Unsafe.As<TFeature?, IBadRequestExceptionFeature?>(ref feature); 760_currentIHttpRequestTimeoutFeature = Unsafe.As<TFeature?, IHttpRequestTimeoutFeature?>(ref feature); 764_currentIHttp2StreamIdFeature = Unsafe.As<TFeature?, IHttp2StreamIdFeature?>(ref feature); 768_currentIHttpRequestLifetimeFeature = Unsafe.As<TFeature?, IHttpRequestLifetimeFeature?>(ref feature); 772_currentIHttpMaxRequestBodySizeFeature = Unsafe.As<TFeature?, IHttpMaxRequestBodySizeFeature?>(ref feature); 776_currentIHttpMinRequestBodyDataRateFeature = Unsafe.As<TFeature?, IHttpMinRequestBodyDataRateFeature?>(ref feature); 780_currentIHttpMinResponseDataRateFeature = Unsafe.As<TFeature?, IHttpMinResponseDataRateFeature?>(ref feature); 784_currentIHttpBodyControlFeature = Unsafe.As<TFeature?, IHttpBodyControlFeature?>(ref feature); 788_currentIHttpRequestBodyDetectionFeature = Unsafe.As<TFeature?, IHttpRequestBodyDetectionFeature?>(ref feature); 792_currentIHttpResetFeature = Unsafe.As<TFeature?, IHttpResetFeature?>(ref feature); 796_currentIPersistentStateFeature = Unsafe.As<TFeature?, IPersistentStateFeature?>(ref feature);
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
59return (T*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(alloc)); 101return (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(buffer));
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (26)
src\Servers\Kestrel\shared\TransportConnection.Generated.cs (26)
263feature = Unsafe.As<IConnectionIdFeature?, TFeature?>(ref _currentIConnectionIdFeature); 267feature = Unsafe.As<IConnectionTransportFeature?, TFeature?>(ref _currentIConnectionTransportFeature); 271feature = Unsafe.As<IConnectionItemsFeature?, TFeature?>(ref _currentIConnectionItemsFeature); 275feature = Unsafe.As<IPersistentStateFeature?, TFeature?>(ref _currentIPersistentStateFeature); 279feature = Unsafe.As<IMemoryPoolFeature?, TFeature?>(ref _currentIMemoryPoolFeature); 283feature = Unsafe.As<IConnectionLifetimeFeature?, TFeature?>(ref _currentIConnectionLifetimeFeature); 287feature = Unsafe.As<IConnectionSocketFeature?, TFeature?>(ref _currentIConnectionSocketFeature); 291feature = Unsafe.As<IProtocolErrorCodeFeature?, TFeature?>(ref _currentIProtocolErrorCodeFeature); 295feature = Unsafe.As<IStreamDirectionFeature?, TFeature?>(ref _currentIStreamDirectionFeature); 299feature = Unsafe.As<IStreamIdFeature?, TFeature?>(ref _currentIStreamIdFeature); 303feature = Unsafe.As<IStreamAbortFeature?, TFeature?>(ref _currentIStreamAbortFeature); 307feature = Unsafe.As<IStreamClosedFeature?, TFeature?>(ref _currentIStreamClosedFeature); 311feature = Unsafe.As<IConnectionMetricsTagsFeature?, TFeature?>(ref _currentIConnectionMetricsTagsFeature); 335_currentIConnectionIdFeature = Unsafe.As<TFeature?, IConnectionIdFeature?>(ref feature); 339_currentIConnectionTransportFeature = Unsafe.As<TFeature?, IConnectionTransportFeature?>(ref feature); 343_currentIConnectionItemsFeature = Unsafe.As<TFeature?, IConnectionItemsFeature?>(ref feature); 347_currentIPersistentStateFeature = Unsafe.As<TFeature?, IPersistentStateFeature?>(ref feature); 351_currentIMemoryPoolFeature = Unsafe.As<TFeature?, IMemoryPoolFeature?>(ref feature); 355_currentIConnectionLifetimeFeature = Unsafe.As<TFeature?, IConnectionLifetimeFeature?>(ref feature); 359_currentIConnectionSocketFeature = Unsafe.As<TFeature?, IConnectionSocketFeature?>(ref feature); 363_currentIProtocolErrorCodeFeature = Unsafe.As<TFeature?, IProtocolErrorCodeFeature?>(ref feature); 367_currentIStreamDirectionFeature = Unsafe.As<TFeature?, IStreamDirectionFeature?>(ref feature); 371_currentIStreamIdFeature = Unsafe.As<TFeature?, IStreamIdFeature?>(ref feature); 375_currentIStreamAbortFeature = Unsafe.As<TFeature?, IStreamAbortFeature?>(ref feature); 379_currentIStreamClosedFeature = Unsafe.As<TFeature?, IStreamClosedFeature?>(ref feature); 383_currentIConnectionMetricsTagsFeature = Unsafe.As<TFeature?, IConnectionMetricsTagsFeature?>(ref feature);
Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes (28)
src\Servers\Kestrel\shared\TransportConnection.Generated.cs (26)
263feature = Unsafe.As<IConnectionIdFeature?, TFeature?>(ref _currentIConnectionIdFeature); 267feature = Unsafe.As<IConnectionTransportFeature?, TFeature?>(ref _currentIConnectionTransportFeature); 271feature = Unsafe.As<IConnectionItemsFeature?, TFeature?>(ref _currentIConnectionItemsFeature); 275feature = Unsafe.As<IPersistentStateFeature?, TFeature?>(ref _currentIPersistentStateFeature); 279feature = Unsafe.As<IMemoryPoolFeature?, TFeature?>(ref _currentIMemoryPoolFeature); 283feature = Unsafe.As<IConnectionLifetimeFeature?, TFeature?>(ref _currentIConnectionLifetimeFeature); 287feature = Unsafe.As<IConnectionSocketFeature?, TFeature?>(ref _currentIConnectionSocketFeature); 291feature = Unsafe.As<IProtocolErrorCodeFeature?, TFeature?>(ref _currentIProtocolErrorCodeFeature); 295feature = Unsafe.As<IStreamDirectionFeature?, TFeature?>(ref _currentIStreamDirectionFeature); 299feature = Unsafe.As<IStreamIdFeature?, TFeature?>(ref _currentIStreamIdFeature); 303feature = Unsafe.As<IStreamAbortFeature?, TFeature?>(ref _currentIStreamAbortFeature); 307feature = Unsafe.As<IStreamClosedFeature?, TFeature?>(ref _currentIStreamClosedFeature); 311feature = Unsafe.As<IConnectionMetricsTagsFeature?, TFeature?>(ref _currentIConnectionMetricsTagsFeature); 335_currentIConnectionIdFeature = Unsafe.As<TFeature?, IConnectionIdFeature?>(ref feature); 339_currentIConnectionTransportFeature = Unsafe.As<TFeature?, IConnectionTransportFeature?>(ref feature); 343_currentIConnectionItemsFeature = Unsafe.As<TFeature?, IConnectionItemsFeature?>(ref feature); 347_currentIPersistentStateFeature = Unsafe.As<TFeature?, IPersistentStateFeature?>(ref feature); 351_currentIMemoryPoolFeature = Unsafe.As<TFeature?, IMemoryPoolFeature?>(ref feature); 355_currentIConnectionLifetimeFeature = Unsafe.As<TFeature?, IConnectionLifetimeFeature?>(ref feature); 359_currentIConnectionSocketFeature = Unsafe.As<TFeature?, IConnectionSocketFeature?>(ref feature); 363_currentIProtocolErrorCodeFeature = Unsafe.As<TFeature?, IProtocolErrorCodeFeature?>(ref feature); 367_currentIStreamDirectionFeature = Unsafe.As<TFeature?, IStreamDirectionFeature?>(ref feature); 371_currentIStreamIdFeature = Unsafe.As<TFeature?, IStreamIdFeature?>(ref feature); 375_currentIStreamAbortFeature = Unsafe.As<TFeature?, IStreamAbortFeature?>(ref feature); 379_currentIStreamClosedFeature = Unsafe.As<TFeature?, IStreamClosedFeature?>(ref feature); 383_currentIConnectionMetricsTagsFeature = Unsafe.As<TFeature?, IConnectionMetricsTagsFeature?>(ref feature);
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
59return (T*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(alloc)); 101return (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(buffer));
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (45)
src\Servers\Kestrel\shared\TransportConnection.Generated.cs (26)
263feature = Unsafe.As<IConnectionIdFeature?, TFeature?>(ref _currentIConnectionIdFeature); 267feature = Unsafe.As<IConnectionTransportFeature?, TFeature?>(ref _currentIConnectionTransportFeature); 271feature = Unsafe.As<IConnectionItemsFeature?, TFeature?>(ref _currentIConnectionItemsFeature); 275feature = Unsafe.As<IPersistentStateFeature?, TFeature?>(ref _currentIPersistentStateFeature); 279feature = Unsafe.As<IMemoryPoolFeature?, TFeature?>(ref _currentIMemoryPoolFeature); 283feature = Unsafe.As<IConnectionLifetimeFeature?, TFeature?>(ref _currentIConnectionLifetimeFeature); 287feature = Unsafe.As<IConnectionSocketFeature?, TFeature?>(ref _currentIConnectionSocketFeature); 291feature = Unsafe.As<IProtocolErrorCodeFeature?, TFeature?>(ref _currentIProtocolErrorCodeFeature); 295feature = Unsafe.As<IStreamDirectionFeature?, TFeature?>(ref _currentIStreamDirectionFeature); 299feature = Unsafe.As<IStreamIdFeature?, TFeature?>(ref _currentIStreamIdFeature); 303feature = Unsafe.As<IStreamAbortFeature?, TFeature?>(ref _currentIStreamAbortFeature); 307feature = Unsafe.As<IStreamClosedFeature?, TFeature?>(ref _currentIStreamClosedFeature); 311feature = Unsafe.As<IConnectionMetricsTagsFeature?, TFeature?>(ref _currentIConnectionMetricsTagsFeature); 335_currentIConnectionIdFeature = Unsafe.As<TFeature?, IConnectionIdFeature?>(ref feature); 339_currentIConnectionTransportFeature = Unsafe.As<TFeature?, IConnectionTransportFeature?>(ref feature); 343_currentIConnectionItemsFeature = Unsafe.As<TFeature?, IConnectionItemsFeature?>(ref feature); 347_currentIPersistentStateFeature = Unsafe.As<TFeature?, IPersistentStateFeature?>(ref feature); 351_currentIMemoryPoolFeature = Unsafe.As<TFeature?, IMemoryPoolFeature?>(ref feature); 355_currentIConnectionLifetimeFeature = Unsafe.As<TFeature?, IConnectionLifetimeFeature?>(ref feature); 359_currentIConnectionSocketFeature = Unsafe.As<TFeature?, IConnectionSocketFeature?>(ref feature); 363_currentIProtocolErrorCodeFeature = Unsafe.As<TFeature?, IProtocolErrorCodeFeature?>(ref feature); 367_currentIStreamDirectionFeature = Unsafe.As<TFeature?, IStreamDirectionFeature?>(ref feature); 371_currentIStreamIdFeature = Unsafe.As<TFeature?, IStreamIdFeature?>(ref feature); 375_currentIStreamAbortFeature = Unsafe.As<TFeature?, IStreamAbortFeature?>(ref feature); 379_currentIStreamClosedFeature = Unsafe.As<TFeature?, IStreamClosedFeature?>(ref feature); 383_currentIConnectionMetricsTagsFeature = Unsafe.As<TFeature?, IConnectionMetricsTagsFeature?>(ref feature);
src\Servers\Kestrel\shared\TransportMultiplexedConnection.Generated.cs (14)
202feature = Unsafe.As<IConnectionIdFeature?, TFeature?>(ref _currentIConnectionIdFeature); 206feature = Unsafe.As<IConnectionTransportFeature?, TFeature?>(ref _currentIConnectionTransportFeature); 210feature = Unsafe.As<IConnectionItemsFeature?, TFeature?>(ref _currentIConnectionItemsFeature); 214feature = Unsafe.As<IMemoryPoolFeature?, TFeature?>(ref _currentIMemoryPoolFeature); 218feature = Unsafe.As<IConnectionLifetimeFeature?, TFeature?>(ref _currentIConnectionLifetimeFeature); 222feature = Unsafe.As<IProtocolErrorCodeFeature?, TFeature?>(ref _currentIProtocolErrorCodeFeature); 226feature = Unsafe.As<ITlsConnectionFeature?, TFeature?>(ref _currentITlsConnectionFeature); 245_currentIConnectionIdFeature = Unsafe.As<TFeature?, IConnectionIdFeature?>(ref feature); 249_currentIConnectionTransportFeature = Unsafe.As<TFeature?, IConnectionTransportFeature?>(ref feature); 253_currentIConnectionItemsFeature = Unsafe.As<TFeature?, IConnectionItemsFeature?>(ref feature); 257_currentIMemoryPoolFeature = Unsafe.As<TFeature?, IMemoryPoolFeature?>(ref feature); 261_currentIConnectionLifetimeFeature = Unsafe.As<TFeature?, IConnectionLifetimeFeature?>(ref feature); 265_currentIProtocolErrorCodeFeature = Unsafe.As<TFeature?, IProtocolErrorCodeFeature?>(ref feature); 269_currentITlsConnectionFeature = Unsafe.As<TFeature?, ITlsConnectionFeature?>(ref feature);
src\Shared\Buffers.MemoryPool\UnmanagedBufferAllocator.cs (2)
59return (T*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(alloc)); 101return (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(buffer));
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (26)
src\Servers\Kestrel\shared\TransportConnection.Generated.cs (26)
263feature = Unsafe.As<IConnectionIdFeature?, TFeature?>(ref _currentIConnectionIdFeature); 267feature = Unsafe.As<IConnectionTransportFeature?, TFeature?>(ref _currentIConnectionTransportFeature); 271feature = Unsafe.As<IConnectionItemsFeature?, TFeature?>(ref _currentIConnectionItemsFeature); 275feature = Unsafe.As<IPersistentStateFeature?, TFeature?>(ref _currentIPersistentStateFeature); 279feature = Unsafe.As<IMemoryPoolFeature?, TFeature?>(ref _currentIMemoryPoolFeature); 283feature = Unsafe.As<IConnectionLifetimeFeature?, TFeature?>(ref _currentIConnectionLifetimeFeature); 287feature = Unsafe.As<IConnectionSocketFeature?, TFeature?>(ref _currentIConnectionSocketFeature); 291feature = Unsafe.As<IProtocolErrorCodeFeature?, TFeature?>(ref _currentIProtocolErrorCodeFeature); 295feature = Unsafe.As<IStreamDirectionFeature?, TFeature?>(ref _currentIStreamDirectionFeature); 299feature = Unsafe.As<IStreamIdFeature?, TFeature?>(ref _currentIStreamIdFeature); 303feature = Unsafe.As<IStreamAbortFeature?, TFeature?>(ref _currentIStreamAbortFeature); 307feature = Unsafe.As<IStreamClosedFeature?, TFeature?>(ref _currentIStreamClosedFeature); 311feature = Unsafe.As<IConnectionMetricsTagsFeature?, TFeature?>(ref _currentIConnectionMetricsTagsFeature); 335_currentIConnectionIdFeature = Unsafe.As<TFeature?, IConnectionIdFeature?>(ref feature); 339_currentIConnectionTransportFeature = Unsafe.As<TFeature?, IConnectionTransportFeature?>(ref feature); 343_currentIConnectionItemsFeature = Unsafe.As<TFeature?, IConnectionItemsFeature?>(ref feature); 347_currentIPersistentStateFeature = Unsafe.As<TFeature?, IPersistentStateFeature?>(ref feature); 351_currentIMemoryPoolFeature = Unsafe.As<TFeature?, IMemoryPoolFeature?>(ref feature); 355_currentIConnectionLifetimeFeature = Unsafe.As<TFeature?, IConnectionLifetimeFeature?>(ref feature); 359_currentIConnectionSocketFeature = Unsafe.As<TFeature?, IConnectionSocketFeature?>(ref feature); 363_currentIProtocolErrorCodeFeature = Unsafe.As<TFeature?, IProtocolErrorCodeFeature?>(ref feature); 367_currentIStreamDirectionFeature = Unsafe.As<TFeature?, IStreamDirectionFeature?>(ref feature); 371_currentIStreamIdFeature = Unsafe.As<TFeature?, IStreamIdFeature?>(ref feature); 375_currentIStreamAbortFeature = Unsafe.As<TFeature?, IStreamAbortFeature?>(ref feature); 379_currentIStreamClosedFeature = Unsafe.As<TFeature?, IStreamClosedFeature?>(ref feature); 383_currentIConnectionMetricsTagsFeature = Unsafe.As<TFeature?, IConnectionMetricsTagsFeature?>(ref feature);
Microsoft.AspNetCore.Shared.Tests (4)
src\Shared\HttpSys\RequestProcessing\NativeRequestContext.cs (1)
113ref Unsafe.As<byte, long>(ref MemoryMarshal.GetReference(timingInfo.Span[sizeof(long)..])),
src\Shared\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
Microsoft.Build.Framework (19)
ArraySortHelper.cs (2)
410Debug.Assert(!Unsafe.AreSame(ref i, ref j)); 1298return Unsafe.AddByteOffset(
ImmutableSegmentedDictionary`2+PrivateInterlocked.cs (3)
19var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 28var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 37var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
ImmutableSegmentedList`1+PrivateInterlocked.cs (3)
19var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 28var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 37var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
RoslynUnsafe.cs (2)
16=> ref Unsafe.AsRef<T>(null); 26=> Unsafe.AsPointer(ref source) == null;
SegmentedArray`1.cs (1)
26/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
SegmentedArrayHelper.cs (8)
29if (Unsafe.SizeOf<T>() == Unsafe.SizeOf<object>()) 42if (Unsafe.SizeOf<T>() == Unsafe.SizeOf<object>()) 55if (Unsafe.SizeOf<T>() == Unsafe.SizeOf<object>()) 138public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<object>()); 145public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
Microsoft.CodeAnalysis (29)
Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (7)
23return Unsafe.SizeOf<T>() switch 40_ => InlineCalculateSegmentSize(Unsafe.SizeOf<T>()), 50return Unsafe.SizeOf<T>() switch 67_ => InlineCalculateSegmentShift(Unsafe.SizeOf<T>()), 77return Unsafe.SizeOf<T>() switch 94_ => InlineCalculateOffsetMask(Unsafe.SizeOf<T>()), 175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
Microsoft.CodeAnalysis.Analyzers (52)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\ModifierExtensions.cs (1)
16return Unsafe.As<Modifiers, DeclarationModifiers>(ref modifiers);
Microsoft.CodeAnalysis.AnalyzerUtilities (51)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
Microsoft.CodeAnalysis.BannedApiAnalyzers (52)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\ModifierExtensions.cs (1)
16return Unsafe.As<Modifiers, DeclarationModifiers>(ref modifiers);
Microsoft.CodeAnalysis.CodeStyle (51)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\ModifierExtensions.cs (1)
16return Unsafe.As<Modifiers, DeclarationModifiers>(ref modifiers);
Microsoft.CodeAnalysis.Collections.Package (18)
Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
Microsoft.CodeAnalysis.CSharp (3)
Compilation\CSharpCompilation.cs (1)
2587Debug.Assert(System.Runtime.CompilerServices.Unsafe.AreSame(ref cachedBinderFactories, ref ignoreAccessibility ? ref _ignoreAccessibilityBinderFactories : ref _binderFactories));
Parser\Directives.cs (1)
132=> Interlocked.CompareExchange(ref Unsafe.AsRef(in location._directives), value._directives, null);
Symbols\Metadata\PE\PENamedTypeSymbol.cs (1)
1955var result = (TypeKind)Volatile.Read(ref Unsafe.As<TypeKind, byte>(ref _lazyKind));
Microsoft.CodeAnalysis.CSharp.CodeStyle (2)
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (2)
154if (Unsafe.IsNullRef(ref valueRef)) 174if (Unsafe.IsNullRef(ref valueRef))
Microsoft.CodeAnalysis.CSharp.Features (2)
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (2)
154if (Unsafe.IsNullRef(ref valueRef)) 174if (Unsafe.IsNullRef(ref valueRef))
Microsoft.CodeAnalysis.Extensions.Package (18)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
Microsoft.CodeAnalysis.Features (1)
QuickInfo\Presentation\TaggedTextExtensions.cs (1)
122=> ref Unsafe.AsRef(in builder);
Microsoft.CodeAnalysis.InteractiveHost (18)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (52)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\ModifierExtensions.cs (1)
16return Unsafe.As<Modifiers, DeclarationModifiers>(ref modifiers);
Microsoft.CodeAnalysis.PublicApiAnalyzers (51)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
Microsoft.CodeAnalysis.ResxSourceGenerator (51)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
Microsoft.CodeAnalysis.Test.Utilities (1)
Platform\Desktop\TestHelpers.cs (1)
78dir.CopyFile(typeof(System.Runtime.CompilerServices.Unsafe).Assembly.Location);
Microsoft.CodeAnalysis.Threading.Package (18)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
Microsoft.CodeAnalysis.UnitTests (21)
Analyzers\AnalyzerFileReferenceAppDomainTests.cs (1)
86dir.CopyFile(typeof(System.Runtime.CompilerServices.Unsafe).Assembly.Location);
Collections\ImmutableSegmentedListBuilderTest.cs (1)
383ref var unsafeRef = ref Unsafe.AsRef(in safeRef);
Collections\ImmutableSegmentedListTest.cs (1)
818ref var unsafeRef = ref Unsafe.AsRef(in safeRef);
Collections\SegmentedArrayHelperTests.cs (2)
106var unsafeSizeOfMethod = typeof(Unsafe).GetMethod(nameof(Unsafe.SizeOf)).MakeGenericMethod(type);
Collections\SegmentedCollectionsMarshalTests.cs (16)
67Assert.True(Unsafe.IsNullRef(ref SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3))); 123Assert.True(Unsafe.IsNullRef(ref SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3))); 202Assert.True(Unsafe.IsNullRef(ref Unsafe.AsRef(in SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3)))); 249Assert.True(Unsafe.IsNullRef(ref Unsafe.AsRef(in SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3)))); 303Assert.True(Unsafe.IsNullRef(ref SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3))); 357Assert.True(Unsafe.IsNullRef(ref SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3))); 446ref T actualRef = ref Unsafe.AsRef(in immutableList.ItemRef(0)); 448Assert.True(Unsafe.AreSame(ref expectedRef, ref actualRef)); 512ref T expectedRef = ref Unsafe.AsRef(in immutableList.ItemRef(0)); 515Assert.True(Unsafe.AreSame(ref expectedRef, ref actualRef)); 708ref TValue actualRef = ref Unsafe.AsRef(in SegmentedCollectionsMarshal.GetValueRefOrNullRef(immutableDictionary, 0)); 710Assert.True(Unsafe.AreSame(ref expectedRef, ref actualRef)); 774ref T expectedRef = ref Unsafe.AsRef(in SegmentedCollectionsMarshal.GetValueRefOrNullRef(immutableDictionary, 0)); 777Assert.True(Unsafe.AreSame(ref expectedRef, ref actualRef));
Microsoft.CodeAnalysis.Workspaces (55)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (7)
23return Unsafe.SizeOf<T>() switch 40_ => InlineCalculateSegmentSize(Unsafe.SizeOf<T>()), 50return Unsafe.SizeOf<T>() switch 67_ => InlineCalculateSegmentShift(Unsafe.SizeOf<T>()), 77return Unsafe.SizeOf<T>() switch 94_ => InlineCalculateOffsetMask(Unsafe.SizeOf<T>()), 175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
Workspace\Solution\Checksum.cs (1)
89Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(span), this);
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (21)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (7)
23return Unsafe.SizeOf<T>() switch 40_ => InlineCalculateSegmentSize(Unsafe.SizeOf<T>()), 50return Unsafe.SizeOf<T>() switch 67_ => InlineCalculateSegmentShift(Unsafe.SizeOf<T>()), 77return Unsafe.SizeOf<T>() switch 94_ => InlineCalculateOffsetMask(Unsafe.SizeOf<T>()), 175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
Microsoft.Data.Analysis (15)
DataFrameColumns\StringDataFrameColumn.cs (1)
21public static int MaxCapacity = ArrayUtility.ArrayMaxSize / Unsafe.SizeOf<IntPtr>(); // Max Size in bytes / size of pointer (8 bytes on x64)
DataFrameColumns\VBufferDataFrameColumn.cs (1)
20public static int MaxCapacity = ArrayUtility.ArrayMaxSize / Unsafe.SizeOf<VBuffer<T>>();
PrimitiveColumnContainer.cs (1)
552ReadOnlyDataFrameBuffer<bool> boolLocalBuffer = Unsafe.As<ReadOnlyDataFrameBuffer<T>, ReadOnlyDataFrameBuffer<bool>>(ref localBuffer);
PrimitiveDataFrameColumn.cs (9)
1058newColumn._columnContainer.HandleOperation(operation, Unsafe.As<U, T>(ref value)); 1093newColumn._columnContainer.HandleOperation(operation, Unsafe.As<U, T>(ref value)); 1135newColumn._columnContainer.HandleReverseOperation(operation, Unsafe.As<U, T>(ref value)); 1169newColumn._columnContainer.HandleReverseOperation(operation, Unsafe.As<U, T>(ref value)); 1207retColumn._columnContainer.HandleOperation(operation, Unsafe.As<U, bool>(ref value)); 1364return new BooleanDataFrameColumn(Name, (this as PrimitiveDataFrameColumn<bool>)._columnContainer.HandleOperation(operation, Unsafe.As<U, bool>(ref value))); 1374return new BooleanDataFrameColumn(Name, primitiveColumn._columnContainer.HandleOperation(operation, Unsafe.As<U, T>(ref value))); 1386return new BooleanDataFrameColumn(Name, (this as PrimitiveDataFrameColumn<DateTime>)._columnContainer.HandleOperation(operation, Unsafe.As<U, DateTime>(ref value))); 1406return new BooleanDataFrameColumn(Name, primitiveColumn._columnContainer.HandleOperation(operation, Unsafe.As<U, T>(ref value)));
PrimitiveDataFrameColumn.Sort.cs (1)
63ReadOnlyMemory<T> typedBuffer = Unsafe.As<ReadOnlyMemory<byte>, ReadOnlyMemory<T>>(ref buffer);
ReadOnlyDataFrameBuffer.cs (2)
31return Unsafe.As<ReadOnlyMemory<byte>, ReadOnlyMemory<T>>(ref memory); 35protected static int Size = Unsafe.SizeOf<T>();
Microsoft.DotNet.Build.Tasks.Installers (1)
src\RpmHeader.cs (1)
356Offset = -(Entries.Count + 1) * Unsafe.SizeOf<IndexEntry>(),
Microsoft.Extensions.Caching.Hybrid (8)
Internal\BufferChunk.cs (2)
83Unsafe.AsRef(in this) = default; // anti foot-shotgun double-return guard; not 100%, but worth doing 97Unsafe.AsRef(in copy._lengthAndPoolFlag) &= ~FlagReturnToPool;
Internal\DefaultHybridCache.CacheItem.cs (1)
44=> Unsafe.AsRef(in _creationTimestamp) = timestamp;
Internal\DefaultHybridCache.cs (1)
60internal void DebugRemoveFeatures(CacheFeatures features) => Unsafe.AsRef(in _features) &= ~features;
Internal\DefaultHybridCache.L2.cs (2)
48IBufferDistributedCache cache = Unsafe.As<IBufferDistributedCache>(_backendCache!); // type-checked already 99IBufferDistributedCache cache = Unsafe.As<IBufferDistributedCache>(_backendCache!); // type-checked already
Internal\DefaultHybridCache.Serialization.cs (1)
25? Unsafe.As<IHybridCacheSerializer<T>>(serializer) : ResolveAndAddSerializer(this);
Internal\DefaultHybridCache.StampedeState.cs (1)
70protected static readonly WaitCallback SharedWaitCallback = static obj => Unsafe.As<StampedeState>(obj).Execute();
Microsoft.Extensions.Compliance.Abstractions (1)
src\Shared\RentedSpan\RentedSpan.cs (1)
54var size = Unsafe.SizeOf<T>() * length;
Microsoft.Extensions.Diagnostics.ResourceMonitoring (1)
src\Shared\RentedSpan\RentedSpan.cs (1)
54var size = Unsafe.SizeOf<T>() * length;
Microsoft.Extensions.Logging.EventSource (1)
LoggingEventSource.cs (1)
577eventData.DataPointer = (IntPtr)Unsafe.AsPointer(ref value);
Microsoft.Extensions.Primitives (10)
InplaceStringBuilder.cs (1)
105Unsafe.CopyBlockUnaligned(destination + _offset, source + offset, (uint)count * 2);
StringValues.cs (9)
109return Unsafe.As<string?[]>(value).Length; 150return Unsafe.As<string?[]>(value)[index]; // may throw 194string?[] values = Unsafe.As<string?[]>(value); 293return new[] { Unsafe.As<string>(value) }; 330return string.Equals(Unsafe.As<string>(value), item, StringComparison.Ordinal) ? 0 : -1; 384array[arrayIndex] = Unsafe.As<string>(value); 441return string.IsNullOrEmpty(Unsafe.As<string>(data)); 756return Unsafe.As<string>(value)?.GetHashCode() ?? Count.GetHashCode(); 779_values = Unsafe.As<string?[]>(value);
Microsoft.Extensions.Telemetry (2)
src\Shared\LogBuffering\SerializedLogRecordFactory.cs (1)
18private static readonly int _serializedLogRecordSize = Unsafe.SizeOf<SerializedLogRecord>();
src\Shared\RentedSpan\RentedSpan.cs (1)
54var size = Unsafe.SizeOf<T>() * length;
Microsoft.Maui.Controls.BindingSourceGen (3)
EquatableArray.cs (3)
17 this.array = Unsafe.As<ImmutableArray<T>, T[]?>(ref array); 65 return Unsafe.As<T[]?, ImmutableArray<T>>(ref Unsafe.AsRef(in this.array));
Microsoft.ML.CpuMath (1)
FactorizationMachine\AvxIntrinsics.cs (1)
67Unsafe.InitBlock(pq, 0, (uint)(m * m * d * sizeof(float)));
Microsoft.ML.Data (1)
TrainCatalog.cs (1)
109scoredTest = (Unsafe.As<TransformerChain<ITransformer>>(model)).Transform(split.TestSet, TransformerScope.Everything);
Microsoft.NET.StringTools (2)
InternableString.cs (2)
249Unsafe.CopyBlockUnaligned(destPtr, sourcePtr, 2 * (uint)_inlineSpan.Length); 262Unsafe.CopyBlockUnaligned(destPtr, sourcePtr, 2 * (uint)span.Length);
PresentationCore (32)
MS\Internal\Interop\DWrite\IDWriteFactory.cs (11)
14return ((delegate* unmanaged<IDWriteFactory*, Guid*, void**, int>)(lpVtbl[0]))((IDWriteFactory*)Unsafe.AsPointer(ref this), riid, ppvObject); 19return ((delegate* unmanaged<IDWriteFactory*, uint>)(lpVtbl[1]))((IDWriteFactory*)Unsafe.AsPointer(ref this)); 24return ((delegate* unmanaged<IDWriteFactory*, uint>)(lpVtbl[2]))((IDWriteFactory*)Unsafe.AsPointer(ref this)); 29return ((delegate* unmanaged<IDWriteFactory*, IDWriteFontCollection**, int, int>)(lpVtbl[3]))((IDWriteFactory*)Unsafe.AsPointer(ref this), fontCollection, checkForUpdates); 34return ((delegate* unmanaged<IDWriteFactory*, IDWriteFontCollectionLoader*, void*, uint, IDWriteFontCollection**, int>)(lpVtbl[4]))((IDWriteFactory*)Unsafe.AsPointer(ref this), collectionLoader, collectionKey, collectionKeySize, fontCollection); 39return ((delegate* unmanaged<IDWriteFactory*, IDWriteFontCollectionLoader*, int>)(lpVtbl[5]))((IDWriteFactory*)Unsafe.AsPointer(ref this), fontCollectionLoader); 44return ((delegate* unmanaged<IDWriteFactory*, IDWriteFontCollectionLoader*, int>)(lpVtbl[6]))((IDWriteFactory*)Unsafe.AsPointer(ref this), fontCollectionLoader); 49return ((delegate* unmanaged<IDWriteFactory*, DWRITE_FONT_FACE_TYPE, uint, IDWriteFontFile**, uint, DWRITE_FONT_SIMULATIONS, IDWriteFontFace**, int>)(lpVtbl[9]))((IDWriteFactory*)Unsafe.AsPointer(ref this), fontFaceType, numberOfFiles, fontFiles, faceIndex, fontFaceSimulationFlags, fontFace); 54return ((delegate* unmanaged<IDWriteFactory*, IDWriteFontFileLoader*, int>)(lpVtbl[13]))((IDWriteFactory*)Unsafe.AsPointer(ref this), fontFileLoader); 59return ((delegate* unmanaged<IDWriteFactory*, IDWriteFontFileLoader*, int>)(lpVtbl[14]))((IDWriteFactory*)Unsafe.AsPointer(ref this), fontFileLoader); 64return ((delegate* unmanaged<IDWriteFactory*, IDWriteTextAnalyzer**, int>)(lpVtbl[21]))((IDWriteFactory*)Unsafe.AsPointer(ref this), textAnalyzer);
MS\Internal\Interop\DWrite\IDWriteFontCollection.cs (3)
14return ((delegate* unmanaged<IDWriteFontCollection*, Guid*, void**, int>)(lpVtbl[0]))((IDWriteFontCollection*)Unsafe.AsPointer(ref this), riid, ppvObject); 19return ((delegate* unmanaged<IDWriteFontCollection*, uint>)(lpVtbl[1]))((IDWriteFontCollection*)Unsafe.AsPointer(ref this)); 24return ((delegate* unmanaged<IDWriteFontCollection*, uint>)(lpVtbl[2]))((IDWriteFontCollection*)Unsafe.AsPointer(ref this));
MS\Internal\Interop\DWrite\IDWriteFontCollectionLoader.cs (3)
14return ((delegate* unmanaged<IDWriteFontCollectionLoader*, Guid*, void**, int>)(lpVtbl[0]))((IDWriteFontCollectionLoader*)Unsafe.AsPointer(ref this), riid, ppvObject); 19return ((delegate* unmanaged<IDWriteFontCollectionLoader*, uint>)(lpVtbl[1]))((IDWriteFontCollectionLoader*)Unsafe.AsPointer(ref this)); 24return ((delegate* unmanaged<IDWriteFontCollectionLoader*, uint>)(lpVtbl[2]))((IDWriteFontCollectionLoader*)Unsafe.AsPointer(ref this));
MS\Internal\Interop\DWrite\IDWriteFontFace.cs (3)
14return ((delegate* unmanaged<IDWriteFontFace*, Guid*, void**, int>)(lpVtbl[0]))((IDWriteFontFace*)Unsafe.AsPointer(ref this), riid, ppvObject); 19return ((delegate* unmanaged<IDWriteFontFace*, uint>)(lpVtbl[1]))((IDWriteFontFace*)Unsafe.AsPointer(ref this)); 24return ((delegate* unmanaged<IDWriteFontFace*, uint>)(lpVtbl[2]))((IDWriteFontFace*)Unsafe.AsPointer(ref this));
MS\Internal\Interop\DWrite\IDWriteFontFile.cs (3)
14return ((delegate* unmanaged<IDWriteFontFile*, Guid*, void**, int>)(lpVtbl[0]))((IDWriteFontFile*)Unsafe.AsPointer(ref this), riid, ppvObject); 19return ((delegate* unmanaged<IDWriteFontFile*, uint>)(lpVtbl[1]))((IDWriteFontFile*)Unsafe.AsPointer(ref this)); 24return ((delegate* unmanaged<IDWriteFontFile*, uint>)(lpVtbl[2]))((IDWriteFontFile*)Unsafe.AsPointer(ref this));
MS\Internal\Interop\DWrite\IDWriteFontFileLoader.cs (3)
14return ((delegate* unmanaged<IDWriteFontFileLoader*, Guid*, void**, int>)(lpVtbl[0]))((IDWriteFontFileLoader*)Unsafe.AsPointer(ref this), riid, ppvObject); 19return ((delegate* unmanaged<IDWriteFontFileLoader*, uint>)(lpVtbl[1]))((IDWriteFontFileLoader*)Unsafe.AsPointer(ref this)); 24return ((delegate* unmanaged<IDWriteFontFileLoader*, uint>)(lpVtbl[2]))((IDWriteFontFileLoader*)Unsafe.AsPointer(ref this));
MS\Internal\Interop\DWrite\IDWriteTextAnalyzer.cs (3)
14return ((delegate* unmanaged<IDWriteTextAnalyzer*, Guid*, void**, int>)(lpVtbl[0]))((IDWriteTextAnalyzer*)Unsafe.AsPointer(ref this), riid, ppvObject); 19return ((delegate* unmanaged<IDWriteTextAnalyzer*, uint>)(lpVtbl[1]))((IDWriteTextAnalyzer*)Unsafe.AsPointer(ref this)); 24return ((delegate* unmanaged<IDWriteTextAnalyzer*, uint>)(lpVtbl[2]))((IDWriteTextAnalyzer*)Unsafe.AsPointer(ref this));
src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\Ink\Native.cs (1)
24SizeOfGuid = (uint)Unsafe.SizeOf<Guid>();
System\Windows\Media\Imaging\BitmapSource.cs (1)
670fixed (byte* pixelArray = &Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(pixels), (nint)offset * elementSize))
System\Windows\Media\PixelFormat.cs (1)
150Debug.Assert(Unsafe.SizeOf<Guid>() == 16);
PresentationCore.Tests (1)
System\Windows\Media\Imaging\WriteableBitmap.Tests.cs (1)
199public static nint AsNativePointer<T>(this Span<T> span) => (nint)Unsafe.AsPointer(ref MemoryMarshal.GetReference(span));
PresentationUI (1)
MS\Internal\Documents\PeoplePickerWrapper.cs (1)
518Unsafe.SizeOf<Guid>() + sizeof(UInt32);
Roslyn.Diagnostics.Analyzers (52)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\ModifierExtensions.cs (1)
16return Unsafe.As<Modifiers, DeclarationModifiers>(ref modifiers);
Shared (2)
LogBuffering\SerializedLogRecordFactory.cs (1)
18private static readonly int _serializedLogRecordSize = Unsafe.SizeOf<SerializedLogRecord>();
RentedSpan\RentedSpan.cs (1)
54var size = Unsafe.SizeOf<T>() * length;
System.Collections (1)
System\Collections\Generic\OrderedDictionary.cs (1)
635ref Entry entry = ref Unsafe.NullRef<Entry>();
System.Collections.Concurrent (1)
System\Collections\Concurrent\ConcurrentDictionary.cs (1)
2329return Unsafe.As<IAlternateEqualityComparer<TAlternateKey, TKey>>(tables._comparer!);
System.Collections.Immutable (35)
System\Collections\Frozen\DefaultFrozenDictionary.AlternateLookup.cs (1)
56return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\DefaultFrozenDictionary.cs (1)
41return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\EmptyFrozenDictionary.cs (1)
29private protected override ref readonly TValue GetValueRefOrNullRefCore(TKey key) => ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\FrozenDictionary.AlternateLookup.cs (4)
69return Unsafe.As<IAlternateEqualityComparer<TAlternateKey, TKey>>(Comparer); 107if (Unsafe.IsNullRef(in valueRef)) 121!Unsafe.IsNullRef(in _alternateLookupDelegate(Dictionary, key)); 135if (!Unsafe.IsNullRef(in valueRef))
System\Collections\Frozen\FrozenDictionary.cs (8)
490/// <remarks>The null reference can be detected by calling <see cref="Unsafe.IsNullRef"/>.</remarks> 554public static readonly AlternateLookupDelegate<TAlternateKey> ReturnsNullRef = (_, _) => ref Unsafe.NullRef<TValue>(); 567if (Unsafe.IsNullRef(ref Unsafe.AsRef(in valueRef))) 591!Unsafe.IsNullRef(ref Unsafe.AsRef(in GetValueRefOrNullRef(key))); 616if (!Unsafe.IsNullRef(ref Unsafe.AsRef(in valueRef)))
System\Collections\Frozen\FrozenSet.AlternateLookup.cs (1)
69return Unsafe.As<IAlternateEqualityComparer<TAlternate, T>>(Comparer);
System\Collections\Frozen\Int32\Int32FrozenDictionary.AlternateLookup.cs (1)
57return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\Int32\Int32FrozenDictionary.cs (1)
79return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\Integer\DenseIntegralFrozenDictionary.cs (2)
143return ref Unsafe.NullRef<TValue>(); 180return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\SmallFrozenDictionary.AlternateLookup.cs (1)
52return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\SmallFrozenDictionary.cs (1)
49return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\SmallValueTypeComparableFrozenDictionary.cs (1)
66return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\SmallValueTypeDefaultComparerFrozenDictionary.cs (1)
47return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\String\LengthBucketsFrozenDictionary.AlternateLookup.cs (1)
58return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\String\LengthBucketsFrozenDictionary.cs (1)
110return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\String\OrdinalStringFrozenDictionary.AlternateLookup.cs (1)
55return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\String\OrdinalStringFrozenDictionary.cs (1)
107return ref Unsafe.NullRef<TValue>();
System\Collections\Frozen\ValueTypeDefaultComparerFrozenDictionary.cs (1)
41return ref Unsafe.NullRef<TValue>();
System\Collections\Immutable\ImmutableInterlocked.cs (6)
128T[]? oldArray = Volatile.Read(ref Unsafe.AsRef(in location.array)); 138T[]? interlockedResult = Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), newImmutableArray.array, oldArray); 175T[]? oldArray = Volatile.Read(ref Unsafe.AsRef(in location.array)); 185T[]? interlockedResult = Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), newImmutableArray.array, oldArray); 205return new ImmutableArray<T>(Interlocked.Exchange(ref Unsafe.AsRef(in location.array), value.array)); 219return new ImmutableArray<T>(Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), value.array, comparand.array));
System.Diagnostics.DiagnosticSource (5)
System\Diagnostics\Activity.cs (2)
2011Unsafe.WriteUnaligned(ref outBytes[0], r.Next()); 2015Unsafe.WriteUnaligned(ref outBytes[8], r.Next());
System\Diagnostics\ActivityCreationOptions.cs (3)
122Unsafe.AsRef(in _samplerTags) = new ActivityTagsCollection(); 139Unsafe.AsRef(in _context) = new ActivityContext(id, default, ActivityTraceFlags.None); 159internal void SetTraceState(string? traceState) => Unsafe.AsRef(in _traceState) = traceState;
System.Formats.Nrbf (1)
System\Formats\Nrbf\ArraySinglePrimitiveRecord.cs (1)
84? Unsafe.SizeOf<T>()
System.IO.Hashing (21)
System\IO\Hashing\Crc32.Arm.cs (4)
26Unsafe.ReadUnaligned<ulong>(ref Unsafe.Add(ref ptr, i))); 54Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref ptr, i)));
System\IO\Hashing\Crc32.Vectorized.cs (4)
52srcRef = ref Unsafe.Add(ref srcRef, Vector128<byte>.Count * 4); 73srcRef = ref Unsafe.Add(ref srcRef, Vector128<byte>.Count * 4); 91srcRef = ref Unsafe.Add(ref srcRef, Vector128<byte>.Count); 101srcRef = ref Unsafe.Add(ref srcRef, Vector128<byte>.Count);
System\IO\Hashing\Crc64.Vectorized.cs (4)
70srcRef = ref Unsafe.Add(ref srcRef, Vector128<byte>.Count * 8); 103srcRef = ref Unsafe.Add(ref srcRef, Vector128<byte>.Count * 8); 128srcRef = ref Unsafe.Add(ref srcRef, Vector128<byte>.Count); 138srcRef = ref Unsafe.Add(ref srcRef, Vector128<byte>.Count);
System\IO\Hashing\XxHash128.cs (3)
226Unsafe.WriteUnaligned(ref dest0, high); 227Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
System\IO\Hashing\XxHash3.cs (1)
112Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), hash);
System\IO\Hashing\XxHashShared.cs (5)
785Unsafe.ReadUnaligned<uint>(data) : 786BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 791Unsafe.ReadUnaligned<ulong>(data) : 792BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 801Unsafe.WriteUnaligned(data, value);
System.Linq (23)
System\Linq\Enumerable.cs (2)
56span = Unsafe.As<TSource[]>(source); 60span = CollectionsMarshal.AsSpan(Unsafe.As<List<TSource>>(source));
System\Linq\MaxMin.cs (12)
54ref T lastVectorStart = ref Unsafe.Add(ref current, span.Length - Vector128<T>.Count); 57current = ref Unsafe.Add(ref current, Vector128<T>.Count); 59while (Unsafe.IsAddressLessThan(ref current, ref lastVectorStart)) 62current = ref Unsafe.Add(ref current, Vector128<T>.Count); 78ref T lastVectorStart = ref Unsafe.Add(ref current, span.Length - Vector256<T>.Count); 81current = ref Unsafe.Add(ref current, Vector256<T>.Count); 83while (Unsafe.IsAddressLessThan(ref current, ref lastVectorStart)) 86current = ref Unsafe.Add(ref current, Vector256<T>.Count); 102ref T lastVectorStart = ref Unsafe.Add(ref current, span.Length - Vector512<T>.Count); 105current = ref Unsafe.Add(ref current, Vector512<T>.Count); 107while (Unsafe.IsAddressLessThan(ref current, ref lastVectorStart)) 110current = ref Unsafe.Add(ref current, Vector512<T>.Count);
System\Linq\Range.cs (6)
83ref T end = ref Unsafe.Add(ref pos, destination.Length); 93ref T oneVectorFromEnd = ref Unsafe.Subtract(ref end, Vector<T>.Count); 98pos = ref Unsafe.Add(ref pos, Vector<T>.Count); 100while (!Unsafe.IsAddressGreaterThan(ref pos, ref oneVectorFromEnd)); 105while (Unsafe.IsAddressLessThan(ref pos, ref end)) 108pos = ref Unsafe.Add(ref pos, 1);
System\Linq\Sum.cs (3)
63return (TResult)(object)SumSignedIntegersVectorized(Unsafe.BitCast<ReadOnlySpan<T>, ReadOnlySpan<long>>(span)); 67return (TResult)(object)SumSignedIntegersVectorized(Unsafe.BitCast<ReadOnlySpan<T>, ReadOnlySpan<int>>(span)); 185checked { result += Unsafe.Add(ref ptr, index); }
System.Memory (3)
System\Buffers\ReadOnlySequence.cs (1)
494ReadOnlySequence<char> charSequence = Unsafe.As<ReadOnlySequence<T>, ReadOnlySequence<char>>(ref localThis);
System\Buffers\ReadOnlySequence.Helpers.cs (1)
688return MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<char, T>(ref MemoryMarshal.GetReference(spanOfChar)), spanOfChar.Length);
System\Buffers\SequenceReader.cs (1)
102Unsafe.AsRef(in _length) = Sequence.Length;
System.Numerics.Tensors (640)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IAggregationOperator.cs (93)
144result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, i))); 822result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 14))); 826result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 13))); 830result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 12))); 834result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 11))); 838result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 10))); 842result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 9))); 846result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 8))); 850result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 7))); 854result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 6))); 858result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 5))); 862result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 4))); 866result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 3))); 870result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 2))); 874result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 1))); 969result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 6))); 973result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 5))); 977result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 4))); 981result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 3))); 985result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 2))); 989result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 1))); 1067result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 2))); 1073result = TAggregationOperator.Invoke(result, transform.Invoke(Unsafe.Add(ref xRef, 1))); 1263result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, i), 1264Unsafe.Add(ref yRef, i))); 2024result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 14), Unsafe.Add(ref yRef, 14))); 2028result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 13), Unsafe.Add(ref yRef, 13))); 2032result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 12), Unsafe.Add(ref yRef, 12))); 2036result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 11), Unsafe.Add(ref yRef, 11))); 2040result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 10), Unsafe.Add(ref yRef, 10))); 2044result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 9), Unsafe.Add(ref yRef, 9))); 2048result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 8), Unsafe.Add(ref yRef, 8))); 2052result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 7), Unsafe.Add(ref yRef, 7))); 2056result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 6), Unsafe.Add(ref yRef, 6))); 2060result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 5), Unsafe.Add(ref yRef, 5))); 2064result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 4), Unsafe.Add(ref yRef, 4))); 2068result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 3), Unsafe.Add(ref yRef, 3))); 2072result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 2), Unsafe.Add(ref yRef, 2))); 2076result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 1), Unsafe.Add(ref yRef, 1))); 2177result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 6), Unsafe.Add(ref yRef, 6))); 2181result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 5), Unsafe.Add(ref yRef, 5))); 2185result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 4), Unsafe.Add(ref yRef, 4))); 2189result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 3), Unsafe.Add(ref yRef, 3))); 2193result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 2), Unsafe.Add(ref yRef, 2))); 2197result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 1), Unsafe.Add(ref yRef, 1))); 2281result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 2282Unsafe.Add(ref yRef, 2))); 2288result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 2289Unsafe.Add(ref yRef, 1))); 2396ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(AlignmentByteMask_64x65)), 2403ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(AlignmentUInt16Mask_32x33)), 2410ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(AlignmentUInt32Mask_16x17)), 2417ref Unsafe.As<ulong, T>(ref MemoryMarshal.GetReference(AlignmentUInt64Mask_8x9)), 2432ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(AlignmentByteMask_64x65)), 2439ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(AlignmentUInt16Mask_32x33)), 2446ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(AlignmentUInt32Mask_16x17)), 2453ref Unsafe.As<ulong, T>(ref MemoryMarshal.GetReference(AlignmentUInt64Mask_8x9)), 2468ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(AlignmentByteMask_64x65)), 2475ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(AlignmentUInt16Mask_32x33)), 2482ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(AlignmentUInt32Mask_16x17)), 2489ref Unsafe.As<ulong, T>(ref MemoryMarshal.GetReference(AlignmentUInt64Mask_8x9)), 2504ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(RemainderByteMask_64x65)), 2511ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(RemainderUInt16Mask_32x33)), 2518ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(RemainderUInt32Mask_16x17)), 2525ref Unsafe.As<ulong, T>(ref MemoryMarshal.GetReference(RemainderUInt64Mask_8x9)), 2540ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(RemainderByteMask_64x65)), 2547ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(RemainderUInt16Mask_32x33)), 2554ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(RemainderUInt32Mask_16x17)), 2561ref Unsafe.As<ulong, T>(ref MemoryMarshal.GetReference(RemainderUInt64Mask_8x9)), 2576ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(RemainderByteMask_64x65)), 2583ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(RemainderUInt16Mask_32x33)), 2590ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(RemainderUInt32Mask_16x17)), 2597ref Unsafe.As<ulong, T>(ref MemoryMarshal.GetReference(RemainderUInt64Mask_8x9)),
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IBinaryOperator.cs (115)
149Unsafe.Add(ref dRef, i) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, i), 150Unsafe.Add(ref yRef, i)); 1012Unsafe.Add(ref dRef, 14) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 14), 1013Unsafe.Add(ref yRef, 14)); 1017Unsafe.Add(ref dRef, 13) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 13), 1018Unsafe.Add(ref yRef, 13)); 1022Unsafe.Add(ref dRef, 12) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 12), 1023Unsafe.Add(ref yRef, 12)); 1027Unsafe.Add(ref dRef, 11) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 11), 1028Unsafe.Add(ref yRef, 11)); 1032Unsafe.Add(ref dRef, 10) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 10), 1033Unsafe.Add(ref yRef, 10)); 1037Unsafe.Add(ref dRef, 9) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 9), 1038Unsafe.Add(ref yRef, 9)); 1042Unsafe.Add(ref dRef, 8) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 8), 1043Unsafe.Add(ref yRef, 8)); 1047Unsafe.Add(ref dRef, 7) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 7), 1048Unsafe.Add(ref yRef, 7)); 1052Unsafe.Add(ref dRef, 6) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 1053Unsafe.Add(ref yRef, 6)); 1057Unsafe.Add(ref dRef, 5) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 1058Unsafe.Add(ref yRef, 5)); 1062Unsafe.Add(ref dRef, 4) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 1063Unsafe.Add(ref yRef, 4)); 1067Unsafe.Add(ref dRef, 3) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 1068Unsafe.Add(ref yRef, 3)); 1072Unsafe.Add(ref dRef, 2) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 1073Unsafe.Add(ref yRef, 2)); 1077Unsafe.Add(ref dRef, 1) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 1078Unsafe.Add(ref yRef, 1)); 1176Unsafe.Add(ref dRef, 6) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 1177Unsafe.Add(ref yRef, 6)); 1181Unsafe.Add(ref dRef, 5) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 1182Unsafe.Add(ref yRef, 5)); 1186Unsafe.Add(ref dRef, 4) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 1187Unsafe.Add(ref yRef, 4)); 1191Unsafe.Add(ref dRef, 3) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 1192Unsafe.Add(ref yRef, 3)); 1196Unsafe.Add(ref dRef, 2) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 1197Unsafe.Add(ref yRef, 2)); 1201Unsafe.Add(ref dRef, 1) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 1202Unsafe.Add(ref yRef, 1)); 1283Unsafe.Add(ref dRef, 2) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 1284Unsafe.Add(ref yRef, 2)); 1290Unsafe.Add(ref dRef, 1) = TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 1291Unsafe.Add(ref yRef, 1)); 1481Unsafe.Add(ref dRef, i) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, i)), 2336Unsafe.Add(ref dRef, 14) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 14)), 2341Unsafe.Add(ref dRef, 13) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 13)), 2346Unsafe.Add(ref dRef, 12) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 12)), 2351Unsafe.Add(ref dRef, 11) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 11)), 2356Unsafe.Add(ref dRef, 10) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 10)), 2361Unsafe.Add(ref dRef, 9) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 9)), 2366Unsafe.Add(ref dRef, 8) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 8)), 2371Unsafe.Add(ref dRef, 7) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 7)), 2376Unsafe.Add(ref dRef, 6) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 6)), 2381Unsafe.Add(ref dRef, 5) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 5)), 2386Unsafe.Add(ref dRef, 4) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 4)), 2391Unsafe.Add(ref dRef, 3) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 3)), 2396Unsafe.Add(ref dRef, 2) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 2)), 2401Unsafe.Add(ref dRef, 1) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 1)), 2504Unsafe.Add(ref dRef, 6) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 6)), 2509Unsafe.Add(ref dRef, 5) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 5)), 2514Unsafe.Add(ref dRef, 4) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 4)), 2519Unsafe.Add(ref dRef, 3) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 3)), 2524Unsafe.Add(ref dRef, 2) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 2)), 2529Unsafe.Add(ref dRef, 1) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 1)), 2615Unsafe.Add(ref dRef, 2) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 2)), 2622Unsafe.Add(ref dRef, 1) = TBinaryOperator.Invoke(TTransformOperator.Invoke(Unsafe.Add(ref xRef, 1)),
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IBooleanUnaryOperator.cs (21)
187if (TAnyAll.ShouldEarlyExit(TOperator.Invoke(Unsafe.Add(ref xRef, i)))) 261(v & Vector512<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 292(v & Vector256<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 323(v & Vector128<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 330Unsafe.Add(ref destinationRef, i) = TOperator.Invoke(Unsafe.Add(ref xRef, i)); 372(v & Vector512<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 406(v & Vector256<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 440(v & Vector128<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 447Unsafe.Add(ref destinationRef, i) = TOperator.Invoke(Unsafe.Add(ref xRef, i)); 493(v & Vector512<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 531(v & Vector256<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 569(v & Vector128<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 576Unsafe.Add(ref destinationRef, i) = TOperator.Invoke(Unsafe.Add(ref xRef, i)); 630(v & Vector512<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 678(v & Vector256<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 726(v & Vector128<byte>.One).StoreUnsafe(ref Unsafe.As<bool, byte>(ref destinationRef), (uint)i); 733Unsafe.Add(ref destinationRef, i) = TOperator.Invoke(Unsafe.Add(ref xRef, i));
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IStatefulUnaryOperator.cs (46)
115Unsafe.Add(ref dRef, i) = op.Invoke(Unsafe.Add(ref xRef, i)); 878Unsafe.Add(ref dRef, 14) = op.Invoke(Unsafe.Add(ref xRef, 14)); 882Unsafe.Add(ref dRef, 13) = op.Invoke(Unsafe.Add(ref xRef, 13)); 886Unsafe.Add(ref dRef, 12) = op.Invoke(Unsafe.Add(ref xRef, 12)); 890Unsafe.Add(ref dRef, 11) = op.Invoke(Unsafe.Add(ref xRef, 11)); 894Unsafe.Add(ref dRef, 10) = op.Invoke(Unsafe.Add(ref xRef, 10)); 898Unsafe.Add(ref dRef, 9) = op.Invoke(Unsafe.Add(ref xRef, 9)); 902Unsafe.Add(ref dRef, 8) = op.Invoke(Unsafe.Add(ref xRef, 8)); 906Unsafe.Add(ref dRef, 7) = op.Invoke(Unsafe.Add(ref xRef, 7)); 910Unsafe.Add(ref dRef, 6) = op.Invoke(Unsafe.Add(ref xRef, 6)); 914Unsafe.Add(ref dRef, 5) = op.Invoke(Unsafe.Add(ref xRef, 5)); 918Unsafe.Add(ref dRef, 4) = op.Invoke(Unsafe.Add(ref xRef, 4)); 922Unsafe.Add(ref dRef, 3) = op.Invoke(Unsafe.Add(ref xRef, 3)); 926Unsafe.Add(ref dRef, 2) = op.Invoke(Unsafe.Add(ref xRef, 2)); 930Unsafe.Add(ref dRef, 1) = op.Invoke(Unsafe.Add(ref xRef, 1)); 1022Unsafe.Add(ref dRef, 6) = op.Invoke(Unsafe.Add(ref xRef, 6)); 1026Unsafe.Add(ref dRef, 5) = op.Invoke(Unsafe.Add(ref xRef, 5)); 1030Unsafe.Add(ref dRef, 4) = op.Invoke(Unsafe.Add(ref xRef, 4)); 1034Unsafe.Add(ref dRef, 3) = op.Invoke(Unsafe.Add(ref xRef, 3)); 1038Unsafe.Add(ref dRef, 2) = op.Invoke(Unsafe.Add(ref xRef, 2)); 1042Unsafe.Add(ref dRef, 1) = op.Invoke(Unsafe.Add(ref xRef, 1)); 1117Unsafe.Add(ref dRef, 2) = op.Invoke(Unsafe.Add(ref xRef, 2)); 1123Unsafe.Add(ref dRef, 1) = op.Invoke(Unsafe.Add(ref xRef, 1));
System\Numerics\Tensors\netcore\Common\TensorPrimitives.ITernaryOperator.cs (207)
136Unsafe.Add(ref dRef, i) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, i), 137Unsafe.Add(ref yRef, i), 138Unsafe.Add(ref zRef, i)); 1099Unsafe.Add(ref dRef, 14) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 14), 1100Unsafe.Add(ref yRef, 14), 1101Unsafe.Add(ref zRef, 14)); 1105Unsafe.Add(ref dRef, 13) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 13), 1106Unsafe.Add(ref yRef, 13), 1107Unsafe.Add(ref zRef, 13)); 1111Unsafe.Add(ref dRef, 12) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 12), 1112Unsafe.Add(ref yRef, 12), 1113Unsafe.Add(ref zRef, 12)); 1117Unsafe.Add(ref dRef, 11) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 11), 1118Unsafe.Add(ref yRef, 11), 1119Unsafe.Add(ref zRef, 11)); 1123Unsafe.Add(ref dRef, 10) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 10), 1124Unsafe.Add(ref yRef, 10), 1125Unsafe.Add(ref zRef, 10)); 1129Unsafe.Add(ref dRef, 9) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 9), 1130Unsafe.Add(ref yRef, 9), 1131Unsafe.Add(ref zRef, 9)); 1135Unsafe.Add(ref dRef, 8) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 8), 1136Unsafe.Add(ref yRef, 8), 1137Unsafe.Add(ref zRef, 8)); 1141Unsafe.Add(ref dRef, 7) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 7), 1142Unsafe.Add(ref yRef, 7), 1143Unsafe.Add(ref zRef, 7)); 1147Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 1148Unsafe.Add(ref yRef, 6), 1149Unsafe.Add(ref zRef, 6)); 1153Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 1154Unsafe.Add(ref yRef, 5), 1155Unsafe.Add(ref zRef, 5)); 1159Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 1160Unsafe.Add(ref yRef, 4), 1161Unsafe.Add(ref zRef, 4)); 1165Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 1166Unsafe.Add(ref yRef, 3), 1167Unsafe.Add(ref zRef, 3)); 1171Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 1172Unsafe.Add(ref yRef, 2), 1173Unsafe.Add(ref zRef, 2)); 1177Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 1178Unsafe.Add(ref yRef, 1), 1179Unsafe.Add(ref zRef, 1)); 1283Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 1284Unsafe.Add(ref yRef, 6), 1285Unsafe.Add(ref zRef, 6)); 1289Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 1290Unsafe.Add(ref yRef, 5), 1291Unsafe.Add(ref zRef, 5)); 1295Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 1296Unsafe.Add(ref yRef, 4), 1297Unsafe.Add(ref zRef, 4)); 1301Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 1302Unsafe.Add(ref yRef, 3), 1303Unsafe.Add(ref zRef, 3)); 1307Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 1308Unsafe.Add(ref yRef, 2), 1309Unsafe.Add(ref zRef, 2)); 1313Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 1314Unsafe.Add(ref yRef, 1), 1315Unsafe.Add(ref zRef, 1)); 1402Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 1403Unsafe.Add(ref yRef, 2), 1404Unsafe.Add(ref zRef, 2)); 1410Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 1411Unsafe.Add(ref yRef, 1), 1412Unsafe.Add(ref zRef, 1)); 1611Unsafe.Add(ref dRef, i) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, i), 1612Unsafe.Add(ref yRef, i), 2566Unsafe.Add(ref dRef, 14) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 14), 2567Unsafe.Add(ref yRef, 14), 2572Unsafe.Add(ref dRef, 13) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 13), 2573Unsafe.Add(ref yRef, 13), 2578Unsafe.Add(ref dRef, 12) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 12), 2579Unsafe.Add(ref yRef, 12), 2584Unsafe.Add(ref dRef, 11) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 11), 2585Unsafe.Add(ref yRef, 11), 2590Unsafe.Add(ref dRef, 10) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 10), 2591Unsafe.Add(ref yRef, 10), 2596Unsafe.Add(ref dRef, 9) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 9), 2597Unsafe.Add(ref yRef, 9), 2602Unsafe.Add(ref dRef, 8) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 8), 2603Unsafe.Add(ref yRef, 8), 2608Unsafe.Add(ref dRef, 7) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 7), 2609Unsafe.Add(ref yRef, 7), 2614Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 2615Unsafe.Add(ref yRef, 6), 2620Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 2621Unsafe.Add(ref yRef, 5), 2626Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 2627Unsafe.Add(ref yRef, 4), 2632Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 2633Unsafe.Add(ref yRef, 3), 2638Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 2639Unsafe.Add(ref yRef, 2), 2644Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 2645Unsafe.Add(ref yRef, 1), 2754Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 2755Unsafe.Add(ref yRef, 6), 2760Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 2761Unsafe.Add(ref yRef, 5), 2766Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 2767Unsafe.Add(ref yRef, 4), 2772Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 2773Unsafe.Add(ref yRef, 3), 2778Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 2779Unsafe.Add(ref yRef, 2), 2784Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 2785Unsafe.Add(ref yRef, 1), 2877Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 2878Unsafe.Add(ref yRef, 2), 2885Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 2886Unsafe.Add(ref yRef, 1), 3097Unsafe.Add(ref dRef, i) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, i), 4039Unsafe.Add(ref dRef, 14) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 14), 4045Unsafe.Add(ref dRef, 13) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 13), 4051Unsafe.Add(ref dRef, 12) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 12), 4057Unsafe.Add(ref dRef, 11) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 11), 4063Unsafe.Add(ref dRef, 10) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 10), 4069Unsafe.Add(ref dRef, 9) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 9), 4075Unsafe.Add(ref dRef, 8) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 8), 4081Unsafe.Add(ref dRef, 7) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 7), 4087Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 4093Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 4099Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 4105Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 4111Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 4117Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 4229Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 4235Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 4241Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 4247Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 4253Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 4259Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 4354Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 4362Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1),
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryInputBinaryOutput.cs (10)
163(T first, T second) = TUnaryOperator.Invoke(Unsafe.Add(ref sourceRef, i)); 164Unsafe.Add(ref destination1Ref, i) = first; 165Unsafe.Add(ref destination2Ref, i) = second; 352(T first, T second) = TOperator.Invoke(Unsafe.Add(ref xRef, i), Unsafe.Add(ref yRef, i)); 353Unsafe.Add(ref destination1Ref, i) = first; 354Unsafe.Add(ref destination2Ref, i) = second; 539(T first, T second) = TOperator.Invoke(Unsafe.Add(ref xRef, i), y); 540Unsafe.Add(ref destination1Ref, i) = first; 541Unsafe.Add(ref destination2Ref, i) = second;
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryOneToFourOperator.cs (2)
157Unsafe.Add(ref destinationRef, i) = TUnaryOperator.Invoke(Unsafe.Add(ref sourceRef, i));
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryOneToTwoOperator.cs (2)
145Unsafe.Add(ref destinationRef, i) = TUnaryOperator.Invoke(Unsafe.Add(ref sourceRef, i));
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryOperator.cs (46)
155Unsafe.Add(ref dRef, i) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, i)); 918Unsafe.Add(ref dRef, 14) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 14)); 922Unsafe.Add(ref dRef, 13) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 13)); 926Unsafe.Add(ref dRef, 12) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 12)); 930Unsafe.Add(ref dRef, 11) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 11)); 934Unsafe.Add(ref dRef, 10) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 10)); 938Unsafe.Add(ref dRef, 9) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 9)); 942Unsafe.Add(ref dRef, 8) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 8)); 946Unsafe.Add(ref dRef, 7) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 7)); 950Unsafe.Add(ref dRef, 6) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 6)); 954Unsafe.Add(ref dRef, 5) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 5)); 958Unsafe.Add(ref dRef, 4) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 4)); 962Unsafe.Add(ref dRef, 3) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 3)); 966Unsafe.Add(ref dRef, 2) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 2)); 970Unsafe.Add(ref dRef, 1) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 1)); 1062Unsafe.Add(ref dRef, 6) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 6)); 1066Unsafe.Add(ref dRef, 5) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 5)); 1070Unsafe.Add(ref dRef, 4) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 4)); 1074Unsafe.Add(ref dRef, 3) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 3)); 1078Unsafe.Add(ref dRef, 2) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 2)); 1082Unsafe.Add(ref dRef, 1) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 1)); 1157Unsafe.Add(ref dRef, 2) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 2)); 1163Unsafe.Add(ref dRef, 1) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, 1));
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryTwoToOneOperator.cs (2)
145Unsafe.Add(ref destinationRef, i) = TUnaryOperator.Invoke(Unsafe.Add(ref xRef, i));
System\Numerics\Tensors\netcore\ReadOnlyTensorDimensionSpan_1.cs (1)
55return new ReadOnlyTensorSpan<T>(ref Unsafe.Add(ref _tensor._reference, linearOffset), _sliceShape);
System\Numerics\Tensors\netcore\ReadOnlyTensorSpan_1.cs (20)
46: ref Unsafe.NullRef<T>(); 81: ref Unsafe.NullRef<T>(); 104? ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (uint)start) 105: ref Unsafe.NullRef<T>(); 158? ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)) 159: ref Unsafe.NullRef<T>(); 185? ref Unsafe.Add(ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)), linearOffset) 186: ref Unsafe.NullRef<T>(); 199_reference = ref Unsafe.AsRef<T>(data); 238_reference = ref Unsafe.AsRef<T>(data); 256get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNInt, nint>(indexes)); 262get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 303=> Unsafe.AreSame(ref left._reference, ref right._reference) 327ref Unsafe.As<TDerived, T>(ref items._reference), 380ref T ret = ref Unsafe.NullRef<T>(); 390ref Unsafe.Add(ref _reference, linearOffset), 400ref Unsafe.Add(ref _reference, linearOffset), 410ref Unsafe.Add(ref _reference, linearOffset), 497public readonly ref readonly T Current => ref Unsafe.Add(ref _span._reference, _linearOffset);
System\Numerics\Tensors\netcore\Tensor.cs (3)
1640ReadOnlySpan<T> span = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref tensor.AsTensorSpan()._reference, tensor._start), tensor._values.Length - tensor._start); 2202ReadOnlyTensorSpan<T> tmpTensor = new ReadOnlyTensorSpan<T>(ref Unsafe.Add(ref tensor._reference, i * tensor.Strides[0]), tmpShape); 2222sb.Append(Unsafe.Add(ref tensor._reference, i));
System\Numerics\Tensors\netcore\Tensor_1.cs (7)
83get => ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_values), _start + _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNInt, nint>(indexes)); 89get => ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_values), _start + _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 137public ReadOnlyTensorSpan<T> AsReadOnlyTensorSpan() => new ReadOnlyTensorSpan<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_values), _start), in _shape); 149public TensorSpan<T> AsTensorSpan() => new TensorSpan<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_values), _start), in _shape); 195ref T ret = ref Unsafe.NullRef<T>(); 205return new MemoryHandle(Unsafe.AsPointer(ref GetPinnableReference()), handle); 381public readonly ref T Current => ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_tensor._values), _linearOffset);
System\Numerics\Tensors\netcore\TensorDimensionSpan_1.cs (1)
52return new TensorSpan<T>(ref Unsafe.Add(ref _tensor._reference, linearOffset), _sliceShape);
System\Numerics\Tensors\netcore\TensorOperation.cs (23)
22ref Unsafe.Add(ref x._reference, linearOffset) 44in Unsafe.Add(ref x._reference, xLinearOffset), 45in Unsafe.Add(ref y._reference, yLinearOffset), 73in Unsafe.Add(ref x._reference, xLinearOffset), 98ref Unsafe.Add(ref destination._reference, linearOffset), 118in Unsafe.Add(ref x._reference, xLinearOffset), 119ref Unsafe.Add(ref destination._reference, destinationLinearOffset) 146in Unsafe.Add(ref x._reference, xLinearOffset), 147ref Unsafe.Add(ref destination._reference, destinationLinearOffset) 168in Unsafe.Add(ref x._reference, xLinearOffset), 169ref Unsafe.Add(ref destination[0], destinationIndex) 186in Unsafe.Add(ref x._reference, xLinearOffset), 208in Unsafe.Add(ref x._reference, xLinearOffset), 209in Unsafe.Add(ref y._reference, yLinearOffset), 210ref Unsafe.Add(ref destination._reference, destinationLinearOffset) 237in Unsafe.Add(ref x._reference, xLinearOffset), 238in Unsafe.Add(ref y._reference, yLinearOffset), 267in Unsafe.Add(ref x._reference, xLinearOffset), 269ref Unsafe.Add(ref destination._reference, destinationLinearOffset) 290in Unsafe.Add(ref y._reference, xLinearOffset), 291ref Unsafe.Add(ref destination._reference, destinationLinearOffset) 309in Unsafe.Add(ref x._reference, xLinearOffset), 2641Unsafe.SkipInit(out rentedBuffer._inline);
System\Numerics\Tensors\netcore\TensorPrimitives.ConvertHelpers.cs (2)
392public static float Invoke(short x) => (float)Unsafe.BitCast<short, Half>(x); 573public static ushort Invoke(float x) => Unsafe.BitCast<Half, ushort>((Half)x);
System\Numerics\Tensors\netcore\TensorPrimitives.CosineSimilarity.cs (6)
203ref short xRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(x)); 204ref short yRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(y)); 245ref short xRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(x)); 246ref short yRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(y)); 287ref short xRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(x)); 288ref short yRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(y));
System\Numerics\Tensors\netcore\TensorPrimitives.HammingDistance.cs (2)
55MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(x)), x.Length), 56MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(y)), y.Length));
System\Numerics\Tensors\netcore\TensorShape.cs (9)
175Unsafe.SkipInit(out stridesOrderBuffer); 720Unsafe.SkipInit(out lengthsBuffer); 777Unsafe.SkipInit(out intermediateLengthsBuffer); 914if (!Unsafe.IsNullRef(ref reference)) 936if (!Unsafe.IsNullRef(ref reference)) 954=> Create(ref Unsafe.AsRef<T>(address), linearLength, pinned: true); 957=> Create(ref Unsafe.AsRef<T>(address), linearLength, lengths, strides, pinned: true); 1057Unsafe.SkipInit(out intermediateLengthsBuffer); 1060Unsafe.SkipInit(out intermediateStridesBuffer);
System\Numerics\Tensors\netcore\TensorSpan_1.cs (19)
44: ref Unsafe.NullRef<T>(); 61: ref Unsafe.NullRef<T>(); 72? ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (uint)start) 73: ref Unsafe.NullRef<T>(); 104? ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)) 105: ref Unsafe.NullRef<T>(); 116? ref Unsafe.Add(ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)), linearOffset) 117: ref Unsafe.NullRef<T>(); 125_reference = ref Unsafe.AsRef<T>(data); 138_reference = ref Unsafe.AsRef<T>(data); 156get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNInt, nint>(indexes)); 162get => ref Unsafe.Add(ref _reference, _shape.GetLinearOffset<TensorShape.GetOffsetAndLengthForNIndex, NIndex>(indexes)); 200=> Unsafe.AreSame(ref left._reference, ref right._reference) 276ref T ret = ref Unsafe.NullRef<T>(); 286ref Unsafe.Add(ref _reference, linearOffset), 296ref Unsafe.Add(ref _reference, linearOffset), 306ref Unsafe.Add(ref _reference, linearOffset), 423public readonly ref T Current => ref Unsafe.Add(ref _span._reference, _linearOffset);
System\Numerics\Tensors\TensorPrimitives.Helpers.cs (3)
18if (!Unsafe.AreSame(ref MemoryMarshal.GetReference(input), ref MemoryMarshal.GetReference(destination)) && 53return Unsafe.BitCast<Span<TFrom>, Span<TTo>>(span); 69return Unsafe.BitCast<ReadOnlySpan<TFrom>, ReadOnlySpan<TTo>>(span);
System.Private.CoreLib (4077)
src\libraries\Common\src\System\HexConverter.cs (6)
119ref ushort destRef = ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(chars)); 140uint i32 = Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref srcRef, pos)); 270ref ushort srcRef = ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(chars)); 334Unsafe.WriteUnaligned(ref Unsafe.Add(ref destRef, offset / 2), output.AsUInt64().ToScalar());
src\libraries\Common\src\System\Number.NumberBuffer.cs (1)
33public readonly byte* DigitsPtr => (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(Digits)); // safe since constructor expects Digits to refer to unmovable memory
src\libraries\System.Private.CoreLib\src\System\Activator.RuntimeType.cs (2)
152return Unsafe.As<object, T>(ref o); 157rtType.CallDefaultStructConstructor(ref Unsafe.As<T, byte>(ref t));
src\libraries\System.Private.CoreLib\src\System\Array.cs (75)
380ref byte src = ref Unsafe.As<RawArrayData>(sourceArray).Data; 381ref byte dst = ref Unsafe.As<RawArrayData>(destinationArray).Data; 412ref byte src = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(sourceArray).Data, (uint)sourceIndex * elementSize); 413ref byte dst = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(destinationArray).Data, (uint)destinationIndex * elementSize); 463ref byte src = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(sourceArray), (uint)sourceIndex * elementSize); 464ref byte dst = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(destinationArray), (uint)destinationIndex * elementSize); 538ref object? srcData = ref Unsafe.Add(ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(sourceArray)), sourceIndex); 539ref byte destData = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(destinationArray), (nuint)destinationIndex * destSize); 543object? obj = Unsafe.Add(ref srcData, i); 569destData = ref Unsafe.AddByteOffset(ref destData, destSize); 583ref byte srcData = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(sourceArray), (nuint)sourceIndex * srcSize); 584ref object? destData = ref Unsafe.Add(ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(destinationArray)), destinationIndex); 593Unsafe.Add(ref destData, i) = obj; 594srcData = ref Unsafe.AddByteOffset(ref srcData, srcSize); 606ref object? srcData = ref Unsafe.Add(ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(sourceArray)), sourceIndex); 607ref object? destData = ref Unsafe.Add(ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(destinationArray)), destinationIndex); 611object? obj = Unsafe.Add(ref srcData, i); 619Unsafe.Add(ref destData, i) = CastHelpers.ChkCastAny(pDestMT, obj); 643ref byte srcData = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(sourceArray), (nuint)sourceIndex * srcElSize); 644ref byte destData = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(destinationArray), (nuint)destinationIndex * destElSize); 649srcData = ref Unsafe.AddByteOffset(ref srcData, srcElSize); 650destData = ref Unsafe.AddByteOffset(ref destData, destElSize); 675SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref pStart), totalByteLength / (nuint)sizeof(IntPtr)); 689ref byte p = ref Unsafe.As<RawArrayData>(array).Data; 696lowerBound = Unsafe.Add(ref Unsafe.As<byte, int>(ref p), rank); 697p = ref Unsafe.Add(ref p, 2 * sizeof(int) * rank); // skip the bounds 707ref byte ptr = ref Unsafe.AddByteOffset(ref p, (uint)offset * elementSize); 711SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref ptr), byteLength / (uint)sizeof(IntPtr)); 726rawIndex -= Unsafe.Add(ref bounds, 1); 745int index = indices[i] - Unsafe.Add(ref bounds, indices.Length + i); 746int length = Unsafe.Add(ref bounds, i); 773return Unsafe.Add(ref this.GetMultiDimensionalArrayBounds(), dimension); 787return Unsafe.Add(ref bounds, dimension) 788+ (SupportsNonZeroLowerBound ? Unsafe.Add(ref bounds, rank + dimension) : 0) 803return Unsafe.Add(ref this.GetMultiDimensionalArrayBounds(), rank + dimension); 1339=> UnsafeArrayAsSpan<T>(array, adjustedIndex, length).BinarySearch(Unsafe.As<byte, T>(ref value.GetRawData())); 1512ref T first = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)startIndex); 1835=> UnsafeArrayAsSpan<T>(array, adjustedIndex, length).IndexOf(Unsafe.As<byte, T>(ref value.GetRawData())); 1902ref Unsafe.Add(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(array)), startIndex), 1903Unsafe.BitCast<T, byte>(value), 1910ref Unsafe.Add(ref Unsafe.As<T, short>(ref MemoryMarshal.GetArrayDataReference(array)), startIndex), 1911Unsafe.BitCast<T, short>(value), 1918ref Unsafe.Add(ref Unsafe.As<T, int>(ref MemoryMarshal.GetArrayDataReference(array)), startIndex), 1919Unsafe.BitCast<T, int>(value), 1926ref Unsafe.Add(ref Unsafe.As<T, long>(ref MemoryMarshal.GetArrayDataReference(array)), startIndex), 1927Unsafe.BitCast<T, long>(value), 2062=> UnsafeArrayAsSpan<T>(array, adjustedIndex, length).LastIndexOf(Unsafe.As<byte, T>(ref value.GetRawData())); 2147ref Unsafe.Add(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(array)), endIndex), 2148Unsafe.BitCast<T, byte>(value), 2157ref Unsafe.Add(ref Unsafe.As<T, short>(ref MemoryMarshal.GetArrayDataReference(array)), endIndex), 2158Unsafe.BitCast<T, short>(value), 2167ref Unsafe.Add(ref Unsafe.As<T, int>(ref MemoryMarshal.GetArrayDataReference(array)), endIndex), 2168Unsafe.BitCast<T, int>(value), 2177ref Unsafe.Add(ref Unsafe.As<T, long>(ref MemoryMarshal.GetArrayDataReference(array)), endIndex), 2178Unsafe.BitCast<T, long>(value), 2297SpanHelpers.Reverse(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index), (nuint)length); 2547var span = new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index), length); 2571var spanKeys = new Span<TKey>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(keys), index), length); 2572var spanItems = new Span<TValue>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(items), index), length); 3060new Span<T>(ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)), array.Length).Slice(adjustedIndex, length);
src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (39)
46Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value ? (byte)1 : (byte)0); 74Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 102Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 130Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 158Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 186Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 216Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 246Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 276Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 306Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 334Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 362Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 390Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 416return Unsafe.ReadUnaligned<char>(ref MemoryMarshal.GetReference(value)); 437return Unsafe.ReadUnaligned<short>(ref value[startIndex]); 451return Unsafe.ReadUnaligned<short>(ref MemoryMarshal.GetReference(value)); 475return Unsafe.ReadUnaligned<int>(ref value[startIndex]); 489return Unsafe.ReadUnaligned<int>(ref MemoryMarshal.GetReference(value)); 513return Unsafe.ReadUnaligned<long>(ref value[startIndex]); 527return Unsafe.ReadUnaligned<long>(ref MemoryMarshal.GetReference(value)); 551return Unsafe.ReadUnaligned<Int128>(ref value[startIndex]); 565return Unsafe.ReadUnaligned<Int128>(ref MemoryMarshal.GetReference(value)); 592return Unsafe.ReadUnaligned<ushort>(ref MemoryMarshal.GetReference(value)); 622return Unsafe.ReadUnaligned<uint>(ref MemoryMarshal.GetReference(value)); 652return Unsafe.ReadUnaligned<ulong>(ref MemoryMarshal.GetReference(value)); 677return Unsafe.ReadUnaligned<UInt128>(ref value[startIndex]); 692return Unsafe.ReadUnaligned<UInt128>(ref MemoryMarshal.GetReference(value)); 717return Unsafe.ReadUnaligned<Half>(ref MemoryMarshal.GetReference(value)); 745return Unsafe.ReadUnaligned<float>(ref MemoryMarshal.GetReference(value)); 773return Unsafe.ReadUnaligned<double>(ref MemoryMarshal.GetReference(value)); 899return Unsafe.ReadUnaligned<byte>(ref MemoryMarshal.GetReference(value)) != 0; 908public static long DoubleToInt64Bits(double value) => Unsafe.BitCast<double, long>(value); 916public static double Int64BitsToDouble(long value) => Unsafe.BitCast<long, double>(value); 924public static int SingleToInt32Bits(float value) => Unsafe.BitCast<float, int>(value); 932public static float Int32BitsToSingle(int value) => Unsafe.BitCast<int, float>(value); 957public static ulong DoubleToUInt64Bits(double value) => Unsafe.BitCast<double, ulong>(value); 966public static double UInt64BitsToDouble(ulong value) => Unsafe.BitCast<ulong, double>(value); 975public static uint SingleToUInt32Bits(float value) => Unsafe.BitCast<float, uint>(value); 984public static float UInt32BitsToSingle(uint value) => Unsafe.BitCast<uint, float>(value);
src\libraries\System.Private.CoreLib\src\System\Buffer.cs (14)
53Memmove(ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(dst), uDstOffset), ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(src), uSrcOffset), uCount); 85return Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index); 96Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index) = value; 158ref Unsafe.As<T, byte>(ref destination), 159ref Unsafe.As<T, byte>(ref source), 166ref Unsafe.As<T, byte>(ref destination), 167ref Unsafe.As<T, byte>(ref source), 198if (Unsafe.AreSame(ref source, ref destination)) 202if ((nuint)(nint)Unsafe.ByteOffset(ref source, ref destination) >= byteCount) 210destination = ref Unsafe.AddByteOffset(ref destination, BulkMoveWithWriteBarrierChunk); 211source = ref Unsafe.AddByteOffset(ref source, BulkMoveWithWriteBarrierChunk); 221BulkMoveWithWriteBarrierInternal(ref Unsafe.AddByteOffset(ref destination, byteCount), ref Unsafe.AddByteOffset(ref source, byteCount), BulkMoveWithWriteBarrierChunk);
src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.ReverseEndianness.cs (6)
297if (Unsafe.AreSame(ref sourceRef, ref destRef) || 328Unsafe.Add(ref destRef, i) = TReverser.Reverse(Unsafe.Add(ref sourceRef, i)); 361Unsafe.Add(ref destRef, i) = TReverser.Reverse(Unsafe.Add(ref sourceRef, i)); 386if (Unsafe.AreSame(ref MemoryMarshal.GetReference(source), ref MemoryMarshal.GetReference(destination)) ||
src\libraries\System.Private.CoreLib\src\System\Buffers\SharedArrayPool.cs (3)
63buffer = Unsafe.As<T[]?>(tlsBuckets[bucketIndex].Array); 82buffer = Unsafe.As<T[]?>(b.TryPop()); 408Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(arrays), count) = array; // arrays[count] = array, but avoiding stelemref
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Helper\Base64DecoderHelper.cs (15)
174int i2 = Unsafe.Add(ref decodingMap, (IntPtr)t2); 175int i3 = Unsafe.Add(ref decodingMap, (IntPtr)t3); 197int i2 = Unsafe.Add(ref decodingMap, (IntPtr)t2); 384int i0 = Unsafe.Add(ref decodingMap, (int)t0); 385int i1 = Unsafe.Add(ref decodingMap, (int)t1); 394int i2 = Unsafe.Add(ref decodingMap, (int)t2); 395int i3 = Unsafe.Add(ref decodingMap, (int)t3); 412int i2 = Unsafe.Add(ref decodingMap, (int)t2); 558if (decoder.IsValidPadding(Unsafe.Subtract(ref ptrToLastElement, 1))) 1396int i0 = Unsafe.Add(ref decodingMap, (int)t0); 1397int i1 = Unsafe.Add(ref decodingMap, (int)t1); 1398int i2 = Unsafe.Add(ref decodingMap, (int)t2); 1399int i3 = Unsafe.Add(ref decodingMap, (int)t3); 1440int i0 = Unsafe.Add(ref decodingMap, (IntPtr)t0); 1441int i1 = Unsafe.Add(ref decodingMap, (IntPtr)t1);
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Helper\Base64EncoderHelper.cs (13)
629Unsafe.WriteUnaligned(bufferBytes + destinationIndex, result); 648uint i0 = Unsafe.Add(ref encodingMap, (IntPtr)(i >> 18)); 649uint i1 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 12) & 0x3F)); 650uint i2 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 6) & 0x3F)); 651uint i3 = Unsafe.Add(ref encodingMap, (IntPtr)(i & 0x3F)); 705uint i0 = Unsafe.Add(ref encodingMap, (IntPtr)(i >> 10)); 706uint i1 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 4) & 0x3F)); 709Unsafe.WriteUnaligned(dest, result); 720uint i0 = Unsafe.Add(ref encodingMap, (IntPtr)(i >> 18)); 721uint i1 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 12) & 0x3F)); 722uint i2 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 6) & 0x3F)); 725Unsafe.WriteUnaligned(dest, result); 769Unsafe.WriteUnaligned(destination, result);
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Helper\Base64Helper.cs (4)
21int vectorElements = Unsafe.SizeOf<TVector>(); 35int vectorElements = Unsafe.SizeOf<TVector>(); 49int vectorElements = Unsafe.SizeOf<TVector>(); 63int vectorElements = Unsafe.SizeOf<TVector>();
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Url\Base64UrlDecoder.cs (7)
315if (decoder.IsValidPadding(Unsafe.Subtract(ref ptrToLastElement, 1))) 779int i0 = Unsafe.Add(ref decodingMap, (int)t0); 780int i1 = Unsafe.Add(ref decodingMap, (int)t1); 781int i2 = Unsafe.Add(ref decodingMap, (int)t2); 782int i3 = Unsafe.Add(ref decodingMap, (int)t3); 828int i0 = Unsafe.Add(ref decodingMap, (IntPtr)t0); 829int i1 = Unsafe.Add(ref decodingMap, (IntPtr)t1);
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Url\Base64UrlEncoder.cs (17)
252byte i0 = Unsafe.Add(ref encodingMap, (IntPtr)(i >> 10)); 253byte i1 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 4) & 0x3F)); 266Unsafe.WriteUnaligned(dest, result); 277byte i0 = Unsafe.Add(ref encodingMap, (IntPtr)(i >> 18)); 278byte i1 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 12) & 0x3F)); 279byte i2 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 6) & 0x3F)); 346uint i0 = Unsafe.Add(ref encodingMap, (IntPtr)(i >> 10)); 347uint i1 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 4) & 0x3F)); 360Unsafe.WriteUnaligned(dest, result); 371ushort i0 = Unsafe.Add(ref encodingMap, (IntPtr)(i >> 18)); 372ushort i1 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 12) & 0x3F)); 373ushort i2 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 6) & 0x3F)); 434ulong i0 = Unsafe.Add(ref encodingMap, (IntPtr)(i >> 18)); 435ulong i1 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 12) & 0x3F)); 436ulong i2 = Unsafe.Add(ref encodingMap, (IntPtr)((i >> 6) & 0x3F)); 437ulong i3 = Unsafe.Add(ref encodingMap, (IntPtr)(i & 0x3F)); 449Unsafe.WriteUnaligned(destination, result);
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\FormattingHelpers.CountDigits.cs (1)
55ulong powerOf10 = Unsafe.Add(ref MemoryMarshal.GetReference(powersOf10), elementOffset);
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\ParserHelpers.cs (2)
65Unsafe.SkipInit(out value); // bypass language initialization rules since we're about to throw 66Unsafe.SkipInit(out bytesConsumed);
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Integer.Signed.cs (8)
58Unsafe.SkipInit(out value); // will be populated by TryParseByteX 59return TryParseByteX(source, out Unsafe.As<sbyte, byte>(ref value), out bytesConsumed); 110Unsafe.SkipInit(out value); // will be populated by TryParseUInt16X 111return TryParseUInt16X(source, out Unsafe.As<short, ushort>(ref value), out bytesConsumed); 162Unsafe.SkipInit(out value); // will be populated by TryParseUInt32X 163return TryParseUInt32X(source, out Unsafe.As<int, uint>(ref value), out bytesConsumed); 214Unsafe.SkipInit(out value); // will be populated by TryParseUInt64X 215return TryParseUInt64X(source, out Unsafe.As<long, ulong>(ref value), out bytesConsumed);
src\libraries\System.Private.CoreLib\src\System\ByReference.cs (1)
17public static ByReference Create<T>(ref T p) => new ByReference(ref Unsafe.As<T, byte>(ref p));
src\libraries\System.Private.CoreLib\src\System\Byte.cs (1)
322result = Unsafe.Add(ref MemoryMarshal.GetReference(source), source.Length - sizeof(byte));
src\libraries\System.Private.CoreLib\src\System\Char.cs (3)
1239sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(char)); 1242result = Unsafe.ReadUnaligned<char>(ref sourceRef); 1290result = Unsafe.ReadUnaligned<char>(ref sourceRef);
src\libraries\System.Private.CoreLib\src\System\Collections\BitArray.cs (7)
170ref byte value = ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetArrayDataReference<bool>(values)); 179Unsafe.WriteUnaligned(ref Unsafe.Add(ref arrayRef, sizeof(ulong) * (i / 64u)), ~result); 190Unsafe.WriteUnaligned(ref Unsafe.Add(ref arrayRef, sizeof(uint) * (i / 32u)), ~result); 205Unsafe.WriteUnaligned( 206ref Unsafe.Add(ref arrayRef, sizeof(uint) * (i / 32u)),
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs (21)
401Debug.Assert(!Unsafe.AreSame(ref i, ref j)); 464ref T lastRef = ref Unsafe.Add(ref zeroRef, keys.Length - 1); 465ref T middleRef = ref Unsafe.Add(ref zeroRef, (keys.Length - 1) >> 1); 471ref T nextToLastRef = ref Unsafe.Add(ref zeroRef, keys.Length - 2); 477while (Unsafe.IsAddressLessThan(ref leftRef, ref rightRef)) 481while (Unsafe.IsAddressLessThan(ref leftRef, ref nextToLastRef) && (leftRef = ref Unsafe.Add(ref leftRef, 1)) == null) ; 482while (Unsafe.IsAddressGreaterThan(ref rightRef, ref zeroRef) && (rightRef = ref Unsafe.Add(ref rightRef, -1)) != null) ; 486while (Unsafe.IsAddressLessThan(ref leftRef, ref nextToLastRef) && GreaterThan(ref pivot, ref leftRef = ref Unsafe.Add(ref leftRef, 1))) ; 487while (Unsafe.IsAddressGreaterThan(ref rightRef, ref zeroRef) && LessThan(ref pivot, ref rightRef = ref Unsafe.Add(ref rightRef, -1))) ; 490if (!Unsafe.IsAddressLessThan(ref leftRef, ref rightRef)) 499if (!Unsafe.AreSame(ref leftRef, ref nextToLastRef)) 504return (int)((nint)Unsafe.ByteOffset(ref zeroRef, ref leftRef) / sizeof(T)); 549T t = Unsafe.Add(ref MemoryMarshal.GetReference(keys), i + 1); 552while (j >= 0 && (t == null || LessThan(ref t, ref Unsafe.Add(ref MemoryMarshal.GetReference(keys), j)))) 554Unsafe.Add(ref MemoryMarshal.GetReference(keys), j + 1) = Unsafe.Add(ref MemoryMarshal.GetReference(keys), j); 558Unsafe.Add(ref MemoryMarshal.GetReference(keys), j + 1) = t!;
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\Dictionary.cs (17)
233if (!Unsafe.IsNullRef(ref value)) 260if (!Unsafe.IsNullRef(ref value) && EqualityComparer<TValue>.Default.Equals(value, keyValuePair.Value)) 271if (!Unsafe.IsNullRef(ref value) && EqualityComparer<TValue>.Default.Equals(value, keyValuePair.Value)) 298!Unsafe.IsNullRef(ref FindValue(key)); 404ref Entry entry = ref Unsafe.NullRef<Entry>(); 484value = ref Unsafe.NullRef<TValue>(); 716if (Unsafe.IsNullRef(ref value)) 739return Unsafe.As<IAlternateEqualityComparer<TAlternateKey, TKey>>(dictionary._comparer); 753if (!Unsafe.IsNullRef(ref valueRef)) 778if (!Unsafe.IsNullRef(ref valueRef)) 794!Unsafe.IsNullRef(ref FindValue(key, out _)); 805ref Entry entry = ref Unsafe.NullRef<Entry>(); 850value = ref Unsafe.NullRef<TValue>(); 1051Debug.Assert(!Unsafe.IsNullRef(ref value), "the lookup result cannot be a null ref here"); 1188Debug.Assert(!Unsafe.IsNullRef(ref value), "the lookup result cannot be a null ref here"); 1444if (!Unsafe.IsNullRef(ref valRef)) 1650if (!Unsafe.IsNullRef(ref value))
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\HashSet.cs (7)
447return Unsafe.As<IAlternateEqualityComparer<TAlternate, T>>(set._comparer); 470ref int bucket = ref Unsafe.NullRef<int>(); 606public bool Contains(TAlternate item) => !Unsafe.IsNullRef(in FindValue(item)); 615if (!Unsafe.IsNullRef(in value)) 631ref Entry entry = ref Unsafe.NullRef<Entry>(); 675value = ref Unsafe.NullRef<T>(); 1426ref int bucket = ref Unsafe.NullRef<int>();
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\RandomizedStringEqualityComparer.cs (1)
90ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(alternate)),
src\libraries\System.Private.CoreLib\src\System\ComAwareWeakReference.cs (4)
146return Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits)); 153return Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits)).Target; 159return Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits))._weakHandle; 167Unsafe.As<ComAwareWeakReference>(GCHandle.InternalGet(taggedHandle & ~HandleTagBits));
src\libraries\System.Private.CoreLib\src\System\Convert.Base64.cs (24)
64int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 67WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 82int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 83int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 84int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 85int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 89i0 = Unsafe.Add(ref decodingMap, i0); 90i1 = Unsafe.Add(ref decodingMap, i1); 99i2 = Unsafe.Add(ref decodingMap, i2); 100i3 = Unsafe.Add(ref decodingMap, i3); 111WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 116i2 = Unsafe.Add(ref decodingMap, i2); 126Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 127Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 136Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 161int i1 = Unsafe.Add(ref encodedChars, 1); 162int i2 = Unsafe.Add(ref encodedChars, 2); 163int i3 = Unsafe.Add(ref encodedChars, 3); 168i0 = Unsafe.Add(ref decodingMap, i0); 169i1 = Unsafe.Add(ref decodingMap, i1); 170i2 = Unsafe.Add(ref decodingMap, i2); 171i3 = Unsafe.Add(ref decodingMap, i3); 188Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 189Unsafe.Add(ref destination, 2) = (byte)value;
src\libraries\System.Private.CoreLib\src\System\Convert.cs (21)
2488ref ushort dest = ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(chars)); 2489ref byte src = ref Unsafe.As<ushort, byte>(ref dest); 2495dest = ref Unsafe.Add(ref dest, charLengthRequired); 2496src = ref Unsafe.Add(ref src, charLengthRequired); 2501ref byte srcBeginningPlus31 = ref Unsafe.Add(ref srcBeginning, 31); 2502while (Unsafe.IsAddressGreaterThan(ref src, ref srcBeginningPlus31)) 2504src = ref Unsafe.Subtract(ref src, 32); 2505dest = ref Unsafe.Subtract(ref dest, 32); 2517ref byte srcBeginningPlus15 = ref Unsafe.Add(ref srcBeginning, 15); 2518while (Unsafe.IsAddressGreaterThan(ref src, ref srcBeginningPlus15)) 2520src = ref Unsafe.Subtract(ref src, 16); 2521dest = ref Unsafe.Subtract(ref dest, 16); 2531ref byte srcBeginningPlus3 = ref Unsafe.Add(ref srcBeginning, 3); 2532while (Unsafe.IsAddressGreaterThan(ref src, ref srcBeginningPlus3)) 2534dest = ref Unsafe.Subtract(ref dest, 4); 2535src = ref Unsafe.Subtract(ref src, 4); 2536Ascii.WidenFourAsciiBytesToUtf16AndWriteToBuffer(ref Unsafe.As<ushort, char>(ref dest), Unsafe.ReadUnaligned<uint>(ref src)); 2543Debug.Assert(Unsafe.AreSame(ref srcBeginning, ref src)); 2544Debug.Assert(Unsafe.AreSame(ref srcBeginning, ref Unsafe.As<ushort, byte>(ref dest)),
src\libraries\System.Private.CoreLib\src\System\Decimal.cs (6)
1188Unsafe.WriteUnaligned(ref address, hi32); 1189Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref address, sizeof(uint)), lo64); 1217Unsafe.WriteUnaligned(ref address, lo64); 1218Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref address, sizeof(ulong)), hi32);
src\libraries\System.Private.CoreLib\src\System\Decimal.DecCalc.cs (11)
24private static ref DecCalc AsMutable(ref decimal d) => ref Unsafe.As<decimal, DecCalc>(ref d); 1067Unsafe.SkipInit(out Buf24 bufNum); 1408Unsafe.SkipInit(out Buf24 bufProd); 1940Unsafe.SkipInit(out Buf12 bufQuo); 2038Unsafe.SkipInit(out Buf16 bufRem); 2104Unsafe.SkipInit(out Buf12 bufDivisor); 2218int cmp = VarDecCmpSub(in Unsafe.As<DecCalc, decimal>(ref d1), in Unsafe.As<DecCalc, decimal>(ref d2)); 2253Unsafe.SkipInit(out Buf12 bufQuo); 2309Unsafe.SkipInit(out Buf28 b); 2363Unsafe.SkipInit(out Buf12 bufDivisor);
src\libraries\System.Private.CoreLib\src\System\Delegate.cs (3)
81public bool HasSingleTarget => Unsafe.As<MulticastDelegate>(this).HasSingleTarget; 97=> new InvocationListEnumerator<TDelegate>(Unsafe.As<MulticastDelegate>(d)); 131if ((_current = Unsafe.As<TDelegate>(_delegate?.TryGetAt(index))) == null)
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs (2)
2824if (Unsafe.IsNullRef(ref eventMeta)) return false; 3333if (!Unsafe.IsNullRef(ref startEventMetadata))
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\NativeRuntimeEventSource.cs (1)
55if (Unsafe.IsNullRef(ref metadata))
src\libraries\System.Private.CoreLib\src\System\Enum.cs (111)
421ushort flagsValue = Unsafe.As<byte, ushort>(ref pFlagsValue); 422return (Unsafe.As<byte, ushort>(ref pThisValue) & flagsValue) == flagsValue; 428uint flagsValue = Unsafe.As<byte, uint>(ref pFlagsValue); 429return (Unsafe.As<byte, uint>(ref pThisValue) & flagsValue) == flagsValue; 435ulong flagsValue = Unsafe.As<byte, ulong>(ref pFlagsValue); 436return (Unsafe.As<byte, ulong>(ref pThisValue) & flagsValue) == flagsValue; 890Unsafe.SkipInit(out result); 894if (underlyingType == typeof(sbyte)) return TryParseByValueOrName<sbyte, byte>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, sbyte>(ref result)); 895if (underlyingType == typeof(byte)) return TryParseByValueOrName<byte, byte>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, byte>(ref result)); 896if (underlyingType == typeof(short)) return TryParseByValueOrName<short, ushort>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, short>(ref result)); 897if (underlyingType == typeof(ushort)) return TryParseByValueOrName<ushort, ushort>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, ushort>(ref result)); 898if (underlyingType == typeof(int)) return TryParseByValueOrName<int, uint>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, int>(ref result)); 899if (underlyingType == typeof(uint)) return TryParseByValueOrName<uint, uint>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, uint>(ref result)); 900if (underlyingType == typeof(long)) return TryParseByValueOrName<long, ulong>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, long>(ref result)); 901if (underlyingType == typeof(ulong)) return TryParseByValueOrName<ulong, ulong>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, ulong>(ref result)); 903if (underlyingType == typeof(nint)) return TryParseRareTypeByValueOrName<nint, nuint>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, nint>(ref result)); 904if (underlyingType == typeof(nuint)) return TryParseRareTypeByValueOrName<nuint, nuint>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, nuint>(ref result)); 905if (underlyingType == typeof(float)) return TryParseRareTypeByValueOrName<float, float>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, float>(ref result)); 906if (underlyingType == typeof(double)) return TryParseRareTypeByValueOrName<double, double>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, double>(ref result)); 907if (underlyingType == typeof(char)) return TryParseRareTypeByValueOrName<char, char>(rt, value, ignoreCase, throwOnFailure, out Unsafe.As<TEnum, char>(ref result)); 937Unsafe.SkipInit(out result); 938return TryParseByName(enumType, value, ignoreCase, throwOnFailure, out Unsafe.As<TUnderlying, TStorage>(ref result)); 952Unsafe.SkipInit(out result); 953return TryParseByName(enumType, value, ignoreCase, throwOnFailure, out Unsafe.As<TUnderlying, TStorage>(ref result)); 995Unsafe.SkipInit(out result); 996return TryParseByName(enumType, value, ignoreCase, throwOnFailure, out Unsafe.As<TUnderlying, TStorage>(ref result)); 1019Unsafe.SkipInit(out result); 1020return TryParseByName(enumType, value, ignoreCase, throwOnFailure, out Unsafe.As<TUnderlying, TStorage>(ref result)); 1169CorElementType.ELEMENT_TYPE_I1 => Unsafe.As<byte, sbyte>(ref data), 1171CorElementType.ELEMENT_TYPE_I2 => Unsafe.As<byte, short>(ref data), 1172CorElementType.ELEMENT_TYPE_U2 => Unsafe.As<byte, ushort>(ref data), 1173CorElementType.ELEMENT_TYPE_I4 => Unsafe.As<byte, int>(ref data), 1174CorElementType.ELEMENT_TYPE_U4 => Unsafe.As<byte, uint>(ref data), 1175CorElementType.ELEMENT_TYPE_I8 => Unsafe.As<byte, long>(ref data), 1176CorElementType.ELEMENT_TYPE_U8 => Unsafe.As<byte, ulong>(ref data), 1178CorElementType.ELEMENT_TYPE_R4 => Unsafe.As<byte, float>(ref data), 1179CorElementType.ELEMENT_TYPE_R8 => Unsafe.As<byte, double>(ref data), 1180CorElementType.ELEMENT_TYPE_I => Unsafe.As<byte, IntPtr>(ref data), 1181CorElementType.ELEMENT_TYPE_U => Unsafe.As<byte, UIntPtr>(ref data), 1182CorElementType.ELEMENT_TYPE_CHAR => Unsafe.As<byte, char>(ref data), 1183CorElementType.ELEMENT_TYPE_BOOLEAN => Unsafe.As<byte, bool>(ref data), 1212return Unsafe.As<byte, ushort>(ref pThisValue) == Unsafe.As<byte, ushort>(ref pOtherValue); 1216return Unsafe.As<byte, uint>(ref pThisValue) == Unsafe.As<byte, uint>(ref pOtherValue); 1220return Unsafe.As<byte, ulong>(ref pThisValue) == Unsafe.As<byte, ulong>(ref pOtherValue); 1259CorElementType.ELEMENT_TYPE_I1 => Unsafe.As<byte, sbyte>(ref data).GetHashCode(), 1261CorElementType.ELEMENT_TYPE_I2 => Unsafe.As<byte, short>(ref data).GetHashCode(), 1262CorElementType.ELEMENT_TYPE_U2 => Unsafe.As<byte, ushort>(ref data).GetHashCode(), 1263CorElementType.ELEMENT_TYPE_I4 => Unsafe.As<byte, int>(ref data).GetHashCode(), 1264CorElementType.ELEMENT_TYPE_U4 => Unsafe.As<byte, uint>(ref data).GetHashCode(), 1265CorElementType.ELEMENT_TYPE_I8 => Unsafe.As<byte, long>(ref data).GetHashCode(), 1266CorElementType.ELEMENT_TYPE_U8 => Unsafe.As<byte, ulong>(ref data).GetHashCode(), 1268CorElementType.ELEMENT_TYPE_R4 => Unsafe.As<byte, float>(ref data).GetHashCode(), 1269CorElementType.ELEMENT_TYPE_R8 => Unsafe.As<byte, double>(ref data).GetHashCode(), 1270CorElementType.ELEMENT_TYPE_I => Unsafe.As<byte, IntPtr>(ref data).GetHashCode(), 1271CorElementType.ELEMENT_TYPE_U => Unsafe.As<byte, UIntPtr>(ref data).GetHashCode(), 1272CorElementType.ELEMENT_TYPE_CHAR => Unsafe.As<byte, char>(ref data).GetHashCode(), 1273CorElementType.ELEMENT_TYPE_BOOLEAN => Unsafe.As<byte, bool>(ref data).GetHashCode(), 1297return Unsafe.As<byte, sbyte>(ref pThisValue).CompareTo(Unsafe.As<byte, sbyte>(ref pTargetValue)); 1303return Unsafe.As<byte, short>(ref pThisValue).CompareTo(Unsafe.As<byte, short>(ref pTargetValue)); 1306return Unsafe.As<byte, ushort>(ref pThisValue).CompareTo(Unsafe.As<byte, ushort>(ref pTargetValue)); 1309return Unsafe.As<byte, int>(ref pThisValue).CompareTo(Unsafe.As<byte, int>(ref pTargetValue)); 1312return Unsafe.As<byte, uint>(ref pThisValue).CompareTo(Unsafe.As<byte, uint>(ref pTargetValue)); 1315return Unsafe.As<byte, long>(ref pThisValue).CompareTo(Unsafe.As<byte, long>(ref pTargetValue)); 1318return Unsafe.As<byte, ulong>(ref pThisValue).CompareTo(Unsafe.As<byte, ulong>(ref pTargetValue)); 1322return Unsafe.As<byte, float>(ref pThisValue).CompareTo(Unsafe.As<byte, float>(ref pTargetValue)); 1325return Unsafe.As<byte, double>(ref pThisValue).CompareTo(Unsafe.As<byte, double>(ref pTargetValue)); 1469TStorage value = Unsafe.As<byte, TStorage>(ref rawData); 1476return result ?? Unsafe.BitCast<TStorage, TUnderlying>(value).ToString()!; 1499TStorage value = Unsafe.As<byte, TStorage>(ref rawData); 1514result = Unsafe.BitCast<TStorage, TUnderlying>(value).ToString()!; 1566ushort value = Unsafe.As<byte, ushort>(ref data); 1577uint value = Unsafe.As<byte, uint>(ref data); 1590ulong value = Unsafe.As<byte, ulong>(ref data); 1699CorElementType.ELEMENT_TYPE_I2 => TryFormatPrimitiveDefault<short, ushort>(enumType, Unsafe.As<byte, short>(ref rawData), destination, out charsWritten), 1700CorElementType.ELEMENT_TYPE_U2 => TryFormatPrimitiveDefault<ushort, ushort>(enumType, Unsafe.As<byte, ushort>(ref rawData), destination, out charsWritten), 1701CorElementType.ELEMENT_TYPE_I4 => TryFormatPrimitiveDefault<int, uint>(enumType, Unsafe.As<byte, int>(ref rawData), destination, out charsWritten), 1702CorElementType.ELEMENT_TYPE_U4 => TryFormatPrimitiveDefault<uint, uint>(enumType, Unsafe.As<byte, uint>(ref rawData), destination, out charsWritten), 1703CorElementType.ELEMENT_TYPE_I8 => TryFormatPrimitiveDefault<long, ulong>(enumType, Unsafe.As<byte, long>(ref rawData), destination, out charsWritten), 1704CorElementType.ELEMENT_TYPE_U8 => TryFormatPrimitiveDefault<ulong, ulong>(enumType, Unsafe.As<byte, ulong>(ref rawData), destination, out charsWritten), 1706CorElementType.ELEMENT_TYPE_R4 => TryFormatPrimitiveDefault<float, float>(enumType, Unsafe.As<byte, float>(ref rawData), destination, out charsWritten), 1707CorElementType.ELEMENT_TYPE_R8 => TryFormatPrimitiveDefault<double, double>(enumType, Unsafe.As<byte, double>(ref rawData), destination, out charsWritten), 1708CorElementType.ELEMENT_TYPE_I => TryFormatPrimitiveDefault<nint, nuint>(enumType, Unsafe.As<byte, nint>(ref rawData), destination, out charsWritten), 1709CorElementType.ELEMENT_TYPE_U => TryFormatPrimitiveDefault<nuint, nuint>(enumType, Unsafe.As<byte, nuint>(ref rawData), destination, out charsWritten), 1710CorElementType.ELEMENT_TYPE_CHAR => TryFormatPrimitiveDefault<char, char>(enumType, Unsafe.As<byte, char>(ref rawData), destination, out charsWritten), 1721CorElementType.ELEMENT_TYPE_I2 => TryFormatPrimitiveNonDefault<short, ushort>(enumType, Unsafe.As<byte, short>(ref rawData), destination, out charsWritten, format), 1722CorElementType.ELEMENT_TYPE_U2 => TryFormatPrimitiveNonDefault<ushort, ushort>(enumType, Unsafe.As<byte, ushort>(ref rawData), destination, out charsWritten, format), 1723CorElementType.ELEMENT_TYPE_I4 => TryFormatPrimitiveNonDefault<int, uint>(enumType, Unsafe.As<byte, int>(ref rawData), destination, out charsWritten, format), 1724CorElementType.ELEMENT_TYPE_U4 => TryFormatPrimitiveNonDefault<uint, uint>(enumType, Unsafe.As<byte, uint>(ref rawData), destination, out charsWritten, format), 1725CorElementType.ELEMENT_TYPE_I8 => TryFormatPrimitiveNonDefault<long, ulong>(enumType, Unsafe.As<byte, long>(ref rawData), destination, out charsWritten, format), 1726CorElementType.ELEMENT_TYPE_U8 => TryFormatPrimitiveNonDefault<ulong, ulong>(enumType, Unsafe.As<byte, ulong>(ref rawData), destination, out charsWritten, format), 1728CorElementType.ELEMENT_TYPE_R4 => TryFormatPrimitiveNonDefault<float, float>(enumType, Unsafe.As<byte, float>(ref rawData), destination, out charsWritten, format), 1729CorElementType.ELEMENT_TYPE_R8 => TryFormatPrimitiveNonDefault<double, double>(enumType, Unsafe.As<byte, double>(ref rawData), destination, out charsWritten, format), 1730CorElementType.ELEMENT_TYPE_I => TryFormatPrimitiveNonDefault<nint, nuint>(enumType, Unsafe.As<byte, nint>(ref rawData), destination, out charsWritten, format), 1731CorElementType.ELEMENT_TYPE_U => TryFormatPrimitiveNonDefault<nuint, nuint>(enumType, Unsafe.As<byte, nuint>(ref rawData), destination, out charsWritten, format), 1732CorElementType.ELEMENT_TYPE_CHAR => TryFormatPrimitiveNonDefault<char, char>(enumType, Unsafe.As<byte, char>(ref rawData), destination, out charsWritten, format), 1866if (GetNameInlined(enumInfo, Unsafe.BitCast<TUnderlying, TStorage>(value)) is string enumName) 1881if (TryFormatFlagNames(enumInfo, Unsafe.BitCast<TUnderlying, TStorage>(value), destination, out charsWritten, ref destinationIsTooSmall) || destinationIsTooSmall) 1910return TryFormatNumberAsHex<TStorage>(ref Unsafe.As<TUnderlying, byte>(ref value), destination, out charsWritten); 1914if (TryFormatFlagNames(GetEnumInfo<TStorage>(enumType), Unsafe.BitCast<TUnderlying, TStorage>(value), destination, out charsWritten, ref destinationIsTooSmall) ||
src\libraries\System.Private.CoreLib\src\System\Globalization\CharUnicodeInfo.cs (27)
88StrongBidiCategory bidiCategory = (StrongBidiCategory)(Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(CategoriesValues), offset) & 0b_0110_0000); 124uint rawValue = Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(DigitValues), offset); 158int rawValue = Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(DigitValues), offset); 172return (GraphemeClusterBreakType)Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(GraphemeSegmentationValues), offset); 190return (sbyte)Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(CategoriesValues), offset) < 0; 236ref byte refToValue = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(NumericValues), offset * 8 /* sizeof(double) */); 242return Unsafe.ReadUnaligned<double>(ref refToValue); 246ulong temp = Unsafe.ReadUnaligned<ulong>(ref refToValue); 260ref short rsStart = ref Unsafe.As<byte, short>(ref MemoryMarshal.GetReference(UppercaseValues)); 261ref short rsDelta = ref Unsafe.Add(ref rsStart, (nint)offset); 279ref ushort rsStart = ref Unsafe.As<byte, ushort>(ref MemoryMarshal.GetReference(UppercaseValues)); 280ref ushort rsDelta = ref Unsafe.Add(ref rsStart, (nint)offset); 295ref short rsStart = ref Unsafe.As<byte, short>(ref MemoryMarshal.GetReference(LowercaseValues)); 296ref short rsDelta = ref Unsafe.Add(ref rsStart, (nint)offset); 314ref ushort rsStart = ref Unsafe.As<byte, ushort>(ref MemoryMarshal.GetReference(LowercaseValues)); 315ref ushort rsDelta = ref Unsafe.Add(ref rsStart, (nint)offset); 394return (UnicodeCategory)(Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(CategoriesValues), offset) & 0x1F); 456uint index = Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(CategoryCasingLevel1Index), codePoint >> 9); 462ref byte level2Ref = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(CategoryCasingLevel2Index), (index << 6) + ((codePoint >> 3) & 0b_0011_1110)); 466index = Unsafe.ReadUnaligned<ushort>(ref level2Ref); 470index = BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ushort>(ref level2Ref)); 476return Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(CategoryCasingLevel3Index), (index << 4) + (codePoint & 0x0F)); 493uint index = Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(NumericGraphemeLevel1Index), codePoint >> 9); 499ref byte level2Ref = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(NumericGraphemeLevel2Index), (index << 6) + ((codePoint >> 3) & 0b_0011_1110)); 503index = Unsafe.ReadUnaligned<ushort>(ref level2Ref); 507index = BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ushort>(ref level2Ref)); 513return Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(NumericGraphemeLevel3Index), (index << 4) + (codePoint & 0x0F));
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.cs (2)
367Debug.Assert(!Unsafe.IsNullRef(ref MemoryMarshal.GetReference(span1))); 368Debug.Assert(!Unsafe.IsNullRef(ref MemoryMarshal.GetReference(span2)));
src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeFormat.cs (5)
766result.Append(Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(s)); 771Encoding.UTF8.GetBytes(s, Unsafe.BitCast<Span<TChar>, Span<byte>>(result.AppendSpan(Encoding.UTF8.GetByteCount(s)))); 780fraction.TryFormat(Unsafe.BitCast<Span<TChar>, Span<char>>(chars), out charCount, fractionFormat, CultureInfo.InvariantCulture) : 781fraction.TryFormat(Unsafe.BitCast<Span<TChar>, Span<byte>>(chars), out charCount, fractionFormat, CultureInfo.InvariantCulture); 1115bool success = Unsafe.AreSame(ref MemoryMarshal.GetReference(destination), ref MemoryMarshal.GetReference(vlb.AsSpan()));
src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeFormatInfo.cs (10)
372Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(AMDesignator) : 373Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(amDesignatorUtf8 ??= Encoding.UTF8.GetBytes(AMDesignator)); 621Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(DateSeparator) : 622Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(dateSeparatorUtf8 ??= Encoding.UTF8.GetBytes(DateSeparator)); 824Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(PMDesignator) : 825Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(pmDesignatorUtf8 ??= Encoding.UTF8.GetBytes(PMDesignator)); 1006Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(TimeSeparator) : 1007Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(timeSeparatorUtf8 ??= Encoding.UTF8.GetBytes(TimeSeparator)); 1706Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(DecimalSeparator) : 1707Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_decimalSeparatorUtf8 ??= Encoding.UTF8.GetBytes(DecimalSeparator));
src\libraries\System.Private.CoreLib\src\System\Globalization\InvariantModeCasing.cs (5)
172char charB = Unsafe.Add(ref source, 1); 201charA = ref Unsafe.Add(ref charA, codePointLengthA); 202charB = ref Unsafe.Add(ref charB, codePointLengthB); 213charA = ref Unsafe.Add(ref charA, codePointLengthA); 214charB = ref Unsafe.Add(ref charB, codePointLengthB);
src\libraries\System.Private.CoreLib\src\System\Globalization\NumberFormatInfo.cs (28)
272Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_currencyDecimalSeparator) : 273Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_currencyDecimalSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_currencyDecimalSeparator)); 364Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_currencyGroupSeparator) : 365Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_currencyGroupSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_currencyGroupSeparator)); 386Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_currencySymbol) : 387Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_currencySymbolUtf8 ??= Encoding.UTF8.GetBytes(_currencySymbol)); 432Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_nanSymbol) : 433Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_nanSymbolUtf8 ??= Encoding.UTF8.GetBytes(_nanSymbol)); 517Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_negativeInfinitySymbol) : 518Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_negativeInfinitySymbolUtf8 ??= Encoding.UTF8.GetBytes(_negativeInfinitySymbol)); 540Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_negativeSign) : 541Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_negativeSignUtf8 ??= Encoding.UTF8.GetBytes(_negativeSign)); 576Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_numberDecimalSeparator) : 577Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_numberDecimalSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_numberDecimalSeparator)); 597Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_numberGroupSeparator) : 598Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_numberGroupSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_numberGroupSeparator)); 634Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_positiveInfinitySymbol) : 635Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_positiveInfinitySymbolUtf8 ??= Encoding.UTF8.GetBytes(_positiveInfinitySymbol)); 657Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_positiveSign) : 658Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_positiveSignUtf8 ??= Encoding.UTF8.GetBytes(_positiveSign)); 693Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_percentDecimalSeparator) : 694Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_percentDecimalSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_percentDecimalSeparator)); 714Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_percentGroupSeparator) : 715Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_percentGroupSeparatorUtf8 ??= Encoding.UTF8.GetBytes(_percentGroupSeparator)); 735Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_percentSymbol) : 736Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_percentSymbolUtf8 ??= Encoding.UTF8.GetBytes(_percentSymbol)); 757Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(_perMilleSymbol) : 758Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(_perMilleSymbolUtf8 ??= Encoding.UTF8.GetBytes(_perMilleSymbol));
src\libraries\System.Private.CoreLib\src\System\Globalization\Ordinal.cs (33)
33charA = ref Unsafe.Add(ref charA, 1); 34charB = ref Unsafe.Add(ref charB, 1); 96vec1 = TVector.LoadUnsafe(ref Unsafe.As<char, ushort>(ref charA), i); 97vec2 = TVector.LoadUnsafe(ref Unsafe.As<char, ushort>(ref charB), i); 123vec1 = TVector.LoadUnsafe(ref Unsafe.As<char, ushort>(ref charA), i); 124vec2 = TVector.LoadUnsafe(ref Unsafe.As<char, ushort>(ref charB), i); 155ref Unsafe.Add(ref charA, i), (int)(lengthU - i), 156ref Unsafe.Add(ref charB, i), (int)(lengthU - i)) == 0; 187valueAu64 = Unsafe.ReadUnaligned<ulong>(ref Unsafe.As<char, byte>(ref Unsafe.AddByteOffset(ref charA, byteOffset))); 188valueBu64 = Unsafe.ReadUnaligned<ulong>(ref Unsafe.As<char, byte>(ref Unsafe.AddByteOffset(ref charB, byteOffset))); 222valueAu32 = Unsafe.ReadUnaligned<uint>(ref Unsafe.As<char, byte>(ref Unsafe.AddByteOffset(ref charA, byteOffset))); 223valueBu32 = Unsafe.ReadUnaligned<uint>(ref Unsafe.As<char, byte>(ref Unsafe.AddByteOffset(ref charB, byteOffset))); 250valueAu32 = Unsafe.AddByteOffset(ref charA, byteOffset); 251valueBu32 = Unsafe.AddByteOffset(ref charB, byteOffset); 294return CompareStringIgnoreCase(ref Unsafe.AddByteOffset(ref charA, byteOffset), length, ref Unsafe.AddByteOffset(ref charB, byteOffset), length) == 0; 377valueCharU = Unsafe.Add(ref valueRef, valueTailLength); 400? PackedSpanHelpers.IndexOfAnyIgnoreCase(ref Unsafe.Add(ref searchSpace, offset), valueCharL, searchSpaceMinusValueTailLength) 401: SpanHelpers.IndexOfAnyChar(ref Unsafe.Add(ref searchSpace, offset), valueCharU, valueCharL, searchSpaceMinusValueTailLength) : 402SpanHelpers.IndexOfChar(ref Unsafe.Add(ref searchSpace, offset), valueChar, searchSpaceMinusValueTailLength); 418ref Unsafe.Add(ref searchSpace, (nuint)(offset + 1)), 419ref Unsafe.Add(ref valueRef, 1), valueTailLength)) 445char tmp = Unsafe.Add(ref valueRef, ch1ch2Distance - 1); 507if (EqualsIgnoreCase(ref Unsafe.Add(ref searchSpace, offset + charPos), ref valueRef, value.Length)) 573if (EqualsIgnoreCase(ref Unsafe.Add(ref searchSpace, offset + charPos), ref valueRef, value.Length))
src\libraries\System.Private.CoreLib\src\System\Globalization\Ordinal.Utf8.cs (56)
38charA = ref Unsafe.Add(ref charA, 1); 39charB = ref Unsafe.Add(ref charB, 1); 145return EqualsIgnoreCaseUtf8_Scalar(ref Unsafe.Add(ref charA, i), (int)(lengthU - i), ref Unsafe.Add(ref charB, i), (int)(lengthU - i)); 156ref Unsafe.Add(ref charA, i), lengthA - (int)i, 157ref Unsafe.Add(ref charB, i), lengthB - (int)i 186valueAu64 = Unsafe.ReadUnaligned<ulong>(ref Unsafe.AddByteOffset(ref charA, byteOffset)); 187valueBu64 = Unsafe.ReadUnaligned<ulong>(ref Unsafe.AddByteOffset(ref charB, byteOffset)); 225valueAu32 = Unsafe.ReadUnaligned<uint>(ref Unsafe.AddByteOffset(ref charA, byteOffset)); 226valueBu32 = Unsafe.ReadUnaligned<uint>(ref Unsafe.AddByteOffset(ref charB, byteOffset)); 260valueAu32 = Unsafe.ReadUnaligned<ushort>(ref Unsafe.AddByteOffset(ref charA, byteOffset)); 261valueBu32 = Unsafe.ReadUnaligned<ushort>(ref Unsafe.AddByteOffset(ref charB, byteOffset)); 265valueAu32 |= (uint)(Unsafe.AddByteOffset(ref charA, byteOffset) << 16); 266valueBu32 |= (uint)(Unsafe.AddByteOffset(ref charB, byteOffset) << 16); 270valueAu32 = Unsafe.ReadUnaligned<ushort>(ref Unsafe.AddByteOffset(ref charA, byteOffset)); 271valueBu32 = Unsafe.ReadUnaligned<ushort>(ref Unsafe.AddByteOffset(ref charB, byteOffset)); 277valueAu32 = Unsafe.AddByteOffset(ref charA, byteOffset); 278valueBu32 = Unsafe.AddByteOffset(ref charB, byteOffset); 326return EqualsStringIgnoreCaseUtf8(ref Unsafe.AddByteOffset(ref charA, byteOffset), lengthA - range, ref Unsafe.AddByteOffset(ref charB, byteOffset), lengthB - range); 348source = ref Unsafe.Add(ref source, 1); 349prefix = ref Unsafe.Add(ref prefix, 1); 455return StartsWithIgnoreCaseUtf8_Scalar(ref Unsafe.Add(ref source, i), (int)(lengthU - i), ref Unsafe.Add(ref prefix, i), (int)(lengthU - i)); 466ref Unsafe.Add(ref source, i), sourceLength - (int)i, 467ref Unsafe.Add(ref prefix, i), prefixLength - (int)i 496valueAu64 = Unsafe.ReadUnaligned<ulong>(ref Unsafe.AddByteOffset(ref source, byteOffset)); 497valueBu64 = Unsafe.ReadUnaligned<ulong>(ref Unsafe.AddByteOffset(ref prefix, byteOffset)); 535valueAu32 = Unsafe.ReadUnaligned<uint>(ref Unsafe.AddByteOffset(ref source, byteOffset)); 536valueBu32 = Unsafe.ReadUnaligned<uint>(ref Unsafe.AddByteOffset(ref prefix, byteOffset)); 570valueAu32 = Unsafe.ReadUnaligned<ushort>(ref Unsafe.AddByteOffset(ref source, byteOffset)); 571valueBu32 = Unsafe.ReadUnaligned<ushort>(ref Unsafe.AddByteOffset(ref prefix, byteOffset)); 575valueAu32 |= (uint)(Unsafe.AddByteOffset(ref source, byteOffset) << 16); 576valueBu32 |= (uint)(Unsafe.AddByteOffset(ref prefix, byteOffset) << 16); 580valueAu32 = Unsafe.ReadUnaligned<ushort>(ref Unsafe.AddByteOffset(ref source, byteOffset)); 581valueBu32 = Unsafe.ReadUnaligned<ushort>(ref Unsafe.AddByteOffset(ref prefix, byteOffset)); 587valueAu32 = Unsafe.AddByteOffset(ref source, byteOffset); 588valueBu32 = Unsafe.AddByteOffset(ref prefix, byteOffset); 640return StartsWithStringIgnoreCaseUtf8(ref Unsafe.AddByteOffset(ref source, byteOffset), sourceLength - range, ref Unsafe.AddByteOffset(ref prefix, byteOffset), prefixLength - range);
src\libraries\System.Private.CoreLib\src\System\Globalization\OrdinalCasing.Icu.cs (11)
204if (!char.IsHighSurrogate(a) || index >= lengthA - 1 || !char.IsLowSurrogate(lowSurrogateA = Unsafe.Add(ref charA, 1))) 206if (!char.IsHighSurrogate(b) || index >= lengthB - 1 || !char.IsLowSurrogate(Unsafe.Add(ref charB, 1))) 215charA = ref Unsafe.Add(ref charA, 1); 216charB = ref Unsafe.Add(ref charB, 1); 226charA = ref Unsafe.Add(ref charA, 1); 227charB = ref Unsafe.Add(ref charB, 1); 247if (!char.IsHighSurrogate(b) || index >= lengthB - 1 || !char.IsLowSurrogate(lowSurrogateB = Unsafe.Add(ref charB, 1))) 266charA = ref Unsafe.Add(ref charA, 2); 267charB = ref Unsafe.Add(ref charB, 2); 277charA = ref Unsafe.Add(ref charA, 2); 278charB = ref Unsafe.Add(ref charB, 2);
src\libraries\System.Private.CoreLib\src\System\Globalization\TextInfo.cs (1)
290uint tempValue = Unsafe.ReadUnaligned<uint>(pSource + currIdx);
src\libraries\System.Private.CoreLib\src\System\Guid.cs (26)
248return Unsafe.As<GuidResult, Guid>(ref Unsafe.AsRef(in this)); 324Unsafe.AsRef(in result._a) = (int)(unix_ts_ms >> 16); 325Unsafe.AsRef(in result._b) = (short)(unix_ts_ms); 327Unsafe.AsRef(in result._c) = (short)((result._c & ~VersionMask) | Version7Value); 328Unsafe.AsRef(in result._d) = (byte)((result._d & ~Variant10xxMask) | Variant10xxValue); 795Unsafe.Add(ref result._d, i) = (byte)byteVal; 889ReadOnlySpan<char> charSpan = Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<char>>(str); 918return Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(new ReadOnlySpan<char>(chArr, 0, newLength)); 924ReadOnlySpan<byte> srcUtf8Span = Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<byte>>(str); 977return Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(destUtf8Span.Slice(0, newLength)); 1066ref int r = ref Unsafe.AsRef(in _a); 1067return r ^ Unsafe.Add(ref r, 1) ^ Unsafe.Add(ref r, 2) ^ Unsafe.Add(ref r, 3); 1081return Unsafe.BitCast<Guid, Vector128<byte>>(left) == Unsafe.BitCast<Guid, Vector128<byte>>(right); 1084ref int rA = ref Unsafe.AsRef(in left._a); 1085ref int rB = ref Unsafe.AsRef(in right._a); 1090&& Unsafe.Add(ref rA, 1) == Unsafe.Add(ref rB, 1) 1091&& Unsafe.Add(ref rA, 2) == Unsafe.Add(ref rB, 2) 1092&& Unsafe.Add(ref rA, 3) == Unsafe.Add(ref rB, 3); 1517Vector128<byte> srcVec = Unsafe.BitCast<Guid, Vector128<byte>>(value);
src\libraries\System.Private.CoreLib\src\System\Guid.Unix.cs (2)
29Unsafe.AsRef(in g._c) = (short)((g._c & ~VersionMask) | Version4Value); 31Unsafe.AsRef(in g._d) = (byte)((g._d & ~Variant10xxMask) | Variant10xxValue);
src\libraries\System.Private.CoreLib\src\System\HashCode.cs (27)
321ref byte end = ref Unsafe.Add(ref pos, value.Length); 340Debug.Assert(Unsafe.ByteOffset(ref pos, ref end) >= sizeof(int)); 341Add(Unsafe.ReadUnaligned<int>(ref pos)); 342pos = ref Unsafe.Add(ref pos, sizeof(int)); 345Debug.Assert(Unsafe.ByteOffset(ref pos, ref end) >= sizeof(int)); 346Add(Unsafe.ReadUnaligned<int>(ref pos)); 347pos = ref Unsafe.Add(ref pos, sizeof(int)); 350Debug.Assert(Unsafe.ByteOffset(ref pos, ref end) >= sizeof(int)); 351Add(Unsafe.ReadUnaligned<int>(ref pos)); 352pos = ref Unsafe.Add(ref pos, sizeof(int)); 359ref byte blockEnd = ref Unsafe.Subtract(ref end, Unsafe.ByteOffset(ref pos, ref end) % (sizeof(int) * 4)); 360while (Unsafe.IsAddressLessThan(ref pos, ref blockEnd)) 362Debug.Assert(Unsafe.ByteOffset(ref pos, ref blockEnd) >= (sizeof(int) * 4)); 363uint v1 = Unsafe.ReadUnaligned<uint>(ref pos); 365uint v2 = Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref pos, sizeof(int) * 1)); 367uint v3 = Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref pos, sizeof(int) * 2)); 369uint v4 = Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref pos, sizeof(int) * 3)); 373pos = ref Unsafe.Add(ref pos, sizeof(int) * 4); 378while (Unsafe.ByteOffset(ref pos, ref end) >= sizeof(int)) 380Add(Unsafe.ReadUnaligned<int>(ref pos)); 381pos = ref Unsafe.Add(ref pos, sizeof(int)); 385while (Unsafe.IsAddressLessThan(ref pos, ref end)) 388pos = ref Unsafe.Add(ref pos, 1);
src\libraries\System.Private.CoreLib\src\System\Int128.cs (5)
800sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - Size); 803result = Unsafe.ReadUnaligned<Int128>(ref sourceRef); 819result |= Unsafe.Add(ref sourceRef, i); 883result = Unsafe.ReadUnaligned<Int128>(ref sourceRef); 901result |= Unsafe.Add(ref sourceRef, i);
src\libraries\System.Private.CoreLib\src\System\Int16.cs (3)
348sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(short)); 351result = Unsafe.ReadUnaligned<short>(ref sourceRef); 424result = Unsafe.ReadUnaligned<short>(ref sourceRef);
src\libraries\System.Private.CoreLib\src\System\Int32.cs (5)
368sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(int)); 371result = Unsafe.ReadUnaligned<int>(ref sourceRef); 387result |= Unsafe.Add(ref sourceRef, i); 451result = Unsafe.ReadUnaligned<int>(ref sourceRef); 469result |= Unsafe.Add(ref sourceRef, i);
src\libraries\System.Private.CoreLib\src\System\Int64.cs (5)
365sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(long)); 368result = Unsafe.ReadUnaligned<long>(ref sourceRef); 384result |= Unsafe.Add(ref sourceRef, i); 448result = Unsafe.ReadUnaligned<long>(ref sourceRef); 466result |= Unsafe.Add(ref sourceRef, i);
src\libraries\System.Private.CoreLib\src\System\IntPtr.cs (23)
227Unsafe.SkipInit(out result); 228return nint_t.TryParse(s, out Unsafe.As<nint, nint_t>(ref result)); 234Unsafe.SkipInit(out result); 235return nint_t.TryParse(s, provider, out Unsafe.As<nint, nint_t>(ref result)); 240Unsafe.SkipInit(out result); 241return nint_t.TryParse(s, style, provider, out Unsafe.As<nint, nint_t>(ref result)); 246Unsafe.SkipInit(out result); 247return nint_t.TryParse(s, out Unsafe.As<nint, nint_t>(ref result)); 256Unsafe.SkipInit(out result); 257return nint_t.TryParse(utf8Text, out Unsafe.As<nint, nint_t>(ref result)); 267Unsafe.SkipInit(out result); 268return nint_t.TryParse(s, provider, out Unsafe.As<nint, nint_t>(ref result)); 273Unsafe.SkipInit(out result); 274return nint_t.TryParse(s, style, provider, out Unsafe.As<nint, nint_t>(ref result)); 370sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(nint_t)); 373result = Unsafe.ReadUnaligned<nint>(ref sourceRef); 389result |= Unsafe.Add(ref sourceRef, i); 453result = Unsafe.ReadUnaligned<nint>(ref sourceRef); 471result |= Unsafe.Add(ref sourceRef, i); 1418Unsafe.SkipInit(out result); 1419return nint_t.TryParse(utf8Text, style, provider, out Unsafe.As<nint, nint_t>(ref result)); 1428Unsafe.SkipInit(out result); 1429return nint_t.TryParse(utf8Text, provider, out Unsafe.As<nint, nint_t>(ref result));
src\libraries\System.Private.CoreLib\src\System\IO\BinaryReader.cs (2)
360MemoryStream mStream = Unsafe.As<MemoryStream>(_stream); 480return Unsafe.As<MemoryStream>(_stream).InternalReadSpan(buffer.Length);
src\libraries\System.Private.CoreLib\src\System\IO\UnmanagedMemoryAccessor.cs (14)
152result = Unsafe.ReadUnaligned<short>(pointer + _offset + position); 177result = Unsafe.ReadUnaligned<int>(pointer + _offset + position); 202result = Unsafe.ReadUnaligned<long>(pointer + _offset + position); 232lo = Unsafe.ReadUnaligned<int>(pointer); 233mid = Unsafe.ReadUnaligned<int>(pointer + 4); 234hi = Unsafe.ReadUnaligned<int>(pointer + 8); 235flags = Unsafe.ReadUnaligned<int>(pointer + 12); 401Unsafe.WriteUnaligned(pointer + _offset + position, value); 424Unsafe.WriteUnaligned(pointer + _offset + position, value); 447Unsafe.WriteUnaligned(pointer + _offset + position, value); 475Unsafe.WriteUnaligned(pointer, bits[0]); 476Unsafe.WriteUnaligned(pointer + 4, bits[1]); 477Unsafe.WriteUnaligned(pointer + 8, bits[2]); 478Unsafe.WriteUnaligned(pointer + 12, bits[3]);
src\libraries\System.Private.CoreLib\src\System\Marvin.cs (11)
64p0 += Unsafe.ReadUnaligned<uint>(ref data); 65uint nextUInt32 = Unsafe.ReadUnaligned<uint>(ref Unsafe.AddByteOffset(ref data, 4)); 80data = ref Unsafe.AddByteOffset(ref data, 8); 101p0 += Unsafe.ReadUnaligned<uint>(ref data); 116uint partialResult = Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref Unsafe.AddByteOffset(ref data, (nuint)count & 7), -4)); 182partialResult = Unsafe.AddByteOffset(ref data, (nuint)count & 2); 208partialResult |= (uint)Unsafe.ReadUnaligned<ushort>(ref data); 212partialResult |= (uint)Unsafe.ReadUnaligned<ushort>(ref data);
src\libraries\System.Private.CoreLib\src\System\Marvin.OrdinalIgnoreCase.cs (6)
28tempValue = Unsafe.ReadUnaligned<uint>(ref Unsafe.As<char, byte>(ref Unsafe.AddByteOffset(ref data, byteOffset))); 45tempValue = Unsafe.AddByteOffset(ref data, byteOffset); 78return ComputeHash32OrdinalIgnoreCaseSlow(ref Unsafe.AddByteOffset(ref data, byteOffset), (int)ucount, p0, p1); 93int hash = ComputeHash32(ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(scratch)), (uint)charsWritten * 2, p0, p1);
src\libraries\System.Private.CoreLib\src\System\Memory.cs (17)
275ref T refToReturn = ref Unsafe.NullRef<T>(); 287refToReturn = ref Unsafe.As<char, T>(ref Unsafe.As<string>(tmpObject).GetRawStringData()); 288lengthOfUnderlyingSpan = Unsafe.As<string>(tmpObject).Length; 304refToReturn = ref MemoryMarshal.GetArrayDataReference(Unsafe.As<T[]>(tmpObject)); 305lengthOfUnderlyingSpan = Unsafe.As<T[]>(tmpObject).Length; 316Span<T> memoryManagerSpan = Unsafe.As<MemoryManager<T>>(tmpObject).GetSpan(); 345refToReturn = ref Unsafe.Add(ref refToReturn, desiredStartIndex); 402ref char stringData = ref Unsafe.Add(ref s.GetRawStringData(), _index); 403return new MemoryHandle(Unsafe.AsPointer(ref stringData), handle); 414void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<T[]>(tmpObject))), _index & ReadOnlyMemory<T>.RemoveFlagsBitMask); 421void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<T[]>(tmpObject))), _index); 428return Unsafe.As<MemoryManager<T>>(tmpObject).Pin(_index);
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.cs (450)
39return new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)start /* force zero-extension */), array.Length - start); 63return new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)actualIndex /* force zero-extension */), array.Length - actualIndex); 87return new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)start /* force zero-extension */), length); 126return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetRawStringData(), (nint)(uint)start /* force zero-extension */), text.Length - start); 152return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetRawStringData(), (nint)(uint)actualIndex /* force zero-extension */), text.Length - actualIndex); 178return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetRawStringData(), (nint)(uint)start /* force zero-extension */), length); 210return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetRawStringData(), (nint)(uint)start /* force zero-extension */), length); 335ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 336Unsafe.BitCast<T, byte>(value), 342ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 343Unsafe.BitCast<T, short>(value), 349ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 350Unsafe.BitCast<T, int>(value), 356ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 357Unsafe.BitCast<T, long>(value), 814ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 815Unsafe.BitCast<T, byte>(value), 821ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 822Unsafe.BitCast<T, short>(value), 828ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 829Unsafe.BitCast<T, int>(value), 835ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 836Unsafe.BitCast<T, long>(value), 863ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 864Unsafe.BitCast<T, byte>(value), 870ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 871Unsafe.BitCast<T, short>(value), 877ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 878Unsafe.BitCast<T, int>(value), 884ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 885Unsafe.BitCast<T, long>(value), 941ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 942Unsafe.BitCast<T, byte>(value0), 943Unsafe.BitCast<T, byte>(value1), 949ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 950Unsafe.BitCast<T, short>(value0), 951Unsafe.BitCast<T, short>(value1), 979ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 980Unsafe.BitCast<T, byte>(value0), 981Unsafe.BitCast<T, byte>(value1), 987ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 988Unsafe.BitCast<T, short>(value0), 989Unsafe.BitCast<T, short>(value1), 1048ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1049Unsafe.BitCast<T, byte>(value0), 1050Unsafe.BitCast<T, byte>(value1), 1051Unsafe.BitCast<T, byte>(value2), 1057ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1058Unsafe.BitCast<T, short>(value0), 1059Unsafe.BitCast<T, short>(value1), 1060Unsafe.BitCast<T, short>(value2), 1089ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1090Unsafe.BitCast<T, byte>(value0), 1091Unsafe.BitCast<T, byte>(value1), 1092Unsafe.BitCast<T, byte>(value2), 1098ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1099Unsafe.BitCast<T, short>(value0), 1100Unsafe.BitCast<T, short>(value1), 1101Unsafe.BitCast<T, short>(value2), 1151ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1152Unsafe.BitCast<T, byte>(value0), 1153Unsafe.BitCast<T, byte>(value1), 1154Unsafe.BitCast<T, byte>(value2), 1155Unsafe.BitCast<T, byte>(value3), 1161ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1162Unsafe.BitCast<T, short>(value0), 1163Unsafe.BitCast<T, short>(value1), 1164Unsafe.BitCast<T, short>(value2), 1165Unsafe.BitCast<T, short>(value3), 1208ref byte valuesRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)); 1211ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1213Unsafe.Add(ref valuesRef, 1), 1214Unsafe.Add(ref valuesRef, 2), 1215Unsafe.Add(ref valuesRef, 3), 1216Unsafe.Add(ref valuesRef, 4), 1221ref short valuesRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(values)); 1224ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1226Unsafe.Add(ref valuesRef, 1), 1227Unsafe.Add(ref valuesRef, 2), 1228Unsafe.Add(ref valuesRef, 3), 1229Unsafe.Add(ref valuesRef, 4), 1237ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 1239ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(values)), 1392ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1393Unsafe.BitCast<T, byte>(value), 1399ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1400Unsafe.BitCast<T, short>(value), 1406ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 1407Unsafe.BitCast<T, int>(value), 1413ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 1414Unsafe.BitCast<T, long>(value), 1441ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1442Unsafe.BitCast<T, byte>(value), 1448ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1449Unsafe.BitCast<T, short>(value), 1455ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 1456Unsafe.BitCast<T, int>(value), 1462ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 1463Unsafe.BitCast<T, long>(value), 1519ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1520Unsafe.BitCast<T, byte>(value0), 1521Unsafe.BitCast<T, byte>(value1), 1527ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1528Unsafe.BitCast<T, short>(value0), 1529Unsafe.BitCast<T, short>(value1), 1557ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1558Unsafe.BitCast<T, byte>(value0), 1559Unsafe.BitCast<T, byte>(value1), 1565ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1566Unsafe.BitCast<T, short>(value0), 1567Unsafe.BitCast<T, short>(value1), 1626ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1627Unsafe.BitCast<T, byte>(value0), 1628Unsafe.BitCast<T, byte>(value1), 1629Unsafe.BitCast<T, byte>(value2), 1635ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1636Unsafe.BitCast<T, short>(value0), 1637Unsafe.BitCast<T, short>(value1), 1638Unsafe.BitCast<T, short>(value2), 1667ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1668Unsafe.BitCast<T, byte>(value0), 1669Unsafe.BitCast<T, byte>(value1), 1670Unsafe.BitCast<T, byte>(value2), 1676ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1677Unsafe.BitCast<T, short>(value0), 1678Unsafe.BitCast<T, short>(value1), 1679Unsafe.BitCast<T, short>(value2), 1730ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1731Unsafe.BitCast<T, byte>(value0), 1732Unsafe.BitCast<T, byte>(value1), 1733Unsafe.BitCast<T, byte>(value2), 1734Unsafe.BitCast<T, byte>(value3), 1740ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1741Unsafe.BitCast<T, short>(value0), 1742Unsafe.BitCast<T, short>(value1), 1743Unsafe.BitCast<T, short>(value2), 1744Unsafe.BitCast<T, short>(value3), 1788ref byte valuesRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)); 1791ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1793Unsafe.Add(ref valuesRef, 1), 1794Unsafe.Add(ref valuesRef, 2), 1795Unsafe.Add(ref valuesRef, 3), 1796Unsafe.Add(ref valuesRef, 4), 1801ref short valuesRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(values)); 1804ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1806Unsafe.Add(ref valuesRef, 1), 1807Unsafe.Add(ref valuesRef, 2), 1808Unsafe.Add(ref valuesRef, 3), 1809Unsafe.Add(ref valuesRef, 4), 1817ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 1819ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(values)), 1920ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1921Unsafe.BitCast<T, byte>(lowInclusive), 1922Unsafe.BitCast<T, byte>(highInclusive), 1929ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)), 1930Unsafe.BitCast<T, ushort>(lowInclusive), 1931Unsafe.BitCast<T, ushort>(highInclusive), 1938ref Unsafe.As<T, uint>(ref MemoryMarshal.GetReference(span)), 1939Unsafe.BitCast<T, uint>(lowInclusive), 1940Unsafe.BitCast<T, uint>(highInclusive), 1947ref Unsafe.As<T, ulong>(ref MemoryMarshal.GetReference(span)), 1948Unsafe.BitCast<T, ulong>(lowInclusive), 1949Unsafe.BitCast<T, ulong>(highInclusive), 1985ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1986Unsafe.BitCast<T, byte>(lowInclusive), 1987Unsafe.BitCast<T, byte>(highInclusive), 1994ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)), 1995Unsafe.BitCast<T, ushort>(lowInclusive), 1996Unsafe.BitCast<T, ushort>(highInclusive), 2003ref Unsafe.As<T, uint>(ref MemoryMarshal.GetReference(span)), 2004Unsafe.BitCast<T, uint>(lowInclusive), 2005Unsafe.BitCast<T, uint>(highInclusive), 2012ref Unsafe.As<T, ulong>(ref MemoryMarshal.GetReference(span)), 2013Unsafe.BitCast<T, ulong>(lowInclusive), 2014Unsafe.BitCast<T, ulong>(highInclusive), 2050ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2051Unsafe.BitCast<T, byte>(lowInclusive), 2052Unsafe.BitCast<T, byte>(highInclusive), 2059ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)), 2060Unsafe.BitCast<T, ushort>(lowInclusive), 2061Unsafe.BitCast<T, ushort>(highInclusive), 2068ref Unsafe.As<T, uint>(ref MemoryMarshal.GetReference(span)), 2069Unsafe.BitCast<T, uint>(lowInclusive), 2070Unsafe.BitCast<T, uint>(highInclusive), 2077ref Unsafe.As<T, ulong>(ref MemoryMarshal.GetReference(span)), 2078Unsafe.BitCast<T, ulong>(lowInclusive), 2079Unsafe.BitCast<T, ulong>(highInclusive), 2115ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2116Unsafe.BitCast<T, byte>(lowInclusive), 2117Unsafe.BitCast<T, byte>(highInclusive), 2124ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)), 2125Unsafe.BitCast<T, ushort>(lowInclusive), 2126Unsafe.BitCast<T, ushort>(highInclusive), 2133ref Unsafe.As<T, uint>(ref MemoryMarshal.GetReference(span)), 2134Unsafe.BitCast<T, uint>(lowInclusive), 2135Unsafe.BitCast<T, uint>(highInclusive), 2142ref Unsafe.As<T, ulong>(ref MemoryMarshal.GetReference(span)), 2143Unsafe.BitCast<T, ulong>(lowInclusive), 2144Unsafe.BitCast<T, ulong>(highInclusive), 2188ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2189Unsafe.BitCast<T, byte>(value), 2194ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2195Unsafe.BitCast<T, short>(value), 2200ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 2201Unsafe.BitCast<T, int>(value), 2206ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 2207Unsafe.BitCast<T, long>(value), 2229ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2230Unsafe.BitCast<T, byte>(value), 2235ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2236Unsafe.BitCast<T, short>(value), 2241ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 2242Unsafe.BitCast<T, int>(value), 2247ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 2248Unsafe.BitCast<T, long>(value), 2297ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2299ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 2304ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 2306ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(value)), 2326ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2328ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 2333ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 2335ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(value)), 2384ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2385Unsafe.BitCast<T, byte>(value), 2391ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2392Unsafe.BitCast<T, short>(value), 2398ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 2399Unsafe.BitCast<T, int>(value), 2405ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 2406Unsafe.BitCast<T, long>(value), 2430ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2431Unsafe.BitCast<T, byte>(value), 2437ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2438Unsafe.BitCast<T, short>(value), 2444ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 2445Unsafe.BitCast<T, int>(value), 2451ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 2452Unsafe.BitCast<T, long>(value), 2504ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2506ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 2512ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 2514ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(value)), 2536ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2538ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 2544ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 2546ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(value)), 2647ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2648Unsafe.BitCast<T, byte>(value0), 2649Unsafe.BitCast<T, byte>(value1), 2655ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2656Unsafe.BitCast<T, short>(value0), 2657Unsafe.BitCast<T, short>(value1), 2682ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2683Unsafe.BitCast<T, byte>(value0), 2684Unsafe.BitCast<T, byte>(value1), 2690ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2691Unsafe.BitCast<T, short>(value0), 2692Unsafe.BitCast<T, short>(value1), 2747ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2748Unsafe.BitCast<T, byte>(value0), 2749Unsafe.BitCast<T, byte>(value1), 2750Unsafe.BitCast<T, byte>(value2), 2756ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2757Unsafe.BitCast<T, short>(value0), 2758Unsafe.BitCast<T, short>(value1), 2759Unsafe.BitCast<T, short>(value2), 2785ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2786Unsafe.BitCast<T, byte>(value0), 2787Unsafe.BitCast<T, byte>(value1), 2788Unsafe.BitCast<T, byte>(value2), 2794ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2795Unsafe.BitCast<T, short>(value0), 2796Unsafe.BitCast<T, short>(value1), 2797Unsafe.BitCast<T, short>(value2), 2851ref byte spanRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)); 2852ref byte valueRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)); 2865Unsafe.Add(ref valueRef, 1), 2872Unsafe.Add(ref valueRef, 1), 2873Unsafe.Add(ref valueRef, 2), 2880Unsafe.Add(ref valueRef, 1), 2881Unsafe.Add(ref valueRef, 2), 2882Unsafe.Add(ref valueRef, 3), 2889Unsafe.Add(ref valueRef, 1), 2890Unsafe.Add(ref valueRef, 2), 2891Unsafe.Add(ref valueRef, 3), 2892Unsafe.Add(ref valueRef, 4), 2899ref short spanRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)); 2900ref short valueRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(values)); 2908Unsafe.Add(ref valueRef, 1), 2913Unsafe.Add(ref valueRef, 1), 2914Unsafe.Add(ref valueRef, 2), 2919Unsafe.Add(ref valueRef, 1), 2920Unsafe.Add(ref valueRef, 2), 2921Unsafe.Add(ref valueRef, 3), 2926Unsafe.Add(ref valueRef, 1), 2927Unsafe.Add(ref valueRef, 2), 2928Unsafe.Add(ref valueRef, 3), 2929Unsafe.Add(ref valueRef, 4), 2931_ => ProbabilisticMap.IndexOfAny(ref Unsafe.As<short, char>(ref spanRef), span.Length, ref Unsafe.As<short, char>(ref valueRef), values.Length), 3067ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3068Unsafe.BitCast<T, byte>(value0), 3069Unsafe.BitCast<T, byte>(value1), 3075ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 3076Unsafe.BitCast<T, short>(value0), 3077Unsafe.BitCast<T, short>(value1), 3102ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3103Unsafe.BitCast<T, byte>(value0), 3104Unsafe.BitCast<T, byte>(value1), 3110ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 3111Unsafe.BitCast<T, short>(value0), 3112Unsafe.BitCast<T, short>(value1), 3168ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3169Unsafe.BitCast<T, byte>(value0), 3170Unsafe.BitCast<T, byte>(value1), 3171Unsafe.BitCast<T, byte>(value2), 3177ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 3178Unsafe.BitCast<T, short>(value0), 3179Unsafe.BitCast<T, short>(value1), 3180Unsafe.BitCast<T, short>(value2), 3206ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3207Unsafe.BitCast<T, byte>(value0), 3208Unsafe.BitCast<T, byte>(value1), 3209Unsafe.BitCast<T, byte>(value2), 3215ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 3216Unsafe.BitCast<T, short>(value0), 3217Unsafe.BitCast<T, short>(value1), 3218Unsafe.BitCast<T, short>(value2), 3273ref byte spanRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)); 3274ref byte valueRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)); 3287Unsafe.Add(ref valueRef, 1), 3294Unsafe.Add(ref valueRef, 1), 3295Unsafe.Add(ref valueRef, 2), 3302Unsafe.Add(ref valueRef, 1), 3303Unsafe.Add(ref valueRef, 2), 3304Unsafe.Add(ref valueRef, 3), 3311Unsafe.Add(ref valueRef, 1), 3312Unsafe.Add(ref valueRef, 2), 3313Unsafe.Add(ref valueRef, 3), 3314Unsafe.Add(ref valueRef, 4), 3321ref short spanRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)); 3322ref short valueRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(values)); 3330Unsafe.Add(ref valueRef, 1), 3335Unsafe.Add(ref valueRef, 1), 3336Unsafe.Add(ref valueRef, 2), 3341Unsafe.Add(ref valueRef, 1), 3342Unsafe.Add(ref valueRef, 2), 3343Unsafe.Add(ref valueRef, 3), 3348Unsafe.Add(ref valueRef, 1), 3349Unsafe.Add(ref valueRef, 2), 3350Unsafe.Add(ref valueRef, 3), 3351Unsafe.Add(ref valueRef, 4), 3353_ => ProbabilisticMap.LastIndexOfAny(ref Unsafe.As<short, char>(ref spanRef), span.Length, ref Unsafe.As<short, char>(ref valueRef), values.Length), 3428ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3429ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), 3470ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3471ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), 3512ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3514ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), 3519ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 3521ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(other)), 3568ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3569ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 3609ref Unsafe.As<T, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)(spanLength - valueLength) /* force zero-extension */)), 3610ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 3616ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)(spanLength - valueLength) /* force zero-extension */), 4097nint byteOffset = Unsafe.ByteOffset( 4116nint byteOffset = Unsafe.ByteOffset( 4429ref byte src = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)); 4433Unsafe.BitCast<T, byte>(oldValue), 4434Unsafe.BitCast<T, byte>(newValue), 4441ref ushort src = ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)); 4445Unsafe.BitCast<T, ushort>(oldValue), 4446Unsafe.BitCast<T, ushort>(newValue), 4452ref int src = ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)); 4456Unsafe.BitCast<T, int>(oldValue), 4457Unsafe.BitCast<T, int>(newValue), 4463ref long src = ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)); 4467Unsafe.BitCast<T, long>(oldValue), 4468Unsafe.BitCast<T, long>(newValue), 4495ref byte src = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)); 4499Unsafe.BitCast<T, byte>(oldValue), 4500Unsafe.BitCast<T, byte>(newValue), 4507ref ushort src = ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)); 4511Unsafe.BitCast<T, ushort>(oldValue), 4512Unsafe.BitCast<T, ushort>(newValue), 4518ref int src = ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)); 4522Unsafe.BitCast<T, int>(oldValue), 4523Unsafe.BitCast<T, int>(newValue), 4529ref long src = ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)); 4533Unsafe.BitCast<T, long>(oldValue), 4534Unsafe.BitCast<T, long>(newValue), 4596nint byteOffset = Unsafe.ByteOffset(ref src, ref dst); 4609ref Unsafe.As<T, byte>(ref src), 4610ref Unsafe.As<T, byte>(ref dst), 4611Unsafe.BitCast<T, byte>(oldValue), 4612Unsafe.BitCast<T, byte>(newValue), 4620ref Unsafe.As<T, ushort>(ref src), 4621ref Unsafe.As<T, ushort>(ref dst), 4622Unsafe.BitCast<T, ushort>(oldValue), 4623Unsafe.BitCast<T, ushort>(newValue), 4630ref Unsafe.As<T, int>(ref src), 4631ref Unsafe.As<T, int>(ref dst), 4632Unsafe.BitCast<T, int>(oldValue), 4633Unsafe.BitCast<T, int>(newValue), 4640ref Unsafe.As<T, long>(ref src), 4641ref Unsafe.As<T, long>(ref dst), 4642Unsafe.BitCast<T, long>(oldValue), 4643Unsafe.BitCast<T, long>(newValue), 4680nint byteOffset = Unsafe.ByteOffset(ref src, ref dst); 4695ref Unsafe.As<T, byte>(ref src), 4696ref Unsafe.As<T, byte>(ref dst), 4697Unsafe.BitCast<T, byte>(oldValue), 4698Unsafe.BitCast<T, byte>(newValue), 4706ref Unsafe.As<T, ushort>(ref src), 4707ref Unsafe.As<T, ushort>(ref dst), 4708Unsafe.BitCast<T, ushort>(oldValue), 4709Unsafe.BitCast<T, ushort>(newValue), 4716ref Unsafe.As<T, int>(ref src), 4717ref Unsafe.As<T, int>(ref dst), 4718Unsafe.BitCast<T, int>(oldValue), 4719Unsafe.BitCast<T, int>(newValue), 4726ref Unsafe.As<T, long>(ref src), 4727ref Unsafe.As<T, long>(ref dst), 4728Unsafe.BitCast<T, long>(oldValue), 4729Unsafe.BitCast<T, long>(newValue), 4779if (!Unsafe.AreSame(ref source._reference, ref destination._reference) && 4829if (!Unsafe.AreSame(ref source._reference, ref destination._reference) && 4888ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 4889ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), 5382ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 5383Unsafe.BitCast<T, byte>(value), 5389ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 5390Unsafe.BitCast<T, short>(value), 5396ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 5397Unsafe.BitCast<T, int>(value), 5403ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 5404Unsafe.BitCast<T, long>(value), 5431ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 5432Unsafe.BitCast<T, byte>(value), 5438ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 5439Unsafe.BitCast<T, short>(value), 5445ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 5446Unsafe.BitCast<T, int>(value), 5452ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 5453Unsafe.BitCast<T, long>(value), 5878_searchValues = Unsafe.As<SearchValues<T>>(string.SearchValuesStorage.WhiteSpaceChars);
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.Globalization.cs (1)
325ref Unsafe.Add(ref MemoryMarshal.GetReference(span), span.Length - value.Length),
src\libraries\System.Private.CoreLib\src\System\Number.BigInteger.cs (1)
1329(byte*)Unsafe.AsPointer(ref _blocks[0]), // This is safe to do since we are a ref struct
src\libraries\System.Private.CoreLib\src\System\Number.Formatting.cs (8)
617if (source.TryCopyTo(Unsafe.BitCast<Span<TChar>, Span<char>>(destination))) 628return Encoding.UTF8.TryGetBytes(source, Unsafe.BitCast<Span<TChar>, Span<byte>>(destination), out charsWritten); 1573Unsafe.CopyBlockUnaligned( 1575ref Unsafe.Add(ref MemoryMarshal.GetReference(typeof(TChar) == typeof(char) ? TwoDigitsCharsAsBytes : TwoDigitsBytes), (uint)sizeof(TChar) * 2 * value), 1593Unsafe.CopyBlockUnaligned( 1595ref Unsafe.Add(ref charsArray, (uint)sizeof(TChar) * 2 * value), 1598Unsafe.CopyBlockUnaligned( 1600ref Unsafe.Add(ref charsArray, (uint)sizeof(TChar) * 2 * remainder),
src\libraries\System.Private.CoreLib\src\System\Number.NumberToFloatingPointBits.cs (1)
954ulong val = Unsafe.ReadUnaligned<ulong>(chars);
src\libraries\System.Private.CoreLib\src\System\Number.Parsing.cs (13)
898ReadOnlySpan<char> typedSpan = Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<char>>(span); 899ReadOnlySpan<char> typedValue = Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<char>>(value); 906ReadOnlySpan<byte> typedSpan = Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<byte>>(span); 907ReadOnlySpan<byte> typedValue = Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<byte>>(value); 918return Unsafe.BitCast<ReadOnlySpan<char>, ReadOnlySpan<TChar>>(Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<char>>(span).Trim()); 924return Unsafe.BitCast<ReadOnlySpan<byte>, ReadOnlySpan<TChar>>(Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<byte>>(span).TrimUtf8()); 934ReadOnlySpan<char> typedSpan = Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<char>>(span); 935ReadOnlySpan<char> typedValue = Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<char>>(value); 942ReadOnlySpan<byte> typedSpan = Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<byte>>(span); 943ReadOnlySpan<byte> typedValue = Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<byte>>(value); 1056ReadOnlySpan<byte> bytes = Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<byte>>(value);
src\libraries\System.Private.CoreLib\src\System\Numerics\BitOperations.cs (9)
393return Unsafe.AddByteOffset( 576return Unsafe.AddByteOffset( 876crc = Unsafe.Add(ref lookupTable, (nint)(byte)(crc ^ data)) ^ (crc >> 8); 885crc = Unsafe.Add(ref lookupTable, (nint)(byte)(crc ^ (byte)data)) ^ (crc >> 8); 887crc = Unsafe.Add(ref lookupTable, (nint)(byte)(crc ^ data)) ^ (crc >> 8); 901crc = Unsafe.Add(ref lookupTable, (nint)(byte)(crc ^ (byte)data)) ^ (crc >> 8); 903crc = Unsafe.Add(ref lookupTable, (nint)(byte)(crc ^ (byte)data)) ^ (crc >> 8); 905crc = Unsafe.Add(ref lookupTable, (nint)(byte)(crc ^ (byte)data)) ^ (crc >> 8); 907crc = Unsafe.Add(ref lookupTable, (nint)(byte)(crc ^ data)) ^ (crc >> 8);
src\libraries\System.Private.CoreLib\src\System\Numerics\Matrix3x2.cs (8)
180return Unsafe.Add(ref Unsafe.AsRef(in AsROImpl()).X, row); 222Unsafe.Add(ref AsImpl().X, row) = value; 281return Unsafe.Add(ref Unsafe.AsRef(in M11), (row * ColumnCount) + column); 323Unsafe.Add(ref M11, (row * ColumnCount) + column) = value; 416Unsafe.SkipInit(out Matrix3x2 result); 530Unsafe.SkipInit(out result);
src\libraries\System.Private.CoreLib\src\System\Numerics\Matrix3x2.Impl.cs (4)
20internal ref Impl AsImpl() => ref Unsafe.As<Matrix3x2, Impl>(ref this); 24internal readonly ref readonly Impl AsROImpl() => ref Unsafe.As<Matrix3x2, Impl>(ref Unsafe.AsRef(in this)); 30public ref Matrix3x2 AsM3x2() => ref Unsafe.As<Impl, Matrix3x2>(ref this);
src\libraries\System.Private.CoreLib\src\System\Numerics\Matrix4x4.cs (10)
259return Unsafe.Add(ref Unsafe.AsRef(in impl.X), row); 309Unsafe.Add(ref Unsafe.AsRef(in impl.X), row) = value; 375return Unsafe.Add(ref Unsafe.AsRef(in M11), (row * ColumnCount) + column); 425Unsafe.Add(ref Unsafe.AsRef(in M11), (row * ColumnCount) + column) = value; 535Unsafe.SkipInit(out Matrix4x4 result); 976Unsafe.SkipInit(out result);
src\libraries\System.Private.CoreLib\src\System\Numerics\Matrix4x4.Impl.cs (5)
23internal ref Impl AsImpl() => ref Unsafe.As<Matrix4x4, Impl>(ref this); 27internal readonly ref readonly Impl AsROImpl() => ref Unsafe.As<Matrix4x4, Impl>(ref Unsafe.AsRef(in this)); 33public ref Matrix4x4 AsM4x4() => ref Unsafe.As<Impl, Matrix4x4>(ref this); 1132scale = Unsafe.ReadUnaligned<Vector3>(scales);
src\libraries\System.Private.CoreLib\src\System\Numerics\Plane.Extensions.cs (1)
19return Unsafe.BitCast<Plane, Vector4>(value);
src\libraries\System.Private.CoreLib\src\System\Numerics\Quaternion.Extensions.cs (1)
19return Unsafe.BitCast<Quaternion, Vector4>(value);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector.cs (92)
44Unsafe.SkipInit(out Vector<T> result); 71Unsafe.SkipInit(out Vector<T> result); 155return Unsafe.BitCast<Vector<TFrom>, Vector<TTo>>(vector); 298Unsafe.SkipInit(out Vector<T> result); 318Unsafe.SkipInit(out Vector<double> result); 337Unsafe.SkipInit(out Vector<float> result); 444Unsafe.SkipInit(out Vector<int> result); 461Unsafe.SkipInit(out Vector<int> result); 478Unsafe.SkipInit(out Vector<long> result); 495Unsafe.SkipInit(out Vector<long> result); 512Unsafe.SkipInit(out Vector<float> result); 553Unsafe.SkipInit(out Vector<uint> result); 571Unsafe.SkipInit(out Vector<uint> result); 589Unsafe.SkipInit(out Vector<ulong> result); 607Unsafe.SkipInit(out Vector<ulong> result); 621Unsafe.SkipInit(out Vector<T> result); 679Unsafe.SkipInit(out Vector<T> result); 740Unsafe.SkipInit(out Vector<T> result); 763return Unsafe.ReadUnaligned<Vector<T>>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values))); 792Unsafe.SkipInit(out Vector<T> result); 810Unsafe.SkipInit(out Vector<T> result); 884Unsafe.SkipInit(out Vector<T> result); 954Unsafe.SkipInit(out Vector<T> result); 1015Unsafe.SkipInit(out Vector<T> result); 1035Unsafe.SkipInit(out Vector<double> result); 1054Unsafe.SkipInit(out Vector<float> result); 1078Unsafe.SkipInit(out Vector<double> result); 1102Unsafe.SkipInit(out Vector<float> result); 1141Unsafe.SkipInit(out Vector<T> result); 1229Unsafe.SkipInit(out Vector<T> result); 1311Unsafe.SkipInit(out Vector<T> result); 1638Unsafe.SkipInit(out Vector<T> result); 1696Unsafe.SkipInit(out Vector<T> result); 1784Unsafe.SkipInit(out Vector<T> result); 1912ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source)); 1913return Unsafe.ReadUnaligned<Vector<T>>(in address); 1928ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 1929return Unsafe.ReadUnaligned<Vector<T>>(in address); 1935Unsafe.SkipInit(out Vector<T> result); 1977Unsafe.SkipInit(out Vector<T> result); 2027Unsafe.SkipInit(out Vector<T> result); 2050Unsafe.SkipInit(out Vector<T> result); 2073Unsafe.SkipInit(out Vector<T> result); 2096Unsafe.SkipInit(out Vector<T> result); 2119Unsafe.SkipInit(out Vector<T> result); 2142Unsafe.SkipInit(out Vector<T> result); 2165Unsafe.SkipInit(out Vector<T> result); 2188Unsafe.SkipInit(out Vector<T> result); 2211Unsafe.SkipInit(out Vector<T> result); 2234Unsafe.SkipInit(out Vector<T> result); 2274Unsafe.SkipInit(out Vector<T> result); 2290Unsafe.SkipInit(out Vector<double> result); 2306Unsafe.SkipInit(out Vector<float> result); 2323Unsafe.SkipInit(out Vector<TResult> result); 2392Unsafe.SkipInit(out Vector<TResult> result); 2496Unsafe.SkipInit(out Vector<T> result); 2554Unsafe.SkipInit(out Vector<T> result); 2807Unsafe.SkipInit(out Vector<T> result); 2849Unsafe.SkipInit(out Vector<T> sinResult); 2850Unsafe.SkipInit(out Vector<T> cosResult); 2898Unsafe.SkipInit(out Vector<T> result); 2958ref byte address = ref Unsafe.As<T, byte>(ref destination); 2959Unsafe.WriteUnaligned(ref address, source); 2974destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 2975Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source); 2993Unsafe.SkipInit(out Vector<T> result); 3053Unsafe.SkipInit(out Vector<T> result); 3204Unsafe.SkipInit(out Vector<ushort> lower); 3222Unsafe.SkipInit(out Vector<int> lower); 3240Unsafe.SkipInit(out Vector<long> lower); 3259Unsafe.SkipInit(out Vector<short> lower); 3277Unsafe.SkipInit(out Vector<double> lower); 3296Unsafe.SkipInit(out Vector<uint> lower); 3315Unsafe.SkipInit(out Vector<ulong> lower); 3334Unsafe.SkipInit(out Vector<ushort> upper); 3352Unsafe.SkipInit(out Vector<int> upper); 3370Unsafe.SkipInit(out Vector<long> upper); 3389Unsafe.SkipInit(out Vector<short> upper); 3407Unsafe.SkipInit(out Vector<double> upper); 3426Unsafe.SkipInit(out Vector<uint> upper); 3445Unsafe.SkipInit(out Vector<ulong> upper); 3489ref T address = ref Unsafe.As<Vector<T>, T>(ref Unsafe.AsRef(in vector)); 3490return Unsafe.Add(ref address, index); 3497ref T address = ref Unsafe.As<Vector<T>, T>(ref Unsafe.AsRef(in vector)); 3498Unsafe.Add(ref address, index) = value;
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector_1.cs (30)
61this = Unsafe.ReadUnaligned<Vector<T>>(ref Unsafe.As<T, byte>(ref values[0])); 80this = Unsafe.ReadUnaligned<Vector<T>>(ref Unsafe.As<T, byte>(ref values[index])); 97this = Unsafe.ReadUnaligned<Vector<T>>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values))); 115this = Unsafe.ReadUnaligned<Vector<T>>(ref MemoryMarshal.GetReference(values)); 156Unsafe.SkipInit(out Vector<T> result); 228Unsafe.SkipInit(out Vector<T> result); 248Unsafe.SkipInit(out Vector<ulong> result); 271Unsafe.SkipInit(out Vector<ulong> result); 293Unsafe.SkipInit(out Vector<T> result); 312Unsafe.SkipInit(out Vector<T> result); 350Unsafe.SkipInit(out Vector<ulong> result); 468Unsafe.SkipInit(out Vector<T> result); 487Unsafe.SkipInit(out Vector<T> result); 520Unsafe.SkipInit(out Vector<ulong> result); 541Unsafe.SkipInit(out Vector<T> result); 560Unsafe.SkipInit(out Vector<T> result); 611Unsafe.SkipInit(out Vector<T> result); 636Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[0]), this); 660Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[startIndex]), this); 676Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), this); 690Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), this); 797Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), this); 812Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), this);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector2.cs (17)
411return Unsafe.ReadUnaligned<Vector2>(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(values))); 704ref readonly byte address = ref Unsafe.As<float, byte>(ref Unsafe.AsRef(in source)); 705return Unsafe.ReadUnaligned<Vector2>(in address); 714ref readonly byte address = ref Unsafe.As<float, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 715return Unsafe.ReadUnaligned<Vector2>(in address); 974Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref array[0]), this); 1002Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref array[index]), this); 1016Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(destination)), this); 1030Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(destination)), this);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector2.Extensions.cs (5)
84ref byte address = ref Unsafe.As<float, byte>(ref destination); 85Unsafe.WriteUnaligned(ref address, source); 96destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 97Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref destination), source);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector3.cs (17)
446return Unsafe.ReadUnaligned<Vector3>(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(values))); 737ref readonly byte address = ref Unsafe.As<float, byte>(ref Unsafe.AsRef(in source)); 738return Unsafe.ReadUnaligned<Vector3>(in address); 747ref readonly byte address = ref Unsafe.As<float, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 748return Unsafe.ReadUnaligned<Vector3>(in address); 987Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref array[0]), this); 1015Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref array[index]), this); 1029Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(destination)), this); 1043Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(destination)), this);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector3.Extensions.cs (5)
79ref byte address = ref Unsafe.As<float, byte>(ref destination); 80Unsafe.WriteUnaligned(ref address, source); 91destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 92Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref destination), source);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector4.Extensions.cs (2)
20return Unsafe.BitCast<Vector4, Plane>(value); 32return Unsafe.BitCast<Vector4, Quaternion>(value);
src\libraries\System.Private.CoreLib\src\System\Numerics\VectorDebugView_1.cs (23)
23Unsafe.WriteUnaligned(ref items[0], _value); 33Unsafe.WriteUnaligned(ref Unsafe.As<double, byte>(ref items[0]), _value); 43Unsafe.WriteUnaligned(ref Unsafe.As<short, byte>(ref items[0]), _value); 53Unsafe.WriteUnaligned(ref Unsafe.As<int, byte>(ref items[0]), _value); 63Unsafe.WriteUnaligned(ref Unsafe.As<long, byte>(ref items[0]), _value); 73Unsafe.WriteUnaligned(ref Unsafe.As<nint, byte>(ref items[0]), _value); 83Unsafe.WriteUnaligned(ref Unsafe.As<nuint, byte>(ref items[0]), _value); 93Unsafe.WriteUnaligned(ref Unsafe.As<sbyte, byte>(ref items[0]), _value); 103Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref items[0]), _value); 113Unsafe.WriteUnaligned(ref Unsafe.As<ushort, byte>(ref items[0]), _value); 123Unsafe.WriteUnaligned(ref Unsafe.As<uint, byte>(ref items[0]), _value); 133Unsafe.WriteUnaligned(ref Unsafe.As<ulong, byte>(ref items[0]), _value);
src\libraries\System.Private.CoreLib\src\System\ReadOnlyMemory.cs (17)
197ref T refToReturn = ref Unsafe.NullRef<T>(); 209refToReturn = ref Unsafe.As<char, T>(ref Unsafe.As<string>(tmpObject).GetRawStringData()); 210lengthOfUnderlyingSpan = Unsafe.As<string>(tmpObject).Length; 226refToReturn = ref MemoryMarshal.GetArrayDataReference(Unsafe.As<T[]>(tmpObject)); 227lengthOfUnderlyingSpan = Unsafe.As<T[]>(tmpObject).Length; 238Span<T> memoryManagerSpan = Unsafe.As<MemoryManager<T>>(tmpObject).GetSpan(); 267refToReturn = ref Unsafe.Add(ref refToReturn, desiredStartIndex); 317ref char stringData = ref Unsafe.Add(ref s.GetRawStringData(), _index); 318return new MemoryHandle(Unsafe.AsPointer(ref stringData), handle); 329void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<T[]>(tmpObject))), _index & RemoveFlagsBitMask); 336void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<T[]>(tmpObject))), _index); 343return Unsafe.As<MemoryManager<T>>(tmpObject).Pin(_index);
src\libraries\System.Private.CoreLib\src\System\ReadOnlySpan.cs (9)
83_reference = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)start /* force zero-extension */); 119_reference = ref Unsafe.AsRef(in reference); 150return ref Unsafe.Add(ref _reference, (nint)(uint)index /* force zero-extension */); 227return new ReadOnlySpan<T>(ref Unsafe.As<TDerived, T>(ref items._reference), items.Length); 292ref T ret = ref Unsafe.NullRef<T>(); 348Unsafe.AreSame(ref left._reference, ref right._reference); 358return new string(new ReadOnlySpan<char>(ref Unsafe.As<T, char>(ref _reference), _length)); 376return new ReadOnlySpan<T>(ref Unsafe.Add(ref _reference, (nint)(uint)start /* force zero-extension */), _length - start); 399return new ReadOnlySpan<T>(ref Unsafe.Add(ref _reference, (nint)(uint)start /* force zero-extension */), length);
src\libraries\System.Private.CoreLib\src\System\Reflection\ConstructorInvoker.cs (4)
320copyOfArgs = new(ref Unsafe.AsRef<object?>(pArgStorage), _argCount); 351copyOfArgs = new(ref Unsafe.AsRef<object?>(pStorage), _argCount); 370ByReference.Create(ref Unsafe.AsRef<object>(pStorage + i).GetRawData()) : 371ByReference.Create(ref Unsafe.AsRef<object>(pStorage + i));
src\libraries\System.Private.CoreLib\src\System\Reflection\FieldAccessor.cs (30)
131return Volatile.Read(ref Unsafe.As<byte, object>(ref Unsafe.AddByteOffset(ref obj.GetRawData(), _addressOrOffset))); 142ref Unsafe.AddByteOffset(ref obj.GetRawData(), _addressOrOffset)); 148(void*)Unsafe.As<byte, IntPtr>(ref Unsafe.AddByteOffset(ref obj.GetRawData(), _addressOrOffset)), 152return Volatile.Read(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)_addressOrOffset)); 159return RuntimeHelpers.Box(_methodTable, ref Unsafe.AsRef<byte>(_addressOrOffset.ToPointer())); 165ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)_addressOrOffset).GetRawData()); 168return Pointer.Box((void*)Unsafe.As<byte, IntPtr>( 169ref Unsafe.AsRef<byte>(_addressOrOffset.ToPointer())), _fieldInfo.FieldType); 223ref Unsafe.As<byte, object?>(ref Unsafe.AddByteOffset(ref obj.GetRawData(), _addressOrOffset)), 231ref Unsafe.AddByteOffset(ref obj.GetRawData(), _addressOrOffset), 239ref Unsafe.As<byte, short>(ref Unsafe.AddByteOffset(ref obj.GetRawData(), _addressOrOffset)), 240Unsafe.As<byte, short>(ref value!.GetRawData())); 247ref Unsafe.As<byte, int>(ref Unsafe.AddByteOffset(ref obj.GetRawData(), _addressOrOffset)), 248Unsafe.As<byte, int>(ref value!.GetRawData())); 255ref Unsafe.As<byte, long>(ref Unsafe.AddByteOffset(ref obj.GetRawData(), _addressOrOffset)), 256Unsafe.As<byte, long>(ref value!.GetRawData())); 261Volatile.Write(ref Unsafe.As<IntPtr, object?>(ref *(IntPtr*)_addressOrOffset), value); 267ref Unsafe.AsRef<byte>(_addressOrOffset.ToPointer()), 274ref Unsafe.AsRef<short>(_addressOrOffset.ToPointer()), 275Unsafe.As<byte, short>(ref value!.GetRawData())); 281ref Unsafe.AsRef<int>(_addressOrOffset.ToPointer()), 282Unsafe.As<byte, int>(ref value!.GetRawData())); 288ref Unsafe.AsRef<long>(_addressOrOffset.ToPointer()), 289Unsafe.As<byte, long>(ref value!.GetRawData()));
src\libraries\System.Private.CoreLib\src\System\Reflection\InvokeUtils.cs (55)
138Unsafe.As<byte, ushort>(ref destElement) = srcElement; break; 141Unsafe.As<byte, uint>(ref destElement) = srcElement; break; 144Unsafe.As<byte, ulong>(ref destElement) = srcElement; break; 146Unsafe.As<byte, float>(ref destElement) = srcElement; break; 148Unsafe.As<byte, double>(ref destElement) = srcElement; break; 158Unsafe.As<byte, short>(ref destElement) = Unsafe.As<byte, sbyte>(ref srcElement); break; 160Unsafe.As<byte, int>(ref destElement) = Unsafe.As<byte, sbyte>(ref srcElement); break; 162Unsafe.As<byte, long>(ref destElement) = Unsafe.As<byte, sbyte>(ref srcElement); break; 164Unsafe.As<byte, float>(ref destElement) = Unsafe.As<byte, sbyte>(ref srcElement); break; 166Unsafe.As<byte, double>(ref destElement) = Unsafe.As<byte, sbyte>(ref srcElement); break; 179Unsafe.As<byte, ushort>(ref destElement) = Unsafe.As<byte, ushort>(ref srcElement); break; 182Unsafe.As<byte, uint>(ref destElement) = Unsafe.As<byte, ushort>(ref srcElement); break; 185Unsafe.As<byte, ulong>(ref destElement) = Unsafe.As<byte, ushort>(ref srcElement); break; 187Unsafe.As<byte, float>(ref destElement) = Unsafe.As<byte, ushort>(ref srcElement); break; 189Unsafe.As<byte, double>(ref destElement) = Unsafe.As<byte, ushort>(ref srcElement); break; 199Unsafe.As<byte, int>(ref destElement) = Unsafe.As<byte, short>(ref srcElement); break; 201Unsafe.As<byte, long>(ref destElement) = Unsafe.As<byte, short>(ref srcElement); break; 203Unsafe.As<byte, float>(ref destElement) = Unsafe.As<byte, short>(ref srcElement); break; 205Unsafe.As<byte, double>(ref destElement) = Unsafe.As<byte, short>(ref srcElement); break; 216Unsafe.As<byte, ulong>(ref destElement) = Unsafe.As<byte, uint>(ref srcElement); break; 218Unsafe.As<byte, float>(ref destElement) = Unsafe.As<byte, uint>(ref srcElement); break; 220Unsafe.As<byte, double>(ref destElement) = Unsafe.As<byte, uint>(ref srcElement); break; 230Unsafe.As<byte, long>(ref destElement) = Unsafe.As<byte, int>(ref srcElement); break; 232Unsafe.As<byte, float>(ref destElement) = Unsafe.As<byte, int>(ref srcElement); break; 234Unsafe.As<byte, double>(ref destElement) = Unsafe.As<byte, int>(ref srcElement); break; 244Unsafe.As<byte, float>(ref destElement) = Unsafe.As<byte, ulong>(ref srcElement); break; 246Unsafe.As<byte, double>(ref destElement) = Unsafe.As<byte, ulong>(ref srcElement); break; 256Unsafe.As<byte, float>(ref destElement) = Unsafe.As<byte, long>(ref srcElement); break; 258Unsafe.As<byte, double>(ref destElement) = Unsafe.As<byte, long>(ref srcElement); break; 266Unsafe.As<byte, double>(ref destElement) = Unsafe.As<byte, float>(ref srcElement); break;
src\libraries\System.Private.CoreLib\src\System\Reflection\MethodBaseInvoker.Constructor.cs (3)
29Span<object?> copyOfArgs = new(ref Unsafe.AsRef<object?>(pStorage), argCount); 44ByReference.Create(ref Unsafe.AsRef<object>(pStorage + i).GetRawData()) : 45ByReference.Create(ref Unsafe.AsRef<object>(pStorage + i));
src\libraries\System.Private.CoreLib\src\System\Reflection\MethodBaseInvoker.cs (4)
205copyOfArgs = new(ref Unsafe.AsRef<object?>(pArgStorage), _argCount); 240copyOfArgs = new(ref Unsafe.AsRef<object?>(pStorage), _argCount); 256ByReference.Create(ref Unsafe.AsRef<object>(pStorage + i).GetRawData()) : 257ByReference.Create(ref Unsafe.AsRef<object>(pStorage + i));
src\libraries\System.Private.CoreLib\src\System\Reflection\MethodInvoker.cs (4)
373copyOfArgs = new(ref Unsafe.AsRef<object?>(pArgStorage), _argCount); 404copyOfArgs = new(ref Unsafe.AsRef<object?>(pStorage), _argCount); 423ByReference.Create(ref Unsafe.AsRef<object>(pStorage + i).GetRawData()) : 424ByReference.Create(ref Unsafe.AsRef<object>(pStorage + i));
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\AsyncTaskMethodBuilderT.cs (4)
108ref TaskAwaiter ta = ref Unsafe.As<TAwaiter, TaskAwaiter>(ref awaiter); // relies on TaskAwaiter/TaskAwaiter<T> having the same layout 113ref ConfiguredTaskAwaitable.ConfiguredTaskAwaiter ta = ref Unsafe.As<TAwaiter, ConfiguredTaskAwaitable.ConfiguredTaskAwaiter>(ref awaiter); 292Unsafe.As<AsyncStateMachineBox<TStateMachine>>(s).StateMachine!.MoveNext(); 343return ref Unsafe.As<object?, ExecutionContext?>(ref m_stateObject);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\CastCache.cs (7)
109return ref Unsafe.As<byte, int>(ref Unsafe.AddByteOffset(ref table.GetRawData(), (nint)sizeof(nint))); 123return ref Unsafe.Add(ref tableData, 1); 129return ref Unsafe.As<int, uint>(ref Unsafe.Add(ref tableData, 2)); 136return ref Unsafe.Add(ref Unsafe.As<int, CastCacheEntry>(ref tableData), index + 1);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\ConditionalWeakTable.cs (4)
634value = Unsafe.As<TValue>(secondary); 685key = Unsafe.As<TKey>(oKey); 686value = Unsafe.As<TValue>(oValue); 714value = Unsafe.As<TValue>(valueObject);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\ConfiguredValueTaskAwaitable.cs (6)
63Unsafe.As<IValueTaskSource>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, 85Unsafe.As<IValueTaskSource>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, 105Unsafe.As<IValueTaskSource>(obj).OnCompleted(ThreadPool.s_invokeAsyncStateMachineBox, box, _value._token, 168Unsafe.As<IValueTaskSource<TResult>>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, 190Unsafe.As<IValueTaskSource<TResult>>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, 210Unsafe.As<IValueTaskSource<TResult>>(obj).OnCompleted(ThreadPool.s_invokeAsyncStateMachineBox, box, _value._token,
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\GenericCache.cs (5)
112return ref Unsafe.As<byte, Entry>(ref Unsafe.As<RawArrayData>(table).Data); 138return ref Unsafe.Add(ref Unsafe.As<byte, Entry>(ref Unsafe.As<RawArrayData>(table).Data), index + 1);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\PoolingAsyncValueTaskMethodBuilderT.cs (2)
370return ref Unsafe.As<object?, StateMachineBox<TStateMachine>?>(ref s_perCoreCache[i].Object); 392Unsafe.As<StateMachineBox<TStateMachine>>(s).StateMachine!.MoveNext();
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\QCallHandles.cs (9)
17_ptr = Unsafe.AsPointer(ref s); 33return new ObjectHandleOnStack(Unsafe.AsPointer(ref o)); 66return new ByteRefOnStack(Unsafe.AsPointer(ref byteRef)); 77_ptr = Unsafe.AsPointer(ref stackMark); 89_ptr = Unsafe.AsPointer(ref module); 95_ptr = Unsafe.AsPointer(ref module); 108_ptr = Unsafe.AsPointer(ref assembly); 121_ptr = Unsafe.AsPointer(ref type); 127_ptr = Unsafe.AsPointer(ref rth);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\RuntimeHelpers.cs (3)
54dest = Unsafe.As<T[]>(Array.CreateInstanceFromArrayType(array.GetType(), length)); 64ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), offset), 154=> new ReadOnlySpan<T>(ref Unsafe.As<byte, T>(ref GetSpanDataFrom(fldHandle, typeof(T).TypeHandle, out int length)), length);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\ValueTaskAwaiter.cs (6)
58Unsafe.As<IValueTaskSource>(obj).OnCompleted(s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext | ValueTaskSourceOnCompletedFlags.FlowExecutionContext); 78Unsafe.As<IValueTaskSource>(obj).OnCompleted(s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext); 97Unsafe.As<IValueTaskSource>(obj).OnCompleted(ThreadPool.s_invokeAsyncStateMachineBox, box, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext); 140Unsafe.As<IValueTaskSource<TResult>>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext | ValueTaskSourceOnCompletedFlags.FlowExecutionContext); 160Unsafe.As<IValueTaskSource<TResult>>(obj).OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext); 179Unsafe.As<IValueTaskSource<TResult>>(obj).OnCompleted(ThreadPool.s_invokeAsyncStateMachineBox, box, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\ComWrappers.cs (4)
135return Unsafe.As<T>(comInstance->Holder!.WrappedObject); 229return Unsafe.As<ManagedObjectWrapperHolder>(GCHandle.FromIntPtr(handle).Target); 441Interlocked.Or(ref Unsafe.As<CreateComInterfaceFlagsEx, int>(ref Flags), setMask); 447Interlocked.And(ref Unsafe.As<CreateComInterfaceFlagsEx, int>(ref Flags), resetMask);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\GCHandle.cs (5)
138return (IntPtr)Unsafe.AsPointer(ref Unsafe.As<string>(target).GetRawStringData()); 142return (IntPtr)Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<Array>(target))); 145return (IntPtr)Unsafe.AsPointer(ref target.GetRawData());
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\GCHandle.T.cs (1)
52return Unsafe.As<T>(GCHandle.InternalGet(handle));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\GCHandleExtensions.cs (2)
36return (T*)Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(array)); 59return (char*)Unsafe.AsPointer(ref str.GetRawStringData());
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshal.cs (8)
169void* pRawData = Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(arr)); 178void* pRawData = Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(arr)); 315return Unsafe.ReadUnaligned<short>(addr); 339return Unsafe.ReadUnaligned<int>(addr); 386return Unsafe.ReadUnaligned<long>(addr); 426Unsafe.WriteUnaligned(addr, val); 459Unsafe.WriteUnaligned(addr, val); 510Unsafe.WriteUnaligned(addr, val);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\AnsiStringMarshaller.cs (1)
91_unmanagedValue = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(buffer));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\ArrayMarshaller.cs (2)
179return (TUnmanagedElement*)Unsafe.AsPointer(ref GetPinnableReference()); 199return ref Unsafe.NullRef<T>();
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\BStrStringMarshaller.cs (1)
90byte* pBuffer = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(buffer));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\ComVariant.cs (1)
581return ref Unsafe.As<UnionTypes, T>(ref _typeUnion._unionTypes);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\PointerArrayMarshaller.cs (5)
53=> Unsafe.As<IntPtr[]>(managed); 84=> Unsafe.As<IntPtr[]>(managed); 159public ReadOnlySpan<IntPtr> GetManagedValuesSource() => Unsafe.As<IntPtr[]>(_managedArray); 180return (TUnmanagedElement*)Unsafe.AsPointer(ref GetPinnableReference()); 200return ref Unsafe.NullRef<byte>();
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\ReadOnlySpanMarshaller.cs (3)
44if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(managed))) 104if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(managed))) 149return (TUnmanagedElement*)Unsafe.AsPointer(ref GetPinnableReference());
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\SpanMarshaller.cs (3)
38if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(managed))) 132if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(managed))) 176return (TUnmanagedElement*)Unsafe.AsPointer(ref GetPinnableReference());
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\Utf8StringMarshaller.cs (1)
95_unmanagedValue = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(buffer));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\MemoryMarshal.cs (19)
37ref Unsafe.As<T, byte>(ref GetReference(span)), 60ref Unsafe.As<T, byte>(ref GetReference(span)), 93internal static unsafe ref T GetNonNullPinnableReference<T>(Span<T> span) => ref (span.Length != 0) ? ref Unsafe.AsRef(in span._reference) : ref Unsafe.AsRef<T>((void*)1); 100internal static unsafe ref T GetNonNullPinnableReference<T>(ReadOnlySpan<T> span) => ref (span.Length != 0) ? ref Unsafe.AsRef(in span._reference) : ref Unsafe.AsRef<T>((void*)1); 153ref Unsafe.As<TFrom, TTo>(ref span._reference), 208ref Unsafe.As<TFrom, TTo>(ref GetReference(span)), 227new Span<T>(ref Unsafe.AsRef(in reference), length); 244new ReadOnlySpan<T>(ref Unsafe.AsRef(in reference), length); 290segment = new ArraySegment<T>(Unsafe.As<T[]>(obj), index & ReadOnlyMemory<T>.RemoveFlagsBitMask, length); 299if (Unsafe.As<MemoryManager<T>>(obj).TryGetArray(out ArraySegment<T> tempArraySegment)) 411T[] array = Unsafe.As<T[]>(obj); 479return Unsafe.ReadUnaligned<T>(ref GetReference(source)); 499value = Unsafe.ReadUnaligned<T>(ref GetReference(source)); 518Unsafe.WriteUnaligned(ref GetReference(destination), value); 537Unsafe.WriteUnaligned(ref GetReference(destination), value); 560return ref Unsafe.As<byte, T>(ref GetReference(span)); 582return ref Unsafe.As<byte, T>(ref GetReference(span));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NFloat.cs (16)
697Unsafe.SkipInit(out result); 698return NativeType.TryParse(s, out Unsafe.As<NFloat, NativeType>(ref result)); 707Unsafe.SkipInit(out result); 708return NativeType.TryParse(s, out Unsafe.As<NFloat, NativeType>(ref result)); 717Unsafe.SkipInit(out result); 718return NativeType.TryParse(utf8Text, out Unsafe.As<NFloat, NativeType>(ref result)); 734Unsafe.SkipInit(out result); 735return NativeType.TryParse(s, style, provider, out Unsafe.As<NFloat, NativeType>(ref result)); 751Unsafe.SkipInit(out result); 752return NativeType.TryParse(s, style, provider, out Unsafe.As<NFloat, NativeType>(ref result)); 1052Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), exponent); 1076Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), exponent); 1100Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), significand); 1124Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), significand); 1922Unsafe.SkipInit(out result); 1923return NativeType.TryParse(utf8Text, style, provider, out Unsafe.As<NFloat, NativeType>(ref result));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\PinnedGCHandle.T.cs (2)
54return Unsafe.As<T>(GCHandle.InternalGet(handle)); 93return Unsafe.AsPointer(ref target.GetRawData());
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\ReferenceTrackerHost.cs (2)
14private static readonly unsafe IntPtr s_globalHostServices = (IntPtr)Unsafe.AsPointer(in HostServices.Vftbl); 19IReferenceTrackerManager.SetReferenceTrackerHost(trackerManager, (IntPtr)Unsafe.AsPointer(in s_globalHostServices));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeBuffer.cs (6)
195return Unsafe.ReadUnaligned<T>(ptr); 249Unsafe.Add(ref structure, (nint)(uint)i) = Unsafe.ReadUnaligned<T>(ptr + alignedSizeofT * (uint)i); 282Unsafe.WriteUnaligned(ptr, value); 338Unsafe.WriteUnaligned(ptr + alignedSizeofT * (uint)i, Unsafe.Add(ref structure, (nint)(uint)i));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\TrackerObjectManager.cs (1)
75ReferenceTrackerNativeObjectWrapper? nativeObjectWrapper = Unsafe.As<ReferenceTrackerNativeObjectWrapper?>(weakNativeObjectWrapperHandle.Target);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\WeakGCHandle.T.cs (1)
56T? obj = Unsafe.As<T?>(GCHandle.InternalGet(handle));
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\ISimdVector_2.cs (1)
275Unsafe.SkipInit(out TSelf result);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector128.cs (56)
183return Unsafe.BitCast<Vector128<TFrom>, Vector128<TTo>>(vector); 568Unsafe.SkipInit(out Vector128<float> result); 679Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[0]), vector); 706Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[startIndex]), vector); 723Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 907return Unsafe.ReadUnaligned<Vector128<T>>(ref Unsafe.As<T, byte>(ref values[0])); 928return Unsafe.ReadUnaligned<Vector128<T>>(ref Unsafe.As<T, byte>(ref values[index])); 945return Unsafe.ReadUnaligned<Vector128<T>>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values))); 1172Unsafe.SkipInit(out Vector128<T> result); 1358Unsafe.SkipInit(out Vector128<T> result); 2279ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source)); 2280return Unsafe.ReadUnaligned<Vector128<T>>(in address); 2295ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 2296return Unsafe.ReadUnaligned<Vector128<T>>(in address); 2302internal static Vector128<ushort> LoadUnsafe(ref char source) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source)); 2308internal static Vector128<ushort> LoadUnsafe(ref char source, nuint elementOffset) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source), elementOffset); 2623Unsafe.SkipInit(out Vector128<TResult> result); 2720Unsafe.SkipInit(out Vector128<TResult> result); 3240Unsafe.SkipInit(out Vector128<byte> result); 3285Unsafe.SkipInit(out Vector128<sbyte> result); 3362Unsafe.SkipInit(out Vector128<short> result); 3387Unsafe.SkipInit(out Vector128<ushort> result); 3450Unsafe.SkipInit(out Vector128<int> result); 3475Unsafe.SkipInit(out Vector128<uint> result); 3499Unsafe.SkipInit(out Vector128<float> result); 3581Unsafe.SkipInit(out Vector128<long> result); 3606Unsafe.SkipInit(out Vector128<ulong> result); 3630Unsafe.SkipInit(out Vector128<double> result); 3859ref byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref destination, elementOffset)); 3860Unsafe.WriteUnaligned(ref address, source.AsDouble().ToScalar()); 3873ref byte address = ref Unsafe.As<T, byte>(ref destination); 3874Unsafe.WriteUnaligned(ref address, source); 3889destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 3890Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source); 3985Unsafe.SkipInit(out Vector256<T> result); 4038Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 4375ref T address = ref Unsafe.As<Vector128<T>, T>(ref Unsafe.AsRef(in vector)); 4376return Unsafe.Add(ref address, index); 4383ref T address = ref Unsafe.As<Vector128<T>, T>(ref Unsafe.AsRef(in vector)); 4384Unsafe.Add(ref address, index) = value; 4388internal static void SetLowerUnsafe<T>(in this Vector128<T> vector, Vector64<T> value) => Unsafe.AsRef(in vector._lower) = value; 4391internal static void SetUpperUnsafe<T>(in this Vector128<T> vector, Vector64<T> value) => Unsafe.AsRef(in vector._upper) = value;
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector128.Numerics.cs (20)
61return Unsafe.BitCast<Vector128<float>, Plane>(value); 74return Unsafe.BitCast<Vector128<float>, Quaternion>(value); 87return Unsafe.BitCast<Plane, Vector128<float>>(value); 100return Unsafe.BitCast<Quaternion, Vector128<float>>(value); 125return Unsafe.BitCast<Vector4, Vector128<float>>(value); 141ref byte address = ref Unsafe.As<Vector<T>, byte>(ref value); 142return Unsafe.ReadUnaligned<Vector128<T>>(ref address); 154Unsafe.SkipInit(out Vector128<float> result); 155Unsafe.WriteUnaligned(ref Unsafe.As<Vector128<float>, byte>(ref result), value); 168Unsafe.SkipInit(out Vector128<float> result); 169Unsafe.WriteUnaligned(ref Unsafe.As<Vector128<float>, byte>(ref result), value); 180ref byte address = ref Unsafe.As<Vector128<float>, byte>(ref value); 181return Unsafe.ReadUnaligned<Vector2>(ref address); 191ref byte address = ref Unsafe.As<Vector128<float>, byte>(ref value); 192return Unsafe.ReadUnaligned<Vector3>(ref address); 204return Unsafe.BitCast<Vector128<float>, Vector4>(value); 221Unsafe.WriteUnaligned(ref Unsafe.As<Vector<T>, byte>(ref result), value);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector128_1.cs (1)
66Unsafe.SkipInit(out Vector128<T> result);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector128DebugView_1.cs (23)
22Unsafe.WriteUnaligned(ref items[0], _value); 32Unsafe.WriteUnaligned(ref Unsafe.As<double, byte>(ref items[0]), _value); 42Unsafe.WriteUnaligned(ref Unsafe.As<short, byte>(ref items[0]), _value); 52Unsafe.WriteUnaligned(ref Unsafe.As<int, byte>(ref items[0]), _value); 62Unsafe.WriteUnaligned(ref Unsafe.As<long, byte>(ref items[0]), _value); 72Unsafe.WriteUnaligned(ref Unsafe.As<nint, byte>(ref items[0]), _value); 82Unsafe.WriteUnaligned(ref Unsafe.As<nuint, byte>(ref items[0]), _value); 92Unsafe.WriteUnaligned(ref Unsafe.As<sbyte, byte>(ref items[0]), _value); 102Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref items[0]), _value); 112Unsafe.WriteUnaligned(ref Unsafe.As<ushort, byte>(ref items[0]), _value); 122Unsafe.WriteUnaligned(ref Unsafe.As<uint, byte>(ref items[0]), _value); 132Unsafe.WriteUnaligned(ref Unsafe.As<ulong, byte>(ref items[0]), _value);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector256.cs (60)
177return Unsafe.BitCast<Vector256<TFrom>, Vector256<TTo>>(vector); 295ref byte address = ref Unsafe.As<Vector<T>, byte>(ref value); 296return Unsafe.ReadUnaligned<Vector256<T>>(ref address); 301Unsafe.WriteUnaligned(ref Unsafe.As<Vector256<T>, byte>(ref result), value); 319ref byte address = ref Unsafe.As<Vector256<T>, byte>(ref value); 320return Unsafe.ReadUnaligned<Vector<T>>(ref address); 325Unsafe.WriteUnaligned(ref Unsafe.As<Vector<T>, byte>(ref result), value); 695Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[0]), vector); 722Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[startIndex]), vector); 739Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 923return Unsafe.ReadUnaligned<Vector256<T>>(ref Unsafe.As<T, byte>(ref values[0])); 944return Unsafe.ReadUnaligned<Vector256<T>>(ref Unsafe.As<T, byte>(ref values[index])); 961return Unsafe.ReadUnaligned<Vector256<T>>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values))); 1265Unsafe.SkipInit(out Vector256<T> result); 1453Unsafe.SkipInit(out Vector256<T> result); 2372ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source)); 2373return Unsafe.ReadUnaligned<Vector256<T>>(in address); 2388ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 2389return Unsafe.ReadUnaligned<Vector256<T>>(in address); 2395internal static Vector256<ushort> LoadUnsafe(ref char source) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source)); 2401internal static Vector256<ushort> LoadUnsafe(ref char source, nuint elementOffset) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source), elementOffset); 2716Unsafe.SkipInit(out Vector256<TResult> result); 2785Unsafe.SkipInit(out Vector256<TResult> result); 3264Unsafe.SkipInit(out Vector256<byte> result); 3289Unsafe.SkipInit(out Vector256<sbyte> result); 3354Unsafe.SkipInit(out Vector256<short> result); 3379Unsafe.SkipInit(out Vector256<ushort> result); 3442Unsafe.SkipInit(out Vector256<int> result); 3467Unsafe.SkipInit(out Vector256<uint> result); 3491Unsafe.SkipInit(out Vector256<float> result); 3573Unsafe.SkipInit(out Vector256<long> result); 3598Unsafe.SkipInit(out Vector256<ulong> result); 3622Unsafe.SkipInit(out Vector256<double> result); 3849ref byte address = ref Unsafe.As<T, byte>(ref destination); 3850Unsafe.WriteUnaligned(ref address, source); 3865destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 3866Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source); 3949Unsafe.SkipInit(out Vector512<T> result); 4002Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 4337ref T address = ref Unsafe.As<Vector256<T>, T>(ref Unsafe.AsRef(in vector)); 4338return Unsafe.Add(ref address, index); 4345ref T address = ref Unsafe.As<Vector256<T>, T>(ref Unsafe.AsRef(in vector)); 4346Unsafe.Add(ref address, index) = value; 4349internal static void SetLowerUnsafe<T>(in this Vector256<T> vector, Vector128<T> value) => Unsafe.AsRef(in vector._lower) = value; 4351internal static void SetUpperUnsafe<T>(in this Vector256<T> vector, Vector128<T> value) => Unsafe.AsRef(in vector._upper) = value;
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector256_1.cs (1)
65Unsafe.SkipInit(out Vector256<T> result);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector256DebugView_1.cs (23)
22Unsafe.WriteUnaligned(ref items[0], _value); 32Unsafe.WriteUnaligned(ref Unsafe.As<double, byte>(ref items[0]), _value); 42Unsafe.WriteUnaligned(ref Unsafe.As<short, byte>(ref items[0]), _value); 52Unsafe.WriteUnaligned(ref Unsafe.As<int, byte>(ref items[0]), _value); 62Unsafe.WriteUnaligned(ref Unsafe.As<long, byte>(ref items[0]), _value); 72Unsafe.WriteUnaligned(ref Unsafe.As<nint, byte>(ref items[0]), _value); 82Unsafe.WriteUnaligned(ref Unsafe.As<nuint, byte>(ref items[0]), _value); 92Unsafe.WriteUnaligned(ref Unsafe.As<sbyte, byte>(ref items[0]), _value); 102Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref items[0]), _value); 112Unsafe.WriteUnaligned(ref Unsafe.As<ushort, byte>(ref items[0]), _value); 122Unsafe.WriteUnaligned(ref Unsafe.As<uint, byte>(ref items[0]), _value); 132Unsafe.WriteUnaligned(ref Unsafe.As<ulong, byte>(ref items[0]), _value);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector512.cs (55)
176return Unsafe.BitCast<Vector512<TFrom>, Vector512<TTo>>(vector); 294Unsafe.WriteUnaligned(ref Unsafe.As<Vector512<T>, byte>(ref result), value); 310ref byte address = ref Unsafe.As<Vector512<T>, byte>(ref value); 311return Unsafe.ReadUnaligned<Vector<T>>(ref address); 607Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[0]), vector); 633Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[startIndex]), vector); 649Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 825return Unsafe.ReadUnaligned<Vector512<T>>(ref Unsafe.As<T, byte>(ref values[0])); 845return Unsafe.ReadUnaligned<Vector512<T>>(ref Unsafe.As<T, byte>(ref values[index])); 862return Unsafe.ReadUnaligned<Vector512<T>>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values))); 1305Unsafe.SkipInit(out Vector512<T> result); 1492Unsafe.SkipInit(out Vector512<T> result); 2398ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source)); 2399return Unsafe.ReadUnaligned<Vector512<T>>(in address); 2414ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 2415return Unsafe.ReadUnaligned<Vector512<T>>(in address); 2421internal static Vector512<ushort> LoadUnsafe(ref char source) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source)); 2427internal static Vector512<ushort> LoadUnsafe(ref char source, nuint elementOffset) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source), elementOffset); 2741Unsafe.SkipInit(out Vector512<TResult> result); 2810Unsafe.SkipInit(out Vector512<TResult> result); 3289Unsafe.SkipInit(out Vector512<byte> result); 3314Unsafe.SkipInit(out Vector512<sbyte> result); 3379Unsafe.SkipInit(out Vector512<short> result); 3404Unsafe.SkipInit(out Vector512<ushort> result); 3467Unsafe.SkipInit(out Vector512<int> result); 3492Unsafe.SkipInit(out Vector512<uint> result); 3516Unsafe.SkipInit(out Vector512<float> result); 3598Unsafe.SkipInit(out Vector512<long> result); 3623Unsafe.SkipInit(out Vector512<ulong> result); 3647Unsafe.SkipInit(out Vector512<double> result); 3860ref byte address = ref Unsafe.As<T, byte>(ref destination); 3861Unsafe.WriteUnaligned(ref address, source); 3876destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 3877Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source); 3979Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 4314ref T address = ref Unsafe.As<Vector512<T>, T>(ref Unsafe.AsRef(in vector)); 4315return Unsafe.Add(ref address, index); 4322ref T address = ref Unsafe.As<Vector512<T>, T>(ref Unsafe.AsRef(in vector)); 4323Unsafe.Add(ref address, index) = value; 4326internal static void SetLowerUnsafe<T>(in this Vector512<T> vector, Vector256<T> value) => Unsafe.AsRef(in vector._lower) = value; 4328internal static void SetUpperUnsafe<T>(in this Vector512<T> vector, Vector256<T> value) => Unsafe.AsRef(in vector._upper) = value;
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector512_1.cs (1)
65Unsafe.SkipInit(out Vector512<T> result);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector512DebugView_1.cs (23)
22Unsafe.WriteUnaligned(ref items[0], _value); 32Unsafe.WriteUnaligned(ref Unsafe.As<double, byte>(ref items[0]), _value); 42Unsafe.WriteUnaligned(ref Unsafe.As<short, byte>(ref items[0]), _value); 52Unsafe.WriteUnaligned(ref Unsafe.As<int, byte>(ref items[0]), _value); 62Unsafe.WriteUnaligned(ref Unsafe.As<long, byte>(ref items[0]), _value); 72Unsafe.WriteUnaligned(ref Unsafe.As<nint, byte>(ref items[0]), _value); 82Unsafe.WriteUnaligned(ref Unsafe.As<nuint, byte>(ref items[0]), _value); 92Unsafe.WriteUnaligned(ref Unsafe.As<sbyte, byte>(ref items[0]), _value); 102Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref items[0]), _value); 112Unsafe.WriteUnaligned(ref Unsafe.As<ushort, byte>(ref items[0]), _value); 122Unsafe.WriteUnaligned(ref Unsafe.As<uint, byte>(ref items[0]), _value); 132Unsafe.WriteUnaligned(ref Unsafe.As<ulong, byte>(ref items[0]), _value);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector64.cs (120)
46Unsafe.SkipInit(out Vector64<T> result); 73Unsafe.SkipInit(out Vector64<T> result); 176return Unsafe.BitCast<Vector64<TFrom>, Vector64<TTo>>(vector); 321Unsafe.SkipInit(out Vector64<T> result); 382Unsafe.SkipInit(out Vector64<double> result); 401Unsafe.SkipInit(out Vector64<double> result); 419Unsafe.SkipInit(out Vector64<int> result); 437Unsafe.SkipInit(out Vector64<int> result); 455Unsafe.SkipInit(out Vector64<long> result); 473Unsafe.SkipInit(out Vector64<long> result); 491Unsafe.SkipInit(out Vector64<float> result); 510Unsafe.SkipInit(out Vector64<float> result); 529Unsafe.SkipInit(out Vector64<uint> result); 548Unsafe.SkipInit(out Vector64<uint> result); 567Unsafe.SkipInit(out Vector64<ulong> result); 586Unsafe.SkipInit(out Vector64<ulong> result); 616Unsafe.SkipInit(out Vector64<T> result); 645Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[0]), vector); 672Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[startIndex]), vector); 689Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 695Unsafe.SkipInit(out Vector64<T> result); 786Unsafe.SkipInit(out Vector64<T> result); 896return Unsafe.ReadUnaligned<Vector64<T>>(ref Unsafe.As<T, byte>(ref values[0])); 917return Unsafe.ReadUnaligned<Vector64<T>>(ref Unsafe.As<T, byte>(ref values[index])); 934return Unsafe.ReadUnaligned<Vector64<T>>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values))); 952Unsafe.SkipInit(out Vector64<byte> result); 975Unsafe.SkipInit(out Vector64<short> result); 992Unsafe.SkipInit(out Vector64<int> result); 1014Unsafe.SkipInit(out Vector64<sbyte> result); 1034Unsafe.SkipInit(out Vector64<float> result); 1052Unsafe.SkipInit(out Vector64<ushort> result); 1070Unsafe.SkipInit(out Vector64<uint> result); 1180Unsafe.SkipInit(out Vector64<T> result); 1275Unsafe.SkipInit(out Vector64<T> result); 1356Unsafe.SkipInit(out Vector64<T> result); 1400Unsafe.SkipInit(out Vector64<T> result); 1493Unsafe.SkipInit(out Vector64<T> result); 1532Unsafe.SkipInit(out Vector64<double> result); 1556Unsafe.SkipInit(out Vector64<float> result); 1596Unsafe.SkipInit(out Vector64<T> result); 1659Unsafe.SkipInit(out Vector64<T> result); 1715Unsafe.SkipInit(out Vector64<T> result); 2047Unsafe.SkipInit(out Vector64<T> result); 2106Unsafe.SkipInit(out Vector64<T> result); 2169Unsafe.SkipInit(out Vector64<T> result); 2271ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source)); 2272return Unsafe.ReadUnaligned<Vector64<T>>(in address); 2287ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 2288return Unsafe.ReadUnaligned<Vector64<T>>(in address); 2294Unsafe.SkipInit(out Vector64<T> result); 2340Unsafe.SkipInit(out Vector64<T> result); 2394Unsafe.SkipInit(out Vector64<T> result); 2417Unsafe.SkipInit(out Vector64<T> result); 2440Unsafe.SkipInit(out Vector64<T> result); 2463Unsafe.SkipInit(out Vector64<T> result); 2486Unsafe.SkipInit(out Vector64<T> result); 2509Unsafe.SkipInit(out Vector64<T> result); 2532Unsafe.SkipInit(out Vector64<T> result); 2555Unsafe.SkipInit(out Vector64<T> result); 2578Unsafe.SkipInit(out Vector64<T> result); 2601Unsafe.SkipInit(out Vector64<T> result); 2644Unsafe.SkipInit(out Vector64<T> result); 2668Unsafe.SkipInit(out Vector64<double> result); 2692Unsafe.SkipInit(out Vector64<float> result); 2709Unsafe.SkipInit(out Vector64<TResult> result); 2778Unsafe.SkipInit(out Vector64<TResult> result); 2893Unsafe.SkipInit(out Vector64<T> result); 2957Unsafe.SkipInit(out Vector64<T> result); 3068Unsafe.SkipInit(out Vector64<uint> result); 3090Unsafe.SkipInit(out Vector64<ulong> result); 3281Unsafe.SkipInit(out Vector64<byte> result); 3306Unsafe.SkipInit(out Vector64<sbyte> result); 3371Unsafe.SkipInit(out Vector64<short> result); 3396Unsafe.SkipInit(out Vector64<ushort> result); 3459Unsafe.SkipInit(out Vector64<int> result); 3484Unsafe.SkipInit(out Vector64<uint> result); 3508Unsafe.SkipInit(out Vector64<float> result); 3586Unsafe.SkipInit(out Vector64<T> result); 3639Unsafe.SkipInit(out Vector64<T> sinResult); 3640Unsafe.SkipInit(out Vector64<T> cosResult); 3700Unsafe.SkipInit(out Vector64<T> result); 3760ref byte address = ref Unsafe.As<T, byte>(ref destination); 3761Unsafe.WriteUnaligned(ref address, source); 3776destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 3777Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source); 3795Unsafe.SkipInit(out Vector64<T> result); 3868Unsafe.SkipInit(out Vector128<T> result); 3892Unsafe.SkipInit(out Vector64<T> result); 3926Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 3984Unsafe.SkipInit(out Vector64<ushort> lower); 4002Unsafe.SkipInit(out Vector64<int> lower); 4020Unsafe.SkipInit(out Vector64<long> lower); 4039Unsafe.SkipInit(out Vector64<short> lower); 4057Unsafe.SkipInit(out Vector64<double> lower); 4076Unsafe.SkipInit(out Vector64<uint> lower); 4095Unsafe.SkipInit(out Vector64<ulong> lower); 4114Unsafe.SkipInit(out Vector64<ushort> upper); 4132Unsafe.SkipInit(out Vector64<int> upper); 4150Unsafe.SkipInit(out Vector64<long> upper); 4169Unsafe.SkipInit(out Vector64<short> upper); 4187Unsafe.SkipInit(out Vector64<double> upper); 4206Unsafe.SkipInit(out Vector64<uint> upper); 4225Unsafe.SkipInit(out Vector64<ulong> upper); 4271ref T address = ref Unsafe.As<Vector64<T>, T>(ref Unsafe.AsRef(in vector)); 4272return Unsafe.Add(ref address, index); 4279ref T address = ref Unsafe.As<Vector64<T>, T>(ref Unsafe.AsRef(in vector)); 4280Unsafe.Add(ref address, index) = value;
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector64_1.cs (18)
65Unsafe.SkipInit(out Vector64<T> result); 137Unsafe.SkipInit(out Vector64<T> result); 159Unsafe.SkipInit(out Vector64<T> result); 160Unsafe.AsRef(in result._00) = left._00 & right._00; 176Unsafe.SkipInit(out Vector64<T> result); 177Unsafe.AsRef(in result._00) = left._00 | right._00; 191Unsafe.SkipInit(out Vector64<T> result); 210Unsafe.SkipInit(out Vector64<T> result); 251Unsafe.SkipInit(out Vector64<T> result); 252Unsafe.AsRef(in result._00) = left._00 ^ right._00; 273Unsafe.SkipInit(out Vector64<T> result); 293Unsafe.SkipInit(out Vector64<T> result); 313Unsafe.SkipInit(out Vector64<T> result); 342Unsafe.SkipInit(out Vector64<T> result); 343Unsafe.AsRef(in result._00) = ~vector._00; 356Unsafe.SkipInit(out Vector64<T> result); 376Unsafe.SkipInit(out Vector64<T> result); 428Unsafe.SkipInit(out Vector64<T> result);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector64DebugView_1.cs (23)
22Unsafe.WriteUnaligned(ref items[0], _value); 32Unsafe.WriteUnaligned(ref Unsafe.As<double, byte>(ref items[0]), _value); 42Unsafe.WriteUnaligned(ref Unsafe.As<short, byte>(ref items[0]), _value); 52Unsafe.WriteUnaligned(ref Unsafe.As<int, byte>(ref items[0]), _value); 62Unsafe.WriteUnaligned(ref Unsafe.As<long, byte>(ref items[0]), _value); 72Unsafe.WriteUnaligned(ref Unsafe.As<nint, byte>(ref items[0]), _value); 82Unsafe.WriteUnaligned(ref Unsafe.As<nuint, byte>(ref items[0]), _value); 92Unsafe.WriteUnaligned(ref Unsafe.As<sbyte, byte>(ref items[0]), _value); 102Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref items[0]), _value); 112Unsafe.WriteUnaligned(ref Unsafe.As<ushort, byte>(ref items[0]), _value); 122Unsafe.WriteUnaligned(ref Unsafe.As<uint, byte>(ref items[0]), _value); 132Unsafe.WriteUnaligned(ref Unsafe.As<ulong, byte>(ref items[0]), _value);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\VectorMath.cs (113)
78TVectorInt64 ux = Unsafe.BitCast<TVectorDouble, TVectorInt64>(ax); 113Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(region & TVectorInt64.One, TVectorInt64.Zero)), 119Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals((region + TVectorInt64.One) & TVectorInt64.Create(2), TVectorInt64.Zero)), 130Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.GreaterThan(ux, TVectorInt64.Create(ARG_SMALLER - 1))), 216TVectorInt32 ux = Unsafe.BitCast<TVectorSingle, TVectorInt32>(ax); 273Unsafe.BitCast<TVectorInt32, TVectorSingle>(TVectorInt32.GreaterThan(ux, TVectorInt32.Create(ARG_SMALLER - 1))), 287Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(region & TVectorInt64.One, TVectorInt64.Zero)), 293Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals((region + TVectorInt64.One) & TVectorInt64.Create(2), TVectorInt64.Zero)), 411if (TVectorUInt64.LessThanOrEqualAll(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(TVectorDouble.Abs(x)), TVectorUInt64.Create(V_ARG_MAX))) 417TVectorUInt64 n = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(dn); 454return poly * Unsafe.BitCast<TVectorUInt64, TVectorDouble>((n + TVectorUInt64.Create(V_DP64_BIAS)) << 52); 542if (TVectorUInt32.GreaterThanAny(Unsafe.BitCast<TVectorSingle, TVectorUInt32>(TVectorSingle.Abs(x)), TVectorUInt32.Create(V_ARG_MAX))) 569TVectorUInt64 n = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(dn); 588return Unsafe.BitCast<TVectorUInt64, TVectorDouble>(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(poly) + (n << 52)); 608TVectorUInt64 xBits = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(ax); 609TVectorUInt64 yBits = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(ay); 618TVectorDouble insignificanMask = Unsafe.BitCast<TVectorUInt64, TVectorDouble>( 627TVectorDouble expFix = TVectorDouble.ConditionalSelect(Unsafe.BitCast<TVectorUInt64, TVectorDouble>(scaleDownMask), TVectorDouble.Create(4.149515568880993E+180), TVectorDouble.One); 633expFix = TVectorDouble.ConditionalSelect(Unsafe.BitCast<TVectorUInt64, TVectorDouble>(scaleUpMask), TVectorDouble.Create(2.409919865102884E-181), expFix); 648ax = Unsafe.BitCast<TVectorUInt64, TVectorDouble>(xBits); 649ax -= subnormalFix & Unsafe.BitCast<TVectorUInt64, TVectorDouble>(xSubnormalMask); 653ay = Unsafe.BitCast<TVectorUInt64, TVectorDouble>(yBits); 654ay -= subnormalFix & Unsafe.BitCast<TVectorUInt64, TVectorDouble>(ySubnormalMask); 656xBits = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(ax); 657yBits = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(ay); 667xBits = TVectorUInt64.ConditionalSelect(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(lessThanMask), yBits, xBits); 668yBits = TVectorUInt64.ConditionalSelect(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(lessThanMask), tmpBits, yBits); 675TVectorDouble xHead = Unsafe.BitCast<TVectorUInt64, TVectorDouble>(xBits & headMask); 676TVectorDouble yHead = Unsafe.BitCast<TVectorUInt64, TVectorDouble>(yBits & headMask); 698TVectorDouble equalExponentsMask = Unsafe.BitCast<TVectorUInt64, TVectorDouble>(TVectorUInt64.IsZero(expDiff)); 776TVectorUInt32 bits = Unsafe.BitCast<TVectorSingle, TVectorUInt32>(TVectorSingle.Abs(vector)); 793return Unsafe.BitCast<TVectorUInt32, TVectorSingle>(result); 801TVectorUInt64 bits = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(TVectorDouble.Abs(vector)); 818return Unsafe.BitCast<TVectorUInt64, TVectorDouble>(result); 826TVectorUInt32 bits = Unsafe.BitCast<TVectorSingle, TVectorUInt32>(TVectorSingle.Abs(vector)); 839return Unsafe.BitCast<TVectorUInt32, TVectorSingle>(result); 847TVectorUInt64 bits = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(TVectorDouble.Abs(vector)); 860return Unsafe.BitCast<TVectorUInt64, TVectorDouble>(result); 933TVectorUInt64 specialMask = TVectorUInt64.GreaterThanOrEqual(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x) - TVectorUInt64.Create(V_MIN), TVectorUInt64.Create(V_MAX - V_MIN)); 962TVectorDouble subnormalMask = TVectorDouble.AndNot(Unsafe.BitCast<TVectorUInt64, TVectorDouble>(specialMask), temp); 967Unsafe.BitCast<TVectorUInt64, TVectorDouble>(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x * 4503599627370496.0) - TVectorUInt64.Create(52ul << 52)), 971specialMask = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(temp); 975TVectorUInt64 vx = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x) - TVectorUInt64.Create(V_OFF); 976TVectorDouble n = ConvertToDouble<TVectorInt64, TVectorDouble>(Unsafe.BitCast<TVectorUInt64, TVectorInt64>(vx) >> 52); 980TVectorDouble r = Unsafe.BitCast<TVectorUInt64, TVectorDouble>(vx) - TVectorDouble.One; 1027Unsafe.BitCast<TVectorUInt64, TVectorDouble>(specialMask), 1114TVectorUInt32 specialMask = TVectorUInt32.GreaterThanOrEqual(Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x) - TVectorUInt32.Create(V_MIN), TVectorUInt32.Create(V_MAX - V_MIN)); 1143TVectorSingle subnormalMask = TVectorSingle.AndNot(Unsafe.BitCast<TVectorUInt32, TVectorSingle>(specialMask), temp); 1147Unsafe.BitCast<TVectorUInt32, TVectorSingle>(Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x * 8388608.0f) - TVectorUInt32.Create(23u << 23)), 1151specialMask = Unsafe.BitCast<TVectorSingle, TVectorUInt32>(temp); 1154TVectorUInt32 vx = Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x) - TVectorUInt32.Create(V_OFF); 1155TVectorSingle n = ConvertToSingle<TVectorInt32, TVectorSingle>(Unsafe.BitCast<TVectorUInt32, TVectorInt32>(vx) >> 23); 1159TVectorSingle r = Unsafe.BitCast<TVectorUInt32, TVectorSingle>(vx) - TVectorSingle.Create(1.0f); 1186Unsafe.BitCast<TVectorUInt32, TVectorSingle>(specialMask), 1253TVectorUInt64 specialMask = TVectorUInt64.GreaterThanOrEqual(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x) - TVectorUInt64.Create(V_MIN), TVectorUInt64.Create(V_MAX - V_MIN)); 1282TVectorDouble subnormalMask = TVectorDouble.AndNot(Unsafe.BitCast<TVectorUInt64, TVectorDouble>(specialMask), temp); 1287Unsafe.BitCast<TVectorUInt64, TVectorDouble>(Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x * 4503599627370496.0) - TVectorUInt64.Create(52ul << 52)), 1291specialMask = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(temp); 1295TVectorUInt64 vx = Unsafe.BitCast<TVectorDouble, TVectorUInt64>(x) - TVectorUInt64.Create(V_OFF); 1296TVectorDouble n = ConvertToDouble<TVectorInt64, TVectorDouble>(Unsafe.BitCast<TVectorUInt64, TVectorInt64>(vx) >> 52); 1300TVectorDouble r = Unsafe.BitCast<TVectorUInt64, TVectorDouble>(vx) - TVectorDouble.One; 1347Unsafe.BitCast<TVectorUInt64, TVectorDouble>(specialMask), 1430TVectorUInt32 specialMask = TVectorUInt32.GreaterThanOrEqual(Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x) - TVectorUInt32.Create(V_MIN), TVectorUInt32.Create(V_MAX - V_MIN)); 1459TVectorSingle subnormalMask = TVectorSingle.AndNot(Unsafe.BitCast<TVectorUInt32, TVectorSingle>(specialMask), temp); 1464Unsafe.BitCast<TVectorUInt32, TVectorSingle>(Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x * 8388608.0f) - TVectorUInt32.Create(23u << 23)), 1468specialMask = Unsafe.BitCast<TVectorSingle, TVectorUInt32>(temp); 1472TVectorUInt32 vx = Unsafe.BitCast<TVectorSingle, TVectorUInt32>(x) - TVectorUInt32.Create(V_OFF); 1473TVectorSingle n = ConvertToSingle<TVectorInt32, TVectorSingle>(Unsafe.BitCast<TVectorUInt32, TVectorInt32>(vx) >> 23); 1477TVectorSingle r = Unsafe.BitCast<TVectorUInt32, TVectorSingle>(vx) - TVectorSingle.One; 1504Unsafe.BitCast<TVectorUInt32, TVectorSingle>(specialMask), 1803TVectorInt64 ux = Unsafe.BitCast<TVectorDouble, TVectorInt64>(ax); 1842Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(region & TVectorInt64.One, TVectorInt64.Zero)), 1848Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(region & TVectorInt64.One, TVectorInt64.Zero)), 1853TVectorInt64 sign = Unsafe.BitCast<TVectorDouble, TVectorInt64>(x) >>> 63; 1856Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(((sign & (region >>> 1)) | (~sign & ~(region >>> 1))) & TVectorInt64.One, TVectorInt64.Zero)), 1862Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals((region + TVectorInt64.One) & TVectorInt64.Create(2), TVectorInt64.Zero)), 1873Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.GreaterThan(ux, TVectorInt64.Create(ARG_SMALLER - 1))), 1879Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.GreaterThan(ux, TVectorInt64.Create(ARG_SMALLER - 1))), 1922TVectorInt32 ux = Unsafe.BitCast<TVectorSingle, TVectorInt32>(ax); 1997Unsafe.BitCast<TVectorInt32, TVectorSingle>(TVectorInt32.GreaterThan(ux, TVectorInt32.Create(ARG_SMALLER - 1))), 2003Unsafe.BitCast<TVectorInt32, TVectorSingle>(TVectorInt32.GreaterThan(ux, TVectorInt32.Create(ARG_SMALLER - 1))), 2019Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(region & TVectorInt64.One, TVectorInt64.Zero)), 2025Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(region & TVectorInt64.One, TVectorInt64.Zero)), 2030TVectorInt64 sign = Unsafe.BitCast<TVectorDouble, TVectorInt64>(x) >>> 63; 2033Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(((sign & (region >>> 1)) | (~sign & ~(region >>> 1))) & TVectorInt64.One, TVectorInt64.Zero)), 2039Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals((region + TVectorInt64.One) & TVectorInt64.Create(2), TVectorInt64.Zero)), 2123TVectorInt64 ux = Unsafe.BitCast<TVectorDouble, TVectorInt64>(ax); 2153Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(region & TVectorInt64.One, TVectorInt64.Zero)), 2158TVectorInt64 sign = Unsafe.BitCast<TVectorDouble, TVectorInt64>(x) >>> 63; 2161Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(((sign & (region >>> 1)) | (~sign & ~(region >>> 1))) & TVectorInt64.One, TVectorInt64.Zero)), 2172Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.GreaterThan(ux, TVectorInt64.Create(ARG_SMALLER - 1))), 2253TVectorInt32 ux = Unsafe.BitCast<TVectorSingle, TVectorInt32>(ax); 2310Unsafe.BitCast<TVectorInt32, TVectorSingle>(TVectorInt32.GreaterThan(ux, TVectorInt32.Create(ARG_SMALLER - 1))), 2325Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(region & TVectorInt64.One, TVectorInt64.Zero)), 2330TVectorInt64 sign = Unsafe.BitCast<TVectorDouble, TVectorInt64>(x) >>> 63; 2333Unsafe.BitCast<TVectorInt64, TVectorDouble>(TVectorInt64.Equals(((sign & (region >>> 1)) | (~sign & ~(region >>> 1))) & TVectorInt64.One, TVectorInt64.Zero)), 2358Unsafe.SkipInit(out TVectorDouble result); 2393Unsafe.SkipInit(out TVectorSingle result); 2517Unsafe.SkipInit(out TVector result); 2551Unsafe.SkipInit(out TVector result); 2586Unsafe.SkipInit(out TVectorSingle result); 2643Unsafe.SkipInit(out TVectorSingle result); 2682Unsafe.SkipInit(out TVectorUInt32 result); 2731Unsafe.SkipInit(out TVectorUInt64 result); 2880TVectorInt64 region = Unsafe.BitCast<TVectorDouble, TVectorInt64>(npi2); 2899Unsafe.SkipInit(out TVectorDouble result); 2968Unsafe.SkipInit(out TVectorDouble result); 3008Unsafe.SkipInit(out TVectorDouble result);
src\libraries\System.Private.CoreLib\src\System\SByte.cs (1)
348result = (sbyte)Unsafe.Add(ref MemoryMarshal.GetReference(source), source.Length - sizeof(sbyte));
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any1SearchValues.cs (4)
36SpanHelpers.NonPackedIndexOfValueType<TImpl, SpanHelpers.DontNegate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, span.Length); 40SpanHelpers.NonPackedIndexOfValueType<TImpl, SpanHelpers.Negate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, span.Length); 44SpanHelpers.LastIndexOfValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, span.Length); 48SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any2CharPackedIgnoreCaseSearchValues.cs (2)
57ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 65ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any2SearchValues.cs (4)
36SpanHelpers.NonPackedIndexOfAnyValueType<TImpl, SpanHelpers.DontNegate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, span.Length); 40SpanHelpers.NonPackedIndexOfAnyValueType<TImpl, SpanHelpers.Negate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, span.Length); 44SpanHelpers.LastIndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, span.Length); 48SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any3SearchValues.cs (4)
36SpanHelpers.NonPackedIndexOfAnyValueType<TImpl, SpanHelpers.DontNegate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, span.Length); 40SpanHelpers.NonPackedIndexOfAnyValueType<TImpl, SpanHelpers.Negate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, span.Length); 44SpanHelpers.LastIndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, span.Length); 48SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any4SearchValues.cs (4)
39SpanHelpers.IndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, span.Length); 43SpanHelpers.IndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, span.Length); 47SpanHelpers.LastIndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, span.Length); 51SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any5SearchValues.cs (4)
40SpanHelpers.IndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, _e4, span.Length); 44SpanHelpers.IndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, _e4, span.Length); 48SpanHelpers.LastIndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, _e4, span.Length); 52SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, _e4, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\AsciiCharSearchValues.cs (6)
49ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 57ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 65ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 73ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 81ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 89ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
src\libraries\System.Private.CoreLib\src\System\SearchValues\BitmapCharSearchValues.cs (5)
73ref char searchSpaceEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 77while (!Unsafe.AreSame(ref cur, ref searchSpaceEnd)) 82return (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref cur) / sizeof(char)); 85cur = ref Unsafe.Add(ref cur, 1); 98char c = Unsafe.Add(ref searchSpace, searchSpaceLength);
src\libraries\System.Private.CoreLib\src\System\SearchValues\IndexOfAnyAsciiSearcher.cs (102)
193TryIndexOfAny<DontNegate>(ref Unsafe.As<char, short>(ref searchSpace), searchSpaceLength, asciiValues, out index); 197TryIndexOfAny<Negate>(ref Unsafe.As<char, short>(ref searchSpace), searchSpaceLength, asciiValues, out index); 201TryLastIndexOfAny<DontNegate>(ref Unsafe.As<char, short>(ref searchSpace), searchSpaceLength, asciiValues, out index); 205TryLastIndexOfAny<Negate>(ref Unsafe.As<char, short>(ref searchSpace), searchSpaceLength, asciiValues, out index); 295ref short searchSpaceEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 297while (!Unsafe.AreSame(ref currentSearchSpace, ref searchSpaceEnd)) 305currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 1); 325ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - (2 * Vector256<short>.Count)); 338currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector256<short>.Count); 340while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 347ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - Vector256<short>.Count); 349ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 378ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - (2 * Vector128<short>.Count)); 391currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector128<short>.Count); 393while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 400ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - Vector128<short>.Count); 402ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 431char c = (char)Unsafe.Add(ref searchSpace, i); 441ref short currentSearchSpace = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 457ref short twoVectorsAfterStart = ref Unsafe.Add(ref searchSpace, 2 * Vector256<short>.Count); 461currentSearchSpace = ref Unsafe.Subtract(ref currentSearchSpace, 2 * Vector256<short>.Count); 472while (Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref twoVectorsAfterStart)); 479ref short oneVectorAfterStart = ref Unsafe.Add(ref searchSpace, Vector256<short>.Count); 481ref short secondVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAfterStart) 482? ref Unsafe.Subtract(ref currentSearchSpace, Vector256<short>.Count) 508ref short twoVectorsAfterStart = ref Unsafe.Add(ref searchSpace, 2 * Vector128<short>.Count); 512currentSearchSpace = ref Unsafe.Subtract(ref currentSearchSpace, 2 * Vector128<short>.Count); 523while (Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref twoVectorsAfterStart)); 530ref short oneVectorAfterStart = ref Unsafe.Add(ref searchSpace, Vector128<short>.Count); 532ref short secondVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAfterStart) 533? ref Unsafe.Subtract(ref currentSearchSpace, Vector128<short>.Count) 580ref byte searchSpaceEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 582while (!Unsafe.AreSame(ref currentSearchSpace, ref searchSpaceEnd)) 590currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 1); 608ref byte vectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - Vector256<byte>.Count); 620currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<byte>.Count); 622while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref vectorAwayFromEnd)); 629ref byte halfVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - Vector128<byte>.Count); 631ref byte firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref halfVectorAwayFromEnd) 657ref byte vectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - Vector128<byte>.Count); 669currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<byte>.Count); 671while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref vectorAwayFromEnd)); 678ref byte halfVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - sizeof(ulong)); 680ref byte firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref halfVectorAwayFromEnd) 684ulong source0 = Unsafe.ReadUnaligned<ulong>(ref firstVector); 685ulong source1 = Unsafe.ReadUnaligned<ulong>(ref halfVectorAwayFromEnd); 709byte b = Unsafe.Add(ref searchSpace, i); 719ref byte currentSearchSpace = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 733ref byte vectorAfterStart = ref Unsafe.Add(ref searchSpace, Vector256<byte>.Count); 737currentSearchSpace = ref Unsafe.Subtract(ref currentSearchSpace, Vector256<byte>.Count); 747while (Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref vectorAfterStart)); 754ref byte halfVectorAfterStart = ref Unsafe.Add(ref searchSpace, Vector128<byte>.Count); 756ref byte secondVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref halfVectorAfterStart) 757? ref Unsafe.Subtract(ref currentSearchSpace, Vector128<byte>.Count) 782ref byte vectorAfterStart = ref Unsafe.Add(ref searchSpace, Vector128<byte>.Count); 786currentSearchSpace = ref Unsafe.Subtract(ref currentSearchSpace, Vector128<byte>.Count); 796while (Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref vectorAfterStart)); 803ref byte halfVectorAfterStart = ref Unsafe.Add(ref searchSpace, sizeof(ulong)); 805ref byte secondVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref halfVectorAfterStart) 806? ref Unsafe.Subtract(ref currentSearchSpace, sizeof(ulong)) 809ulong source0 = Unsafe.ReadUnaligned<ulong>(ref searchSpace); 810ulong source1 = Unsafe.ReadUnaligned<ulong>(ref secondVector); 851ref byte searchSpaceEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 853while (!Unsafe.AreSame(ref currentSearchSpace, ref searchSpaceEnd)) 861currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 1); 880ref byte vectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - Vector256<byte>.Count); 892currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<byte>.Count); 894while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref vectorAwayFromEnd)); 901ref byte halfVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - Vector128<byte>.Count); 903ref byte firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref halfVectorAwayFromEnd) 932ref byte vectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - Vector128<byte>.Count); 944currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<byte>.Count); 946while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref vectorAwayFromEnd)); 953ref byte halfVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength - sizeof(ulong)); 955ref byte firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref halfVectorAwayFromEnd) 959ulong source0 = Unsafe.ReadUnaligned<ulong>(ref firstVector); 960ulong source1 = Unsafe.ReadUnaligned<ulong>(ref halfVectorAwayFromEnd); 983byte b = Unsafe.Add(ref searchSpace, i); 993ref byte currentSearchSpace = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 1008ref byte vectorAfterStart = ref Unsafe.Add(ref searchSpace, Vector256<byte>.Count); 1012currentSearchSpace = ref Unsafe.Subtract(ref currentSearchSpace, Vector256<byte>.Count); 1022while (Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref vectorAfterStart)); 1029ref byte halfVectorAfterStart = ref Unsafe.Add(ref searchSpace, Vector128<byte>.Count); 1031ref byte secondVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref halfVectorAfterStart) 1032? ref Unsafe.Subtract(ref currentSearchSpace, Vector128<byte>.Count) 1060ref byte vectorAfterStart = ref Unsafe.Add(ref searchSpace, Vector128<byte>.Count); 1064currentSearchSpace = ref Unsafe.Subtract(ref currentSearchSpace, Vector128<byte>.Count); 1074while (Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref vectorAfterStart)); 1081ref byte halfVectorAfterStart = ref Unsafe.Add(ref searchSpace, sizeof(ulong)); 1083ref byte secondVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref halfVectorAfterStart) 1084? ref Unsafe.Subtract(ref currentSearchSpace, sizeof(ulong)) 1087ulong source0 = Unsafe.ReadUnaligned<ulong>(ref searchSpace); 1088ulong source1 = Unsafe.ReadUnaligned<ulong>(ref secondVector); 1257return offsetInVector + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / (nuint)sizeof(T)); 1272return offsetInVector - Vector128<short>.Count + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref secondVector) / (nuint)sizeof(T)); 1288return offsetInVector + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / (nuint)sizeof(T)); 1310return offsetInVector - Vector256<short>.Count + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref secondVector) / (nuint)sizeof(T)); 1464return (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / (nuint)sizeof(T)); 1472return offsetInVector + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / (nuint)sizeof(T)); 1487return offsetInVector + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / (nuint)sizeof(T)); 1501return offsetInVector + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current0) / (nuint)sizeof(T)); 1522return offsetInVector + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current0) / (nuint)sizeof(T));
src\libraries\System.Private.CoreLib\src\System\SearchValues\ProbabilisticMap.cs (69)
85Unsafe.Add(ref Unsafe.As<uint, byte>(ref charMap), value & VectorizedIndexMask) |= (byte)(1u << (value >> VectorizedIndexShift)); 89Unsafe.Add(ref charMap, value & PortableIndexMask) |= 1u << (value >> PortableIndexShift); 96? (Unsafe.Add(ref Unsafe.As<uint, byte>(ref charMap), value & VectorizedIndexMask) & (1u << (value >> VectorizedIndexShift))) != 0 97: (Unsafe.Add(ref charMap, value & PortableIndexMask) & (1u << (value >> PortableIndexShift))) != 0; 108ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(values)), 426ref char searchSpaceEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 428Vector256<byte> charMap256 = Vector256.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map)); 437ref char lastStartVector = ref Unsafe.Subtract(ref searchSpaceEnd, 64); 441Vector512<byte> result = ContainsMask64CharsAvx512(charMap512, ref cur, ref Unsafe.Add(ref cur, Vector512<ushort>.Count)); 451cur = ref Unsafe.Add(ref cur, 64); 453if (Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVector)) 455if (Unsafe.AreSame(ref cur, ref searchSpaceEnd)) 471Vector512<byte> result = ContainsMask64CharsAvx512(charMap512, ref searchSpace, ref Unsafe.Subtract(ref searchSpaceEnd, Vector512<ushort>.Count)); 488Vector256<byte> result = ContainsMask32CharsAvx512(charMap256, ref searchSpace, ref Unsafe.Subtract(ref searchSpaceEnd, Vector256<ushort>.Count)); 510ref char searchSpaceEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 513Vector128<byte> charMapLower = Vector128.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map)); 514Vector128<byte> charMapUpper = Vector128.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map), (nuint)Vector128<byte>.Count); 523ref char lastStartVectorAvx2 = ref Unsafe.Subtract(ref searchSpaceEnd, 32); 537cur = ref Unsafe.Add(ref cur, 32); 539if (Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVectorAvx2)) 541if (Unsafe.AreSame(ref cur, ref searchSpaceEnd)) 546if (Unsafe.ByteOffset(ref cur, ref searchSpaceEnd) > 16 * sizeof(char)) 556cur = ref Unsafe.Subtract(ref searchSpaceEnd, 16); 563ref char lastStartVector = ref Unsafe.Subtract(ref searchSpaceEnd, 16); 577cur = ref Unsafe.Add(ref cur, 16); 579if (Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVector)) 581if (Unsafe.AreSame(ref cur, ref searchSpaceEnd)) 601ref char cur = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 603Vector256<byte> charMap256 = Vector256.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map)); 611ref char lastStartVector = ref Unsafe.Add(ref searchSpace, 64); 615Debug.Assert(Unsafe.ByteOffset(ref searchSpace, ref cur) >= 64 * sizeof(char)); 617cur = ref Unsafe.Subtract(ref cur, 64); 619Vector512<byte> result = ContainsMask64CharsAvx512(charMap512, ref cur, ref Unsafe.Add(ref cur, Vector512<ushort>.Count)); 629if (!Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVector)) 631if (Unsafe.AreSame(ref cur, ref searchSpace)) 644Debug.Assert(Unsafe.ByteOffset(ref searchSpace, ref cur) >= 32 * sizeof(char)); 648Vector512<byte> result = ContainsMask64CharsAvx512(charMap512, ref searchSpace, ref Unsafe.Subtract(ref cur, Vector512<ushort>.Count)); 662Debug.Assert(Unsafe.ByteOffset(ref searchSpace, ref cur) >= 16 * sizeof(char)); 666Vector256<byte> result = ContainsMask32CharsAvx512(charMap256, ref searchSpace, ref Unsafe.Subtract(ref cur, Vector256<ushort>.Count)); 688ref char cur = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 690Vector128<byte> charMapLower = Vector128.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map)); 691Vector128<byte> charMapUpper = Vector128.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map), (nuint)Vector128<byte>.Count); 700ref char lastStartVectorAvx2 = ref Unsafe.Add(ref searchSpace, 32); 704Debug.Assert(Unsafe.ByteOffset(ref searchSpace, ref cur) >= 32 * sizeof(char)); 706cur = ref Unsafe.Subtract(ref cur, 32); 718if (!Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVectorAvx2)) 720if (Unsafe.AreSame(ref cur, ref searchSpace)) 725if (Unsafe.ByteOffset(ref searchSpace, ref cur) > 16 * sizeof(char)) 735cur = ref Unsafe.Add(ref searchSpace, 16); 742ref char lastStartVector = ref Unsafe.Add(ref searchSpace, 16); 746Debug.Assert(Unsafe.ByteOffset(ref searchSpace, ref cur) >= 16 * sizeof(char)); 748cur = ref Unsafe.Subtract(ref cur, 16); 760if (!Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVector)) 762if (Unsafe.AreSame(ref cur, ref searchSpace)) 777(int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref cur) / sizeof(char)); 787if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 815if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 836if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 864if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 885if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 917if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 936if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 968if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 983ref char searchSpaceEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 986while (!Unsafe.AreSame(ref cur, ref searchSpaceEnd)) 994cur = ref Unsafe.Add(ref cur, 1); 1006char c = Unsafe.Add(ref searchSpace, i);
src\libraries\System.Private.CoreLib\src\System\SearchValues\ProbabilisticMapState.cs (11)
88return Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(hashEntries), (nuint)offset) == value; 98ref Unsafe.As<ProbabilisticMap, uint>(ref Map), 234ref char searchSpaceEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 244while (!Unsafe.AreSame(ref cur, ref searchSpaceEnd)) 249return (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref cur) / sizeof(char)); 252cur = ref Unsafe.Add(ref cur, 1); 257while (!Unsafe.AreSame(ref cur, ref searchSpaceEnd)) 262return (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref cur) / sizeof(char)); 265cur = ref Unsafe.Add(ref cur, 1); 286char c = Unsafe.Add(ref searchSpace, searchSpaceLength); 297char c = Unsafe.Add(ref searchSpace, searchSpaceLength);
src\libraries\System.Private.CoreLib\src\System\SearchValues\ProbabilisticWithAsciiCharSearchValues.cs (6)
60ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), 70ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), 109ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), 159ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), 169ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), 198ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)),
src\libraries\System.Private.CoreLib\src\System\SearchValues\RangeCharSearchValues.cs (2)
45ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(span)), 55ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(span)),
src\libraries\System.Private.CoreLib\src\System\SearchValues\SearchValues.T.cs (1)
59"\"" + new string(Unsafe.As<T[], char[]>(ref values)) + "\"" :
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\AsciiStringSearchValuesTeddyBase.cs (48)
203ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationVector128); 205searchSpace = ref Unsafe.Add(ref searchSpace, MatchStartOffsetN2); 223searchSpace = ref Unsafe.Add(ref searchSpace, CharsPerIterationVector128); 225if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpaceStart)) 227if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpaceStart, CharsPerIterationVector128))) 255ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationAvx2); 257searchSpace = ref Unsafe.Add(ref searchSpace, MatchStartOffsetN2); 275searchSpace = ref Unsafe.Add(ref searchSpace, CharsPerIterationAvx2); 277if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpaceStart)) 279if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpaceStart, CharsPerIterationAvx2))) 307ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationAvx512); 309searchSpace = ref Unsafe.Add(ref searchSpace, MatchStartOffsetN2); 327searchSpace = ref Unsafe.Add(ref searchSpace, CharsPerIterationAvx512); 329if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpaceStart)) 331if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpaceStart, CharsPerIterationAvx512))) 362ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationVector128); 364searchSpace = ref Unsafe.Add(ref searchSpace, MatchStartOffsetN3); 397searchSpace = ref Unsafe.Add(ref searchSpace, CharsPerIterationVector128); 399if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpaceStart)) 401if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpaceStart, CharsPerIterationVector128))) 432ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationAvx2); 434searchSpace = ref Unsafe.Add(ref searchSpace, MatchStartOffsetN3); 454searchSpace = ref Unsafe.Add(ref searchSpace, CharsPerIterationAvx2); 456if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpaceStart)) 458if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpaceStart, CharsPerIterationAvx2))) 487ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationAvx512); 489searchSpace = ref Unsafe.Add(ref searchSpace, MatchStartOffsetN3); 509searchSpace = ref Unsafe.Add(ref searchSpace, CharsPerIterationAvx512); 511if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpaceStart)) 513if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpaceStart, CharsPerIterationAvx512))) 546ref char matchRef = ref Unsafe.Add(ref searchSpace, matchOffset - matchStartOffset); 547offsetFromStart = (int)((nuint)Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref matchRef) / 2); 564? StartsWith<TCaseSensitivity>(ref matchRef, lengthRemaining, Unsafe.As<string[]>(bucket)) 565: StartsWith<TCaseSensitivity>(ref matchRef, lengthRemaining, Unsafe.As<string>(bucket))) 593ref char matchRef = ref Unsafe.Add(ref searchSpace, matchOffset - matchStartOffset); 594offsetFromStart = (int)((nuint)Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref matchRef) / 2); 609? StartsWith<TCaseSensitivity>(ref matchRef, lengthRemaining, Unsafe.As<string[]>(bucket)) 610: StartsWith<TCaseSensitivity>(ref matchRef, lengthRemaining, Unsafe.As<string>(bucket))) 638ref char matchRef = ref Unsafe.Add(ref searchSpace, matchOffset - matchStartOffset); 639offsetFromStart = (int)((nuint)Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref matchRef) / 2); 654? StartsWith<TCaseSensitivity>(ref matchRef, lengthRemaining, Unsafe.As<string[]>(bucket)) 655: StartsWith<TCaseSensitivity>(ref matchRef, lengthRemaining, Unsafe.As<string>(bucket)))
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\AhoCorasick.cs (13)
100ref Unsafe.As<char, short>(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), i)), 102ref Unsafe.AsRef(in _startingAsciiChars)); 123char c = TCaseSensitivity.TransformInput(Unsafe.Add(ref MemoryMarshal.GetReference(span), i)); 128ref AhoCorasickNode node = ref Unsafe.Add(ref nodes, (uint)nodeIndex); 136int matchLength = Unsafe.Add(ref nodes, (uint)nodeIndex).MatchLength; 209ref Unsafe.As<char, short>(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), i)), 211ref Unsafe.AsRef(in _startingAsciiChars)); 242c = Unsafe.Add(ref MemoryMarshal.GetReference(span), i); 247char.IsLowSurrogate(lowSurrogate = Unsafe.Add(ref MemoryMarshal.GetReference(span), i + 1))) 277ref AhoCorasickNode node = ref Unsafe.Add(ref nodes, (uint)nodeIndex); 285int matchLength = Unsafe.Add(ref nodes, (uint)nodeIndex).MatchLength;
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\AhoCorasickNode.cs (2)
44int[] table = Unsafe.As<int[]>(children); 56return Unsafe.As<Dictionary<char, int>>(children).TryGetValue(c, out index);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\RabinKarp.cs (7)
120ref char end = ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (uint)(span.Length - hashLength)); 125hash = (hash << HashShiftPerElement) + TCaseSensitivity.TransformInput(Unsafe.Add(ref current, i)); 135if (Unsafe.Add(ref bucketsRef, hash % BucketCount) is string[] bucket) 137int startOffset = (int)((nuint)Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref current) / sizeof(char)); 145if (!Unsafe.IsAddressLessThan(ref current, ref end)) 151char next = TCaseSensitivity.TransformInput(Unsafe.Add(ref current, (uint)hashLength)); 155current = ref Unsafe.Add(ref current, 1);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\StringSearchValuesHelper.cs (35)
30nint currentByteOffset = Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref searchSpace); 75ref Unsafe.As<char, byte>(ref matchStart), 150Vector128.LoadUnsafe(ref Unsafe.AddByteOffset(ref value.GetRawStringDataAsUInt16(), SecondReadByteOffset))); 156Unsafe.ReadUnaligned<ulong>(ref value.GetRawStringDataAsUInt8()), 157Unsafe.ReadUnaligned<ulong>(ref Unsafe.Add(ref value.GetRawStringDataAsUInt8(), SecondReadByteOffset)) 166Unsafe.ReadUnaligned<uint>(ref value.GetRawStringDataAsUInt8()), 167Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref value.GetRawStringDataAsUInt8(), SecondReadByteOffset)) 192Vector128.LoadUnsafe(ref Unsafe.AddByteOffset(ref matchStart, SecondReadByteOffset))); 199different |= Vector128.LoadUnsafe(ref Unsafe.AddByteOffset(ref matchStart, SecondReadByteOffset)) ^ Value256.GetUpper(); 214Vector128.LoadUnsafe(ref Unsafe.AddByteOffset(ref matchStart, SecondReadByteOffset))); 221different |= (Vector128.LoadUnsafe(ref Unsafe.AddByteOffset(ref matchStart, SecondReadByteOffset)) & ToUpperMask256.GetUpper()) ^ Value256.GetUpper(); 265ref byte matchByteStart = ref Unsafe.As<char, byte>(ref matchStart); 266ulong differentBits = Unsafe.ReadUnaligned<ulong>(ref matchByteStart) - state.Value64_0; 267differentBits |= Unsafe.ReadUnaligned<ulong>(ref Unsafe.Add(ref matchByteStart, state.SecondReadByteOffset)) - state.Value64_1; 277ref byte matchByteStart = ref Unsafe.As<char, byte>(ref matchStart); 278return Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref matchByteStart, state.SecondReadByteOffset)) == state.Value32_1; 314ref byte matchByteStart = ref Unsafe.As<char, byte>(ref matchStart); 315ulong differentBits = (Unsafe.ReadUnaligned<ulong>(ref matchByteStart) & CaseMask) - state.Value64_0; 316differentBits |= (Unsafe.ReadUnaligned<ulong>(ref Unsafe.Add(ref matchByteStart, state.SecondReadByteOffset)) & CaseMask) - state.Value64_1; 327ref byte matchByteStart = ref Unsafe.As<char, byte>(ref matchStart); 328return (Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref matchByteStart, state.SecondReadByteOffset)) & CaseMask) == state.Value32_1; 387ref byte matchByteStart = ref Unsafe.As<char, byte>(ref matchStart); 388ulong differentBits = (Unsafe.ReadUnaligned<ulong>(ref matchByteStart) & state.ToUpperMask64_0) - state.Value64_0; 389differentBits |= (Unsafe.ReadUnaligned<ulong>(ref Unsafe.Add(ref matchByteStart, state.SecondReadByteOffset)) & state.ToUpperMask64_1) - state.Value64_1; 397ref byte matchByteStart = ref Unsafe.As<char, byte>(ref matchStart); 398uint differentBits = (Unsafe.ReadUnaligned<uint>(ref matchByteStart) & state.ToUpperMask32_0) - state.Value32_0; 399differentBits |= (Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref matchByteStart, state.SecondReadByteOffset)) & state.ToUpperMask32_1) - state.Value32_1;
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\SingleStringSearchValuesThreeChars.cs (32)
97ref char lastSearchSpace = ref Unsafe.Add(ref searchSpace, searchSpaceMinusValueTailLength - Vector512<ushort>.Count); 115searchSpace = ref Unsafe.Add(ref searchSpace, Vector512<ushort>.Count); 117if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpace)) 119if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpace, Vector512<ushort>.Count))) 145ref char lastSearchSpace = ref Unsafe.Add(ref searchSpace, searchSpaceMinusValueTailLength - Vector256<ushort>.Count); 162searchSpace = ref Unsafe.Add(ref searchSpace, Vector256<ushort>.Count); 164if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpace)) 166if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpace, Vector256<ushort>.Count))) 192ref char lastSearchSpace = ref Unsafe.Add(ref searchSpace, searchSpaceMinusValueTailLength - Vector128<ushort>.Count); 209searchSpace = ref Unsafe.Add(ref searchSpace, Vector128<ushort>.Count); 211if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpace)) 213if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpace, Vector128<ushort>.Count))) 239ref char cur = ref Unsafe.Add(ref searchSpace, i); 260Vector128<ushort> cmpCh2 = Vector128.Equals(ch2, Vector128.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16()); 261Vector128<ushort> cmpCh3 = Vector128.Equals(ch3, Vector128.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16()); 273Vector128<ushort> cmpCh2 = Vector128.Equals(ch2, Vector128.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16() & caseConversion); 274Vector128<ushort> cmpCh3 = Vector128.Equals(ch3, Vector128.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16() & caseConversion); 288Vector256<ushort> cmpCh2 = Vector256.Equals(ch2, Vector256.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16()); 289Vector256<ushort> cmpCh3 = Vector256.Equals(ch3, Vector256.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16()); 297Vector256<ushort> cmpCh2 = Vector256.Equals(ch2, Vector256.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16() & caseConversion); 298Vector256<ushort> cmpCh3 = Vector256.Equals(ch3, Vector256.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16() & caseConversion); 311Vector512<ushort> cmpCh2 = Vector512.Equals(ch2, Vector512.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16()); 312Vector512<ushort> cmpCh3 = Vector512.Equals(ch3, Vector512.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16()); 320Vector512<ushort> cmpCh2 = Vector512.Equals(ch2, Vector512.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16() & caseConversion); 321Vector512<ushort> cmpCh3 = Vector512.Equals(ch3, Vector512.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16() & caseConversion); 336ref char matchRef = ref Unsafe.AddByteOffset(ref searchSpace, bitPos); 342offsetFromStart = (int)((nuint)Unsafe.ByteOffset(ref searchSpaceStart, ref matchRef) / 2); 364ref char matchRef = ref Unsafe.AddByteOffset(ref searchSpace, bitPos); 370offsetFromStart = (int)((nuint)Unsafe.ByteOffset(ref searchSpaceStart, ref matchRef) / 2);
src\libraries\System.Private.CoreLib\src\System\Span.cs (9)
88_reference = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)start /* force zero-extension */); 155return ref Unsafe.Add(ref _reference, (nint)(uint)index /* force zero-extension */); 285ref T ret = ref Unsafe.NullRef<T>(); 298SpanHelpers.ClearWithReferences(ref Unsafe.As<T, IntPtr>(ref _reference), (uint)_length * (nuint)(sizeof(T) / sizeof(nuint))); 302SpanHelpers.ClearWithoutReferences(ref Unsafe.As<T, byte>(ref _reference), (uint)_length * (nuint)sizeof(T)); 366Unsafe.AreSame(ref left._reference, ref right._reference); 382return new string(new ReadOnlySpan<char>(ref Unsafe.As<T, char>(ref _reference), _length)); 400return new Span<T>(ref Unsafe.Add(ref _reference, (nint)(uint)start /* force zero-extension */), _length - start); 428return new Span<T>(ref Unsafe.Add(ref _reference, (nint)(uint)start /* force zero-extension */), length);
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.BinarySearch.cs (1)
40int c = comparable.CompareTo(Unsafe.Add(ref spanStart, i));
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.Byte.cs (75)
36ref byte valueTail = ref Unsafe.Add(ref value, 1); 42int relativeIndex = IndexOfValueType(ref Unsafe.Add(ref searchSpace, offset), valueHead, remainingSearchSpaceLength); 54ref Unsafe.Add(ref searchSpace, offset + 1), 70byte ch2Val = Unsafe.Add(ref value, valueTailLength); 73ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 116ref Unsafe.Add(ref searchSpace, offset + bitPos), 131byte ch2Val = Unsafe.Add(ref value, valueTailLength); 134ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 177ref Unsafe.Add(ref searchSpace, offset + bitPos), 192byte ch2Val = Unsafe.Add(ref value, valueTailLength); 195ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 238ref Unsafe.Add(ref searchSpace, offset + bitPos), 272ref byte valueTail = ref Unsafe.Add(ref value, 1); 288ref Unsafe.Add(ref searchSpace, relativeIndex + 1), 305byte ch2Val = Unsafe.Add(ref value, valueTailLength); 308ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 328ref Unsafe.Add(ref searchSpace, offset + highestSetBitIndex), 352byte ch2Val = Unsafe.Add(ref value, valueTailLength); 355ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 375ref Unsafe.Add(ref searchSpace, offset + highestSetBitIndex), 399byte ch2Val = Unsafe.Add(ref value, valueTailLength); 402ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 424ref Unsafe.Add(ref searchSpace, offset + highestSetBitIndex), 786differentBits |= (uint)Unsafe.AddByteOffset(ref first, offset) - (uint)Unsafe.AddByteOffset(ref second, offset); 804if (!Unsafe.AreSame(ref first, ref second)) 968if (Unsafe.AreSame(ref first, ref second)) 1013int result = Unsafe.AddByteOffset(ref first, offset).CompareTo(Unsafe.AddByteOffset(ref second, offset)); 1054int result = Unsafe.AddByteOffset(ref first, offset).CompareTo(Unsafe.AddByteOffset(ref second, offset)); 1091int result = Unsafe.AddByteOffset(ref first, offset).CompareTo(Unsafe.AddByteOffset(ref second, offset)); 1140int result = Unsafe.AddByteOffset(ref first, offset).CompareTo(Unsafe.AddByteOffset(ref second, offset)); 1171if (Unsafe.Add(ref first, 1) != Unsafe.Add(ref second, 1)) 1176if (i > 2 && Unsafe.Add(ref first, 2) != Unsafe.Add(ref second, 2)) 1185if (Unsafe.Add(ref first, i + 0) != Unsafe.Add(ref second, i + 0)) goto Found0; 1186if (Unsafe.Add(ref first, i + 1) != Unsafe.Add(ref second, i + 1)) goto Found1; 1187if (Unsafe.Add(ref first, i + 2) != Unsafe.Add(ref second, i + 2)) goto Found2; 1188if (Unsafe.Add(ref first, i + 3) != Unsafe.Add(ref second, i + 3)) goto Found3; 1254=> Unsafe.ReadUnaligned<ushort>(ref start); 1258=> Unsafe.ReadUnaligned<uint>(ref start); 1262=> Unsafe.ReadUnaligned<uint>(ref Unsafe.AddByteOffset(ref start, offset)); 1266=> Unsafe.ReadUnaligned<nuint>(ref start); 1270=> Unsafe.ReadUnaligned<nuint>(ref Unsafe.AddByteOffset(ref start, offset)); 1274=> Unsafe.ReadUnaligned<Vector128<byte>>(ref Unsafe.AddByteOffset(ref start, offset)); 1278=> Unsafe.ReadUnaligned<Vector256<byte>>(ref Unsafe.AddByteOffset(ref start, offset)); 1429long tempFirst = Unsafe.ReadUnaligned<long>(ref Unsafe.Add(ref buf, offset)); 1430long tempLast = Unsafe.ReadUnaligned<long>(ref Unsafe.Add(ref buf, lastOffset)); 1433Unsafe.WriteUnaligned(ref Unsafe.Add(ref buf, offset), BinaryPrimitives.ReverseEndianness(tempLast)); 1434Unsafe.WriteUnaligned(ref Unsafe.Add(ref buf, lastOffset), BinaryPrimitives.ReverseEndianness(tempFirst)); 1448int tempFirst = Unsafe.ReadUnaligned<int>(ref Unsafe.Add(ref buf, offset)); 1449int tempLast = Unsafe.ReadUnaligned<int>(ref Unsafe.Add(ref buf, lastOffset)); 1452Unsafe.WriteUnaligned(ref Unsafe.Add(ref buf, offset), BinaryPrimitives.ReverseEndianness(tempLast)); 1453Unsafe.WriteUnaligned(ref Unsafe.Add(ref buf, lastOffset), BinaryPrimitives.ReverseEndianness(tempFirst)); 1464ReverseInner(ref Unsafe.Add(ref buf, offset), (nuint)remainder);
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.ByteMemOps.cs (98)
40if ((nuint)Unsafe.ByteOffset(ref src, ref dest) < len || 41(nuint)Unsafe.ByteOffset(ref dest, ref src) < len) 46ref byte srcEnd = ref Unsafe.Add(ref src, len); 47ref byte destEnd = ref Unsafe.Add(ref dest, len); 58Unsafe.WriteUnaligned(ref dest, Unsafe.ReadUnaligned<Block16>(ref src)); 71Unsafe.WriteUnaligned(ref Unsafe.Add(ref dest, 16), Unsafe.ReadUnaligned<Block16>(ref Unsafe.Add(ref src, 16))); 84Unsafe.WriteUnaligned(ref Unsafe.Add(ref dest, 32), Unsafe.ReadUnaligned<Block16>(ref Unsafe.Add(ref src, 32))); 99Unsafe.WriteUnaligned(ref Unsafe.Add(ref destEnd, -16), Unsafe.ReadUnaligned<Block16>(ref Unsafe.Add(ref srcEnd, -16))); 117Unsafe.WriteUnaligned(ref dest, Unsafe.ReadUnaligned<long>(ref src)); 118Unsafe.WriteUnaligned(ref Unsafe.Add(ref destEnd, -8), Unsafe.ReadUnaligned<long>(ref Unsafe.Add(ref srcEnd, -8))); 132Unsafe.WriteUnaligned(ref dest, Unsafe.ReadUnaligned<int>(ref src)); 133Unsafe.WriteUnaligned(ref Unsafe.Add(ref destEnd, -4), Unsafe.ReadUnaligned<int>(ref Unsafe.Add(ref srcEnd, -4))); 144Unsafe.WriteUnaligned(ref Unsafe.Add(ref destEnd, -2), Unsafe.ReadUnaligned<short>(ref Unsafe.Add(ref srcEnd, -2))); 162nuint misalignedElements = 64 - Unsafe.OpportunisticMisalignment(ref dest, 64); 163Unsafe.WriteUnaligned(ref dest, Unsafe.ReadUnaligned<Block64>(ref src)); 164src = ref Unsafe.Add(ref src, misalignedElements); 165dest = ref Unsafe.Add(ref dest, misalignedElements); 177Unsafe.WriteUnaligned(ref dest, Unsafe.ReadUnaligned<Block64>(ref src)); 205dest = ref Unsafe.Add(ref dest, 64); 206src = ref Unsafe.Add(ref src, 64); 215Unsafe.WriteUnaligned(ref Unsafe.Add(ref destEnd, -16), Unsafe.ReadUnaligned<Block16>(ref Unsafe.Add(ref srcEnd, -16))); 230if (Unsafe.AreSame(ref dest, ref src)) 233_ = Unsafe.ReadUnaligned<byte>(ref dest); 240_ = Unsafe.ReadUnaligned<byte>(ref dest); 241_ = Unsafe.ReadUnaligned<byte>(ref src); 251ref byte destEnd = ref Unsafe.Add(ref dest, len); 262Unsafe.WriteUnaligned<Block16>(ref dest, default); 275Unsafe.WriteUnaligned<Block16>(ref Unsafe.Add(ref dest, 16), default); 288Unsafe.WriteUnaligned<Block16>(ref Unsafe.Add(ref dest, 32), default); 303Unsafe.WriteUnaligned<Block16>(ref Unsafe.Add(ref destEnd, -16), default); 321Unsafe.WriteUnaligned<long>(ref dest, 0); 322Unsafe.WriteUnaligned<long>(ref Unsafe.Add(ref destEnd, -8), 0); 336Unsafe.WriteUnaligned<int>(ref dest, 0); 337Unsafe.WriteUnaligned<int>(ref Unsafe.Add(ref destEnd, -4), 0); 348Unsafe.WriteUnaligned<short>(ref Unsafe.Add(ref destEnd, -2), 0); 363nuint misalignedElements = 64 - Unsafe.OpportunisticMisalignment(ref dest, 64); 364Unsafe.WriteUnaligned<Block64>(ref dest, default); 365dest = ref Unsafe.Add(ref dest, misalignedElements); 376Unsafe.WriteUnaligned<Block64>(ref dest, default); 404dest = ref Unsafe.Add(ref dest, 64); 413Unsafe.WriteUnaligned<Block16>(ref Unsafe.Add(ref destEnd, -16), default); 427_ = Unsafe.ReadUnaligned<byte>(ref dest); 452Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest, offset), vector); 453Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest, offset + (nuint)Vector<byte>.Count), vector); 465Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest, offset), vector); 474Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest, len - (nuint)Vector<byte>.Count), vector); 492Unsafe.Add(ref dest, (nint)i + 0) = value; 493Unsafe.Add(ref dest, (nint)i + 1) = value; 494Unsafe.Add(ref dest, (nint)i + 2) = value; 495Unsafe.Add(ref dest, (nint)i + 3) = value; 496Unsafe.Add(ref dest, (nint)i + 4) = value; 497Unsafe.Add(ref dest, (nint)i + 5) = value; 498Unsafe.Add(ref dest, (nint)i + 6) = value; 499Unsafe.Add(ref dest, (nint)i + 7) = value; 506Unsafe.Add(ref dest, (nint)i + 0) = value; 507Unsafe.Add(ref dest, (nint)i + 1) = value; 508Unsafe.Add(ref dest, (nint)i + 2) = value; 509Unsafe.Add(ref dest, (nint)i + 3) = value; 516Unsafe.Add(ref dest, (nint)i + 0) = value; 517Unsafe.Add(ref dest, (nint)i + 1) = value; 524Unsafe.Add(ref dest, (nint)i) = value;
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.Char.cs (75)
37ref byte valueTail = ref Unsafe.As<char, byte>(ref Unsafe.Add(ref value, 1)); 44int relativeIndex = NonPackedIndexOfChar(ref Unsafe.Add(ref searchSpace, offset), valueHead, remainingSearchSpaceLength); 56ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + 1)), 75ushort ch2Val = Unsafe.Add(ref value, valueTailLength); 78ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 122ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), 123ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) 142ushort ch2Val = Unsafe.Add(ref value, valueTailLength); 145ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 187ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), 188ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) 204ushort ch2Val = Unsafe.Add(ref value, valueTailLength); 207ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 249ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), 250ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) 274return LastIndexOfValueType(ref Unsafe.As<char, short>(ref searchSpace), (short)value, searchSpaceLength); // for single-char values use plain LastIndexOf 284ref byte valueTail = ref Unsafe.As<char, byte>(ref Unsafe.Add(ref value, 1)); 294int relativeIndex = LastIndexOfValueType(ref Unsafe.As<char, short>(ref searchSpace), (short)valueHead, remainingSearchSpaceLength); 300ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, relativeIndex + 1)), 319char ch2Val = Unsafe.Add(ref value, valueTailLength); 322ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 346ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), 347ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) 369char ch2Val = Unsafe.Add(ref value, valueTailLength); 372ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 396ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), 397ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) 419char ch2Val = Unsafe.Add(ref value, valueTailLength); 422ch2Val = Unsafe.Add(ref value, --ch1ch2Distance); 446ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, offset + charPos)), 447ref Unsafe.As<char, byte>(ref value), (nuint)(uint)valueLength * 2)) 472if (Unsafe.AreSame(ref first, ref second)) 485if (Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)i))) != 486Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)i)))) 497if (Unsafe.ReadUnaligned<nuint>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)i))) != 498Unsafe.ReadUnaligned<nuint>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)i)))) 509if (Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, (nint)i))) == 510Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref second, (nint)i)))) 519int result = Unsafe.Add(ref first, (nint)i).CompareTo(Unsafe.Add(ref second, (nint)i)); 899ref ushort first = ref Unsafe.As<char, ushort>(ref Unsafe.Add(ref buf, offset)); 900ref ushort last = ref Unsafe.As<char, ushort>(ref Unsafe.Add(ref buf, lastOffset)); 938ref byte first = ref Unsafe.As<char, byte>(ref Unsafe.Add(ref buf, offset)); 939ref byte last = ref Unsafe.As<char, byte>(ref Unsafe.Add(ref buf, lastOffset)); 977ref ushort first = ref Unsafe.As<char, ushort>(ref Unsafe.Add(ref buf, offset)); 978ref ushort last = ref Unsafe.As<char, ushort>(ref Unsafe.Add(ref buf, lastOffset)); 1008ReverseInner(ref Unsafe.Add(ref buf, offset), (nuint)remainder);
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.cs (37)
15Debug.Assert(Unsafe.IsOpportunisticallyAligned(ref ip, (uint)sizeof(IntPtr)), "Should've been aligned on natural word boundary."); 23Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -1) = default; 24Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -2) = default; 25Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -3) = default; 26Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -4) = default; 27Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -5) = default; 28Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -6) = default; 29Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -7) = default; 30Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -8) = default; 69Unsafe.Add(ref ip, 2) = default; 70Unsafe.Add(ref ip, 3) = default; 71Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -3) = default; 72Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -2) = default; 78Unsafe.Add(ref ip, 1) = default; 79Unsafe.Add(ref Unsafe.Add(ref ip, (nint)pointerSizeLength), -1) = default; 189ReverseInner(ref Unsafe.Add(ref buf, offset), (nuint)remainder); 294ReverseInner(ref Unsafe.Add(ref buf, offset), (nuint)remainder); 307Reverse(ref Unsafe.As<T, byte>(ref elements), length); 312Reverse(ref Unsafe.As<T, char>(ref elements), length); 317Reverse(ref Unsafe.As<T, int>(ref elements), length); 322Reverse(ref Unsafe.As<T, long>(ref elements), length); 336ref T last = ref Unsafe.Subtract(ref Unsafe.Add(ref first, length), 1); 342first = ref Unsafe.Add(ref first, 1); 343last = ref Unsafe.Subtract(ref last, 1); 344} while (Unsafe.IsAddressLessThan(ref first, ref last));
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.Packed.cs (111)
28return Unsafe.BitCast<T, ushort>(value) - 1u < 254u; 34IndexOf<SpanHelpers.DontNegate<short>, NopTransform>(ref Unsafe.As<char, short>(ref searchSpace), (short)value, length); 39IndexOf<SpanHelpers.Negate<short>, NopTransform>(ref Unsafe.As<char, short>(ref searchSpace), (short)value, length); 44IndexOfAny<SpanHelpers.DontNegate<short>, NopTransform>(ref Unsafe.As<char, short>(ref searchSpace), (short)value0, (short)value1, length); 49IndexOfAny<SpanHelpers.Negate<short>, NopTransform>(ref Unsafe.As<char, short>(ref searchSpace), (short)value0, (short)value1, length); 54IndexOfAny<SpanHelpers.DontNegate<short>>(ref Unsafe.As<char, short>(ref searchSpace), (short)value0, (short)value1, (short)value2, length); 59IndexOfAny<SpanHelpers.Negate<short>>(ref Unsafe.As<char, short>(ref searchSpace), (short)value0, (short)value1, (short)value2, length); 67return IndexOf<SpanHelpers.DontNegate<short>, Or20Transform>(ref Unsafe.As<char, short>(ref searchSpace), (short)value, length); 76return IndexOf<SpanHelpers.Negate<short>, Or20Transform>(ref Unsafe.As<char, short>(ref searchSpace), (short)value, length); 86return IndexOfAny<SpanHelpers.DontNegate<short>, Or20Transform>(ref Unsafe.As<char, short>(ref searchSpace), (short)value0, (short)value1, length); 96return IndexOfAny<SpanHelpers.Negate<short>, Or20Transform>(ref Unsafe.As<char, short>(ref searchSpace), (short)value0, (short)value1, length); 102IndexOfAnyInRange<SpanHelpers.DontNegate<short>>(ref Unsafe.As<char, short>(ref searchSpace), (short)lowInclusive, (short)rangeInclusive, length); 107IndexOfAnyInRange<SpanHelpers.Negate<short>>(ref Unsafe.As<char, short>(ref searchSpace), (short)lowInclusive, (short)rangeInclusive, length); 123Unsafe.Add(ref searchSpace, 1) == value || 124Unsafe.Add(ref searchSpace, 2) == value || 125Unsafe.Add(ref searchSpace, 3) == value) 137if (Unsafe.Add(ref searchSpace, offset) == value) 160ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector512<short>.Count)); 173currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector512<short>.Count); 175while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 181ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<short>.Count); 183ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 209ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector256<short>.Count)); 223currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector256<short>.Count); 225while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 231ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<short>.Count); 233ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 267ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector128<short>.Count)); 281currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector128<short>.Count); 283while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 289ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<short>.Count); 291ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 327if (TNegator.NegateIfNeeded(TTransform.TransformInput(Unsafe.Add(ref searchSpace, 1)) == value)) return 1; 328if (TNegator.NegateIfNeeded(TTransform.TransformInput(Unsafe.Add(ref searchSpace, 2)) == value)) return 2; 329if (TNegator.NegateIfNeeded(TTransform.TransformInput(Unsafe.Add(ref searchSpace, 3)) == value)) return 3; 338if (TNegator.NegateIfNeeded(TTransform.TransformInput(Unsafe.Add(ref searchSpace, offset)) == value)) return (int)offset; 359ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector512<short>.Count)); 372currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector512<short>.Count); 374while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 380ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<short>.Count); 382ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 408ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector256<short>.Count)); 423currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector256<short>.Count); 425while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 431ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<short>.Count); 433ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 468ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector128<short>.Count)); 483currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector128<short>.Count); 485while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 491ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<short>.Count); 493ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 533lookUp = TTransform.TransformInput(Unsafe.Add(ref searchSpace, 1)); 535lookUp = TTransform.TransformInput(Unsafe.Add(ref searchSpace, 2)); 537lookUp = TTransform.TransformInput(Unsafe.Add(ref searchSpace, 3)); 547lookUp = TTransform.TransformInput(Unsafe.Add(ref searchSpace, offset)); 569ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector512<short>.Count)); 583currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector512<short>.Count); 585while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 591ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<short>.Count); 593ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 621ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector256<short>.Count)); 636currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector256<short>.Count); 638while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 644ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<short>.Count); 646ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 682ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector128<short>.Count)); 697currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector128<short>.Count); 699while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 705ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<short>.Count); 707ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 747lookUp = Unsafe.Add(ref searchSpace, 1); 749lookUp = Unsafe.Add(ref searchSpace, 2); 751lookUp = Unsafe.Add(ref searchSpace, 3); 761lookUp = Unsafe.Add(ref searchSpace, offset); 785ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector512<short>.Count)); 799currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector512<short>.Count); 801while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 807ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<short>.Count); 809ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 838ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector256<short>.Count)); 853currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector256<short>.Count); 855while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 861ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<short>.Count); 863ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 900ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector128<short>.Count)); 915currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector128<short>.Count); 917while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 923ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<short>.Count); 925ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 960uint current = (uint)Unsafe.Add(ref searchSpace, i); 984ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector512<short>.Count)); 997currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector512<short>.Count); 999while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 1005ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<short>.Count); 1007ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 1034ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector256<short>.Count)); 1049currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector256<short>.Count); 1051while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 1057ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<short>.Count); 1059ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 1095ref short twoVectorsAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - (2 * Vector128<short>.Count)); 1110currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, 2 * Vector128<short>.Count); 1112while (Unsafe.IsAddressLessThan(ref currentSearchSpace, ref twoVectorsAwayFromEnd)); 1118ref short oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<short>.Count); 1120ref short firstVector = ref Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd) 1234return index + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / sizeof(short)); 1243return index + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / sizeof(short)); 1252return index + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / sizeof(short)); 1266return offsetInVector + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current0) / sizeof(short)); 1281return offsetInVector + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current0) / sizeof(short)); 1296return offsetInVector + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current0) / sizeof(short));
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.T.cs (419)
36vector = new Vector<byte>(Unsafe.BitCast<T, byte>(value)); 40vector = (Vector<byte>)new Vector<ushort>(Unsafe.BitCast<T, ushort>(value)); 46? (Vector<byte>)new Vector<float>(Unsafe.BitCast<T, float>(value)) 47: (Vector<byte>)new Vector<uint>(Unsafe.BitCast<T, uint>(value)); 53? (Vector<byte>)new Vector<double>(Unsafe.BitCast<T, double>(value)) 54: (Vector<byte>)new Vector<ulong>(Unsafe.BitCast<T, ulong>(value)); 58vector = Unsafe.BitCast<T, Vector<byte>>(value); 64vector = Vector256.Create(Unsafe.BitCast<T, Vector128<byte>>(value)).AsVector(); 68vector = Vector512.Create(Unsafe.BitCast<T, Vector128<byte>>(value)).AsVector(); 80vector = Vector512.Create(Unsafe.BitCast<T, Vector256<byte>>(value)).AsVector(); 94ref byte refDataAsBytes = ref Unsafe.As<T, byte>(ref refData); 107Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref refDataAsBytes, offset), vector); 108Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref refDataAsBytes, offset + (nuint)Vector<byte>.Count), vector); 121Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref refDataAsBytes, offset), vector); 131Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref refDataAsBytes, totalByteLength - (nuint)Vector<byte>.Count), vector); 152Unsafe.Add(ref refData, (nint)i + 0) = value; 153Unsafe.Add(ref refData, (nint)i + 1) = value; 154Unsafe.Add(ref refData, (nint)i + 2) = value; 155Unsafe.Add(ref refData, (nint)i + 3) = value; 156Unsafe.Add(ref refData, (nint)i + 4) = value; 157Unsafe.Add(ref refData, (nint)i + 5) = value; 158Unsafe.Add(ref refData, (nint)i + 6) = value; 159Unsafe.Add(ref refData, (nint)i + 7) = value; 167Unsafe.Add(ref refData, (nint)i + 0) = value; 168Unsafe.Add(ref refData, (nint)i + 1) = value; 169Unsafe.Add(ref refData, (nint)i + 2) = value; 170Unsafe.Add(ref refData, (nint)i + 3) = value; 178Unsafe.Add(ref refData, (nint)i + 0) = value; 179Unsafe.Add(ref refData, (nint)i + 1) = value; 187Unsafe.Add(ref refData, (nint)i) = value; 200ref T valueTail = ref Unsafe.Add(ref value, 1); 212int relativeIndex = IndexOf(ref Unsafe.Add(ref searchSpace, index), valueHead, remainingSearchSpaceLength); 218if (SequenceEqual(ref Unsafe.Add(ref searchSpace, index + 1), ref valueTail, valueTailLength)) 241if (value.Equals(Unsafe.Add(ref searchSpace, index + 0)) || 242value.Equals(Unsafe.Add(ref searchSpace, index + 1)) || 243value.Equals(Unsafe.Add(ref searchSpace, index + 2)) || 244value.Equals(Unsafe.Add(ref searchSpace, index + 3)) || 245value.Equals(Unsafe.Add(ref searchSpace, index + 4)) || 246value.Equals(Unsafe.Add(ref searchSpace, index + 5)) || 247value.Equals(Unsafe.Add(ref searchSpace, index + 6)) || 248value.Equals(Unsafe.Add(ref searchSpace, index + 7))) 260if (value.Equals(Unsafe.Add(ref searchSpace, index + 0)) || 261value.Equals(Unsafe.Add(ref searchSpace, index + 1)) || 262value.Equals(Unsafe.Add(ref searchSpace, index + 2)) || 263value.Equals(Unsafe.Add(ref searchSpace, index + 3))) 275if (value.Equals(Unsafe.Add(ref searchSpace, index))) 286if ((object?)Unsafe.Add(ref searchSpace, index) is null) 312if (value.Equals(Unsafe.Add(ref searchSpace, index))) 314if (value.Equals(Unsafe.Add(ref searchSpace, index + 1))) 316if (value.Equals(Unsafe.Add(ref searchSpace, index + 2))) 318if (value.Equals(Unsafe.Add(ref searchSpace, index + 3))) 320if (value.Equals(Unsafe.Add(ref searchSpace, index + 4))) 322if (value.Equals(Unsafe.Add(ref searchSpace, index + 5))) 324if (value.Equals(Unsafe.Add(ref searchSpace, index + 6))) 326if (value.Equals(Unsafe.Add(ref searchSpace, index + 7))) 336if (value.Equals(Unsafe.Add(ref searchSpace, index))) 338if (value.Equals(Unsafe.Add(ref searchSpace, index + 1))) 340if (value.Equals(Unsafe.Add(ref searchSpace, index + 2))) 342if (value.Equals(Unsafe.Add(ref searchSpace, index + 3))) 350if (value.Equals(Unsafe.Add(ref searchSpace, index))) 362if ((object?)Unsafe.Add(ref searchSpace, index) is null) 400lookUp = Unsafe.Add(ref searchSpace, index); 403lookUp = Unsafe.Add(ref searchSpace, index + 1); 406lookUp = Unsafe.Add(ref searchSpace, index + 2); 409lookUp = Unsafe.Add(ref searchSpace, index + 3); 412lookUp = Unsafe.Add(ref searchSpace, index + 4); 415lookUp = Unsafe.Add(ref searchSpace, index + 5); 418lookUp = Unsafe.Add(ref searchSpace, index + 6); 421lookUp = Unsafe.Add(ref searchSpace, index + 7); 430lookUp = Unsafe.Add(ref searchSpace, index); 433lookUp = Unsafe.Add(ref searchSpace, index + 1); 436lookUp = Unsafe.Add(ref searchSpace, index + 2); 439lookUp = Unsafe.Add(ref searchSpace, index + 3); 448lookUp = Unsafe.Add(ref searchSpace, index); 459lookUp = Unsafe.Add(ref searchSpace, index); 506lookUp = Unsafe.Add(ref searchSpace, index); 509lookUp = Unsafe.Add(ref searchSpace, index + 1); 512lookUp = Unsafe.Add(ref searchSpace, index + 2); 515lookUp = Unsafe.Add(ref searchSpace, index + 3); 518lookUp = Unsafe.Add(ref searchSpace, index + 4); 521lookUp = Unsafe.Add(ref searchSpace, index + 5); 524lookUp = Unsafe.Add(ref searchSpace, index + 6); 527lookUp = Unsafe.Add(ref searchSpace, index + 7); 536lookUp = Unsafe.Add(ref searchSpace, index); 539lookUp = Unsafe.Add(ref searchSpace, index + 1); 542lookUp = Unsafe.Add(ref searchSpace, index + 2); 545lookUp = Unsafe.Add(ref searchSpace, index + 3); 554lookUp = Unsafe.Add(ref searchSpace, index); 565lookUp = Unsafe.Add(ref searchSpace, index); 626T candidate = Unsafe.Add(ref searchSpace, i); 629if (Unsafe.Add(ref value, j)!.Equals(candidate)) 643T candidate = Unsafe.Add(ref searchSpace, i); 648if (candidate.Equals(Unsafe.Add(ref value, j))) 658if (Unsafe.Add(ref value, j) is null) 687ref T valueTail = ref Unsafe.Add(ref value, 1); 702if (SequenceEqual(ref Unsafe.Add(ref searchSpace, relativeIndex + 1), ref valueTail, valueTailLength)) 722if (value.Equals(Unsafe.Add(ref searchSpace, length + 7))) 724if (value.Equals(Unsafe.Add(ref searchSpace, length + 6))) 726if (value.Equals(Unsafe.Add(ref searchSpace, length + 5))) 728if (value.Equals(Unsafe.Add(ref searchSpace, length + 4))) 730if (value.Equals(Unsafe.Add(ref searchSpace, length + 3))) 732if (value.Equals(Unsafe.Add(ref searchSpace, length + 2))) 734if (value.Equals(Unsafe.Add(ref searchSpace, length + 1))) 736if (value.Equals(Unsafe.Add(ref searchSpace, length))) 744if (value.Equals(Unsafe.Add(ref searchSpace, length + 3))) 746if (value.Equals(Unsafe.Add(ref searchSpace, length + 2))) 748if (value.Equals(Unsafe.Add(ref searchSpace, length + 1))) 750if (value.Equals(Unsafe.Add(ref searchSpace, length))) 758if (value.Equals(Unsafe.Add(ref searchSpace, length))) 766if ((object?)Unsafe.Add(ref searchSpace, length) is null) 806lookUp = Unsafe.Add(ref searchSpace, length + 7); 809lookUp = Unsafe.Add(ref searchSpace, length + 6); 812lookUp = Unsafe.Add(ref searchSpace, length + 5); 815lookUp = Unsafe.Add(ref searchSpace, length + 4); 818lookUp = Unsafe.Add(ref searchSpace, length + 3); 821lookUp = Unsafe.Add(ref searchSpace, length + 2); 824lookUp = Unsafe.Add(ref searchSpace, length + 1); 827lookUp = Unsafe.Add(ref searchSpace, length); 836lookUp = Unsafe.Add(ref searchSpace, length + 3); 839lookUp = Unsafe.Add(ref searchSpace, length + 2); 842lookUp = Unsafe.Add(ref searchSpace, length + 1); 845lookUp = Unsafe.Add(ref searchSpace, length); 854lookUp = Unsafe.Add(ref searchSpace, length); 863lookUp = Unsafe.Add(ref searchSpace, length); 911lookUp = Unsafe.Add(ref searchSpace, length + 7); 914lookUp = Unsafe.Add(ref searchSpace, length + 6); 917lookUp = Unsafe.Add(ref searchSpace, length + 5); 920lookUp = Unsafe.Add(ref searchSpace, length + 4); 923lookUp = Unsafe.Add(ref searchSpace, length + 3); 926lookUp = Unsafe.Add(ref searchSpace, length + 2); 929lookUp = Unsafe.Add(ref searchSpace, length + 1); 932lookUp = Unsafe.Add(ref searchSpace, length); 941lookUp = Unsafe.Add(ref searchSpace, length + 3); 944lookUp = Unsafe.Add(ref searchSpace, length + 2); 947lookUp = Unsafe.Add(ref searchSpace, length + 1); 950lookUp = Unsafe.Add(ref searchSpace, length); 959lookUp = Unsafe.Add(ref searchSpace, length); 968lookUp = Unsafe.Add(ref searchSpace, length); 1018T candidate = Unsafe.Add(ref searchSpace, i); 1021if (Unsafe.Add(ref value, j)!.Equals(candidate)) 1032T candidate = Unsafe.Add(ref searchSpace, i); 1037if (candidate.Equals(Unsafe.Add(ref value, j))) 1047if (Unsafe.Add(ref value, j) is null) 1065if (!EqualityComparer<T>.Default.Equals(Unsafe.Add(ref searchSpace, i), value0)) 1080if (!EqualityComparer<T>.Default.Equals(Unsafe.Add(ref searchSpace, i), value0)) 1095ref T current = ref Unsafe.Add(ref searchSpace, i); 1111ref T current = ref Unsafe.Add(ref searchSpace, i); 1127ref T current = ref Unsafe.Add(ref searchSpace, i); 1145ref T current = ref Unsafe.Add(ref searchSpace, i); 1163ref T current = ref Unsafe.Add(ref searchSpace, i); 1182ref T current = ref Unsafe.Add(ref searchSpace, i); 1199if (Unsafe.AreSame(ref first, ref second)) 1209lookUp0 = Unsafe.Add(ref first, index); 1210lookUp1 = Unsafe.Add(ref second, index); 1213lookUp0 = Unsafe.Add(ref first, index + 1); 1214lookUp1 = Unsafe.Add(ref second, index + 1); 1217lookUp0 = Unsafe.Add(ref first, index + 2); 1218lookUp1 = Unsafe.Add(ref second, index + 2); 1221lookUp0 = Unsafe.Add(ref first, index + 3); 1222lookUp1 = Unsafe.Add(ref second, index + 3); 1225lookUp0 = Unsafe.Add(ref first, index + 4); 1226lookUp1 = Unsafe.Add(ref second, index + 4); 1229lookUp0 = Unsafe.Add(ref first, index + 5); 1230lookUp1 = Unsafe.Add(ref second, index + 5); 1233lookUp0 = Unsafe.Add(ref first, index + 6); 1234lookUp1 = Unsafe.Add(ref second, index + 6); 1237lookUp0 = Unsafe.Add(ref first, index + 7); 1238lookUp1 = Unsafe.Add(ref second, index + 7); 1249lookUp0 = Unsafe.Add(ref first, index); 1250lookUp1 = Unsafe.Add(ref second, index); 1253lookUp0 = Unsafe.Add(ref first, index + 1); 1254lookUp1 = Unsafe.Add(ref second, index + 1); 1257lookUp0 = Unsafe.Add(ref first, index + 2); 1258lookUp1 = Unsafe.Add(ref second, index + 2); 1261lookUp0 = Unsafe.Add(ref first, index + 3); 1262lookUp1 = Unsafe.Add(ref second, index + 3); 1271lookUp0 = Unsafe.Add(ref first, index); 1272lookUp1 = Unsafe.Add(ref second, index); 1297T lookUp = Unsafe.Add(ref second, i); 1298int result = (Unsafe.Add(ref first, i)?.CompareTo(lookUp) ?? (((object?)lookUp is null) ? 0 : -1)); 1310return PackedSpanHelpers.Contains(ref Unsafe.As<T, short>(ref searchSpace), Unsafe.BitCast<T, short>(value), length); 1329if (Unsafe.Add(ref searchSpace, offset) == value 1330|| Unsafe.Add(ref searchSpace, offset + 1) == value 1331|| Unsafe.Add(ref searchSpace, offset + 2) == value 1332|| Unsafe.Add(ref searchSpace, offset + 3) == value 1333|| Unsafe.Add(ref searchSpace, offset + 4) == value 1334|| Unsafe.Add(ref searchSpace, offset + 5) == value 1335|| Unsafe.Add(ref searchSpace, offset + 6) == value 1336|| Unsafe.Add(ref searchSpace, offset + 7) == value) 1348if (Unsafe.Add(ref searchSpace, offset) == value 1349|| Unsafe.Add(ref searchSpace, offset + 1) == value 1350|| Unsafe.Add(ref searchSpace, offset + 2) == value 1351|| Unsafe.Add(ref searchSpace, offset + 3) == value) 1363if (Unsafe.Add(ref searchSpace, offset) == value) return true; 1372ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector512<T>.Count)); 1384currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<T>.Count); 1386while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1403ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector256<T>.Count)); 1411currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<T>.Count); 1417while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1433ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector128<T>.Count)); 1441currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<T>.Count); 1447while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1465=> IndexOfValueType(ref Unsafe.As<char, short>(ref searchSpace), (short)value, length); 1469NonPackedIndexOfValueType<short, DontNegate<short>>(ref Unsafe.As<char, short>(ref searchSpace), (short)value, length); 1487? PackedSpanHelpers.IndexOf(ref Unsafe.As<TValue, char>(ref searchSpace), Unsafe.BitCast<TValue, char>(value), length) 1488: PackedSpanHelpers.IndexOfAnyExcept(ref Unsafe.As<TValue, char>(ref searchSpace), Unsafe.BitCast<TValue, char>(value), length); 1509if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 1510if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 1) == value)) goto Found1; 1511if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 2) == value)) goto Found2; 1512if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 3) == value)) goto Found3; 1513if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 4) == value)) goto Found4; 1514if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 5) == value)) goto Found5; 1515if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 6) == value)) goto Found6; 1516if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 7) == value)) goto Found7; 1525if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 1526if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 1) == value)) goto Found1; 1527if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 2) == value)) goto Found2; 1528if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 3) == value)) goto Found3; 1537if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 1563ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<TValue>.Count); 1575currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<TValue>.Count); 1577while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1594ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<TValue>.Count); 1602currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<TValue>.Count); 1608while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1624ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<TValue>.Count); 1632currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<TValue>.Count); 1638while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1656=> IndexOfAnyValueType(ref Unsafe.As<char, short>(ref searchSpace), (short)value0, (short)value1, length); 1673char char0 = Unsafe.BitCast<TValue, char>(value0); 1674char char1 = Unsafe.BitCast<TValue, char>(value1); 1686? PackedSpanHelpers.IndexOfAnyIgnoreCase(ref Unsafe.As<TValue, char>(ref searchSpace), lowerCase, length) 1687: PackedSpanHelpers.IndexOfAnyExceptIgnoreCase(ref Unsafe.As<TValue, char>(ref searchSpace), lowerCase, length); 1692? PackedSpanHelpers.IndexOfAny(ref Unsafe.As<TValue, char>(ref searchSpace), char0, char1, length) 1693: PackedSpanHelpers.IndexOfAnyExcept(ref Unsafe.As<TValue, char>(ref searchSpace), char0, char1, length); 1718ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 1721lookUp = Unsafe.Add(ref current, 1); 1723lookUp = Unsafe.Add(ref current, 2); 1725lookUp = Unsafe.Add(ref current, 3); 1727lookUp = Unsafe.Add(ref current, 4); 1729lookUp = Unsafe.Add(ref current, 5); 1731lookUp = Unsafe.Add(ref current, 6); 1733lookUp = Unsafe.Add(ref current, 7); 1744ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 1747lookUp = Unsafe.Add(ref current, 1); 1749lookUp = Unsafe.Add(ref current, 2); 1751lookUp = Unsafe.Add(ref current, 3); 1761lookUp = Unsafe.Add(ref searchSpace, offset); 1788ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<TValue>.Count); 1797currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<TValue>.Count); 1803while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1820ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<TValue>.Count); 1829currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<TValue>.Count); 1835while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1852ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<TValue>.Count); 1861currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<TValue>.Count); 1867while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1900? PackedSpanHelpers.IndexOfAny(ref Unsafe.As<TValue, char>(ref searchSpace), Unsafe.BitCast<TValue, char>(value0), Unsafe.BitCast<TValue, char>(value1), Unsafe.BitCast<TValue, char>(value2), length) 1901: PackedSpanHelpers.IndexOfAnyExcept(ref Unsafe.As<TValue, char>(ref searchSpace), Unsafe.BitCast<TValue, char>(value0), Unsafe.BitCast<TValue, char>(value1), Unsafe.BitCast<TValue, char>(value2), length); 1925ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 1928lookUp = Unsafe.Add(ref current, 1); 1930lookUp = Unsafe.Add(ref current, 2); 1932lookUp = Unsafe.Add(ref current, 3); 1934lookUp = Unsafe.Add(ref current, 4); 1936lookUp = Unsafe.Add(ref current, 5); 1938lookUp = Unsafe.Add(ref current, 6); 1940lookUp = Unsafe.Add(ref current, 7); 1951ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 1954lookUp = Unsafe.Add(ref current, 1); 1956lookUp = Unsafe.Add(ref current, 2); 1958lookUp = Unsafe.Add(ref current, 3); 1968lookUp = Unsafe.Add(ref searchSpace, offset); 1995ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<TValue>.Count); 2004currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<TValue>.Count); 2010while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2027ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<TValue>.Count); 2036currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<TValue>.Count); 2042while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2059ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<TValue>.Count); 2068currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<TValue>.Count); 2074while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2115ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2118lookUp = Unsafe.Add(ref current, 1); 2120lookUp = Unsafe.Add(ref current, 2); 2122lookUp = Unsafe.Add(ref current, 3); 2132lookUp = Unsafe.Add(ref searchSpace, offset); 2151ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<TValue>.Count); 2161currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<TValue>.Count); 2167while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2185ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<TValue>.Count); 2195currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<TValue>.Count); 2201while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2219ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<TValue>.Count); 2229currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<TValue>.Count); 2235while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2277ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2280lookUp = Unsafe.Add(ref current, 1); 2282lookUp = Unsafe.Add(ref current, 2); 2284lookUp = Unsafe.Add(ref current, 3); 2294lookUp = Unsafe.Add(ref searchSpace, offset); 2315ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector512<TValue>.Count)); 2325currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<TValue>.Count); 2331while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2350ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector256<TValue>.Count)); 2360currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<TValue>.Count); 2366while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2385ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector128<TValue>.Count)); 2395currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<TValue>.Count); 2401while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2442if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 2443if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 1) == value)) goto FoundM1; 2444if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 2) == value)) goto FoundM2; 2445if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 3) == value)) goto FoundM3; 2446if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 4) == value)) goto FoundM4; 2447if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 5) == value)) goto FoundM5; 2448if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 6) == value)) goto FoundM6; 2449if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 7) == value)) goto FoundM7; 2458if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 2459if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 1) == value)) goto FoundM1; 2460if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 2) == value)) goto FoundM2; 2461if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 3) == value)) goto FoundM3; 2470if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 2565ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2568lookUp = Unsafe.Add(ref current, -1); 2570lookUp = Unsafe.Add(ref current, -2); 2572lookUp = Unsafe.Add(ref current, -3); 2574lookUp = Unsafe.Add(ref current, -4); 2576lookUp = Unsafe.Add(ref current, -5); 2578lookUp = Unsafe.Add(ref current, -6); 2580lookUp = Unsafe.Add(ref current, -7); 2591ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2594lookUp = Unsafe.Add(ref current, -1); 2596lookUp = Unsafe.Add(ref current, -2); 2598lookUp = Unsafe.Add(ref current, -3); 2608lookUp = Unsafe.Add(ref searchSpace, offset); 2750ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2753lookUp = Unsafe.Add(ref current, -1); 2755lookUp = Unsafe.Add(ref current, -2); 2757lookUp = Unsafe.Add(ref current, -3); 2759lookUp = Unsafe.Add(ref current, -4); 2761lookUp = Unsafe.Add(ref current, -5); 2763lookUp = Unsafe.Add(ref current, -6); 2765lookUp = Unsafe.Add(ref current, -7); 2776ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2779lookUp = Unsafe.Add(ref current, -1); 2781lookUp = Unsafe.Add(ref current, -2); 2783lookUp = Unsafe.Add(ref current, -3); 2793lookUp = Unsafe.Add(ref searchSpace, offset); 2934ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2937lookUp = Unsafe.Add(ref current, -1); 2939lookUp = Unsafe.Add(ref current, -2); 2941lookUp = Unsafe.Add(ref current, -3); 2951lookUp = Unsafe.Add(ref searchSpace, offset); 3068T original = Unsafe.Add(ref src, idx); 3069Unsafe.Add(ref dst, idx) = oldValue.Equals(original) ? newValue : original; 3076T original = Unsafe.Add(ref src, idx); 3077Unsafe.Add(ref dst, idx) = original is null ? newValue : original; 3088T original = Unsafe.Add(ref src, idx); 3089Unsafe.Add(ref dst, idx) = EqualityComparer<T>.Default.Equals(original, oldValue) ? newValue : original; 3201ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 3204lookUp = Unsafe.Add(ref current, -1); 3206lookUp = Unsafe.Add(ref current, -2); 3208lookUp = Unsafe.Add(ref current, -3); 3218lookUp = Unsafe.Add(ref searchSpace, offset); 3330return index + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / (nuint)sizeof(T)); 3338return index + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / (nuint)sizeof(T)); 3346return index + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / (nuint)sizeof(T)); 3443ref T current = ref Unsafe.Add(ref searchSpace, i); 3458ref T current = ref Unsafe.Add(ref searchSpace, i); 3483ref char charSearchSpace = ref Unsafe.As<T, char>(ref searchSpace); 3484char charLowInclusive = Unsafe.BitCast<T, char>(lowInclusive); 3485char charRange = (char)(Unsafe.BitCast<T, char>(highInclusive) - charLowInclusive); 3506ref T current = ref Unsafe.Add(ref searchSpace, i); 3520ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector128<T>.Count)); 3531current = ref Unsafe.Add(ref current, Vector128<T>.Count); 3533while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)); 3549ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector256<T>.Count)); 3560current = ref Unsafe.Add(ref current, Vector256<T>.Count); 3562while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)); 3578ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector512<T>.Count)); 3589current = ref Unsafe.Add(ref current, Vector256<T>.Count); 3591while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)); 3609ref T current = ref Unsafe.Add(ref searchSpace, i); 3624ref T current = ref Unsafe.Add(ref searchSpace, i); 3653ref T current = ref Unsafe.Add(ref searchSpace, i); 3749ref T end = ref Unsafe.Add(ref current, length); 3752while (Unsafe.IsAddressLessThan(ref current, ref end)) 3759current = ref Unsafe.Add(ref current, 1); 3764while (Unsafe.IsAddressLessThan(ref current, ref end)) 3771current = ref Unsafe.Add(ref current, 1); 3781ref T end = ref Unsafe.Add(ref current, length); 3788ref T oneVectorAwayFromEnd = ref Unsafe.Subtract(ref end, Vector512<T>.Count); 3789while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)) 3792current = ref Unsafe.Add(ref current, Vector512<T>.Count); 3797mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)sizeof(T)); 3803ref T oneVectorAwayFromEnd = ref Unsafe.Subtract(ref end, Vector256<T>.Count); 3804while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)) 3807current = ref Unsafe.Add(ref current, Vector256<T>.Count); 3812mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)sizeof(T)); 3818ref T oneVectorAwayFromEnd = ref Unsafe.Subtract(ref end, Vector128<T>.Count); 3819while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)) 3822current = ref Unsafe.Add(ref current, Vector128<T>.Count); 3827mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)sizeof(T)); 3833while (Unsafe.IsAddressLessThan(ref current, ref end)) 3840current = ref Unsafe.Add(ref current, 1);
src\libraries\System.Private.CoreLib\src\System\String.Comparison.cs (16)
45ref Unsafe.Add(ref strA.GetRawStringData(), (nint)(uint)indexA /* force zero-extension */), countA, 46ref Unsafe.Add(ref strB.GetRawStringData(), (nint)(uint)indexB /* force zero-extension */), countB); 421return Ordinal.CompareStringIgnoreCase(ref Unsafe.Add(ref strA.GetRawStringData(), indexA), lengthA, ref Unsafe.Add(ref strB.GetRawStringData(), indexB), lengthB); 570Ordinal.EqualsIgnoreCase(ref Unsafe.Add(ref GetRawStringData(), Length - value.Length), 605return Unsafe.Add(ref _firstChar, (nint)localLength - 1) == value; 758return Marvin.ComputeHash32(ref Unsafe.As<char, byte>(ref _firstChar), (uint)_stringLength * 2 /* in bytes, not chars */, (uint)seed, (uint)(seed >> 32)); 779return Marvin.ComputeHash32(ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(value)), (uint)value.Length * 2 /* in bytes, not chars */, (uint)seed, (uint)(seed >> 32)); 877hash1 = BitOperations.RotateLeft(hash1, 5) + hash1 ^ Unsafe.ReadUnaligned<uint>(ptr); 878hash2 = BitOperations.RotateLeft(hash2, 5) + hash2 ^ Unsafe.ReadUnaligned<uint>(ptr + 1); 885hash1 = BitOperations.RotateLeft(hash1, 5) + hash1 ^ Unsafe.ReadUnaligned<uint>(ptr); 896hash2 = BitOperations.RotateLeft(hash2, 5) + hash2 ^ Unsafe.ReadUnaligned<uint>(ptr); 987p0 = Unsafe.ReadUnaligned<uint>(ptr); 988p1 = Unsafe.ReadUnaligned<uint>(ptr + 1); 1003p0 = Unsafe.ReadUnaligned<uint>(ptr); 1020p0 = Unsafe.ReadUnaligned<uint>(ptr);
src\libraries\System.Private.CoreLib\src\System\String.cs (9)
112source: ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(value), startIndex)); 386slice = new ReadOnlySpan<char>(ref Unsafe.Add(ref _firstChar, (nint)(uint)startIndex /* force zero-extension */), count); 427destination: ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(destination), destinationIndex), 428source: ref Unsafe.Add(ref _firstChar, sourceIndex), 497source: ref Unsafe.Add(ref _firstChar, startIndex), 528internal ref byte GetRawStringDataAsUInt8() => ref Unsafe.As<char, byte>(ref _firstChar); 529internal ref ushort GetRawStringDataAsUInt16() => ref Unsafe.As<char, ushort>(ref _firstChar); 573Unsafe.Add(ref result._firstChar, 1) = c2; 735return Unsafe.Add(ref _firstChar, (nint)(uint)index /* force zero-extension */);
src\libraries\System.Private.CoreLib\src\System\String.Manipulation.cs (25)
63destination: ref Unsafe.Add(ref dest._firstChar, destPos), 713Buffer.Memmove(ref Unsafe.Add(ref result._firstChar, startIndex), ref value._firstChar, (nuint)insertLength); 714Buffer.Memmove(ref Unsafe.Add(ref result._firstChar, startIndex + insertLength), ref Unsafe.Add(ref _firstChar, startIndex), (nuint)(oldLength - startIndex)); 927return JoinCore(separator, CollectionsMarshal.AsSpan(Unsafe.As<List<string?>>(values))); 950IEnumerator<char> en = Unsafe.As<IEnumerator<char>>(e); 1101ref char dest = ref Unsafe.Add(ref result._firstChar, copiedLength); 1138Buffer.Memmove(ref Unsafe.Add(ref result._firstChar, count), ref _firstChar, (nuint)oldLength); 1156new Span<char>(ref Unsafe.Add(ref result._firstChar, oldLength), count).Fill(paddingChar); 1177Buffer.Memmove(ref Unsafe.Add(ref result._firstChar, startIndex), ref Unsafe.Add(ref _firstChar, startIndex + count), (nuint)(newLength - startIndex)); 1293ref ushort pSrc = ref Unsafe.Add(ref GetRawStringDataAsUInt16(), (uint)copyLength); 1294ref ushort pDst = ref Unsafe.Add(ref result.GetRawStringDataAsUInt16(), (uint)copyLength); 1303pSrc = ref Unsafe.Subtract(ref pSrc, adjust); 1304pDst = ref Unsafe.Subtract(ref pDst, adjust); 1310pSrc = ref Unsafe.Subtract(ref pSrc, adjust); 1311pDst = ref Unsafe.Subtract(ref pDst, adjust); 1317pSrc = ref Unsafe.Subtract(ref pSrc, adjust); 1318pDst = ref Unsafe.Subtract(ref pDst, adjust); 1357int pos = PackedSpanHelpers.IndexOf(ref Unsafe.Add(ref _firstChar, i), c, Length - i); 1370int pos = SpanHelpers.NonPackedIndexOfChar(ref Unsafe.Add(ref _firstChar, i), c, Length - i); 1386int pos = SpanHelpers.IndexOf(ref Unsafe.Add(ref _firstChar, i), Length - i, ref oldValue._firstChar, oldValue.Length); 2018ref uint charMap = ref Unsafe.As<ProbabilisticMap, uint>(ref map); 2133char curr = Unsafe.Add(ref source, offset); 2289source: ref Unsafe.Add(ref _firstChar, (nint)(uint)startIndex /* force zero-extension */));
src\libraries\System.Private.CoreLib\src\System\String.Searching.cs (7)
37=> SpanHelpers.ContainsValueType(ref Unsafe.As<char, short>(ref _firstChar), (short)value, Length); 98int result = SpanHelpers.IndexOfChar(ref Unsafe.Add(ref _firstChar, startIndex), value, count); 138int result = new ReadOnlySpan<char>(ref Unsafe.Add(ref _firstChar, startIndex), count).IndexOfAny(anyOf); 270=> SpanHelpers.LastIndexOfValueType(ref Unsafe.As<char, short>(ref _firstChar), (short)value, Length); 295int result = SpanHelpers.LastIndexOfValueType(ref Unsafe.As<char, short>(ref Unsafe.Add(ref _firstChar, startSearchAt)), (short)value, count); 343int result = new ReadOnlySpan<char>(ref Unsafe.Add(ref _firstChar, startSearchAt), count).LastIndexOfAny(anyOf);
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.CaseConversion.cs (7)
318ulong nextBlockAsUInt64 = Unsafe.ReadUnaligned<ulong>(&pSrc[i]); 342Unsafe.WriteUnaligned(&pDest[i], nextBlockAsUInt64); 357Unsafe.WriteUnaligned(&pDest[i], narrowedBlock.ToScalar()); 377uint nextBlockAsUInt32 = Unsafe.ReadUnaligned<uint>(&pSrc[i]); 401Unsafe.WriteUnaligned(&pDest[i], nextBlockAsUInt32); 411Unsafe.WriteUnaligned(&pDest[i], widenedBlock.ToScalar()); 417Unsafe.WriteUnaligned(&pDest[i], narrowedBlock.ToScalar());
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.cs (36)
32IsValidCore(ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(value)), value.Length); 62Unsafe.ReadUnaligned<uint>(ref Unsafe.As<T, byte>(ref searchSpace)) | 63Unsafe.ReadUnaligned<uint>(ref Unsafe.As<T, byte>(ref Unsafe.Add(ref searchSpace, length - sizeof(uint))))); 70? (Unsafe.BitCast<T, byte>(Unsafe.Add(ref searchSpace, j)) > 127) 71: (Unsafe.BitCast<T, char>(Unsafe.Add(ref searchSpace, j)) > 127)) 90Unsafe.ReadUnaligned<ulong>(ref Unsafe.As<T, byte>(ref Unsafe.Add(ref searchSpace, i))) | 91Unsafe.ReadUnaligned<ulong>(ref Unsafe.As<T, byte>(ref Unsafe.Add(ref searchSpace, i + elementsPerUlong))))) 102Unsafe.ReadUnaligned<ulong>(ref Unsafe.As<T, byte>(ref Unsafe.Add(ref searchSpace, i))) | 103Unsafe.ReadUnaligned<ulong>(ref Unsafe.Subtract(ref Unsafe.As<T, byte>(ref Unsafe.Add(ref searchSpace, length)), sizeof(ulong)))); 106ref T searchSpaceEnd = ref Unsafe.Add(ref searchSpace, length); 113Vector128.LoadUnsafe(ref Unsafe.Subtract(ref searchSpaceEnd, Vector128<T>.Count))); 123Vector256.LoadUnsafe(ref Unsafe.Subtract(ref searchSpaceEnd, Vector256<T>.Count))); 144nuint misalignedElements = Unsafe.OpportunisticMisalignment(ref searchSpace, (uint)Vector256<byte>.Count) / (nuint)sizeof(T); 152ref T current = ref Unsafe.Add(ref searchSpace, i); 164searchSpace = ref Unsafe.Add(ref searchSpace, finalStart); 173Vector256.LoadUnsafe(ref Unsafe.Subtract(ref searchSpaceEnd, 2 * Vector256<T>.Count)) | 174Vector256.LoadUnsafe(ref Unsafe.Subtract(ref searchSpaceEnd, Vector256<T>.Count))); 196nuint misalignedElements = Unsafe.OpportunisticMisalignment(ref searchSpace, (uint)Vector128<byte>.Count) / (nuint)sizeof(T); 204ref T current = ref Unsafe.Add(ref searchSpace, i); 216searchSpace = ref Unsafe.Add(ref searchSpace, finalStart); 225Vector128.LoadUnsafe(ref Unsafe.Subtract(ref searchSpaceEnd, 2 * Vector128<T>.Count)) | 226Vector128.LoadUnsafe(ref Unsafe.Subtract(ref searchSpaceEnd, Vector128<T>.Count)));
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.Equality.cs (44)
31&& Equals<byte, ushort, WideningLoader>(ref MemoryMarshal.GetReference(left), ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(right)), (uint)right.Length); 40&& Equals<ushort, ushort, PlainLoader<ushort>>(ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(left)), ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(right)), (uint)right.Length); 56uint valueA = uint.CreateTruncating(Unsafe.Add(ref left, i)); 57uint valueB = uint.CreateTruncating(Unsafe.Add(ref right, i)); 73ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector512<TLeft>.Count); 83currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, Vector512<TLeft>.Count); 84currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, Vector512<TLeft>.Count); 86while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 91ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref left, length - (uint)Vector512<TLeft>.Count); 103ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector256<TLeft>.Count); 113currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, Vector256<TLeft>.Count); 114currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, Vector256<TLeft>.Count); 116while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 121ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref left, length - (uint)Vector256<TLeft>.Count); 128ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref currentLeftSearchSpace, length - TLoader.Count128); 130ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector128<TRight>.Count); 147currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, (uint)Vector128<TRight>.Count); 148currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, TLoader.Count128); 150while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 182&& EqualsIgnoreCase<byte, ushort, WideningLoader>(ref MemoryMarshal.GetReference(left), ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(right)), (uint)right.Length); 191&& EqualsIgnoreCase<ushort, ushort, PlainLoader<ushort>>(ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(left)), ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(right)), (uint)right.Length); 194EqualsIgnoreCase<ushort, ushort, PlainLoader<ushort>>(ref Unsafe.As<char, ushort>(ref left), ref Unsafe.As<char, ushort>(ref right), length); 210uint valueA = uint.CreateTruncating(Unsafe.Add(ref left, i)); 211uint valueB = uint.CreateTruncating(Unsafe.Add(ref right, i)); 238ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref currentLeftSearchSpace, length - TLoader.Count512); 240ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector512<TRight>.Count); 274currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, (uint)Vector512<TRight>.Count); 275currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, TLoader.Count512); 277while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 309ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref currentLeftSearchSpace, length - TLoader.Count256); 311ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector256<TRight>.Count); 346currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, (uint)Vector256<TRight>.Count); 347currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, TLoader.Count256); 349while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 381ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref currentLeftSearchSpace, length - TLoader.Count128); 383ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector128<TRight>.Count); 419currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, (uint)Vector128<TRight>.Count); 420currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, TLoader.Count128); 422while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 523Vector128<byte> vec = Vector128.CreateScalarUnsafe(Unsafe.ReadUnaligned<long>(ref ptr)).AsByte(); 528Vector128<byte> vec = Vector128.CreateScalarUnsafe(Unsafe.ReadUnaligned<long>(ref ptr)).AsByte();
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.Utility.cs (45)
266currentUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer); 267uint nextUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer + 4); 291currentUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer); 304currentUInt32 = Unsafe.ReadUnaligned<ushort>(pBuffer); 636ulong candidateUInt64 = Unsafe.ReadUnaligned<ulong>(pBuffer); 651currentDWord = Unsafe.ReadUnaligned<uint>(pBuffer); 652uint nextDWord = Unsafe.ReadUnaligned<uint>(pBuffer + 4); 676currentDWord = Unsafe.ReadUnaligned<uint>(pBuffer); 691currentDWord = Unsafe.ReadUnaligned<ushort>(pBuffer); 885currentUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer); 886uint nextUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer + 4 / sizeof(char)); 910currentUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer); 1192ulong candidateUInt64 = Unsafe.ReadUnaligned<ulong>(pBuffer); 1209currentDWord = Unsafe.ReadUnaligned<uint>(pBuffer); 1210uint nextDWord = Unsafe.ReadUnaligned<uint>(pBuffer + 4 / sizeof(char)); 1234currentDWord = Unsafe.ReadUnaligned<uint>(pBuffer); 1277Unsafe.WriteUnaligned(ref outputBuffer, Sse2.ConvertToUInt32(vecNarrow)); 1286Unsafe.WriteUnaligned(ref outputBuffer, lower.AsUInt32().ToScalar()); 1295Unsafe.Add(ref outputBuffer, 1) = (byte)value; 1297Unsafe.Add(ref outputBuffer, 2) = (byte)value; 1299Unsafe.Add(ref outputBuffer, 3) = (byte)value; 1303Unsafe.Add(ref outputBuffer, 3) = (byte)value; 1305Unsafe.Add(ref outputBuffer, 2) = (byte)value; 1307Unsafe.Add(ref outputBuffer, 1) = (byte)value; 1327Unsafe.Add(ref outputBuffer, 1) = (byte)(value >> 16); 1331Unsafe.Add(ref outputBuffer, 1) = (byte)value; 1358utf16Data64Bits = Unsafe.ReadUnaligned<ulong>(pUtf16Buffer); 1366utf16Data32BitsHigh = Unsafe.ReadUnaligned<uint>(pUtf16Buffer); 1367utf16Data32BitsLow = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + 4 / sizeof(char)); 1402utf16Data64Bits = Unsafe.ReadUnaligned<ulong>(pUtf16Buffer + currentOffset); 1412utf16Data32BitsHigh = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + currentOffset); 1413utf16Data32BitsLow = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + currentOffset + 4 / sizeof(char)); 1431utf16Data32BitsHigh = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + currentOffset); 2103asciiData = Unsafe.ReadUnaligned<uint>(pAsciiBuffer + currentOffset); 2118asciiData = Unsafe.ReadUnaligned<ushort>(pAsciiBuffer + currentOffset); 2282Unsafe.WriteUnaligned(ref Unsafe.As<char, byte>(ref outputBuffer), vecWide.ToScalar()); 2288Unsafe.WriteUnaligned(ref Unsafe.As<char, byte>(ref outputBuffer), vecWide.ToScalar()); 2297Unsafe.Add(ref outputBuffer, 1) = (char)(byte)value; 2299Unsafe.Add(ref outputBuffer, 2) = (char)(byte)value; 2301Unsafe.Add(ref outputBuffer, 3) = (char)value; 2305Unsafe.Add(ref outputBuffer, 3) = (char)(byte)value; 2307Unsafe.Add(ref outputBuffer, 2) = (char)(byte)value; 2309Unsafe.Add(ref outputBuffer, 1) = (char)(byte)value;
src\libraries\System.Private.CoreLib\src\System\Text\Encoding.Internal.cs (12)
272pChars: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(chars)), 365pChars: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(chars)), 549pChars: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(chars)), 551pBytes: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(bytes)), 652pChars: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(chars)), 654pBytes: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(bytes)), 872pBytes: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(bytes)), 961pBytes: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(bytes)), 1152pBytes: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(bytes)), 1154pChars: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(chars)), 1252pBytes: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(bytes)), 1254pChars: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(chars)),
src\libraries\System.Private.CoreLib\src\System\Text\Latin1Utility.cs (25)
52if (Vector.LessThanOrEqualAll(Unsafe.ReadUnaligned<Vector<ushort>>(pBuffer), maxLatin1)) 72if (Vector.GreaterThanAny(Unsafe.Read<Vector<ushort>>(pBuffer), maxLatin1)) 98currentUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer); 99uint nextUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer + 4 / sizeof(char)); 123currentUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer); 463ulong candidateUInt64 = Unsafe.ReadUnaligned<ulong>(pBuffer); 480currentDWord = Unsafe.ReadUnaligned<uint>(pBuffer); 481uint nextDWord = Unsafe.ReadUnaligned<uint>(pBuffer + 4 / sizeof(char)); 505currentDWord = Unsafe.ReadUnaligned<uint>(pBuffer); 560utf16Data64Bits = Unsafe.ReadUnaligned<ulong>(pUtf16Buffer); 568utf16Data32BitsHigh = Unsafe.ReadUnaligned<uint>(pUtf16Buffer); 569utf16Data32BitsLow = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + 4 / sizeof(char)); 592utf16Data64Bits = Unsafe.ReadUnaligned<ulong>(pUtf16Buffer); 600utf16Data32BitsHigh = Unsafe.ReadUnaligned<uint>(pUtf16Buffer); 601utf16Data32BitsLow = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + 4 / sizeof(char)); 613Vector<ushort> utf16VectorHigh = Unsafe.ReadUnaligned<Vector<ushort>>(pUtf16Buffer + currentOffset); 614Vector<ushort> utf16VectorLow = Unsafe.ReadUnaligned<Vector<ushort>>(pUtf16Buffer + currentOffset + Vector<ushort>.Count); 623Unsafe.WriteUnaligned(pLatin1Buffer + currentOffset, latin1Vector); 644utf16Data64Bits = Unsafe.ReadUnaligned<ulong>(pUtf16Buffer + currentOffset); 654utf16Data32BitsHigh = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + currentOffset); 655utf16Data32BitsLow = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + currentOffset + 4 / sizeof(char)); 673utf16Data32BitsHigh = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + currentOffset); 1087Vector<byte> latin1Vector = Unsafe.ReadUnaligned<Vector<byte>>(pLatin1Buffer + currentOffset); 1091Unsafe.WriteUnaligned(pUtf16Buffer + currentOffset, utf16LowVector); 1092Unsafe.WriteUnaligned(pUtf16Buffer + currentOffset + Vector<ushort>.Count, utf16HighVector);
src\libraries\System.Private.CoreLib\src\System\Text\Latin1Utility.Helpers.cs (9)
60Unsafe.WriteUnaligned(ref outputBuffer, Sse2.ConvertToUInt32(vecNarrow)); 68Unsafe.Add(ref outputBuffer, 1) = (byte)value; 70Unsafe.Add(ref outputBuffer, 2) = (byte)value; 72Unsafe.Add(ref outputBuffer, 3) = (byte)value; 76Unsafe.Add(ref outputBuffer, 3) = (byte)value; 78Unsafe.Add(ref outputBuffer, 2) = (byte)value; 80Unsafe.Add(ref outputBuffer, 1) = (byte)value; 100Unsafe.Add(ref outputBuffer, 1) = (byte)(value >> 16); 104Unsafe.Add(ref outputBuffer, 1) = (byte)value;
src\libraries\System.Private.CoreLib\src\System\Text\StringBuilder.cs (8)
340ref Unsafe.Add(ref result.GetRawStringData(), chunkOffset), 787Append(ref Unsafe.Add(ref value.GetRawStringData(), startIndex), count); 1238Debug.Assert(!Unsafe.IsNullRef(ref separator)); 2277ref char destination = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(chunkChars), chunkLength); 2283Unsafe.Add(ref destination, 1) = Unsafe.Add(ref value, 1); 2324new ReadOnlySpan<char>(ref Unsafe.Add(ref value, firstLength), restLength).CopyTo(m_ChunkChars); 2491value = ref Unsafe.Add(ref value, lengthToCopy);
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf16Utility.Validation.cs (1)
417thisChar = Unsafe.ReadUnaligned<uint>(pInputBuffer);
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8.cs (18)
63pInputBuffer: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)), 65pOutputBuffer: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)), 93destination = destination.Slice((int)(pOutputBufferRemaining - (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)))); 108source = source.Slice((int)(pInputBufferRemaining - (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source))) + 1); 111pInputBufferRemaining = (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)); 112pOutputBufferRemaining = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)); 154pInputBuffer: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)), 156pOutputBuffer: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)), 184destination = destination.Slice((int)(pOutputBufferRemaining - (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)))); 198source = source.Slice((int)(pInputBufferRemaining - (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)))); 205pInputBufferRemaining = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)); 206pOutputBufferRemaining = (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)); 249pInputBuffer: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)), 251pOutputBuffer: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)), 283source = source.Slice((int)(pInputBufferRemaining - (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)))); 284destination = destination.Slice((int)(pOutputBufferRemaining - (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)))); 305pInputBufferRemaining = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)); 306pOutputBufferRemaining = (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination));
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.cs (1)
33int index = (int)(void*)Unsafe.ByteOffset(ref *pUtf8Data, ref *pFirstInvalidByte);
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.Helpers.cs (12)
736Unsafe.WriteUnaligned(ref outputBuffer, tempA + tempB + 0xE080_80E0u); // = [ 1110ZZZZ 10xxxxxx 10yyyyyy 1110zzzz ] 737Unsafe.WriteUnaligned(ref Unsafe.Add(ref outputBuffer, 4), (ushort)(((value >> 22) & 0x3Fu) + ((value >> 8) & 0x3F00u) + 0x8080u)); // = [ 10XXXXXX 10YYYYYY ] 744Unsafe.Add(ref outputBuffer, 5) = (byte)((value & 0x3Fu) | 0x80u); 745Unsafe.Add(ref outputBuffer, 4) = (byte)(((value >>= 6) & 0x3Fu) | 0x80u); 746Unsafe.Add(ref outputBuffer, 3) = (byte)(((value >>= 6) & 0x0Fu) | 0xE0u); 747Unsafe.Add(ref outputBuffer, 2) = (byte)(((value >>= 4) & 0x3Fu) | 0x80u); 748Unsafe.Add(ref outputBuffer, 1) = (byte)(((value >>= 6) & 0x3Fu) | 0x80u); 770Unsafe.WriteUnaligned(ref outputBuffer, (ushort)(tempA + tempB + 0x80E0u)); // [ 10yyyyyy 1110zzzz ] 771Unsafe.Add(ref outputBuffer, 2) = (byte)((value & 0x3Fu) | ~0x7Fu); // [ 10xxxxxx ] 778Unsafe.Add(ref outputBuffer, 2) = (byte)(((value >>= 16) & 0x3Fu) | 0x80u); 779Unsafe.Add(ref outputBuffer, 1) = (byte)(((value >>= 6) & 0x3Fu) | 0x80u);
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.Transcoding.cs (36)
69uint thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 96uint remainingInputBytes = (uint)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *pFinalPosWhereCanReadDWordFromInputBuffer) + 4; 104thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 105secondDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer + sizeof(uint)); 245thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 289Unsafe.WriteUnaligned(pOutputBuffer, ExtractTwoCharsPackedFromTwoAdjacentTwoByteSequences(thisDWord)); 300thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 389thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 412thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 487if (outputCharsRemaining > 1 && (nint)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *pFinalPosWhereCanReadDWordFromInputBuffer) >= 3) 496uint secondDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer + 3); 552thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 629Unsafe.WriteUnaligned(pOutputBuffer, ExtractCharsFromFourByteSequence(thisDWord)); 640inputLength = (int)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *pFinalPosWhereCanReadDWordFromInputBuffer) + 4; 905thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 933Unsafe.WriteUnaligned(pOutputBuffer, (ushort)valueToWrite); 957Unsafe.SkipInit(out nonAsciiUtf16DataMask); 959utf16Data = Unsafe.ReadUnaligned<Vector128<short>>(pInputBuffer); 1000possibleNonAsciiQWord = Unsafe.ReadUnaligned<ulong>(pInputBuffer); 1015Unsafe.WriteUnaligned(pOutputBuffer, Sse2.ConvertToUInt32(Sse2.PackUnsignedSaturate(utf16Data, utf16Data).AsUInt32())); 1058Unsafe.WriteUnaligned(pOutputBuffer, Sse2.ConvertToUInt32(Sse2.PackUnsignedSaturate(utf16Data, utf16Data).AsUInt32())); 1079Unsafe.WriteUnaligned(pOutputBuffer, (ushort)(thisDWord | (thisDWord >> 8))); 1097thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1098secondDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer + 2); 1107Unsafe.WriteUnaligned(pOutputBuffer, (ushort)(thisDWord | (thisDWord >> 8))); 1108Unsafe.WriteUnaligned(pOutputBuffer + 2, (ushort)(secondDWord | (secondDWord >> 8))); 1128Unsafe.WriteUnaligned(pOutputBuffer, (ushort)(thisDWord | (thisDWord >> 8))); 1174thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1196Unsafe.WriteUnaligned(pOutputBuffer, ExtractTwoUtf8TwoByteSequencesFromTwoPackedUtf16Chars(thisDWord)); 1211thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1230Unsafe.WriteUnaligned(pOutputBuffer, (ushort)ExtractUtf8TwoByteSequenceFromFirstUtf16Char(thisDWord)); 1271thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1310thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1368thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1388thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1402Unsafe.WriteUnaligned(pOutputBuffer, ExtractFourUtf8BytesFromSurrogatePair(thisDWord));
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.Validation.cs (10)
74uint thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 98if ((nint)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *pFinalPosWhereCanReadDWordFromInputBuffer) >= 4 * sizeof(uint)) 104thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 200thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); // no longer guaranteed to be aligned 246thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 301thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 355thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 466ulong thisQWord = Unsafe.ReadUnaligned<ulong>(pInputBuffer); 566thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 661inputBufferRemainingBytes = (nuint)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *pFinalPosWhereCanReadDWordFromInputBuffer) + 4;
src\libraries\System.Private.CoreLib\src\System\Text\UnicodeEncoding.cs (2)
746Unsafe.WriteUnaligned(longBytes, *longChars); 1402Unsafe.WriteUnaligned(longChars, *longBytes);
src\libraries\System.Private.CoreLib\src\System\Threading\Interlocked.cs (67)
44(uint)Add(ref Unsafe.As<uint, int>(ref location), -1); 53(ulong)Add(ref Unsafe.As<ulong, long>(ref location), -1); 66(sbyte)Exchange(ref Unsafe.As<sbyte, byte>(ref location1), (byte)value); 76(short)Exchange(ref Unsafe.As<short, ushort>(ref location1), (ushort)value); 164(uint)Exchange(ref Unsafe.As<uint, int>(ref location1), (int)value); 175(ulong)Exchange(ref Unsafe.As<ulong, long>(ref location1), (long)value); 184=> Unsafe.BitCast<int, float>(Exchange(ref Unsafe.As<float, int>(ref location1), Unsafe.BitCast<float, int>(value))); 193=> Unsafe.BitCast<long, double>(Exchange(ref Unsafe.As<double, long>(ref location1), Unsafe.BitCast<double, long>(value))); 206return (IntPtr)Interlocked.Exchange(ref Unsafe.As<IntPtr, long>(ref location1), (long)value); 224return (UIntPtr)Interlocked.Exchange(ref Unsafe.As<UIntPtr, long>(ref location1), (long)value); 248object? result = Exchange(ref Unsafe.As<T, object?>(ref location1), value); 249return Unsafe.As<object?, T>(ref result); 261return Unsafe.BitCast<byte, T>( 263ref Unsafe.As<T, byte>(ref location1), 264Unsafe.BitCast<T, byte>(value))); 269return Unsafe.BitCast<ushort, T>( 271ref Unsafe.As<T, ushort>(ref location1), 272Unsafe.BitCast<T, ushort>(value))); 277return Unsafe.BitCast<int, T>( 279ref Unsafe.As<T, int>(ref location1), 280Unsafe.BitCast<T, int>(value))); 284return Unsafe.BitCast<long, T>( 286ref Unsafe.As<T, long>(ref location1), 287Unsafe.BitCast<T, long>(value))); 302(sbyte)CompareExchange(ref Unsafe.As<sbyte, byte>(ref location1), (byte)value, (byte)comparand); 313(short)CompareExchange(ref Unsafe.As<short, ushort>(ref location1), (ushort)value, (ushort)comparand); 410(uint)CompareExchange(ref Unsafe.As<uint, int>(ref location1), (int)value, (int)comparand); 422(ulong)CompareExchange(ref Unsafe.As<ulong, long>(ref location1), (long)value, (long)comparand); 432=> Unsafe.BitCast<int, float>(CompareExchange(ref Unsafe.As<float, int>(ref location1), Unsafe.BitCast<float, int>(value), Unsafe.BitCast<float, int>(comparand))); 442=> Unsafe.BitCast<long, double>(CompareExchange(ref Unsafe.As<double, long>(ref location1), Unsafe.BitCast<double, long>(value), Unsafe.BitCast<double, long>(comparand))); 456return (IntPtr)Interlocked.CompareExchange(ref Unsafe.As<IntPtr, long>(ref location1), (long)value, (long)comparand); 475return (UIntPtr)Interlocked.CompareExchange(ref Unsafe.As<UIntPtr, long>(ref location1), (long)value, (long)comparand); 500object? result = CompareExchange(ref Unsafe.As<T, object?>(ref location1), value, comparand); 501return Unsafe.As<object?, T>(ref result); 513return Unsafe.BitCast<byte, T>( 515ref Unsafe.As<T, byte>(ref location1), 516Unsafe.BitCast<T, byte>(value), 517Unsafe.BitCast<T, byte>(comparand))); 522return Unsafe.BitCast<ushort, T>( 524ref Unsafe.As<T, ushort>(ref location1), 525Unsafe.BitCast<T, ushort>(value), 526Unsafe.BitCast<T, ushort>(comparand))); 531return Unsafe.BitCast<int, T>( 533ref Unsafe.As<T, int>(ref location1), 534Unsafe.BitCast<T, int>(value), 535Unsafe.BitCast<T, int>(comparand))); 539return Unsafe.BitCast<long, T>( 541ref Unsafe.As<T, long>(ref location1), 542Unsafe.BitCast<T, long>(value), 543Unsafe.BitCast<T, long>(comparand))); 556(uint)Add(ref Unsafe.As<uint, int>(ref location1), (int)value); 566(ulong)Add(ref Unsafe.As<ulong, long>(ref location1), (long)value); 576CompareExchange(ref Unsafe.AsRef(in location), 0, 0); 610(uint)And(ref Unsafe.As<uint, int>(ref location1), (int)value); 642(ulong)And(ref Unsafe.As<ulong, long>(ref location1), (long)value); 676(uint)Or(ref Unsafe.As<uint, int>(ref location1), (int)value); 708(ulong)Or(ref Unsafe.As<ulong, long>(ref location1), (long)value);
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Task.cs (2)
2384Unsafe.As<Task>(obj).InnerInvoke(); 6725return WhenAnyCore((ReadOnlySpan<TTask>)CollectionsMarshal.AsSpan(Unsafe.As<List<TTask>>(tasks)));
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\ValueTask.cs (12)
179GetTaskForValueTaskSource(Unsafe.As<IValueTaskSource>(obj)); 313return Unsafe.As<IValueTaskSource>(obj).GetStatus(_token) != ValueTaskSourceStatus.Pending; 336return Unsafe.As<IValueTaskSource>(obj).GetStatus(_token) == ValueTaskSourceStatus.Succeeded; 358return Unsafe.As<IValueTaskSource>(obj).GetStatus(_token) == ValueTaskSourceStatus.Faulted; 385return Unsafe.As<IValueTaskSource>(obj).GetStatus(_token) == ValueTaskSourceStatus.Canceled; 404Unsafe.As<IValueTaskSource>(obj).GetResult(_token); 588return GetTaskForValueTaskSource(Unsafe.As<IValueTaskSource<TResult>>(obj)); 720return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) != ValueTaskSourceStatus.Pending; 743return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) == ValueTaskSourceStatus.Succeeded; 765return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) == ValueTaskSourceStatus.Faulted; 792return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) == ValueTaskSourceStatus.Canceled; 817return Unsafe.As<IValueTaskSource<TResult>>(obj).GetResult(_token);
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadBlockingInfo.cs (4)
72t_first = (ThreadBlockingInfo*)Unsafe.AsPointer(ref this); 111return ((Lock)Unsafe.AsRef<object>(_objectPtr)).OwningOSThreadId; 144return ((Lock)Unsafe.AsRef<object>(_objectPtr)).OwningManagedThreadId; 173_blockingInfo.Push(Unsafe.AsPointer(ref _object), objectKind, timeoutMs);
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadInt64PersistentCounter.cs (3)
32Unsafe.As<ThreadLocalNode>(threadLocalCountObject).Increment(); 39Unsafe.As<ThreadLocalNode>(threadLocalCountObject).Decrement(); 46Unsafe.As<ThreadLocalNode>(threadLocalCountObject).Add(count);
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolWorkQueue.cs (1)
1257Unsafe.As<IThreadPoolWorkItem>(workItem).Execute();
src\libraries\System.Private.CoreLib\src\System\Threading\Volatile.cs (43)
22Unsafe.As<bool, VolatileBoolean>(ref Unsafe.AsRef(in location)).Value; 27Unsafe.As<bool, VolatileBoolean>(ref location).Value = value; 36Unsafe.As<byte, VolatileByte>(ref Unsafe.AsRef(in location)).Value; 41Unsafe.As<byte, VolatileByte>(ref location).Value = value; 49long result = Read(ref Unsafe.As<double, long>(ref Unsafe.AsRef(in location))); 56Write(ref Unsafe.As<double, long>(ref location), BitConverter.DoubleToInt64Bits(value)); 65Unsafe.As<short, VolatileInt16>(ref Unsafe.AsRef(in location)).Value; 70Unsafe.As<short, VolatileInt16>(ref location).Value = value; 79Unsafe.As<int, VolatileInt32>(ref Unsafe.AsRef(in location)).Value; 84Unsafe.As<int, VolatileInt32>(ref location).Value = value; 92(long)Unsafe.As<long, VolatileIntPtr>(ref Unsafe.AsRef(in location)).Value; 102Unsafe.As<long, VolatileIntPtr>(ref location).Value = (nint)value; 115Unsafe.As<IntPtr, VolatileIntPtr>(ref Unsafe.AsRef(in location)).Value; 120Unsafe.As<IntPtr, VolatileIntPtr>(ref location).Value = value; 130Unsafe.As<sbyte, VolatileSByte>(ref Unsafe.AsRef(in location)).Value; 136Unsafe.As<sbyte, VolatileSByte>(ref location).Value = value; 145Unsafe.As<float, VolatileSingle>(ref Unsafe.AsRef(in location)).Value; 150Unsafe.As<float, VolatileSingle>(ref location).Value = value; 160Unsafe.As<ushort, VolatileUInt16>(ref Unsafe.AsRef(in location)).Value; 166Unsafe.As<ushort, VolatileUInt16>(ref location).Value = value; 176Unsafe.As<uint, VolatileUInt32>(ref Unsafe.AsRef(in location)).Value; 182Unsafe.As<uint, VolatileUInt32>(ref location).Value = value; 190(ulong)Read(ref Unsafe.As<ulong, long>(ref Unsafe.AsRef(in location))); 196Write(ref Unsafe.As<ulong, long>(ref location), (long)value); 206Unsafe.As<UIntPtr, VolatileUIntPtr>(ref Unsafe.AsRef(in location)).Value; 212Unsafe.As<UIntPtr, VolatileUIntPtr>(ref location).Value = value; 222Unsafe.As<T>(Unsafe.As<T, VolatileObject>(ref Unsafe.AsRef(in location)).Value); 227Unsafe.As<T, VolatileObject>(ref location).Value = value;
src\libraries\System.Private.CoreLib\src\System\TypedReference.cs (2)
26ref byte targetRef = ref Unsafe.NullRef<byte>(); 78internal bool IsNull => Unsafe.IsNullRef(ref _value) && _type == IntPtr.Zero;
src\libraries\System.Private.CoreLib\src\System\UInt128.cs (13)
851sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - Size); 854result = Unsafe.ReadUnaligned<UInt128>(ref sourceRef); 870result |= Unsafe.Add(ref sourceRef, i); 909result = Unsafe.ReadUnaligned<UInt128>(ref sourceRef); 926UInt128 part = Unsafe.Add(ref sourceRef, i); 1144Unsafe.WriteUnaligned(ref *(byte*)(pLeft + 0), (uint)(quotient._lower >> 00)); 1145Unsafe.WriteUnaligned(ref *(byte*)(pLeft + 1), (uint)(quotient._lower >> 32)); 1147Unsafe.WriteUnaligned(ref *(byte*)(pLeft + 2), (uint)(quotient._upper >> 00)); 1148Unsafe.WriteUnaligned(ref *(byte*)(pLeft + 3), (uint)(quotient._upper >> 32)); 1156Unsafe.WriteUnaligned(ref *(byte*)(pRight + 0), (uint)(divisor._lower >> 00)); 1157Unsafe.WriteUnaligned(ref *(byte*)(pRight + 1), (uint)(divisor._lower >> 32)); 1159Unsafe.WriteUnaligned(ref *(byte*)(pRight + 2), (uint)(divisor._upper >> 00)); 1160Unsafe.WriteUnaligned(ref *(byte*)(pRight + 3), (uint)(divisor._upper >> 32));
src\libraries\System.Private.CoreLib\src\System\UInt16.cs (3)
322sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(ushort)); 325result = Unsafe.ReadUnaligned<ushort>(ref sourceRef); 373result = Unsafe.ReadUnaligned<ushort>(ref sourceRef);
src\libraries\System.Private.CoreLib\src\System\UInt32.cs (5)
343sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(uint)); 346result = Unsafe.ReadUnaligned<uint>(ref sourceRef); 362result |= Unsafe.Add(ref sourceRef, i); 401result = Unsafe.ReadUnaligned<uint>(ref sourceRef); 418uint part = Unsafe.Add(ref sourceRef, i);
src\libraries\System.Private.CoreLib\src\System\UInt64.cs (5)
342sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(ulong)); 345result = Unsafe.ReadUnaligned<ulong>(ref sourceRef); 361result |= Unsafe.Add(ref sourceRef, i); 400result = Unsafe.ReadUnaligned<ulong>(ref sourceRef); 417ulong part = Unsafe.Add(ref sourceRef, i);
src\libraries\System.Private.CoreLib\src\System\UIntPtr.cs (23)
223Unsafe.SkipInit(out result); 224return nuint_t.TryParse(s, out Unsafe.As<nuint, nuint_t>(ref result)); 234Unsafe.SkipInit(out result); 235return nuint_t.TryParse(s, provider, out Unsafe.As<nuint, nuint_t>(ref result)); 240Unsafe.SkipInit(out result); 241return nuint_t.TryParse(s, style, provider, out Unsafe.As<nuint, nuint_t>(ref result)); 246Unsafe.SkipInit(out result); 247return nuint_t.TryParse(s, out Unsafe.As<nuint, nuint_t>(ref result)); 256Unsafe.SkipInit(out result); 257return nuint_t.TryParse(utf8Text, out Unsafe.As<nuint, nuint_t>(ref result)); 263Unsafe.SkipInit(out result); 264return nuint_t.TryParse(s, provider, out Unsafe.As<nuint, nuint_t>(ref result)); 269Unsafe.SkipInit(out result); 270return nuint_t.TryParse(s, style, provider, out Unsafe.As<nuint, nuint_t>(ref result)); 346sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(nuint_t)); 349result = Unsafe.ReadUnaligned<nuint>(ref sourceRef); 365result |= Unsafe.Add(ref sourceRef, i); 404result = Unsafe.ReadUnaligned<nuint>(ref sourceRef); 421nuint part = Unsafe.Add(ref sourceRef, i); 1216Unsafe.SkipInit(out result); 1217return nuint_t.TryParse(utf8Text, style, provider, out Unsafe.As<nuint, nuint_t>(ref result)); 1226Unsafe.SkipInit(out result); 1227return nuint_t.TryParse(utf8Text, provider, out Unsafe.As<nuint, nuint_t>(ref result));
src\libraries\System.Private.CoreLib\src\System\Version.cs (2)
252((uint)value).TryFormat(Unsafe.BitCast<Span<TChar>, Span<char>>(destination), out valueCharsWritten) : 253((uint)value).TryFormat(Unsafe.BitCast<Span<TChar>, Span<byte>>(destination), out valueCharsWritten, default, CultureInfo.InvariantCulture);
src\libraries\System.Private.CoreLib\src\System\WeakReference.T.cs (2)
144target = Unsafe.As<T?>(ComAwareWeakReference.GetTarget(th)); 155target = Unsafe.As<T?>(GCHandle.InternalGetBridgeWait(th));
src\System\Array.CoreCLR.cs (20)
165ref byte offsetDataRef = ref Unsafe.Add(ref arrayDataRef, flattenedIndex * pMethodTable->ComponentSize); 173ref object elementRef = ref Unsafe.As<byte, object>(ref arrayDataRef); 174ref object offsetElementRef = ref Unsafe.Add(ref elementRef, (nuint)flattenedIndex); 207ref byte offsetDataRef = ref Unsafe.Add(ref arrayDataRef, flattenedIndex * pMethodTable->ComponentSize); 211SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, nint>(ref offsetDataRef), elementSize / (nuint)sizeof(IntPtr)); 221Unsafe.Add(ref Unsafe.As<byte, object?>(ref arrayDataRef), (nuint)flattenedIndex) = null; 230Unsafe.Add(ref Unsafe.As<byte, object?>(ref arrayDataRef), (nuint)flattenedIndex) = value; 236ref byte offsetDataRef = ref Unsafe.Add(ref arrayDataRef, flattenedIndex * pMethodTable->ComponentSize); 288public int Length => checked((int)Unsafe.As<RawArrayData>(this).Length); 291internal nuint NativeLength => Unsafe.As<RawArrayData>(this).Length; 344arrayRef = ref Unsafe.Add(ref arrayRef, elementSize); 404T[] @this = Unsafe.As<T[]>(this); 414T[] @this = Unsafe.As<T[]>(this); 422T[] @this = Unsafe.As<T[]>(this); 430T[] @this = Unsafe.As<T[]>(this); 443T[] @this = Unsafe.As<T[]>(this); 462T[] @this = Unsafe.As<T[]>(this); 483T[] @this = Unsafe.As<T[]>(this);
src\System\Buffer.CoreCLR.cs (1)
34Memmove(ref *(pDest + (uint)destIndex), ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(src), (nint)(uint)srcIndex /* force zero-extension */), (uint)len);
src\System\Delegate.CoreCLR.cs (1)
438return Unsafe.As<MulticastDelegate>(RuntimeTypeHandle.InternalAlloc(type));
src\System\Enum.CoreCLR.cs (1)
129=> ref Unsafe.As<RuntimeType.IGenericCacheEntry?, EnumInfo<TStorage>?>(ref compositeEntry._enumInfo);
src\System\GC.CoreCLR.cs (1)
885ref GCConfigurationContext context = ref Unsafe.As<byte, GCConfigurationContext>(ref *(byte*)configurationContext);
src\System\MulticastDelegate.CoreCLR.cs (2)
57MulticastDelegate d = Unsafe.As<MulticastDelegate>(obj); 170MulticastDelegate result = Unsafe.As<MulticastDelegate>(RuntimeTypeHandle.InternalAllocNoChecks(RuntimeHelpers.GetMethodTable(this)));
src\System\Reflection\RuntimeCustomAttributeData.cs (1)
1540int data = Unsafe.ReadUnaligned<int>((void*)blobStart);
src\System\Reflection\TypeNameResolver.CoreCLR.cs (1)
187assembly = RuntimeAssembly.InternalLoad(assemblyName, ref Unsafe.NullRef<StackCrawlMark>(),
src\System\Runtime\CompilerServices\AsyncHelpers.CoreCLR.cs (8)
238finalContinuation.Data = new byte[Unsafe.SizeOf<T>()]; 255return Unsafe.As<byte, T>(ref finalResult.GCData![0]!.GetRawData()); 258return Unsafe.As<object, T>(ref finalResult.GCData![0]!); 262return Unsafe.As<byte, T>(ref finalResult.Data![0]); 304finalContinuation.Data = new byte[Unsafe.SizeOf<T>()]; 321return Unsafe.As<byte, T>(ref finalResult.GCData![0]!.GetRawData()); 324return Unsafe.As<object, T>(ref finalResult.GCData![0]!); 328return Unsafe.As<byte, T>(ref finalResult.Data![0]);
src\System\Runtime\CompilerServices\CastHelpers.cs (7)
430ref object? element = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index); 447ref object? element = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index); 539ref byte srcValue = ref Unsafe.Add(ref nullableData, srcMT->NullableValueAddrOffset); 552_ = Unsafe.ReadUnaligned<byte>(ref unboxedData); 639SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref destPtr), typeMT->GetNumInstanceFieldBytesIfContainsGCPointers() / (nuint)sizeof(IntPtr)); 650Unsafe.As<byte, bool>(ref destPtr) = true; 651ref byte dst = ref Unsafe.Add(ref destPtr, typeMT->NullableValueAddrOffset);
src\System\Runtime\CompilerServices\RuntimeHelpers.CoreCLR.cs (19)
68new ReadOnlySpan<ushort>(ref Unsafe.As<byte, ushort>(ref src), array.Length), 69new Span<ushort>(ref Unsafe.As<byte, ushort>(ref dst), array.Length)); 73new ReadOnlySpan<uint>(ref Unsafe.As<byte, uint>(ref src), array.Length), 74new Span<uint>(ref Unsafe.As<byte, uint>(ref dst), array.Length)); 78new ReadOnlySpan<ulong>(ref Unsafe.As<byte, ulong>(ref src), array.Length), 79new Span<ulong>(ref Unsafe.As<byte, ulong>(ref dst), array.Length)); 391ref Unsafe.As<RawData>(obj).Data; 401rawSize += (uint)Unsafe.As<RawArrayData>(obj).Length * (nuint)pMT->ComponentSize; 422return ref Unsafe.As<byte, int>(ref Unsafe.As<RawArrayData>(array).Data); 576/// This API returns the same value as <see cref="Unsafe.SizeOf{T}"/> for the type that <paramref name="type"/> represents. 631private MethodDescChunk* GetMethodDescChunk() => (MethodDescChunk*)(((byte*)Unsafe.AsPointer<MethodDesc>(ref this)) - (sizeof(MethodDescChunk) + ChunkIndex * sizeof(IntPtr))); 962return *(RuntimeType*)Unsafe.AsPointer(ref _exposedClassObject); 984return ref Unsafe.AsRef<byte>((byte*)((nuint)p & ~(nuint)DynamicStaticsInfo.ISCLASSNOTINITED)); 1061return *(RuntimeType*)Unsafe.AsPointer(ref ExposedClassObjectRaw); 1074return ref Unsafe.Subtract(ref Unsafe.As<MethodTableAuxiliaryData, DynamicStaticsInfo>(ref this), 1); 1082return ref Unsafe.Subtract(ref Unsafe.As<MethodTableAuxiliaryData, ThreadStaticsInfo>(ref this), 1);
src\System\Runtime\CompilerServices\StaticsHelpers.cs (12)
35if ((((nuint)Unsafe.AsPointer(ref nonGCStaticBase)) & DynamicStaticsInfo.ISCLASSNOTINITED) != 0) 46if ((((nuint)Unsafe.AsPointer(ref nonGCStaticBase)) & DynamicStaticsInfo.ISCLASSNOTINITED) != 0) 65if ((((nuint)Unsafe.AsPointer(ref gcStaticBase)) & DynamicStaticsInfo.ISCLASSNOTINITED) != 0) 76if ((((nuint)Unsafe.AsPointer(ref gcStaticBase)) & DynamicStaticsInfo.ISCLASSNOTINITED) != 0) 91return ref Unsafe.Subtract(ref RuntimeHelpers.GetRawData(obj), sizeof(MethodTable*)); 108return Unsafe.As<IntPtr, object[]>(ref _nonCollectibleTlsArrayData_private); 183object? threadStaticObjectNonCollectible = Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(t_ThreadStatics->NonCollectibleTlsArrayData), indexOffset - ThreadLocalData.NUMBER_OF_TLSOFFSETS_NOT_USED_IN_NONCOLLECTIBLE_ARRAY); 192return ref Unsafe.Add(ref Unsafe.AsRef<byte>(t_ThreadStatics), indexOffset); 283return ref Unsafe.Add(ref pArgs->staticBaseHelper(pArgs->arg0), pArgs->offset); 289object boxedObject = Unsafe.As<byte, object>(ref Unsafe.Add(ref pArgs->staticBaseHelper(pArgs->arg0), pArgs->offset));
src\System\Runtime\InteropServices\Marshal.CoreCLR.cs (5)
263structMarshalStub(ref structure.GetRawData(), (byte*)ptr, MarshalOperation.Cleanup, ref Unsafe.NullRef<CleanupWorkListElement?>()); 266structMarshalStub(ref structure.GetRawData(), (byte*)ptr, MarshalOperation.Marshal, ref Unsafe.NullRef<CleanupWorkListElement?>()); 291structMarshalStub(ref structure.GetRawData(), (byte*)ptr, MarshalOperation.Unmarshal, ref Unsafe.NullRef<CleanupWorkListElement?>()); 325structMarshalStub(ref Unsafe.NullRef<byte>(), (byte*)ptr, MarshalOperation.Cleanup, ref Unsafe.NullRef<CleanupWorkListElement?>());
src\System\Runtime\InteropServices\MemoryMarshal.CoreCLR.cs (2)
44return ref Unsafe.AddByteOffset(ref Unsafe.As<RawData>(array).Data, (nuint)RuntimeHelpers.GetMethodTable(array)->BaseSize - (nuint)(2 * sizeof(IntPtr)));
src\System\RuntimeHandles.cs (3)
1556Debug.Assert(!Unsafe.IsNullRef(ref fieldDataRef.Get())); 1563Debug.Assert(!Unsafe.IsNullRef(ref target)); 1565return ref Unsafe.AddByteOffset(ref target, offset);
src\System\RuntimeType.BoxCache.cs (3)
72return Unsafe.As<byte, object>(ref data); 77byte maybeNullableHasValue = Unsafe.ReadUnaligned<byte>(ref source); 85source = ref Unsafe.Add(ref source, _nullableValueOffset);
src\System\RuntimeType.CoreCLR.cs (2)
2424return Unsafe.As<RuntimeTypeCache>(cache); 2441return Unsafe.As<RuntimeTypeCache>(cache);
src\System\StubHelpers.cs (3)
510if (Unsafe.IsNullRef(ref cleanupWorkList)) 1541structMarshalStub(ref obj.GetRawData(), pNative, MarshalOperation.Unmarshal, ref Unsafe.NullRef<CleanupWorkListElement?>()); 1560structMarshalStub(ref obj.GetRawData(), pNative, MarshalOperation.Cleanup, ref Unsafe.NullRef<CleanupWorkListElement?>());
src\System\Threading\Interlocked.CoreCLR.cs (3)
97if (Unsafe.IsNullRef(ref location1)) 163if (Unsafe.IsNullRef(ref location1)) 228CompareExchange(ref Unsafe.AsRef(in location), 0, 0);
src\System\Threading\Thread.CoreCLR.cs (1)
456return (StaticsHelpers.ThreadLocalData*)(((byte*)Unsafe.AsPointer(ref DirectOnThreadLocalData.pNativeThread)) - sizeof(StaticsHelpers.ThreadLocalData));
src\System\TypedReference.CoreCLR.cs (1)
69result = Unsafe.As<byte, object>(ref value._value);
src\System\ValueType.cs (8)
126hashCode.Add(Unsafe.As<byte, object>(ref Unsafe.AddByteOffset(ref rawData, fieldOffset)).GetHashCode()); 130hashCode.Add(Unsafe.As<byte, double>(ref Unsafe.AddByteOffset(ref rawData, fieldOffset)).GetHashCode()); 134hashCode.Add(Unsafe.As<byte, float>(ref Unsafe.AddByteOffset(ref rawData, fieldOffset)).GetHashCode()); 139hashCode.AddBytes(MemoryMarshal.CreateReadOnlySpan(ref Unsafe.AddByteOffset(ref rawData, fieldOffset), (int)fieldSize)); 145hashCode.Add(RuntimeHelpers.Box(fieldMT, ref Unsafe.AddByteOffset(ref rawData, fieldOffset))?.GetHashCode() ?? 0);
System.Private.DataContractSerialization (5)
System\Xml\XmlBinaryWriter.cs (5)
110ref byte bytePtr = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(buffer), offset); 113Unsafe.WriteUnaligned<T>(ref Unsafe.Add(ref bytePtr, 1), value); 125ref byte bytePtr = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(buffer), offset); 126Unsafe.WriteUnaligned<T>(ref bytePtr, value);
System.Private.Uri (4)
System\Uri.cs (1)
208Interlocked.Or(ref Unsafe.As<Flags, ulong>(ref _flags), (ulong)flags);
System\UriExt.cs (1)
647!Unsafe.AreSame(ref MemoryMarshal.GetReference(charsToUnescape), ref MemoryMarshal.GetReference(destination));
System\UriScheme.cs (1)
80ulong previous = Interlocked.Or(ref Unsafe.As<Uri.Flags, ulong>(ref uri._flags), (ulong)Uri.Flags.CustomParser_ParseMinimalAlreadyCalled);
System\UriSyntax.cs (1)
272Interlocked.Or(ref Unsafe.As<Uri.Flags, ulong>(ref thisUri._flags), (ulong)Uri.Flags.CustomParser_ParseMinimalAlreadyCalled);
System.Private.Windows.Core (171)
System\IO\BinaryReaderExtensions.cs (1)
45return Unsafe.As<long, DateTime>(ref data);
System\IO\BinaryWriterExtensions.cs (1)
24long dateData = Unsafe.As<DateTime, long>(ref value);
System\Private\Windows\BinaryFormat\BinaryFormatWriter.cs (1)
92Unsafe.As<DateTime, ulong>(ref value)).Write(writer);
System\Private\Windows\Ole\Composition.NativeToRuntimeAdapter.cs (7)
32fixed (Com.FORMATETC* nativeFormat = &Unsafe.As<FORMATETC, Com.FORMATETC>(ref pFormatetc)) 70HRESULT result = nativeDataObject.Value->GetCanonicalFormatEtc(Unsafe.As<FORMATETC, Com.FORMATETC>(ref formatIn), out Com.FORMATETC nativeFormat); 71formatOut = Unsafe.As<Com.FORMATETC, FORMATETC>(ref nativeFormat); 77Com.FORMATETC nativeFormat = Unsafe.As<FORMATETC, Com.FORMATETC>(ref format); 87Com.FORMATETC nativeFormat = Unsafe.As<FORMATETC, Com.FORMATETC>(ref format); 98return nativeDataObject.Value->QueryGetData(Unsafe.As<FORMATETC, Com.FORMATETC>(ref format)); 104Com.FORMATETC nativeFormat = Unsafe.As<FORMATETC, Com.FORMATETC>(ref formatIn);
System\Private\Windows\Ole\FormatEnumerator.cs (1)
117rgelt[i] = Unsafe.As<ComTypes.FORMATETC, FORMATETC>(ref elt[i]);
System\SpanReader.cs (4)
148value = Unsafe.ReadUnaligned<TValue>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(_unread))); 182value = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<T, TValue>(ref MemoryMarshal.GetReference(_unread)), count); 280span = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)start), length);
System\SpanWriter.cs (1)
103span = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)start), length);
System\Value.cs (118)
605return new(Unsafe.As<T, bool>(ref Unsafe.AsRef(in value))); 607return new(Unsafe.As<T, byte>(ref Unsafe.AsRef(in value))); 609return new(Unsafe.As<T, sbyte>(ref Unsafe.AsRef(in value))); 611return new(Unsafe.As<T, char>(ref Unsafe.AsRef(in value))); 613return new(Unsafe.As<T, short>(ref Unsafe.AsRef(in value))); 615return new(Unsafe.As<T, int>(ref Unsafe.AsRef(in value))); 617return new(Unsafe.As<T, long>(ref Unsafe.AsRef(in value))); 619return new(Unsafe.As<T, ushort>(ref Unsafe.AsRef(in value))); 621return new(Unsafe.As<T, uint>(ref Unsafe.AsRef(in value))); 623return new(Unsafe.As<T, ulong>(ref Unsafe.AsRef(in value))); 625return new(Unsafe.As<T, float>(ref Unsafe.AsRef(in value))); 627return new(Unsafe.As<T, double>(ref Unsafe.AsRef(in value))); 629return new(Unsafe.As<T, DateTime>(ref Unsafe.AsRef(in value))); 631return new(Unsafe.As<T, DateTimeOffset>(ref Unsafe.AsRef(in value))); 633return new(Unsafe.As<T, Color>(ref Unsafe.AsRef(in value))); 636return new(Unsafe.As<T, bool?>(ref Unsafe.AsRef(in value))); 638return new(Unsafe.As<T, byte?>(ref Unsafe.AsRef(in value))); 640return new(Unsafe.As<T, sbyte?>(ref Unsafe.AsRef(in value))); 642return new(Unsafe.As<T, char?>(ref Unsafe.AsRef(in value))); 644return new(Unsafe.As<T, short?>(ref Unsafe.AsRef(in value))); 646return new(Unsafe.As<T, int?>(ref Unsafe.AsRef(in value))); 648return new(Unsafe.As<T, long?>(ref Unsafe.AsRef(in value))); 650return new(Unsafe.As<T, ushort?>(ref Unsafe.AsRef(in value))); 652return new(Unsafe.As<T, uint?>(ref Unsafe.AsRef(in value))); 654return new(Unsafe.As<T, ulong?>(ref Unsafe.AsRef(in value))); 656return new(Unsafe.As<T, float?>(ref Unsafe.AsRef(in value))); 658return new(Unsafe.As<T, double?>(ref Unsafe.AsRef(in value))); 660return new(Unsafe.As<T, DateTime?>(ref Unsafe.AsRef(in value))); 662return new(Unsafe.As<T, DateTimeOffset?>(ref Unsafe.AsRef(in value))); 665return new(Unsafe.As<T, ArraySegment<byte>>(ref Unsafe.AsRef(in value))); 667return new(Unsafe.As<T, ArraySegment<char>>(ref Unsafe.AsRef(in value))); 671Debug.Assert(Unsafe.SizeOf<T>() <= sizeof(ulong)); 672return new Value(StraightCastFlag<T>.Instance, Unsafe.As<T, ulong>(ref value)); 681Unsafe.SkipInit(out _union); 717value = Unsafe.As<Union, T>(ref Unsafe.AsRef(in _union)); 723value = Unsafe.As<Color, T>(ref Unsafe.AsRef(in color)); 728value = Unsafe.As<DateTime, T>(ref Unsafe.AsRef(in _union.DateTime)); 734value = Unsafe.As<DateTimeOffset, T>(ref Unsafe.AsRef(in dto)); 740value = Unsafe.As<DateTimeOffset, T>(ref Unsafe.AsRef(in dto)); 785value = Unsafe.As<ArraySegment<byte>, T>(ref segment); 801value = Unsafe.As<ArraySegment<char>, T>(ref segment); 812value = Unsafe.As<int?, T>(ref Unsafe.AsRef(in @int)); 818value = Unsafe.As<long?, T>(ref Unsafe.AsRef(in @long)); 824value = Unsafe.As<bool?, T>(ref Unsafe.AsRef(in @bool)); 830value = Unsafe.As<float?, T>(ref Unsafe.AsRef(in single)); 836value = Unsafe.As<double?, T>(ref Unsafe.AsRef(in @double)); 842value = Unsafe.As<uint?, T>(ref Unsafe.AsRef(in @uint)); 848value = Unsafe.As<ulong?, T>(ref Unsafe.AsRef(in @ulong)); 854value = Unsafe.As<char?, T>(ref Unsafe.AsRef(in @char)); 860value = Unsafe.As<short?, T>(ref Unsafe.AsRef(in @short)); 866value = Unsafe.As<ushort?, T>(ref Unsafe.AsRef(in @ushort)); 872value = Unsafe.As<byte?, T>(ref Unsafe.AsRef(in @byte)); 878value = Unsafe.As<sbyte?, T>(ref Unsafe.AsRef(in @sbyte)); 884value = Unsafe.As<Color?, T>(ref Unsafe.AsRef(in color)); 890value = Unsafe.As<DateTime?, T>(ref Unsafe.AsRef(in dateTime)); 896value = Unsafe.As<DateTimeOffset?, T>(ref Unsafe.AsRef(in dto)); 902value = Unsafe.As<DateTimeOffset?, T>(ref Unsafe.AsRef(in dto)); 915int size = Unsafe.SizeOf<T>(); 921value = Unsafe.As<NullableTemplate<byte>, T>(ref Unsafe.AsRef(in byteTemplate)); 926value = Unsafe.As<NullableTemplate<ushort>, T>(ref Unsafe.AsRef(in ushortTemplate)); 931value = Unsafe.As<NullableTemplate<uint>, T>(ref Unsafe.AsRef(in uintTemplate)); 936value = Unsafe.As<NullableTemplate<ulong>, T>(ref Unsafe.AsRef(in ulongTemplate));
System\Value.PackedColor.cs (2)
36CastColor castColor = Unsafe.As<Color, CastColor>(ref Unsafe.AsRef(in color));
System\Value.StraightCastFlag.cs (2)
18public override T To(in Value value) => Unsafe.As<Union, T>(ref Unsafe.AsRef(in value._union));
Windows\Win32\Foundation\BSTR.cs (1)
22Unsafe.AsRef(in this) = default;
Windows\Win32\Foundation\HandleRef.cs (2)
60return new(handle.Wrapper, Unsafe.As<THandle, nint>(ref local)); 71return new(handle.Wrapper, Unsafe.As<nint, THandle>(ref local));
Windows\Win32\Graphics\Gdi\ARGB.cs (3)
28Unsafe.SkipInit(out this); 38Unsafe.SkipInit(out this); 60ref Unsafe.As<uint, ARGB>(ref MemoryMarshal.GetReference(argbColors)),
Windows\Win32\Graphics\Gdi\ArgbBuffer.cs (1)
39ref Unsafe.As<ARGB, uint>(ref _bufferScope.GetPinnableReference());
Windows\Win32\System\Com\ComInterfaceTable.cs (8)
25Entries = (ComInterfaceEntry*)Unsafe.AsPointer(ref entries[0]), 43Entries = (ComInterfaceEntry*)Unsafe.AsPointer(ref entries[0]), 63Entries = (ComInterfaceEntry*)Unsafe.AsPointer(ref entries[0]), 85Entries = (ComInterfaceEntry*)Unsafe.AsPointer(ref entries[0]), 109Entries = (ComInterfaceEntry*)Unsafe.AsPointer(ref entries[0]), 135Entries = (ComInterfaceEntry*)Unsafe.AsPointer(ref entries[0]), 169Entries = (ComInterfaceEntry*)Unsafe.AsPointer(ref entries[0]), 239Entries = (ComInterfaceEntry*)Unsafe.AsPointer(ref entries[0]),
Windows\Win32\System\Com\ComScope.cs (4)
49public static implicit operator T**(in ComScope<T> scope) => (T**)Unsafe.AsPointer(ref Unsafe.AsRef(in scope._value)); 52public static implicit operator void**(in ComScope<T> scope) => (void**)Unsafe.AsPointer(ref Unsafe.AsRef(in scope._value));
Windows\Win32\System\Com\IComCallableWrapper.cs (1)
28return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
Windows\Win32\System\Com\IID.cs (6)
21return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data)); 33=> (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in T.Guid)); 40=> ref Unsafe.AsRef(in T.Guid); 45public static Guid* NULL() => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IID_NULL));
Windows\Win32\System\Com\SAFEARRAY.cs (2)
96void* v = Unsafe.Add<T>(pvData, (int)cell); 97return Unsafe.AsRef<T>(v);
Windows\Win32\System\Com\SafeArrayScope.cs (4)
257public static implicit operator SAFEARRAY**(in SafeArrayScope<T> scope) => (SAFEARRAY**)Unsafe.AsPointer(ref Unsafe.AsRef(in scope._value)); 260public static implicit operator void**(in SafeArrayScope<T> scope) => (void**)Unsafe.AsPointer(ref Unsafe.AsRef(in scope._value));
Windows\Win32\System\Variant\VARIANT.cs (1)
868=> MemoryMarshal.CreateSpan(ref Unsafe.AsRef<T>(Marshal.UnsafeAddrOfPinnedArrayElement(array, 0).ToPointer()), array.Length);
System.Private.Windows.Core.TestUtilities (3)
XUnit\InvalidEnumDataAttribute.cs (3)
32currentValue = Unsafe.As<ulong, TEnum>(ref currentFlagValue); 52currentValue = Unsafe.As<ulong, TEnum>(ref minValue); 62currentValue = Unsafe.As<ulong, TEnum>(ref maxValue);
System.Private.Windows.GdiPlus (6)
Windows\Win32\Graphics\GdiPlus\GpBitmapExtensions.cs (2)
26(BitmapData*)Unsafe.AsPointer(ref data)).ThrowIfFailed(); 33PInvokeGdiPlus.GdipBitmapUnlockBits(bitmap.GetPointer(), (BitmapData*)Unsafe.AsPointer(ref data)).ThrowIfFailed();
Windows\Win32\Graphics\GdiPlus\Rect.cs (2)
11public static implicit operator Rectangle(Rect rect) => Unsafe.As<Rect, Rectangle>(ref rect); 12public static implicit operator Rect(Rectangle rectangle) => Unsafe.As<Rectangle, Rect>(ref rectangle);
Windows\Win32\Graphics\GdiPlus\RectF.cs (2)
11public static implicit operator RectangleF(RectF rect) => Unsafe.As<RectF, RectangleF>(ref rect); 12public static implicit operator RectF(RectangleF rectangle) => Unsafe.As<RectangleF, RectF>(ref rectangle);
System.Private.Xml (1)
System\Xml\XmlCharType.cs (1)
186private static uint GetCharProperties(char ch) => Unsafe.Add(ref MemoryMarshal.GetReference(CharProperties), ch);
System.Reflection.Metadata (8)
System\Reflection\Internal\Utilities\BlobUtilities.cs (5)
52Unsafe.WriteUnaligned(ref buffer[start], !BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness(value) : value); 55Unsafe.WriteUnaligned(ref buffer[start], BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness(value) : value); 58Unsafe.WriteUnaligned(ref buffer[start], BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness(value) : value); 61Unsafe.WriteUnaligned(ref buffer[start], !BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness(value) : value); 64Unsafe.WriteUnaligned(ref buffer[start], !BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness(value) : value);
System\Reflection\Internal\Utilities\MemoryBlock.cs (3)
130uint result = Unsafe.ReadUnaligned<uint>(Pointer + offset); 188ushort result = Unsafe.ReadUnaligned<ushort>(Pointer + offset); 248return Unsafe.ReadUnaligned<Guid>(ptr);
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net10.0\System.Runtime.Forwards.cs (1)
640[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.Unsafe))]
System.Runtime.CompilerServices.Unsafe (1)
System.Runtime.CompilerServices.Unsafe.cs (1)
4[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.Unsafe))]
System.Runtime.Numerics (61)
src\libraries\Common\src\System\Number.NumberBuffer.cs (1)
33public readonly byte* DigitsPtr => (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(Digits)); // safe since constructor expects Digits to refer to unmovable memory
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\FormattingHelpers.CountDigits.cs (1)
55ulong powerOf10 = Unsafe.Add(ref MemoryMarshal.GetReference(powersOf10), elementOffset);
System\Number.BigInteger.cs (3)
1176Debug.Assert(Unsafe.AreSame(ref bits[0], ref powersOfTen2[0])); 1238ref TChar lastWholeBlockStart = ref Unsafe.Add(ref MemoryMarshal.GetReference(input), input.Length - TParser.DigitsPerBlock); 1243MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Subtract(ref lastWholeBlockStart, i * TParser.DigitsPerBlock), TParser.DigitsPerBlock),
System\Numerics\BigInteger.cs (25)
3673Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 3680ref byte address = ref Unsafe.Add(ref startAddress, (bits.Length - 1) * sizeof(uint)); 3691Unsafe.WriteUnaligned(ref address, part); 3692address = ref Unsafe.Subtract(ref address, sizeof(uint)); 3701ref byte address = ref Unsafe.Add(ref startAddress, byteCount - sizeof(uint)); 3716Unsafe.WriteUnaligned(ref address, part); 3717address = ref Unsafe.Subtract(ref address, sizeof(uint)); 3733Unsafe.WriteUnaligned(ref address, part); 3734address = ref Unsafe.Subtract(ref address, sizeof(uint)); 3739if (Unsafe.AreSame(ref address, ref startAddress)) 3743Unsafe.WriteUnaligned(ref address, uint.MaxValue); 3748Debug.Assert(Unsafe.AreSame(ref startAddress, ref Unsafe.Add(ref address, sizeof(uint)))); 3775Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 3792Unsafe.WriteUnaligned(ref address, part); 3793address = ref Unsafe.Add(ref address, sizeof(uint)); 3802ref byte lastAddress = ref Unsafe.Add(ref address, byteCount - sizeof(uint)); 3817Unsafe.WriteUnaligned(ref address, part); 3818address = ref Unsafe.Add(ref address, sizeof(uint)); 3834Unsafe.WriteUnaligned(ref address, part); 3835address = ref Unsafe.Add(ref address, sizeof(uint)); 3840if (Unsafe.AreSame(ref address, ref lastAddress)) 3844Unsafe.WriteUnaligned(ref address, uint.MaxValue); 3849Debug.Assert(Unsafe.AreSame(ref lastAddress, ref Unsafe.Subtract(ref address, sizeof(uint))));
System\Numerics\BigIntegerCalculator.AddSub.cs (16)
49carry += Unsafe.Add(ref leftPtr, i); 50carry += Unsafe.Add(ref rightPtr, i); 51Unsafe.Add(ref resultPtr, i) = unchecked((uint)carry); 76long digit = (Unsafe.Add(ref leftPtr, i) + carry) + right[i]; 77Unsafe.Add(ref leftPtr, i) = unchecked((uint)digit); 122carry += Unsafe.Add(ref leftPtr, i); 123carry -= Unsafe.Add(ref rightPtr, i); 124Unsafe.Add(ref resultPtr, i) = unchecked((uint)carry); 152long digit = (Unsafe.Add(ref leftPtr, i) + carry) - right[i]; 153Unsafe.Add(ref leftPtr, i) = unchecked((uint)digit); 182Unsafe.Add(ref resultPtr, i) = unchecked((uint)carry); 186Unsafe.Add(ref resultPtr, left.Length) = unchecked((uint)carry); 193Unsafe.Add(ref resultPtr, i) = unchecked((uint)carry); 205Unsafe.Add(ref resultPtr, left.Length) = unchecked((uint)carry); 229Unsafe.Add(ref resultPtr, i) = unchecked((uint)carry); 238Unsafe.Add(ref resultPtr, i) = unchecked((uint)carry);
System\Numerics\BigIntegerCalculator.SquMul.cs (11)
57ulong digit1 = Unsafe.Add(ref resultPtr, i + j) + carry; 59Unsafe.Add(ref resultPtr, i + j) = unchecked((uint)(digit1 + (digit2 << 1))); 63Unsafe.Add(ref resultPtr, i + i) = unchecked((uint)digits); 64Unsafe.Add(ref resultPtr, i + i + 1) = (uint)(digits >> 32); 352ref uint elementPtr = ref Unsafe.Add(ref resultPtr, i + j); 357Unsafe.Add(ref resultPtr, i + left.Length) = (uint)carry; 384long digit = (Unsafe.Add(ref corePtr, i) + carry) - Unsafe.Add(ref leftPtr, i) - right[i]; 385Unsafe.Add(ref corePtr, i) = unchecked((uint)digit); 391long digit = (Unsafe.Add(ref corePtr, i) + carry) - left[i]; 392Unsafe.Add(ref corePtr, i) = unchecked((uint)digit);
System\Numerics\Complex.cs (4)
2216m_real.TryFormat(Unsafe.BitCast<Span<TChar>, Span<char>>(destination.Slice(1)), out realChars, format, provider) : 2217m_real.TryFormat(Unsafe.BitCast<Span<TChar>, Span<byte>>(destination.Slice(1)), out realChars, format, provider)) 2227m_imaginary.TryFormat(Unsafe.BitCast<Span<TChar>, Span<char>>(destination.Slice(2)), out imaginaryChars, format, provider) : 2228m_imaginary.TryFormat(Unsafe.BitCast<Span<TChar>, Span<byte>>(destination.Slice(2)), out imaginaryChars, format, provider))
System.Security.Cryptography.Pkcs (2)
src\libraries\Common\src\System\Security\Cryptography\Helpers.cs (1)
69return Unsafe.IsNullRef(ref MemoryMarshal.GetReference(span));
src\libraries\Common\src\System\Security\Cryptography\Pkcs12Kdf.cs (1)
127if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(password)))
System.ServiceModel.UnixDomainSocket (2)
System\ServiceModel\Channels\UnixDomainSocketChannelFactory.cs (2)
87return Unsafe.As<TimeSpan, T>(ref temp); 104return Unsafe.As<int, T>(ref temp);
System.Text.Encoding.CodePages (2)
System\Text\DBCSCodePageEncoding.cs (1)
123Unsafe.InitBlockUnaligned(pNativeMemory, 0, (uint)sizeToAllocate);
System\Text\SBCSCodePageEncoding.cs (1)
86Unsafe.InitBlockUnaligned(pNativeMemory, 0, (uint)bytesToAllocate);
System.Text.Encodings.Web (1)
System\Text\Encodings\Web\OptimizedInboxTextEncoder.cs (1)
46allowedCodePointsBmp = ref Unsafe.NullRef<AllowedBmpCodePointsBitmap>();
System.Text.Json (12)
src\libraries\System.Private.CoreLib\src\System\Marvin.cs (11)
64p0 += Unsafe.ReadUnaligned<uint>(ref data); 65uint nextUInt32 = Unsafe.ReadUnaligned<uint>(ref Unsafe.AddByteOffset(ref data, 4)); 80data = ref Unsafe.AddByteOffset(ref data, 8); 101p0 += Unsafe.ReadUnaligned<uint>(ref data); 116uint partialResult = Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref Unsafe.AddByteOffset(ref data, (nuint)count & 7), -4)); 182partialResult = Unsafe.AddByteOffset(ref data, (nuint)count & 2); 208partialResult |= (uint)Unsafe.ReadUnaligned<ushort>(ref data); 212partialResult |= (uint)Unsafe.ReadUnaligned<ushort>(ref data);
System\Text\Json\Document\JsonDocument.DbRow.cs (1)
61Debug.Assert(Unsafe.SizeOf<DbRow>() == Size);
System.Text.RegularExpressions (1)
System\Text\RegularExpressions\RegexCompiler.cs (1)
105private static MethodInfo UnsafeAsMethod => field ??= typeof(Unsafe).GetMethod("As", [typeof(object)])!;
System.Text.RegularExpressions.Generator (1)
Stubs.cs (1)
93uint oldValue = (uint)Interlocked.CompareExchange(ref Unsafe.As<uint, int>(ref location1), (int)newValue, (int)current);
System.Threading.Tasks.Parallel (4)
System\Threading\Tasks\ParallelLoopState.cs (4)
362return Unsafe.BitCast<int, TInt>(Volatile.Read(ref Unsafe.As<TInt, int>(ref _lowestBreakIteration))); 366return Unsafe.BitCast<long, TInt>(Volatile.Read(ref Unsafe.As<TInt, long>(ref _lowestBreakIteration)));
System.Windows.Forms (5)
System\Windows\Forms\Application.ComponentThreadContext.cs (1)
360=> PreTranslateMessage(ref Unsafe.AsRef<MSG>(msg));
System\Windows\Forms\Dialogs\CommonDialogs\FontDialog.cs (1)
425UpdateFont(ref Unsafe.As<LOGFONTW, LOGFONT>(ref logFont));
System\Windows\Forms\PropertyStore.cs (2)
203AddOrUpdate(key, Unsafe.As<T, Padding>(ref value)); 207AddOrUpdate(key, Unsafe.As<T, Rectangle>(ref value));
System\Windows\Forms\SystemInformation.cs (1)
156return Font.FromLogFont(Unsafe.AsRef<LOGFONT>((LOGFONT*)&data.lfMenuFont));
System.Windows.Forms.Primitives (10)
Microsoft\Office\IMsoComponent.cs (1)
118return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
Microsoft\Office\IMsoComponentManager.cs (1)
30return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
Microsoft\VisualStudio\Shell\ICategorizeProperties.cs (1)
28return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
Microsoft\VisualStudio\Shell\IProvidePropertyBuilder.cs (1)
28return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
Microsoft\VisualStudio\Shell\IVSMDPerPropertyBrowsing.cs (1)
29return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
Microsoft\VisualStudio\Shell\IVsPerPropertyBrowsing.cs (1)
28return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
System\Drawing\FontExtensions.cs (2)
14return Unsafe.As<LOGFONT, LOGFONTW>(ref logFont); 20return Unsafe.As<LOGFONT, LOGFONTW>(ref logFont);
System\EnumExtensions.cs (1)
21T* v = (T*)Unsafe.AsPointer(ref value);
System\Windows\Forms\IExtender.cs (1)
99return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
System.Windows.Forms.Primitives.Tests (1)
Windows\Win32\System\Com\ComScopeTests.cs (1)
63return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
System.Windows.Forms.Primitives.TestUtilities (1)
Metafiles\DataHelpers.cs (1)
23Unsafe.CopyBlock(p, i, (uint)(sizeof(int) * values.Length));
System.Windows.Forms.Tests (1)
System\Windows\Forms\DragDropHelperTests.cs (1)
107Assert.Equal(expectedIsInDragLoopFormat, DragDropHelper.IsInDragLoopFormat(Unsafe.As<FORMATETC, Com.FORMATETC>(ref formatEtc)));
Test.Utilities (54)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (7)
23return Unsafe.SizeOf<T>() switch 40_ => InlineCalculateSegmentSize(Unsafe.SizeOf<T>()), 50return Unsafe.SizeOf<T>() switch 67_ => InlineCalculateSegmentShift(Unsafe.SizeOf<T>()), 77return Unsafe.SizeOf<T>() switch 94_ => InlineCalculateOffsetMask(Unsafe.SizeOf<T>()), 175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
Text.Analyzers (52)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (3)
230Unsafe.WriteUnaligned(ref dest0, high); 231Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (5)
794Unsafe.ReadUnaligned<uint>(data) : 795BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<uint>(data)); 800Unsafe.ReadUnaligned<ulong>(data) : 801BinaryPrimitives.ReverseEndianness(Unsafe.ReadUnaligned<ulong>(data)); 810Unsafe.WriteUnaligned(data, value);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
415Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
18=> ref Unsafe.AsRef<T>(null); 28=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
23return Unsafe.SizeOf<T>() switch 50return Unsafe.SizeOf<T>() switch 77return Unsafe.SizeOf<T>() switch 200public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 31var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 40var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 31var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 40var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 31var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 40var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Segmented\SegmentedArray`1.cs (1)
28/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
src\Dependencies\Collections\TemporaryArrayExtensions.cs (1)
42=> ref Unsafe.AsRef(in array);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (24)
48Unsafe.Add(ref destination, 1) = (byte)(value >> 8); 49Unsafe.Add(ref destination, 2) = (byte)value; 56int i1 = Unsafe.Add(ref encodedChars, 1); 57int i2 = Unsafe.Add(ref encodedChars, 2); 58int i3 = Unsafe.Add(ref encodedChars, 3); 63i0 = Unsafe.Add(ref decodingMap, i0); 64i1 = Unsafe.Add(ref decodingMap, i1); 65i2 = Unsafe.Add(ref decodingMap, i2); 66i3 = Unsafe.Add(ref decodingMap, i3); 227int result = Decode(ref Unsafe.Add(ref srcChars, sourceIndex), ref decodingMap); 230WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), result); 245int i0 = Unsafe.Add(ref srcChars, srcLength - 4); 246int i1 = Unsafe.Add(ref srcChars, srcLength - 3); 247int i2 = Unsafe.Add(ref srcChars, srcLength - 2); 248int i3 = Unsafe.Add(ref srcChars, srcLength - 1); 252i0 = Unsafe.Add(ref decodingMap, i0); 253i1 = Unsafe.Add(ref decodingMap, i1); 262i2 = Unsafe.Add(ref decodingMap, i2); 263i3 = Unsafe.Add(ref decodingMap, i3); 274WriteThreeLowOrderBytes(ref Unsafe.Add(ref destBytes, destIndex), i0); 279i2 = Unsafe.Add(ref decodingMap, i2); 289Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16); 290Unsafe.Add(ref destBytes, destIndex + 1) = (byte)(i0 >> 8); 299Unsafe.Add(ref destBytes, destIndex) = (byte)(i0 >> 16);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
150return Unsafe.As<TFromEnum, TToEnum>(ref value);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\ModifierExtensions.cs (1)
16return Unsafe.As<Modifiers, DeclarationModifiers>(ref modifiers);