OSDN Git Service

Merge "Accept output profile path from dalvikvm command"
authorCalin Juravle <calin@google.com>
Fri, 17 Mar 2017 22:03:49 +0000 (22:03 +0000)
committerGerrit Code Review <noreply-gerritcodereview@google.com>
Fri, 17 Mar 2017 22:03:49 +0000 (22:03 +0000)
cmdline/cmdline_parser_test.cc
cmdline/cmdline_types.h
runtime/jit/profile_saver_options.h
runtime/parsed_options.cc
runtime/runtime.cc

index 550e8c4..5b331bc 100644 (file)
@@ -476,7 +476,7 @@ TEST_F(CmdlineParserTest, TestJitOptions) {
 * -Xps-*
 */
 TEST_F(CmdlineParserTest, ProfileSaverOptions) {
-  ProfileSaverOptions opt = ProfileSaverOptions(true, 1, 2, 3, 4, 5, 6, 7);
+  ProfileSaverOptions opt = ProfileSaverOptions(true, 1, 2, 3, 4, 5, 6, 7, "abc");
 
   EXPECT_SINGLE_PARSE_VALUE(opt,
                             "-Xjitsaveprofilinginfo "
@@ -486,7 +486,8 @@ TEST_F(CmdlineParserTest, ProfileSaverOptions) {
                             "-Xps-min-methods-to-save:4 "
                             "-Xps-min-classes-to-save:5 "
                             "-Xps-min-notification-before-wake:6 "
-                            "-Xps-max-notification-before-wake:7",
+                            "-Xps-max-notification-before-wake:7 "
+                            "-Xps-profile-path:abc",
                             M::ProfileSaverOpts);
 }  // TEST_F
 
index f1123eb..71c4e95 100644 (file)
@@ -752,9 +752,13 @@ struct CmdlineType<ProfileSaverOptions> : CmdlineTypeParser<ProfileSaverOptions>
       return ParseInto(existing,
              &ProfileSaverOptions::max_notification_before_wake_,
              type_parser.Parse(suffix));
-    } else {
-      return Result::Failure(std::string("Invalid suboption '") + option + "'");
     }
+    if (android::base::StartsWith(option, "profile-path:")) {
+      existing.profile_path_ = suffix;
+      return Result::SuccessNoValue();
+    }
+
+    return Result::Failure(std::string("Invalid suboption '") + option + "'");
   }
 
   static const char* Name() { return "ProfileSaverOptions"; }
@@ -774,6 +778,5 @@ struct CmdlineType<ExperimentalFlags> : CmdlineTypeParser<ExperimentalFlags> {
 
   static const char* Name() { return "ExperimentalFlags"; }
 };
-
 }  // namespace art
 #endif  // ART_CMDLINE_CMDLINE_TYPES_H_
index 4ab2052..c8d256f 100644 (file)
@@ -37,7 +37,8 @@ struct ProfileSaverOptions {
     min_methods_to_save_(kMinMethodsToSave),
     min_classes_to_save_(kMinClassesToSave),
     min_notification_before_wake_(kMinNotificationBeforeWake),
-    max_notification_before_wake_(kMaxNotificationBeforeWake) {}
+    max_notification_before_wake_(kMaxNotificationBeforeWake),
+    profile_path_("") {}
 
   ProfileSaverOptions(
       bool enabled,
@@ -47,7 +48,8 @@ struct ProfileSaverOptions {
       uint32_t min_methods_to_save,
       uint32_t min_classes_to_save,
       uint32_t min_notification_before_wake,
-      uint32_t max_notification_before_wake):
+      uint32_t max_notification_before_wake,
+      const std::string& profile_path):
     enabled_(enabled),
     min_save_period_ms_(min_save_period_ms),
     save_resolved_classes_delay_ms_(save_resolved_classes_delay_ms),
@@ -55,7 +57,8 @@ struct ProfileSaverOptions {
     min_methods_to_save_(min_methods_to_save),
     min_classes_to_save_(min_classes_to_save),
     min_notification_before_wake_(min_notification_before_wake),
-    max_notification_before_wake_(max_notification_before_wake) {}
+    max_notification_before_wake_(max_notification_before_wake),
+    profile_path_(profile_path) {}
 
   bool IsEnabled() const {
     return enabled_;
@@ -85,6 +88,9 @@ struct ProfileSaverOptions {
   uint32_t GetMaxNotificationBeforeWake() const {
     return max_notification_before_wake_;
   }
+  std::string GetProfilePath() const {
+    return profile_path_;
+  }
 
   friend std::ostream & operator<<(std::ostream &os, const ProfileSaverOptions& pso) {
     os << "enabled_" << pso.enabled_
@@ -106,6 +112,7 @@ struct ProfileSaverOptions {
   uint32_t min_classes_to_save_;
   uint32_t min_notification_before_wake_;
   uint32_t max_notification_before_wake_;
+  std::string profile_path_;
 };
 
 }  // namespace art
index 9113f83..4d787db 100644 (file)
@@ -708,6 +708,7 @@ void ParsedOptions::Usage(const char* fmt, ...) {
   UsageMessage(stream, "  -Xps-min-classes-to-save:integervalue\n");
   UsageMessage(stream, "  -Xps-min-notification-before-wake:integervalue\n");
   UsageMessage(stream, "  -Xps-max-notification-before-wake:integervalue\n");
+  UsageMessage(stream, "  -Xps-profile-path:file-path\n");
   UsageMessage(stream, "  -Xcompiler:filename\n");
   UsageMessage(stream, "  -Xcompiler-option dex2oat-option\n");
   UsageMessage(stream, "  -Ximage-compiler-option dex2oat-option\n");
index 13370a0..44f8281 100644 (file)
@@ -2155,6 +2155,19 @@ void Runtime::CreateJit() {
   jit_.reset(jit::Jit::Create(jit_options_.get(), &error_msg));
   if (jit_.get() == nullptr) {
     LOG(WARNING) << "Failed to create JIT " << error_msg;
+    return;
+  }
+
+  // In case we have a profile path passed as a command line argument,
+  // register the current class path for profiling now. Note that we cannot do
+  // this before we create the JIT and having it here is the most convenient way.
+  // This is used when testing profiles with dalvikvm command as there is no
+  // framework to register the dex files for profiling.
+  if (jit_options_->GetSaveProfilingInfo() &&
+      !jit_options_->GetProfileSaverOptions().GetProfilePath().empty()) {
+    std::vector<std::string> dex_filenames;
+    Split(class_path_string_, ':', &dex_filenames);
+    RegisterAppInfo(dex_filenames, jit_options_->GetProfileSaverOptions().GetProfilePath());
   }
 }