Home | History | Annotate | Download | only in compiler

Lines Matching refs:node

34 Reduction EscapeAnalysisReducer::ReduceNode(Node* node) {
35 if (node->id() < static_cast<NodeId>(fully_reduced_.length()) &&
36 fully_reduced_.Contains(node->id())) {
40 switch (node->opcode()) {
43 return ReduceLoad(node);
46 return ReduceStore(node);
48 return ReduceAllocate(node);
50 return ReduceFinishRegion(node);
52 return ReduceReferenceEqual(node);
54 return ReduceObjectIsSmi(node);
59 if (node->id() >= static_cast<NodeId>(fully_reduced_.length()) ||
60 fully_reduced_.Contains(node->id())) {
64 for (Node* input : node->inputs()) {
83 fully_reduced_.Add(node->id());
90 // whether a node might have a frame state input.
91 if (exists_virtual_allocate_ && node->op()->EffectInputCount() > 0) {
92 return ReduceFrameStateUses(node);
99 Reduction EscapeAnalysisReducer::Reduce(Node* node) {
100 Reduction reduction = ReduceNode(node);
101 if (reduction.Changed() && node != reduction.replacement()) {
102 escape_analysis()->SetReplacement(node, reduction.replacement());
109 Node* MaybeGuard(JSGraph* jsgraph, Zone* zone, Node* original,
110 Node* replacement) {
112 // node is not in a sub-type relation to the type of the the {original} node.
116 Node* const control = NodeProperties::GetControlInput(original);
124 Node* SkipTypeGuards(Node* node) {
125 while (node->opcode() == IrOpcode::kTypeGuard) {
126 node = NodeProperties::GetValueInput(node, 0);
128 return node;
133 Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) {
134 DCHECK(node->opcode() == IrOpcode::kLoadField ||
135 node->opcode() == IrOpcode::kLoadElement);
136 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) {
137 fully_reduced_.Add(node->id());
140 SkipTypeGuards(NodeProperties::GetValueInput(node, 0)))) {
141 if (Node* rep = escape_analysis()->GetReplacement(node)) {
142 TRACE("Replaced #%d (%s) with #%d (%s)\n", node->id(),
143 node->op()->mnemonic(), rep->id(), rep->op()->mnemonic());
144 rep = MaybeGuard(jsgraph(), zone(), node, rep);
145 ReplaceWithValue(node, rep);
153 Reduction EscapeAnalysisReducer::ReduceStore(Node* node) {
154 DCHECK(node->opcode() == IrOpcode::kStoreField ||
155 node->opcode() == IrOpcode::kStoreElement);
156 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) {
157 fully_reduced_.Add(node->id());
160 SkipTypeGuards(NodeProperties::GetValueInput(node, 0)))) {
161 TRACE("Removed #%d (%s) from effect chain\n", node->id(),
162 node->op()->mnemonic());
163 RelaxEffectsAndControls(node);
164 return Changed(node);
170 Reduction EscapeAnalysisReducer::ReduceAllocate(Node* node) {
171 DCHECK_EQ(node->opcode(), IrOpcode::kAllocate);
172 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) {
173 fully_reduced_.Add(node->id());
175 if (escape_analysis()->IsVirtual(node)) {
176 RelaxEffectsAndControls(node);
177 TRACE("Removed allocate #%d from effect chain\n", node->id());
178 return Changed(node);
184 Reduction EscapeAnalysisReducer::ReduceFinishRegion(Node* node) {
185 DCHECK_EQ(node->opcode(), IrOpcode::kFinishRegion);
186 Node* effect = NodeProperties::GetEffectInput(node, 0);
190 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) {
191 fully_reduced_.Add(node->id());
194 RelaxEffectsAndControls(node);
198 node->id());
199 PrintF(" %d user(s) of #%d remain(s):", node->UseCount(), node->id());
200 for (Edge edge : node->use_edges()) {
206 return Changed(node);
212 Reduction EscapeAnalysisReducer::ReduceReferenceEqual(Node* node) {
213 DCHECK_EQ(node->opcode(), IrOpcode::kReferenceEqual);
214 Node* left = SkipTypeGuards(NodeProperties::GetValueInput(node, 0));
215 Node* right = SkipTypeGuards(NodeProperties::GetValueInput(node, 1));
219 ReplaceWithValue(node, jsgraph()->TrueConstant());
220 TRACE("Replaced ref eq #%d with true\n", node->id());
224 ReplaceWithValue(node, jsgraph()->FalseConstant());
225 TRACE("Replaced ref eq #%d with false\n", node->id());
229 ReplaceWithValue(node, jsgraph()->FalseConstant());
230 TRACE("Replaced ref eq #%d with false\n", node->id());
237 Reduction EscapeAnalysisReducer::ReduceObjectIsSmi(Node* node) {
238 DCHECK_EQ(node->opcode(), IrOpcode::kObjectIsSmi);
239 Node* input = SkipTypeGuards(NodeProperties::GetValueInput(node, 0));
241 ReplaceWithValue(node, jsgraph()->FalseConstant());
242 TRACE("Replaced ObjectIsSmi #%d with false\n", node->id());
249 Reduction EscapeAnalysisReducer::ReduceFrameStateUses(Node* node) {
250 DCHECK_GE(node->op()->EffectInputCount(), 1);
251 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) {
252 fully_reduced_.Add(node->id());
255 for (int i = 0; i < node->InputCount(); ++i) {
256 Node* input = node->InputAt(i);
258 if (Node* ret = ReduceDeoptState(input, node, false)) {
259 node->ReplaceInput(i, ret);
265 return Changed(node);
271 // Returns the clone if it duplicated the node, and null otherwise.
272 Node* EscapeAnalysisReducer::ReduceDeoptState(Node* node, Node* effect,
274 DCHECK(node->opcode() == IrOpcode::kFrameState ||
275 node->opcode() == IrOpcode::kStateValues);
276 if (node->id() < static_cast<NodeId>(fully_reduced_.length()) &&
277 fully_reduced_.Contains(node->id())) {
280 TRACE("Reducing %s %d\n", node->op()->mnemonic(), node->id());
281 Node* clone = nullptr;
282 bool node_multiused = node->UseCount() > 1;
284 for (int i = 0; i < node->op()->ValueInputCount(); ++i) {
285 Node* input = NodeProperties::GetValueInput(node, i);
287 if (Node* ret = ReduceDeoptState(input, effect, multiple_users_rec)) {
289 TRACE(" Cloning #%d", node->id());
290 node = clone = jsgraph()->graph()->CloneNode(node);
291 TRACE(" to #%d\n", node->id());
294 NodeProperties::ReplaceValueInput(node, ret, i);
297 if (Node* ret = ReduceStateValueInput(node, i, effect, node_multiused,
301 node = clone = ret;
305 if (node->opcode() == IrOpcode::kFrameState) {
306 Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
308 if (Node* ret =
311 TRACE(" Cloning #%d", node->id());
312 node = clone = jsgraph()->graph()->CloneNode(node);
313 TRACE(" to #%d\n", node->id());
315 NodeProperties::ReplaceFrameStateInput(node, ret);
319 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) {
320 fully_reduced_.Add(node->id());
326 // Returns the clone if it duplicated the node, and null otherwise.
327 Node* EscapeAnalysisReducer::ReduceStateValueInput(Node* node, int node_index,
328 Node* effect,
332 Node* input = SkipTypeGuards(NodeProperties::GetValueInput(node, node_index));
333 if (node->id() < static_cast<NodeId>(fully_reduced_.length()) &&
334 fully_reduced_.Contains(node->id())) {
339 Node* clone = nullptr;
349 if (Node* object_state =
352 TRACE("Cloning #%d", node->id());
353 node = clone = jsgraph()->graph()->CloneNode(node);
354 TRACE(" to #%d\n", node->id());
358 NodeProperties::ReplaceValueInput(node, object_state, node_index);
360 node->id(), input->id(), object_state->id());
375 for (Node* node : all.reachable) {
376 if (node->opcode() == IrOpcode::kAllocate) {
377 CHECK(!escape_analysis_->IsVirtual(node));