OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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.h" | 5 #include "src/compiler/node.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 return false; | 293 return false; |
294 } | 294 } |
295 } | 295 } |
296 return mask == 3; | 296 return mask == 3; |
297 } | 297 } |
298 | 298 |
299 | 299 |
300 void Node::Print() const { | 300 void Node::Print() const { |
301 OFStream os(stdout); | 301 OFStream os(stdout); |
302 os << *this << std::endl; | 302 os << *this << std::endl; |
| 303 for (Node* input : this->inputs()) { |
| 304 os << " " << *input << std::endl; |
| 305 } |
303 } | 306 } |
304 | 307 |
| 308 std::ostream& operator<<(std::ostream& os, const Node& n) { |
| 309 os << n.id() << ": " << *n.op(); |
| 310 if (n.InputCount() > 0) { |
| 311 os << "("; |
| 312 for (int i = 0; i < n.InputCount(); ++i) { |
| 313 if (i != 0) os << ", "; |
| 314 if (n.InputAt(i)) { |
| 315 os << n.InputAt(i)->id(); |
| 316 } else { |
| 317 os << "null"; |
| 318 } |
| 319 } |
| 320 os << ")"; |
| 321 } |
| 322 return os; |
| 323 } |
305 | 324 |
306 Node::Node(NodeId id, const Operator* op, int inline_count, int inline_capacity) | 325 Node::Node(NodeId id, const Operator* op, int inline_count, int inline_capacity) |
307 : op_(op), | 326 : op_(op), |
308 type_(nullptr), | 327 type_(nullptr), |
309 mark_(0), | 328 mark_(0), |
310 bit_field_(IdField::encode(id) | InlineCountField::encode(inline_count) | | 329 bit_field_(IdField::encode(id) | InlineCountField::encode(inline_count) | |
311 InlineCapacityField::encode(inline_capacity)), | 330 InlineCapacityField::encode(inline_capacity)), |
312 first_use_(nullptr) { | 331 first_use_(nullptr) { |
313 // Inputs must either be out of line or within the inline capacity. | 332 // Inputs must either be out of line or within the inline capacity. |
314 DCHECK(inline_capacity <= kMaxInlineCapacity); | 333 DCHECK(inline_capacity <= kMaxInlineCapacity); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 CHECK_EQ(index, edge.index()); | 390 CHECK_EQ(index, edge.index()); |
372 CHECK_EQ(this->InputAt(index), edge.to()); | 391 CHECK_EQ(this->InputAt(index), edge.to()); |
373 index++; | 392 index++; |
374 } | 393 } |
375 CHECK_EQ(count, index); | 394 CHECK_EQ(count, index); |
376 CHECK_EQ(this->InputCount(), index); | 395 CHECK_EQ(this->InputCount(), index); |
377 } | 396 } |
378 } | 397 } |
379 #endif | 398 #endif |
380 | 399 |
381 | |
382 std::ostream& operator<<(std::ostream& os, const Node& n) { | |
383 os << n.id() << ": " << *n.op(); | |
384 if (n.InputCount() > 0) { | |
385 os << "("; | |
386 for (int i = 0; i < n.InputCount(); ++i) { | |
387 if (i != 0) os << ", "; | |
388 if (n.InputAt(i)) { | |
389 os << n.InputAt(i)->id(); | |
390 } else { | |
391 os << "null"; | |
392 } | |
393 } | |
394 os << ")"; | |
395 } | |
396 return os; | |
397 } | |
398 | |
399 | |
400 Node::InputEdges::iterator Node::InputEdges::iterator::operator++(int n) { | 400 Node::InputEdges::iterator Node::InputEdges::iterator::operator++(int n) { |
401 iterator result(*this); | 401 iterator result(*this); |
402 ++(*this); | 402 ++(*this); |
403 return result; | 403 return result; |
404 } | 404 } |
405 | 405 |
406 | 406 |
407 Node::Inputs::const_iterator Node::Inputs::const_iterator::operator++(int n) { | 407 Node::Inputs::const_iterator Node::Inputs::const_iterator::operator++(int n) { |
408 const_iterator result(*this); | 408 const_iterator result(*this); |
409 ++(*this); | 409 ++(*this); |
(...skipping 16 matching lines...) Expand all Loading... |
426 ++(*this); | 426 ++(*this); |
427 return result; | 427 return result; |
428 } | 428 } |
429 | 429 |
430 | 430 |
431 bool Node::Uses::empty() const { return begin() == end(); } | 431 bool Node::Uses::empty() const { return begin() == end(); } |
432 | 432 |
433 } // namespace compiler | 433 } // namespace compiler |
434 } // namespace internal | 434 } // namespace internal |
435 } // namespace v8 | 435 } // namespace v8 |
OLD | NEW |