Create individual counters and timers for compilation kinds.

Bug: 112676029
Test: m
Change-Id: I6f500d1253288e89ab83cd5d77f6ce0360bff340
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 4ea61c6..373d93c 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -267,7 +267,8 @@
       collection_in_progress_(false),
       last_collection_increased_code_cache_(false),
       garbage_collect_code_(true),
-      number_of_compilations_(0),
+      number_of_baseline_compilations_(0),
+      number_of_optimized_compilations_(0),
       number_of_osr_compilations_(0),
       number_of_collections_(0),
       histogram_stack_map_memory_use_("Memory used for stack maps", 16),
@@ -694,7 +695,17 @@
     return false;
   }
 
-  number_of_compilations_++;
+  switch (compilation_kind) {
+    case CompilationKind::kOsr:
+      number_of_osr_compilations_++;
+      break;
+    case CompilationKind::kBaseline:
+      number_of_baseline_compilations_++;
+      break;
+    case CompilationKind::kOptimized:
+      number_of_optimized_compilations_++;
+      break;
+  }
 
   // We need to update the debug info before the entry point gets set.
   // At the same time we want to do under JIT lock so that debug info and JIT maps are in sync.
@@ -750,7 +761,6 @@
         method_code_map_.Put(code_ptr, method);
       }
       if (compilation_kind == CompilationKind::kOsr) {
-        number_of_osr_compilations_++;
         osr_code_map_.Put(method, code_ptr);
       } else if (NeedsClinitCheckBeforeCall(method) &&
                  !method->GetDeclaringClass()->IsVisiblyInitialized()) {
@@ -1913,7 +1923,8 @@
      << "Current JIT capacity: " << PrettySize(GetCurrentRegion()->GetCurrentCapacity()) << "\n"
      << "Current number of JIT JNI stub entries: " << jni_stubs_map_.size() << "\n"
      << "Current number of JIT code cache entries: " << method_code_map_.size() << "\n"
-     << "Total number of JIT compilations: " << number_of_compilations_ << "\n"
+     << "Total number of JIT baseline compilations: " << number_of_baseline_compilations_ << "\n"
+     << "Total number of JIT optimized compilations: " << number_of_optimized_compilations_ << "\n"
      << "Total number of JIT compilations for on stack replacement: "
         << number_of_osr_compilations_ << "\n"
      << "Total number of JIT code cache collections: " << number_of_collections_ << std::endl;
@@ -1947,7 +1958,8 @@
   }
 
   // Reset all statistics to be specific to this process.
-  number_of_compilations_ = 0;
+  number_of_baseline_compilations_ = 0;
+  number_of_optimized_compilations_ = 0;
   number_of_osr_compilations_ = 0;
   number_of_collections_ = 0;
   histogram_stack_map_memory_use_.Reset();
diff --git a/runtime/jit/jit_code_cache.h b/runtime/jit/jit_code_cache.h
index 4340603..d055ed3 100644
--- a/runtime/jit/jit_code_cache.h
+++ b/runtime/jit/jit_code_cache.h
@@ -579,8 +579,11 @@
 
   // ---------------- JIT statistics -------------------------------------- //
 
-  // Number of compilations done throughout the lifetime of the JIT.
-  size_t number_of_compilations_ GUARDED_BY(Locks::jit_lock_);
+  // Number of baseline compilations done throughout the lifetime of the JIT.
+  size_t number_of_baseline_compilations_ GUARDED_BY(Locks::jit_lock_);
+
+  // Number of optimized compilations done throughout the lifetime of the JIT.
+  size_t number_of_optimized_compilations_ GUARDED_BY(Locks::jit_lock_);
 
   // Number of compilations for on-stack-replacement done throughout the lifetime of the JIT.
   size_t number_of_osr_compilations_ GUARDED_BY(Locks::jit_lock_);