Implement DDMS heap info ("HPIF") chunks.

This lets you see how many bytes/objects are in your managed heap.

Change-Id: Ie925207e9c48989a24968633e60b99314d220865
diff --git a/src/jdwp/jdwp_bits.h b/src/jdwp/jdwp_bits.h
index 59ece03..3b951f9 100644
--- a/src/jdwp/jdwp_bits.h
+++ b/src/jdwp/jdwp_bits.h
@@ -107,6 +107,26 @@
   *buf = (uint8_t)(val);
 }
 
+static inline void Write1BE(uint8_t** dst, uint8_t value) {
+  Set1(*dst, value);
+  *dst += sizeof(value);
+}
+
+static inline void Write2BE(uint8_t** dst, uint16_t value) {
+  Set2BE(*dst, value);
+  *dst += sizeof(value);
+}
+
+static inline void Write4BE(uint8_t** dst, uint32_t value) {
+  Set4BE(*dst, value);
+  *dst += sizeof(value);
+}
+
+static inline void Write8BE(uint8_t** dst, uint64_t value) {
+  Set8BE(*dst, value);
+  *dst += sizeof(value);
+}
+
 /*
  * Stuff a UTF-8 string into the buffer.
  */
diff --git a/src/jdwp/jdwp_handler.cc b/src/jdwp/jdwp_handler.cc
index f408c54..04c4734 100644
--- a/src/jdwp/jdwp_handler.cc
+++ b/src/jdwp/jdwp_handler.cc
@@ -1806,7 +1806,7 @@
    * the initial setup.  Only update if this is a non-DDMS packet.
    */
   if (pHeader->cmdSet != kJDWPDdmCmdSet) {
-    QuasiAtomicSwap64(GetNowMsec(), &lastActivityWhen);
+    QuasiAtomicSwap64(MilliTime(), &lastActivityWhen);
   }
 
   /* tell the VM that GC is okay again */
diff --git a/src/jdwp/jdwp_main.cc b/src/jdwp/jdwp_main.cc
index 1df0d66..fa02895 100644
--- a/src/jdwp/jdwp_main.cc
+++ b/src/jdwp/jdwp_main.cc
@@ -412,21 +412,6 @@
  */
 
 /*
- * Get a notion of the current time, in milliseconds.
- */
-int64_t GetNowMsec() {
-#ifdef HAVE_POSIX_CLOCKS
-  struct timespec now;
-  clock_gettime(CLOCK_MONOTONIC, &now);
-  return now.tv_sec * 1000LL + now.tv_nsec / 1000000LL;
-#else
-  struct timeval now;
-  gettimeofday(&now, NULL);
-  return now.tv_sec * 1000LL + now.tv_usec / 1000LL;
-#endif
-}
-
-/*
  * Return the time, in milliseconds, since the last debugger activity.
  *
  * Returns -1 if no debugger is attached, or 0 if we're in the middle of
@@ -447,7 +432,7 @@
   }
 
   /* now get the current time */
-  int64_t now = GetNowMsec();
+  int64_t now = MilliTime();
   CHECK_GT(now, last);
 
   LOG(VERBOSE) << "+++ debugger interval=" << (now - last);
diff --git a/src/jdwp/jdwp_priv.h b/src/jdwp/jdwp_priv.h
index 46f79b8..45d70f8 100644
--- a/src/jdwp/jdwp_priv.h
+++ b/src/jdwp/jdwp_priv.h
@@ -83,9 +83,6 @@
   Mutex socket_lock_;
 };
 
-/* get current time, in msec */
-int64_t GetNowMsec();
-
 }  // namespace JDWP
 
 }  // namespace art