11cb0ef41Sopenharmony_ci// Copyright 2018 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#include "src/compiler/refs-map.h"
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_cinamespace v8 {
81cb0ef41Sopenharmony_cinamespace internal {
91cb0ef41Sopenharmony_cinamespace compiler {
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciusing UnderlyingMap =
121cb0ef41Sopenharmony_ci    base::TemplateHashMapImpl<Address, ObjectData*, AddressMatcher,
131cb0ef41Sopenharmony_ci                              ZoneAllocationPolicy>;
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciRefsMap::RefsMap(uint32_t capacity, AddressMatcher match, Zone* zone)
161cb0ef41Sopenharmony_ci    : UnderlyingMap(capacity, match, ZoneAllocationPolicy(zone)) {}
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciRefsMap::RefsMap(const RefsMap* other, Zone* zone)
191cb0ef41Sopenharmony_ci    : UnderlyingMap(other, ZoneAllocationPolicy(zone)) {}
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ciRefsMap::Entry* RefsMap::Lookup(const Address& key) const {
221cb0ef41Sopenharmony_ci  return UnderlyingMap::Lookup(key, Hash(key));
231cb0ef41Sopenharmony_ci}
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciRefsMap::Entry* RefsMap::LookupOrInsert(const Address& key) {
261cb0ef41Sopenharmony_ci  return UnderlyingMap::LookupOrInsert(key, RefsMap::Hash(key),
271cb0ef41Sopenharmony_ci                                       []() { return nullptr; });
281cb0ef41Sopenharmony_ci}
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ciObjectData* RefsMap::Remove(const Address& key) {
311cb0ef41Sopenharmony_ci  return UnderlyingMap::Remove(key, RefsMap::Hash(key));
321cb0ef41Sopenharmony_ci}
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ciuint32_t RefsMap::Hash(Address addr) { return static_cast<uint32_t>(addr); }
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci}  // namespace compiler
371cb0ef41Sopenharmony_ci}  // namespace internal
381cb0ef41Sopenharmony_ci}  // namespace v8
39