1// Copyright 2018 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#include "src/compiler/refs-map.h"
6
7namespace v8 {
8namespace internal {
9namespace compiler {
10
11using UnderlyingMap =
12    base::TemplateHashMapImpl<Address, ObjectData*, AddressMatcher,
13                              ZoneAllocationPolicy>;
14
15RefsMap::RefsMap(uint32_t capacity, AddressMatcher match, Zone* zone)
16    : UnderlyingMap(capacity, match, ZoneAllocationPolicy(zone)) {}
17
18RefsMap::RefsMap(const RefsMap* other, Zone* zone)
19    : UnderlyingMap(other, ZoneAllocationPolicy(zone)) {}
20
21RefsMap::Entry* RefsMap::Lookup(const Address& key) const {
22  return UnderlyingMap::Lookup(key, Hash(key));
23}
24
25RefsMap::Entry* RefsMap::LookupOrInsert(const Address& key) {
26  return UnderlyingMap::LookupOrInsert(key, RefsMap::Hash(key),
27                                       []() { return nullptr; });
28}
29
30ObjectData* RefsMap::Remove(const Address& key) {
31  return UnderlyingMap::Remove(key, RefsMap::Hash(key));
32}
33
34uint32_t RefsMap::Hash(Address addr) { return static_cast<uint32_t>(addr); }
35
36}  // namespace compiler
37}  // namespace internal
38}  // namespace v8
39