Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(708)

Side by Side Diff: src/compiler/escape-analysis-reducer.cc

Issue 1491903002: [turbofan] Refactor escape analysis to only expose one class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ensure only EscapeAnalysis can create EscapeStatusAnalysis Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/escape-analysis-reducer.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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( 14 EscapeAnalysisReducer::EscapeAnalysisReducer(Editor* editor, JSGraph* jsgraph,
15 Editor* editor, JSGraph* jsgraph, EscapeStatusAnalysis* escape_status, 15 EscapeAnalysis* escape_analysis,
16 EscapeObjectAnalysis* escape_analysis, Zone* zone) 16 Zone* zone)
17 : AdvancedReducer(editor), 17 : AdvancedReducer(editor),
18 jsgraph_(jsgraph), 18 jsgraph_(jsgraph),
19 escape_status_(escape_status),
20 escape_analysis_(escape_analysis), 19 escape_analysis_(escape_analysis),
21 zone_(zone) {} 20 zone_(zone) {}
22 21
23 22
24 Reduction EscapeAnalysisReducer::Reduce(Node* node) { 23 Reduction EscapeAnalysisReducer::Reduce(Node* node) {
25 switch (node->opcode()) { 24 switch (node->opcode()) {
26 case IrOpcode::kLoadField: 25 case IrOpcode::kLoadField:
27 return ReduceLoadField(node); 26 return ReduceLoadField(node);
28 case IrOpcode::kStoreField: 27 case IrOpcode::kStoreField:
29 return ReduceStoreField(node); 28 return ReduceStoreField(node);
(...skipping 21 matching lines...) Expand all
51 } 50 }
52 ReplaceWithValue(node, rep); 51 ReplaceWithValue(node, rep);
53 return Changed(rep); 52 return Changed(rep);
54 } 53 }
55 return NoChange(); 54 return NoChange();
56 } 55 }
57 56
58 57
59 Reduction EscapeAnalysisReducer::ReduceStoreField(Node* node) { 58 Reduction EscapeAnalysisReducer::ReduceStoreField(Node* node) {
60 DCHECK_EQ(node->opcode(), IrOpcode::kStoreField); 59 DCHECK_EQ(node->opcode(), IrOpcode::kStoreField);
61 if (escape_status()->IsVirtual(NodeProperties::GetValueInput(node, 0))) { 60 if (escape_analysis()->IsVirtual(NodeProperties::GetValueInput(node, 0))) {
62 if (FLAG_trace_turbo_escape) { 61 if (FLAG_trace_turbo_escape) {
63 PrintF("Removed store field #%d from effect chain\n", node->id()); 62 PrintF("Removed store field #%d from effect chain\n", node->id());
64 } 63 }
65 RelaxEffectsAndControls(node); 64 RelaxEffectsAndControls(node);
66 return Changed(node); 65 return Changed(node);
67 } 66 }
68 return NoChange(); 67 return NoChange();
69 } 68 }
70 69
71 70
72 Reduction EscapeAnalysisReducer::ReduceAllocate(Node* node) { 71 Reduction EscapeAnalysisReducer::ReduceAllocate(Node* node) {
73 DCHECK_EQ(node->opcode(), IrOpcode::kAllocate); 72 DCHECK_EQ(node->opcode(), IrOpcode::kAllocate);
74 if (escape_status()->IsVirtual(node)) { 73 if (escape_analysis()->IsVirtual(node)) {
75 RelaxEffectsAndControls(node); 74 RelaxEffectsAndControls(node);
76 if (FLAG_trace_turbo_escape) { 75 if (FLAG_trace_turbo_escape) {
77 PrintF("Removed allocate #%d from effect chain\n", node->id()); 76 PrintF("Removed allocate #%d from effect chain\n", node->id());
78 } 77 }
79 return Changed(node); 78 return Changed(node);
80 } 79 }
81 return NoChange(); 80 return NoChange();
82 } 81 }
83 82
84 83
(...skipping 15 matching lines...) Expand all
100 return Changed(node); 99 return Changed(node);
101 } 100 }
102 return NoChange(); 101 return NoChange();
103 } 102 }
104 103
105 104
106 Reduction EscapeAnalysisReducer::ReduceReferenceEqual(Node* node) { 105 Reduction EscapeAnalysisReducer::ReduceReferenceEqual(Node* node) {
107 DCHECK_EQ(node->opcode(), IrOpcode::kReferenceEqual); 106 DCHECK_EQ(node->opcode(), IrOpcode::kReferenceEqual);
108 Node* left = NodeProperties::GetValueInput(node, 0); 107 Node* left = NodeProperties::GetValueInput(node, 0);
109 Node* right = NodeProperties::GetValueInput(node, 1); 108 Node* right = NodeProperties::GetValueInput(node, 1);
110 if (escape_status()->IsVirtual(left)) { 109 if (escape_analysis()->IsVirtual(left)) {
111 if (escape_status()->IsVirtual(right)) { 110 if (escape_analysis()->IsVirtual(right)) {
112 if (Node* rep = escape_analysis()->GetReplacement(node, left->id())) { 111 if (Node* rep = escape_analysis()->GetReplacement(node, left->id())) {
113 left = rep; 112 left = rep;
114 } 113 }
115 if (Node* rep = escape_analysis()->GetReplacement(node, right->id())) { 114 if (Node* rep = escape_analysis()->GetReplacement(node, right->id())) {
116 right = rep; 115 right = rep;
117 } 116 }
118 // TODO(sigurds): What to do if either is a PHI? 117 // TODO(sigurds): What to do if either is a PHI?
119 if (left == right) { 118 if (left == right) {
120 ReplaceWithValue(node, jsgraph()->TrueConstant()); 119 ReplaceWithValue(node, jsgraph()->TrueConstant());
121 if (FLAG_trace_turbo_escape) { 120 if (FLAG_trace_turbo_escape) {
122 PrintF("Replaced ref eq #%d with true\n", node->id()); 121 PrintF("Replaced ref eq #%d with true\n", node->id());
123 } 122 }
124 return Replace(node); 123 return Replace(node);
125 } 124 }
126 } 125 }
127 // Right-hand side is either not virtual, or a different node. 126 // Right-hand side is either not virtual, or a different node.
128 ReplaceWithValue(node, jsgraph()->FalseConstant()); 127 ReplaceWithValue(node, jsgraph()->FalseConstant());
129 if (FLAG_trace_turbo_escape) { 128 if (FLAG_trace_turbo_escape) {
130 PrintF("Replaced ref eq #%d with false\n", node->id()); 129 PrintF("Replaced ref eq #%d with false\n", node->id());
131 } 130 }
132 return Replace(node); 131 return Replace(node);
133 } else if (escape_status()->IsVirtual(right)) { 132 } else if (escape_analysis()->IsVirtual(right)) {
134 // Left-hand side is not a virtual object. 133 // Left-hand side is not a virtual object.
135 ReplaceWithValue(node, jsgraph()->FalseConstant()); 134 ReplaceWithValue(node, jsgraph()->FalseConstant());
136 if (FLAG_trace_turbo_escape) { 135 if (FLAG_trace_turbo_escape) {
137 PrintF("Replaced ref eq #%d with false\n", node->id()); 136 PrintF("Replaced ref eq #%d with false\n", node->id());
138 } 137 }
139 } 138 }
140 return NoChange(); 139 return NoChange();
141 } 140 }
142 141
143 142
144 // TODO(sigurds): This is a temporary solution until escape analysis 143 // TODO(sigurds): This is a temporary solution until escape analysis
145 // supports deoptimization. 144 // supports deoptimization.
146 Reduction EscapeAnalysisReducer::ReplaceWithDeoptDummy(Node* node) { 145 Reduction EscapeAnalysisReducer::ReplaceWithDeoptDummy(Node* node) {
147 DCHECK(node->opcode() == IrOpcode::kStateValues || 146 DCHECK(node->opcode() == IrOpcode::kStateValues ||
148 node->opcode() == IrOpcode::kFrameState); 147 node->opcode() == IrOpcode::kFrameState);
149 Reduction r = NoChange(); 148 Reduction r = NoChange();
150 for (int i = 0; i < node->op()->ValueInputCount(); ++i) { 149 for (int i = 0; i < node->op()->ValueInputCount(); ++i) {
151 Node* input = NodeProperties::GetValueInput(node, i); 150 Node* input = NodeProperties::GetValueInput(node, i);
152 if (input->opcode() == IrOpcode::kFinishRegion || 151 if (input->opcode() == IrOpcode::kFinishRegion ||
153 input->opcode() == IrOpcode::kAllocate || 152 input->opcode() == IrOpcode::kAllocate ||
154 input->opcode() == IrOpcode::kPhi) { 153 input->opcode() == IrOpcode::kPhi) {
155 if (escape_status()->IsVirtual(input)) { 154 if (escape_analysis()->IsVirtual(input)) {
156 NodeProperties::ReplaceValueInput(node, jsgraph()->UndefinedConstant(), 155 NodeProperties::ReplaceValueInput(node, jsgraph()->UndefinedConstant(),
157 i); 156 i);
158 if (FLAG_trace_turbo_escape) { 157 if (FLAG_trace_turbo_escape) {
159 PrintF("Replaced state value (#%d) input with dummy\n", node->id()); 158 PrintF("Replaced state value (#%d) input with dummy\n", node->id());
160 } 159 }
161 r = Changed(node); 160 r = Changed(node);
162 } 161 }
163 } 162 }
164 } 163 }
165 return r; 164 return r;
166 } 165 }
167 166
168 167
169 } // namespace compiler 168 } // namespace compiler
170 } // namespace internal 169 } // namespace internal
171 } // namespace v8 170 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/escape-analysis-reducer.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698