From ee690a3dd364c025ebc1767d9f84097bb7473eec Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Mon, 1 Dec 2014 17:04:16 +0000 Subject: ART: Added Checker, a pattern matching test engine This patch adds a Python script which implements a domain-specific mini-language similar to that of LLVM's FileCheck. It is primarily intended for writing tests for the optimizing compiler but could be configured for other use cases too. It is implemented from scratch in order to avoid dependency on LLVM. Checker tests are written in Java and dex2oat is invoked with a flag which dumps the CFG before and after each pass of the optimizing compiler. The output is then compared against assertions in the test's comments parsed by Checker. See comments in tools/checker.py for more details about the currently supported language features. This initial CL implements only one type of assertion - whether the output contains lines matching a desired pattern in the given order - but supports both plain text and regex matching and allows for equivalency testing by matching for the outcome of a previous match. See the tests in compiler/optimizing/test/ConstantFolding.java for examples. Change-Id: I1ad7431b399c38dc0391ccee74d2c643ba0b0675 --- compiler/optimizing/graph_visualizer.cc | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'compiler/optimizing/graph_visualizer.cc') diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc index 5d1703e237..b14b0a70e2 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -167,6 +167,15 @@ class HGraphVisualizerPrinter : public HGraphVisitor { } output_ << "]"; } + if (instruction->IsIntConstant()) { + output_ << " " << instruction->AsIntConstant()->GetValue(); + } else if (instruction->IsLongConstant()) { + output_ << " " << instruction->AsLongConstant()->GetValue(); + } else if (instruction->IsFloatConstant()) { + output_ << " " << instruction->AsFloatConstant()->GetValue(); + } else if (instruction->IsDoubleConstant()) { + output_ << " " << instruction->AsDoubleConstant()->GetValue(); + } if (pass_name_ == kLivenessPassName && instruction->GetLifetimePosition() != kNoLifetime) { output_ << " (liveness: " << instruction->GetLifetimePosition(); if (instruction->HasLiveInterval()) { @@ -270,7 +279,7 @@ HGraphVisualizer::HGraphVisualizer(std::ostream* output, const char* string_filter, const CodeGenerator& codegen, const char* method_name) - : output_(output), graph_(graph), codegen_(codegen), is_enabled_(false) { + : output_(output), graph_(graph), codegen_(codegen), is_enabled_(false) { if (output == nullptr) { return; } @@ -279,7 +288,7 @@ HGraphVisualizer::HGraphVisualizer(std::ostream* output, } is_enabled_ = true; - HGraphVisualizerPrinter printer(graph, *output_, "", codegen_); + HGraphVisualizerPrinter printer(graph_, *output_, "", codegen_); printer.StartTag("compilation"); printer.PrintProperty("name", method_name); printer.PrintProperty("method", method_name); @@ -287,12 +296,12 @@ HGraphVisualizer::HGraphVisualizer(std::ostream* output, printer.EndTag("compilation"); } -void HGraphVisualizer::DumpGraph(const char* pass_name) const { - if (!is_enabled_) { - return; +void HGraphVisualizer::DumpGraph(const char* pass_name, bool is_after_pass) const { + if (is_enabled_) { + std::string pass_desc = std::string(pass_name) + (is_after_pass ? " (after)" : " (before)"); + HGraphVisualizerPrinter printer(graph_, *output_, pass_desc.c_str(), codegen_); + printer.Run(); } - HGraphVisualizerPrinter printer(graph_, *output_, pass_name, codegen_); - printer.Run(); } } // namespace art -- cgit v1.2.3