diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-05-14 09:43:38 +0100 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-05-14 14:26:11 +0100 |
commit | f635e63318447ca04731b265a86a573c9ed1737c (patch) | |
tree | 47cab84a6ac47d8a4f5f281e3eabdf1780f220d0 /compiler/optimizing/optimizing_compiler.cc | |
parent | d115735fe5523ff72319f0968f773683323c7f79 (diff) | |
download | art-f635e63318447ca04731b265a86a573c9ed1737c.zip art-f635e63318447ca04731b265a86a573c9ed1737c.tar.gz art-f635e63318447ca04731b265a86a573c9ed1737c.tar.bz2 |
Add a compilation tracing mechanism to the new compiler.
Code mostly imported from: https://android-review.googlesource.com/#/c/81653/.
Change-Id: I150fe942be0fb270e03fabb19032180f7a065d13
Diffstat (limited to 'compiler/optimizing/optimizing_compiler.cc')
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index a5031e0..f435cb0 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -14,6 +14,7 @@ * limitations under the License. */ +#include <fstream> #include <stdint.h> #include "builder.h" @@ -21,6 +22,7 @@ #include "compilers.h" #include "driver/compiler_driver.h" #include "driver/dex_compilation_unit.h" +#include "graph_visualizer.h" #include "nodes.h" #include "ssa_liveness_analysis.h" #include "utils/arena_allocator.h" @@ -50,6 +52,22 @@ class CodeVectorAllocator FINAL : public CodeAllocator { DISALLOW_COPY_AND_ASSIGN(CodeVectorAllocator); }; +/** + * If set to true, generates a file suitable for the c1visualizer tool and IRHydra. + */ +static bool kIsVisualizerEnabled = false; + +/** + * Filter to apply to the visualizer. Methods whose name contain that filter will + * be in the file. + */ +static const char* kStringFilter = ""; + +OptimizingCompiler::OptimizingCompiler(CompilerDriver* driver) : QuickCompiler(driver) { + if (kIsVisualizerEnabled) { + visualizer_output_.reset(new std::ofstream("art.cfg")); + } +} CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_item, uint32_t access_flags, @@ -70,6 +88,7 @@ CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_ite ArenaPool pool; ArenaAllocator arena(&pool); HGraphBuilder builder(&arena, &dex_compilation_unit, &dex_file); + HGraph* graph = builder.BuildGraph(*code_item); if (graph == nullptr) { if (shouldCompile) { @@ -77,6 +96,8 @@ CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_ite } return nullptr; } + HGraphVisualizer visualizer(visualizer_output_.get(), graph, kStringFilter, dex_compilation_unit); + visualizer.DumpGraph("builder"); InstructionSet instruction_set = GetCompilerDriver()->GetInstructionSet(); // The optimizing compiler currently does not have a Thumb2 assembler. @@ -104,6 +125,8 @@ CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_ite // Run these phases to get some test coverage. graph->BuildDominatorTree(); graph->TransformToSSA(); + visualizer.DumpGraph("ssa"); + graph->FindNaturalLoops(); SsaLivenessAnalysis(*graph).Analyze(); |