From 866c03125a3fcd74c9fff04da87865f5eb1767d9 Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Tue, 13 Jan 2015 21:21:31 +0000 Subject: [PATCH] ART: dex2oat flag for HGraphVisualizer dump file This patch adds a new '--dump-cfg=' flag to dex2oat which specifies the file that HGraphVisualizer will store its output into. Until now the graph was dumped to 'art.cfg' in the current working directory. To make Checker work with run-test, the output directory needs to be customizable. Change-Id: I4a940f7708b88deea5a0e51d13aed13e52199349 --- compiler/common_compiler_test.cc | 2 +- compiler/driver/compiler_driver.cc | 4 +++- compiler/driver/compiler_driver.h | 6 ++++++ compiler/oat_test.cc | 2 +- compiler/optimizing/optimizing_compiler.cc | 5 +++-- dex2oat/dex2oat.cc | 4 ++++ tools/checker.py | 4 ++-- 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index 7df71f5b8..96f8e0c35 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -164,7 +164,7 @@ void CommonCompilerTest::SetUp() { compiler_kind, instruction_set, instruction_set_features_.get(), true, new std::set, nullptr, - 2, true, true, timer_.get(), -1, "")); + 2, true, true, "", timer_.get(), -1, "")); } // We typically don't generate an image in unit tests, disable this optimization by default. compiler_driver_->SetSupportBootImageFixup(false); diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 9985d6646..e37180768 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -339,7 +339,8 @@ CompilerDriver::CompilerDriver(const CompilerOptions* compiler_options, const InstructionSetFeatures* instruction_set_features, bool image, std::set* image_classes, std::set* compiled_classes, size_t thread_count, - bool dump_stats, bool dump_passes, CumulativeLogger* timer, + bool dump_stats, bool dump_passes, + const std::string& dump_cfg_file_name, CumulativeLogger* timer, int swap_fd, const std::string& profile_file) : swap_space_(swap_fd == -1 ? nullptr : new SwapSpace(swap_fd, 10 * MB)), swap_space_allocator_(new SwapAllocator(swap_space_.get())), @@ -361,6 +362,7 @@ CompilerDriver::CompilerDriver(const CompilerOptions* compiler_options, stats_(new AOTCompilationStats), dump_stats_(dump_stats), dump_passes_(dump_passes), + dump_cfg_file_name_(dump_cfg_file_name), timings_logger_(timer), compiler_context_(nullptr), support_boot_image_fixup_(instruction_set != kMips), diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 7ddc32cdd..11b4329e3 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -97,6 +97,7 @@ class CompilerDriver { bool image, std::set* image_classes, std::set* compiled_classes, size_t thread_count, bool dump_stats, bool dump_passes, + const std::string& dump_cfg_file_name, CumulativeLogger* timer, int swap_fd, const std::string& profile_file); @@ -371,6 +372,10 @@ class CompilerDriver { return dump_passes_; } + const std::string& GetDumpCfgFileName() const { + return dump_cfg_file_name_; + } + CumulativeLogger* GetTimingsLogger() const { return timings_logger_; } @@ -542,6 +547,7 @@ class CompilerDriver { bool dump_stats_; const bool dump_passes_; + const std::string& dump_cfg_file_name_; CumulativeLogger* const timings_logger_; diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc index d14153872..6770e56a7 100644 --- a/compiler/oat_test.cc +++ b/compiler/oat_test.cc @@ -92,7 +92,7 @@ TEST_F(OatTest, WriteRead) { method_inliner_map_.get(), compiler_kind, insn_set, insn_features.get(), false, nullptr, nullptr, 2, true, - true, timer_.get(), -1, "")); + true, "", timer_.get(), -1, "")); jobject class_loader = nullptr; if (kCompile) { TimingLogger timings2("OatTest::WriteRead", false, false); diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 692d452f5..eaecbb04a 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -149,11 +149,12 @@ void OptimizingCompiler::Init() { // Enable C1visualizer output. Must be done in Init() because the compiler // driver is not fully initialized when passed to the compiler's constructor. CompilerDriver* driver = GetCompilerDriver(); - if (driver->GetDumpPasses()) { + const std::string cfg_file_name = driver->GetDumpCfgFileName(); + if (!cfg_file_name.empty()) { CHECK_EQ(driver->GetThreadCount(), 1U) << "Graph visualizer requires the compiler to run single-threaded. " << "Invoke the compiler with '-j1'."; - visualizer_output_.reset(new std::ofstream("art.cfg")); + visualizer_output_.reset(new std::ofstream(cfg_file_name)); } } diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 4f279f23d..8e564d185 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -659,6 +659,8 @@ class Dex2Oat FINAL { dump_timing_ = true; } else if (option == "--dump-passes") { dump_passes_ = true; + } else if (option.starts_with("--dump-cfg=")) { + dump_cfg_file_name_ = option.substr(strlen("--dump-cfg=")).data(); } else if (option == "--dump-stats") { dump_stats_ = true; } else if (option == "--include-debug-symbols" || option == "--no-strip-symbols") { @@ -1211,6 +1213,7 @@ class Dex2Oat FINAL { thread_count_, dump_stats_, dump_passes_, + dump_cfg_file_name_, compiler_phases_timings_.get(), swap_fd_, profile_file_)); @@ -1661,6 +1664,7 @@ class Dex2Oat FINAL { bool dump_passes_; bool dump_timing_; bool dump_slow_timing_; + std::string dump_cfg_file_name_; std::string swap_file_name_; int swap_fd_; std::string profile_file_; // Profile file to use diff --git a/tools/checker.py b/tools/checker.py index 406a31163..a7cde62fe 100755 --- a/tools/checker.py +++ b/tools/checker.py @@ -713,7 +713,7 @@ def CompileTest(inputFile, tempFolder): classFolder = tempFolder + "/classes" dexFile = tempFolder + "/test.dex" oatFile = tempFolder + "/test.oat" - outputFile = tempFolder + "/art.cfg" + outputFile = tempFolder + "/test.cfg" os.makedirs(classFolder) # Build a DEX from the source file. We pass "--no-optimize" to dx to avoid @@ -723,7 +723,7 @@ def CompileTest(inputFile, tempFolder): # Run dex2oat and export the HGraph. The output is stored into ${PWD}/art.cfg. with cd(tempFolder): - check_call(["dex2oat", "-j1", "--dump-passes", "--compiler-backend=Optimizing", + check_call(["dex2oat", "-j1", "--dump-cfg=" + outputFile, "--compiler-backend=Optimizing", "--android-root=" + os.environ["ANDROID_HOST_OUT"], "--boot-image=" + os.environ["ANDROID_HOST_OUT"] + "/framework/core-optimizing.art", "--runtime-arg", "-Xnorelocate", "--dex-file=" + dexFile, "--oat-file=" + oatFile]) -- 2.11.0