| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8c508b9 commit 754d28e
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ | |||
| 38 | 38 | ||
| 39 | 39 | # Reset this number to 0 on major V8 upgrades. | |
| 40 | 40 | # Increment by one for each non-official patch applied to deps/v8. | |
| 41 | - 'v8_embedder_string': '-node.7', | ||
| 41 | + 'v8_embedder_string': '-node.8', | ||
| 42 | 42 | ||
| 43 | 43 | ##### V8 defaults for Node.js ##### | |
| 44 | 44 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -883,14 +883,14 @@ BUILTIN(Uint8ArrayFromHex) { | |||
| 883 | 883 | base::Vector<const uint8_t> input_vector = | |
| 884 | 884 | input_content.ToOneByteVector(); | |
| 885 | 885 | result = ArrayBufferFromHex( | |
| 886 | - input_vector, /*is_shared*/ false, | ||
| 887 | - static_cast<uint8_t*>(buffer->backing_store()), output_length); | ||
| 886 | + input_vector, static_cast<uint8_t*>(buffer->backing_store()), | ||
| 887 | + output_length); | ||
| 888 | 888 | } else { | |
| 889 | 889 | base::Vector<const base::uc16> input_vector = | |
| 890 | 890 | input_content.ToUC16Vector(); | |
| 891 | 891 | result = ArrayBufferFromHex( | |
| 892 | - input_vector, /*is_shared*/ false, | ||
| 893 | - static_cast<uint8_t*>(buffer->backing_store()), output_length); | ||
| 892 | + input_vector, static_cast<uint8_t*>(buffer->backing_store()), | ||
| 893 | + output_length); | ||
| 894 | 894 | } | |
| 895 | 895 | } | |
| 896 | 896 | ||
@@ -959,6 +959,11 @@ BUILTIN(Uint8ArrayPrototypeSetFromHex) { | |||
| 959 | 959 | size_t output_length = (input_length / 2); | |
| 960 | 960 | output_length = std::min(output_length, array_length); | |
| 961 | 961 | ||
| 962 | + // TODO(rezvan): Add path for typed arrays backed by SharedArrayBuffer | ||
| 963 | + if (uint8array->buffer()->is_shared()) { | ||
| 964 | + UNIMPLEMENTED(); | ||
| 965 | + } | ||
| 966 | + | ||
| 962 | 967 | // 7. Let result be FromHex(string, byteLength). | |
| 963 | 968 | // 8. Let bytes be result.[[Bytes]]. | |
| 964 | 969 | // 9. Let written be the length of bytes. | |
@@ -974,15 +979,15 @@ BUILTIN(Uint8ArrayPrototypeSetFromHex) { | |||
| 974 | 979 | if (input_content.IsOneByte()) { | |
| 975 | 980 | base::Vector<const uint8_t> input_vector = | |
| 976 | 981 | input_content.ToOneByteVector(); | |
| 977 | - result = ArrayBufferFromHex( | ||
| 978 | - input_vector, uint8array->buffer()->is_shared(), | ||
| 979 | - static_cast<uint8_t*>(uint8array->DataPtr()), output_length); | ||
| 982 | + result = ArrayBufferFromHex(input_vector, | ||
| 983 | + static_cast<uint8_t*>(uint8array->DataPtr()), | ||
| 984 | + output_length); | ||
| 980 | 985 | } else { | |
| 981 | 986 | base::Vector<const base::uc16> input_vector = | |
| 982 | 987 | input_content.ToUC16Vector(); | |
| 983 | - result = ArrayBufferFromHex( | ||
| 984 | - input_vector, uint8array->buffer()->is_shared(), | ||
| 985 | - static_cast<uint8_t*>(uint8array->DataPtr()), output_length); | ||
| 988 | + result = ArrayBufferFromHex(input_vector, | ||
| 989 | + static_cast<uint8_t*>(uint8array->DataPtr()), | ||
| 990 | + output_length); | ||
| 986 | 991 | } | |
| 987 | 992 | } | |
| 988 | 993 | ||
@@ -1052,8 +1057,7 @@ BUILTIN(Uint8ArrayPrototypeToHex) { | |||
| 1052 | 1057 | // b. Set hex to StringPad(hex, 2, "0", start). | |
| 1053 | 1058 | // c. Set out to the string-concatenation of out and hex. | |
| 1054 | 1059 | // 6. Return out. | |
| 1055 | - return Uint8ArrayToHex(bytes, length, uint8array->buffer()->is_shared(), | ||
| 1056 | - output); | ||
| 1060 | + return Uint8ArrayToHex(bytes, length, output); | ||
| 1057 | 1061 | } | |
| 1058 | 1062 | ||
| 1059 | 1063 | } // namespace internal | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,11 +20,11 @@ uintptr_t ArrayIndexOfIncludesSmiOrObject(Address array_start, | |||
| 20 | 20 | uintptr_t ArrayIndexOfIncludesDouble(Address array_start, uintptr_t array_len, | |
| 21 | 21 | uintptr_t from_index, | |
| 22 | 22 | Address search_element); | |
| 23 | - Tagged<Object> Uint8ArrayToHex(const char* bytes, size_t length, bool is_shared, | ||
| 23 | + Tagged<Object> Uint8ArrayToHex(const char* bytes, size_t length, | ||
| 24 | 24 | DirectHandle<SeqOneByteString> string_output); | |
| 25 | 25 | template <typename T> | |
| 26 | - bool ArrayBufferFromHex(const base::Vector<T>& input_vector, bool is_shared, | ||
| 27 | - uint8_t* buffer, size_t output_length); | ||
| 26 | + bool ArrayBufferFromHex(const base::Vector<T>& input_vector, uint8_t* buffer, | ||
| 27 | + size_t output_length); | ||
| 28 | 28 | ||
| 29 | 29 | } // namespace internal | |
| 30 | 30 | } // namespace v8 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments