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}
This commit is contained in:
sampsong 2017-03-30 11:36:53 -07:00 committed by Commit bot
parent e89452dd25
commit de74e1ac84

View File

@ -44,7 +44,11 @@ String16 calculateHash(const String16& str) {
size_t sizeInBytes = sizeof(UChar) * str.length();
data = reinterpret_cast<const uint32_t*>(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<const uint8_t*>(data)[i];
#else
if (i % 2) {
v |= reinterpret_cast<const uint8_t*>(data)[i - 1];
} else {
v |= reinterpret_cast<const uint8_t*>(data)[i + 1];
}
#endif
}
uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF;
hashes[current] = (hashes[current] + zi[current] * xi) % prime[current];