Fix build breakage caused by the countInstancesOfClass change.

There is an apparent visibility skew between passion-eng and sim-eng
builds.  On sim-eng, the contents of Heap.h are globally visible but
on passion-eng this is not the case.  To resolve this issue, I have
moved the offending declarations to alloc/Alloc.h which is directly
exported from Dalvik.h.

Change-Id: Iaf6f167964f81f24fa0817aa4a84b9fb4ff9a9a0
diff --git a/vm/alloc/Alloc.c b/vm/alloc/Alloc.c
index 61a1350..50f6ed9 100644
--- a/vm/alloc/Alloc.c
+++ b/vm/alloc/Alloc.c
@@ -19,6 +19,7 @@
 #include "Dalvik.h"
 #include "alloc/Heap.h"
 #include "alloc/HeapInternal.h"
+#include "alloc/HeapSource.h"
 
 #if WITH_HPROF && WITH_HPROF_STACK
 #include "hprof/Hprof.h"
@@ -299,3 +300,33 @@
 
     dvmUnlockHeap();
 }
+
+typedef struct {
+    const ClassObject *clazz;
+    size_t count;
+} CountInstancesOfClassContext;
+
+static void countInstancesOfClassCallback(size_t numPtrs, void **ptrs,
+                                          const void *finger, void *arg)
+{
+    CountInstancesOfClassContext *ctx = arg;
+    size_t i;
+
+    assert(ctx != NULL);
+    for (i = 0; i < numPtrs; ++i) {
+        const Object *obj = ptrs[i];
+        if (obj->clazz == ctx->clazz) {
+            ctx->count += 1;
+        }
+    }
+}
+
+size_t dvmCountInstancesOfClass(const ClassObject *clazz)
+{
+    CountInstancesOfClassContext ctx = { clazz, 0 };
+    HeapBitmap *bitmap = dvmHeapSourceGetLiveBits();
+    dvmLockHeap();
+    dvmHeapBitmapWalk(bitmap, countInstancesOfClassCallback, &ctx);
+    dvmUnlockHeap();
+    return ctx.count;
+}
diff --git a/vm/alloc/Alloc.h b/vm/alloc/Alloc.h
index 4cb856c..aeed9c3 100644
--- a/vm/alloc/Alloc.h
+++ b/vm/alloc/Alloc.h
@@ -179,4 +179,9 @@
  */
 size_t dvmGetExternalBytesAllocated(void);
 
+/*
+ * Returns a count of the extant instances of a class.
+ */
+size_t dvmCountInstancesOfClass(const ClassObject *clazz);
+
 #endif /*_DALVIK_ALLOC_ALLOC*/
diff --git a/vm/alloc/Heap.c b/vm/alloc/Heap.c
index ba38300..b8f6288 100644
--- a/vm/alloc/Heap.c
+++ b/vm/alloc/Heap.c
@@ -950,36 +950,6 @@
     dvmChangeStatus(self, oldStatus);
 }
 
-typedef struct {
-    const ClassObject *clazz;
-    size_t count;
-} CountInstancesOfClassContext;
-
-static void countInstancesOfClassCallback(size_t numPtrs, void **ptrs,
-                                          const void *finger, void *arg)
-{
-    CountInstancesOfClassContext *ctx = arg;
-    size_t i;
-
-    assert(ctx != NULL);
-    for (i = 0; i < numPtrs; ++i) {
-        const Object *obj = ptrs[i];
-        if (obj->clazz == ctx->clazz) {
-            ctx->count += 1;
-        }
-    }
-}
-
-size_t dvmHeapCountInstancesOfClass(const ClassObject *clazz)
-{
-    CountInstancesOfClassContext ctx = { clazz, 0 };
-    HeapBitmap *bitmap = dvmHeapSourceGetLiveBits();
-    dvmLockHeap();
-    dvmHeapBitmapWalk(bitmap, countInstancesOfClassCallback, &ctx);
-    dvmUnlockHeap();
-    return ctx.count;
-}
-
 #if WITH_HPROF
 /*
  * Perform garbage collection, writing heap information to the specified file.
diff --git a/vm/alloc/Heap.h b/vm/alloc/Heap.h
index 903102c..ea0510f 100644
--- a/vm/alloc/Heap.h
+++ b/vm/alloc/Heap.h
@@ -89,9 +89,4 @@
  */
 void dvmWaitForConcurrentGcToComplete(void);
 
-/*
- * Returns a count of the extant instances of a class.
- */
-size_t dvmHeapCountInstancesOfClass(const ClassObject *clazz);
-
 #endif  // _DALVIK_ALLOC_HEAP
diff --git a/vm/native/dalvik_system_VMDebug.c b/vm/native/dalvik_system_VMDebug.c
index 6a2b8a4..60086e6 100644
--- a/vm/native/dalvik_system_VMDebug.c
+++ b/vm/native/dalvik_system_VMDebug.c
@@ -942,7 +942,7 @@
     if (clazz == NULL) {
         RETURN_LONG(0);
     } else {
-        size_t count = dvmHeapCountInstancesOfClass(clazz);
+        size_t count = dvmCountInstancesOfClass(clazz);
         RETURN_LONG((long long)count);
     }
 }