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_HASH_SEED_INL_H_
6#define V8_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.
16namespace v8 {
17namespace internal {
18
19class Isolate;
20class ReadOnlyRoots;
21
22// TODO(v8:7464): Remove the Isolate version of this.
23inline uint64_t HashSeed(Isolate* isolate);
24inline uint64_t HashSeed(ReadOnlyRoots roots);
25
26} // namespace internal
27} // namespace v8
28
29// See comment above for why this isn't at the top of the file.
30#include "src/objects/fixed-array-inl.h"
31#include "src/roots-inl.h"
32
33namespace v8 {
34namespace internal {
35
36inline uint64_t HashSeed(Isolate* isolate) {
37 return HashSeed(ReadOnlyRoots(isolate));
38}
39
40inline uint64_t HashSeed(ReadOnlyRoots roots) {
41 uint64_t seed;
42 roots.hash_seed()->copy_out(0, reinterpret_cast<byte*>(&seed), kInt64Size);
43 DCHECK(FLAG_randomize_hashes || seed == 0);
44 return seed;
45}
46
47} // namespace internal
48} // namespace v8
49
50#endif // V8_HASH_SEED_INL_H_
51