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
3 // found in the LICENSE file.
5 #include "src/compiler/graph-replay.h"
7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/graph.h"
9 #include "src/compiler/graph-inl.h"
10 #include "src/compiler/node.h"
11 #include "src/compiler/operator.h"
12 #include "src/compiler/operator-properties-inl.h"
20 void GraphReplayPrinter::PrintReplay(Graph* graph) {
21 GraphReplayPrinter replay;
22 PrintF(" Node* nil = graph.NewNode(common_builder.Dead());\n");
23 graph->VisitNodeInputsFromEnd(&replay);
27 GenericGraphVisit::Control 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) {
33 PrintF("); USE(n%d);\n", node->id());
34 return GenericGraphVisit::CONTINUE;
38 void GraphReplayPrinter::PostEdge(Node* from, int index, Node* to) {
39 PrintF(" n%d->ReplaceInput(%d, n%d);\n", from->id(), index, to->id());
43 void GraphReplayPrinter::PrintReplayOpCreator(Operator* op) {
44 IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode());
46 IrOpcode::IsCommonOpcode(opcode) ? "common_builder" : "js_builder";
47 const char* mnemonic = IrOpcode::IsCommonOpcode(opcode)
48 ? IrOpcode::Mnemonic(opcode)
49 : IrOpcode::Mnemonic(opcode) + 2;
50 PrintF(" op = %s.%s(", builder, mnemonic);
52 case IrOpcode::kParameter:
53 case IrOpcode::kNumberConstant:
57 PrintF("unique_name");
59 case IrOpcode::kHeapConstant:
60 PrintF("unique_constant");
63 PrintF("%d", op->InputCount());
65 case IrOpcode::kEffectPhi:
66 PrintF("%d", OperatorProperties::GetEffectInputCount(op));
69 case IrOpcode::kMerge:
70 PrintF("%d", OperatorProperties::GetControlInputCount(op));
81 } // namespace v8::internal::compiler