"src/compilation-statistics.h",
"src/compiler/access-builder.cc",
"src/compiler/access-builder.h",
+ "src/compiler/all-nodes.cc",
+ "src/compiler/all-nodes.h",
"src/compiler/ast-graph-builder.cc",
"src/compiler/ast-graph-builder.h",
"src/compiler/ast-loop-assignment-analyzer.cc",
--- /dev/null
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/compiler/all-nodes.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+AllNodes::AllNodes(Zone* local_zone, const Graph* graph)
+ : live(local_zone),
+ gray(local_zone),
+ state(graph->NodeCount(), AllNodes::kDead, local_zone) {
+ Node* end = graph->end();
+ state[end->id()] = AllNodes::kLive;
+ live.push_back(end);
+ // Find all live nodes reachable from end.
+ for (size_t i = 0; i < live.size(); i++) {
+ for (Node* const input : live[i]->inputs()) {
+ if (input == nullptr) {
+ // TODO(titzer): print a warning.
+ continue;
+ }
+ if (input->id() >= graph->NodeCount()) {
+ // TODO(titzer): print a warning.
+ continue;
+ }
+ if (state[input->id()] != AllNodes::kLive) {
+ live.push_back(input);
+ state[input->id()] = AllNodes::kLive;
+ }
+ }
+ }
+
+ // Find all nodes that are not reachable from end that use live nodes.
+ for (size_t i = 0; i < live.size(); i++) {
+ for (Node* const use : live[i]->uses()) {
+ if (state[use->id()] == AllNodes::kDead) {
+ gray.push_back(use);
+ state[use->id()] = AllNodes::kGray;
+ }
+ }
+ }
+}
+}
+}
+} // namespace v8::internal::compiler
--- /dev/null
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_COMPILER_ALL_NODES_H_
+#define V8_COMPILER_ALL_NODES_H_
+
+#include "src/compiler/graph.h"
+#include "src/compiler/node.h"
+#include "src/v8.h"
+#include "src/zone-containers.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+// A helper utility that traverses the graph and gathers all nodes reachable
+// from end.
+class AllNodes {
+ public:
+ // Constructor. Traverses the graph and builds the {live} and {gray} sets.
+ AllNodes(Zone* local_zone, const Graph* graph);
+
+ bool IsLive(Node* node) {
+ return node != nullptr && node->id() < static_cast<int>(state.size()) &&
+ state[node->id()] == kLive;
+ }
+
+ NodeVector live; // Nodes reachable from end.
+ NodeVector gray; // Nodes themselves not reachable from end, but that
+ // appear in use lists of live nodes.
+
+ private:
+ enum State { kDead, kGray, kLive };
+
+ ZoneVector<State> state;
+};
+}
+}
+} // namespace v8::internal::compiler
+
+#endif // V8_COMPILER_ALL_NODES_H_
#include "src/v8.h"
#include "src/compiler/common-operator.h"
-#include "src/compiler/graph-inl.h"
+#include "src/compiler/graph.h"
#include "src/compiler/node.h"
namespace v8 {
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "src/compiler/graph-reducer.h"
-
#include <functional>
-#include "src/compiler/graph-inl.h"
+#include "src/compiler/graph.h"
+#include "src/compiler/graph-reducer.h"
+#include "src/compiler/node.h"
namespace v8 {
namespace internal {
#include "src/compiler/graph-replay.h"
+#include "src/compiler/all-nodes.h"
#include "src/compiler/common-operator.h"
#include "src/compiler/graph.h"
-#include "src/compiler/graph-inl.h"
#include "src/compiler/node.h"
#include "src/compiler/operator.h"
#include "src/compiler/operator-properties.h"
void GraphReplayPrinter::PrintReplay(Graph* graph) {
GraphReplayPrinter replay;
PrintF(" Node* nil = graph.NewNode(common_builder.Dead());\n");
- graph->VisitNodeInputsFromEnd(&replay);
-}
-
+ Zone zone;
+ AllNodes nodes(&zone, graph);
-void GraphReplayPrinter::Pre(Node* node) {
- PrintReplayOpCreator(node->op());
- PrintF(" Node* n%d = graph.NewNode(op", node->id());
- for (int i = 0; i < node->InputCount(); ++i) {
- PrintF(", nil");
+ // Allocate the nodes first.
+ for (Node* node : nodes.live) {
+ PrintReplayOpCreator(node->op());
+ PrintF(" Node* n%d = graph.NewNode(op", node->id());
+ for (int i = 0; i < node->InputCount(); ++i) {
+ PrintF(", nil");
+ }
+ PrintF("); USE(n%d);\n", node->id());
}
- PrintF("); USE(n%d);\n", node->id());
-}
-
-void GraphReplayPrinter::PostEdge(Node* from, int index, Node* to) {
- PrintF(" n%d->ReplaceInput(%d, n%d);\n", from->id(), index, to->id());
+ // Connect the nodes to their inputs.
+ for (Node* node : nodes.live) {
+ for (int i = 0; i < node->InputCount(); i++) {
+ PrintF(" n%d->ReplaceInput(%d, n%d);\n", node->id(), i,
+ node->InputAt(i)->id());
+ }
+ }
}
#ifndef V8_COMPILER_GRAPH_REPLAY_H_
#define V8_COMPILER_GRAPH_REPLAY_H_
-#include "src/compiler/generic-algorithm.h"
#include "src/compiler/node.h"
namespace v8 {
// Helper class to print a full replay of a graph. This replay can be used to
// materialize the same graph within a C++ unit test and hence test subsequent
// optimization passes on a graph without going through the construction steps.
-class GraphReplayPrinter FINAL : public NullNodeVisitor {
+class GraphReplayPrinter {
public:
#ifdef DEBUG
static void PrintReplay(Graph* graph);
static void PrintReplay(Graph* graph) {}
#endif
- void Pre(Node* node);
- void PostEdge(Node* from, int index, Node* to);
-
private:
GraphReplayPrinter() {}
#include <string>
#include "src/code-stubs.h"
+#include "src/compiler/all-nodes.h"
#include "src/compiler/graph.h"
-#include "src/compiler/graph-inl.h"
#include "src/compiler/node.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/node-properties-inl.h"
#define DEAD_COLOR "#999999"
-class AllNodes {
- public:
- enum State { kDead, kGray, kLive };
-
- AllNodes(Zone* local_zone, const Graph* graph)
- : state(graph->NodeCount(), kDead, local_zone),
- live(local_zone),
- gray(local_zone) {
- Node* end = graph->end();
- state[end->id()] = kLive;
- live.push_back(end);
- // Find all live nodes reachable from end.
- for (size_t i = 0; i < live.size(); i++) {
- for (Node* const input : live[i]->inputs()) {
- if (input == NULL) {
- // TODO(titzer): print a warning.
- continue;
- }
- if (input->id() >= graph->NodeCount()) {
- // TODO(titzer): print a warning.
- continue;
- }
- if (state[input->id()] != kLive) {
- live.push_back(input);
- state[input->id()] = kLive;
- }
- }
- }
-
- // Find all nodes that are not reachable from end that use live nodes.
- for (size_t i = 0; i < live.size(); i++) {
- for (Node* const use : live[i]->uses()) {
- if (state[use->id()] == kDead) {
- gray.push_back(use);
- state[use->id()] = kGray;
- }
- }
- }
- }
-
- bool IsLive(Node* node) {
- return node != NULL && node->id() < static_cast<int>(state.size()) &&
- state[node->id()] == kLive;
- }
-
- ZoneVector<State> state;
- NodeVector live;
- NodeVector gray;
-};
-
-
class Escaped {
public:
explicit Escaped(const std::ostringstream& os,
// found in the LICENSE file.
#include "src/compiler/diamond.h"
-#include "src/compiler/graph-inl.h"
#include "src/compiler/js-builtin-reducer.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler.h"
#include "src/compiler/common-operator.h"
-#include "src/compiler/graph-inl.h"
#include "src/compiler/js-operator.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties-inl.h"
#include "src/code-factory.h"
#include "src/code-stubs.h"
#include "src/compiler/common-operator.h"
-#include "src/compiler/graph-inl.h"
#include "src/compiler/js-generic-lowering.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-aux-data-inl.h"
// found in the LICENSE file.
#include "src/compiler/access-builder.h"
-#include "src/compiler/graph-inl.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/js-typed-lowering.h"
#include "src/compiler/node-aux-data-inl.h"
#include "src/code-factory.h"
#include "src/compiler/common-operator.h"
#include "src/compiler/diamond.h"
-#include "src/compiler/graph-inl.h"
#include "src/compiler/linkage.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties-inl.h"
#include <string>
#include "src/bit-vector.h"
-#include "src/compiler/generic-algorithm.h"
-#include "src/compiler/graph-inl.h"
+#include "src/compiler/all-nodes.h"
#include "src/compiler/graph.h"
#include "src/compiler/node.h"
#include "src/compiler/node-properties-inl.h"
}
-class Verifier::Visitor : public NullNodeVisitor {
+class Verifier::Visitor {
public:
Visitor(Zone* z, Typing typed) : zone(z), typing(typed) {}
- // Fulfills the PreNodeCallback interface.
- void Pre(Node* node);
+ void Check(Node* node);
Zone* zone;
Typing typing;
};
-void Verifier::Visitor::Pre(Node* node) {
+void Verifier::Visitor::Check(Node* node) {
int value_count = node->op()->ValueInputCount();
int context_count = OperatorProperties::GetContextInputCount(node->op());
int frame_state_count =
void Verifier::Run(Graph* graph, Typing typing) {
- Visitor visitor(graph->zone(), typing);
CHECK_NE(NULL, graph->start());
CHECK_NE(NULL, graph->end());
- graph->VisitNodeInputsFromEnd(&visitor);
+ Zone zone;
+ Visitor visitor(&zone, typing);
+ for (Node* node : AllNodes(&zone, graph).live) visitor.Check(node);
}
'../../src/compilation-statistics.h',
'../../src/compiler/access-builder.cc',
'../../src/compiler/access-builder.h',
+ '../../src/compiler/all-nodes.cc',
+ '../../src/compiler/all-nodes.h',
'../../src/compiler/ast-graph-builder.cc',
'../../src/compiler/ast-graph-builder.h',
'../../src/compiler/ast-loop-assignment-analyzer.cc',