diff options
Diffstat (limited to 'compiler/optimizing/graph_visualizer.cc')
-rw-r--r-- | compiler/optimizing/graph_visualizer.cc | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc index a7604beac4..52e3e374b6 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -18,6 +18,7 @@ #include "driver/dex_compilation_unit.h" #include "nodes.h" +#include "ssa_liveness_analysis.h" namespace art { @@ -102,6 +103,24 @@ class HGraphVisualizerPrinter : public HGraphVisitor { } output_ << "]"; } + if (instruction->GetLifetimePosition() != kNoLifetime) { + output_ << " (liveness: " << instruction->GetLifetimePosition(); + if (instruction->HasLiveInterval()) { + output_ << " "; + const GrowableArray<LiveRange>& ranges = instruction->GetLiveInterval()->GetRanges(); + size_t i = ranges.Size() - 1; + do { + output_ << "[" << ranges.Get(i).GetStart() << "," << ranges.Get(i).GetEnd() << "["; + if (i == 0) { + break; + } else { + --i; + output_ << ","; + } + } while (true); + } + output_ << ")"; + } } void PrintInstructions(const HInstructionList& list) { @@ -126,8 +145,14 @@ class HGraphVisualizerPrinter : public HGraphVisitor { void VisitBasicBlock(HBasicBlock* block) { StartTag("block"); PrintProperty("name", "B", block->GetBlockId()); - PrintInt("from_bci", -1); - PrintInt("to_bci", -1); + if (block->GetLifetimeStart() != kNoLifetime) { + // Piggy back on these fields to show the lifetime of the block. + PrintInt("from_bci", block->GetLifetimeStart()); + PrintInt("to_bci", block->GetLifetimeEnd()); + } else { + PrintInt("from_bci", -1); + PrintInt("to_bci", -1); + } PrintPredecessors(block); PrintSuccessors(block); PrintEmptyProperty("xhandlers"); @@ -188,6 +213,23 @@ HGraphVisualizer::HGraphVisualizer(std::ostream* output, printer.EndTag("compilation"); } +HGraphVisualizer::HGraphVisualizer(std::ostream* output, + HGraph* graph, + const char* name) + : output_(output), graph_(graph), is_enabled_(false) { + if (output == nullptr) { + return; + } + + is_enabled_ = true; + HGraphVisualizerPrinter printer(graph, *output_); + printer.StartTag("compilation"); + printer.PrintProperty("name", name); + printer.PrintProperty("method", name); + printer.PrintTime("date"); + printer.EndTag("compilation"); +} + void HGraphVisualizer::DumpGraph(const char* pass_name) { if (!is_enabled_) { return; |