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

Unified Diff: src/compiler/graph-trimmer.h

Issue 1188433010: [turbofan] Move graph trimming functionality to dedicated GraphTrimmer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/graph-reducer.cc ('k') | src/compiler/graph-trimmer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/graph-trimmer.h
diff --git a/src/compiler/graph-trimmer.h b/src/compiler/graph-trimmer.h
new file mode 100644
index 0000000000000000000000000000000000000000..d8258becc8d6e4c3cb46ac9bdbc50a9ae28ab460
--- /dev/null
+++ b/src/compiler/graph-trimmer.h
@@ -0,0 +1,57 @@
+// 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_GRAPH_TRIMMER_H_
+#define V8_COMPILER_GRAPH_TRIMMER_H_
+
+#include "src/compiler/node-marker.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+// Forward declarations.
+class Graph;
+
+
+// Trims dead nodes from the node graph.
+class GraphTrimmer final {
+ public:
+ GraphTrimmer(Zone* zone, Graph* graph);
+ ~GraphTrimmer();
+
+ // Trim nodes in the {graph} that are not reachable from {graph->end()}.
+ void TrimGraph();
+
+ // Trim nodes in the {graph} that are not reachable from either {graph->end()}
+ // or any of the roots in the sequence [{begin},{end}[.
+ template <typename ForwardIterator>
+ void TrimGraph(ForwardIterator begin, ForwardIterator end) {
+ while (begin != end) MarkAsLive(*begin++);
+ TrimGraph();
+ }
+
+ private:
+ V8_INLINE bool IsLive(Node* const node) { return is_live_.Get(node); }
+ V8_INLINE void MarkAsLive(Node* const node) {
+ if (!node->IsDead() && !IsLive(node)) {
+ is_live_.Set(node, true);
+ live_.push_back(node);
+ }
+ }
+
+ Graph* graph() const { return graph_; }
+
+ Graph* const graph_;
+ NodeMarker<bool> is_live_;
+ NodeVector live_;
+
+ DISALLOW_COPY_AND_ASSIGN(GraphTrimmer);
+};
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
+
+#endif // V8_COMPILER_GRAPH_TRIMMER_H_
« no previous file with comments | « src/compiler/graph-reducer.cc ('k') | src/compiler/graph-trimmer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698