Reland "Change hotness counting."

This reverts commit ce131feb7c60ffdf28c315c5d67f9cac33a077ce.

Bug: 203810169
Test: test.py
Test: health/microbench/startup/hscapps/compile-speed-profile/open-clock

Reason for revert: Kept logic from before on what methods to save in the
profile.

Change-Id: Id67cd47a9fe31b4c6b154db20f632015238016d2
diff --git a/runtime/interpreter/mterp/nterp.cc b/runtime/interpreter/mterp/nterp.cc
index fd57ece..e339dcf 100644
--- a/runtime/interpreter/mterp/nterp.cc
+++ b/runtime/interpreter/mterp/nterp.cc
@@ -90,18 +90,7 @@
   // The hotness we will add to a method when we perform a
   // field/method/class/string lookup.
   constexpr uint16_t kNterpHotnessLookup = 0xf;
-
-  // Convert to uint32_t to handle uint16_t overflow.
-  uint32_t counter = method->GetCounter();
-  uint32_t new_counter = counter + kNterpHotnessLookup;
-  if (new_counter > kNterpHotnessMask) {
-    // Let the nterp code actually call the compilation: we want to make sure
-    // there's at least a second execution of the method or a back-edge to avoid
-    // compiling straightline initialization methods.
-    method->SetCounter(kNterpHotnessMask);
-  } else {
-    method->SetCounter(new_counter);
-  }
+  method->UpdateCounter(kNterpHotnessLookup);
 }
 
 template<typename T>
@@ -738,6 +727,7 @@
 extern "C" jit::OsrData* NterpHotMethod(ArtMethod* method, uint16_t* dex_pc_ptr, uint32_t* vregs)
     REQUIRES_SHARED(Locks::mutator_lock_) {
   ScopedAssertNoThreadSuspension sants("In nterp");
+  method->ResetCounter();
   jit::Jit* jit = Runtime::Current()->GetJit();
   if (jit != nullptr && jit->UseJitCompilation()) {
     // Nterp passes null on entry where we don't want to OSR.
@@ -751,7 +741,7 @@
         return osr_data;
       }
     }
-    jit->EnqueueCompilationFromNterp(method, Thread::Current());
+    jit->EnqueueCompilation(method, Thread::Current());
   }
   return nullptr;
 }