| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index ffe724f76376a911eaadda0064139f8381019667..f73d33f2a8edffb2e338bd956df8507e8dde9b34 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -8507,7 +8507,36 @@ template <typename Char>
|
| static inline bool CompareRawStringContents(const Char* const a,
|
| const Char* const b,
|
| int length) {
|
| - return CompareChars(a, b, length) == 0;
|
| + int i = 0;
|
| +#ifndef V8_HOST_CAN_READ_UNALIGNED
|
| + // If this architecture isn't comfortable reading unaligned ints
|
| + // then we have to check that the strings are aligned before
|
| + // comparing them blockwise.
|
| + const int kAlignmentMask = sizeof(uint32_t) - 1; // NOLINT
|
| + uintptr_t pa_addr = reinterpret_cast<uintptr_t>(a);
|
| + uintptr_t pb_addr = reinterpret_cast<uintptr_t>(b);
|
| + if (((pa_addr & kAlignmentMask) | (pb_addr & kAlignmentMask)) == 0) {
|
| +#endif
|
| + const int kStepSize = sizeof(int) / sizeof(Char); // NOLINT
|
| + int endpoint = length - kStepSize;
|
| + // Compare blocks until we reach near the end of the string.
|
| + for (; i <= endpoint; i += kStepSize) {
|
| + uint32_t wa = *reinterpret_cast<const uint32_t*>(a + i);
|
| + uint32_t wb = *reinterpret_cast<const uint32_t*>(b + i);
|
| + if (wa != wb) {
|
| + return false;
|
| + }
|
| + }
|
| +#ifndef V8_HOST_CAN_READ_UNALIGNED
|
| + }
|
| +#endif
|
| + // Compare the remaining characters that didn't fit into a block.
|
| + for (; i < length; i++) {
|
| + if (a[i] != b[i]) {
|
| + return false;
|
| + }
|
| + }
|
| + return true;
|
| }
|
|
|
|
|
|
|