diff options
author | Roland Levillain <rpl@google.com> | 2014-10-17 17:02:00 +0100 |
---|---|---|
committer | Roland Levillain <rpl@google.com> | 2014-10-17 17:11:43 +0100 |
commit | 75be28332b278cff9039b54bfb228ac72f539ccc (patch) | |
tree | a01829ba0412d0f6637a833b41694f0d757d8f43 /compiler/optimizing/graph_checker.h | |
parent | ffb078ee815a38123581e706099a3bed65a6cb24 (diff) | |
download | art-75be28332b278cff9039b54bfb228ac72f539ccc.tar.gz art-75be28332b278cff9039b54bfb228ac72f539ccc.tar.bz2 art-75be28332b278cff9039b54bfb228ac72f539ccc.zip |
Revert "Revert "Introduce a class to implement optimization passes.""
This reverts commit 1ddbf6d4b37979a9f11a203c12befd5ae8b65df4.
Change-Id: I110a14668d1564ee0604dc958b91394b40da89fc
Diffstat (limited to 'compiler/optimizing/graph_checker.h')
-rw-r--r-- | compiler/optimizing/graph_checker.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/compiler/optimizing/graph_checker.h b/compiler/optimizing/graph_checker.h index 862f1b600b..db3130678a 100644 --- a/compiler/optimizing/graph_checker.h +++ b/compiler/optimizing/graph_checker.h @@ -19,15 +19,19 @@ #include "nodes.h" +#include <ostream> + namespace art { // A control-flow graph visitor performing various checks. class GraphChecker : public HGraphVisitor { public: - GraphChecker(ArenaAllocator* allocator, HGraph* graph) + GraphChecker(ArenaAllocator* allocator, HGraph* graph, + const char* dump_prefix = "art::GraphChecker: ") : HGraphVisitor(graph), allocator_(allocator), - errors_(allocator, 0) {} + errors_(allocator, 0), + dump_prefix_(dump_prefix) {} // Check the whole graph (in insertion order). virtual void Run() { VisitInsertionOrder(); } @@ -48,6 +52,13 @@ class GraphChecker : public HGraphVisitor { return errors_; } + // Print detected errors on output stream `os`. + void Dump(std::ostream& os) { + for (size_t i = 0, e = errors_.Size(); i < e; ++i) { + os << dump_prefix_ << errors_.Get(i) << std::endl; + } + } + protected: ArenaAllocator* const allocator_; // The block currently visited. @@ -56,6 +67,9 @@ class GraphChecker : public HGraphVisitor { GrowableArray<std::string> errors_; private: + // String displayed before dumped errors. + const char* dump_prefix_; + DISALLOW_COPY_AND_ASSIGN(GraphChecker); }; @@ -66,7 +80,7 @@ class SSAChecker : public GraphChecker { typedef GraphChecker super_type; SSAChecker(ArenaAllocator* allocator, HGraph* graph) - : GraphChecker(allocator, graph) {} + : GraphChecker(allocator, graph, "art::SSAChecker: ") {} // Check the whole graph (in reverse post-order). virtual void Run() { |