OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/graph-replay.h" | 5 #include "src/compiler/graph-replay.h" |
6 | 6 |
| 7 #include "src/compiler/all-nodes.h" |
7 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
9 #include "src/compiler/graph-inl.h" | |
10 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
11 #include "src/compiler/operator.h" | 11 #include "src/compiler/operator.h" |
12 #include "src/compiler/operator-properties.h" | 12 #include "src/compiler/operator-properties.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 namespace compiler { | 16 namespace compiler { |
17 | 17 |
18 #ifdef DEBUG | 18 #ifdef DEBUG |
19 | 19 |
20 void GraphReplayPrinter::PrintReplay(Graph* graph) { | 20 void GraphReplayPrinter::PrintReplay(Graph* graph) { |
21 GraphReplayPrinter replay; | 21 GraphReplayPrinter replay; |
22 PrintF(" Node* nil = graph.NewNode(common_builder.Dead());\n"); | 22 PrintF(" Node* nil = graph.NewNode(common_builder.Dead());\n"); |
23 graph->VisitNodeInputsFromEnd(&replay); | 23 Zone zone; |
| 24 AllNodes nodes(&zone, graph); |
| 25 |
| 26 // Allocate the nodes first. |
| 27 for (Node* node : nodes.live) { |
| 28 PrintReplayOpCreator(node->op()); |
| 29 PrintF(" Node* n%d = graph.NewNode(op", node->id()); |
| 30 for (int i = 0; i < node->InputCount(); ++i) { |
| 31 PrintF(", nil"); |
| 32 } |
| 33 PrintF("); USE(n%d);\n", node->id()); |
| 34 } |
| 35 |
| 36 // Connect the nodes to their inputs. |
| 37 for (Node* node : nodes.live) { |
| 38 for (int i = 0; i < node->InputCount(); i++) { |
| 39 PrintF(" n%d->ReplaceInput(%d, n%d);\n", node->id(), i, |
| 40 node->InputAt(i)->id()); |
| 41 } |
| 42 } |
24 } | 43 } |
25 | 44 |
26 | 45 |
27 void GraphReplayPrinter::Pre(Node* node) { | |
28 PrintReplayOpCreator(node->op()); | |
29 PrintF(" Node* n%d = graph.NewNode(op", node->id()); | |
30 for (int i = 0; i < node->InputCount(); ++i) { | |
31 PrintF(", nil"); | |
32 } | |
33 PrintF("); USE(n%d);\n", node->id()); | |
34 } | |
35 | |
36 | |
37 void GraphReplayPrinter::PostEdge(Node* from, int index, Node* to) { | |
38 PrintF(" n%d->ReplaceInput(%d, n%d);\n", from->id(), index, to->id()); | |
39 } | |
40 | |
41 | |
42 void GraphReplayPrinter::PrintReplayOpCreator(const Operator* op) { | 46 void GraphReplayPrinter::PrintReplayOpCreator(const Operator* op) { |
43 IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode()); | 47 IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode()); |
44 const char* builder = | 48 const char* builder = |
45 IrOpcode::IsCommonOpcode(opcode) ? "common_builder" : "js_builder"; | 49 IrOpcode::IsCommonOpcode(opcode) ? "common_builder" : "js_builder"; |
46 const char* mnemonic = IrOpcode::IsCommonOpcode(opcode) | 50 const char* mnemonic = IrOpcode::IsCommonOpcode(opcode) |
47 ? IrOpcode::Mnemonic(opcode) | 51 ? IrOpcode::Mnemonic(opcode) |
48 : IrOpcode::Mnemonic(opcode) + 2; | 52 : IrOpcode::Mnemonic(opcode) + 2; |
49 PrintF(" op = %s.%s(", builder, mnemonic); | 53 PrintF(" op = %s.%s(", builder, mnemonic); |
50 switch (opcode) { | 54 switch (opcode) { |
51 case IrOpcode::kParameter: | 55 case IrOpcode::kParameter: |
(...skipping 19 matching lines...) Expand all Loading... |
71 default: | 75 default: |
72 break; | 76 break; |
73 } | 77 } |
74 PrintF(");\n"); | 78 PrintF(");\n"); |
75 } | 79 } |
76 | 80 |
77 #endif // DEBUG | 81 #endif // DEBUG |
78 } | 82 } |
79 } | 83 } |
80 } // namespace v8::internal::compiler | 84 } // namespace v8::internal::compiler |
OLD | NEW |