ART: Add parameter for verifier timing log threshold

Make the old 100ms timing threshold configurable.

Bug: 111857793
Test: m test-art-host
Test: manual
Change-Id: I6c3d0c05acbe9d35d71999522077d5768c4e6c20
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index 7383d47..a44e5a4 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -333,6 +333,9 @@
           .IntoKey(M::UseStderrLogger)
       .Define("-Xonly-use-system-oat-files")
           .IntoKey(M::OnlyUseSystemOatFiles)
+      .Define("-Xverifier-logging-threshold=_")
+          .WithType<unsigned int>()
+          .IntoKey(M::VerifierLoggingThreshold)
       .Ignore({
           "-ea", "-da", "-enableassertions", "-disableassertions", "--runtime-arg", "-esa",
           "-dsa", "-enablesystemassertions", "-disablesystemassertions", "-Xrs", "-Xint:_",
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index a81c4d0..facebda 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -273,7 +273,8 @@
       pruned_dalvik_cache_(false),
       // Initially assume we perceive jank in case the process state is never updated.
       process_state_(kProcessStateJankPerceptible),
-      zygote_no_threads_(false) {
+      zygote_no_threads_(false),
+      verifier_logging_threshold_ms_(100) {
   static_assert(Runtime::kCalleeSaveSize ==
                     static_cast<uint32_t>(CalleeSaveType::kLastCalleeSaveType), "Unexpected size");
 
@@ -1438,6 +1439,8 @@
     }
   }
 
+  verifier_logging_threshold_ms_ = runtime_options.GetOrDefault(Opt::VerifierLoggingThreshold);
+
   std::string error_msg;
   java_vm_ = JavaVMExt::Create(this, runtime_options, &error_msg);
   if (java_vm_.get() == nullptr) {
diff --git a/runtime/runtime.h b/runtime/runtime.h
index f413733..ca93e24 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -767,6 +767,10 @@
 
   static constexpr int32_t kUnsetSdkVersion = 0u;
 
+  uint32_t GetVerifierLoggingThresholdMs() const {
+    return verifier_logging_threshold_ms_;
+  }
+
  private:
   static void InitPlatformSignalHandlers();
 
@@ -1073,6 +1077,8 @@
 
   std::unique_ptr<MemMap> protected_fault_page_;
 
+  uint32_t verifier_logging_threshold_ms_;
+
   DISALLOW_COPY_AND_ASSIGN(Runtime);
 };
 
diff --git a/runtime/runtime_options.def b/runtime/runtime_options.def
index 3f9a322..ef21f9f 100644
--- a/runtime/runtime_options.def
+++ b/runtime/runtime_options.def
@@ -152,5 +152,6 @@
 RUNTIME_OPTIONS_KEY (Unit,                UseStderrLogger)
 
 RUNTIME_OPTIONS_KEY (Unit,                OnlyUseSystemOatFiles)
+RUNTIME_OPTIONS_KEY (unsigned int,        VerifierLoggingThreshold,       100)
 
 #undef RUNTIME_OPTIONS_KEY
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 01b6bf8..a1b8938 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -439,7 +439,7 @@
   }
   if (kTimeVerifyMethod) {
     uint64_t duration_ns = NanoTime() - start_ns;
-    if (duration_ns > MsToNs(100)) {
+    if (duration_ns > MsToNs(Runtime::Current()->GetVerifierLoggingThresholdMs())) {
       LOG(WARNING) << "Verification of " << dex_file->PrettyMethod(method_idx)
                    << " took " << PrettyDuration(duration_ns)
                    << (IsLargeMethod(verifier.CodeItem()) ? " (large method)" : "");