@@ -458,38 +458,16 @@ char NibbleToHex(uint8_t nibble) {
458
458
return c + (mask & correction);
459
459
}
460
460
461
- void PerformNibbleToHexAndWriteIntoStringOutPut (
462
- uint8_t byte, int index, DirectHandle<SeqOneByteString> string_output) {
463
- uint8_t high = byte >> 4 ;
464
- uint8_t low = byte & 0x0F ;
465
-
466
- string_output->SeqOneByteStringSet (index ++, NibbleToHex (high));
467
- string_output->SeqOneByteStringSet (index , NibbleToHex (low));
468
- }
469
-
470
461
void Uint8ArrayToHexSlow (const char * bytes, size_t length,
471
462
DirectHandle<SeqOneByteString> string_output) {
472
463
int index = 0 ;
473
464
for (size_t i = 0 ; i < length; i++) {
474
465
uint8_t byte = bytes[i];
475
- PerformNibbleToHexAndWriteIntoStringOutPut (byte, index , string_output);
476
- index += 2 ;
477
- }
478
- }
466
+ uint8_t high = byte >> 4 ;
467
+ uint8_t low = byte & 0x0F ;
479
468
480
- void AtomicUint8ArrayToHexSlow (const char * bytes, size_t length,
481
- DirectHandle<SeqOneByteString> string_output) {
482
- int index = 0 ;
483
- // std::atomic_ref<T> must not have a const T, see
484
- // https://cplusplus.github.io/LWG/issue3508
485
- // we instead provide a mutable input, which is ok since we are only reading
486
- // from it.
487
- char * mutable_bytes = const_cast <char *>(bytes);
488
- for (size_t i = 0 ; i < length; i++) {
489
- uint8_t byte =
490
- std::atomic_ref<char >(mutable_bytes[i]).load (std::memory_order_relaxed);
491
- PerformNibbleToHexAndWriteIntoStringOutPut (byte, index , string_output);
492
- index += 2 ;
469
+ string_output->SeqOneByteStringSet (index ++, NibbleToHex (high));
470
+ string_output->SeqOneByteStringSet (index ++, NibbleToHex (low));
493
471
}
494
472
}
495
473
@@ -618,14 +596,11 @@ void Uint8ArrayToHexFastWithNeon(const char* bytes, uint8_t* output,
618
596
#endif
619
597
} // namespace
620
598
621
- Tagged<Object> Uint8ArrayToHex (const char * bytes, size_t length, bool is_shared,
599
+ Tagged<Object> Uint8ArrayToHex (const char * bytes, size_t length,
622
600
DirectHandle<SeqOneByteString> string_output) {
623
- // TODO(rezvan): Add relaxed version for simd methods to handle shared array
624
- // buffers.
625
-
626
601
#ifdef __SSE3__
627
- if (!is_shared && ( get_vectorization_kind () == SimdKinds::kAVX2 ||
628
- get_vectorization_kind () == SimdKinds::kSSE ) ) {
602
+ if (get_vectorization_kind () == SimdKinds::kAVX2 ||
603
+ get_vectorization_kind () == SimdKinds::kSSE ) {
629
604
{
630
605
DisallowGarbageCollection no_gc;
631
606
Uint8ArrayToHexFastWithSSE (bytes, string_output->GetChars (no_gc), length);
@@ -635,7 +610,7 @@ Tagged<Object> Uint8ArrayToHex(const char* bytes, size_t length, bool is_shared,
635
610
#endif
636
611
637
612
#ifdef NEON64
638
- if (!is_shared && get_vectorization_kind () == SimdKinds::kNeon ) {
613
+ if (get_vectorization_kind () == SimdKinds::kNeon ) {
639
614
{
640
615
DisallowGarbageCollection no_gc;
641
616
Uint8ArrayToHexFastWithNeon (bytes, string_output->GetChars (no_gc),
@@ -645,11 +620,7 @@ Tagged<Object> Uint8ArrayToHex(const char* bytes, size_t length, bool is_shared,
645
620
}
646
621
#endif
647
622
648
- if (is_shared) {
649
- AtomicUint8ArrayToHexSlow (bytes, length, string_output);
650
- } else {
651
- Uint8ArrayToHexSlow (bytes, length, string_output);
652
- }
623
+ Uint8ArrayToHexSlow (bytes, length, string_output);
653
624
return *string_output;
654
625
}
655
626
@@ -1055,24 +1026,21 @@ bool Uint8ArrayFromHexWithNeon(const base::Vector<T>& input_vector,
1055
1026
} // namespace
1056
1027
1057
1028
template <typename T>
1058
- bool ArrayBufferFromHex (const base::Vector<T>& input_vector, bool is_shared ,
1059
- uint8_t * buffer, size_t output_length) {
1029
+ bool ArrayBufferFromHex (const base::Vector<T>& input_vector, uint8_t * buffer ,
1030
+ size_t output_length) {
1060
1031
size_t input_length = input_vector.size ();
1061
1032
USE (input_length);
1062
1033
DCHECK_LE (output_length, input_length / 2 );
1063
1034
1064
- // TODO(rezvan): Add relaxed version for simd methods to handle shared array
1065
- // buffers.
1066
-
1067
1035
#ifdef __SSE3__
1068
- if (!is_shared && ( get_vectorization_kind () == SimdKinds::kAVX2 ||
1069
- get_vectorization_kind () == SimdKinds::kSSE ) ) {
1036
+ if (get_vectorization_kind () == SimdKinds::kAVX2 ||
1037
+ get_vectorization_kind () == SimdKinds::kSSE ) {
1070
1038
return Uint8ArrayFromHexWithSSE (input_vector, buffer, output_length);
1071
1039
}
1072
1040
#endif
1073
1041
1074
1042
#ifdef NEON64
1075
- if (!is_shared && get_vectorization_kind () == SimdKinds::kNeon ) {
1043
+ if (get_vectorization_kind () == SimdKinds::kNeon ) {
1076
1044
return Uint8ArrayFromHexWithNeon (input_vector, buffer, output_length);
1077
1045
}
1078
1046
#endif
@@ -1082,12 +1050,7 @@ bool ArrayBufferFromHex(const base::Vector<T>& input_vector, bool is_shared,
1082
1050
for (uint32_t i = 0 ; i < output_length * 2 ; i += 2 ) {
1083
1051
result = HandleRemainingHexValues (input_vector, i);
1084
1052
if (result.has_value ()) {
1085
- if (is_shared) {
1086
- std::atomic_ref<uint8_t >(buffer[index ++])
1087
- .store (result.value (), std::memory_order_relaxed);
1088
- } else {
1089
- buffer[index ++] = result.value ();
1090
- }
1053
+ buffer[index ++] = result.value ();
1091
1054
} else {
1092
1055
return false ;
1093
1056
}
@@ -1096,11 +1059,11 @@ bool ArrayBufferFromHex(const base::Vector<T>& input_vector, bool is_shared,
1096
1059
}
1097
1060
1098
1061
template bool ArrayBufferFromHex (
1099
- const base::Vector<const uint8_t >& input_vector, bool is_shared ,
1100
- uint8_t * buffer, size_t output_length);
1062
+ const base::Vector<const uint8_t >& input_vector, uint8_t * buffer ,
1063
+ size_t output_length);
1101
1064
template bool ArrayBufferFromHex (
1102
- const base::Vector<const base::uc16>& input_vector, bool is_shared ,
1103
- uint8_t * buffer, size_t output_length);
1065
+ const base::Vector<const base::uc16>& input_vector, uint8_t * buffer ,
1066
+ size_t output_length);
1104
1067
1105
1068
#ifdef NEON64
1106
1069
#undef NEON64
0 commit comments