@@ -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,23 +1026,20 @@ 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
DCHECK_LE (output_length, input_length / 2 );
1062
1033
1063
- // TODO(rezvan): Add relaxed version for simd methods to handle shared array
1064
- // buffers.
1065
-
1066
1034
#ifdef __SSE3__
1067
- if (!is_shared && ( get_vectorization_kind () == SimdKinds::kAVX2 ||
1068
- get_vectorization_kind () == SimdKinds::kSSE ) ) {
1035
+ if (get_vectorization_kind () == SimdKinds::kAVX2 ||
1036
+ get_vectorization_kind () == SimdKinds::kSSE ) {
1069
1037
return Uint8ArrayFromHexWithSSE (input_vector, buffer, output_length);
1070
1038
}
1071
1039
#endif
1072
1040
1073
1041
#ifdef NEON64
1074
- if (!is_shared && get_vectorization_kind () == SimdKinds::kNeon ) {
1042
+ if (get_vectorization_kind () == SimdKinds::kNeon ) {
1075
1043
return Uint8ArrayFromHexWithNeon (input_vector, buffer, output_length);
1076
1044
}
1077
1045
#endif
@@ -1081,12 +1049,7 @@ bool ArrayBufferFromHex(const base::Vector<T>& input_vector, bool is_shared,
1081
1049
for (uint32_t i = 0 ; i < input_length; i += 2 ) {
1082
1050
result = HandleRemainingHexValues (input_vector, i);
1083
1051
if (result.has_value ()) {
1084
- if (is_shared) {
1085
- std::atomic_ref<uint8_t >(buffer[index++])
1086
- .store (result.value (), std::memory_order_relaxed);
1087
- } else {
1088
- buffer[index++] = result.value ();
1089
- }
1052
+ buffer[index++] = result.value ();
1090
1053
} else {
1091
1054
return false ;
1092
1055
}
@@ -1095,11 +1058,11 @@ bool ArrayBufferFromHex(const base::Vector<T>& input_vector, bool is_shared,
1095
1058
}
1096
1059
1097
1060
template bool ArrayBufferFromHex (
1098
- const base::Vector<const uint8_t >& input_vector, bool is_shared ,
1099
- uint8_t * buffer, size_t output_length);
1061
+ const base::Vector<const uint8_t >& input_vector, uint8_t * buffer ,
1062
+ size_t output_length);
1100
1063
template bool ArrayBufferFromHex (
1101
- const base::Vector<const base::uc16>& input_vector, bool is_shared ,
1102
- uint8_t * buffer, size_t output_length);
1064
+ const base::Vector<const base::uc16>& input_vector, uint8_t * buffer ,
1065
+ size_t output_length);
1103
1066
1104
1067
#ifdef NEON64
1105
1068
#undef NEON64
0 commit comments