@@ -458,38 +458,16 @@ char NibbleToHex(uint8_t nibble) {
458458 return c + (mask & correction);
459459}
460460
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-
470461void Uint8ArrayToHexSlow (const char * bytes, size_t length,
471462 DirectHandle<SeqOneByteString> string_output) {
472463 int index = 0 ;
473464 for (size_t i = 0 ; i < length; i++) {
474465 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 ;
479468
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));
493471 }
494472}
495473
@@ -618,14 +596,11 @@ void Uint8ArrayToHexFastWithNeon(const char* bytes, uint8_t* output,
618596#endif
619597} // namespace
620598
621- Tagged<Object> Uint8ArrayToHex (const char * bytes, size_t length, bool is_shared,
599+ Tagged<Object> Uint8ArrayToHex (const char * bytes, size_t length,
622600 DirectHandle<SeqOneByteString> string_output) {
623- // TODO(rezvan): Add relaxed version for simd methods to handle shared array
624- // buffers.
625-
626601#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 ) {
629604 {
630605 DisallowGarbageCollection no_gc;
631606 Uint8ArrayToHexFastWithSSE (bytes, string_output->GetChars (no_gc), length);
@@ -635,7 +610,7 @@ Tagged<Object> Uint8ArrayToHex(const char* bytes, size_t length, bool is_shared,
635610#endif
636611
637612#ifdef NEON64
638- if (!is_shared && get_vectorization_kind () == SimdKinds::kNeon ) {
613+ if (get_vectorization_kind () == SimdKinds::kNeon ) {
639614 {
640615 DisallowGarbageCollection no_gc;
641616 Uint8ArrayToHexFastWithNeon (bytes, string_output->GetChars (no_gc),
@@ -645,11 +620,7 @@ Tagged<Object> Uint8ArrayToHex(const char* bytes, size_t length, bool is_shared,
645620 }
646621#endif
647622
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);
653624 return *string_output;
654625}
655626
@@ -1055,23 +1026,20 @@ bool Uint8ArrayFromHexWithNeon(const base::Vector<T>& input_vector,
10551026} // namespace
10561027
10571028template <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) {
10601031 size_t input_length = input_vector.size ();
10611032 DCHECK_LE (output_length, input_length / 2 );
10621033
1063- // TODO(rezvan): Add relaxed version for simd methods to handle shared array
1064- // buffers.
1065-
10661034#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 ) {
10691037 return Uint8ArrayFromHexWithSSE (input_vector, buffer, output_length);
10701038 }
10711039#endif
10721040
10731041#ifdef NEON64
1074- if (!is_shared && get_vectorization_kind () == SimdKinds::kNeon ) {
1042+ if (get_vectorization_kind () == SimdKinds::kNeon ) {
10751043 return Uint8ArrayFromHexWithNeon (input_vector, buffer, output_length);
10761044 }
10771045#endif
@@ -1081,12 +1049,7 @@ bool ArrayBufferFromHex(const base::Vector<T>& input_vector, bool is_shared,
10811049 for (uint32_t i = 0 ; i < input_length; i += 2 ) {
10821050 result = HandleRemainingHexValues (input_vector, i);
10831051 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 ();
10901053 } else {
10911054 return false ;
10921055 }
@@ -1095,11 +1058,11 @@ bool ArrayBufferFromHex(const base::Vector<T>& input_vector, bool is_shared,
10951058}
10961059
10971060template 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);
11001063template 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);
11031066
11041067#ifdef NEON64
11051068#undef NEON64
0 commit comments