Use the dvmAllocRegion instead of ashmem and mmap.

Also clean-up an uneeded include of ashmem.h from a similar commit in
the past.

Change-Id: Id86b89e72031406cfd2bf3d3a97f2d2327e090b6
diff --git a/vm/alloc/HeapBitmap.c b/vm/alloc/HeapBitmap.c
index d96d911..5ac28be 100644
--- a/vm/alloc/HeapBitmap.c
+++ b/vm/alloc/HeapBitmap.c
@@ -19,7 +19,6 @@
 #include "clz.h"
 #include <limits.h>     // for ULONG_MAX
 #include <sys/mman.h>   // for madvise(), mmap()
-#include <cutils/ashmem.h>
 
 #define LIKELY(exp)     (__builtin_expect((exp) != 0, true))
 #define UNLIKELY(exp)   (__builtin_expect((exp) != 0, false))
diff --git a/vm/alloc/MarkSweep.c b/vm/alloc/MarkSweep.c
index 4ab4514..1ead96c 100644
--- a/vm/alloc/MarkSweep.c
+++ b/vm/alloc/MarkSweep.c
@@ -23,7 +23,6 @@
 #include "alloc/Visit.h"
 #include <limits.h>     // for ULONG_MAX
 #include <sys/mman.h>   // for madvise(), mmap()
-#include <cutils/ashmem.h>
 #include <errno.h>
 
 #define GC_LOG_TAG      LOG_TAG "-gc"
@@ -57,8 +56,8 @@
 createMarkStack(GcMarkStack *stack)
 {
     const Object **limit;
+    const char *name;
     size_t size;
-    int fd, err;
 
     /* Create a stack big enough for the worst possible case,
      * where the heap is perfectly full of the smallest object.
@@ -68,27 +67,15 @@
     size = dvmHeapSourceGetIdealFootprint() * sizeof(Object*) /
             (sizeof(Object) + HEAP_SOURCE_CHUNK_OVERHEAD);
     size = ALIGN_UP_TO_PAGE_SIZE(size);
-    fd = ashmem_create_region("dalvik-heap-markstack", size);
-    if (fd < 0) {
-        LOGE_GC("Could not create %d-byte ashmem mark stack: %s\n",
-            size, strerror(errno));
+    name = "dalvik-mark-stack";
+    limit = dvmAllocRegion(size, PROT_READ | PROT_WRITE, name);
+    if (limit == NULL) {
+        LOGE_GC("Could not mmap %zd-byte ashmem region '%s'", size, name);
         return false;
     }
-    limit = (const Object **)mmap(NULL, size, PROT_READ | PROT_WRITE,
-            MAP_PRIVATE, fd, 0);
-    err = errno;
-    close(fd);
-    if (limit == MAP_FAILED) {
-        LOGE_GC("Could not mmap %d-byte ashmem mark stack: %s\n",
-            size, strerror(err));
-        return false;
-    }
-
-    memset(stack, 0, sizeof(*stack));
     stack->limit = limit;
     stack->base = (const Object **)((uintptr_t)limit + size);
     stack->top = stack->base;
-
     return true;
 }