From de74e1ac8495305718d5a6ddbe7a4702eadeead0 Mon Sep 17 00:00:00 2001 From: sampsong Date: Thu, 30 Mar 2017 11:36:53 -0700 Subject: [PATCH] PPC/S390: Fix inspector/runtime/es6-module.js test failure due to endianness R=dgozman@chromium.org, kozyatinskiy@chromium.org, bjaideep@ca.ibm.com, jyan@ca.ibm.com, joransiu@ca.ibm.com BUG= Review-Url: https://codereview.chromium.org/2787713003 Cr-Commit-Position: refs/heads/master@{#44279} --- src/inspector/v8-debugger-script.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/inspector/v8-debugger-script.cc b/src/inspector/v8-debugger-script.cc index f8dae51812..d151ab821f 100644 --- a/src/inspector/v8-debugger-script.cc +++ b/src/inspector/v8-debugger-script.cc @@ -44,7 +44,11 @@ String16 calculateHash(const String16& str) { size_t sizeInBytes = sizeof(UChar) * str.length(); data = reinterpret_cast(str.characters16()); for (size_t i = 0; i < sizeInBytes / 4; i += 4) { +#if V8_TARGET_LITTLE_ENDIAN uint32_t v = data[i]; +#else + uint32_t v = (data[i] << 16) | (data[i] >> 16); +#endif uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; zi[current] = (zi[current] * random[current]) % prime[current]; @@ -54,7 +58,15 @@ String16 calculateHash(const String16& str) { uint32_t v = 0; for (size_t i = sizeInBytes - sizeInBytes % 4; i < sizeInBytes; ++i) { v <<= 8; +#if V8_TARGET_LITTLE_ENDIAN v |= reinterpret_cast(data)[i]; +#else + if (i % 2) { + v |= reinterpret_cast(data)[i - 1]; + } else { + v |= reinterpret_cast(data)[i + 1]; + } +#endif } uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; hashes[current] = (hashes[current] + zi[current] * xi) % prime[current];