@@ -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,24 +1026,21 @@ 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 USE (input_length);
10621033 DCHECK_LE (output_length, input_length / 2 );
10631034
1064- // TODO(rezvan): Add relaxed version for simd methods to handle shared array
1065- // buffers.
1066-
10671035#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 ) {
10701038 return Uint8ArrayFromHexWithSSE (input_vector, buffer, output_length);
10711039 }
10721040#endif
10731041
10741042#ifdef NEON64
1075- if (!is_shared && get_vectorization_kind () == SimdKinds::kNeon ) {
1043+ if (get_vectorization_kind () == SimdKinds::kNeon ) {
10761044 return Uint8ArrayFromHexWithNeon (input_vector, buffer, output_length);
10771045 }
10781046#endif
@@ -1082,12 +1050,7 @@ bool ArrayBufferFromHex(const base::Vector<T>& input_vector, bool is_shared,
10821050 for (uint32_t i = 0 ; i < output_length * 2 ; i += 2 ) {
10831051 result = HandleRemainingHexValues (input_vector, i);
10841052 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 ();
10911054 } else {
10921055 return false ;
10931056 }
@@ -1096,11 +1059,11 @@ bool ArrayBufferFromHex(const base::Vector<T>& input_vector, bool is_shared,
10961059}
10971060
10981061template 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);
11011064template 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);
11041067
11051068#ifdef NEON64
11061069#undef NEON64
0 commit comments