Make the baseline threshold based on -Xjitthreshold.

Also remove handling of now unused -Xjitosrtreshold.

Test: test.py
Change-Id: Ib808373c58cacede2a8fa71ea6c69a4456cedbb5
diff --git a/runtime/interpreter/mterp/nterp.cc b/runtime/interpreter/mterp/nterp.cc
index 009f9bc..670ae1b 100644
--- a/runtime/interpreter/mterp/nterp.cc
+++ b/runtime/interpreter/mterp/nterp.cc
@@ -81,8 +81,6 @@
       LOG(FATAL) << "ERROR: unexpected asm interp size " << interp_size
                  << "(did an instruction handler exceed " << width << " bytes?)";
   }
-  static_assert(IsPowerOfTwo(kTieredHotnessMask + 1),
-                "Tiered hotness mask must be a (power of 2) - 1");
 }
 
 inline void UpdateHotness(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) {
diff --git a/runtime/interpreter/mterp/nterp.h b/runtime/interpreter/mterp/nterp.h
index b7cbbf7..1590b28 100644
--- a/runtime/interpreter/mterp/nterp.h
+++ b/runtime/interpreter/mterp/nterp.h
@@ -35,10 +35,6 @@
 
 constexpr uint16_t kNterpHotnessValue = 0;
 
-// The hotness threshold for the baseline compiler to trigger optimized
-// compilation.
-constexpr uint16_t kTieredHotnessMask = 0xffff;
-
 // The maximum we allow an nterp frame to be.
 constexpr size_t kNterpMaxFrame = 3 * KB;
 
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 9c5eff5..2ab10ff 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -129,13 +129,6 @@
   }
   DCHECK_LE(jit_options->warmup_threshold_, kJitMaxThreshold);
 
-  if (options.Exists(RuntimeArgumentMap::JITOsrThreshold)) {
-    jit_options->osr_threshold_ = *options.Get(RuntimeArgumentMap::JITOsrThreshold);
-  } else {
-    jit_options->osr_threshold_ = jit_options->warmup_threshold_;
-  }
-  DCHECK_LE(jit_options->osr_threshold_, kJitMaxThreshold);
-
   if (options.Exists(RuntimeArgumentMap::JITPriorityThreadWeight)) {
     jit_options->priority_thread_weight_ =
         *options.Get(RuntimeArgumentMap::JITPriorityThreadWeight);
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index 24dab6d..c0c4536 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -78,10 +78,6 @@
     return warmup_threshold_;
   }
 
-  uint16_t GetOsrThreshold() const {
-    return osr_threshold_;
-  }
-
   uint16_t GetPriorityThreadWeight() const {
     return priority_thread_weight_;
   }
@@ -163,7 +159,6 @@
   size_t code_cache_max_capacity_;
   uint32_t optimize_threshold_;
   uint32_t warmup_threshold_;
-  uint32_t osr_threshold_;
   uint16_t priority_thread_weight_;
   uint16_t invoke_transition_weight_;
   bool dump_info_on_shutdown_;
@@ -179,7 +174,6 @@
         code_cache_max_capacity_(0),
         optimize_threshold_(0),
         warmup_threshold_(0),
-        osr_threshold_(0),
         priority_thread_weight_(0),
         invoke_transition_weight_(0),
         dump_info_on_shutdown_(false),
@@ -279,10 +273,6 @@
     return options_->GetThreadPoolPthreadPriority();
   }
 
-  uint16_t OSRMethodThreshold() const {
-    return options_->GetOsrThreshold();
-  }
-
   uint16_t HotMethodThreshold() const {
     return options_->GetOptimizeThreshold();
   }
diff --git a/runtime/jit/profiling_info.cc b/runtime/jit/profiling_info.cc
index b8e7303..d859d5a 100644
--- a/runtime/jit/profiling_info.cc
+++ b/runtime/jit/profiling_info.cc
@@ -26,7 +26,7 @@
 namespace art {
 
 ProfilingInfo::ProfilingInfo(ArtMethod* method, const std::vector<uint32_t>& entries)
-      : baseline_hotness_count_(interpreter::kTieredHotnessMask),
+      : baseline_hotness_count_(GetOptimizeThreshold()),
         method_(method),
         number_of_inline_caches_(entries.size()),
         current_inline_uses_(0) {
@@ -36,6 +36,10 @@
   }
 }
 
+uint16_t ProfilingInfo::GetOptimizeThreshold() {
+  return Runtime::Current()->GetJITOptions()->GetOptimizeThreshold();
+}
+
 ProfilingInfo* ProfilingInfo::Create(Thread* self, ArtMethod* method) {
   // Walk over the dex instructions of the method and keep track of
   // instructions we are interested in profiling.
diff --git a/runtime/jit/profiling_info.h b/runtime/jit/profiling_info.h
index e658717..ed0847c 100644
--- a/runtime/jit/profiling_info.h
+++ b/runtime/jit/profiling_info.h
@@ -108,11 +108,11 @@
   }
 
   void ResetCounter() {
-    baseline_hotness_count_ = interpreter::kTieredHotnessMask;
+    baseline_hotness_count_ = GetOptimizeThreshold();
   }
 
   bool CounterHasChanged() const {
-    return baseline_hotness_count_ != interpreter::kTieredHotnessMask;
+    return baseline_hotness_count_ != GetOptimizeThreshold();
   }
 
   uint16_t GetBaselineHotnessCount() const {
@@ -122,6 +122,8 @@
  private:
   ProfilingInfo(ArtMethod* method, const std::vector<uint32_t>& entries);
 
+  static uint16_t GetOptimizeThreshold();
+
   // Hotness count for methods compiled with the JIT baseline compiler. Once
   // a threshold is hit (currentily the maximum value of uint16_t), we will
   // JIT compile optimized the method.
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index a999951..7b108b5 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -272,9 +272,6 @@
       .Define("-Xjitwarmupthreshold:_")
           .WithType<unsigned int>()
           .IntoKey(M::JITWarmupThreshold)
-      .Define("-Xjitosrthreshold:_")
-          .WithType<unsigned int>()
-          .IntoKey(M::JITOsrThreshold)
       .Define("-Xjitprithreadweight:_")
           .WithType<unsigned int>()
           .IntoKey(M::JITPriorityThreadWeight)
@@ -475,7 +472,7 @@
           "-Xverifyopt:_", "-Xcheckdexsum", "-Xincludeselectedop", "-Xjitop:_",
           "-Xincludeselectedmethod",
           "-Xjitblocking", "-Xjitmethod:_", "-Xjitclass:_", "-Xjitoffset:_",
-          "-Xjitconfig:_", "-Xjitcheckcg", "-Xjitverbose", "-Xjitprofile",
+          "-Xjitosrthreshold:_", "-Xjitconfig:_", "-Xjitcheckcg", "-Xjitverbose", "-Xjitprofile",
           "-Xjitdisableopt", "-Xjitsuspendpoll", "-XX:mainThreadStackSize=_"})
       .IgnoreUnrecognized(ignore_unrecognized)
       .OrderCategories({"standard", "extended", "Dalvik", "ART"});
diff --git a/runtime/runtime_options.def b/runtime/runtime_options.def
index b386d87..5df8421 100644
--- a/runtime/runtime_options.def
+++ b/runtime/runtime_options.def
@@ -92,7 +92,6 @@
 RUNTIME_OPTIONS_KEY (bool,                AutoPromoteOpaqueJniIds,        true)  // testing use only. -Xauto-promote-opaque-jni-ids:{true, false}
 RUNTIME_OPTIONS_KEY (unsigned int,        JITOptimizeThreshold)
 RUNTIME_OPTIONS_KEY (unsigned int,        JITWarmupThreshold)
-RUNTIME_OPTIONS_KEY (unsigned int,        JITOsrThreshold)
 RUNTIME_OPTIONS_KEY (unsigned int,        JITPriorityThreadWeight)
 RUNTIME_OPTIONS_KEY (unsigned int,        JITInvokeTransitionWeight)
 RUNTIME_OPTIONS_KEY (int,                 JITPoolThreadPthreadPriority,   jit::kJitPoolThreadPthreadDefaultPriority)