Skip to content

Commit 437490f

Browse files
committed
base tests working
1 parent 4f85d11 commit 437490f

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/UTF8.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static void ToString(Vector128<byte> v)
1414
{
1515
Span<byte> b = stackalloc byte[16];
1616
v.CopyTo(b);
17-
// Console.WriteLine(Convert.ToHexString(b));
17+
// Console .WriteLine(Convert.ToHexString(b));
1818
}
1919

2020
// Returns &inputBuffer[inputLength] if the input buffer is valid.
@@ -480,7 +480,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
480480

481481
public unsafe static byte* GetPointerToFirstInvalidByteSse(byte* pInputBuffer, int inputLength, out int utf16CodeUnitCountAdjustment, out int scalarCountAdjustment)
482482
{
483-
// Console.WriteLine("-------------------Calling function--------------------");
483+
// Console .WriteLine("-------------------Calling function--------------------");
484484
int processedLength = 0;
485485
if (pInputBuffer == null || inputLength <= 0)
486486
{
@@ -510,7 +510,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
510510

511511
if (processedLength + 16 < inputLength)
512512
{
513-
// Console.WriteLine("-------SIMD kicking in-------");
513+
// Console .WriteLine("-------SIMD kicking in-------");
514514
Vector128<byte> prevInputBlock = Vector128<byte>.Zero;
515515

516516
Vector128<byte> maxValue = Vector128.Create(
@@ -591,23 +591,23 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
591591
int n4 = 0; // number of 4-byte sequences that start in this block
592592
for (; processedLength + 16 <= inputLength; processedLength += 16)
593593
{
594-
// Console.WriteLine($"Processing {processedLength} bytes", processedLength);
594+
// Console .WriteLine($"Processing {processedLength} bytes", processedLength);
595595

596596
Vector128<byte> currentBlock = Avx.LoadVector128(pInputBuffer + processedLength);
597-
int mask = Sse42.MoveMask(currentBlock.AsDouble());
598-
// ToString(currentBlock);
599-
// Console.WriteLine($"{mask}");
597+
int mask = Sse42.MoveMask(currentBlock);
598+
// ToString (currentBlock);
599+
// // Console .WriteLine($"{mask}");
600600
if (mask == 0)
601601
{
602602
// We have an ASCII block, no need to process it, but
603603
// we need to check if the previous block was incomplete.
604604
//
605605

606-
// Console.WriteLine("Found all ASCII");
606+
// Console .WriteLine("Found all ASCII");
607607
// ToString(prevIncomplete);
608608
if (!Sse41.TestZ(prevIncomplete, prevIncomplete))
609609
{
610-
// Console.WriteLine($"Found all-ascii but previous is incomplete.Triggering Rewind");
610+
// // Console .WriteLine($"Found all-ascii but previous is incomplete.Triggering Rewind");
611611
int off = processedLength >= 3 ? processedLength - 3 : processedLength;
612612
byte* invalidBytePointer = SimdUnicode.UTF8.SimpleRewindAndValidateWithErrors(16 - 3, pInputBuffer + processedLength - 3, inputLength - processedLength + 3);
613613
// So the code is correct up to invalidBytePointer
@@ -627,7 +627,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
627627
}
628628
else // Contains non-ASCII characters, we need to do non-trivial processing
629629
{
630-
// Console.WriteLine("Contains ASCII characters, firing standard SIMD routine");
630+
// Console .WriteLine("Contains ASCII characters, firing standard SIMD routine");
631631
// Use SubtractSaturate to effectively compare if bytes in block are greater than markers.
632632
// Contains non-ASCII characters, we need to do non-trivial processing
633633
Vector128<byte> prev1 = Ssse3.AlignRight(currentBlock, prevInputBlock, (byte)(16 - 1));
@@ -638,7 +638,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
638638
Vector128<byte> prev2 = Ssse3.AlignRight(currentBlock, prevInputBlock, (byte)(16 - 2));
639639
Vector128<byte> prev3 = Ssse3.AlignRight(currentBlock, prevInputBlock, (byte)(16 - 3));
640640
prevInputBlock = currentBlock;
641-
// Console.WriteLine("PrevIncomplete:");
641+
// // Console .WriteLine("PrevIncomplete:");
642642
// ToString(prevIncomplete);
643643

644644
Vector128<byte> isThirdByte = Sse2.SubtractSaturate(prev2, thirdByte);
@@ -649,7 +649,7 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
649649

650650
if (!Sse42.TestZ(error, error))
651651
{
652-
// Console.WriteLine($"Found error! rewinding...");
652+
// Console .WriteLine($"Found error! rewinding...");
653653

654654
byte* invalidBytePointer;
655655
if (processedLength == 0)
@@ -683,10 +683,10 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
683683
// important: we just update asciibytes if there was no error.
684684
// We count the number of ascii bytes in the block using just some simple arithmetic
685685
// and no expensive operation:
686-
asciibytes += (int)(32 - Popcnt.PopCount((uint)mask));
686+
asciibytes += (int)(16 - Popcnt.PopCount((uint)mask));
687687
}
688688

689-
// Console.WriteLine($"-----SIMD finished , calling scalar:");
689+
// Console .WriteLine($"-----SIMD finished , calling scalar:");
690690

691691
// We may still have an error.
692692
if (processedLength < inputLength || !Sse42.TestZ(prevIncomplete, prevIncomplete))

0 commit comments

Comments
 (0)