Fix identifier size in the heap dump.

We're using addresses as IDs and previously we would have written
sizeof(void*) as the identifier size in the header. Heap references
are actually uint32_t so writting 4 bytes should be enough.

Bug: 16016862
Change-Id: I785abf5030681b6009370b7b2d7552e8b4b54e67
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index 7e3b6ba..8c0f3fb 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -633,8 +633,12 @@
     // U1: NUL-terminated magic string.
     fwrite(magic, 1, sizeof(magic), header_fp_);
 
-    // U4: size of identifiers.  We're using addresses as IDs, so make sure a pointer fits.
-    U4_TO_BUF_BE(buf, 0, sizeof(void*));
+    // U4: size of identifiers.  We're using addresses as IDs and our heap references are stored
+    // as uint32_t.
+    // Note of warning: hprof-conv hard-codes the size of identifiers to 4.
+    COMPILE_ASSERT(sizeof(mirror::HeapReference<mirror::Object>) == sizeof(uint32_t),
+      UnexpectedHeapReferenceSize);
+    U4_TO_BUF_BE(buf, 0, sizeof(uint32_t));
     fwrite(buf, 1, sizeof(uint32_t), header_fp_);
 
     // The current time, in milliseconds since 0:00 GMT, 1/1/70.