Commit a4bddba0 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[Runtime] Use platform specific value for JSReceiver::HashMask

This allows us to remove the loop while calculating the hash value and
just use the HashMask as the mask for ComputeIntegerHash. This
previously overflowed on 32-bit systems failing the Smi::IsValid
check.

Bug: v8:6404
Change-Id: I84610a7592fa9d7ce4fa5cef7903bd50b8e8a4df
Reviewed-on: https://chromium-review.googlesource.com/702675Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48319}
parent fee37178
......@@ -6481,13 +6481,8 @@ Smi* JSObject::GetOrCreateIdentityHash(Isolate* isolate) {
return Smi::cast(hash_obj);
}
int masked_hash;
// TODO(gsathya): Remove the loop and pass kHashMask directly to
// GenerateIdentityHash.
do {
int hash = isolate->GenerateIdentityHash(Smi::kMaxValue);
masked_hash = hash & JSReceiver::kHashMask;
} while (masked_hash == PropertyArray::kNoHashSentinel);
int masked_hash = isolate->GenerateIdentityHash(JSReceiver::kHashMask);
DCHECK_NE(PropertyArray::kNoHashSentinel, masked_hash);
SetIdentityHash(masked_hash);
return Smi::FromInt(masked_hash);
......
......@@ -1951,8 +1951,13 @@ class PropertyArray : public HeapObject {
typedef BodyDescriptor BodyDescriptorWeak;
static const int kLengthMask = 0x3ff;
#if V8_TARGET_ARCH_64_BIT
static const int kHashMask = 0x7ffffc00;
STATIC_ASSERT(kLengthMask + kHashMask == 0x7fffffff);
#else
static const int kHashMask = 0x3ffffc00;
STATIC_ASSERT(kLengthMask + kHashMask == 0x3fffffff);
#endif
static const int kMaxLength = kLengthMask;
STATIC_ASSERT(kMaxLength > kMaxNumberOfDescriptors);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment