summaryrefslogtreecommitdiffstats
path: root/compiler/optimizing/graph_checker.h
diff options
context:
space:
mode:
authorRoland Levillain <rpl@google.com>2014-09-30 16:15:14 +0100
committerRoland Levillain <rpl@google.com>2014-10-01 11:52:58 +0100
commitbf9cd7ba2118a75f5aa9b56241c4d5fa00dedeb8 (patch)
tree0bd049b173d23fcaed5c1b5cb4299e8faef840da /compiler/optimizing/graph_checker.h
parent34bb808affbed7a1db177b9ef4ab5461c2b2106b (diff)
downloadart-bf9cd7ba2118a75f5aa9b56241c4d5fa00dedeb8.tar.gz
art-bf9cd7ba2118a75f5aa9b56241c4d5fa00dedeb8.tar.bz2
art-bf9cd7ba2118a75f5aa9b56241c4d5fa00dedeb8.zip
Introduce a class to implement optimization passes.
- Add art::HOptimization. - Rename art::ConstantPropagation to art::HConstantFolding in compiler/optimizing/constant_folding.h to avoid name clashes with a class of the same name in compiler/dex/post_opt_passes.h. - Rename art::DeadCodeElimination to art::HDeadCodeElimination for consistency reasons. - Have art::HDeadCodeElimination and art::HConstantFolding derive from art::HOptimization. - Start to use these optimizations in art:OptimizingCompiler::TryCompile. Change-Id: Iaab350c122d87b2333b3760312b15c0592d7e010
Diffstat (limited to 'compiler/optimizing/graph_checker.h')
-rw-r--r--compiler/optimizing/graph_checker.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/compiler/optimizing/graph_checker.h b/compiler/optimizing/graph_checker.h
index 34a770b5f3..4fb07e0ae4 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 `block`.
virtual void VisitBasicBlock(HBasicBlock* block) OVERRIDE;
@@ -45,6 +49,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.
@@ -53,6 +64,9 @@ class GraphChecker : public HGraphVisitor {
GrowableArray<std::string> errors_;
private:
+ // String displayed before dumped errors.
+ const char* dump_prefix_;
+
DISALLOW_COPY_AND_ASSIGN(GraphChecker);
};
@@ -63,7 +77,7 @@ class SSAChecker : public GraphChecker {
typedef GraphChecker super_type;
SSAChecker(ArenaAllocator* allocator, HGraph* graph)
- : GraphChecker(allocator, graph) {}
+ : GraphChecker(allocator, graph, "art::SSAChecker: ") {}
// Perform SSA form checks on `block`.
virtual void VisitBasicBlock(HBasicBlock* block) OVERRIDE;