@@ -881,12 +881,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
881881 }
882882 return GetPointerToFirstInvalidByteScalar ( pInputBuffer + processedLength , inputLength - processedLength , out utf16CodeUnitCountAdjustment , out scalarCountAdjustment ) ;
883883 }
884- public static void ToString ( Vector128 < byte > v )
885- {
886- Span < byte > b = stackalloc byte [ 16 ] ;
887- v . CopyTo ( b ) ;
888- Console . WriteLine ( Convert . ToHexString ( b ) ) ;
889- }
884+
890885 public unsafe static byte * GetPointerToFirstInvalidByteArm64 ( byte * pInputBuffer , int inputLength , out int utf16CodeUnitCountAdjustment , out int scalarCountAdjustment )
891886 {
892887 int processedLength = 0 ;
@@ -979,7 +974,6 @@ public static void ToString(Vector128<byte> v)
979974 // we need to check if the previous block was incomplete.
980975 if ( AdvSimd . Arm64 . MaxAcross ( prevIncomplete ) . ToScalar ( ) != 0 )
981976 {
982- // Console.WriteLine("ASCII block, but previous block was incomplete");
983977 int off = processedLength >= 3 ? processedLength - 3 : processedLength ;
984978 byte * invalidBytePointer = SimdUnicode . UTF8 . SimpleRewindAndValidateWithErrors ( 16 - 3 , pInputBuffer + processedLength - 3 , inputLength - processedLength + 3 ) ;
985979 // So the code is correct up to invalidBytePointer
@@ -1019,19 +1013,6 @@ public static void ToString(Vector128<byte> v)
10191013 // hardware:
10201014 if ( AdvSimd . Arm64 . MaxAcross ( Vector128 . AsUInt32 ( error ) ) . ToScalar ( ) != 0 )
10211015 {
1022- // Console.WriteLine("Error block detected");
1023- int slown4 = 0 ;
1024- int slowcontbytes = 0 ;
1025- int slowasciibytes = 0 ;
1026- addCounters ( pInputBuffer , pInputBuffer + processedLength , ref slowasciibytes , ref slown4 , ref slowcontbytes ) ;
1027- if ( slowasciibytes != asciibytes || slown4 != n4 || slowcontbytes != contbytes )
1028- {
1029- Console . WriteLine ( "Error in counting" ) ;
1030- Console . WriteLine ( $ "asciibytes: { asciibytes } { slowasciibytes } ") ;
1031- Console . WriteLine ( $ "n4: { n4 } { slown4 } ") ;
1032- Console . WriteLine ( $ "contbytes: { contbytes } { slowcontbytes } ") ;
1033- }
1034-
10351016 byte * invalidBytePointer ;
10361017 if ( processedLength == 0 )
10371018 {
@@ -1058,31 +1039,11 @@ public static void ToString(Vector128<byte> v)
10581039 contbytes += - AdvSimd . Arm64 . AddAcross ( AdvSimd . CompareLessThanOrEqual ( Vector128 . AsSByte ( currentBlock ) , largestcont ) ) . ToScalar ( ) ;
10591040 Vector128 < byte > fourthByteMinusOne = Vector128 . Create ( ( byte ) ( 0b11110000u - 1 ) ) ;
10601041
1061- int reallyslown4 = 0 ;
1062- for ( int i = 0 ; i < 16 ; i ++ )
1063- {
1064- if ( pInputBuffer [ processedLength + i ] >= 0xF0 )
1065- {
1066- reallyslown4 ++ ;
1067- }
1068- }
1042+ // computing n4 is more expensive than we would like:
10691043 var largerthan0f = AdvSimd . CompareGreaterThan ( currentBlock , fourthByteMinusOne ) ;
10701044 var largerthan0fones = AdvSimd . And ( largerthan0f , Vector128 . Create ( ( byte ) 1 ) ) ;
10711045 var largerthan0fonescount = AdvSimd . Arm64 . AddAcross ( largerthan0fones ) . ToScalar ( ) ;
1072- if ( largerthan0fonescount != reallyslown4 )
1073- {
1074- Console . WriteLine ( "***********Error in counting 4-byte sequences" ) ;
1075- ToString ( currentBlock ) ;
1076- ToString ( fourthByteMinusOne ) ;
1077- ToString ( AdvSimd . SubtractSaturate ( currentBlock , fourthByteMinusOne ) ) ;
1078- ToString ( AdvSimd . CompareGreaterThan ( currentBlock , fourthByteMinusOne ) ) ;
1079- Console . WriteLine ( ( ( AdvSimd . Arm64 . AddAcross ( AdvSimd . CompareGreaterThan ( currentBlock , fourthByteMinusOne ) ) . ToScalar ( ) ^ 0xff ) + 1 ) & 0xff ) ;
1080-
1081- Console . WriteLine ( reallyslown4 ) ;
1082- }
10831046 n4 += largerthan0fonescount ;
1084-
1085- //n4 += (int)(((AdvSimd.Arm64.AddAcross(AdvSimd.CompareGreaterThan(currentBlock, fourthByteMinusOne)).ToScalar()^0xff)+1)&0xff);
10861047 }
10871048 asciibytes -= ( sbyte ) AdvSimd . Arm64 . AddAcross ( AdvSimd . CompareLessThan ( currentBlock , v80 ) ) . ToScalar ( ) ;
10881049 }
@@ -1101,8 +1062,6 @@ public static void ToString(Vector128<byte> v)
11011062 }
11021063 if ( invalidBytePointer != pInputBuffer + inputLength )
11031064 {
1104- // Console.WriteLine("trailing Error block detected");
1105-
11061065 if ( invalidBytePointer < pInputBuffer + processedLength )
11071066 {
11081067 removeCounters ( invalidBytePointer , pInputBuffer + processedLength , ref asciibytes , ref n4 , ref contbytes ) ;
@@ -1120,15 +1079,11 @@ public static void ToString(Vector128<byte> v)
11201079 addCounters ( pInputBuffer + processedLength , invalidBytePointer , ref asciibytes , ref n4 , ref contbytes ) ;
11211080 }
11221081 }
1123- //Console.WriteLine("trailing simd method");
1124-
11251082 int final_total_bytes_processed = inputLength - start_point ;
11261083 ( utf16CodeUnitCountAdjustment , scalarCountAdjustment ) = CalculateN2N3FinalSIMDAdjustments ( asciibytes , n4 , contbytes , final_total_bytes_processed ) ;
11271084 return pInputBuffer + inputLength ;
11281085 }
11291086 }
1130- //Console.WriteLine("trailing scalar method");
1131-
11321087 return GetPointerToFirstInvalidByteScalar ( pInputBuffer + processedLength , inputLength - processedLength , out utf16CodeUnitCountAdjustment , out scalarCountAdjustment ) ;
11331088 }
11341089
0 commit comments