Use the break position of the current mspace for sizing the zygote heap.

Previously, the mspace footprint used the "overhead" of a heap which
underestimates the size of the zygote heap by 16 bytes, the specific
size of a descriptor deposited at the start of an mspace containing
the control information about that mspace.  If a heap is a multiple of
a page or within 15 bytes of it, the size of the new heap would be

Bad things happened when this underestimate was used to create an
application heap.  The starting address of the application heap was
based on a correctly computed value instead of the underestimate.
This caused the application heap to be one page to large and end one
page beyond where it should.  This additional page happened to overlap
the first page one of the heap bitmaps.  Furthermore, the mspace
routine would proceed access protect that page thinking it was unused
free space.  During the next GC reads to the first page of the bitmap
would generate a SIGSEGV.

By using the break position, correctly rounded, for all sizing
computations this problem no longer exists.

Change-Id: Icb3c82731e589747e8e4cf16d0797052e64b3ad5
diff --git a/vm/alloc/HeapSource.c b/vm/alloc/HeapSource.c
index 46b1c78..a18def5 100644
--- a/vm/alloc/HeapSource.c
+++ b/vm/alloc/HeapSource.c
@@ -377,7 +377,6 @@
 addNewHeap(HeapSource *hs, mspace msp, size_t mspAbsoluteMaxSize)
     Heap heap;
-    void *base;
     if (hs->numHeaps >= HEAP_SOURCE_MAX_HEAP_COUNT) {
         LOGE("Attempt to create too many heaps (%zd >= %zd)\n",
@@ -395,9 +394,11 @@
         heap.base = hs->heapBase;
         heap.limit = hs->heapBase + heap.absoluteMaxSize;
     } else {
-        size_t overhead;
+        void *sbrk0 = contiguous_mspace_sbrk0(hs->heaps[0].msp);
+        char *base = (char *)ALIGN_UP_TO_PAGE_SIZE(sbrk0);
+        size_t overhead = base - hs->heaps[0].base;
-        overhead = ALIGN_UP_TO_PAGE_SIZE(oldHeapOverhead(hs, true));
+        assert(((size_t)hs->heaps[0].base & (SYSTEM_PAGE_SIZE - 1)) == 0);
         if (overhead + HEAP_MIN_FREE >= hs->absoluteMaxSize) {
             LOGE_HEAP("No room to create any more heaps "
                     "(%zd overhead, %zd max)\n",
@@ -405,10 +406,8 @@
             return false;
         hs->heaps[0].absoluteMaxSize = overhead;
-        heap.absoluteMaxSize = hs->absoluteMaxSize - overhead;
-        base = contiguous_mspace_sbrk0(hs->heaps[0].msp);
         hs->heaps[0].limit = base;
-        base = (void *)ALIGN_UP_TO_PAGE_SIZE(base);
+        heap.absoluteMaxSize = hs->absoluteMaxSize - overhead;
         heap.msp = createMspace(base, HEAP_MIN_FREE, heap.absoluteMaxSize);
         heap.concurrentStartBytes = HEAP_MIN_FREE - CONCURRENT_START;
         heap.base = base;