v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
refs-map.h
Go to the documentation of this file.
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#ifndef V8_COMPILER_REFS_MAP_H_
6#define V8_COMPILER_REFS_MAP_H_
7
8#include "src/base/hashmap.h"
9#include "src/zone/zone.h"
10
11namespace v8 {
12namespace internal {
13namespace compiler {
14
15class ObjectData;
16
18 public:
19 bool operator()(uint32_t hash1, uint32_t hash2, const Address& key1,
20 const Address& key2) const {
21 return key1 == key2;
22 }
23};
24
25// This class employs our own implementation of hash map for the purpose of
26// storing the mapping between canonical Addresses and allocated ObjectData.
27// It's used as the refs map in JSHeapBroker and as the snapshot in
28// PerIsolateCompilerCache, as we need a cheap copy between the two and
29// std::unordered_map doesn't satisfy this requirement, as it rehashes the
30// whole map and copies all entries one by one.
32 : public base::TemplateHashMapImpl<Address, ObjectData*, AddressMatcher,
33 ZoneAllocationPolicy>,
34 public ZoneObject {
35 public:
36 RefsMap(uint32_t capacity, AddressMatcher match, Zone* zone);
37 RefsMap(const RefsMap* other, Zone* zone);
38
39 bool IsEmpty() const { return occupancy() == 0; }
40
41 // Wrappers around methods from UnderlyingMap
42 Entry* Lookup(const Address& key) const;
45
46 private:
47 static uint32_t Hash(Address addr);
48};
49
50} // namespace compiler
51} // namespace internal
52} // namespace v8
53
54#endif // V8_COMPILER_REFS_MAP_H_
bool operator()(uint32_t hash1, uint32_t hash2, const Address &key1, const Address &key2) const
Definition refs-map.h:19
RefsMap(uint32_t capacity, AddressMatcher match, Zone *zone)
Definition refs-map.cc:15
ObjectData * Remove(const Address &key)
Definition refs-map.cc:30
static uint32_t Hash(Address addr)
Definition refs-map.cc:34
Entry * Lookup(const Address &key) const
Definition refs-map.cc:21
Entry * LookupOrInsert(const Address &key)
Definition refs-map.cc:25