@@ -23,7 +23,6 @@ public static class UTF8
23
23
24
24
for ( int i = 0 ; i <= howFarBack ; i ++ )
25
25
{
26
- // Console.WriteLine("Activiting main backup:" + i);
27
26
byte candidateByte = buf [ 0 - i ] ;
28
27
foundLeadingBytes = ( candidateByte & 0b11000000 ) != 0b10000000 ;
29
28
if ( foundLeadingBytes )
@@ -200,7 +199,7 @@ public unsafe static (int totalbyteadjustment,int backedupByHowMuch,int ascii,in
200
199
return ( 0 , i , - 1 , 0 , 0 ) ; // We must have that i == 1
201
200
}
202
201
if ( ( pInputBuffer [ - i ] & 0b11100000 ) == 0b11000000 ) {
203
- return ( 2 - i , i , 0 , - 1 , 0 ) ; // We have that i == 1 or i == 2, if i == 1, we are missing one byte.
202
+ return ( 2 - i , i , 0 , 0 , 0 ) ; // We have that i == 1 or i == 2, if i == 1, we are missing one byte.
204
203
}
205
204
if ( ( pInputBuffer [ - i ] & 0b11110000 ) == 0b11100000 ) {
206
205
return ( 3 - i , i , 0 , 0 , 0 ) ; // We have that i == 1 or i == 2 or i == 3, if i == 1, we are missing two bytes, if i == 2, we are missing one byte.
@@ -211,12 +210,16 @@ public unsafe static (int totalbyteadjustment,int backedupByHowMuch,int ascii,in
211
210
212
211
public static ( int utfadjust , int scalaradjust ) CalculateN2N3FinalSIMDAdjustments ( int asciibytes , int n4 , int contbytes , int totalbyte )
213
212
{
214
- // Console.WriteLine("CalculateN2N3FinalSIMDAdjustments's input debug. This is ascii count:" + asciibytes + " n4: " + n4 + " contbytes:" + contbytes + " totalbytes:" + totalbyte);
213
+ Console . WriteLine ( "---------" ) ;
214
+ Console . WriteLine ( "CalculateN2N3FinalSIMDAdjustments's input debug. This is ascii count:" + asciibytes + " n4: " + n4 + " contbytes:" + contbytes + " totalbytes:" + totalbyte ) ;
215
215
int n3 = asciibytes - 2 * n4 + 2 * contbytes - totalbyte ;
216
216
int n2 = - 2 * asciibytes + n4 - 3 * contbytes + 2 * totalbyte ;
217
217
int utfadjust = - 2 * n4 - 2 * n3 - n2 ;
218
218
int scalaradjust = - n4 ;
219
219
220
+ Console . WriteLine ( "CalculateN2N3FinalSIMDAdjustments's output debug. This is n3 count:" + n3 + " n2: " + n2 + " utfadjust:" + utfadjust + " scalaradjust:" + scalaradjust ) ;
221
+
222
+
220
223
return ( utfadjust , scalaradjust ) ;
221
224
}
222
225
@@ -392,6 +395,7 @@ public unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust(
392
395
393
396
public unsafe static byte * GetPointerToFirstInvalidByteAvx2 ( byte * pInputBuffer , int inputLength , out int utf16CodeUnitCountAdjustment , out int scalarCountAdjustment )
394
397
{
398
+ Console . WriteLine ( "-------------------------------------" ) ;
395
399
int processedLength = 0 ;
396
400
int TempUtf16CodeUnitCountAdjustment = 0 ;
397
401
int TempScalarCountAdjustment = 0 ;
@@ -544,7 +548,7 @@ public unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust(
544
548
//
545
549
if ( ! Avx2 . TestZ ( prevIncomplete , prevIncomplete ) )
546
550
{
547
- // TODO : this path is not explicitly tested, write tests
551
+ // TODO : this path is not explicitly tested, write tests
548
552
int totalbyteasciierror = processedLength - start_point ;
549
553
var ( utfadjustasciierror , scalaradjustasciierror ) = CalculateN2N3FinalSIMDAdjustments ( asciibytes , n4 , contbytes , totalbyteasciierror ) ;
550
554
@@ -577,6 +581,7 @@ public unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust(
577
581
Vector256 < byte > error = Avx2 . Xor ( must23As80 , sc ) ;
578
582
if ( ! Avx2 . TestZ ( error , error ) )
579
583
{
584
+ Console . WriteLine ( "--Error!" ) ;
580
585
int totalbyteasciierror = processedLength - start_point ;
581
586
var ( utfadjustasciierror , scalaradjustasciierror ) = calculateErrorPathadjust ( start_point , processedLength , pInputBuffer , asciibytes , n4 , contbytes ) ;
582
587
@@ -605,6 +610,8 @@ public unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust(
605
610
processedLength -= i ;
606
611
n4 += tempn4 ;
607
612
contbytes += tempcont ;
613
+ Console . WriteLine ( $ "Unterminated! Backing up by { i } ") ;
614
+
608
615
}
609
616
610
617
// No errors! Updating the variables we keep track of
@@ -631,7 +638,6 @@ public unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust(
631
638
632
639
utf16CodeUnitCountAdjustment = utf16adjust ;
633
640
scalarCountAdjustment = scalaradjust ;
634
-
635
641
}
636
642
637
643
0 commit comments