OSDN Git Service

ART: dex2oat flag for HGraphVisualizer dump file
authorDavid Brazdil <dbrazdil@google.com>
Tue, 13 Jan 2015 21:21:31 +0000 (21:21 +0000)
committerDavid Brazdil <dbrazdil@google.com>
Tue, 13 Jan 2015 21:21:31 +0000 (21:21 +0000)
This patch adds a new '--dump-cfg=<file>' 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
compiler/driver/compiler_driver.cc
compiler/driver/compiler_driver.h
compiler/oat_test.cc
compiler/optimizing/optimizing_compiler.cc
dex2oat/dex2oat.cc
tools/checker.py

index 7df71f5..96f8e0c 100644 (file)
@@ -164,7 +164,7 @@ void CommonCompilerTest::SetUp() {
                                               compiler_kind, instruction_set,
                                               instruction_set_features_.get(),
                                               true, new std::set<std::string>, 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);
index 9985d66..e371807 100644 (file)
@@ -339,7 +339,8 @@ CompilerDriver::CompilerDriver(const CompilerOptions* compiler_options,
                                const InstructionSetFeatures* instruction_set_features,
                                bool image, std::set<std::string>* image_classes,
                                std::set<std::string>* 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<void>(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),
index 7ddc32c..11b4329 100644 (file)
@@ -97,6 +97,7 @@ class CompilerDriver {
                           bool image, std::set<std::string>* image_classes,
                           std::set<std::string>* 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_;
 
index d141538..6770e56 100644 (file)
@@ -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);
index 692d452..eaecbb0 100644 (file)
@@ -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));
   }
 }
 
index 4f279f2..8e564d1 100644 (file)
@@ -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
index 406a311..a7cde62 100755 (executable)
@@ -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])