[art] Add GetObjectsAllocated and TotalTimeWaitingForGc APIs

It's difficult to analyze sluggish issue due to excessive GC.
So, I would like to add APIs for GC status check.

GetObjectsAllocated : return count of allocated objects.
 how to use : Debug.getRuntimeStat("art.gc.objects-allocated)
TotalTimeWaitingForGc : return total waiting time for GC.
 how to use : Debug.getRuntimeStat("art.gc.total-time-waiting-for-gc")

This must be submitted with the libcore code.

Test: check value using Debug.getRuntimeStat()

Change-Id: I2e865957ddb7e8cb5ac955e65a18d2aaffe4c672
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 5d0ba8f..53eed6b 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -850,6 +850,9 @@
   uint64_t GetBlockingGcTime() const;
   void DumpGcCountRateHistogram(std::ostream& os) const REQUIRES(!*gc_complete_lock_);
   void DumpBlockingGcCountRateHistogram(std::ostream& os) const REQUIRES(!*gc_complete_lock_);
+  uint64_t GetTotalTimeWaitingForGC() const {
+    return total_wait_time_;
+  }
 
   // Perfetto Art Heap Profiler Support.
   HeapSampler& GetHeapSampler() {
diff --git a/runtime/native/dalvik_system_VMDebug.cc b/runtime/native/dalvik_system_VMDebug.cc
index d1683a9..5c8bd84 100644
--- a/runtime/native/dalvik_system_VMDebug.cc
+++ b/runtime/native/dalvik_system_VMDebug.cc
@@ -313,6 +313,8 @@
   kArtGcBlockingGcTime,
   kArtGcGcCountRateHistogram,
   kArtGcBlockingGcCountRateHistogram,
+  kArtGcObjectsAllocated,
+  kArtGcTotalTimeWaitingForGc,
   kNumRuntimeStats,
 };
 
@@ -353,6 +355,14 @@
       heap->DumpBlockingGcCountRateHistogram(output);
       return env->NewStringUTF(output.str().c_str());
     }
+    case VMDebugRuntimeStatId::kArtGcObjectsAllocated: {
+      std::string output = std::to_string(heap->GetObjectsAllocated());
+      return env->NewStringUTF(output.c_str());
+    }
+    case VMDebugRuntimeStatId::kArtGcTotalTimeWaitingForGc: {
+      std::string output = std::to_string(heap->GetTotalTimeWaitingForGC());
+      return env->NewStringUTF(output.c_str());
+    }
     default:
       return nullptr;
   }