Skip to content

Commit

Permalink
added Runtime's UTF8 validation function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Nuon committed Nov 18, 2023
1 parent 448a02e commit 87e777b
Show file tree
Hide file tree
Showing 3 changed files with 1,230 additions and 0 deletions.
4 changes: 4 additions & 0 deletions benchmark/CS_runtime.cs → benchmark/ASCII_runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;

// This is from the Runtime. Copy/pasted as I found no other way to benchmark it.

//Changes from original:
//copy pasted CompExactlyDependsOnAttribute : Attribute into System.Text namespace
//copy/pasted StoreLowerUnsafe into ascii class
//The various Vector.Size likely refer to size in bytes so
//Replaced all instances of Vector512.Size by 64 (see:https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs,77df495766d5de9c)
//Vector256's by 32 (see:https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs,877aa6254c4e4d00)
//Vector128's by 16 (see:https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs,eb1e72a6f843c5a5)
// GetIndexofFirstNonAsciiByte is no longer internal

namespace Competition
{
Expand Down Expand Up @@ -213,6 +216,7 @@ private static bool FirstCharInUInt32IsAscii(uint value)
/// <returns>An ASCII byte is defined as 0x00 - 0x7F, inclusive.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe nuint GetIndexOfFirstNonAsciiByte(byte* pBuffer, nuint bufferLength)
// internal static unsafe nuint GetIndexOfFirstNonAsciiByte(byte* pBuffer, nuint bufferLength)
{
// If 256/512-bit aren't supported but SSE2 is supported, use those specific intrinsics instead of
// the generic vectorized code. This has two benefits: (a) we can take advantage of specific instructions
Expand Down
Loading

0 comments on commit 87e777b

Please sign in to comment.