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

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

Issue 935033004: Introduce and test NodeProperties::CollectControlProjections. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/scheduler.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/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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if (use->opcode() == IrOpcode::kProjection && 175 if (use->opcode() == IrOpcode::kProjection &&
176 ProjectionIndexOf(use->op()) == projection_index) { 176 ProjectionIndexOf(use->op()) == projection_index) {
177 return use; 177 return use;
178 } 178 }
179 } 179 }
180 return nullptr; 180 return nullptr;
181 } 181 }
182 182
183 183
184 // static 184 // static
185 void NodeProperties::CollectControlProjections(Node* node, Node** projections,
186 size_t projection_count) {
187 #ifdef DEBUG
188 DCHECK_EQ(static_cast<int>(projection_count), node->UseCount());
189 std::memset(projections, 0, sizeof(*projections) * projection_count);
190 #endif
191 size_t if_value_index = 0;
192 for (Node* const use : node->uses()) {
193 size_t index;
194 switch (use->opcode()) {
195 default:
196 UNREACHABLE();
197 // Fall through.
198 case IrOpcode::kIfTrue:
199 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
200 index = 0;
201 break;
202 case IrOpcode::kIfFalse:
203 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
204 index = 1;
205 break;
206 case IrOpcode::kIfValue:
207 DCHECK_EQ(IrOpcode::kSwitch, node->opcode());
208 index = if_value_index++;
209 break;
210 case IrOpcode::kIfDefault:
211 DCHECK_EQ(IrOpcode::kSwitch, node->opcode());
212 index = projection_count - 1;
213 break;
214 }
215 DCHECK_LT(if_value_index, projection_count);
216 DCHECK_LT(index, projection_count);
217 DCHECK_NULL(projections[index]);
218 projections[index] = use;
219 }
220 #ifdef DEBUG
221 for (size_t index = 0; index < projection_count; ++index) {
222 DCHECK_NOT_NULL(projections[index]);
223 }
224 #endif
225 }
226
227
228 // static
185 bool NodeProperties::AllValueInputsAreTyped(Node* node) { 229 bool NodeProperties::AllValueInputsAreTyped(Node* node) {
186 int input_count = node->op()->ValueInputCount(); 230 int input_count = node->op()->ValueInputCount();
187 for (int index = 0; index < input_count; ++index) { 231 for (int index = 0; index < input_count; ++index) {
188 if (!IsTyped(GetValueInput(node, index))) return false; 232 if (!IsTyped(GetValueInput(node, index))) return false;
189 } 233 }
190 return true; 234 return true;
191 } 235 }
192 236
193 237
194 // static 238 // static
195 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { 239 bool NodeProperties::IsInputRange(Edge edge, int first, int num) {
196 if (num == 0) return false; 240 if (num == 0) return false;
197 int const index = edge.index(); 241 int const index = edge.index();
198 return first <= index && index < first + num; 242 return first <= index && index < first + num;
199 } 243 }
200 244
201 } // namespace compiler 245 } // namespace compiler
202 } // namespace internal 246 } // namespace internal
203 } // namespace v8 247 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/node-properties.h ('k') | src/compiler/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698