diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc index c890261d1d..003dcf4709 100644 --- a/src/code-stub-assembler.cc +++ b/src/code-stub-assembler.cc @@ -253,40 +253,6 @@ HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(HEAP_CONSTANT_ACCESSOR); HEAP_IMMOVABLE_OBJECT_LIST(HEAP_CONSTANT_TEST); #undef HEAP_CONSTANT_TEST -TNode CodeStubAssembler::HashSeed() { - DCHECK(Is64()); - TNode hash_seed_root = - TNode::UncheckedCast(LoadRoot(RootIndex::kHashSeed)); - return TNode::UncheckedCast(LoadObjectField( - hash_seed_root, ByteArray::kHeaderSize, MachineType::Int64())); -} - -TNode CodeStubAssembler::HashSeedHigh() { - DCHECK(!Is64()); -#ifdef V8_TARGET_BIG_ENDIAN - static int kOffset = 0; -#else - static int kOffset = kInt32Size; -#endif - TNode hash_seed_root = - TNode::UncheckedCast(LoadRoot(RootIndex::kHashSeed)); - return TNode::UncheckedCast(LoadObjectField( - hash_seed_root, ByteArray::kHeaderSize + kOffset, MachineType::Int32())); -} - -TNode CodeStubAssembler::HashSeedLow() { - DCHECK(!Is64()); -#ifdef V8_TARGET_BIG_ENDIAN - static int kOffset = kInt32Size; -#else - static int kOffset = 0; -#endif - TNode hash_seed_root = - TNode::UncheckedCast(LoadRoot(RootIndex::kHashSeed)); - return TNode::UncheckedCast(LoadObjectField( - hash_seed_root, ByteArray::kHeaderSize + kOffset, MachineType::Int32())); -} - Node* CodeStubAssembler::IntPtrOrSmiConstant(int value, ParameterMode mode) { if (mode == SMI_PARAMETERS) { return SmiConstant(value); @@ -7780,22 +7746,18 @@ Node* CodeStubAssembler::ComputeUnseededHash(Node* key) { } Node* CodeStubAssembler::ComputeSeededHash(Node* key) { - // See v8::internal::ComputeIntegerHash() - Node* hash_seed; - if (Is64()) { - hash_seed = TruncateInt64ToInt32(HashSeed()); - } else { - hash_seed = HashSeedLow(); - } - Node* hash = Word32Xor(TruncateIntPtrToInt32(key), hash_seed); - hash = Int32Add(Word32Xor(hash, Int32Constant(0xFFFFFFFF)), - Word32Shl(hash, Int32Constant(15))); - hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12))); - hash = Int32Add(hash, Word32Shl(hash, Int32Constant(2))); - hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(4))); - hash = Int32Mul(hash, Int32Constant(2057)); - hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(16))); - return Word32And(hash, Int32Constant(0x3FFFFFFF)); + 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( diff --git a/src/code-stub-assembler.h b/src/code-stub-assembler.h index 140ea58810..1ff89f5afa 100644 --- a/src/code-stub-assembler.h +++ b/src/code-stub-assembler.h @@ -450,10 +450,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { HEAP_IMMOVABLE_OBJECT_LIST(HEAP_CONSTANT_TEST) #undef HEAP_CONSTANT_TEST - TNode HashSeed(); - TNode HashSeedHigh(); - TNode HashSeedLow(); - Node* IntPtrOrSmiConstant(int value, ParameterMode mode); TNode LanguageModeConstant(LanguageMode mode) { return SmiConstant(static_cast(mode)); diff --git a/src/external-reference.cc b/src/external-reference.cc index 44ced93c76..9decc88e28 100644 --- a/src/external-reference.cc +++ b/src/external-reference.cc @@ -759,6 +759,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/src/external-reference.h b/src/external-reference.h index 69d80200cf..bbb7f0cfa0 100644 --- a/src/external-reference.h +++ b/src/external-reference.h @@ -82,6 +82,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") \