15 : js_graph_(js_graph),
16 hash_map_(AreKeysEqual,
ZoneHashMap::kDefaultHashMapCapacity,
18 working_space_(zone()),
19 empty_state_values_(nullptr) {}
27 if (node_key1->
node ==
nullptr) {
28 if (node_key2->
node ==
nullptr) {
36 if (node_key2->
node ==
nullptr) {
41 return node_key1->
node == node_key2->
node;
50 if (
key->count !=
static_cast<size_t>(node->InputCount())) {
54 DCHECK_EQ(IrOpcode::kStateValues, node->opcode());
64 if (
key->values[
i] != node->InputAt(
static_cast<int>(
i))) {
81 for (
size_t i = 0;
i < key1->
count;
i++) {
108int StateValuesHashKey(
Node** nodes,
size_t count) {
110 for (
size_t i = 0;
i <
count;
i++) {
111 hash = hash * 23 + (nodes[
i] ==
nullptr ? 0 : nodes[
i]->id());
113 return static_cast<int>(hash & 0x7FFFFFFF);
121 int hash = StateValuesHashKey(nodes,
count);
125 if (lookup->
value ==
nullptr) {
126 int node_count =
static_cast<int>(
count);
130 lookup->
key = new_key;
133 node =
reinterpret_cast<Node*
>(lookup->
value);
139 WorkingBuffer* node_buffer,
size_t* node_count,
size_t* values_idx,
145 size_t virtual_node_count = *node_count;
149 DCHECK_LE(*values_idx,
static_cast<size_t>(INT_MAX));
151 if (liveness ==
nullptr ||
153 input_mask |= 1 << (virtual_node_count);
154 (*node_buffer)[(*node_count)++] = values[*values_idx];
156 virtual_node_count++;
175 size_t node_count = 0;
180 values,
count, liveness);
191 size_t previous_input_count = node_count;
193 values,
count, liveness);
201 DCHECK_EQ(input_mask & ((1 << previous_input_count) - 1), 0u);
203 input_mask |= ((1 << previous_input_count) - 1);
211 (*node_buffer)[node_count++] = subtree;
221 DCHECK_EQ((*node_buffer)[0]->opcode(), IrOpcode::kStateValues);
222 return (*node_buffer)[0];
232void CheckTreeContainsValues(
Node* tree,
Node** values,
size_t count,
238 auto it = access.begin();
239 auto itend = access.end();
240 for (
i = 0; it != itend; ++it, ++
i) {
257 for (
size_t i = 0;
i <
count;
i++) {
258 if (values[
i] !=
nullptr) {
259 DCHECK_NE(values[
i]->opcode(), IrOpcode::kStateValues);
260 DCHECK_NE(values[
i]->opcode(), IrOpcode::kTypedStateValues);
263 if (liveness !=
nullptr) {
266 for (
size_t i = 0;
i <
count;
i++) {
284 while (
count > max_inputs) {
289 size_t values_idx = 0;
295 DCHECK_EQ(tree->opcode(), IrOpcode::kStateValues);
298 CheckTreeContainsValues(tree, values,
count, liveness);
312 DCHECK_GT(kMaxInlineDepth, current_depth_);
313 return &(stack_[current_depth_]);
318 CHECK_GT(kMaxInlineDepth, current_depth_);
319 stack_[current_depth_] =
336 while (!done() && Top()->IsEmpty()) {
337 count += Top()->AdvanceToNextRealOrEnd();
347 if (top->IsEmpty()) {
365 Node* value_node = top->GetReal();
367 if (value_node->
opcode() == IrOpcode::kStateValues ||
368 value_node->
opcode() == IrOpcode::kTypedStateValues) {
381 return Top()->Get(
nullptr);
385 Node* parent = Top()->parent();
386 DCHECK(!Top()->IsEmpty());
387 if (parent->
opcode() == IrOpcode::kStateValues) {
393 return (*types)[Top()->real_index()];
425 if (value->opcode() == IrOpcode::kStateValues ||
426 value->opcode() == IrOpcode::kTypedStateValues) {
Entry * LookupOrInsert(const Key &key, uint32_t hash)
static constexpr MachineType AnyTagged()
void resize(size_t new_size)
int register_count() const
bool RegisterIsLive(int index) const
constexpr IrOpcode::Value opcode() const
const Operator * op() const
size_t AdvanceTillNotEmpty()
SparseInputMask::InputIterator * Top()
SparseInputMask::InputIterator stack_[kMaxInlineDepth]
bool operator!=(iterator const &other) const
StateValuesAccess(Node *node)
CommonOperatorBuilder * common()
SparseInputMask::BitMaskType FillBufferWithValues(WorkingBuffer *node_buffer, size_t *node_count, size_t *values_idx, Node **values, size_t count, const BytecodeLivenessState *liveness)
static const size_t kMaxInputCount
ZoneVector< WorkingBuffer > working_space_
static bool IsKeysEqualToNode(StateValuesKey *key, Node *node)
Node * BuildTree(size_t *values_idx, Node **values, size_t count, const BytecodeLivenessState *liveness, size_t level)
Node * GetEmptyStateValues()
Node * GetNodeForValues(Node **values, size_t count, const BytecodeLivenessState *liveness=nullptr)
static bool AreValueKeysEqual(StateValuesKey *key1, StateValuesKey *key2)
CustomMatcherZoneHashMap hash_map_
Node * empty_state_values_
WorkingBuffer * GetWorkingSpace(size_t level)
std::array< Node *, kMaxInputCount > WorkingBuffer
static bool AreKeysEqual(void *key1, void *key2)
Node * GetValuesNodeFromCache(Node **nodes, size_t count, SparseInputMask mask)
StateValuesCache(JSGraph *js_graph)
Node * NewNode(const Operator *op, int input_count, Node *const *inputs, bool incomplete=false)
ZoneVector< MachineType > const * MachineTypesOf(Operator const *op)
SparseInputMask SparseInputMaskOf(Operator const *op)
#define DCHECK_LE(v1, v2)
#define CHECK_GT(lhs, rhs)
#define DCHECK_NOT_NULL(val)
#define DCHECK_NE(v1, v2)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)