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\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\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\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\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\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\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\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\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\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\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\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\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\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\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.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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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.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.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\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\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\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\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\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\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\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\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\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\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);