1 // Copyright 2019 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_NUMBERS_HASH_SEED_INL_H_ 6 #define V8_NUMBERS_HASH_SEED_INL_H_ 7 8 #include <stdint.h> 9 10 // The #includes below currently lead to cyclic transitive includes, so 11 // HashSeed() ends up being required before it is defined, so we have to 12 // declare it here. This is a workaround; if we needed this permanently then 13 // we should put that line into a "hash-seed.h" header; but we won't need 14 // it for long. 15 // TODO(jkummerow): Get rid of this by breaking circular include dependencies. 16 namespace v8 { 17 namespace internal { 18 19 class Isolate; 20 class ReadOnlyRoots; 21 22 inline uint64_t HashSeed(Isolate* isolate); 23 inline uint64_t HashSeed(ReadOnlyRoots roots); 24 25 } // namespace internal 26 } // namespace v8 27 28 // See comment above for why this isn't at the top of the file. 29 #include "src/objects/fixed-array-inl.h" 30 #include "src/roots/roots-inl.h" 31 32 namespace v8 { 33 namespace internal { 34 HashSeed(Isolate * isolate)35inline uint64_t HashSeed(Isolate* isolate) { 36 return HashSeed(ReadOnlyRoots(isolate)); 37 } 38 HashSeed(ReadOnlyRoots roots)39inline uint64_t HashSeed(ReadOnlyRoots roots) { 40 uint64_t seed; 41 roots.hash_seed().copy_out(0, reinterpret_cast<byte*>(&seed), kInt64Size); 42 DCHECK(FLAG_randomize_hashes || seed == 0); 43 return seed; 44 } 45 46 } // namespace internal 47 } // namespace v8 48 49 #endif // V8_NUMBERS_HASH_SEED_INL_H_ 50