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

Side by Side Diff: src/compiler/node-properties.cc

Issue 928213003: Model exceptional edges from call nodes in TurboFan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 5 years, 10 months 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/node-properties.h ('k') | src/compiler/opcodes.h » ('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/node-properties.h" 5 #include "src/compiler/node-properties.h"
6 6
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/operator-properties.h" 8 #include "src/compiler/operator-properties.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 146
147 // static 147 // static
148 void NodeProperties::RemoveNonValueInputs(Node* node) { 148 void NodeProperties::RemoveNonValueInputs(Node* node) {
149 node->TrimInputCount(node->op()->ValueInputCount()); 149 node->TrimInputCount(node->op()->ValueInputCount());
150 } 150 }
151 151
152 152
153 // static 153 // static
154 void NodeProperties::ReplaceWithValue(Node* node, Node* value, Node* effect) { 154 void NodeProperties::ReplaceWithValue(Node* node, Node* value, Node* effect) {
155 DCHECK(node->op()->ControlOutputCount() == 0);
156 if (!effect && node->op()->EffectInputCount() > 0) { 155 if (!effect && node->op()->EffectInputCount() > 0) {
157 effect = NodeProperties::GetEffectInput(node); 156 effect = NodeProperties::GetEffectInput(node);
158 } 157 }
159 158
160 // Requires distinguishing between value and effect edges. 159 // Requires distinguishing between value, effect and control edges.
161 for (Edge edge : node->use_edges()) { 160 for (Edge edge : node->use_edges()) {
162 if (IsEffectEdge(edge)) { 161 if (IsControlEdge(edge)) {
162 DCHECK_EQ(IrOpcode::kIfSuccess, edge.from()->opcode());
163 Node* control = NodeProperties::GetControlInput(node);
164 edge.from()->ReplaceUses(control);
165 edge.UpdateTo(NULL);
166 } else if (IsEffectEdge(edge)) {
163 DCHECK_NOT_NULL(effect); 167 DCHECK_NOT_NULL(effect);
164 edge.UpdateTo(effect); 168 edge.UpdateTo(effect);
165 } else { 169 } else {
166 edge.UpdateTo(value); 170 edge.UpdateTo(value);
167 } 171 }
168 } 172 }
169 } 173 }
170 174
171 175
172 // static 176 // static
173 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) { 177 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) {
174 for (auto use : node->uses()) { 178 for (auto use : node->uses()) {
175 if (use->opcode() == IrOpcode::kProjection && 179 if (use->opcode() == IrOpcode::kProjection &&
176 ProjectionIndexOf(use->op()) == projection_index) { 180 ProjectionIndexOf(use->op()) == projection_index) {
177 return use; 181 return use;
178 } 182 }
179 } 183 }
180 return nullptr; 184 return nullptr;
181 } 185 }
182 186
183 187
184 // static 188 // static
185 void NodeProperties::CollectControlProjections(Node* node, Node** projections, 189 void NodeProperties::CollectControlProjections(Node* node, Node** projections,
186 size_t projection_count) { 190 size_t projection_count) {
187 #ifdef DEBUG 191 #ifdef DEBUG
188 DCHECK_EQ(static_cast<int>(projection_count), node->UseCount()); 192 DCHECK_LE(static_cast<int>(projection_count), node->UseCount());
189 std::memset(projections, 0, sizeof(*projections) * projection_count); 193 std::memset(projections, 0, sizeof(*projections) * projection_count);
190 #endif 194 #endif
191 size_t if_value_index = 0; 195 size_t if_value_index = 0;
192 for (Node* const use : node->uses()) { 196 for (Node* const use : node->uses()) {
193 size_t index; 197 size_t index;
194 switch (use->opcode()) { 198 switch (use->opcode()) {
195 default:
196 UNREACHABLE();
197 // Fall through.
198 case IrOpcode::kIfTrue: 199 case IrOpcode::kIfTrue:
199 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); 200 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
200 index = 0; 201 index = 0;
201 break; 202 break;
202 case IrOpcode::kIfFalse: 203 case IrOpcode::kIfFalse:
203 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); 204 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
204 index = 1; 205 index = 1;
205 break; 206 break;
207 case IrOpcode::kIfSuccess:
208 DCHECK_EQ(IrOpcode::kCall, node->opcode());
209 index = 0;
210 break;
211 case IrOpcode::kIfException:
212 DCHECK_EQ(IrOpcode::kCall, node->opcode());
213 index = 1;
214 break;
206 case IrOpcode::kIfValue: 215 case IrOpcode::kIfValue:
207 DCHECK_EQ(IrOpcode::kSwitch, node->opcode()); 216 DCHECK_EQ(IrOpcode::kSwitch, node->opcode());
208 index = if_value_index++; 217 index = if_value_index++;
209 break; 218 break;
210 case IrOpcode::kIfDefault: 219 case IrOpcode::kIfDefault:
211 DCHECK_EQ(IrOpcode::kSwitch, node->opcode()); 220 DCHECK_EQ(IrOpcode::kSwitch, node->opcode());
212 index = projection_count - 1; 221 index = projection_count - 1;
213 break; 222 break;
223 default:
224 continue;
214 } 225 }
215 DCHECK_LT(if_value_index, projection_count); 226 DCHECK_LT(if_value_index, projection_count);
216 DCHECK_LT(index, projection_count); 227 DCHECK_LT(index, projection_count);
217 DCHECK_NULL(projections[index]); 228 DCHECK_NULL(projections[index]);
218 projections[index] = use; 229 projections[index] = use;
219 } 230 }
220 #ifdef DEBUG 231 #ifdef DEBUG
221 for (size_t index = 0; index < projection_count; ++index) { 232 for (size_t index = 0; index < projection_count; ++index) {
222 DCHECK_NOT_NULL(projections[index]); 233 DCHECK_NOT_NULL(projections[index]);
223 } 234 }
(...skipping 14 matching lines...) Expand all
238 // static 249 // static
239 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { 250 bool NodeProperties::IsInputRange(Edge edge, int first, int num) {
240 if (num == 0) return false; 251 if (num == 0) return false;
241 int const index = edge.index(); 252 int const index = edge.index();
242 return first <= index && index < first + num; 253 return first <= index && index < first + num;
243 } 254 }
244 255
245 } // namespace compiler 256 } // namespace compiler
246 } // namespace internal 257 } // namespace internal
247 } // namespace v8 258 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/node-properties.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698