5767 references to Unsafe
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 (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.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)
151RenderBatch(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)
623Unsafe.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)
110ref 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)
110ref 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 (157)
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\ServerInfrastructure\StringUtilities.cs (3)
170Unsafe.WriteUnaligned( 171ref Unsafe.As<char, byte>( 172ref Unsafe.Add(ref MemoryMarshal.GetReference(buffer), i)),
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (2)
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.Microbenchmarks (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.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 (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.Shared.Tests (4)
src\Shared\HttpSys\RequestProcessing\NativeRequestContext.cs (1)
110ref 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)
Collections\TemporaryArrayExtensions.cs (1)
40=> ref Unsafe.AsRef(in array);
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\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 29var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 38var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 29var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 38var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 29var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 38var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
413Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
16=> ref Unsafe.AsRef<T>(null); 26=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (7)
21return Unsafe.SizeOf<T>() switch 38_ => InlineCalculateSegmentSize(Unsafe.SizeOf<T>()), 48return Unsafe.SizeOf<T>() switch 65_ => InlineCalculateSegmentShift(Unsafe.SizeOf<T>()), 75return Unsafe.SizeOf<T>() switch 92_ => InlineCalculateOffsetMask(Unsafe.SizeOf<T>()), 173return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
src\Dependencies\Collections\SegmentedArray`1.cs (1)
26/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
Microsoft.CodeAnalysis.CodeStyle (50)
src\Compilers\Core\Portable\Collections\TemporaryArrayExtensions.cs (1)
40=> ref Unsafe.AsRef(in array);
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\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 29var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 38var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 29var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 38var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 29var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 38var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
413Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
16=> ref Unsafe.AsRef<T>(null); 26=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
21return Unsafe.SizeOf<T>() switch 48return Unsafe.SizeOf<T>() switch 75return Unsafe.SizeOf<T>() switch 198public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\SegmentedArray`1.cs (1)
26/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
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);
Microsoft.CodeAnalysis.Collections.Package (17)
ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 29var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 38var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 29var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 38var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
ImmutableSegmentedList`1+PrivateMarshal.cs (3)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 29var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 38var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
Internal\ArraySortHelper.cs (1)
413Debug.Assert(!Unsafe.AreSame(ref i, ref j));
Internal\RoslynUnsafe.cs (2)
16=> ref Unsafe.AsRef<T>(null); 26=> Unsafe.AsPointer(ref source) == null;
Internal\SegmentedArrayHelper.cs (4)
21return Unsafe.SizeOf<T>() switch 48return Unsafe.SizeOf<T>() switch 75return Unsafe.SizeOf<T>() switch 198public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
SegmentedArray`1.cs (1)
26/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
Microsoft.CodeAnalysis.CSharp (2)
Compilation\CSharpCompilation.cs (1)
2563Debug.Assert(System.Runtime.CompilerServices.Unsafe.AreSame(ref cachedBinderFactories, ref ignoreAccessibility ? ref _ignoreAccessibilityBinderFactories : ref _binderFactories));
Parser\Directives.cs (1)
130=> Interlocked.CompareExchange(ref Unsafe.AsRef(in location._directives), value._directives, null);
Microsoft.CodeAnalysis.CSharp.CodeStyle (2)
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (2)
155if (Unsafe.IsNullRef(ref valueRef)) 175if (Unsafe.IsNullRef(ref valueRef))
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (10)
Emit\LocalStateTracing\LocalStateTracingTests.cs (10)
1314yield return new object[] { "", "nint", "IntPtr", Unsafe.SizeOf<nint>() }; 1315yield return new object[] { "", "nuint", "UIntPtr", Unsafe.SizeOf<nuint>() }; 1316yield return new object[] { "", "System.Int128", "'[System.Runtime]System.Int128'", Unsafe.SizeOf<Int128>() }; 1317yield return new object[] { "", "System.Guid", "'[System.Runtime]System.Guid'", Unsafe.SizeOf<Guid>() }; 1318yield return new object[] { "", "System.ValueTuple<int, bool>", "'[System.Runtime]System.ValueTuple`2<int32,bool>'", Unsafe.SizeOf<(int, bool)>() }; 1319yield return new object[] { "struct S { }", "S", "'S'", Unsafe.SizeOf<S1>() }; 1320yield return new object[] { "struct S<T> where T : struct { T t; }", "S<int>", "'S`1<int32>'", Unsafe.SizeOf<S2<int>>() }; 1321yield return new object[] { "struct S { System.DateTime X; System.Guid Y; decimal Z; unsafe void* P; }", "S", "'S'", Unsafe.SizeOf<S3>() }; 1322yield return new object[] { "", "System.ValueTuple<int?, bool?>", "'[System.Runtime]System.ValueTuple`2<System.Nullable`1<int32>,System.Nullable`1<bool>>'", Unsafe.SizeOf<(int?, bool?)>() }; 1323yield return new object[] { "", "int?", "'[System.Runtime]System.Nullable`1<int32>'", Unsafe.SizeOf<int?>() };
Microsoft.CodeAnalysis.CSharp.Features (2)
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (2)
155if (Unsafe.IsNullRef(ref valueRef)) 175if (Unsafe.IsNullRef(ref valueRef))
Microsoft.CodeAnalysis.Features (1)
QuickInfo\Presentation\TaggedTextExtensions.cs (1)
122=> ref Unsafe.AsRef(in builder);
Microsoft.CodeAnalysis.UnitTests (20)
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 (51)
src\Compilers\Core\Portable\Collections\TemporaryArrayExtensions.cs (1)
40=> ref Unsafe.AsRef(in array);
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\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 29var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 38var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 29var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 38var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 29var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 38var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
413Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
16=> ref Unsafe.AsRef<T>(null); 26=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (4)
21return Unsafe.SizeOf<T>() switch 48return Unsafe.SizeOf<T>() switch 75return Unsafe.SizeOf<T>() switch 198public static readonly int SegmentSize = CalculateSegmentSize(Unsafe.SizeOf<T>());
src\Dependencies\Collections\SegmentedArray`1.cs (1)
26/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
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);
Workspace\Solution\Checksum.cs (1)
89Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(span), this);
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (20)
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (3)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary)); 29var dictionary = Interlocked.Exchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary); 38var dictionary = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._dictionary), value._dictionary, comparand._dictionary);
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (3)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set)); 29var set = Interlocked.Exchange(ref Unsafe.AsRef(in location._set), value._set); 38var set = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._set), value._set, comparand._set);
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (3)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list)); 29var list = Interlocked.Exchange(ref Unsafe.AsRef(in location._list), value._list); 38var list = Interlocked.CompareExchange(ref Unsafe.AsRef(in location._list), value._list, comparand._list);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
413Debug.Assert(!Unsafe.AreSame(ref i, ref j));
src\Dependencies\Collections\Internal\RoslynUnsafe.cs (2)
16=> ref Unsafe.AsRef<T>(null); 26=> Unsafe.AsPointer(ref source) == null;
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (7)
21return Unsafe.SizeOf<T>() switch 38_ => InlineCalculateSegmentSize(Unsafe.SizeOf<T>()), 48return Unsafe.SizeOf<T>() switch 65_ => InlineCalculateSegmentShift(Unsafe.SizeOf<T>()), 75return Unsafe.SizeOf<T>() switch 92_ => InlineCalculateOffsetMask(Unsafe.SizeOf<T>()), 173return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
src\Dependencies\Collections\SegmentedArray`1.cs (1)
26/// <para>The segment size is calculated according to <see cref="Unsafe.SizeOf{T}"/>, performs the IL operation
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 (7)
Internal\BufferChunk.cs (2)
79Unsafe.AsRef(in this) = default; // anti foot-shotgun double-return guard; not 100%, but worth doing 89Unsafe.AsRef(in copy._lengthAndPoolFlag) &= ~FlagReturnToPool;
Internal\DefaultHybridCache.cs (1)
58internal void DebugRemoveFeatures(CacheFeatures features) => Unsafe.AsRef(in _features) &= ~features;
Internal\DefaultHybridCache.L2.cs (2)
42var cache = Unsafe.As<IBufferDistributedCache>(_backendCache!); // type-checked already 90var 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)
572eventData.DataPointer = (IntPtr)Unsafe.AsPointer(ref value);
Microsoft.Extensions.Primitives (11)
InplaceStringBuilder.cs (1)
105Unsafe.CopyBlockUnaligned(destination + _offset, source + offset, (uint)count * 2);
StringValues.cs (10)
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)); 745return Unsafe.As<string>(this[0])?.GetHashCode() ?? Count.GetHashCode(); 756return Unsafe.As<string>(value)?.GetHashCode() ?? Count.GetHashCode(); 779_values = Unsafe.As<string?[]>(value);
Microsoft.Extensions.Telemetry (1)
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 (33)
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)
25SizeOfGuid = (uint)Unsafe.SizeOf<Guid>();
System\Windows\BinaryFormat\BinaryFormatWriter.cs (1)
95Unsafe.As<DateTime, ulong>(ref value)).Write(writer);
System\Windows\BinaryFormat\BinaryWriterExtensions.cs (1)
24long dateData = Unsafe.As<DateTime, long>(ref value);
System\Windows\Media\PixelFormat.cs (1)
151Debug.Assert(Unsafe.SizeOf<Guid>() == 16);
PresentationCore.Tests (1)
BinaryFormat\PrimitiveTypeTests.cs (1)
186return Unsafe.As<long, DateTime>(ref data);
PresentationUI (1)
MS\Internal\Documents\PeoplePickerWrapper.cs (1)
519Unsafe.SizeOf<Guid>() + sizeof(UInt32);
Shared (1)
RentedSpan\RentedSpan.cs (1)
54var size = Unsafe.SizeOf<T>() * length;
System.Collections (2)
System\Collections\BitArray.cs (1)
136ref byte value = ref Unsafe.As<bool, byte>(ref MemoryMarshal.GetArrayDataReference<bool>(values));
System\Collections\Generic\OrderedDictionary.cs (1)
635ref Entry entry = ref Unsafe.NullRef<Entry>();
System.Collections.Concurrent (1)
System\Collections\Concurrent\ConcurrentDictionary.cs (1)
2354return 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)
445/// <remarks>The null reference can be detected by calling <see cref="Unsafe.IsNullRef"/>.</remarks> 509public static readonly AlternateLookupDelegate<TAlternateKey> ReturnsNullRef = (_, _) => ref Unsafe.NullRef<TValue>(); 522if (Unsafe.IsNullRef(ref Unsafe.AsRef(in valueRef))) 546!Unsafe.IsNullRef(ref Unsafe.AsRef(in GetValueRefOrNullRef(key))); 571if (!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)
183return ref Unsafe.NullRef<TValue>(); 220return 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)
2014Unsafe.WriteUnaligned(ref outBytes[0], r.Next()); 2018Unsafe.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)
223Unsafe.WriteUnaligned(ref dest0, high); 224Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref dest0, new IntPtr(sizeof(ulong))), low);
System\IO\Hashing\XxHash3.cs (1)
109Unsafe.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)
82ref int end = ref Unsafe.Add(ref pos, destination.Length); 91ref int oneVectorFromEnd = ref Unsafe.Subtract(ref end, Vector<int>.Count); 96pos = ref Unsafe.Add(ref pos, Vector<int>.Count); 98while (!Unsafe.IsAddressGreaterThan(ref pos, ref oneVectorFromEnd)); 103while (Unsafe.IsAddressLessThan(ref pos, ref end)) 106pos = 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 (5)
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\Buffers\SequenceReaderExtensions.Binary.cs (2)
32value = Unsafe.ReadUnaligned<T>(ref MemoryMarshal.GetReference(span)); 51value = Unsafe.ReadUnaligned<T>(ref MemoryMarshal.GetReference(tempSpan));
System.Net.Http (8)
System\Net\Http\Headers\CacheControlHeaderValue.cs (2)
73Interlocked.Or(ref Unsafe.As<Flags, int>(ref _flags), (int)flag); 77Interlocked.And(ref Unsafe.As<Flags, int>(ref _flags), (int)~flag);
System\Net\Http\Headers\HttpHeaders.cs (6)
710if (Unsafe.IsNullRef(ref storeValueRef)) 725if (!Unsafe.IsNullRef(ref storeValueRef)) 1414ref object valueRef = ref Unsafe.NullRef<object>(); 1430valueRef = ref CollectionsMarshal.GetValueRefOrNullRef(Unsafe.As<Dictionary<HeaderDescriptor, object>>(store), key); 1535return !Unsafe.IsNullRef(ref GetValueRefOrNullRef(key)); 1575removed = Unsafe.As<Dictionary<HeaderDescriptor, object>>(store).Remove(key);
System.Net.Quic (2)
System\Net\Quic\Internal\ResettableValueTaskSource.cs (1)
58public bool IsCompleted => (State)Volatile.Read(ref Unsafe.As<State, byte>(ref _state)) == State.Completed;
System\Net\Quic\Internal\ValueTaskSource.cs (1)
41public bool IsCompleted => (State)Volatile.Read(ref Unsafe.As<State, byte>(ref _state)) == State.Completed;
System.Net.Sockets (2)
System\Net\Sockets\SocketAsyncContext.Unix.cs (1)
818QueueState state = (QueueState)Volatile.Read(ref Unsafe.As<QueueState, int>(ref _state));
System\Net\Sockets\SocketPal.Unix.cs (1)
212Unsafe.IsNullRef(ref MemoryMarshal.GetReference(buffer)) ? Array.Empty<byte>() : buffer;
System.Numerics.Tensors (597)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IAggregationOperator.cs (93)
116result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, i))); 794result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 14))); 798result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 13))); 802result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 12))); 806result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 11))); 810result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 10))); 814result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 9))); 818result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 8))); 822result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 7))); 826result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 6))); 830result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 5))); 834result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 4))); 838result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 3))); 842result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 2))); 846result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 1))); 941result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 6))); 945result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 5))); 949result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 4))); 953result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 3))); 957result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 2))); 961result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 1))); 1039result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 2))); 1045result = TAggregationOperator.Invoke(result, TTransformOperator.Invoke(Unsafe.Add(ref xRef, 1))); 1235result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, i), 1236Unsafe.Add(ref yRef, i))); 1996result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 14), Unsafe.Add(ref yRef, 14))); 2000result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 13), Unsafe.Add(ref yRef, 13))); 2004result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 12), Unsafe.Add(ref yRef, 12))); 2008result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 11), Unsafe.Add(ref yRef, 11))); 2012result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 10), Unsafe.Add(ref yRef, 10))); 2016result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 9), Unsafe.Add(ref yRef, 9))); 2020result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 8), Unsafe.Add(ref yRef, 8))); 2024result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 7), Unsafe.Add(ref yRef, 7))); 2028result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 6), Unsafe.Add(ref yRef, 6))); 2032result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 5), Unsafe.Add(ref yRef, 5))); 2036result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 4), Unsafe.Add(ref yRef, 4))); 2040result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 3), Unsafe.Add(ref yRef, 3))); 2044result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 2), Unsafe.Add(ref yRef, 2))); 2048result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 1), Unsafe.Add(ref yRef, 1))); 2149result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 6), Unsafe.Add(ref yRef, 6))); 2153result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 5), Unsafe.Add(ref yRef, 5))); 2157result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 4), Unsafe.Add(ref yRef, 4))); 2161result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 3), Unsafe.Add(ref yRef, 3))); 2165result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 2), Unsafe.Add(ref yRef, 2))); 2169result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 1), Unsafe.Add(ref yRef, 1))); 2253result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 2254Unsafe.Add(ref yRef, 2))); 2260result = TAggregationOperator.Invoke(result, TBinaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 2261Unsafe.Add(ref yRef, 1))); 2368ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(AlignmentByteMask_64x65)), 2375ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(AlignmentUInt16Mask_32x33)), 2382ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(AlignmentUInt32Mask_16x17)), 2389ref Unsafe.As<ulong, T>(ref MemoryMarshal.GetReference(AlignmentUInt64Mask_8x9)), 2404ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(AlignmentByteMask_64x65)), 2411ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(AlignmentUInt16Mask_32x33)), 2418ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(AlignmentUInt32Mask_16x17)), 2425ref Unsafe.As<ulong, T>(ref MemoryMarshal.GetReference(AlignmentUInt64Mask_8x9)), 2440ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(AlignmentByteMask_64x65)), 2447ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(AlignmentUInt16Mask_32x33)), 2454ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(AlignmentUInt32Mask_16x17)), 2461ref Unsafe.As<ulong, T>(ref MemoryMarshal.GetReference(AlignmentUInt64Mask_8x9)), 2476ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(RemainderByteMask_64x65)), 2483ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(RemainderUInt16Mask_32x33)), 2490ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(RemainderUInt32Mask_16x17)), 2497ref Unsafe.As<ulong, T>(ref MemoryMarshal.GetReference(RemainderUInt64Mask_8x9)), 2512ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(RemainderByteMask_64x65)), 2519ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(RemainderUInt16Mask_32x33)), 2526ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(RemainderUInt32Mask_16x17)), 2533ref Unsafe.As<ulong, T>(ref MemoryMarshal.GetReference(RemainderUInt64Mask_8x9)), 2548ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(RemainderByteMask_64x65)), 2555ref Unsafe.As<ushort, T>(ref MemoryMarshal.GetReference(RemainderUInt16Mask_32x33)), 2562ref Unsafe.As<uint, T>(ref MemoryMarshal.GetReference(RemainderUInt32Mask_16x17)), 2569ref 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.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 (230)
125Unsafe.Add(ref dRef, i) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, i), 126Unsafe.Add(ref yRef, i), 127Unsafe.Add(ref zRef, i)); 1088Unsafe.Add(ref dRef, 14) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 14), 1089Unsafe.Add(ref yRef, 14), 1090Unsafe.Add(ref zRef, 14)); 1094Unsafe.Add(ref dRef, 13) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 13), 1095Unsafe.Add(ref yRef, 13), 1096Unsafe.Add(ref zRef, 13)); 1100Unsafe.Add(ref dRef, 12) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 12), 1101Unsafe.Add(ref yRef, 12), 1102Unsafe.Add(ref zRef, 12)); 1106Unsafe.Add(ref dRef, 11) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 11), 1107Unsafe.Add(ref yRef, 11), 1108Unsafe.Add(ref zRef, 11)); 1112Unsafe.Add(ref dRef, 10) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 10), 1113Unsafe.Add(ref yRef, 10), 1114Unsafe.Add(ref zRef, 10)); 1118Unsafe.Add(ref dRef, 9) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 9), 1119Unsafe.Add(ref yRef, 9), 1120Unsafe.Add(ref zRef, 9)); 1124Unsafe.Add(ref dRef, 8) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 8), 1125Unsafe.Add(ref yRef, 8), 1126Unsafe.Add(ref zRef, 8)); 1130Unsafe.Add(ref dRef, 7) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 7), 1131Unsafe.Add(ref yRef, 7), 1132Unsafe.Add(ref zRef, 7)); 1136Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 1137Unsafe.Add(ref yRef, 6), 1138Unsafe.Add(ref zRef, 6)); 1142Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 1143Unsafe.Add(ref yRef, 5), 1144Unsafe.Add(ref zRef, 5)); 1148Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 1149Unsafe.Add(ref yRef, 4), 1150Unsafe.Add(ref zRef, 4)); 1154Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 1155Unsafe.Add(ref yRef, 3), 1156Unsafe.Add(ref zRef, 3)); 1160Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 1161Unsafe.Add(ref yRef, 2), 1162Unsafe.Add(ref zRef, 2)); 1166Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 1167Unsafe.Add(ref yRef, 1), 1168Unsafe.Add(ref zRef, 1)); 1272Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 1273Unsafe.Add(ref yRef, 6), 1274Unsafe.Add(ref zRef, 6)); 1278Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 1279Unsafe.Add(ref yRef, 5), 1280Unsafe.Add(ref zRef, 5)); 1284Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 1285Unsafe.Add(ref yRef, 4), 1286Unsafe.Add(ref zRef, 4)); 1290Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 1291Unsafe.Add(ref yRef, 3), 1292Unsafe.Add(ref zRef, 3)); 1296Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 1297Unsafe.Add(ref yRef, 2), 1298Unsafe.Add(ref zRef, 2)); 1302Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 1303Unsafe.Add(ref yRef, 1), 1304Unsafe.Add(ref zRef, 1)); 1391Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 1392Unsafe.Add(ref yRef, 2), 1393Unsafe.Add(ref zRef, 2)); 1399Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 1400Unsafe.Add(ref yRef, 1), 1401Unsafe.Add(ref zRef, 1)); 1600Unsafe.Add(ref dRef, i) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, i), 1601Unsafe.Add(ref yRef, i), 2555Unsafe.Add(ref dRef, 14) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 14), 2556Unsafe.Add(ref yRef, 14), 2561Unsafe.Add(ref dRef, 13) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 13), 2562Unsafe.Add(ref yRef, 13), 2567Unsafe.Add(ref dRef, 12) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 12), 2568Unsafe.Add(ref yRef, 12), 2573Unsafe.Add(ref dRef, 11) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 11), 2574Unsafe.Add(ref yRef, 11), 2579Unsafe.Add(ref dRef, 10) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 10), 2580Unsafe.Add(ref yRef, 10), 2585Unsafe.Add(ref dRef, 9) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 9), 2586Unsafe.Add(ref yRef, 9), 2591Unsafe.Add(ref dRef, 8) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 8), 2592Unsafe.Add(ref yRef, 8), 2597Unsafe.Add(ref dRef, 7) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 7), 2598Unsafe.Add(ref yRef, 7), 2603Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 2604Unsafe.Add(ref yRef, 6), 2609Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 2610Unsafe.Add(ref yRef, 5), 2615Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 2616Unsafe.Add(ref yRef, 4), 2621Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 2622Unsafe.Add(ref yRef, 3), 2627Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 2628Unsafe.Add(ref yRef, 2), 2633Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 2634Unsafe.Add(ref yRef, 1), 2743Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 2744Unsafe.Add(ref yRef, 6), 2749Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 2750Unsafe.Add(ref yRef, 5), 2755Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 2756Unsafe.Add(ref yRef, 4), 2761Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 2762Unsafe.Add(ref yRef, 3), 2767Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 2768Unsafe.Add(ref yRef, 2), 2773Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 2774Unsafe.Add(ref yRef, 1), 2866Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 2867Unsafe.Add(ref yRef, 2), 2874Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 2875Unsafe.Add(ref yRef, 1), 3079Unsafe.Add(ref dRef, i) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, i), 3081Unsafe.Add(ref zRef, i)); 4034Unsafe.Add(ref dRef, 14) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 14), 4036Unsafe.Add(ref zRef, 14)); 4040Unsafe.Add(ref dRef, 13) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 13), 4042Unsafe.Add(ref zRef, 13)); 4046Unsafe.Add(ref dRef, 12) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 12), 4048Unsafe.Add(ref zRef, 12)); 4052Unsafe.Add(ref dRef, 11) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 11), 4054Unsafe.Add(ref zRef, 11)); 4058Unsafe.Add(ref dRef, 10) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 10), 4060Unsafe.Add(ref zRef, 10)); 4064Unsafe.Add(ref dRef, 9) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 9), 4066Unsafe.Add(ref zRef, 9)); 4070Unsafe.Add(ref dRef, 8) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 8), 4072Unsafe.Add(ref zRef, 8)); 4076Unsafe.Add(ref dRef, 7) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 7), 4078Unsafe.Add(ref zRef, 7)); 4082Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 4084Unsafe.Add(ref zRef, 6)); 4088Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 4090Unsafe.Add(ref zRef, 5)); 4094Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 4096Unsafe.Add(ref zRef, 4)); 4100Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 4102Unsafe.Add(ref zRef, 3)); 4106Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 4108Unsafe.Add(ref zRef, 2)); 4112Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 4114Unsafe.Add(ref zRef, 1)); 4222Unsafe.Add(ref dRef, 6) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 6), 4224Unsafe.Add(ref zRef, 6)); 4228Unsafe.Add(ref dRef, 5) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 5), 4230Unsafe.Add(ref zRef, 5)); 4234Unsafe.Add(ref dRef, 4) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 4), 4236Unsafe.Add(ref zRef, 4)); 4240Unsafe.Add(ref dRef, 3) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 3), 4242Unsafe.Add(ref zRef, 3)); 4246Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 4248Unsafe.Add(ref zRef, 2)); 4252Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 4254Unsafe.Add(ref zRef, 1)); 4345Unsafe.Add(ref dRef, 2) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 2), 4347Unsafe.Add(ref zRef, 2)); 4353Unsafe.Add(ref dRef, 1) = TTernaryOperator.Invoke(Unsafe.Add(ref xRef, 1), 4355Unsafe.Add(ref zRef, 1));
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryInputBinaryOutput.cs (3)
139(T first, T second) = TUnaryOperator.Invoke(Unsafe.Add(ref sourceRef, i)); 140Unsafe.Add(ref destination1Ref, i) = first; 141Unsafe.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\ReadOnlyTensorSpan.cs (18)
105_reference = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)start /* force zero-extension */); 200_reference = ref Unsafe.Add(ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)), (nint)(uint)startOffset /* force zero-extension */); 248_reference = ref Unsafe.Add(ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)), (nint)(uint)startOffset /* force zero-extension */); 335return ref Unsafe.Add(ref _reference, index /* force zero-extension */); 358return ref Unsafe.Add(ref _reference, index /* force zero-extension */); 423Unsafe.AreSame(ref left._reference, ref right._reference); 463return new ReadOnlyTensorSpan<T>(ref Unsafe.As<TDerived, T>(ref items._reference), items._shape.Lengths, items._shape.Strides, items._shape._memoryLength); 520ref T ret = ref Unsafe.NullRef<T>(); 568TensorSpanHelpers.Memmove(ref Unsafe.Add(ref destinationSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, destinationSlice.Strides, destinationSlice.Lengths)), ref Unsafe.Add(ref srcSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, srcSlice.Strides, srcSlice.Lengths)), copyLength); 624TensorSpanHelpers.Memmove(ref Unsafe.Add(ref destinationSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, destinationSlice.Strides, destinationSlice.Lengths)), ref Unsafe.Add(ref srcSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, srcSlice.Strides, srcSlice.Lengths)), copyLength); 735toReturn = new ReadOnlyTensorSpan<T>(ref Unsafe.Add(ref _reference, index), lengths, _shape.Strides, _shape._memoryLength - index); 771TensorSpanHelpers.Memmove(destination.Slice(checked((int)copiedValues)), ref Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths)), Lengths[Rank - 1]); 814destination.Slice(checked((int)copiedValues), (int)Lengths[Rank - 1]).Fill(Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths))); 818TensorSpanHelpers.Memmove(destination.Slice(checked((int)copiedValues)), ref Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths)), Lengths[Rank - 1]);
System\Numerics\Tensors\netcore\TensorExtensions.cs (15)
3097TensorSpanHelpers.Memmove(ref Unsafe.Add(ref destination._reference, TensorSpanHelpers.ComputeLinearIndex(oIndices, tensor.Strides, tensor.Lengths)), ref Unsafe.Add(ref islice._reference, TensorSpanHelpers.ComputeLinearIndex(iIndices, islice.Strides, islice.Lengths)), copyLength); 3245TensorSpanHelpers.Memmove(ref Unsafe.Add(ref oslice._reference, TensorSpanHelpers.ComputeLinearIndex(oIndices, outputs[0].Strides, outputs[0].Lengths)), ref Unsafe.Add(ref islice._reference, TensorSpanHelpers.ComputeLinearIndex(iIndices, islice.Strides, islice.Lengths)), copyLength); 3574var sp = new ReadOnlyTensorSpan<T>(ref Unsafe.Add(ref tensor._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, tensor.Strides, tensor.Lengths)), [tensor.Lengths[tensor.Rank - 1]], [1], tensor.Lengths[tensor.Rank - 1]); 4708lspan = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Add(ref x._reference, TensorSpanHelpers.ComputeLinearIndex(leftIndexes, x.Strides, x.Lengths)), (int)rowLength); 4709rspan = MemoryMarshal.CreateReadOnlySpan(ref Unsafe.Add(ref y._reference, TensorSpanHelpers.ComputeLinearIndex(rightIndexes, y.Strides, y.Lengths)), (int)rowLength); 7131ospan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref slicedDestination._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, slicedDestination.Strides, slicedDestination.Lengths)), (int)rowLength); 7144ospan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref slicedDestination._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, slicedDestination.Strides, slicedDestination.Lengths)), (int)rowLength); 7146ispan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedRight._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedRight.Strides, broadcastedRight.Lengths)), (int)rowLength); 7157ospan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref slicedDestination._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, slicedDestination.Strides, slicedDestination.Lengths)), (int)rowLength); 7159ispan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedLeft._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedLeft.Strides, broadcastedLeft.Lengths)), (int)rowLength); 7171ospan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref slicedDestination._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, slicedDestination.Strides, slicedDestination.Lengths)), (int)rowLength); 7172ispan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedLeft._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedLeft.Strides, broadcastedLeft.Lengths)), (int)rowLength); 7173rspan = MemoryMarshal.CreateSpan(ref Unsafe.Add(ref broadcastedRight._reference, TensorSpanHelpers.ComputeLinearIndex(curIndex, broadcastedRight.Strides, broadcastedRight.Lengths)), (int)rowLength);
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.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\TensorSpan.cs (16)
107_reference = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)start /* force zero-extension */); 202_reference = ref Unsafe.Add(ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)), (nint)(uint)startOffset /* force zero-extension */); 249_reference = ref Unsafe.Add(ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)), (nint)(uint)startOffset /* force zero-extension */); 337return ref Unsafe.Add(ref _reference, index /* force zero-extension */); 362return ref Unsafe.Add(ref _reference, index /* force zero-extension */); 430Unsafe.AreSame(ref left._reference, ref right._reference); 512ref T ret = ref Unsafe.NullRef<T>(); 540TensorSpanHelpers.Clear(ref Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths)), (nuint)Lengths[Rank - 1]); 597TensorSpanHelpers.Memmove(ref Unsafe.Add(ref destinationSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, destinationSlice.Strides, destinationSlice.Lengths)), ref Unsafe.Add(ref srcSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, srcSlice.Strides, srcSlice.Lengths)), copyLength); 651TensorSpanHelpers.Memmove(ref Unsafe.Add(ref destinationSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, destinationSlice.Strides, destinationSlice.Lengths)), ref Unsafe.Add(ref srcSlice._reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, srcSlice.Strides, srcSlice.Lengths)), copyLength); 770toReturn = new TensorSpan<T>(ref Unsafe.Add(ref _reference, index), lengths, _shape.Strides, _shape._memoryLength - index); 824TensorSpanHelpers.Memmove(destination.Slice(checked((int)copiedValues)), ref Unsafe.Add(ref _reference, TensorSpanHelpers.ComputeLinearIndex(curIndexes, Strides, Lengths)), Lengths[Rank - 1]);
System\Numerics\Tensors\netcore\TensorSpanHelpers.T.cs (2)
37dest = ref Unsafe.Add(ref dest, toClear); 48dest = ref Unsafe.Add(ref dest, toFill);
System\Numerics\Tensors\TensorPrimitives.Helpers.cs (3)
18if (!Unsafe.AreSame(ref MemoryMarshal.GetReference(input), ref MemoryMarshal.GetReference(output)) && 38return Unsafe.BitCast<Span<TFrom>, Span<TTo>>(span); 54return Unsafe.BitCast<ReadOnlySpan<TFrom>, ReadOnlySpan<TTo>>(span);
System.Private.CoreLib (4036)
src\libraries\Common\src\System\HexConverter.cs (6)
118ref ushort destRef = ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(chars)); 139uint i32 = Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref srcRef, pos)); 254ref ushort srcRef = ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(chars)); 312Unsafe.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 (39)
372ref byte src = ref Unsafe.As<RawArrayData>(sourceArray).Data; 373ref byte dst = ref Unsafe.As<RawArrayData>(destinationArray).Data; 403ref byte src = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(sourceArray).Data, (uint)sourceIndex * elementSize); 404ref byte dst = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(destinationArray).Data, (uint)destinationIndex * elementSize); 952=> UnsafeArrayAsSpan<T>(array, adjustedIndex, length).BinarySearch(Unsafe.As<byte, T>(ref value.GetRawData())); 1125ref T first = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)startIndex); 1448=> UnsafeArrayAsSpan<T>(array, adjustedIndex, length).IndexOf(Unsafe.As<byte, T>(ref value.GetRawData())); 1515ref Unsafe.Add(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(array)), startIndex), 1516Unsafe.As<T, byte>(ref value), 1523ref Unsafe.Add(ref Unsafe.As<T, short>(ref MemoryMarshal.GetArrayDataReference(array)), startIndex), 1524Unsafe.As<T, short>(ref value), 1531ref Unsafe.Add(ref Unsafe.As<T, int>(ref MemoryMarshal.GetArrayDataReference(array)), startIndex), 1532Unsafe.As<T, int>(ref value), 1539ref Unsafe.Add(ref Unsafe.As<T, long>(ref MemoryMarshal.GetArrayDataReference(array)), startIndex), 1540Unsafe.As<T, long>(ref value), 1675=> UnsafeArrayAsSpan<T>(array, adjustedIndex, length).LastIndexOf(Unsafe.As<byte, T>(ref value.GetRawData())); 1760ref Unsafe.Add(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(array)), endIndex), 1761Unsafe.As<T, byte>(ref value), 1770ref Unsafe.Add(ref Unsafe.As<T, short>(ref MemoryMarshal.GetArrayDataReference(array)), endIndex), 1771Unsafe.As<T, short>(ref value), 1780ref Unsafe.Add(ref Unsafe.As<T, int>(ref MemoryMarshal.GetArrayDataReference(array)), endIndex), 1781Unsafe.As<T, int>(ref value), 1790ref Unsafe.Add(ref Unsafe.As<T, long>(ref MemoryMarshal.GetArrayDataReference(array)), endIndex), 1791Unsafe.As<T, long>(ref value), 1910SpanHelpers.Reverse(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index), (nuint)length); 2160var span = new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index), length); 2184var spanKeys = new Span<TKey>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(keys), index), length); 2185var spanItems = new Span<TValue>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(items), index), length); 2673new 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 (51)
45Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value ? (byte)1 : (byte)0); 57Unsafe.As<byte, char>(ref bytes[0]) = value; 72Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 84Unsafe.As<byte, short>(ref bytes[0]) = value; 99Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 111Unsafe.As<byte, int>(ref bytes[0]) = value; 126Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 138Unsafe.As<byte, long>(ref bytes[0]) = value; 153Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 165Unsafe.As<byte, Int128>(ref bytes[0]) = value; 180Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 193Unsafe.As<byte, ushort>(ref bytes[0]) = value; 209Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 222Unsafe.As<byte, uint>(ref bytes[0]) = value; 238Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 251Unsafe.As<byte, ulong>(ref bytes[0]) = value; 267Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 280Unsafe.As<byte, UInt128>(ref bytes[0]) = value; 296Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 308Unsafe.As<byte, Half>(ref bytes[0]) = value; 323Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 335Unsafe.As<byte, float>(ref bytes[0]) = value; 350Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 362Unsafe.As<byte, double>(ref bytes[0]) = value; 377Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 403return Unsafe.ReadUnaligned<char>(ref MemoryMarshal.GetReference(value)); 424return Unsafe.ReadUnaligned<short>(ref value[startIndex]); 438return Unsafe.ReadUnaligned<short>(ref MemoryMarshal.GetReference(value)); 462return Unsafe.ReadUnaligned<int>(ref value[startIndex]); 476return Unsafe.ReadUnaligned<int>(ref MemoryMarshal.GetReference(value)); 500return Unsafe.ReadUnaligned<long>(ref value[startIndex]); 514return Unsafe.ReadUnaligned<long>(ref MemoryMarshal.GetReference(value)); 538return Unsafe.ReadUnaligned<Int128>(ref value[startIndex]); 552return Unsafe.ReadUnaligned<Int128>(ref MemoryMarshal.GetReference(value)); 579return Unsafe.ReadUnaligned<ushort>(ref MemoryMarshal.GetReference(value)); 609return Unsafe.ReadUnaligned<uint>(ref MemoryMarshal.GetReference(value)); 639return Unsafe.ReadUnaligned<ulong>(ref MemoryMarshal.GetReference(value)); 664return Unsafe.ReadUnaligned<UInt128>(ref value[startIndex]); 679return Unsafe.ReadUnaligned<UInt128>(ref MemoryMarshal.GetReference(value)); 704return Unsafe.ReadUnaligned<Half>(ref MemoryMarshal.GetReference(value)); 732return Unsafe.ReadUnaligned<float>(ref MemoryMarshal.GetReference(value)); 760return Unsafe.ReadUnaligned<double>(ref MemoryMarshal.GetReference(value)); 886return Unsafe.ReadUnaligned<byte>(ref MemoryMarshal.GetReference(value)) != 0; 895public static long DoubleToInt64Bits(double value) => Unsafe.BitCast<double, long>(value); 903public static double Int64BitsToDouble(long value) => Unsafe.BitCast<long, double>(value); 911public static int SingleToInt32Bits(float value) => Unsafe.BitCast<float, int>(value); 919public static float Int32BitsToSingle(int value) => Unsafe.BitCast<int, float>(value); 944public static ulong DoubleToUInt64Bits(double value) => Unsafe.BitCast<double, ulong>(value); 953public static double UInt64BitsToDouble(ulong value) => Unsafe.BitCast<ulong, double>(value); 962public static uint SingleToUInt32Bits(float value) => Unsafe.BitCast<float, uint>(value); 971public static float UInt32BitsToSingle(uint value) => Unsafe.BitCast<uint, float>(value);
src\libraries\System.Private.CoreLib\src\System\Buffer.cs (14)
52Memmove(ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(dst), uDstOffset), ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(src), uSrcOffset), uCount); 84return Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index); 95Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index) = value; 157ref Unsafe.As<T, byte>(ref destination), 158ref Unsafe.As<T, byte>(ref source), 165ref Unsafe.As<T, byte>(ref destination), 166ref Unsafe.As<T, byte>(ref source), 192if (Unsafe.AreSame(ref source, ref destination)) 196if ((nuint)(nint)Unsafe.ByteOffset(ref source, ref destination) >= byteCount) 203destination = ref Unsafe.AddByteOffset(ref destination, BulkMoveWithWriteBarrierChunk); 204source = ref Unsafe.AddByteOffset(ref source, BulkMoveWithWriteBarrierChunk); 214__BulkMoveWithWriteBarrier(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))) 1398int i0 = Unsafe.Add(ref decodingMap, (int)t0); 1399int i1 = Unsafe.Add(ref decodingMap, (int)t1); 1400int i2 = Unsafe.Add(ref decodingMap, (int)t2); 1401int i3 = Unsafe.Add(ref decodingMap, (int)t3); 1442int i0 = Unsafe.Add(ref decodingMap, (IntPtr)t0); 1443int 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 (3)
28nint elementOffset = Unsafe.Add(ref MemoryMarshal.GetReference(log2ToPow10), BitOperations.Log2(value)); 56ulong powerOf10 = Unsafe.Add(ref MemoryMarshal.GetReference(powersOf10), elementOffset); 106long tableValue = Unsafe.Add(ref MemoryMarshal.GetReference(table), uint.Log2(value));
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)
1206sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(char)); 1209result = Unsafe.ReadUnaligned<char>(ref sourceRef); 1257result = Unsafe.ReadUnaligned<char>(ref sourceRef);
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 (2)
83ref Unsafe.As<char, byte>(ref obj.GetRawStringData()), 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\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 (24)
246return Unsafe.As<GuidResult, Guid>(ref Unsafe.AsRef(in this)); 322Unsafe.AsRef(in result._a) = (int)(unix_ts_ms >> 16); 323Unsafe.AsRef(in result._b) = (short)(unix_ts_ms); 325Unsafe.AsRef(in result._c) = (short)((result._c & ~VersionMask) | Version7Value); 326Unsafe.AsRef(in result._d) = (byte)((result._d & ~Variant10xxMask) | Variant10xxValue); 770Unsafe.Add(ref result._d, i) = (byte)byteVal; 977ref int r = ref Unsafe.AsRef(in _a); 978return r ^ Unsafe.Add(ref r, 1) ^ Unsafe.Add(ref r, 2) ^ Unsafe.Add(ref r, 3); 992return Vector128.LoadUnsafe(ref Unsafe.As<Guid, byte>(ref Unsafe.AsRef(in left))) == Vector128.LoadUnsafe(ref Unsafe.As<Guid, byte>(ref Unsafe.AsRef(in right))); 995ref int rA = ref Unsafe.AsRef(in left._a); 996ref int rB = ref Unsafe.AsRef(in right._a); 1001&& Unsafe.Add(ref rA, 1) == Unsafe.Add(ref rB, 1) 1002&& Unsafe.Add(ref rA, 2) == Unsafe.Add(ref rB, 2) 1003&& Unsafe.Add(ref rA, 3) == Unsafe.Add(ref rB, 3); 1428Vector128<byte> srcVec = Unsafe.As<Guid, Vector128<byte>>(ref 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)
804sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - Size); 807result = Unsafe.ReadUnaligned<Int128>(ref sourceRef); 823result |= Unsafe.Add(ref sourceRef, i); 887result = Unsafe.ReadUnaligned<Int128>(ref sourceRef); 905result |= 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); 1394Unsafe.SkipInit(out result); 1395return nint_t.TryParse(utf8Text, style, provider, out Unsafe.As<nint, nint_t>(ref result)); 1404Unsafe.SkipInit(out result); 1405return 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 (448)
38return new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)start /* force zero-extension */), array.Length - start); 62return new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)actualIndex /* force zero-extension */), array.Length - actualIndex); 86return new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)start /* force zero-extension */), length); 125return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetRawStringData(), (nint)(uint)start /* force zero-extension */), text.Length - start); 151return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetRawStringData(), (nint)(uint)actualIndex /* force zero-extension */), text.Length - actualIndex); 177return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetRawStringData(), (nint)(uint)start /* force zero-extension */), length); 209return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetRawStringData(), (nint)(uint)start /* force zero-extension */), length); 334ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 335Unsafe.BitCast<T, byte>(value), 341ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 342Unsafe.BitCast<T, short>(value), 348ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 349Unsafe.BitCast<T, int>(value), 355ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 356Unsafe.BitCast<T, long>(value), 813ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 814Unsafe.BitCast<T, byte>(value), 820ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 821Unsafe.BitCast<T, short>(value), 827ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 828Unsafe.BitCast<T, int>(value), 834ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 835Unsafe.BitCast<T, long>(value), 862ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 863Unsafe.BitCast<T, byte>(value), 869ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 870Unsafe.BitCast<T, short>(value), 876ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 877Unsafe.BitCast<T, int>(value), 883ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 884Unsafe.BitCast<T, long>(value), 940ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 941Unsafe.BitCast<T, byte>(value0), 942Unsafe.BitCast<T, byte>(value1), 948ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 949Unsafe.BitCast<T, short>(value0), 950Unsafe.BitCast<T, short>(value1), 978ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 979Unsafe.BitCast<T, byte>(value0), 980Unsafe.BitCast<T, byte>(value1), 986ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 987Unsafe.BitCast<T, short>(value0), 988Unsafe.BitCast<T, short>(value1), 1047ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1048Unsafe.BitCast<T, byte>(value0), 1049Unsafe.BitCast<T, byte>(value1), 1050Unsafe.BitCast<T, byte>(value2), 1056ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1057Unsafe.BitCast<T, short>(value0), 1058Unsafe.BitCast<T, short>(value1), 1059Unsafe.BitCast<T, short>(value2), 1088ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1089Unsafe.BitCast<T, byte>(value0), 1090Unsafe.BitCast<T, byte>(value1), 1091Unsafe.BitCast<T, byte>(value2), 1097ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1098Unsafe.BitCast<T, short>(value0), 1099Unsafe.BitCast<T, short>(value1), 1100Unsafe.BitCast<T, short>(value2), 1150ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1151Unsafe.BitCast<T, byte>(value0), 1152Unsafe.BitCast<T, byte>(value1), 1153Unsafe.BitCast<T, byte>(value2), 1154Unsafe.BitCast<T, byte>(value3), 1160ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1161Unsafe.BitCast<T, short>(value0), 1162Unsafe.BitCast<T, short>(value1), 1163Unsafe.BitCast<T, short>(value2), 1164Unsafe.BitCast<T, short>(value3), 1207ref byte valuesRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)); 1210ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1212Unsafe.Add(ref valuesRef, 1), 1213Unsafe.Add(ref valuesRef, 2), 1214Unsafe.Add(ref valuesRef, 3), 1215Unsafe.Add(ref valuesRef, 4), 1220ref short valuesRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(values)); 1223ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1225Unsafe.Add(ref valuesRef, 1), 1226Unsafe.Add(ref valuesRef, 2), 1227Unsafe.Add(ref valuesRef, 3), 1228Unsafe.Add(ref valuesRef, 4), 1236ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 1238ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(values)), 1391ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1392Unsafe.BitCast<T, byte>(value), 1398ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1399Unsafe.BitCast<T, short>(value), 1405ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 1406Unsafe.BitCast<T, int>(value), 1412ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 1413Unsafe.BitCast<T, long>(value), 1440ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1441Unsafe.BitCast<T, byte>(value), 1447ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1448Unsafe.BitCast<T, short>(value), 1454ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 1455Unsafe.BitCast<T, int>(value), 1461ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 1462Unsafe.BitCast<T, long>(value), 1518ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1519Unsafe.BitCast<T, byte>(value0), 1520Unsafe.BitCast<T, byte>(value1), 1526ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1527Unsafe.BitCast<T, short>(value0), 1528Unsafe.BitCast<T, short>(value1), 1556ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1557Unsafe.BitCast<T, byte>(value0), 1558Unsafe.BitCast<T, byte>(value1), 1564ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1565Unsafe.BitCast<T, short>(value0), 1566Unsafe.BitCast<T, short>(value1), 1625ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1626Unsafe.BitCast<T, byte>(value0), 1627Unsafe.BitCast<T, byte>(value1), 1628Unsafe.BitCast<T, byte>(value2), 1634ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1635Unsafe.BitCast<T, short>(value0), 1636Unsafe.BitCast<T, short>(value1), 1637Unsafe.BitCast<T, short>(value2), 1666ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1667Unsafe.BitCast<T, byte>(value0), 1668Unsafe.BitCast<T, byte>(value1), 1669Unsafe.BitCast<T, byte>(value2), 1675ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1676Unsafe.BitCast<T, short>(value0), 1677Unsafe.BitCast<T, short>(value1), 1678Unsafe.BitCast<T, short>(value2), 1729ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1730Unsafe.BitCast<T, byte>(value0), 1731Unsafe.BitCast<T, byte>(value1), 1732Unsafe.BitCast<T, byte>(value2), 1733Unsafe.BitCast<T, byte>(value3), 1739ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1740Unsafe.BitCast<T, short>(value0), 1741Unsafe.BitCast<T, short>(value1), 1742Unsafe.BitCast<T, short>(value2), 1743Unsafe.BitCast<T, short>(value3), 1787ref byte valuesRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)); 1790ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1792Unsafe.Add(ref valuesRef, 1), 1793Unsafe.Add(ref valuesRef, 2), 1794Unsafe.Add(ref valuesRef, 3), 1795Unsafe.Add(ref valuesRef, 4), 1800ref short valuesRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(values)); 1803ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 1805Unsafe.Add(ref valuesRef, 1), 1806Unsafe.Add(ref valuesRef, 2), 1807Unsafe.Add(ref valuesRef, 3), 1808Unsafe.Add(ref valuesRef, 4), 1816ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 1818ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(values)), 1919ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1920Unsafe.BitCast<T, byte>(lowInclusive), 1921Unsafe.BitCast<T, byte>(highInclusive), 1928ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)), 1929Unsafe.BitCast<T, ushort>(lowInclusive), 1930Unsafe.BitCast<T, ushort>(highInclusive), 1937ref Unsafe.As<T, uint>(ref MemoryMarshal.GetReference(span)), 1938Unsafe.BitCast<T, uint>(lowInclusive), 1939Unsafe.BitCast<T, uint>(highInclusive), 1946ref Unsafe.As<T, ulong>(ref MemoryMarshal.GetReference(span)), 1947Unsafe.BitCast<T, ulong>(lowInclusive), 1948Unsafe.BitCast<T, ulong>(highInclusive), 1984ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 1985Unsafe.BitCast<T, byte>(lowInclusive), 1986Unsafe.BitCast<T, byte>(highInclusive), 1993ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)), 1994Unsafe.BitCast<T, ushort>(lowInclusive), 1995Unsafe.BitCast<T, ushort>(highInclusive), 2002ref Unsafe.As<T, uint>(ref MemoryMarshal.GetReference(span)), 2003Unsafe.BitCast<T, uint>(lowInclusive), 2004Unsafe.BitCast<T, uint>(highInclusive), 2011ref Unsafe.As<T, ulong>(ref MemoryMarshal.GetReference(span)), 2012Unsafe.BitCast<T, ulong>(lowInclusive), 2013Unsafe.BitCast<T, ulong>(highInclusive), 2049ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2050Unsafe.BitCast<T, byte>(lowInclusive), 2051Unsafe.BitCast<T, byte>(highInclusive), 2058ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)), 2059Unsafe.BitCast<T, ushort>(lowInclusive), 2060Unsafe.BitCast<T, ushort>(highInclusive), 2067ref Unsafe.As<T, uint>(ref MemoryMarshal.GetReference(span)), 2068Unsafe.BitCast<T, uint>(lowInclusive), 2069Unsafe.BitCast<T, uint>(highInclusive), 2076ref Unsafe.As<T, ulong>(ref MemoryMarshal.GetReference(span)), 2077Unsafe.BitCast<T, ulong>(lowInclusive), 2078Unsafe.BitCast<T, ulong>(highInclusive), 2114ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2115Unsafe.BitCast<T, byte>(lowInclusive), 2116Unsafe.BitCast<T, byte>(highInclusive), 2123ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)), 2124Unsafe.BitCast<T, ushort>(lowInclusive), 2125Unsafe.BitCast<T, ushort>(highInclusive), 2132ref Unsafe.As<T, uint>(ref MemoryMarshal.GetReference(span)), 2133Unsafe.BitCast<T, uint>(lowInclusive), 2134Unsafe.BitCast<T, uint>(highInclusive), 2141ref Unsafe.As<T, ulong>(ref MemoryMarshal.GetReference(span)), 2142Unsafe.BitCast<T, ulong>(lowInclusive), 2143Unsafe.BitCast<T, ulong>(highInclusive), 2187ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2188Unsafe.BitCast<T, byte>(value), 2193ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2194Unsafe.BitCast<T, short>(value), 2199ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 2200Unsafe.BitCast<T, int>(value), 2205ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 2206Unsafe.BitCast<T, long>(value), 2228ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2229Unsafe.BitCast<T, byte>(value), 2234ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2235Unsafe.BitCast<T, short>(value), 2240ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 2241Unsafe.BitCast<T, int>(value), 2246ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 2247Unsafe.BitCast<T, long>(value), 2296ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2298ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 2303ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 2305ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(value)), 2325ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2327ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 2332ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 2334ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(value)), 2383ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2384Unsafe.BitCast<T, byte>(value), 2390ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2391Unsafe.BitCast<T, short>(value), 2397ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 2398Unsafe.BitCast<T, int>(value), 2404ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 2405Unsafe.BitCast<T, long>(value), 2429ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2430Unsafe.BitCast<T, byte>(value), 2436ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2437Unsafe.BitCast<T, short>(value), 2443ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 2444Unsafe.BitCast<T, int>(value), 2450ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 2451Unsafe.BitCast<T, long>(value), 2503ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2505ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 2511ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 2513ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(value)), 2535ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2537ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 2543ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 2545ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(value)), 2646ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2647Unsafe.BitCast<T, byte>(value0), 2648Unsafe.BitCast<T, byte>(value1), 2654ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2655Unsafe.BitCast<T, short>(value0), 2656Unsafe.BitCast<T, short>(value1), 2681ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2682Unsafe.BitCast<T, byte>(value0), 2683Unsafe.BitCast<T, byte>(value1), 2689ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2690Unsafe.BitCast<T, short>(value0), 2691Unsafe.BitCast<T, short>(value1), 2746ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2747Unsafe.BitCast<T, byte>(value0), 2748Unsafe.BitCast<T, byte>(value1), 2749Unsafe.BitCast<T, byte>(value2), 2755ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2756Unsafe.BitCast<T, short>(value0), 2757Unsafe.BitCast<T, short>(value1), 2758Unsafe.BitCast<T, short>(value2), 2784ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 2785Unsafe.BitCast<T, byte>(value0), 2786Unsafe.BitCast<T, byte>(value1), 2787Unsafe.BitCast<T, byte>(value2), 2793ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 2794Unsafe.BitCast<T, short>(value0), 2795Unsafe.BitCast<T, short>(value1), 2796Unsafe.BitCast<T, short>(value2), 2850ref byte spanRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)); 2851ref byte valueRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)); 2864Unsafe.Add(ref valueRef, 1), 2871Unsafe.Add(ref valueRef, 1), 2872Unsafe.Add(ref valueRef, 2), 2879Unsafe.Add(ref valueRef, 1), 2880Unsafe.Add(ref valueRef, 2), 2881Unsafe.Add(ref valueRef, 3), 2888Unsafe.Add(ref valueRef, 1), 2889Unsafe.Add(ref valueRef, 2), 2890Unsafe.Add(ref valueRef, 3), 2891Unsafe.Add(ref valueRef, 4), 2898ref short spanRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)); 2899ref short valueRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(values)); 2907Unsafe.Add(ref valueRef, 1), 2912Unsafe.Add(ref valueRef, 1), 2913Unsafe.Add(ref valueRef, 2), 2918Unsafe.Add(ref valueRef, 1), 2919Unsafe.Add(ref valueRef, 2), 2920Unsafe.Add(ref valueRef, 3), 2925Unsafe.Add(ref valueRef, 1), 2926Unsafe.Add(ref valueRef, 2), 2927Unsafe.Add(ref valueRef, 3), 2928Unsafe.Add(ref valueRef, 4), 2930_ => ProbabilisticMap.IndexOfAny(ref Unsafe.As<short, char>(ref spanRef), span.Length, ref Unsafe.As<short, char>(ref valueRef), values.Length), 3066ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3067Unsafe.BitCast<T, byte>(value0), 3068Unsafe.BitCast<T, byte>(value1), 3074ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 3075Unsafe.BitCast<T, short>(value0), 3076Unsafe.BitCast<T, short>(value1), 3101ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3102Unsafe.BitCast<T, byte>(value0), 3103Unsafe.BitCast<T, byte>(value1), 3109ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 3110Unsafe.BitCast<T, short>(value0), 3111Unsafe.BitCast<T, short>(value1), 3167ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3168Unsafe.BitCast<T, byte>(value0), 3169Unsafe.BitCast<T, byte>(value1), 3170Unsafe.BitCast<T, byte>(value2), 3176ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 3177Unsafe.BitCast<T, short>(value0), 3178Unsafe.BitCast<T, short>(value1), 3179Unsafe.BitCast<T, short>(value2), 3205ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3206Unsafe.BitCast<T, byte>(value0), 3207Unsafe.BitCast<T, byte>(value1), 3208Unsafe.BitCast<T, byte>(value2), 3214ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 3215Unsafe.BitCast<T, short>(value0), 3216Unsafe.BitCast<T, short>(value1), 3217Unsafe.BitCast<T, short>(value2), 3272ref byte spanRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)); 3273ref byte valueRef = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)); 3286Unsafe.Add(ref valueRef, 1), 3293Unsafe.Add(ref valueRef, 1), 3294Unsafe.Add(ref valueRef, 2), 3301Unsafe.Add(ref valueRef, 1), 3302Unsafe.Add(ref valueRef, 2), 3303Unsafe.Add(ref valueRef, 3), 3310Unsafe.Add(ref valueRef, 1), 3311Unsafe.Add(ref valueRef, 2), 3312Unsafe.Add(ref valueRef, 3), 3313Unsafe.Add(ref valueRef, 4), 3320ref short spanRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)); 3321ref short valueRef = ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(values)); 3329Unsafe.Add(ref valueRef, 1), 3334Unsafe.Add(ref valueRef, 1), 3335Unsafe.Add(ref valueRef, 2), 3340Unsafe.Add(ref valueRef, 1), 3341Unsafe.Add(ref valueRef, 2), 3342Unsafe.Add(ref valueRef, 3), 3347Unsafe.Add(ref valueRef, 1), 3348Unsafe.Add(ref valueRef, 2), 3349Unsafe.Add(ref valueRef, 3), 3350Unsafe.Add(ref valueRef, 4), 3352_ => ProbabilisticMap.LastIndexOfAny(ref Unsafe.As<short, char>(ref spanRef), span.Length, ref Unsafe.As<short, char>(ref valueRef), values.Length), 3427ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3428ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), 3469ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3470ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), 3511ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3513ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), 3518ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), 3520ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(other)), 3567ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 3568ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 3608ref Unsafe.As<T, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)(spanLength - valueLength) /* force zero-extension */)), 3609ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), 3615ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)(spanLength - valueLength) /* force zero-extension */), 4096nint byteOffset = Unsafe.ByteOffset( 4115nint byteOffset = Unsafe.ByteOffset( 4428ref byte src = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)); 4432Unsafe.BitCast<T, byte>(oldValue), 4433Unsafe.BitCast<T, byte>(newValue), 4440ref ushort src = ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)); 4444Unsafe.BitCast<T, ushort>(oldValue), 4445Unsafe.BitCast<T, ushort>(newValue), 4451ref int src = ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)); 4455Unsafe.BitCast<T, int>(oldValue), 4456Unsafe.BitCast<T, int>(newValue), 4462ref long src = ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)); 4466Unsafe.BitCast<T, long>(oldValue), 4467Unsafe.BitCast<T, long>(newValue), 4494ref byte src = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)); 4498Unsafe.BitCast<T, byte>(oldValue), 4499Unsafe.BitCast<T, byte>(newValue), 4506ref ushort src = ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(span)); 4510Unsafe.BitCast<T, ushort>(oldValue), 4511Unsafe.BitCast<T, ushort>(newValue), 4517ref int src = ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)); 4521Unsafe.BitCast<T, int>(oldValue), 4522Unsafe.BitCast<T, int>(newValue), 4528ref long src = ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)); 4532Unsafe.BitCast<T, long>(oldValue), 4533Unsafe.BitCast<T, long>(newValue), 4595nint byteOffset = Unsafe.ByteOffset(ref src, ref dst); 4608ref Unsafe.As<T, byte>(ref src), 4609ref Unsafe.As<T, byte>(ref dst), 4610Unsafe.BitCast<T, byte>(oldValue), 4611Unsafe.BitCast<T, byte>(newValue), 4619ref Unsafe.As<T, ushort>(ref src), 4620ref Unsafe.As<T, ushort>(ref dst), 4621Unsafe.BitCast<T, ushort>(oldValue), 4622Unsafe.BitCast<T, ushort>(newValue), 4629ref Unsafe.As<T, int>(ref src), 4630ref Unsafe.As<T, int>(ref dst), 4631Unsafe.BitCast<T, int>(oldValue), 4632Unsafe.BitCast<T, int>(newValue), 4639ref Unsafe.As<T, long>(ref src), 4640ref Unsafe.As<T, long>(ref dst), 4641Unsafe.BitCast<T, long>(oldValue), 4642Unsafe.BitCast<T, long>(newValue), 4679nint byteOffset = Unsafe.ByteOffset(ref src, ref dst); 4694ref Unsafe.As<T, byte>(ref src), 4695ref Unsafe.As<T, byte>(ref dst), 4696Unsafe.BitCast<T, byte>(oldValue), 4697Unsafe.BitCast<T, byte>(newValue), 4705ref Unsafe.As<T, ushort>(ref src), 4706ref Unsafe.As<T, ushort>(ref dst), 4707Unsafe.BitCast<T, ushort>(oldValue), 4708Unsafe.BitCast<T, ushort>(newValue), 4715ref Unsafe.As<T, int>(ref src), 4716ref Unsafe.As<T, int>(ref dst), 4717Unsafe.BitCast<T, int>(oldValue), 4718Unsafe.BitCast<T, int>(newValue), 4725ref Unsafe.As<T, long>(ref src), 4726ref Unsafe.As<T, long>(ref dst), 4727Unsafe.BitCast<T, long>(oldValue), 4728Unsafe.BitCast<T, long>(newValue), 4788ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 4789ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), 5282ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 5283Unsafe.BitCast<T, byte>(value), 5289ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 5290Unsafe.BitCast<T, short>(value), 5296ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 5297Unsafe.BitCast<T, int>(value), 5303ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 5304Unsafe.BitCast<T, long>(value), 5331ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), 5332Unsafe.BitCast<T, byte>(value), 5338ref Unsafe.As<T, short>(ref MemoryMarshal.GetReference(span)), 5339Unsafe.BitCast<T, short>(value), 5345ref Unsafe.As<T, int>(ref MemoryMarshal.GetReference(span)), 5346Unsafe.BitCast<T, int>(value), 5352ref Unsafe.As<T, long>(ref MemoryMarshal.GetReference(span)), 5353Unsafe.BitCast<T, long>(value), 5708_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 (2)
55Unsafe.SkipInit(out this); 265Unsafe.SkipInit(out result);
src\libraries\System.Private.CoreLib\src\System\Numerics\Matrix3x2.Impl.cs (7)
23internal ref Impl AsImpl() => ref Unsafe.As<Matrix3x2, Impl>(ref this); 27internal readonly ref readonly Impl AsROImpl() => ref Unsafe.As<Matrix3x2, Impl>(ref Unsafe.AsRef(in this)); 33public ref Matrix3x2 AsM3x2() => ref Unsafe.As<Impl, Matrix3x2>(ref this); 75return Unsafe.Add(ref Unsafe.AsRef(in X), row)[column]; 85Unsafe.Add(ref X, row)[column] = value;
src\libraries\System.Private.CoreLib\src\System\Numerics\Matrix4x4.cs (3)
96Unsafe.SkipInit(out this); 111Unsafe.SkipInit(out this); 629Unsafe.SkipInit(out result);
src\libraries\System.Private.CoreLib\src\System\Numerics\Matrix4x4.Impl.cs (8)
26internal ref Impl AsImpl() => ref Unsafe.As<Matrix4x4, Impl>(ref this); 30internal readonly ref readonly Impl AsROImpl() => ref Unsafe.As<Matrix4x4, Impl>(ref Unsafe.AsRef(in this)); 36public ref Matrix4x4 AsM4x4() => ref Unsafe.As<Impl, Matrix4x4>(ref this); 93return Unsafe.Add(ref Unsafe.AsRef(in X), row)[column]; 103Unsafe.Add(ref X, row)[column] = value; 1232scale = 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 (95)
45Unsafe.SkipInit(out Vector<T> result); 137return Unsafe.BitCast<Vector<TFrom>, Vector<TTo>>(vector); 280Unsafe.SkipInit(out Vector<T> result); 300Unsafe.SkipInit(out Vector<double> result); 319Unsafe.SkipInit(out Vector<float> result); 426Unsafe.SkipInit(out Vector<int> result); 443Unsafe.SkipInit(out Vector<int> result); 460Unsafe.SkipInit(out Vector<long> result); 477Unsafe.SkipInit(out Vector<long> result); 494Unsafe.SkipInit(out Vector<float> result); 535Unsafe.SkipInit(out Vector<uint> result); 553Unsafe.SkipInit(out Vector<uint> result); 571Unsafe.SkipInit(out Vector<ulong> result); 589Unsafe.SkipInit(out Vector<ulong> result); 603Unsafe.SkipInit(out Vector<T> result); 661Unsafe.SkipInit(out Vector<T> result); 722Unsafe.SkipInit(out Vector<T> result); 745return Unsafe.ReadUnaligned<Vector<T>>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values))); 774Unsafe.SkipInit(out Vector<T> result); 792Unsafe.SkipInit(out Vector<T> result); 866Unsafe.SkipInit(out Vector<T> result); 936Unsafe.SkipInit(out Vector<T> result); 997Unsafe.SkipInit(out Vector<T> result); 1017Unsafe.SkipInit(out Vector<double> result); 1036Unsafe.SkipInit(out Vector<float> result); 1060Unsafe.SkipInit(out Vector<double> result); 1084Unsafe.SkipInit(out Vector<float> result); 1123Unsafe.SkipInit(out Vector<T> result); 1211Unsafe.SkipInit(out Vector<T> result); 1293Unsafe.SkipInit(out Vector<T> result); 1620Unsafe.SkipInit(out Vector<T> result); 1678Unsafe.SkipInit(out Vector<T> result); 1766Unsafe.SkipInit(out Vector<T> result); 1894ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source)); 1895return Unsafe.ReadUnaligned<Vector<T>>(in address); 1910ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 1911return Unsafe.ReadUnaligned<Vector<T>>(in address); 1917Unsafe.SkipInit(out Vector<T> result); 1959Unsafe.SkipInit(out Vector<T> result); 2009Unsafe.SkipInit(out Vector<T> result); 2032Unsafe.SkipInit(out Vector<T> result); 2055Unsafe.SkipInit(out Vector<T> result); 2078Unsafe.SkipInit(out Vector<T> result); 2101Unsafe.SkipInit(out Vector<T> result); 2124Unsafe.SkipInit(out Vector<T> result); 2147Unsafe.SkipInit(out Vector<T> result); 2170Unsafe.SkipInit(out Vector<T> result); 2193Unsafe.SkipInit(out Vector<T> result); 2216Unsafe.SkipInit(out Vector<T> result); 2256Unsafe.SkipInit(out Vector<T> result); 2272Unsafe.SkipInit(out Vector<double> result); 2288Unsafe.SkipInit(out Vector<float> result); 2307Unsafe.SkipInit(out Vector<float> result); 2333Unsafe.SkipInit(out Vector<sbyte> result); 2358Unsafe.SkipInit(out Vector<short> result); 2383Unsafe.SkipInit(out Vector<int> result); 2409Unsafe.SkipInit(out Vector<byte> result); 2435Unsafe.SkipInit(out Vector<ushort> result); 2461Unsafe.SkipInit(out Vector<uint> result); 2519Unsafe.SkipInit(out Vector<T> result); 2577Unsafe.SkipInit(out Vector<T> result); 2830Unsafe.SkipInit(out Vector<T> result); 2872Unsafe.SkipInit(out Vector<T> sinResult); 2873Unsafe.SkipInit(out Vector<T> cosResult); 2921Unsafe.SkipInit(out Vector<T> result); 2981ref byte address = ref Unsafe.As<T, byte>(ref destination); 2982Unsafe.WriteUnaligned(ref address, source); 2997destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 2998Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source); 3057Unsafe.SkipInit(out Vector<T> result); 3208Unsafe.SkipInit(out Vector<ushort> lower); 3226Unsafe.SkipInit(out Vector<int> lower); 3244Unsafe.SkipInit(out Vector<long> lower); 3263Unsafe.SkipInit(out Vector<short> lower); 3281Unsafe.SkipInit(out Vector<double> lower); 3300Unsafe.SkipInit(out Vector<uint> lower); 3319Unsafe.SkipInit(out Vector<ulong> lower); 3338Unsafe.SkipInit(out Vector<ushort> upper); 3356Unsafe.SkipInit(out Vector<int> upper); 3374Unsafe.SkipInit(out Vector<long> upper); 3393Unsafe.SkipInit(out Vector<short> upper); 3411Unsafe.SkipInit(out Vector<double> upper); 3430Unsafe.SkipInit(out Vector<uint> upper); 3449Unsafe.SkipInit(out Vector<ulong> upper); 3493ref T address = ref Unsafe.As<Vector<T>, T>(ref Unsafe.AsRef(in vector)); 3494return Unsafe.Add(ref address, index); 3501ref T address = ref Unsafe.As<Vector<T>, T>(ref Unsafe.AsRef(in vector)); 3502Unsafe.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); 980Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref array[0]), this); 1008Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref array[index]), this); 1022Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(destination)), this); 1036Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(destination)), this);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector2.Extensions.cs (5)
74ref byte address = ref Unsafe.As<float, byte>(ref destination); 75Unsafe.WriteUnaligned(ref address, source); 86destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 87Unsafe.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); 990Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref array[0]), this); 1018Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref array[index]), this); 1032Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(destination)), this); 1046Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(destination)), this);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector3.Extensions.cs (5)
74ref byte address = ref Unsafe.As<float, byte>(ref destination); 75Unsafe.WriteUnaligned(ref address, source); 86destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 87Unsafe.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)
81_reference = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)start /* force zero-extension */); 117_reference = ref Unsafe.AsRef(in reference); 148return ref Unsafe.Add(ref _reference, (nint)(uint)index /* force zero-extension */); 225return new ReadOnlySpan<T>(ref Unsafe.As<TDerived, T>(ref items._reference), items.Length); 278ref T ret = ref Unsafe.NullRef<T>(); 334Unsafe.AreSame(ref left._reference, ref right._reference); 344return new string(new ReadOnlySpan<char>(ref Unsafe.As<T, char>(ref _reference), _length)); 362return new ReadOnlySpan<T>(ref Unsafe.Add(ref _reference, (nint)(uint)start /* force zero-extension */), _length - start); 385return 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\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\Unsafe.cs (1)
751return AsPointer(ref Unsafe.AsRef(in source)) == null;
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\GCHandle.cs (5)
135return (IntPtr)Unsafe.AsPointer(ref Unsafe.As<string>(target).GetRawStringData()); 139return (IntPtr)Unsafe.AsPointer(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<Array>(target))); 142return (IntPtr)Unsafe.AsPointer(ref target.GetRawData());
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\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\Intrinsics\ISimdVector_2.cs (1)
275Unsafe.SkipInit(out TSelf result);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector128.cs (54)
160return Unsafe.BitCast<Vector128<TFrom>, Vector128<TTo>>(vector); 545Unsafe.SkipInit(out Vector128<float> result); 656Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[0]), vector); 683Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[startIndex]), vector); 700Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 884return Unsafe.ReadUnaligned<Vector128<T>>(ref Unsafe.As<T, byte>(ref values[0])); 905return Unsafe.ReadUnaligned<Vector128<T>>(ref Unsafe.As<T, byte>(ref values[index])); 922return Unsafe.ReadUnaligned<Vector128<T>>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values))); 1149Unsafe.SkipInit(out Vector128<T> result); 1335Unsafe.SkipInit(out Vector128<T> result); 2256ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source)); 2257return Unsafe.ReadUnaligned<Vector128<T>>(in address); 2272ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 2273return Unsafe.ReadUnaligned<Vector128<T>>(in address); 2279internal static Vector128<ushort> LoadUnsafe(ref char source) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source)); 2285internal static Vector128<ushort> LoadUnsafe(ref char source, nuint elementOffset) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source), elementOffset); 3046Unsafe.SkipInit(out Vector128<byte> result); 3071Unsafe.SkipInit(out Vector128<sbyte> result); 3128Unsafe.SkipInit(out Vector128<short> result); 3153Unsafe.SkipInit(out Vector128<ushort> result); 3177Unsafe.SkipInit(out Vector128<int> result); 3202Unsafe.SkipInit(out Vector128<uint> result); 3226Unsafe.SkipInit(out Vector128<float> result); 3250Unsafe.SkipInit(out Vector128<long> result); 3275Unsafe.SkipInit(out Vector128<ulong> result); 3299Unsafe.SkipInit(out Vector128<double> result); 3470ref byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref destination, elementOffset)); 3471Unsafe.WriteUnaligned(ref address, source.AsDouble().ToScalar()); 3484ref byte address = ref Unsafe.As<T, byte>(ref destination); 3485Unsafe.WriteUnaligned(ref address, source); 3500destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 3501Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source); 3573Unsafe.SkipInit(out Vector256<T> result); 3626Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 3963ref T address = ref Unsafe.As<Vector128<T>, T>(ref Unsafe.AsRef(in vector)); 3964return Unsafe.Add(ref address, index); 3971ref T address = ref Unsafe.As<Vector128<T>, T>(ref Unsafe.AsRef(in vector)); 3972Unsafe.Add(ref address, index) = value; 3976internal static void SetLowerUnsafe<T>(in this Vector128<T> vector, Vector64<T> value) => Unsafe.AsRef(in vector._lower) = value; 3979internal 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 (54)
165return Unsafe.BitCast<Vector256<TFrom>, Vector256<TTo>>(vector); 283Unsafe.WriteUnaligned(ref Unsafe.As<Vector256<T>, byte>(ref result), value); 299ref byte address = ref Unsafe.As<Vector256<T>, byte>(ref value); 300return Unsafe.ReadUnaligned<Vector<T>>(ref address); 668Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[0]), vector); 695Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[startIndex]), vector); 712Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 896return Unsafe.ReadUnaligned<Vector256<T>>(ref Unsafe.As<T, byte>(ref values[0])); 917return Unsafe.ReadUnaligned<Vector256<T>>(ref Unsafe.As<T, byte>(ref values[index])); 934return Unsafe.ReadUnaligned<Vector256<T>>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values))); 1238Unsafe.SkipInit(out Vector256<T> result); 1426Unsafe.SkipInit(out Vector256<T> result); 2345ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source)); 2346return Unsafe.ReadUnaligned<Vector256<T>>(in address); 2361ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 2362return Unsafe.ReadUnaligned<Vector256<T>>(in address); 2368internal static Vector256<ushort> LoadUnsafe(ref char source) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source)); 2374internal static Vector256<ushort> LoadUnsafe(ref char source, nuint elementOffset) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source), elementOffset); 3135Unsafe.SkipInit(out Vector256<byte> result); 3160Unsafe.SkipInit(out Vector256<sbyte> result); 3184Unsafe.SkipInit(out Vector256<short> result); 3209Unsafe.SkipInit(out Vector256<ushort> result); 3233Unsafe.SkipInit(out Vector256<int> result); 3258Unsafe.SkipInit(out Vector256<uint> result); 3282Unsafe.SkipInit(out Vector256<float> result); 3306Unsafe.SkipInit(out Vector256<long> result); 3331Unsafe.SkipInit(out Vector256<ulong> result); 3355Unsafe.SkipInit(out Vector256<double> result); 3524ref byte address = ref Unsafe.As<T, byte>(ref destination); 3525Unsafe.WriteUnaligned(ref address, source); 3540destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 3541Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source); 3611Unsafe.SkipInit(out Vector512<T> result); 3664Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 3999ref T address = ref Unsafe.As<Vector256<T>, T>(ref Unsafe.AsRef(in vector)); 4000return Unsafe.Add(ref address, index); 4007ref T address = ref Unsafe.As<Vector256<T>, T>(ref Unsafe.AsRef(in vector)); 4008Unsafe.Add(ref address, index) = value; 4011internal static void SetLowerUnsafe<T>(in this Vector256<T> vector, Vector128<T> value) => Unsafe.AsRef(in vector._lower) = value; 4013internal 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 (53)
165return Unsafe.BitCast<Vector512<TFrom>, Vector512<TTo>>(vector); 283Unsafe.WriteUnaligned(ref Unsafe.As<Vector512<T>, byte>(ref result), value); 299ref byte address = ref Unsafe.As<Vector512<T>, byte>(ref value); 300return Unsafe.ReadUnaligned<Vector<T>>(ref address); 596Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[0]), vector); 622Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[startIndex]), vector); 638Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 814return Unsafe.ReadUnaligned<Vector512<T>>(ref Unsafe.As<T, byte>(ref values[0])); 834return Unsafe.ReadUnaligned<Vector512<T>>(ref Unsafe.As<T, byte>(ref values[index])); 851return Unsafe.ReadUnaligned<Vector512<T>>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values))); 1294Unsafe.SkipInit(out Vector512<T> result); 1481Unsafe.SkipInit(out Vector512<T> result); 2387ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source)); 2388return Unsafe.ReadUnaligned<Vector512<T>>(in address); 2403ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 2404return Unsafe.ReadUnaligned<Vector512<T>>(in address); 2410internal static Vector512<ushort> LoadUnsafe(ref char source) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source)); 2416internal static Vector512<ushort> LoadUnsafe(ref char source, nuint elementOffset) => LoadUnsafe(ref Unsafe.As<char, ushort>(ref source), elementOffset); 3176Unsafe.SkipInit(out Vector512<byte> result); 3201Unsafe.SkipInit(out Vector512<sbyte> result); 3225Unsafe.SkipInit(out Vector512<short> result); 3250Unsafe.SkipInit(out Vector512<ushort> result); 3274Unsafe.SkipInit(out Vector512<int> result); 3299Unsafe.SkipInit(out Vector512<uint> result); 3323Unsafe.SkipInit(out Vector512<float> result); 3347Unsafe.SkipInit(out Vector512<long> result); 3372Unsafe.SkipInit(out Vector512<ulong> result); 3396Unsafe.SkipInit(out Vector512<double> result); 3551ref byte address = ref Unsafe.As<T, byte>(ref destination); 3552Unsafe.WriteUnaligned(ref address, source); 3567destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 3568Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source); 3657Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 3992ref T address = ref Unsafe.As<Vector512<T>, T>(ref Unsafe.AsRef(in vector)); 3993return Unsafe.Add(ref address, index); 4000ref T address = ref Unsafe.As<Vector512<T>, T>(ref Unsafe.AsRef(in vector)); 4001Unsafe.Add(ref address, index) = value; 4004internal static void SetLowerUnsafe<T>(in this Vector512<T> vector, Vector256<T> value) => Unsafe.AsRef(in vector._lower) = value; 4006internal 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 (123)
49Unsafe.SkipInit(out Vector64<T> result); 161return Unsafe.BitCast<Vector64<TFrom>, Vector64<TTo>>(vector); 306Unsafe.SkipInit(out Vector64<T> result); 367Unsafe.SkipInit(out Vector64<double> result); 386Unsafe.SkipInit(out Vector64<double> result); 404Unsafe.SkipInit(out Vector64<int> result); 422Unsafe.SkipInit(out Vector64<int> result); 440Unsafe.SkipInit(out Vector64<long> result); 458Unsafe.SkipInit(out Vector64<long> result); 476Unsafe.SkipInit(out Vector64<float> result); 495Unsafe.SkipInit(out Vector64<float> result); 514Unsafe.SkipInit(out Vector64<uint> result); 533Unsafe.SkipInit(out Vector64<uint> result); 552Unsafe.SkipInit(out Vector64<ulong> result); 571Unsafe.SkipInit(out Vector64<ulong> result); 601Unsafe.SkipInit(out Vector64<T> result); 630Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[0]), vector); 657Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination[startIndex]), vector); 674Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 680Unsafe.SkipInit(out Vector64<T> result); 771Unsafe.SkipInit(out Vector64<T> result); 881return Unsafe.ReadUnaligned<Vector64<T>>(ref Unsafe.As<T, byte>(ref values[0])); 902return Unsafe.ReadUnaligned<Vector64<T>>(ref Unsafe.As<T, byte>(ref values[index])); 919return Unsafe.ReadUnaligned<Vector64<T>>(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values))); 937Unsafe.SkipInit(out Vector64<byte> result); 960Unsafe.SkipInit(out Vector64<short> result); 977Unsafe.SkipInit(out Vector64<int> result); 999Unsafe.SkipInit(out Vector64<sbyte> result); 1019Unsafe.SkipInit(out Vector64<float> result); 1037Unsafe.SkipInit(out Vector64<ushort> result); 1055Unsafe.SkipInit(out Vector64<uint> result); 1165Unsafe.SkipInit(out Vector64<T> result); 1260Unsafe.SkipInit(out Vector64<T> result); 1341Unsafe.SkipInit(out Vector64<T> result); 1385Unsafe.SkipInit(out Vector64<T> result); 1478Unsafe.SkipInit(out Vector64<T> result); 1517Unsafe.SkipInit(out Vector64<double> result); 1541Unsafe.SkipInit(out Vector64<float> result); 1581Unsafe.SkipInit(out Vector64<T> result); 1644Unsafe.SkipInit(out Vector64<T> result); 1700Unsafe.SkipInit(out Vector64<T> result); 2032Unsafe.SkipInit(out Vector64<T> result); 2091Unsafe.SkipInit(out Vector64<T> result); 2154Unsafe.SkipInit(out Vector64<T> result); 2256ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source)); 2257return Unsafe.ReadUnaligned<Vector64<T>>(in address); 2272ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset)); 2273return Unsafe.ReadUnaligned<Vector64<T>>(in address); 2279Unsafe.SkipInit(out Vector64<T> result); 2325Unsafe.SkipInit(out Vector64<T> result); 2379Unsafe.SkipInit(out Vector64<T> result); 2402Unsafe.SkipInit(out Vector64<T> result); 2425Unsafe.SkipInit(out Vector64<T> result); 2448Unsafe.SkipInit(out Vector64<T> result); 2471Unsafe.SkipInit(out Vector64<T> result); 2494Unsafe.SkipInit(out Vector64<T> result); 2517Unsafe.SkipInit(out Vector64<T> result); 2540Unsafe.SkipInit(out Vector64<T> result); 2563Unsafe.SkipInit(out Vector64<T> result); 2586Unsafe.SkipInit(out Vector64<T> result); 2629Unsafe.SkipInit(out Vector64<T> result); 2653Unsafe.SkipInit(out Vector64<double> result); 2677Unsafe.SkipInit(out Vector64<float> result); 2696Unsafe.SkipInit(out Vector64<float> result); 2722Unsafe.SkipInit(out Vector64<sbyte> result); 2747Unsafe.SkipInit(out Vector64<short> result); 2772Unsafe.SkipInit(out Vector64<int> result); 2798Unsafe.SkipInit(out Vector64<byte> result); 2824Unsafe.SkipInit(out Vector64<ushort> result); 2850Unsafe.SkipInit(out Vector64<uint> result); 2919Unsafe.SkipInit(out Vector64<T> result); 2983Unsafe.SkipInit(out Vector64<T> result); 3094Unsafe.SkipInit(out Vector64<uint> result); 3116Unsafe.SkipInit(out Vector64<ulong> result); 3259Unsafe.SkipInit(out Vector64<byte> result); 3284Unsafe.SkipInit(out Vector64<sbyte> result); 3308Unsafe.SkipInit(out Vector64<short> result); 3333Unsafe.SkipInit(out Vector64<ushort> result); 3357Unsafe.SkipInit(out Vector64<int> result); 3382Unsafe.SkipInit(out Vector64<uint> result); 3406Unsafe.SkipInit(out Vector64<float> result); 3426Unsafe.SkipInit(out Vector64<T> result); 3479Unsafe.SkipInit(out Vector64<T> sinResult); 3480Unsafe.SkipInit(out Vector64<T> cosResult); 3540Unsafe.SkipInit(out Vector64<T> result); 3600ref byte address = ref Unsafe.As<T, byte>(ref destination); 3601Unsafe.WriteUnaligned(ref address, source); 3616destination = ref Unsafe.Add(ref destination, (nint)elementOffset); 3617Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source); 3690Unsafe.SkipInit(out Vector128<T> result); 3714Unsafe.SkipInit(out Vector64<T> result); 3748Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination)), vector); 3806Unsafe.SkipInit(out Vector64<ushort> lower); 3824Unsafe.SkipInit(out Vector64<int> lower); 3842Unsafe.SkipInit(out Vector64<long> lower); 3861Unsafe.SkipInit(out Vector64<short> lower); 3879Unsafe.SkipInit(out Vector64<double> lower); 3898Unsafe.SkipInit(out Vector64<uint> lower); 3917Unsafe.SkipInit(out Vector64<ulong> lower); 3936Unsafe.SkipInit(out Vector64<ushort> upper); 3954Unsafe.SkipInit(out Vector64<int> upper); 3972Unsafe.SkipInit(out Vector64<long> upper); 3991Unsafe.SkipInit(out Vector64<short> upper); 4009Unsafe.SkipInit(out Vector64<double> upper); 4028Unsafe.SkipInit(out Vector64<uint> upper); 4047Unsafe.SkipInit(out Vector64<ulong> upper); 4093ref T address = ref Unsafe.As<Vector64<T>, T>(ref Unsafe.AsRef(in vector)); 4094return Unsafe.Add(ref address, index); 4101ref T address = ref Unsafe.As<Vector64<T>, T>(ref Unsafe.AsRef(in vector)); 4102Unsafe.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)
80Unsafe.Add(ref Unsafe.As<uint, byte>(ref charMap), value & VectorizedIndexMask) |= (byte)(1u << (value >> VectorizedIndexShift)); 84Unsafe.Add(ref charMap, value & PortableIndexMask) |= 1u << (value >> PortableIndexShift); 90? (Unsafe.Add(ref Unsafe.As<uint, byte>(ref charMap), value & VectorizedIndexMask) & (1u << (value >> VectorizedIndexShift))) != 0 91: (Unsafe.Add(ref charMap, value & PortableIndexMask) & (1u << (value >> PortableIndexShift))) != 0; 102ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(values)), 420ref char searchSpaceEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 422Vector256<byte> charMap256 = Vector256.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map)); 431ref char lastStartVector = ref Unsafe.Subtract(ref searchSpaceEnd, 64); 435Vector512<byte> result = ContainsMask64CharsAvx512(charMap512, ref cur, ref Unsafe.Add(ref cur, Vector512<ushort>.Count)); 445cur = ref Unsafe.Add(ref cur, 64); 447if (Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVector)) 449if (Unsafe.AreSame(ref cur, ref searchSpaceEnd)) 465Vector512<byte> result = ContainsMask64CharsAvx512(charMap512, ref searchSpace, ref Unsafe.Subtract(ref searchSpaceEnd, Vector512<ushort>.Count)); 482Vector256<byte> result = ContainsMask32CharsAvx512(charMap256, ref searchSpace, ref Unsafe.Subtract(ref searchSpaceEnd, Vector256<ushort>.Count)); 504ref char searchSpaceEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 507Vector128<byte> charMapLower = Vector128.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map)); 508Vector128<byte> charMapUpper = Vector128.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map), (nuint)Vector128<byte>.Count); 517ref char lastStartVectorAvx2 = ref Unsafe.Subtract(ref searchSpaceEnd, 32); 531cur = ref Unsafe.Add(ref cur, 32); 533if (Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVectorAvx2)) 535if (Unsafe.AreSame(ref cur, ref searchSpaceEnd)) 540if (Unsafe.ByteOffset(ref cur, ref searchSpaceEnd) > 16 * sizeof(char)) 550cur = ref Unsafe.Subtract(ref searchSpaceEnd, 16); 557ref char lastStartVector = ref Unsafe.Subtract(ref searchSpaceEnd, 16); 571cur = ref Unsafe.Add(ref cur, 16); 573if (Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVector)) 575if (Unsafe.AreSame(ref cur, ref searchSpaceEnd)) 595ref char cur = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 597Vector256<byte> charMap256 = Vector256.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map)); 605ref char lastStartVector = ref Unsafe.Add(ref searchSpace, 64); 609Debug.Assert(Unsafe.ByteOffset(ref searchSpace, ref cur) >= 64 * sizeof(char)); 611cur = ref Unsafe.Subtract(ref cur, 64); 613Vector512<byte> result = ContainsMask64CharsAvx512(charMap512, ref cur, ref Unsafe.Add(ref cur, Vector512<ushort>.Count)); 623if (!Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVector)) 625if (Unsafe.AreSame(ref cur, ref searchSpace)) 638Debug.Assert(Unsafe.ByteOffset(ref searchSpace, ref cur) >= 32 * sizeof(char)); 642Vector512<byte> result = ContainsMask64CharsAvx512(charMap512, ref searchSpace, ref Unsafe.Subtract(ref cur, Vector512<ushort>.Count)); 656Debug.Assert(Unsafe.ByteOffset(ref searchSpace, ref cur) >= 16 * sizeof(char)); 660Vector256<byte> result = ContainsMask32CharsAvx512(charMap256, ref searchSpace, ref Unsafe.Subtract(ref cur, Vector256<ushort>.Count)); 682ref char cur = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 684Vector128<byte> charMapLower = Vector128.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map)); 685Vector128<byte> charMapUpper = Vector128.LoadUnsafe(ref Unsafe.As<ProbabilisticMap, byte>(ref state.Map), (nuint)Vector128<byte>.Count); 694ref char lastStartVectorAvx2 = ref Unsafe.Add(ref searchSpace, 32); 698Debug.Assert(Unsafe.ByteOffset(ref searchSpace, ref cur) >= 32 * sizeof(char)); 700cur = ref Unsafe.Subtract(ref cur, 32); 712if (!Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVectorAvx2)) 714if (Unsafe.AreSame(ref cur, ref searchSpace)) 719if (Unsafe.ByteOffset(ref searchSpace, ref cur) > 16 * sizeof(char)) 729cur = ref Unsafe.Add(ref searchSpace, 16); 736ref char lastStartVector = ref Unsafe.Add(ref searchSpace, 16); 740Debug.Assert(Unsafe.ByteOffset(ref searchSpace, ref cur) >= 16 * sizeof(char)); 742cur = ref Unsafe.Subtract(ref cur, 16); 754if (!Unsafe.IsAddressGreaterThan(ref cur, ref lastStartVector)) 756if (Unsafe.AreSame(ref cur, ref searchSpace)) 771(int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref cur) / sizeof(char)); 781if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 809if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 830if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 858if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 879if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 911if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 930if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 962if (state.ConfirmProbabilisticMatch<TUseFastContains>(Unsafe.Add(ref cur, index))) 977ref char searchSpaceEnd = ref Unsafe.Add(ref searchSpace, searchSpaceLength); 980while (!Unsafe.AreSame(ref cur, ref searchSpaceEnd)) 988cur = ref Unsafe.Add(ref cur, 1); 1000char 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 (6)
45ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(span)), 46Unsafe.As<char, ushort>(ref _lowInclusive), 47Unsafe.As<char, ushort>(ref _highInclusive), 55ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(span)), 56Unsafe.As<char, ushort>(ref _lowInclusive), 57Unsafe.As<char, ushort>(ref _highInclusive),
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 (28)
30nint currentByteOffset = Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref searchSpace); 74if (TCaseSensitivity.TransformInput(Unsafe.Add(ref matchStart, i)) != candidate[i]) 138ref byte first = ref Unsafe.As<char, byte>(ref matchStart); 139ref byte second = ref Unsafe.As<char, byte>(ref candidate.GetRawStringData()); 152ulong differentBits = Unsafe.ReadUnaligned<ulong>(ref first) - Unsafe.ReadUnaligned<ulong>(ref second); 153differentBits |= Unsafe.ReadUnaligned<ulong>(ref Unsafe.Add(ref first, offset)) - Unsafe.ReadUnaligned<ulong>(ref Unsafe.Add(ref second, offset)); 164return Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref first, offset)) 165== Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref second, offset)); 198ref byte first = ref Unsafe.As<char, byte>(ref matchStart); 199ref byte second = ref Unsafe.As<char, byte>(ref candidate.GetRawStringData()); 206ulong differentBits = (Unsafe.ReadUnaligned<ulong>(ref first) & CaseMask) - Unsafe.ReadUnaligned<ulong>(ref second); 207differentBits |= (Unsafe.ReadUnaligned<ulong>(ref Unsafe.Add(ref first, offset)) & CaseMask) - Unsafe.ReadUnaligned<ulong>(ref Unsafe.Add(ref second, offset)); 214uint differentBits = (Unsafe.ReadUnaligned<uint>(ref first) & CaseMask) - Unsafe.ReadUnaligned<uint>(ref second); 215differentBits |= (Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref first, offset)) & CaseMask) - Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref second, offset));
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\SingleStringSearchValuesThreeChars.cs (32)
98ref char lastSearchSpace = ref Unsafe.Add(ref searchSpace, searchSpaceMinusValueTailLength - Vector512<ushort>.Count); 116searchSpace = ref Unsafe.Add(ref searchSpace, Vector512<ushort>.Count); 118if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpace)) 120if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpace, Vector512<ushort>.Count))) 146ref char lastSearchSpace = ref Unsafe.Add(ref searchSpace, searchSpaceMinusValueTailLength - Vector256<ushort>.Count); 163searchSpace = ref Unsafe.Add(ref searchSpace, Vector256<ushort>.Count); 165if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpace)) 167if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpace, Vector256<ushort>.Count))) 193ref char lastSearchSpace = ref Unsafe.Add(ref searchSpace, searchSpaceMinusValueTailLength - Vector128<ushort>.Count); 210searchSpace = ref Unsafe.Add(ref searchSpace, Vector128<ushort>.Count); 212if (Unsafe.IsAddressGreaterThan(ref searchSpace, ref lastSearchSpace)) 214if (Unsafe.AreSame(ref searchSpace, ref Unsafe.Add(ref lastSearchSpace, Vector128<ushort>.Count))) 241ref char cur = ref Unsafe.Add(ref searchSpace, i); 262Vector128<ushort> cmpCh2 = Vector128.Equals(ch2, Vector128.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16()); 263Vector128<ushort> cmpCh3 = Vector128.Equals(ch3, Vector128.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16()); 275Vector128<ushort> cmpCh2 = Vector128.Equals(ch2, Vector128.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16() & caseConversion); 276Vector128<ushort> cmpCh3 = Vector128.Equals(ch3, Vector128.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16() & caseConversion); 290Vector256<ushort> cmpCh2 = Vector256.Equals(ch2, Vector256.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16()); 291Vector256<ushort> cmpCh3 = Vector256.Equals(ch3, Vector256.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16()); 299Vector256<ushort> cmpCh2 = Vector256.Equals(ch2, Vector256.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16() & caseConversion); 300Vector256<ushort> cmpCh3 = Vector256.Equals(ch3, Vector256.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16() & caseConversion); 313Vector512<ushort> cmpCh2 = Vector512.Equals(ch2, Vector512.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16()); 314Vector512<ushort> cmpCh3 = Vector512.Equals(ch3, Vector512.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16()); 322Vector512<ushort> cmpCh2 = Vector512.Equals(ch2, Vector512.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch2ByteOffset).AsUInt16() & caseConversion); 323Vector512<ushort> cmpCh3 = Vector512.Equals(ch3, Vector512.LoadUnsafe(ref Unsafe.As<char, byte>(ref searchSpace), ch3ByteOffset).AsUInt16() & caseConversion); 338ref char matchRef = ref Unsafe.AddByteOffset(ref searchSpace, bitPos); 344offsetFromStart = (int)((nuint)Unsafe.ByteOffset(ref searchSpaceStart, ref matchRef) / 2); 366ref char matchRef = ref Unsafe.AddByteOffset(ref searchSpace, bitPos); 372offsetFromStart = (int)((nuint)Unsafe.ByteOffset(ref searchSpaceStart, ref matchRef) / 2);
src\libraries\System.Private.CoreLib\src\System\Span.cs (9)
86_reference = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)start /* force zero-extension */); 153return ref Unsafe.Add(ref _reference, (nint)(uint)index /* force zero-extension */); 271ref T ret = ref Unsafe.NullRef<T>(); 284SpanHelpers.ClearWithReferences(ref Unsafe.As<T, IntPtr>(ref _reference), (uint)_length * (nuint)(sizeof(T) / sizeof(nuint))); 288SpanHelpers.ClearWithoutReferences(ref Unsafe.As<T, byte>(ref _reference), (uint)_length * (nuint)sizeof(T)); 352Unsafe.AreSame(ref left._reference, ref right._reference); 368return new string(new ReadOnlySpan<char>(ref Unsafe.As<T, char>(ref _reference), _length)); 386return new Span<T>(ref Unsafe.Add(ref _reference, (nint)(uint)start /* force zero-extension */), _length - start); 414return 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 (415)
37vector = new Vector<byte>(Unsafe.As<T, byte>(ref tmp)); 41vector = (Vector<byte>)(new Vector<ushort>(Unsafe.As<T, ushort>(ref tmp))); 48: (Vector<byte>)(new Vector<uint>(Unsafe.As<T, uint>(ref tmp))); 55: (Vector<byte>)(new Vector<ulong>(Unsafe.As<T, ulong>(ref tmp))); 59Vector128<byte> vec128 = Unsafe.As<T, Vector128<byte>>(ref tmp); 78vector = Unsafe.As<T, Vector256<byte>>(ref tmp).AsVector(); 92ref byte refDataAsBytes = ref Unsafe.As<T, byte>(ref refData); 105Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref refDataAsBytes, offset), vector); 106Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref refDataAsBytes, offset + (nuint)Vector<byte>.Count), vector); 119Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref refDataAsBytes, offset), vector); 129Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref refDataAsBytes, totalByteLength - (nuint)Vector<byte>.Count), vector); 150Unsafe.Add(ref refData, (nint)i + 0) = value; 151Unsafe.Add(ref refData, (nint)i + 1) = value; 152Unsafe.Add(ref refData, (nint)i + 2) = value; 153Unsafe.Add(ref refData, (nint)i + 3) = value; 154Unsafe.Add(ref refData, (nint)i + 4) = value; 155Unsafe.Add(ref refData, (nint)i + 5) = value; 156Unsafe.Add(ref refData, (nint)i + 6) = value; 157Unsafe.Add(ref refData, (nint)i + 7) = value; 165Unsafe.Add(ref refData, (nint)i + 0) = value; 166Unsafe.Add(ref refData, (nint)i + 1) = value; 167Unsafe.Add(ref refData, (nint)i + 2) = value; 168Unsafe.Add(ref refData, (nint)i + 3) = value; 176Unsafe.Add(ref refData, (nint)i + 0) = value; 177Unsafe.Add(ref refData, (nint)i + 1) = value; 185Unsafe.Add(ref refData, (nint)i) = value; 198ref T valueTail = ref Unsafe.Add(ref value, 1); 210int relativeIndex = IndexOf(ref Unsafe.Add(ref searchSpace, index), valueHead, remainingSearchSpaceLength); 216if (SequenceEqual(ref Unsafe.Add(ref searchSpace, index + 1), ref valueTail, valueTailLength)) 239if (value.Equals(Unsafe.Add(ref searchSpace, index + 0)) || 240value.Equals(Unsafe.Add(ref searchSpace, index + 1)) || 241value.Equals(Unsafe.Add(ref searchSpace, index + 2)) || 242value.Equals(Unsafe.Add(ref searchSpace, index + 3)) || 243value.Equals(Unsafe.Add(ref searchSpace, index + 4)) || 244value.Equals(Unsafe.Add(ref searchSpace, index + 5)) || 245value.Equals(Unsafe.Add(ref searchSpace, index + 6)) || 246value.Equals(Unsafe.Add(ref searchSpace, index + 7))) 258if (value.Equals(Unsafe.Add(ref searchSpace, index + 0)) || 259value.Equals(Unsafe.Add(ref searchSpace, index + 1)) || 260value.Equals(Unsafe.Add(ref searchSpace, index + 2)) || 261value.Equals(Unsafe.Add(ref searchSpace, index + 3))) 273if (value.Equals(Unsafe.Add(ref searchSpace, index))) 284if ((object?)Unsafe.Add(ref searchSpace, index) is null) 310if (value.Equals(Unsafe.Add(ref searchSpace, index))) 312if (value.Equals(Unsafe.Add(ref searchSpace, index + 1))) 314if (value.Equals(Unsafe.Add(ref searchSpace, index + 2))) 316if (value.Equals(Unsafe.Add(ref searchSpace, index + 3))) 318if (value.Equals(Unsafe.Add(ref searchSpace, index + 4))) 320if (value.Equals(Unsafe.Add(ref searchSpace, index + 5))) 322if (value.Equals(Unsafe.Add(ref searchSpace, index + 6))) 324if (value.Equals(Unsafe.Add(ref searchSpace, index + 7))) 334if (value.Equals(Unsafe.Add(ref searchSpace, index))) 336if (value.Equals(Unsafe.Add(ref searchSpace, index + 1))) 338if (value.Equals(Unsafe.Add(ref searchSpace, index + 2))) 340if (value.Equals(Unsafe.Add(ref searchSpace, index + 3))) 348if (value.Equals(Unsafe.Add(ref searchSpace, index))) 360if ((object?)Unsafe.Add(ref searchSpace, index) is null) 398lookUp = Unsafe.Add(ref searchSpace, index); 401lookUp = Unsafe.Add(ref searchSpace, index + 1); 404lookUp = Unsafe.Add(ref searchSpace, index + 2); 407lookUp = Unsafe.Add(ref searchSpace, index + 3); 410lookUp = Unsafe.Add(ref searchSpace, index + 4); 413lookUp = Unsafe.Add(ref searchSpace, index + 5); 416lookUp = Unsafe.Add(ref searchSpace, index + 6); 419lookUp = Unsafe.Add(ref searchSpace, index + 7); 428lookUp = Unsafe.Add(ref searchSpace, index); 431lookUp = Unsafe.Add(ref searchSpace, index + 1); 434lookUp = Unsafe.Add(ref searchSpace, index + 2); 437lookUp = Unsafe.Add(ref searchSpace, index + 3); 446lookUp = Unsafe.Add(ref searchSpace, index); 457lookUp = Unsafe.Add(ref searchSpace, index); 504lookUp = Unsafe.Add(ref searchSpace, index); 507lookUp = Unsafe.Add(ref searchSpace, index + 1); 510lookUp = Unsafe.Add(ref searchSpace, index + 2); 513lookUp = Unsafe.Add(ref searchSpace, index + 3); 516lookUp = Unsafe.Add(ref searchSpace, index + 4); 519lookUp = Unsafe.Add(ref searchSpace, index + 5); 522lookUp = Unsafe.Add(ref searchSpace, index + 6); 525lookUp = Unsafe.Add(ref searchSpace, index + 7); 534lookUp = Unsafe.Add(ref searchSpace, index); 537lookUp = Unsafe.Add(ref searchSpace, index + 1); 540lookUp = Unsafe.Add(ref searchSpace, index + 2); 543lookUp = Unsafe.Add(ref searchSpace, index + 3); 552lookUp = Unsafe.Add(ref searchSpace, index); 563lookUp = Unsafe.Add(ref searchSpace, index); 624T candidate = Unsafe.Add(ref searchSpace, i); 627if (Unsafe.Add(ref value, j)!.Equals(candidate)) 641T candidate = Unsafe.Add(ref searchSpace, i); 646if (candidate.Equals(Unsafe.Add(ref value, j))) 656if (Unsafe.Add(ref value, j) is null) 685ref T valueTail = ref Unsafe.Add(ref value, 1); 700if (SequenceEqual(ref Unsafe.Add(ref searchSpace, relativeIndex + 1), ref valueTail, valueTailLength)) 720if (value.Equals(Unsafe.Add(ref searchSpace, length + 7))) 722if (value.Equals(Unsafe.Add(ref searchSpace, length + 6))) 724if (value.Equals(Unsafe.Add(ref searchSpace, length + 5))) 726if (value.Equals(Unsafe.Add(ref searchSpace, length + 4))) 728if (value.Equals(Unsafe.Add(ref searchSpace, length + 3))) 730if (value.Equals(Unsafe.Add(ref searchSpace, length + 2))) 732if (value.Equals(Unsafe.Add(ref searchSpace, length + 1))) 734if (value.Equals(Unsafe.Add(ref searchSpace, length))) 742if (value.Equals(Unsafe.Add(ref searchSpace, length + 3))) 744if (value.Equals(Unsafe.Add(ref searchSpace, length + 2))) 746if (value.Equals(Unsafe.Add(ref searchSpace, length + 1))) 748if (value.Equals(Unsafe.Add(ref searchSpace, length))) 756if (value.Equals(Unsafe.Add(ref searchSpace, length))) 764if ((object?)Unsafe.Add(ref searchSpace, length) is null) 804lookUp = Unsafe.Add(ref searchSpace, length + 7); 807lookUp = Unsafe.Add(ref searchSpace, length + 6); 810lookUp = Unsafe.Add(ref searchSpace, length + 5); 813lookUp = Unsafe.Add(ref searchSpace, length + 4); 816lookUp = Unsafe.Add(ref searchSpace, length + 3); 819lookUp = Unsafe.Add(ref searchSpace, length + 2); 822lookUp = Unsafe.Add(ref searchSpace, length + 1); 825lookUp = Unsafe.Add(ref searchSpace, length); 834lookUp = Unsafe.Add(ref searchSpace, length + 3); 837lookUp = Unsafe.Add(ref searchSpace, length + 2); 840lookUp = Unsafe.Add(ref searchSpace, length + 1); 843lookUp = Unsafe.Add(ref searchSpace, length); 852lookUp = Unsafe.Add(ref searchSpace, length); 861lookUp = Unsafe.Add(ref searchSpace, length); 909lookUp = Unsafe.Add(ref searchSpace, length + 7); 912lookUp = Unsafe.Add(ref searchSpace, length + 6); 915lookUp = Unsafe.Add(ref searchSpace, length + 5); 918lookUp = Unsafe.Add(ref searchSpace, length + 4); 921lookUp = Unsafe.Add(ref searchSpace, length + 3); 924lookUp = Unsafe.Add(ref searchSpace, length + 2); 927lookUp = Unsafe.Add(ref searchSpace, length + 1); 930lookUp = Unsafe.Add(ref searchSpace, length); 939lookUp = Unsafe.Add(ref searchSpace, length + 3); 942lookUp = Unsafe.Add(ref searchSpace, length + 2); 945lookUp = Unsafe.Add(ref searchSpace, length + 1); 948lookUp = Unsafe.Add(ref searchSpace, length); 957lookUp = Unsafe.Add(ref searchSpace, length); 966lookUp = Unsafe.Add(ref searchSpace, length); 1016T candidate = Unsafe.Add(ref searchSpace, i); 1019if (Unsafe.Add(ref value, j)!.Equals(candidate)) 1030T candidate = Unsafe.Add(ref searchSpace, i); 1035if (candidate.Equals(Unsafe.Add(ref value, j))) 1045if (Unsafe.Add(ref value, j) is null) 1063if (!EqualityComparer<T>.Default.Equals(Unsafe.Add(ref searchSpace, i), value0)) 1078if (!EqualityComparer<T>.Default.Equals(Unsafe.Add(ref searchSpace, i), value0)) 1093ref T current = ref Unsafe.Add(ref searchSpace, i); 1109ref T current = ref Unsafe.Add(ref searchSpace, i); 1125ref T current = ref Unsafe.Add(ref searchSpace, i); 1143ref T current = ref Unsafe.Add(ref searchSpace, i); 1161ref T current = ref Unsafe.Add(ref searchSpace, i); 1180ref T current = ref Unsafe.Add(ref searchSpace, i); 1197if (Unsafe.AreSame(ref first, ref second)) 1207lookUp0 = Unsafe.Add(ref first, index); 1208lookUp1 = Unsafe.Add(ref second, index); 1211lookUp0 = Unsafe.Add(ref first, index + 1); 1212lookUp1 = Unsafe.Add(ref second, index + 1); 1215lookUp0 = Unsafe.Add(ref first, index + 2); 1216lookUp1 = Unsafe.Add(ref second, index + 2); 1219lookUp0 = Unsafe.Add(ref first, index + 3); 1220lookUp1 = Unsafe.Add(ref second, index + 3); 1223lookUp0 = Unsafe.Add(ref first, index + 4); 1224lookUp1 = Unsafe.Add(ref second, index + 4); 1227lookUp0 = Unsafe.Add(ref first, index + 5); 1228lookUp1 = Unsafe.Add(ref second, index + 5); 1231lookUp0 = Unsafe.Add(ref first, index + 6); 1232lookUp1 = Unsafe.Add(ref second, index + 6); 1235lookUp0 = Unsafe.Add(ref first, index + 7); 1236lookUp1 = Unsafe.Add(ref second, index + 7); 1247lookUp0 = Unsafe.Add(ref first, index); 1248lookUp1 = Unsafe.Add(ref second, index); 1251lookUp0 = Unsafe.Add(ref first, index + 1); 1252lookUp1 = Unsafe.Add(ref second, index + 1); 1255lookUp0 = Unsafe.Add(ref first, index + 2); 1256lookUp1 = Unsafe.Add(ref second, index + 2); 1259lookUp0 = Unsafe.Add(ref first, index + 3); 1260lookUp1 = Unsafe.Add(ref second, index + 3); 1269lookUp0 = Unsafe.Add(ref first, index); 1270lookUp1 = Unsafe.Add(ref second, index); 1295T lookUp = Unsafe.Add(ref second, i); 1296int result = (Unsafe.Add(ref first, i)?.CompareTo(lookUp) ?? (((object?)lookUp is null) ? 0 : -1)); 1308return PackedSpanHelpers.Contains(ref Unsafe.As<T, short>(ref searchSpace), Unsafe.BitCast<T, short>(value), length); 1327if (Unsafe.Add(ref searchSpace, offset) == value 1328|| Unsafe.Add(ref searchSpace, offset + 1) == value 1329|| Unsafe.Add(ref searchSpace, offset + 2) == value 1330|| Unsafe.Add(ref searchSpace, offset + 3) == value 1331|| Unsafe.Add(ref searchSpace, offset + 4) == value 1332|| Unsafe.Add(ref searchSpace, offset + 5) == value 1333|| Unsafe.Add(ref searchSpace, offset + 6) == value 1334|| Unsafe.Add(ref searchSpace, offset + 7) == value) 1346if (Unsafe.Add(ref searchSpace, offset) == value 1347|| Unsafe.Add(ref searchSpace, offset + 1) == value 1348|| Unsafe.Add(ref searchSpace, offset + 2) == value 1349|| Unsafe.Add(ref searchSpace, offset + 3) == value) 1361if (Unsafe.Add(ref searchSpace, offset) == value) return true; 1370ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector512<T>.Count)); 1382currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<T>.Count); 1384while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1401ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector256<T>.Count)); 1409currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<T>.Count); 1415while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1431ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector128<T>.Count)); 1439currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<T>.Count); 1445while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1463=> IndexOfValueType(ref Unsafe.As<char, short>(ref searchSpace), (short)value, length); 1467NonPackedIndexOfValueType<short, DontNegate<short>>(ref Unsafe.As<char, short>(ref searchSpace), (short)value, length); 1485? PackedSpanHelpers.IndexOf(ref Unsafe.As<TValue, char>(ref searchSpace), Unsafe.BitCast<TValue, char>(value), length) 1486: PackedSpanHelpers.IndexOfAnyExcept(ref Unsafe.As<TValue, char>(ref searchSpace), Unsafe.BitCast<TValue, char>(value), length); 1507if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 1508if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 1) == value)) goto Found1; 1509if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 2) == value)) goto Found2; 1510if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 3) == value)) goto Found3; 1511if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 4) == value)) goto Found4; 1512if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 5) == value)) goto Found5; 1513if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 6) == value)) goto Found6; 1514if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 7) == value)) goto Found7; 1523if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 1524if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 1) == value)) goto Found1; 1525if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 2) == value)) goto Found2; 1526if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset + 3) == value)) goto Found3; 1535if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 1561ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<TValue>.Count); 1573currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<TValue>.Count); 1575while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1592ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<TValue>.Count); 1600currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<TValue>.Count); 1606while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1622ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<TValue>.Count); 1630currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<TValue>.Count); 1636while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1654=> IndexOfAnyValueType(ref Unsafe.As<char, short>(ref searchSpace), (short)value0, (short)value1, length); 1671char char0 = Unsafe.BitCast<TValue, char>(value0); 1672char char1 = Unsafe.BitCast<TValue, char>(value1); 1684? PackedSpanHelpers.IndexOfAnyIgnoreCase(ref Unsafe.As<TValue, char>(ref searchSpace), lowerCase, length) 1685: PackedSpanHelpers.IndexOfAnyExceptIgnoreCase(ref Unsafe.As<TValue, char>(ref searchSpace), lowerCase, length); 1690? PackedSpanHelpers.IndexOfAny(ref Unsafe.As<TValue, char>(ref searchSpace), char0, char1, length) 1691: PackedSpanHelpers.IndexOfAnyExcept(ref Unsafe.As<TValue, char>(ref searchSpace), char0, char1, length); 1716ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 1719lookUp = Unsafe.Add(ref current, 1); 1721lookUp = Unsafe.Add(ref current, 2); 1723lookUp = Unsafe.Add(ref current, 3); 1725lookUp = Unsafe.Add(ref current, 4); 1727lookUp = Unsafe.Add(ref current, 5); 1729lookUp = Unsafe.Add(ref current, 6); 1731lookUp = Unsafe.Add(ref current, 7); 1742ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 1745lookUp = Unsafe.Add(ref current, 1); 1747lookUp = Unsafe.Add(ref current, 2); 1749lookUp = Unsafe.Add(ref current, 3); 1759lookUp = Unsafe.Add(ref searchSpace, offset); 1786ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<TValue>.Count); 1795currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<TValue>.Count); 1801while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1818ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<TValue>.Count); 1827currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<TValue>.Count); 1833while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1850ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<TValue>.Count); 1859currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<TValue>.Count); 1865while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 1898? 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) 1899: 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); 1923ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 1926lookUp = Unsafe.Add(ref current, 1); 1928lookUp = Unsafe.Add(ref current, 2); 1930lookUp = Unsafe.Add(ref current, 3); 1932lookUp = Unsafe.Add(ref current, 4); 1934lookUp = Unsafe.Add(ref current, 5); 1936lookUp = Unsafe.Add(ref current, 6); 1938lookUp = Unsafe.Add(ref current, 7); 1949ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 1952lookUp = Unsafe.Add(ref current, 1); 1954lookUp = Unsafe.Add(ref current, 2); 1956lookUp = Unsafe.Add(ref current, 3); 1966lookUp = Unsafe.Add(ref searchSpace, offset); 1993ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<TValue>.Count); 2002currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<TValue>.Count); 2008while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2025ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<TValue>.Count); 2034currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<TValue>.Count); 2040while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2057ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<TValue>.Count); 2066currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<TValue>.Count); 2072while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2113ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2116lookUp = Unsafe.Add(ref current, 1); 2118lookUp = Unsafe.Add(ref current, 2); 2120lookUp = Unsafe.Add(ref current, 3); 2130lookUp = Unsafe.Add(ref searchSpace, offset); 2149ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector512<TValue>.Count); 2159currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<TValue>.Count); 2165while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2183ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector256<TValue>.Count); 2193currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<TValue>.Count); 2199while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2217ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, length - Vector128<TValue>.Count); 2227currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<TValue>.Count); 2233while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2275ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2278lookUp = Unsafe.Add(ref current, 1); 2280lookUp = Unsafe.Add(ref current, 2); 2282lookUp = Unsafe.Add(ref current, 3); 2292lookUp = Unsafe.Add(ref searchSpace, offset); 2313ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector512<TValue>.Count)); 2323currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector512<TValue>.Count); 2329while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2348ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector256<TValue>.Count)); 2358currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector256<TValue>.Count); 2364while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2383ref TValue oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector128<TValue>.Count)); 2393currentSearchSpace = ref Unsafe.Add(ref currentSearchSpace, Vector128<TValue>.Count); 2399while (!Unsafe.IsAddressGreaterThan(ref currentSearchSpace, ref oneVectorAwayFromEnd)); 2440if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 2441if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 1) == value)) goto FoundM1; 2442if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 2) == value)) goto FoundM2; 2443if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 3) == value)) goto FoundM3; 2444if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 4) == value)) goto FoundM4; 2445if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 5) == value)) goto FoundM5; 2446if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 6) == value)) goto FoundM6; 2447if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 7) == value)) goto FoundM7; 2456if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 2457if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 1) == value)) goto FoundM1; 2458if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 2) == value)) goto FoundM2; 2459if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset - 3) == value)) goto FoundM3; 2468if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) goto Found; 2563ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2566lookUp = Unsafe.Add(ref current, -1); 2568lookUp = Unsafe.Add(ref current, -2); 2570lookUp = Unsafe.Add(ref current, -3); 2572lookUp = Unsafe.Add(ref current, -4); 2574lookUp = Unsafe.Add(ref current, -5); 2576lookUp = Unsafe.Add(ref current, -6); 2578lookUp = Unsafe.Add(ref current, -7); 2589ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2592lookUp = Unsafe.Add(ref current, -1); 2594lookUp = Unsafe.Add(ref current, -2); 2596lookUp = Unsafe.Add(ref current, -3); 2606lookUp = Unsafe.Add(ref searchSpace, offset); 2748ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2751lookUp = Unsafe.Add(ref current, -1); 2753lookUp = Unsafe.Add(ref current, -2); 2755lookUp = Unsafe.Add(ref current, -3); 2757lookUp = Unsafe.Add(ref current, -4); 2759lookUp = Unsafe.Add(ref current, -5); 2761lookUp = Unsafe.Add(ref current, -6); 2763lookUp = Unsafe.Add(ref current, -7); 2774ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2777lookUp = Unsafe.Add(ref current, -1); 2779lookUp = Unsafe.Add(ref current, -2); 2781lookUp = Unsafe.Add(ref current, -3); 2791lookUp = Unsafe.Add(ref searchSpace, offset); 2932ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 2935lookUp = Unsafe.Add(ref current, -1); 2937lookUp = Unsafe.Add(ref current, -2); 2939lookUp = Unsafe.Add(ref current, -3); 2949lookUp = Unsafe.Add(ref searchSpace, offset); 3066T original = Unsafe.Add(ref src, idx); 3067Unsafe.Add(ref dst, idx) = oldValue.Equals(original) ? newValue : original; 3074T original = Unsafe.Add(ref src, idx); 3075Unsafe.Add(ref dst, idx) = original is null ? newValue : original; 3086T original = Unsafe.Add(ref src, idx); 3087Unsafe.Add(ref dst, idx) = EqualityComparer<T>.Default.Equals(original, oldValue) ? newValue : original; 3199ref TValue current = ref Unsafe.Add(ref searchSpace, offset); 3202lookUp = Unsafe.Add(ref current, -1); 3204lookUp = Unsafe.Add(ref current, -2); 3206lookUp = Unsafe.Add(ref current, -3); 3216lookUp = Unsafe.Add(ref searchSpace, offset); 3328return index + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / (nuint)sizeof(T)); 3336return index + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / (nuint)sizeof(T)); 3344return index + (int)((nuint)Unsafe.ByteOffset(ref searchSpace, ref current) / (nuint)sizeof(T)); 3441ref T current = ref Unsafe.Add(ref searchSpace, i); 3456ref T current = ref Unsafe.Add(ref searchSpace, i); 3481ref char charSearchSpace = ref Unsafe.As<T, char>(ref searchSpace); 3482char charLowInclusive = Unsafe.BitCast<T, char>(lowInclusive); 3483char charRange = (char)(Unsafe.BitCast<T, char>(highInclusive) - charLowInclusive); 3504ref T current = ref Unsafe.Add(ref searchSpace, i); 3518ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector128<T>.Count)); 3529current = ref Unsafe.Add(ref current, Vector128<T>.Count); 3531while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)); 3547ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector256<T>.Count)); 3558current = ref Unsafe.Add(ref current, Vector256<T>.Count); 3560while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)); 3576ref T oneVectorAwayFromEnd = ref Unsafe.Add(ref searchSpace, (uint)(length - Vector512<T>.Count)); 3587current = ref Unsafe.Add(ref current, Vector256<T>.Count); 3589while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)); 3607ref T current = ref Unsafe.Add(ref searchSpace, i); 3622ref T current = ref Unsafe.Add(ref searchSpace, i); 3651ref T current = ref Unsafe.Add(ref searchSpace, i); 3747ref T end = ref Unsafe.Add(ref current, length); 3750while (Unsafe.IsAddressLessThan(ref current, ref end)) 3757current = ref Unsafe.Add(ref current, 1); 3762while (Unsafe.IsAddressLessThan(ref current, ref end)) 3769current = ref Unsafe.Add(ref current, 1); 3779ref T end = ref Unsafe.Add(ref current, length); 3786ref T oneVectorAwayFromEnd = ref Unsafe.Subtract(ref end, Vector512<T>.Count); 3787while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)) 3790current = ref Unsafe.Add(ref current, Vector512<T>.Count); 3795mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)sizeof(T)); 3801ref T oneVectorAwayFromEnd = ref Unsafe.Subtract(ref end, Vector256<T>.Count); 3802while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)) 3805current = ref Unsafe.Add(ref current, Vector256<T>.Count); 3810mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)sizeof(T)); 3816ref T oneVectorAwayFromEnd = ref Unsafe.Subtract(ref end, Vector128<T>.Count); 3817while (Unsafe.IsAddressLessThan(ref current, ref oneVectorAwayFromEnd)) 3820current = ref Unsafe.Add(ref current, Vector128<T>.Count); 3825mask >>= (int)((nuint)Unsafe.ByteOffset(ref oneVectorAwayFromEnd, ref current) / (uint)sizeof(T)); 3831while (Unsafe.IsAddressLessThan(ref current, ref end)) 3838current = ref Unsafe.Add(ref current, 1);
src\libraries\System.Private.CoreLib\src\System\String.Comparison.cs (20)
30ref Unsafe.As<char, byte>(ref strA.GetRawStringData()), 31ref Unsafe.As<char, byte>(ref strB.GetRawStringData()), 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); 1141ref Unsafe.As<char, byte>(ref this.GetRawStringData()), 1142ref Unsafe.As<char, byte>(ref value.GetRawStringData()),
src\libraries\System.Private.CoreLib\src\System\String.cs (8)
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 ushort GetRawStringDataAsUInt16() => ref Unsafe.As<char, ushort>(ref _firstChar); 572Unsafe.Add(ref result._firstChar, 1) = c2; 734return 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 (43)
30&& Equals<byte, ushort, WideningLoader>(ref MemoryMarshal.GetReference(left), ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(right)), (uint)right.Length); 39&& 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); 55uint valueA = uint.CreateTruncating(Unsafe.Add(ref left, i)); 56uint valueB = uint.CreateTruncating(Unsafe.Add(ref right, i)); 72ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector512<TLeft>.Count); 82currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, Vector512<TLeft>.Count); 83currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, Vector512<TLeft>.Count); 85while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 90ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref left, length - (uint)Vector512<TLeft>.Count); 102ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector256<TLeft>.Count); 112currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, Vector256<TLeft>.Count); 113currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, Vector256<TLeft>.Count); 115while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 120ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref left, length - (uint)Vector256<TLeft>.Count); 127ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref currentLeftSearchSpace, length - TLoader.Count128); 129ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector128<TRight>.Count); 146currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, (uint)Vector128<TRight>.Count); 147currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, TLoader.Count128); 149while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 181&& EqualsIgnoreCase<byte, ushort, WideningLoader>(ref MemoryMarshal.GetReference(left), ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(right)), (uint)right.Length); 190&& 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); 193EqualsIgnoreCase<ushort, ushort, PlainLoader<ushort>>(ref Unsafe.As<char, ushort>(ref left), ref Unsafe.As<char, ushort>(ref right), length); 209uint valueA = uint.CreateTruncating(Unsafe.Add(ref left, i)); 210uint valueB = uint.CreateTruncating(Unsafe.Add(ref right, i)); 237ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref currentLeftSearchSpace, length - TLoader.Count512); 239ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector512<TRight>.Count); 273currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, (uint)Vector512<TRight>.Count); 274currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, TLoader.Count512); 276while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 308ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref currentLeftSearchSpace, length - TLoader.Count256); 310ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector256<TRight>.Count); 345currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, (uint)Vector256<TRight>.Count); 346currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, TLoader.Count256); 348while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 380ref TLeft oneVectorAwayFromLeftEnd = ref Unsafe.Add(ref currentLeftSearchSpace, length - TLoader.Count128); 382ref TRight oneVectorAwayFromRightEnd = ref Unsafe.Add(ref currentRightSearchSpace, length - (uint)Vector128<TRight>.Count); 418currentRightSearchSpace = ref Unsafe.Add(ref currentRightSearchSpace, (uint)Vector128<TRight>.Count); 419currentLeftSearchSpace = ref Unsafe.Add(ref currentLeftSearchSpace, TLoader.Count128); 421while (!Unsafe.IsAddressGreaterThan(ref currentRightSearchSpace, ref oneVectorAwayFromRightEnd)); 522Vector128<byte> vec = Vector128.CreateScalarUnsafe(Unsafe.ReadUnaligned<long>(ref ptr)).AsByte();
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.Utility.cs (45)
253currentUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer); 254uint nextUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer + 4); 278currentUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer); 291currentUInt32 = Unsafe.ReadUnaligned<ushort>(pBuffer); 622ulong candidateUInt64 = Unsafe.ReadUnaligned<ulong>(pBuffer); 637currentDWord = Unsafe.ReadUnaligned<uint>(pBuffer); 638uint nextDWord = Unsafe.ReadUnaligned<uint>(pBuffer + 4); 662currentDWord = Unsafe.ReadUnaligned<uint>(pBuffer); 677currentDWord = Unsafe.ReadUnaligned<ushort>(pBuffer); 867currentUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer); 868uint nextUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer + 4 / sizeof(char)); 892currentUInt32 = Unsafe.ReadUnaligned<uint>(pBuffer); 1173ulong candidateUInt64 = Unsafe.ReadUnaligned<ulong>(pBuffer); 1190currentDWord = Unsafe.ReadUnaligned<uint>(pBuffer); 1191uint nextDWord = Unsafe.ReadUnaligned<uint>(pBuffer + 4 / sizeof(char)); 1215currentDWord = Unsafe.ReadUnaligned<uint>(pBuffer); 1256Unsafe.WriteUnaligned(ref outputBuffer, Sse2.ConvertToUInt32(vecNarrow)); 1265Unsafe.WriteUnaligned(ref outputBuffer, lower.AsUInt32().ToScalar()); 1274Unsafe.Add(ref outputBuffer, 1) = (byte)value; 1276Unsafe.Add(ref outputBuffer, 2) = (byte)value; 1278Unsafe.Add(ref outputBuffer, 3) = (byte)value; 1282Unsafe.Add(ref outputBuffer, 3) = (byte)value; 1284Unsafe.Add(ref outputBuffer, 2) = (byte)value; 1286Unsafe.Add(ref outputBuffer, 1) = (byte)value; 1306Unsafe.Add(ref outputBuffer, 1) = (byte)(value >> 16); 1310Unsafe.Add(ref outputBuffer, 1) = (byte)value; 1336utf16Data64Bits = Unsafe.ReadUnaligned<ulong>(pUtf16Buffer); 1344utf16Data32BitsHigh = Unsafe.ReadUnaligned<uint>(pUtf16Buffer); 1345utf16Data32BitsLow = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + 4 / sizeof(char)); 1379utf16Data64Bits = Unsafe.ReadUnaligned<ulong>(pUtf16Buffer + currentOffset); 1389utf16Data32BitsHigh = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + currentOffset); 1390utf16Data32BitsLow = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + currentOffset + 4 / sizeof(char)); 1408utf16Data32BitsHigh = Unsafe.ReadUnaligned<uint>(pUtf16Buffer + currentOffset); 2076asciiData = Unsafe.ReadUnaligned<uint>(pAsciiBuffer + currentOffset); 2091asciiData = Unsafe.ReadUnaligned<ushort>(pAsciiBuffer + currentOffset); 2253Unsafe.WriteUnaligned(ref Unsafe.As<char, byte>(ref outputBuffer), vecWide.ToScalar()); 2259Unsafe.WriteUnaligned(ref Unsafe.As<char, byte>(ref outputBuffer), vecWide.ToScalar()); 2267Unsafe.Add(ref outputBuffer, 1) = (char)(byte)value; 2269Unsafe.Add(ref outputBuffer, 2) = (char)(byte)value; 2271Unsafe.Add(ref outputBuffer, 3) = (char)value; 2275Unsafe.Add(ref outputBuffer, 3) = (char)(byte)value; 2277Unsafe.Add(ref outputBuffer, 2) = (char)(byte)value; 2279Unsafe.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)
65pInputBuffer: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)), 67pOutputBuffer: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)), 95destination = destination.Slice((int)(pOutputBufferRemaining - (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)))); 110source = source.Slice((int)(pInputBufferRemaining - (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source))) + 1); 113pInputBufferRemaining = (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)); 114pOutputBufferRemaining = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)); 156pInputBuffer: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)), 158pOutputBuffer: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)), 186destination = destination.Slice((int)(pOutputBufferRemaining - (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)))); 200source = source.Slice((int)(pInputBufferRemaining - (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)))); 207pInputBufferRemaining = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)); 208pOutputBufferRemaining = (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)); 250pInputBuffer: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)), 252pOutputBuffer: (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)), 284source = source.Slice((int)(pInputBufferRemaining - (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)))); 285destination = destination.Slice((int)(pOutputBufferRemaining - (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination)))); 306pInputBufferRemaining = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(source)); 307pOutputBufferRemaining = (char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(destination));
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.cs (1)
31int 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)
67uint thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 94uint remainingInputBytes = (uint)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *pFinalPosWhereCanReadDWordFromInputBuffer) + 4; 102thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 103secondDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer + sizeof(uint)); 243thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 287Unsafe.WriteUnaligned(pOutputBuffer, ExtractTwoCharsPackedFromTwoAdjacentTwoByteSequences(thisDWord)); 298thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 387thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 410thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 485if (outputCharsRemaining > 1 && (nint)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *pFinalPosWhereCanReadDWordFromInputBuffer) >= 3) 494uint secondDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer + 3); 550thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 627Unsafe.WriteUnaligned(pOutputBuffer, ExtractCharsFromFourByteSequence(thisDWord)); 638inputLength = (int)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *pFinalPosWhereCanReadDWordFromInputBuffer) + 4; 901thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 929Unsafe.WriteUnaligned(pOutputBuffer, (ushort)valueToWrite); 952Unsafe.SkipInit(out nonAsciiUtf16DataMask); 954utf16Data = Unsafe.ReadUnaligned<Vector128<short>>(pInputBuffer); 995possibleNonAsciiQWord = Unsafe.ReadUnaligned<ulong>(pInputBuffer); 1010Unsafe.WriteUnaligned(pOutputBuffer, Sse2.ConvertToUInt32(Sse2.PackUnsignedSaturate(utf16Data, utf16Data).AsUInt32())); 1053Unsafe.WriteUnaligned(pOutputBuffer, Sse2.ConvertToUInt32(Sse2.PackUnsignedSaturate(utf16Data, utf16Data).AsUInt32())); 1074Unsafe.WriteUnaligned(pOutputBuffer, (ushort)(thisDWord | (thisDWord >> 8))); 1091thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1092secondDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer + 2); 1101Unsafe.WriteUnaligned(pOutputBuffer, (ushort)(thisDWord | (thisDWord >> 8))); 1102Unsafe.WriteUnaligned(pOutputBuffer + 2, (ushort)(secondDWord | (secondDWord >> 8))); 1122Unsafe.WriteUnaligned(pOutputBuffer, (ushort)(thisDWord | (thisDWord >> 8))); 1168thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1190Unsafe.WriteUnaligned(pOutputBuffer, ExtractTwoUtf8TwoByteSequencesFromTwoPackedUtf16Chars(thisDWord)); 1205thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1224Unsafe.WriteUnaligned(pOutputBuffer, (ushort)ExtractUtf8TwoByteSequenceFromFirstUtf16Char(thisDWord)); 1265thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1304thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1362thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1382thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 1396Unsafe.WriteUnaligned(pOutputBuffer, ExtractFourUtf8BytesFromSurrogatePair(thisDWord));
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.Validation.cs (10)
72uint thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 96if ((nint)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *pFinalPosWhereCanReadDWordFromInputBuffer) >= 4 * sizeof(uint)) 102thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 193thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); // no longer guaranteed to be aligned 238thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 293thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 347thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 458ulong thisQWord = Unsafe.ReadUnaligned<ulong>(pInputBuffer); 558thisDWord = Unsafe.ReadUnaligned<uint>(pInputBuffer); 653inputBufferRemainingBytes = (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)
2385Unsafe.As<Task>(obj).InnerInvoke(); 6729return 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); 587return GetTaskForValueTaskSource(Unsafe.As<IValueTaskSource<TResult>>(obj)); 719return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) != ValueTaskSourceStatus.Pending; 742return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) == ValueTaskSourceStatus.Succeeded; 764return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) == ValueTaskSourceStatus.Faulted; 791return Unsafe.As<IValueTaskSource<TResult>>(obj).GetStatus(_token) == ValueTaskSourceStatus.Canceled; 816return 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 (2)
31Unsafe.As<ThreadLocalNode>(threadLocalCountObject).Increment(); 38Unsafe.As<ThreadLocalNode>(threadLocalCountObject).Add(count);
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolWorkQueue.cs (1)
1231Unsafe.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)); 154target = Unsafe.As<T?>(GCHandle.InternalGet(th));
src\System\Array.CoreCLR.cs (56)
88ref byte src = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(sourceArray), (uint)sourceIndex * elementSize); 89ref byte dst = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(destinationArray), (uint)destinationIndex * elementSize); 256ref object? srcData = ref Unsafe.Add(ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(sourceArray)), sourceIndex); 257ref byte data = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(destinationArray), (nuint)destinationIndex * destSize); 261object? obj = Unsafe.Add(ref srcData, i); 266ref byte dest = ref Unsafe.AddByteOffset(ref data, (nuint)i * destSize); 299ref byte data = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(sourceArray), (nuint)sourceIndex * srcSize); 300ref object? destData = ref Unsafe.Add(ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(destinationArray)), destinationIndex); 304object? obj = RuntimeHelpers.Box(pSrcMT, ref Unsafe.AddByteOffset(ref data, (nuint)i * srcSize)); 305Unsafe.Add(ref destData, i) = obj; 314ref object? srcData = ref Unsafe.Add(ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(sourceArray)), sourceIndex); 315ref object? destData = ref Unsafe.Add(ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(destinationArray)), destinationIndex); 319object? obj = Unsafe.Add(ref srcData, i); 324Unsafe.Add(ref destData, i) = CastHelpers.ChkCastAny(destTH, obj); 339ref byte srcData = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(sourceArray), (nuint)sourceIndex * srcElSize); 340ref byte data = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(destinationArray), (nuint)destinationIndex * destElSize); 345srcData = ref Unsafe.AddByteOffset(ref srcData, srcElSize); 346data = ref Unsafe.AddByteOffset(ref data, destElSize); 381SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref pStart), totalByteLength / (nuint)sizeof(IntPtr)); 395ref byte p = ref Unsafe.As<RawArrayData>(array).Data; 402lowerBound = Unsafe.Add(ref Unsafe.As<byte, int>(ref p), rank); 403p = ref Unsafe.Add(ref p, 2 * sizeof(int) * rank); // skip the bounds 413ref byte ptr = ref Unsafe.AddByteOffset(ref p, (uint)offset * elementSize); 417SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref ptr), byteLength / (uint)sizeof(IntPtr)); 432rawIndex -= Unsafe.Add(ref bounds, 1); 451int index = indices[i] - Unsafe.Add(ref bounds, indices.Length + i); 452int length = Unsafe.Add(ref bounds, i); 492ref byte offsetDataRef = ref Unsafe.Add(ref arrayDataRef, flattenedIndex * pMethodTable->ComponentSize); 500ref object elementRef = ref Unsafe.As<byte, object>(ref arrayDataRef); 501ref object offsetElementRef = ref Unsafe.Add(ref elementRef, (nuint)flattenedIndex); 534ref byte offsetDataRef = ref Unsafe.Add(ref arrayDataRef, flattenedIndex * pMethodTable->ComponentSize); 538SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, nint>(ref offsetDataRef), elementSize / (nuint)sizeof(IntPtr)); 548Unsafe.Add(ref Unsafe.As<byte, object?>(ref arrayDataRef), (nuint)flattenedIndex) = null; 557Unsafe.Add(ref Unsafe.As<byte, object?>(ref arrayDataRef), (nuint)flattenedIndex) = value; 563ref byte offsetDataRef = ref Unsafe.Add(ref arrayDataRef, flattenedIndex * pMethodTable->ComponentSize); 615public int Length => checked((int)Unsafe.As<RawArrayData>(this).Length); 618internal nuint NativeLength => Unsafe.As<RawArrayData>(this).Length; 641return Unsafe.Add(ref RuntimeHelpers.GetMultiDimensionalArrayBounds(this), dimension); 655return Unsafe.Add(ref bounds, dimension) + Unsafe.Add(ref bounds, rank + dimension) - 1; 668return Unsafe.Add(ref RuntimeHelpers.GetMultiDimensionalArrayBounds(this), rank + dimension); 709arrayRef = ref Unsafe.Add(ref arrayRef, elementSize); 769T[] @this = Unsafe.As<T[]>(this); 779T[] @this = Unsafe.As<T[]>(this); 787T[] @this = Unsafe.As<T[]>(this); 795T[] @this = Unsafe.As<T[]>(this); 808T[] @this = Unsafe.As<T[]>(this); 827T[] @this = Unsafe.As<T[]>(this); 848T[] @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)
879ref 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((RuntimeType)GetType()));
src\System\Reflection\RuntimeCustomAttributeData.cs (1)
1540int data = Unsafe.ReadUnaligned<int>((void*)blobStart);
src\System\Reflection\TypeNameResolver.CoreCLR.cs (1)
177assembly = RuntimeAssembly.InternalLoad(assemblyName, ref Unsafe.NullRef<StackCrawlMark>(),
src\System\Runtime\CompilerServices\CastHelpers.cs (7)
422ref object? element = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index); 439ref object? element = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index); 592SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref destPtr), typeMT->GetNumInstanceFieldBytesIfContainsGCPointers() / (nuint)sizeof(IntPtr)); 603Unsafe.As<byte, bool>(ref destPtr) = true; 604ref byte dst = ref Unsafe.Add(ref destPtr, typeMT->NullableValueAddrOffset); 623if (!Unsafe.As<byte, bool>(ref nullableData)) 631ref byte srcData = ref Unsafe.Add(ref nullableData, srcMT->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)); 390ref Unsafe.As<RawData>(obj).Data; 400rawSize += (uint)Unsafe.As<RawArrayData>(obj).Length * (nuint)pMT->ComponentSize; 421return ref Unsafe.As<byte, int>(ref Unsafe.As<RawArrayData>(array).Data); 575/// This API returns the same value as <see cref="Unsafe.SizeOf{T}"/> for the type that <paramref name="type"/> represents. 628private MethodDescChunk* GetMethodDescChunk() => (MethodDescChunk*)(((byte*)Unsafe.AsPointer<MethodDesc>(ref this)) - (sizeof(MethodDescChunk) + ChunkIndex * sizeof(IntPtr))); 946return *(RuntimeType*)Unsafe.AsPointer(ref _exposedClassObject); 966return ref Unsafe.AsRef<byte>((byte*)((nuint)p & ~(nuint)DynamicStaticsInfo.ISCLASSNOTINITED)); 1043return *(RuntimeType*)Unsafe.AsPointer(ref ExposedClassObjectRaw); 1054return ref Unsafe.Subtract(ref Unsafe.As<MethodTableAuxiliaryData, DynamicStaticsInfo>(ref this), 1); 1060return ref Unsafe.Subtract(ref Unsafe.As<MethodTableAuxiliaryData, ThreadStaticsInfo>(ref this), 1);
src\System\Runtime\CompilerServices\StaticsHelpers.cs (9)
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);
src\System\Runtime\InteropServices\ComWrappers.cs (1)
97return Unsafe.As<T>(GCHandle.InternalGet(comInstance->GcHandle));
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)
1547Debug.Assert(!Unsafe.IsNullRef(ref fieldDataRef.Get())); 1554Debug.Assert(!Unsafe.IsNullRef(ref target)); 1556return 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\String.CoreCLR.cs (1)
41SpanHelpers.Memmove(ref *(byte*)dest, ref Unsafe.As<char, byte>(ref src.GetRawStringData()), (nuint)len);
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)
454return (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)
121rgelt[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)
46Unsafe.WriteUnaligned(ref buffer[start], !BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness(value) : value); 49Unsafe.WriteUnaligned(ref buffer[start], BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness(value) : value); 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);
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)
623[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 (63)
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 (3)
28nint elementOffset = Unsafe.Add(ref MemoryMarshal.GetReference(log2ToPow10), BitOperations.Log2(value)); 56ulong powerOf10 = Unsafe.Add(ref MemoryMarshal.GetReference(powersOf10), elementOffset); 106long tableValue = Unsafe.Add(ref MemoryMarshal.GetReference(table), uint.Log2(value));
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)
3614Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 3621ref byte address = ref Unsafe.Add(ref startAddress, (bits.Length - 1) * sizeof(uint)); 3632Unsafe.WriteUnaligned(ref address, part); 3633address = ref Unsafe.Subtract(ref address, sizeof(uint)); 3642ref byte address = ref Unsafe.Add(ref startAddress, byteCount - sizeof(uint)); 3657Unsafe.WriteUnaligned(ref address, part); 3658address = ref Unsafe.Subtract(ref address, sizeof(uint)); 3674Unsafe.WriteUnaligned(ref address, part); 3675address = ref Unsafe.Subtract(ref address, sizeof(uint)); 3680if (Unsafe.AreSame(ref address, ref startAddress)) 3684Unsafe.WriteUnaligned(ref address, uint.MaxValue); 3689Debug.Assert(Unsafe.AreSame(ref startAddress, ref Unsafe.Add(ref address, sizeof(uint)))); 3716Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(destination), value); 3733Unsafe.WriteUnaligned(ref address, part); 3734address = ref Unsafe.Add(ref address, sizeof(uint)); 3743ref byte lastAddress = ref Unsafe.Add(ref address, byteCount - sizeof(uint)); 3758Unsafe.WriteUnaligned(ref address, part); 3759address = ref Unsafe.Add(ref address, sizeof(uint)); 3775Unsafe.WriteUnaligned(ref address, part); 3776address = ref Unsafe.Add(ref address, sizeof(uint)); 3781if (Unsafe.AreSame(ref address, ref lastAddress)) 3785Unsafe.WriteUnaligned(ref address, uint.MaxValue); 3790Debug.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); 151long digit = (Unsafe.Add(ref leftPtr, i) + carry) - right[i]; 152Unsafe.Add(ref leftPtr, i) = unchecked((uint)digit); 181Unsafe.Add(ref resultPtr, i) = unchecked((uint)carry); 185Unsafe.Add(ref resultPtr, left.Length) = unchecked((uint)carry); 192Unsafe.Add(ref resultPtr, i) = unchecked((uint)carry); 204Unsafe.Add(ref resultPtr, left.Length) = unchecked((uint)carry); 228Unsafe.Add(ref resultPtr, i) = unchecked((uint)carry); 237Unsafe.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 (8)
Microsoft\Win32\SafeHandles\SafePasswordHandle.cs (1)
40if (!Unsafe.IsNullRef(ref MemoryMarshal.GetReference(password)))
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Cipher.cs (3)
121ref Unsafe.NullRef<byte>(), 123ref Unsafe.NullRef<byte>(), 237if (!EvpCipherSetCcmTag(ctx, ref Unsafe.NullRef<byte>(), tagLength))
src\libraries\Common\src\System\Security\Cryptography\Helpers.cs (1)
67return Unsafe.IsNullRef(ref MemoryMarshal.GetReference(span));
src\libraries\Common\src\System\Security\Cryptography\Pkcs12Kdf.cs (1)
127if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(password)))
System\Security\Cryptography\Helpers.cs (2)
332return ref buffer.Length != 0 ? ref MemoryMarshal.GetReference(buffer) : ref Unsafe.AsRef<byte>((void*)1); 339return ref buffer.Length != 0 ? ref MemoryMarshal.GetReference(buffer) : ref Unsafe.AsRef<byte>((void*)1);
System.Security.Cryptography.Pkcs (2)
src\libraries\Common\src\System\Security\Cryptography\Helpers.cs (1)
67return 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 (2)
System\Text\Encodings\Web\OptimizedInboxTextEncoder.AdvSimd64.cs (1)
97Vector128<byte> packed = Vector128.CreateScalarUnsafe(Unsafe.ReadUnaligned<uint>(pData + i)).AsByte();
System\Text\Encodings\Web\OptimizedInboxTextEncoder.cs (1)
50allowedCodePointsBmp = ref Unsafe.NullRef<AllowedBmpCodePointsBitmap>();
System.Text.Json (34)
System\Text\Json\Document\JsonElement.cs (2)
1479return Unsafe.IsNullRef(ref MemoryMarshal.GetReference(utf8Text)); 1507return Unsafe.IsNullRef(ref MemoryMarshal.GetReference(text));
System\Text\Json\Serialization\Converters\Value\EnumConverter.cs (20)
116case TypeCode.Int32 when reader.TryGetInt32(out int int32): return Unsafe.As<int, T>(ref int32); 117case TypeCode.UInt32 when reader.TryGetUInt32(out uint uint32): return Unsafe.As<uint, T>(ref uint32); 118case TypeCode.Int64 when reader.TryGetInt64(out long int64): return Unsafe.As<long, T>(ref int64); 119case TypeCode.UInt64 when reader.TryGetUInt64(out ulong uint64): return Unsafe.As<ulong, T>(ref uint64); 120case TypeCode.Byte when reader.TryGetByte(out byte ubyte8): return Unsafe.As<byte, T>(ref ubyte8); 121case TypeCode.SByte when reader.TryGetSByte(out sbyte byte8): return Unsafe.As<sbyte, T>(ref byte8); 122case TypeCode.Int16 when reader.TryGetInt16(out short int16): return Unsafe.As<short, T>(ref int16); 123case TypeCode.UInt16 when reader.TryGetUInt16(out ushort uint16): return Unsafe.As<ushort, T>(ref uint16); 355case TypeCode.Int32 or TypeCode.UInt32: return Unsafe.As<T, uint>(ref value); 356case TypeCode.Int64 or TypeCode.UInt64: return Unsafe.As<T, ulong>(ref value); 357case TypeCode.Int16 or TypeCode.UInt16: return Unsafe.As<T, ushort>(ref value); 360return Unsafe.As<T, byte>(ref value); 369case TypeCode.Int32: return Unsafe.As<T, int>(ref value); 370case TypeCode.Int64: return Unsafe.As<T, long>(ref value); 371case TypeCode.Int16: return Unsafe.As<T, short>(ref value); 374return Unsafe.As<T, sbyte>(ref value); 384return Unsafe.As<uint, T>(ref uintValue); 388return Unsafe.As<ulong, T>(ref ulongValue); 392return Unsafe.As<ushort, T>(ref ushortValue); 397return Unsafe.As<byte, T>(ref byteValue);
System\Text\Json\Serialization\Metadata\PropertyRef.cs (12)
63case 2: key |= Unsafe.ReadUnaligned<ushort>(ref reference); goto ComputedKey; 64case 3: key |= Unsafe.ReadUnaligned<ushort>(ref reference); goto OddLength; 65case 4: key |= Unsafe.ReadUnaligned<uint>(ref reference); goto ComputedKey; 66case 5: key |= Unsafe.ReadUnaligned<uint>(ref reference); goto OddLength; 67case 6: key |= Unsafe.ReadUnaligned<uint>(ref reference) | (ulong)Unsafe.ReadUnaligned<ushort>(ref Unsafe.Add(ref reference, 4)) << 32; goto ComputedKey; 68case 7: key |= Unsafe.ReadUnaligned<uint>(ref reference) | (ulong)Unsafe.ReadUnaligned<ushort>(ref Unsafe.Add(ref reference, 4)) << 32; goto OddLength; 69default: key |= Unsafe.ReadUnaligned<ulong>(ref reference) & 0x00ffffffffffffffL; goto ComputedKey; 74key |= (ulong)Unsafe.Add(ref reference, offset) << (offset * 8);
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)
92uint 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 (6)
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 (3)
195AddOrUpdate(key, Unsafe.As<T, Padding>(ref value)); 199AddOrUpdate(key, Unsafe.As<T, Rectangle>(ref value)); 217ref T unboxed = ref Unsafe.Unbox<T>(storedValue);
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)
105Assert.Equal(expectedIsInDragLoopFormat, DragDropHelper.IsInDragLoopFormat(Unsafe.As<FORMATETC, Com.FORMATETC>(ref formatEtc)));