OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/escape-analysis-reducer.h" | 5 #include "src/compiler/escape-analysis-reducer.h" |
6 | 6 |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 namespace compiler { | 12 namespace compiler { |
13 | 13 |
14 EscapeAnalysisReducer::EscapeAnalysisReducer(Editor* editor, JSGraph* jsgraph, | 14 EscapeAnalysisReducer::EscapeAnalysisReducer(Editor* editor, JSGraph* jsgraph, |
15 EscapeAnalysis* escape_analysis, | 15 EscapeAnalysis* escape_analysis, |
16 Zone* zone) | 16 Zone* zone) |
17 : AdvancedReducer(editor), | 17 : AdvancedReducer(editor), |
18 jsgraph_(jsgraph), | 18 jsgraph_(jsgraph), |
19 escape_analysis_(escape_analysis), | 19 escape_analysis_(escape_analysis), |
20 zone_(zone) {} | 20 zone_(zone) {} |
21 | 21 |
22 | 22 |
23 Reduction EscapeAnalysisReducer::Reduce(Node* node) { | 23 Reduction EscapeAnalysisReducer::Reduce(Node* node) { |
24 switch (node->opcode()) { | 24 switch (node->opcode()) { |
25 case IrOpcode::kLoadField: | 25 case IrOpcode::kLoadField: |
26 return ReduceLoadField(node); | 26 case IrOpcode::kLoadElement: |
| 27 return ReduceLoad(node); |
27 case IrOpcode::kStoreField: | 28 case IrOpcode::kStoreField: |
28 return ReduceStoreField(node); | 29 case IrOpcode::kStoreElement: |
| 30 return ReduceStore(node); |
29 case IrOpcode::kAllocate: | 31 case IrOpcode::kAllocate: |
30 return ReduceAllocate(node); | 32 return ReduceAllocate(node); |
31 case IrOpcode::kFinishRegion: | 33 case IrOpcode::kFinishRegion: |
32 return ReduceFinishRegion(node); | 34 return ReduceFinishRegion(node); |
33 case IrOpcode::kReferenceEqual: | 35 case IrOpcode::kReferenceEqual: |
34 return ReduceReferenceEqual(node); | 36 return ReduceReferenceEqual(node); |
35 case IrOpcode::kStateValues: | 37 case IrOpcode::kStateValues: |
36 case IrOpcode::kFrameState: | 38 case IrOpcode::kFrameState: |
37 return ReplaceWithDeoptDummy(node); | 39 return ReplaceWithDeoptDummy(node); |
38 default: | 40 default: |
39 break; | 41 break; |
40 } | 42 } |
41 return NoChange(); | 43 return NoChange(); |
42 } | 44 } |
43 | 45 |
44 | 46 |
45 Reduction EscapeAnalysisReducer::ReduceLoadField(Node* node) { | 47 Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) { |
46 DCHECK_EQ(node->opcode(), IrOpcode::kLoadField); | 48 DCHECK(node->opcode() == IrOpcode::kLoadField || |
| 49 node->opcode() == IrOpcode::kLoadElement); |
47 if (Node* rep = escape_analysis()->GetReplacement(node, node->id())) { | 50 if (Node* rep = escape_analysis()->GetReplacement(node, node->id())) { |
48 if (FLAG_trace_turbo_escape) { | 51 if (FLAG_trace_turbo_escape) { |
49 PrintF("Replaced #%d with #%d\n", node->id(), rep->id()); | 52 PrintF("Replaced #%d (%s) with #%d (%s)\n", node->id(), |
| 53 node->op()->mnemonic(), rep->id(), rep->op()->mnemonic()); |
50 } | 54 } |
51 ReplaceWithValue(node, rep); | 55 ReplaceWithValue(node, rep); |
52 return Changed(rep); | 56 return Changed(rep); |
53 } | 57 } |
54 return NoChange(); | 58 return NoChange(); |
55 } | 59 } |
56 | 60 |
57 | 61 |
58 Reduction EscapeAnalysisReducer::ReduceStoreField(Node* node) { | 62 Reduction EscapeAnalysisReducer::ReduceStore(Node* node) { |
59 DCHECK_EQ(node->opcode(), IrOpcode::kStoreField); | 63 DCHECK(node->opcode() == IrOpcode::kStoreField || |
| 64 node->opcode() == IrOpcode::kStoreElement); |
60 if (escape_analysis()->IsVirtual(NodeProperties::GetValueInput(node, 0))) { | 65 if (escape_analysis()->IsVirtual(NodeProperties::GetValueInput(node, 0))) { |
61 if (FLAG_trace_turbo_escape) { | 66 if (FLAG_trace_turbo_escape) { |
62 PrintF("Removed store field #%d from effect chain\n", node->id()); | 67 PrintF("Removed #%d (%s) from effect chain\n", node->id(), |
| 68 node->op()->mnemonic()); |
63 } | 69 } |
64 RelaxEffectsAndControls(node); | 70 RelaxEffectsAndControls(node); |
65 return Changed(node); | 71 return Changed(node); |
66 } | 72 } |
67 return NoChange(); | 73 return NoChange(); |
68 } | 74 } |
69 | 75 |
70 | 76 |
71 Reduction EscapeAnalysisReducer::ReduceAllocate(Node* node) { | 77 Reduction EscapeAnalysisReducer::ReduceAllocate(Node* node) { |
72 DCHECK_EQ(node->opcode(), IrOpcode::kAllocate); | 78 DCHECK_EQ(node->opcode(), IrOpcode::kAllocate); |
(...skipping 10 matching lines...) Expand all Loading... |
83 | 89 |
84 Reduction EscapeAnalysisReducer::ReduceFinishRegion(Node* node) { | 90 Reduction EscapeAnalysisReducer::ReduceFinishRegion(Node* node) { |
85 DCHECK_EQ(node->opcode(), IrOpcode::kFinishRegion); | 91 DCHECK_EQ(node->opcode(), IrOpcode::kFinishRegion); |
86 Node* effect = NodeProperties::GetEffectInput(node, 0); | 92 Node* effect = NodeProperties::GetEffectInput(node, 0); |
87 if (effect->opcode() == IrOpcode::kBeginRegion) { | 93 if (effect->opcode() == IrOpcode::kBeginRegion) { |
88 RelaxEffectsAndControls(effect); | 94 RelaxEffectsAndControls(effect); |
89 RelaxEffectsAndControls(node); | 95 RelaxEffectsAndControls(node); |
90 if (FLAG_trace_turbo_escape) { | 96 if (FLAG_trace_turbo_escape) { |
91 PrintF("Removed region #%d / #%d from effect chain,", effect->id(), | 97 PrintF("Removed region #%d / #%d from effect chain,", effect->id(), |
92 node->id()); | 98 node->id()); |
93 PrintF("%d user(s) of #%d remain(s):", node->UseCount(), node->id()); | 99 PrintF(" %d user(s) of #%d remain(s):", node->UseCount(), node->id()); |
94 for (Edge edge : node->use_edges()) { | 100 for (Edge edge : node->use_edges()) { |
95 PrintF(" #%d", edge.from()->id()); | 101 PrintF(" #%d", edge.from()->id()); |
96 } | 102 } |
97 PrintF("\n"); | 103 PrintF("\n"); |
98 } | 104 } |
99 return Changed(node); | 105 return Changed(node); |
100 } | 106 } |
101 return NoChange(); | 107 return NoChange(); |
102 } | 108 } |
103 | 109 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 167 } |
162 } | 168 } |
163 } | 169 } |
164 return r; | 170 return r; |
165 } | 171 } |
166 | 172 |
167 | 173 |
168 } // namespace compiler | 174 } // namespace compiler |
169 } // namespace internal | 175 } // namespace internal |
170 } // namespace v8 | 176 } // namespace v8 |
OLD | NEW |