Skip to content

Commit

Permalink
deps: cherry-pick a4bddba from upstream V8
Browse files Browse the repository at this point in the history
Original commit message:

    [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 <adamk@chromium.org>
    Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#48319}

PR-URL: #19824
Refs: v8/v8@a4bddba
Fixes: #19769
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
  • Loading branch information
targos authored and gibfahn committed Apr 12, 2018
1 parent 53b702f commit c97237b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 6
#define V8_MINOR_VERSION 2
#define V8_BUILD_NUMBER 414
#define V8_PATCH_LEVEL 50
#define V8_PATCH_LEVEL 51

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
9 changes: 2 additions & 7 deletions deps/v8/src/objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6368,13 +6368,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);
Expand Down
5 changes: 5 additions & 0 deletions deps/v8/src/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -1954,8 +1954,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);
Expand Down

0 comments on commit c97237b

Please sign in to comment.