diff --git a/common.gypi b/common.gypi index 2621b5e327d5d8..c06cf7104dc4ac 100644 --- a/common.gypi +++ b/common.gypi @@ -25,7 +25,7 @@ 'uv_library%': 'static_library', 'clang%': 0, - + 'openssl_fips%': '', # Default to -O0 for debug builds. @@ -33,7 +33,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.32', + 'v8_embedder_string': '-node.33', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/ast/ast-value-factory.cc b/deps/v8/src/ast/ast-value-factory.cc index 5efecc5375a33d..fc8be819f6cf93 100644 --- a/deps/v8/src/ast/ast-value-factory.cc +++ b/deps/v8/src/ast/ast-value-factory.cc @@ -182,7 +182,7 @@ std::forward_list AstConsString::ToRawStrings() const { return result; } -AstStringConstants::AstStringConstants(Isolate* isolate, uint32_t hash_seed) +AstStringConstants::AstStringConstants(Isolate* isolate, uint64_t hash_seed) : zone_(isolate->allocator(), ZONE_NAME), string_table_(AstRawString::Compare), hash_seed_(hash_seed) { diff --git a/deps/v8/src/ast/ast-value-factory.h b/deps/v8/src/ast/ast-value-factory.h index a453455dd015b3..e85b0675bf6fed 100644 --- a/deps/v8/src/ast/ast-value-factory.h +++ b/deps/v8/src/ast/ast-value-factory.h @@ -240,14 +240,14 @@ class AstBigInt { class AstStringConstants final { public: - AstStringConstants(Isolate* isolate, uint32_t hash_seed); + AstStringConstants(Isolate* isolate, uint64_t hash_seed); #define F(name, str) \ const AstRawString* name##_string() const { return name##_string_; } AST_STRING_CONSTANTS(F) #undef F - uint32_t hash_seed() const { return hash_seed_; } + uint64_t hash_seed() const { return hash_seed_; } const base::CustomMatcherHashMap* string_table() const { return &string_table_; } @@ -255,7 +255,7 @@ class AstStringConstants final { private: Zone zone_; base::CustomMatcherHashMap string_table_; - uint32_t hash_seed_; + uint64_t hash_seed_; #define F(name, str) AstRawString* name##_string_; AST_STRING_CONSTANTS(F) @@ -267,7 +267,7 @@ class AstStringConstants final { class AstValueFactory { public: AstValueFactory(Zone* zone, const AstStringConstants* string_constants, - uint32_t hash_seed) + uint64_t hash_seed) : string_table_(string_constants->string_table()), strings_(nullptr), strings_end_(&strings_), @@ -354,7 +354,7 @@ class AstValueFactory { Zone* zone_; - uint32_t hash_seed_; + uint64_t hash_seed_; }; } // namespace internal } // namespace v8 diff --git a/deps/v8/src/builtins/builtins-collections-gen.cc b/deps/v8/src/builtins/builtins-collections-gen.cc index edbfb26a7132f2..e9791c164995ac 100644 --- a/deps/v8/src/builtins/builtins-collections-gen.cc +++ b/deps/v8/src/builtins/builtins-collections-gen.cc @@ -684,7 +684,7 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler { Node* key_tagged, Variable* result, Label* entry_found, Label* not_found); - Node* ComputeIntegerHashForString(Node* context, Node* string_key); + Node* ComputeStringHash(Node* context, Node* string_key); void SameValueZeroString(Node* context, Node* key_string, Node* candidate_key, Label* if_same, Label* if_not_same); @@ -828,8 +828,7 @@ void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForSmiKey( Node* table, Node* smi_key, Variable* result, Label* entry_found, Label* not_found) { Node* const key_untagged = SmiUntag(smi_key); - Node* const hash = - ChangeInt32ToIntPtr(ComputeIntegerHash(key_untagged, Int32Constant(0))); + Node* const hash = ChangeInt32ToIntPtr(ComputeUnseededHash(key_untagged)); CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0))); result->Bind(hash); FindOrderedHashTableEntry( @@ -844,7 +843,7 @@ template void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForStringKey( Node* context, Node* table, Node* key_tagged, Variable* result, Label* entry_found, Label* not_found) { - Node* const hash = ComputeIntegerHashForString(context, key_tagged); + Node* const hash = ComputeStringHash(context, key_tagged); CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0))); result->Bind(hash); FindOrderedHashTableEntry( @@ -902,8 +901,8 @@ void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForOtherKey( result, entry_found, not_found); } -Node* CollectionsBuiltinsAssembler::ComputeIntegerHashForString( - Node* context, Node* string_key) { +Node* CollectionsBuiltinsAssembler::ComputeStringHash(Node* context, + Node* string_key) { VARIABLE(var_result, MachineType::PointerRepresentation()); Label hash_not_computed(this), done(this, &var_result); diff --git a/deps/v8/src/code-stub-assembler.cc b/deps/v8/src/code-stub-assembler.cc index 9a51017899dc97..01b73bcf405e4e 100644 --- a/deps/v8/src/code-stub-assembler.cc +++ b/deps/v8/src/code-stub-assembler.cc @@ -230,10 +230,6 @@ HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR); HEAP_CONSTANT_LIST(HEAP_CONSTANT_TEST); #undef HEAP_CONSTANT_TEST -TNode CodeStubAssembler::HashSeed() { - return LoadAndUntagToWord32Root(Heap::kHashSeedRootIndex); -} - Node* CodeStubAssembler::IntPtrOrSmiConstant(int value, ParameterMode mode) { if (mode == SMI_PARAMETERS) { return SmiConstant(value); @@ -7094,14 +7090,9 @@ template void CodeStubAssembler::NameDictionaryLookup( TNode, TNode, Label*, TVariable*, Label*, int, LookupMode); -Node* CodeStubAssembler::ComputeIntegerHash(Node* key) { - return ComputeIntegerHash(key, IntPtrConstant(kZeroHashSeed)); -} - -Node* CodeStubAssembler::ComputeIntegerHash(Node* key, Node* seed) { - // See v8::internal::ComputeIntegerHash() +Node* CodeStubAssembler::ComputeUnseededHash(Node* key) { + // See v8::internal::ComputeUnseededHash() Node* hash = TruncateIntPtrToInt32(key); - hash = Word32Xor(hash, seed); hash = Int32Add(Word32Xor(hash, Int32Constant(0xFFFFFFFF)), Word32Shl(hash, Int32Constant(15))); hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12))); @@ -7112,6 +7103,21 @@ Node* CodeStubAssembler::ComputeIntegerHash(Node* key, Node* seed) { return Word32And(hash, Int32Constant(0x3FFFFFFF)); } +Node* CodeStubAssembler::ComputeSeededHash(Node* key) { + Node* const function_addr = + ExternalConstant(ExternalReference::compute_integer_hash()); + Node* const isolate_ptr = + ExternalConstant(ExternalReference::isolate_address(isolate())); + + MachineType type_ptr = MachineType::Pointer(); + MachineType type_uint32 = MachineType::Uint32(); + + Node* const result = + CallCFunction2(type_uint32, type_ptr, type_uint32, function_addr, + isolate_ptr, TruncateIntPtrToInt32(key)); + return result; +} + void CodeStubAssembler::NumberDictionaryLookup( TNode dictionary, TNode intptr_index, Label* if_found, TVariable* var_entry, Label* if_not_found) { @@ -7122,9 +7128,7 @@ void CodeStubAssembler::NumberDictionaryLookup( TNode capacity = SmiUntag(GetCapacity(dictionary)); TNode mask = IntPtrSub(capacity, IntPtrConstant(1)); - TNode int32_seed = HashSeed(); - TNode hash = - ChangeUint32ToWord(ComputeIntegerHash(intptr_index, int32_seed)); + TNode hash = ChangeUint32ToWord(ComputeSeededHash(intptr_index)); Node* key_as_float64 = RoundIntPtrToFloat64(intptr_index); // See Dictionary::FirstProbe(). diff --git a/deps/v8/src/code-stub-assembler.h b/deps/v8/src/code-stub-assembler.h index 35341b65d53e66..cbfc3dce38f536 100644 --- a/deps/v8/src/code-stub-assembler.h +++ b/deps/v8/src/code-stub-assembler.h @@ -221,8 +221,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { HEAP_CONSTANT_LIST(HEAP_CONSTANT_TEST) #undef HEAP_CONSTANT_TEST - TNode HashSeed(); - Node* IntPtrOrSmiConstant(int value, ParameterMode mode); TNode BoolConstant(bool value) { return value ? Int32TrueConstant() : Int32FalseConstant(); @@ -1883,8 +1881,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { int inlined_probes = kInlinedDictionaryProbes, LookupMode mode = kFindExisting); - Node* ComputeIntegerHash(Node* key); - Node* ComputeIntegerHash(Node* key, Node* seed); + Node* ComputeUnseededHash(Node* key); + Node* ComputeSeededHash(Node* key); void NumberDictionaryLookup(TNode dictionary, TNode intptr_index, Label* if_found, diff --git a/deps/v8/src/compiler/effect-control-linearizer.cc b/deps/v8/src/compiler/effect-control-linearizer.cc index 921bfd7852a770..d9554c06b5d785 100644 --- a/deps/v8/src/compiler/effect-control-linearizer.cc +++ b/deps/v8/src/compiler/effect-control-linearizer.cc @@ -4583,8 +4583,8 @@ Node* EffectControlLinearizer::LowerFindOrderedHashMapEntry(Node* node) { } } -Node* EffectControlLinearizer::ComputeIntegerHash(Node* value) { - // See v8::internal::ComputeIntegerHash() +Node* EffectControlLinearizer::ComputeUnseededHash(Node* value) { + // See v8::internal::ComputeUnseededHash() value = __ Int32Add(__ Word32Xor(value, __ Int32Constant(0xFFFFFFFF)), __ Word32Shl(value, __ Int32Constant(15))); value = __ Word32Xor(value, __ Word32Shr(value, __ Int32Constant(12))); @@ -4602,7 +4602,7 @@ Node* EffectControlLinearizer::LowerFindOrderedHashMapEntryForInt32Key( Node* key = NodeProperties::GetValueInput(node, 1); // Compute the integer hash code. - Node* hash = ChangeUint32ToUintPtr(ComputeIntegerHash(key)); + Node* hash = ChangeUint32ToUintPtr(ComputeUnseededHash(key)); Node* number_of_buckets = ChangeSmiToIntPtr(__ LoadField( AccessBuilder::ForOrderedHashTableBaseNumberOfBuckets(), table)); diff --git a/deps/v8/src/compiler/effect-control-linearizer.h b/deps/v8/src/compiler/effect-control-linearizer.h index 7f297f6a12a4af..870208dbea97c4 100644 --- a/deps/v8/src/compiler/effect-control-linearizer.h +++ b/deps/v8/src/compiler/effect-control-linearizer.h @@ -178,7 +178,7 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer { Node* frame_state); Node* BuildFloat64RoundDown(Node* value); Node* BuildFloat64RoundTruncate(Node* input); - Node* ComputeIntegerHash(Node* value); + Node* ComputeUnseededHash(Node* value); Node* LowerStringComparison(Callable const& callable, Node* node); Node* IsElementsKindGreaterThan(Node* kind, ElementsKind reference_kind); diff --git a/deps/v8/src/external-reference.cc b/deps/v8/src/external-reference.cc index 8b09c67ccceca9..856ff6d54eb7fc 100644 --- a/deps/v8/src/external-reference.cc +++ b/deps/v8/src/external-reference.cc @@ -778,6 +778,15 @@ ExternalReference ExternalReference::jsreceiver_create_identity_hash( return ExternalReference(Redirect(FUNCTION_ADDR(f))); } +static uint32_t ComputeSeededIntegerHash(Isolate* isolate, uint32_t key) { + DisallowHeapAllocation no_gc; + return ComputeSeededHash(key, isolate->heap()->HashSeed()); +} + +ExternalReference ExternalReference::compute_integer_hash() { + return ExternalReference(Redirect(FUNCTION_ADDR(ComputeSeededIntegerHash))); +} + ExternalReference ExternalReference::copy_fast_number_jsarray_elements_to_typed_array() { return ExternalReference( diff --git a/deps/v8/src/external-reference.h b/deps/v8/src/external-reference.h index 0332c519747741..373485d6a91530 100644 --- a/deps/v8/src/external-reference.h +++ b/deps/v8/src/external-reference.h @@ -81,6 +81,7 @@ class StatsCounter; V(address_of_uint32_bias, "uint32_bias") \ V(bytecode_size_table_address, "Bytecodes::bytecode_size_table_address") \ V(check_object_type, "check_object_type") \ + V(compute_integer_hash, "ComputeSeededHash") \ V(compute_output_frames_function, "Deoptimizer::ComputeOutputFrames()") \ V(copy_fast_number_jsarray_elements_to_typed_array, \ "copy_fast_number_jsarray_elements_to_typed_array") \ diff --git a/deps/v8/src/flag-definitions.h b/deps/v8/src/flag-definitions.h index e8226006df48b0..980362a09d697e 100644 --- a/deps/v8/src/flag-definitions.h +++ b/deps/v8/src/flag-definitions.h @@ -162,6 +162,7 @@ struct MaybeBoolFlag { FLAG(MAYBE_BOOL, MaybeBoolFlag, nam, {false COMMA false}, cmt) #define DEFINE_INT(nam, def, cmt) FLAG(INT, int, nam, def, cmt) #define DEFINE_UINT(nam, def, cmt) FLAG(UINT, unsigned int, nam, def, cmt) +#define DEFINE_UINT64(nam, def, cmt) FLAG(UINT64, uint64_t, nam, def, cmt) #define DEFINE_FLOAT(nam, def, cmt) FLAG(FLOAT, double, nam, def, cmt) #define DEFINE_SIZE_T(nam, def, cmt) FLAG(SIZE_T, size_t, nam, def, cmt) #define DEFINE_STRING(nam, def, cmt) FLAG(STRING, const char*, nam, def, cmt) @@ -1019,9 +1020,9 @@ DEFINE_BOOL(randomize_hashes, true, "(with snapshots this option cannot override the baked-in seed)") DEFINE_BOOL(rehash_snapshot, true, "rehash strings from the snapshot to override the baked-in seed") -DEFINE_INT(hash_seed, 0, - "Fixed seed to use to hash property keys (0 means random)" - "(with snapshots this option cannot override the baked-in seed)") +DEFINE_UINT64(hash_seed, 0, + "Fixed seed to use to hash property keys (0 means random)" + "(with snapshots this option cannot override the baked-in seed)") DEFINE_INT(random_seed, 0, "Default seed for initializing random generator " "(0, the default, means to use system random).") diff --git a/deps/v8/src/flags.cc b/deps/v8/src/flags.cc index ef5772dce4d3d9..e003f09a03b5f5 100644 --- a/deps/v8/src/flags.cc +++ b/deps/v8/src/flags.cc @@ -39,6 +39,7 @@ struct Flag { TYPE_MAYBE_BOOL, TYPE_INT, TYPE_UINT, + TYPE_UINT64, TYPE_FLOAT, TYPE_SIZE_T, TYPE_STRING, @@ -78,6 +79,11 @@ struct Flag { return reinterpret_cast(valptr_); } + uint64_t* uint64_variable() const { + DCHECK(type_ == TYPE_UINT64); + return reinterpret_cast(valptr_); + } + double* float_variable() const { DCHECK(type_ == TYPE_FLOAT); return reinterpret_cast(valptr_); @@ -121,6 +127,11 @@ struct Flag { return *reinterpret_cast(defptr_); } + uint64_t uint64_default() const { + DCHECK(type_ == TYPE_UINT64); + return *reinterpret_cast(defptr_); + } + double float_default() const { DCHECK(type_ == TYPE_FLOAT); return *reinterpret_cast(defptr_); @@ -152,6 +163,8 @@ struct Flag { return *int_variable() == int_default(); case TYPE_UINT: return *uint_variable() == uint_default(); + case TYPE_UINT64: + return *uint64_variable() == uint64_default(); case TYPE_FLOAT: return *float_variable() == float_default(); case TYPE_SIZE_T: @@ -184,6 +197,9 @@ struct Flag { case TYPE_UINT: *uint_variable() = uint_default(); break; + case TYPE_UINT64: + *uint64_variable() = uint64_default(); + break; case TYPE_FLOAT: *float_variable() = float_default(); break; @@ -217,6 +233,8 @@ static const char* Type2String(Flag::FlagType type) { case Flag::TYPE_INT: return "int"; case Flag::TYPE_UINT: return "uint"; + case Flag::TYPE_UINT64: + return "uint64"; case Flag::TYPE_FLOAT: return "float"; case Flag::TYPE_SIZE_T: return "size_t"; @@ -243,6 +261,9 @@ std::ostream& operator<<(std::ostream& os, const Flag& flag) { // NOLINT case Flag::TYPE_UINT: os << *flag.uint_variable(); break; + case Flag::TYPE_UINT64: + os << *flag.uint64_variable(); + break; case Flag::TYPE_FLOAT: os << *flag.float_variable(); break; @@ -464,6 +485,12 @@ int FlagList::SetFlagsFromCommandLine(int* argc, return_code = j; } break; + case Flag::TYPE_UINT64: + if (!TryParseUnsigned(flag, arg, value, &endp, + flag->uint64_variable())) { + return_code = j; + } + break; case Flag::TYPE_FLOAT: *flag->float_variable() = strtod(value, &endp); break; diff --git a/deps/v8/src/frames.cc b/deps/v8/src/frames.cc index 2ba38e6b66d504..46adfcfd0bc4cb 100644 --- a/deps/v8/src/frames.cc +++ b/deps/v8/src/frames.cc @@ -2146,7 +2146,7 @@ InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* InnerPointerToCodeCache::GetCacheEntry(Address inner_pointer) { isolate_->counters()->pc_to_code()->Increment(); DCHECK(base::bits::IsPowerOfTwo(kInnerPointerToCodeCacheSize)); - uint32_t hash = ComputeIntegerHash( + uint32_t hash = ComputeUnseededHash( ObjectAddressForHashing(reinterpret_cast(inner_pointer))); uint32_t index = hash & (kInnerPointerToCodeCacheSize - 1); InnerPointerToCodeCacheEntry* entry = cache(index); diff --git a/deps/v8/src/heap/heap-inl.h b/deps/v8/src/heap/heap-inl.h index 836923f31a29cc..f4e008a19c0fb8 100644 --- a/deps/v8/src/heap/heap-inl.h +++ b/deps/v8/src/heap/heap-inl.h @@ -529,13 +529,13 @@ Oddball* Heap::ToBoolean(bool condition) { return condition ? true_value() : false_value(); } -uint32_t Heap::HashSeed() { - uint32_t seed = static_cast(hash_seed()->value()); +uint64_t Heap::HashSeed() { + uint64_t seed; + hash_seed()->copy_out(0, reinterpret_cast(&seed), kInt64Size); DCHECK(FLAG_randomize_hashes || seed == 0); return seed; } - int Heap::NextScriptId() { int last_id = last_script_id()->value(); if (last_id == Smi::kMaxValue) last_id = v8::UnboundScript::kNoScriptId; diff --git a/deps/v8/src/heap/heap.cc b/deps/v8/src/heap/heap.cc index d8fad6dd6ff8c0..2afa50b75e857f 100644 --- a/deps/v8/src/heap/heap.cc +++ b/deps/v8/src/heap/heap.cc @@ -4693,10 +4693,6 @@ bool Heap::SetUp() { new ReadOnlySpace(this, RO_SPACE, NOT_EXECUTABLE); if (!read_only_space_->SetUp()) return false; - // Set up the seed that is used to randomize the string hash function. - DCHECK_EQ(Smi::kZero, hash_seed()); - if (FLAG_randomize_hashes) InitializeHashSeed(); - for (int i = 0; i < static_cast(v8::Isolate::kUseCounterFeatureCount); i++) { deferred_counters_[i] = 0; @@ -4756,12 +4752,14 @@ bool Heap::SetUp() { } void Heap::InitializeHashSeed() { + uint64_t new_hash_seed; if (FLAG_hash_seed == 0) { - int rnd = isolate()->random_number_generator()->NextInt(); - set_hash_seed(Smi::FromInt(rnd & Name::kHashBitMask)); + int64_t rnd = isolate()->random_number_generator()->NextInt64(); + new_hash_seed = static_cast(rnd); } else { - set_hash_seed(Smi::FromInt(FLAG_hash_seed)); + new_hash_seed = static_cast(FLAG_hash_seed); } + hash_seed()->copy_in(0, reinterpret_cast(&new_hash_seed), kInt64Size); } void Heap::SetStackLimits() { diff --git a/deps/v8/src/heap/heap.h b/deps/v8/src/heap/heap.h index a051d7262ebb02..a5038b254d9b6c 100644 --- a/deps/v8/src/heap/heap.h +++ b/deps/v8/src/heap/heap.h @@ -280,6 +280,8 @@ using v8::MemoryPressureLevel; V(Object, deserialize_lazy_handler_wide, DeserializeLazyHandlerWide) \ V(Object, deserialize_lazy_handler_extra_wide, \ DeserializeLazyHandlerExtraWide) \ + /* Hash seed */ \ + V(ByteArray, hash_seed, HashSeed) \ /* JS Entries */ \ V(Code, js_entry_code, JsEntryCode) \ V(Code, js_construct_entry_code, JsConstructEntryCode) \ @@ -291,7 +293,6 @@ using v8::MemoryPressureLevel; V(Smi, real_stack_limit, RealStackLimit) \ V(Smi, last_script_id, LastScriptId) \ V(Smi, last_debugging_id, LastDebuggingId) \ - V(Smi, hash_seed, HashSeed) \ /* To distinguish the function templates, so that we can find them in the */ \ /* function cache of the native context. */ \ V(Smi, next_template_serial_number, NextTemplateSerialNumber) \ @@ -917,7 +918,7 @@ class Heap { void IncrementDeferredCount(v8::Isolate::UseCounterFeature feature); - inline uint32_t HashSeed(); + inline uint64_t HashSeed(); inline int NextScriptId(); inline int NextDebuggingId(); diff --git a/deps/v8/src/heap/setup-heap-internal.cc b/deps/v8/src/heap/setup-heap-internal.cc index 3b232ba310dd55..4b38fb4a6ac537 100644 --- a/deps/v8/src/heap/setup-heap-internal.cc +++ b/deps/v8/src/heap/setup-heap-internal.cc @@ -591,6 +591,9 @@ void Heap::CreateInitialObjects() { set_minus_infinity_value( *factory->NewHeapNumber(-V8_INFINITY, IMMUTABLE, TENURED_READ_ONLY)); + set_hash_seed(*factory->NewByteArray(kInt64Size, TENURED)); + InitializeHashSeed(); + // Allocate cache for single character one byte strings. set_single_character_string_cache( *factory->NewFixedArray(String::kMaxOneByteCharCode + 1, TENURED)); diff --git a/deps/v8/src/json-parser.cc b/deps/v8/src/json-parser.cc index 7da11db9cfe5b6..7323b714a53031 100644 --- a/deps/v8/src/json-parser.cc +++ b/deps/v8/src/json-parser.cc @@ -831,7 +831,8 @@ Handle JsonParser::ScanJsonString() { int position = position_; uc32 c0 = c0_; - uint32_t running_hash = isolate()->heap()->HashSeed(); + uint32_t running_hash = + static_cast(isolate()->heap()->HashSeed()); uint32_t index = 0; bool is_array_index = true; diff --git a/deps/v8/src/objects-inl.h b/deps/v8/src/objects-inl.h index edf48fecf56c0e..97a5463bc7f8fd 100644 --- a/deps/v8/src/objects-inl.h +++ b/deps/v8/src/objects-inl.h @@ -3137,14 +3137,14 @@ bool NumberDictionaryBaseShape::IsMatch(uint32_t key, Object* other) { } uint32_t NumberDictionaryBaseShape::Hash(Isolate* isolate, uint32_t key) { - return ComputeIntegerHash(key, isolate->heap()->HashSeed()); + return ComputeSeededHash(key, isolate->heap()->HashSeed()); } uint32_t NumberDictionaryBaseShape::HashForObject(Isolate* isolate, Object* other) { DCHECK(other->IsNumber()); - return ComputeIntegerHash(static_cast(other->Number()), - isolate->heap()->HashSeed()); + return ComputeSeededHash(static_cast(other->Number()), + isolate->heap()->HashSeed()); } Handle NumberDictionaryBaseShape::AsHandle(Isolate* isolate, @@ -3226,18 +3226,18 @@ uint32_t ObjectHashTableShape::HashForObject(Isolate* isolate, Object* other) { Object* Object::GetSimpleHash(Object* object) { DisallowHeapAllocation no_gc; if (object->IsSmi()) { - uint32_t hash = ComputeIntegerHash(Smi::ToInt(object)); + uint32_t hash = ComputeUnseededHash(Smi::ToInt(object)); return Smi::FromInt(hash & Smi::kMaxValue); } if (object->IsHeapNumber()) { double num = HeapNumber::cast(object)->value(); if (std::isnan(num)) return Smi::FromInt(Smi::kMaxValue); - // Use ComputeIntegerHash for all values in Signed32 range, including -0, + // Use ComputeUnseededHash for all values in Signed32 range, including -0, // which is considered equal to 0 because collections use SameValueZero. uint32_t hash; // Check range before conversion to avoid undefined behavior. if (num >= kMinInt && num <= kMaxInt && FastI2D(FastD2I(num)) == num) { - hash = ComputeIntegerHash(FastD2I(num)); + hash = ComputeUnseededHash(FastD2I(num)); } else { hash = ComputeLongHash(double_to_uint64(num)); } diff --git a/deps/v8/src/objects.cc b/deps/v8/src/objects.cc index 80442d5bd89ba1..d778ca799fbf77 100644 --- a/deps/v8/src/objects.cc +++ b/deps/v8/src/objects.cc @@ -12120,9 +12120,7 @@ uint32_t StringHasher::GetHashField() { } } - -uint32_t StringHasher::ComputeUtf8Hash(Vector chars, - uint32_t seed, +uint32_t StringHasher::ComputeUtf8Hash(Vector chars, uint64_t seed, int* utf16_length_out) { int vector_length = chars.length(); // Handle some edge cases @@ -16960,7 +16958,7 @@ Handle JSGlobalObject::EnsureEmptyPropertyCell( // algorithm. class TwoCharHashTableKey : public StringTableKey { public: - TwoCharHashTableKey(uint16_t c1, uint16_t c2, uint32_t seed) + TwoCharHashTableKey(uint16_t c1, uint16_t c2, uint64_t seed) : StringTableKey(ComputeHashField(c1, c2, seed)), c1_(c1), c2_(c2) {} bool IsMatch(Object* o) override { @@ -16977,9 +16975,9 @@ class TwoCharHashTableKey : public StringTableKey { } private: - uint32_t ComputeHashField(uint16_t c1, uint16_t c2, uint32_t seed) { + uint32_t ComputeHashField(uint16_t c1, uint16_t c2, uint64_t seed) { // Char 1. - uint32_t hash = seed; + uint32_t hash = static_cast(seed); hash += c1; hash += hash << 10; hash ^= hash >> 6; @@ -17177,7 +17175,7 @@ namespace { class StringTableNoAllocateKey : public StringTableKey { public: - StringTableNoAllocateKey(String* string, uint32_t seed) + StringTableNoAllocateKey(String* string, uint64_t seed) : StringTableKey(0), string_(string) { StringShape shape(string); one_byte_ = shape.HasOnlyOneByteChars(); diff --git a/deps/v8/src/objects/bigint.h b/deps/v8/src/objects/bigint.h index e6547389343c69..e350a4d0b7dcd6 100644 --- a/deps/v8/src/objects/bigint.h +++ b/deps/v8/src/objects/bigint.h @@ -129,7 +129,7 @@ class V8_EXPORT_PRIVATE BigInt : public BigIntBase { bool ToBoolean() { return !is_zero(); } uint32_t Hash() { // TODO(jkummerow): Improve this. At least use length and sign. - return is_zero() ? 0 : ComputeIntegerHash(static_cast(digit(0))); + return is_zero() ? 0 : ComputeLongHash(static_cast(digit(0))); } static bool EqualToString(Handle x, Handle y); diff --git a/deps/v8/src/objects/ordered-hash-table.h b/deps/v8/src/objects/ordered-hash-table.h index a1129d105d2025..f5313f900627b6 100644 --- a/deps/v8/src/objects/ordered-hash-table.h +++ b/deps/v8/src/objects/ordered-hash-table.h @@ -143,7 +143,7 @@ class OrderedHashTable : public OrderedHashTableBase { // This special cases for Smi, so that we avoid the HandleScope // creation below. if (key->IsSmi()) { - uint32_t hash = ComputeIntegerHash(Smi::ToInt(key)); + uint32_t hash = ComputeUnseededHash(Smi::ToInt(key)); return HashToEntry(hash & Smi::kMaxValue); } HandleScope scope(isolate); diff --git a/deps/v8/src/objects/string-inl.h b/deps/v8/src/objects/string-inl.h index a5d02aec80a45b..7eef12352414f6 100644 --- a/deps/v8/src/objects/string-inl.h +++ b/deps/v8/src/objects/string-inl.h @@ -195,7 +195,7 @@ Char FlatStringReader::Get(int index) { template class SequentialStringKey : public StringTableKey { public: - explicit SequentialStringKey(Vector string, uint32_t seed) + explicit SequentialStringKey(Vector string, uint64_t seed) : StringTableKey(StringHasher::HashSequentialString( string.start(), string.length(), seed)), string_(string) {} @@ -205,7 +205,7 @@ class SequentialStringKey : public StringTableKey { class OneByteStringKey : public SequentialStringKey { public: - OneByteStringKey(Vector str, uint32_t seed) + OneByteStringKey(Vector str, uint64_t seed) : SequentialStringKey(str, seed) {} bool IsMatch(Object* string) override { @@ -250,7 +250,7 @@ class SeqOneByteSubStringKey : public StringTableKey { class TwoByteStringKey : public SequentialStringKey { public: - explicit TwoByteStringKey(Vector str, uint32_t seed) + explicit TwoByteStringKey(Vector str, uint64_t seed) : SequentialStringKey(str, seed) {} bool IsMatch(Object* string) override { @@ -263,7 +263,7 @@ class TwoByteStringKey : public SequentialStringKey { // Utf8StringKey carries a vector of chars as key. class Utf8StringKey : public StringTableKey { public: - explicit Utf8StringKey(Vector string, uint32_t seed) + explicit Utf8StringKey(Vector string, uint64_t seed) : StringTableKey(StringHasher::ComputeUtf8Hash(string, seed, &chars_)), string_(string) {} diff --git a/deps/v8/src/parsing/parse-info.h b/deps/v8/src/parsing/parse-info.h index 08f15c865c97db..e2414199a96448 100644 --- a/deps/v8/src/parsing/parse-info.h +++ b/deps/v8/src/parsing/parse-info.h @@ -139,8 +139,8 @@ class V8_EXPORT_PRIVATE ParseInfo { uintptr_t stack_limit() const { return stack_limit_; } void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; } - uint32_t hash_seed() const { return hash_seed_; } - void set_hash_seed(uint32_t hash_seed) { hash_seed_ = hash_seed; } + uint64_t hash_seed() const { return hash_seed_; } + void set_hash_seed(uint64_t hash_seed) { hash_seed_ = hash_seed; } int function_flags() const { return function_flags_; } void set_function_flags(int function_flags) { @@ -264,7 +264,7 @@ class V8_EXPORT_PRIVATE ParseInfo { DeclarationScope* script_scope_; UnicodeCache* unicode_cache_; uintptr_t stack_limit_; - uint32_t hash_seed_; + uint64_t hash_seed_; // TODO(leszeks): Move any remaining flags used here either to the flags_ // field or to other fields. int function_flags_; diff --git a/deps/v8/src/profiler/allocation-tracker.cc b/deps/v8/src/profiler/allocation-tracker.cc index cf672f920ccfa7..078c70e8dd8337 100644 --- a/deps/v8/src/profiler/allocation-tracker.cc +++ b/deps/v8/src/profiler/allocation-tracker.cc @@ -239,7 +239,7 @@ void AllocationTracker::AllocationEvent(Address addr, int size) { static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) { - return ComputeIntegerHash(static_cast(id)); + return ComputeUnseededHash(static_cast(id)); } diff --git a/deps/v8/src/profiler/heap-profiler.cc b/deps/v8/src/profiler/heap-profiler.cc index 10645ad16161f8..02b80c21d6e7e7 100644 --- a/deps/v8/src/profiler/heap-profiler.cc +++ b/deps/v8/src/profiler/heap-profiler.cc @@ -16,14 +16,14 @@ namespace internal { HeapProfiler::HeapProfiler(Heap* heap) : ids_(new HeapObjectsMap(heap)), - names_(new StringsStorage(heap->HashSeed())), + names_(new StringsStorage()), is_tracking_object_moves_(false) {} HeapProfiler::~HeapProfiler() = default; void HeapProfiler::DeleteAllSnapshots() { snapshots_.clear(); - names_.reset(new StringsStorage(heap()->HashSeed())); + names_.reset(new StringsStorage()); } diff --git a/deps/v8/src/profiler/heap-snapshot-generator.cc b/deps/v8/src/profiler/heap-snapshot-generator.cc index 841d4e16e57209..082cb864ce6249 100644 --- a/deps/v8/src/profiler/heap-snapshot-generator.cc +++ b/deps/v8/src/profiler/heap-snapshot-generator.cc @@ -525,7 +525,7 @@ SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { heap_->HashSeed()); intptr_t element_count = info->GetElementCount(); if (element_count != -1) { - id ^= ComputeIntegerHash(static_cast(element_count)); + id ^= ComputeUnseededHash(static_cast(element_count)); } return id << 1; } diff --git a/deps/v8/src/profiler/heap-snapshot-generator.h b/deps/v8/src/profiler/heap-snapshot-generator.h index d0e17edf03aa50..899fd89a9c66d8 100644 --- a/deps/v8/src/profiler/heap-snapshot-generator.h +++ b/deps/v8/src/profiler/heap-snapshot-generator.h @@ -296,7 +296,7 @@ class HeapEntriesMap { private: static uint32_t Hash(HeapThing thing) { - return ComputeIntegerHash( + return ComputeUnseededHash( static_cast(reinterpret_cast(thing))); } @@ -509,7 +509,7 @@ class NativeObjectsExplorer { struct RetainedInfoHasher { std::size_t operator()(v8::RetainedObjectInfo* info) const { - return ComputeIntegerHash(static_cast(info->GetHash())); + return ComputeUnseededHash(static_cast(info->GetHash())); } }; struct RetainedInfoEquals { diff --git a/deps/v8/src/profiler/profile-generator.cc b/deps/v8/src/profiler/profile-generator.cc index 4273234dd23d86..261d9f0eaf376f 100644 --- a/deps/v8/src/profiler/profile-generator.cc +++ b/deps/v8/src/profiler/profile-generator.cc @@ -83,16 +83,16 @@ CodeEntry* CodeEntry::UnresolvedEntryCreateTrait::Create() { } uint32_t CodeEntry::GetHash() const { - uint32_t hash = ComputeIntegerHash(tag()); + uint32_t hash = ComputeUnseededHash(tag()); if (script_id_ != v8::UnboundScript::kNoScriptId) { - hash ^= ComputeIntegerHash(static_cast(script_id_)); - hash ^= ComputeIntegerHash(static_cast(position_)); + hash ^= ComputeUnseededHash(static_cast(script_id_)); + hash ^= ComputeUnseededHash(static_cast(position_)); } else { - hash ^= ComputeIntegerHash( + hash ^= ComputeUnseededHash( static_cast(reinterpret_cast(name_))); - hash ^= ComputeIntegerHash( + hash ^= ComputeUnseededHash( static_cast(reinterpret_cast(resource_name_))); - hash ^= ComputeIntegerHash(line_number_); + hash ^= ComputeUnseededHash(line_number_); } return hash; } @@ -597,9 +597,7 @@ void CodeMap::Print() { } CpuProfilesCollection::CpuProfilesCollection(Isolate* isolate) - : resource_names_(isolate->heap()->HashSeed()), - profiler_(nullptr), - current_profiles_semaphore_(1) {} + : profiler_(nullptr), current_profiles_semaphore_(1) {} bool CpuProfilesCollection::StartProfiling(const char* title, bool record_samples, diff --git a/deps/v8/src/profiler/profile-generator.h b/deps/v8/src/profiler/profile-generator.h index e575a786481d51..135365939a01ca 100644 --- a/deps/v8/src/profiler/profile-generator.h +++ b/deps/v8/src/profiler/profile-generator.h @@ -241,7 +241,7 @@ class ProfileNode { }; struct Hasher { std::size_t operator()(CodeEntryAndLineNumber pair) const { - return pair.code_entry->GetHash() ^ ComputeIntegerHash(pair.line_number); + return pair.code_entry->GetHash() ^ ComputeUnseededHash(pair.line_number); } }; diff --git a/deps/v8/src/profiler/profiler-listener.cc b/deps/v8/src/profiler/profiler-listener.cc index e3c2c140fb619f..5711c1e0add943 100644 --- a/deps/v8/src/profiler/profiler-listener.cc +++ b/deps/v8/src/profiler/profiler-listener.cc @@ -17,9 +17,7 @@ namespace internal { ProfilerListener::ProfilerListener(Isolate* isolate, CodeEventObserver* observer) - : isolate_(isolate), - observer_(observer), - function_and_resource_names_(isolate->heap()->HashSeed()) {} + : isolate_(isolate), observer_(observer) {} ProfilerListener::~ProfilerListener() = default; diff --git a/deps/v8/src/profiler/strings-storage.cc b/deps/v8/src/profiler/strings-storage.cc index e48d054df63ea2..543b277ad3b976 100644 --- a/deps/v8/src/profiler/strings-storage.cc +++ b/deps/v8/src/profiler/strings-storage.cc @@ -17,8 +17,7 @@ bool StringsStorage::StringsMatch(void* key1, void* key2) { 0; } -StringsStorage::StringsStorage(uint32_t hash_seed) - : hash_seed_(hash_seed), names_(StringsMatch) {} +StringsStorage::StringsStorage() : names_(StringsMatch) {} StringsStorage::~StringsStorage() { for (base::HashMap::Entry* p = names_.Start(); p != nullptr; @@ -116,7 +115,7 @@ const char* StringsStorage::GetFunctionName(const char* name) { } base::HashMap::Entry* StringsStorage::GetEntry(const char* str, int len) { - uint32_t hash = StringHasher::HashSequentialString(str, len, hash_seed_); + uint32_t hash = StringHasher::HashSequentialString(str, len, kZeroHashSeed); return names_.LookupOrInsert(const_cast(str), hash); } diff --git a/deps/v8/src/profiler/strings-storage.h b/deps/v8/src/profiler/strings-storage.h index cdc22e48f22a58..589113be833d88 100644 --- a/deps/v8/src/profiler/strings-storage.h +++ b/deps/v8/src/profiler/strings-storage.h @@ -20,7 +20,7 @@ class Name; // forever, even if they disappear from JS heap or external storage. class V8_EXPORT_PRIVATE StringsStorage { public: - explicit StringsStorage(uint32_t hash_seed); + StringsStorage(); ~StringsStorage(); // Copies the given c-string and stores it, returning the stored copy, or just @@ -49,7 +49,6 @@ class V8_EXPORT_PRIVATE StringsStorage { PRINTF_FORMAT(2, 0) const char* GetVFormatted(const char* format, va_list args); - uint32_t hash_seed_; base::CustomMatcherHashMap names_; DISALLOW_COPY_AND_ASSIGN(StringsStorage); diff --git a/deps/v8/src/string-hasher-inl.h b/deps/v8/src/string-hasher-inl.h index c742c651642e2e..caf0e082bab474 100644 --- a/deps/v8/src/string-hasher-inl.h +++ b/deps/v8/src/string-hasher-inl.h @@ -12,9 +12,9 @@ namespace v8 { namespace internal { -StringHasher::StringHasher(int length, uint32_t seed) +StringHasher::StringHasher(int length, uint64_t seed) : length_(length), - raw_running_hash_(seed), + raw_running_hash_(static_cast(seed)), array_index_(0), is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize), is_first_char_(true) { @@ -113,16 +113,16 @@ inline void StringHasher::AddCharacters(const Char* chars, int length) { template uint32_t StringHasher::HashSequentialString(const schar* chars, int length, - uint32_t seed) { + uint64_t seed) { StringHasher hasher(length, seed); if (!hasher.has_trivial_hash()) hasher.AddCharacters(chars, length); return hasher.GetHashField(); } -IteratingStringHasher::IteratingStringHasher(int len, uint32_t seed) +IteratingStringHasher::IteratingStringHasher(int len, uint64_t seed) : StringHasher(len, seed) {} -uint32_t IteratingStringHasher::Hash(String* string, uint32_t seed) { +uint32_t IteratingStringHasher::Hash(String* string, uint64_t seed) { IteratingStringHasher hasher(string->length(), seed); // Nothing to do. if (hasher.has_trivial_hash()) return hasher.GetHashField(); diff --git a/deps/v8/src/string-hasher.h b/deps/v8/src/string-hasher.h index 62bb9750c6a1ca..573b9bb1c6c080 100644 --- a/deps/v8/src/string-hasher.h +++ b/deps/v8/src/string-hasher.h @@ -18,14 +18,14 @@ class Vector; class V8_EXPORT_PRIVATE StringHasher { public: - explicit inline StringHasher(int length, uint32_t seed); + explicit inline StringHasher(int length, uint64_t seed); template static inline uint32_t HashSequentialString(const schar* chars, int length, - uint32_t seed); + uint64_t seed); // Reads all the data, even for long strings and computes the utf16 length. - static uint32_t ComputeUtf8Hash(Vector chars, uint32_t seed, + static uint32_t ComputeUtf8Hash(Vector chars, uint64_t seed, int* utf16_length_out); // Calculated hash value for a string consisting of 1 to @@ -74,22 +74,22 @@ class V8_EXPORT_PRIVATE StringHasher { class IteratingStringHasher : public StringHasher { public: - static inline uint32_t Hash(String* string, uint32_t seed); + static inline uint32_t Hash(String* string, uint64_t seed); inline void VisitOneByteString(const uint8_t* chars, int length); inline void VisitTwoByteString(const uint16_t* chars, int length); private: - inline IteratingStringHasher(int len, uint32_t seed); + inline IteratingStringHasher(int len, uint64_t seed); void VisitConsString(ConsString* cons_string); DISALLOW_COPY_AND_ASSIGN(IteratingStringHasher); }; // Useful for std containers that require something ()'able. struct SeededStringHasher { - explicit SeededStringHasher(uint32_t hashseed) : hashseed_(hashseed) {} + explicit SeededStringHasher(uint64_t hashseed) : hashseed_(hashseed) {} inline std::size_t operator()(const char* name) const; - uint32_t hashseed_; + uint64_t hashseed_; }; // Useful for std containers that require something ()'able. diff --git a/deps/v8/src/utils.h b/deps/v8/src/utils.h index 31c1c157242110..a1f193bcc9d292 100644 --- a/deps/v8/src/utils.h +++ b/deps/v8/src/utils.h @@ -473,13 +473,12 @@ class BitSetComputer { // ---------------------------------------------------------------------------- // Hash function. -static const uint32_t kZeroHashSeed = 0; +static const uint64_t kZeroHashSeed = 0; // Thomas Wang, Integer Hash Functions. -// http://www.concentric.net/~Ttwang/tech/inthash.htm -inline uint32_t ComputeIntegerHash(uint32_t key, uint32_t seed) { +// http://www.concentric.net/~Ttwang/tech/inthash.htm` +inline uint32_t ComputeUnseededHash(uint32_t key) { uint32_t hash = key; - hash = hash ^ seed; hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; hash = hash ^ (hash >> 12); hash = hash + (hash << 2); @@ -489,10 +488,6 @@ inline uint32_t ComputeIntegerHash(uint32_t key, uint32_t seed) { return hash & 0x3fffffff; } -inline uint32_t ComputeIntegerHash(uint32_t key) { - return ComputeIntegerHash(key, kZeroHashSeed); -} - inline uint32_t ComputeLongHash(uint64_t key) { uint64_t hash = key; hash = ~hash + (hash << 18); // hash = (hash << 18) - hash - 1; @@ -501,17 +496,20 @@ inline uint32_t ComputeLongHash(uint64_t key) { hash = hash ^ (hash >> 11); hash = hash + (hash << 6); hash = hash ^ (hash >> 22); - return static_cast(hash); + return static_cast(hash & 0x3fffffff); } +inline uint32_t ComputeSeededHash(uint32_t key, uint64_t seed) { + return ComputeLongHash(static_cast(key) ^ seed); +} inline uint32_t ComputePointerHash(void* ptr) { - return ComputeIntegerHash( + return ComputeUnseededHash( static_cast(reinterpret_cast(ptr))); } inline uint32_t ComputeAddressHash(Address address) { - return ComputeIntegerHash(static_cast(address & 0xFFFFFFFFul)); + return ComputeUnseededHash(static_cast(address & 0xFFFFFFFFul)); } // ---------------------------------------------------------------------------- diff --git a/deps/v8/test/cctest/heap/test-heap.cc b/deps/v8/test/cctest/heap/test-heap.cc index d8a475cfc4df9a..2fea45410e4061 100644 --- a/deps/v8/test/cctest/heap/test-heap.cc +++ b/deps/v8/test/cctest/heap/test-heap.cc @@ -5914,7 +5914,7 @@ UNINITIALIZED_TEST(ReinitializeStringHashSeed) { v8::Isolate* isolate = v8::Isolate::New(create_params); { v8::Isolate::Scope isolate_scope(isolate); - CHECK_EQ(1337 * i, + CHECK_EQ(static_cast(1337 * i), reinterpret_cast(isolate)->heap()->HashSeed()); v8::HandleScope handle_scope(isolate); v8::Local context = v8::Context::New(isolate); diff --git a/deps/v8/test/cctest/test-code-stub-assembler.cc b/deps/v8/test/cctest/test-code-stub-assembler.cc index 13ebf7ab869563..7ad6352b8e95c4 100644 --- a/deps/v8/test/cctest/test-code-stub-assembler.cc +++ b/deps/v8/test/cctest/test-code-stub-assembler.cc @@ -324,15 +324,13 @@ TEST(JSFunction) { TEST(ComputeIntegerHash) { Isolate* isolate(CcTest::InitIsolateOnce()); - const int kNumParams = 2; + const int kNumParams = 1; CodeAssemblerTester asm_tester(isolate, kNumParams); CodeStubAssembler m(asm_tester.state()); - m.Return(m.SmiFromInt32(m.ComputeIntegerHash(m.SmiUntag(m.Parameter(0)), - m.SmiToInt32(m.Parameter(1))))); - FunctionTester ft(asm_tester.GenerateCode(), kNumParams); + m.Return(m.SmiFromInt32(m.ComputeSeededHash(m.SmiUntag(m.Parameter(0))))); - Handle hash_seed = isolate->factory()->hash_seed(); + FunctionTester ft(asm_tester.GenerateCode(), kNumParams); base::RandomNumberGenerator rand_gen(FLAG_random_seed); @@ -340,9 +338,9 @@ TEST(ComputeIntegerHash) { int k = rand_gen.NextInt(Smi::kMaxValue); Handle key(Smi::FromInt(k), isolate); - Handle result = ft.Call(key, hash_seed).ToHandleChecked(); + Handle result = ft.Call(key).ToHandleChecked(); - uint32_t hash = ComputeIntegerHash(k, hash_seed->value()); + uint32_t hash = ComputeSeededHash(k, isolate->heap()->HashSeed()); Smi* expected = Smi::FromInt(hash & Smi::kMaxValue); CHECK_EQ(expected, Smi::cast(*result)); } diff --git a/deps/v8/test/cctest/test-serialize.cc b/deps/v8/test/cctest/test-serialize.cc index c26a7e734811a0..68f47f61b0ed50 100644 --- a/deps/v8/test/cctest/test-serialize.cc +++ b/deps/v8/test/cctest/test-serialize.cc @@ -3370,7 +3370,8 @@ UNINITIALIZED_TEST(ReinitializeHashSeedNotRehashable) { v8::Isolate* isolate = v8::Isolate::New(create_params); { // Check that no rehashing has been performed. - CHECK_EQ(42, reinterpret_cast(isolate)->heap()->HashSeed()); + CHECK_EQ(static_cast(42), + reinterpret_cast(isolate)->heap()->HashSeed()); v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Local context = v8::Context::New(isolate); @@ -3432,7 +3433,8 @@ UNINITIALIZED_TEST(ReinitializeHashSeedRehashable) { v8::Isolate* isolate = v8::Isolate::New(create_params); { // Check that rehashing has been performed. - CHECK_EQ(1337, reinterpret_cast(isolate)->heap()->HashSeed()); + CHECK_EQ(static_cast(1337), + reinterpret_cast(isolate)->heap()->HashSeed()); v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Local context = v8::Context::New(isolate); diff --git a/deps/v8/test/unittests/strings-storage-unittest.cc b/deps/v8/test/unittests/strings-storage-unittest.cc index de410e8e260e0f..263d2492401d3d 100644 --- a/deps/v8/test/unittests/strings-storage-unittest.cc +++ b/deps/v8/test/unittests/strings-storage-unittest.cc @@ -19,7 +19,7 @@ bool StringEq(const char* left, const char* right) { } TEST_F(StringsStorageWithIsolate, GetNameFromString) { - StringsStorage storage(isolate()->heap()->HashSeed()); + StringsStorage storage; // One char strings are canonical on the v8 heap so use a 2 char string here. Handle str = isolate()->factory()->NewStringFromAsciiChecked("xy"); @@ -40,7 +40,7 @@ TEST_F(StringsStorageWithIsolate, GetNameFromString) { } TEST_F(StringsStorageWithIsolate, GetNameFromSymbol) { - StringsStorage storage(isolate()->heap()->HashSeed()); + StringsStorage storage; Handle symbol = isolate()->factory()->NewSymbol(); const char* stored_symbol = storage.GetName(*symbol); @@ -53,7 +53,7 @@ TEST_F(StringsStorageWithIsolate, GetNameFromSymbol) { } TEST_F(StringsStorageWithIsolate, GetConsName) { - StringsStorage storage(isolate()->heap()->HashSeed()); + StringsStorage storage; Handle str = isolate()->factory()->NewStringFromAsciiChecked("xy"); @@ -65,7 +65,7 @@ TEST_F(StringsStorageWithIsolate, GetConsName) { } TEST_F(StringsStorageWithIsolate, GetNameFromInt) { - StringsStorage storage(isolate()->heap()->HashSeed()); + StringsStorage storage; const char* stored_str = storage.GetName(0); CHECK(StringEq("0", stored_str)); @@ -81,7 +81,7 @@ TEST_F(StringsStorageWithIsolate, GetNameFromInt) { } TEST_F(StringsStorageWithIsolate, GetFunctionNameFromString) { - StringsStorage storage(isolate()->heap()->HashSeed()); + StringsStorage storage; Handle str = isolate()->factory()->NewStringFromAsciiChecked("xy"); const char* stored_str = storage.GetFunctionName(*str); @@ -93,7 +93,7 @@ TEST_F(StringsStorageWithIsolate, GetFunctionNameFromString) { } TEST_F(StringsStorageWithIsolate, GetFunctionNameFromCString) { - StringsStorage storage(isolate()->heap()->HashSeed()); + StringsStorage storage; const char* xy = "xy"; const char* stored_str = storage.GetFunctionName("xy"); @@ -103,7 +103,7 @@ TEST_F(StringsStorageWithIsolate, GetFunctionNameFromCString) { } TEST_F(StringsStorageWithIsolate, Format) { - StringsStorage storage(isolate()->heap()->HashSeed()); + StringsStorage storage; const char* xy = "xy"; const char* stored_str = storage.GetFormatted("%s", xy); @@ -121,7 +121,7 @@ TEST_F(StringsStorageWithIsolate, Format) { } TEST_F(StringsStorageWithIsolate, FormatAndGetShareStorage) { - StringsStorage storage(isolate()->heap()->HashSeed()); + StringsStorage storage; Handle str = isolate()->factory()->NewStringFromAsciiChecked("xy"); const char* stored_str = storage.GetName(*str);