From c97237bc104066ae1f3a8e5465dbc74a7fb4b297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 5 Apr 2018 10:43:42 +0200 Subject: [PATCH] deps: cherry-pick a4bddba from upstream V8 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 Commit-Queue: Sathya Gunasekaran Cr-Commit-Position: refs/heads/master@{#48319} PR-URL: https://github.com/nodejs/node/pull/19824 Refs: https://github.com/v8/v8/commit/a4bddba0b0dac116d987eea28479dba14663cda0 Fixes: https://github.com/nodejs/node/issues/19769 Reviewed-By: Yang Guo Reviewed-By: Gibson Fahnestock --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/objects.cc | 9 ++------- deps/v8/src/objects.h | 5 +++++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 25ce5d071e71c3..ce000d06c11659 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -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.) diff --git a/deps/v8/src/objects.cc b/deps/v8/src/objects.cc index 28c1cd681ffd46..d9d00e058f4ee0 100644 --- a/deps/v8/src/objects.cc +++ b/deps/v8/src/objects.cc @@ -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); diff --git a/deps/v8/src/objects.h b/deps/v8/src/objects.h index f9987c2837c466..5456bfc47f6027 100644 --- a/deps/v8/src/objects.h +++ b/deps/v8/src/objects.h @@ -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);