@@ -881,12 +881,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
881
881
}
882
882
return GetPointerToFirstInvalidByteScalar ( pInputBuffer + processedLength , inputLength - processedLength , out utf16CodeUnitCountAdjustment , out scalarCountAdjustment ) ;
883
883
}
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
+
890
885
public unsafe static byte * GetPointerToFirstInvalidByteArm64 ( byte * pInputBuffer , int inputLength , out int utf16CodeUnitCountAdjustment , out int scalarCountAdjustment )
891
886
{
892
887
int processedLength = 0 ;
@@ -979,7 +974,6 @@ public static void ToString(Vector128<byte> v)
979
974
// we need to check if the previous block was incomplete.
980
975
if ( AdvSimd . Arm64 . MaxAcross ( prevIncomplete ) . ToScalar ( ) != 0 )
981
976
{
982
- // Console.WriteLine("ASCII block, but previous block was incomplete");
983
977
int off = processedLength >= 3 ? processedLength - 3 : processedLength ;
984
978
byte * invalidBytePointer = SimdUnicode . UTF8 . SimpleRewindAndValidateWithErrors ( 16 - 3 , pInputBuffer + processedLength - 3 , inputLength - processedLength + 3 ) ;
985
979
// So the code is correct up to invalidBytePointer
@@ -1019,19 +1013,6 @@ public static void ToString(Vector128<byte> v)
1019
1013
// hardware:
1020
1014
if ( AdvSimd . Arm64 . MaxAcross ( Vector128 . AsUInt32 ( error ) ) . ToScalar ( ) != 0 )
1021
1015
{
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
-
1035
1016
byte * invalidBytePointer ;
1036
1017
if ( processedLength == 0 )
1037
1018
{
@@ -1058,31 +1039,11 @@ public static void ToString(Vector128<byte> v)
1058
1039
contbytes += - AdvSimd . Arm64 . AddAcross ( AdvSimd . CompareLessThanOrEqual ( Vector128 . AsSByte ( currentBlock ) , largestcont ) ) . ToScalar ( ) ;
1059
1040
Vector128 < byte > fourthByteMinusOne = Vector128 . Create ( ( byte ) ( 0b11110000u - 1 ) ) ;
1060
1041
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:
1069
1043
var largerthan0f = AdvSimd . CompareGreaterThan ( currentBlock , fourthByteMinusOne ) ;
1070
1044
var largerthan0fones = AdvSimd . And ( largerthan0f , Vector128 . Create ( ( byte ) 1 ) ) ;
1071
1045
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
- }
1083
1046
n4 += largerthan0fonescount ;
1084
-
1085
- //n4 += (int)(((AdvSimd.Arm64.AddAcross(AdvSimd.CompareGreaterThan(currentBlock, fourthByteMinusOne)).ToScalar()^0xff)+1)&0xff);
1086
1047
}
1087
1048
asciibytes -= ( sbyte ) AdvSimd . Arm64 . AddAcross ( AdvSimd . CompareLessThan ( currentBlock , v80 ) ) . ToScalar ( ) ;
1088
1049
}
@@ -1101,8 +1062,6 @@ public static void ToString(Vector128<byte> v)
1101
1062
}
1102
1063
if ( invalidBytePointer != pInputBuffer + inputLength )
1103
1064
{
1104
- // Console.WriteLine("trailing Error block detected");
1105
-
1106
1065
if ( invalidBytePointer < pInputBuffer + processedLength )
1107
1066
{
1108
1067
removeCounters ( invalidBytePointer , pInputBuffer + processedLength , ref asciibytes , ref n4 , ref contbytes ) ;
@@ -1120,15 +1079,11 @@ public static void ToString(Vector128<byte> v)
1120
1079
addCounters ( pInputBuffer + processedLength , invalidBytePointer , ref asciibytes , ref n4 , ref contbytes ) ;
1121
1080
}
1122
1081
}
1123
- //Console.WriteLine("trailing simd method");
1124
-
1125
1082
int final_total_bytes_processed = inputLength - start_point ;
1126
1083
( utf16CodeUnitCountAdjustment , scalarCountAdjustment ) = CalculateN2N3FinalSIMDAdjustments ( asciibytes , n4 , contbytes , final_total_bytes_processed ) ;
1127
1084
return pInputBuffer + inputLength ;
1128
1085
}
1129
1086
}
1130
- //Console.WriteLine("trailing scalar method");
1131
-
1132
1087
return GetPointerToFirstInvalidByteScalar ( pInputBuffer + processedLength , inputLength - processedLength , out utf16CodeUnitCountAdjustment , out scalarCountAdjustment ) ;
1133
1088
}
1134
1089
0 commit comments