20 dead_(graph->NewNode(common->Dead())),
21 all_allocations_(zone),
22 escaping_allocations_(zone),
27bool IsStore(
Edge edge) {
32 case IrOpcode::kInitializeImmutableInObject:
33 case IrOpcode::kStore:
34 case IrOpcode::kStoreElement:
35 case IrOpcode::kStoreField:
36 case IrOpcode::kStoreToObject:
37 return edge.
index() == 0;
43bool IsEscapingAllocationWitness(Edge edge) {
44 if (edge.to()->opcode() != IrOpcode::kAllocateRaw)
return false;
46 return !IsStore(edge);
52 if (node->opcode() == IrOpcode::kAllocateRaw) {
57 for (
Edge edge : node->input_edges()) {
58 if (IsEscapingAllocationWitness(edge)) {
83std::optional<Node*> TryGetStoredValue(
Node* node) {
85 switch (node->opcode()) {
86 case IrOpcode::kInitializeImmutableInObject:
87 case IrOpcode::kStore:
88 case IrOpcode::kStoreElement:
89 case IrOpcode::kStoreToObject:
92 case IrOpcode::kStoreField:
105 DCHECK_EQ(node->opcode(), IrOpcode::kAllocateRaw);
108 return escaping->second != 0;
112 DCHECK_EQ(node->opcode(), IrOpcode::kAllocateRaw);
113 for (
Edge edge : node->use_edges()) {
115 Node* use = edge.from();
116 if (use->IsDead())
continue;
119 if (std::optional<Node*> stored_value = TryGetStoredValue(use);
120 stored_value.has_value() &&
121 stored_value.value()->opcode() == IrOpcode::kAllocateRaw &&
122 stored_value.value() != node) {
124 revisit_.push_back(stored_value.value());
136 DCHECK_EQ(allocation->opcode(), IrOpcode::kAllocateRaw);
141 DCHECK_EQ(allocation->opcode(), IrOpcode::kAllocateRaw);
void ReplaceWithValue(Node *node, Node *value, Node *effect=nullptr, Node *control=nullptr)
ZoneUnorderedSet< Node * > all_allocations_
LateEscapeAnalysis(Editor *editor, TFGraph *graph, CommonOperatorBuilder *common, Zone *zone)
ZoneUnorderedMap< Node *, int > escaping_allocations_
Reduction Reduce(Node *node) final
void RecordEscapingAllocation(Node *allocation)
void RemoveWitness(Node *allocation)
bool IsEscaping(Node *node)
void RemoveAllocation(Node *node)
static bool IsValueEdge(Edge edge)
static Node * GetValueInput(Node *node, int index)
constexpr IrOpcode::Value opcode() const
static Reduction NoChange()
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)