Skip to content

Commit a4bddba

Browse files
gsathyaCommit Bot
authored andcommitted
[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/702675 Reviewed-by: Adam Klein <[email protected]> Commit-Queue: Sathya Gunasekaran <[email protected]> Cr-Commit-Position: refs/heads/master@{#48319}
1 parent fee3717 commit a4bddba

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/objects.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6481,13 +6481,8 @@ Smi* JSObject::GetOrCreateIdentityHash(Isolate* isolate) {
64816481
return Smi::cast(hash_obj);
64826482
}
64836483

6484-
int masked_hash;
6485-
// TODO(gsathya): Remove the loop and pass kHashMask directly to
6486-
// GenerateIdentityHash.
6487-
do {
6488-
int hash = isolate->GenerateIdentityHash(Smi::kMaxValue);
6489-
masked_hash = hash & JSReceiver::kHashMask;
6490-
} while (masked_hash == PropertyArray::kNoHashSentinel);
6484+
int masked_hash = isolate->GenerateIdentityHash(JSReceiver::kHashMask);
6485+
DCHECK_NE(PropertyArray::kNoHashSentinel, masked_hash);
64916486

64926487
SetIdentityHash(masked_hash);
64936488
return Smi::FromInt(masked_hash);

src/objects.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,8 +1951,13 @@ class PropertyArray : public HeapObject {
19511951
typedef BodyDescriptor BodyDescriptorWeak;
19521952

19531953
static const int kLengthMask = 0x3ff;
1954+
#if V8_TARGET_ARCH_64_BIT
19541955
static const int kHashMask = 0x7ffffc00;
19551956
STATIC_ASSERT(kLengthMask + kHashMask == 0x7fffffff);
1957+
#else
1958+
static const int kHashMask = 0x3ffffc00;
1959+
STATIC_ASSERT(kLengthMask + kHashMask == 0x3fffffff);
1960+
#endif
19561961

19571962
static const int kMaxLength = kLengthMask;
19581963
STATIC_ASSERT(kMaxLength > kMaxNumberOfDescriptors);

0 commit comments

Comments
 (0)