5#ifndef V8_COMPILER_TURBOSHAFT_LAYERED_HASH_MAP_H_
6#define V8_COMPILER_TURBOSHAFT_LAYERED_HASH_MAP_H_
38template <
class Key,
class Value>
77template <
class Key,
class Value>
79 uint32_t initial_capacity)
80 : entry_count_(0), depths_heads_(zone),
zone_(zone) {
82 initial_capacity = std::max<uint32_t>(initial_capacity, 16);
86 mask_ = initial_capacity - 1;
91template <
class Key,
class Value>
93 depths_heads_.push_back(
nullptr);
96template <
class Key,
class Value>
99 for (
Entry* entry = depths_heads_.back(); entry !=
nullptr;) {
105 depths_heads_.pop_back();
108template <
class Key,
class Value>
111 for (
size_t i = hash & mask_;;
i = NextEntryIndex(
i)) {
117template <
class Key,
class Value>
120 size_t hash = ComputeHash(
key);
128template <
class Key,
class Value>
135template <
class Key,
class Value>
137 return Get(
key).has_value();
140template <
class Key,
class Value>
142 if (
table_.size() * kNeedResizePercentage > entry_count_)
return;
143 CHECK_LE(
table_.size(), std::numeric_limits<size_t>::max() / kGrowthFactor);
145 mask_ =
table_.size() - 1;
148 for (
size_t depth_idx = 0; depth_idx < depths_heads_.size(); depth_idx++) {
181 Entry* entry = depths_heads_[depth_idx];
182 depths_heads_[depth_idx] =
nullptr;
183 while (entry !=
nullptr) {
184 Entry* new_entry_loc = FindEntryForKey(entry->
key, entry->
hash);
185 *new_entry_loc = *entry;
188 depths_heads_[depth_idx] = new_entry_loc;
base::Vector< T > NewVector(size_t length)
size_t NextEntryIndex(size_t index)
ZoneVector< Entry * > depths_heads_
static constexpr int kGrowthFactor
LayeredHashMap(Zone *zone, uint32_t initial_capacity=64)
size_t ComputeHash(Key key)
void InsertNewKey(Key key, Value value)
base::Vector< Entry > table_
Entry * FindEntryForKey(Key key, size_t hash=0)
static constexpr double kNeedResizePercentage
std::optional< Value > Get(Key key)
Entry * InsertEntry(Entry entry)
InstructionOperand destination
constexpr unsigned CountLeadingZeros(T value)
constexpr unsigned CountPopulation(T value)
V8_BASE_EXPORT constexpr uint32_t RoundUpToPowerOfTwo32(uint32_t value)
V8_INLINE const Operation & Get(const Graph &graph, OpIndex index)
SourcePositionTable *const table_
#define CHECK_LE(lhs, rhs)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)
Entry * depth_neighboring_entry
#define V8_UNLIKELY(condition)