[MLton-commit] r6776

Matthew Fluet fluet at mlton.org
Tue Aug 19 17:43:49 PDT 2008


Simplifying card/cross map in heap.

The insight is that the old resizeCardMapAndCrossMap function was a
bit misleading, because it copies the contents of the old cross map to
the new cross map.  However, the resizeCardMapAndCrossMap function is
only ever called in the resizeHeap function, which, in turn, is only
ever called in the majorGC function and the GC_unpack function.

After a major GC, the cross map must be cleared, because the major GC
will have collected objects in the old generation, making the cross
map invalid.  So, when resizing the heap (and, hence, resizing or
moving the card/cross maps) after a major collection, it suffices to
clear the resulting cross map, rather than clearing the cross map and
then copying the cleared cross map to its new location.

It seems safe to assume that major garbage collections will be much
more frequent than GC_unpack, so it makes sense to simplify the code
for the common case.

This commit allocates space at the end of the ML object heap for the
card and cross maps.

After creating, swapping, or resizing the heap, it uses
setCardMapAndCrossMap to set gcState.generationalMaps appropriately
(according to gcState.heap.start and gcState.heap.size) and clear the
card and cross maps.  There is no complicated copying of card and
cross maps when heaps are resized.

The only downside is that at a GC_unpack, after resizing the heap
after a minor collection, we clear the cross map and, thus, are forced
to recompute the cross map at the next minor collection.  (Note,
however, that because the runtime does not always use generational
collection, there may in fact have been no valid data in the cross map
and there may be no minor collection before the next major
collection.)
----------------------------------------------------------------------

U   mlton/trunk/runtime/gc/cheney-copy.c
U   mlton/trunk/runtime/gc/garbage-collection.c
U   mlton/trunk/runtime/gc/generational.c
U   mlton/trunk/runtime/gc/generational.h
U   mlton/trunk/runtime/gc/heap.c
U   mlton/trunk/runtime/gc/heap.h
U   mlton/trunk/runtime/gc/init-world.c
U   mlton/trunk/runtime/gc/mark-compact.c
U   mlton/trunk/runtime/gc/pack.c
U   mlton/trunk/runtime/gc/world.c
U   mlton/trunk/runtime/gc.h

----------------------------------------------------------------------

Modified: mlton/trunk/runtime/gc/cheney-copy.c
===================================================================
--- mlton/trunk/runtime/gc/cheney-copy.c	2008-08-20 00:43:42 UTC (rev 6775)
+++ mlton/trunk/runtime/gc/cheney-copy.c	2008-08-20 00:43:47 UTC (rev 6776)
@@ -39,11 +39,10 @@
 void swapHeapsForCheneyCopy (GC_state s) {
   struct GC_heap tempHeap;
 
-  copyCardMapAndCrossMap (s, &s->secondaryHeap);
   tempHeap = s->secondaryHeap;
   s->secondaryHeap = s->heap;
   s->heap = tempHeap;
-  setCardMapAbsolute (s);
+  setCardMapAndCrossMap (s);
 }
 
 void majorCheneyCopyGC (GC_state s) {
@@ -86,7 +85,6 @@
   bytesCopied = s->secondaryHeap.oldGenSize;
   s->cumulativeStatistics.bytesCopied += bytesCopied;
   swapHeapsForCheneyCopy (s);
-  clearCrossMap (s);
   s->lastMajorStatistics.kind = GC_COPYING;
   if (detailedGCTime (s))
     stopTiming (&ru_start, &s->cumulativeStatistics.ru_gcCopying);

Modified: mlton/trunk/runtime/gc/garbage-collection.c
===================================================================
--- mlton/trunk/runtime/gc/garbage-collection.c	2008-08-20 00:43:42 UTC (rev 6775)
+++ mlton/trunk/runtime/gc/garbage-collection.c	2008-08-20 00:43:47 UTC (rev 6776)
@@ -41,8 +41,10 @@
    * argument to createHeapSecondary above.  Above, it was an
    * estimate.  Here, it is exactly how much was live after the GC.
    */
-  if (mayResize)
+  if (mayResize) {
     resizeHeap (s, s->lastMajorStatistics.bytesLive + bytesRequested);
+    setCardMapAndCrossMap (s);
+  }
   resizeHeapSecondary (s);
   assert (s->heap.oldGenSize + bytesRequested <= s->heap.size);
 }

Modified: mlton/trunk/runtime/gc/generational.c
===================================================================
--- mlton/trunk/runtime/gc/generational.c	2008-08-20 00:43:42 UTC (rev 6775)
+++ mlton/trunk/runtime/gc/generational.c	2008-08-20 00:43:47 UTC (rev 6776)
@@ -175,6 +175,11 @@
           s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE);
 }
 
+void clearCardMapAndCrossMap (GC_state s) {
+  clearCardMap (s);
+  clearCrossMap (s);
+}
+
 size_t sizeofCardMapAndCrossMap (GC_state s, size_t heapSize) {
   size_t totalMapSize;
 
@@ -185,7 +190,7 @@
   return totalMapSize;
 }
 
-static inline void initCardMapAndCrossMap (GC_state s, GC_heap h, size_t size) {
+void setCardMapAndCrossMap (GC_state s) {
   unless (s->mutatorMarksCards) {
     s->generationalMaps.cardMapLength = 0;
     s->generationalMaps.cardMap = NULL;
@@ -194,141 +199,30 @@
     s->generationalMaps.crossMap = NULL;
     return;
   }
-  assert (isAligned (size, CARD_SIZE));
 
   GC_cardMapIndex cardMapLength;
   size_t cardMapSize;
   GC_crossMapIndex crossMapLength;
   size_t crossMapSize;
-  size_t totalMapSize;
 
-  cardMapLength = sizeToCardMapIndex (size);
-  cardMapSize = align (cardMapLength * CARD_MAP_ELEM_SIZE, s->sysvals.pageSize);
-  cardMapLength = (GC_cardMapIndex)(cardMapSize / CARD_MAP_ELEM_SIZE);
+  cardMapSize = sizeofCardMap (s, s->heap.size);
+  cardMapLength = lenofCardMap (s, cardMapSize);
   s->generationalMaps.cardMapLength = cardMapLength;
 
-  crossMapLength = sizeToCardMapIndex (size);
-  crossMapSize = align (crossMapLength * CROSS_MAP_ELEM_SIZE, s->sysvals.pageSize);
-  crossMapLength = (GC_crossMapIndex)(crossMapSize / CROSS_MAP_ELEM_SIZE);
+  crossMapSize = sizeofCrossMap (s, s->heap.size);
+  crossMapLength = lenofCrossMap (s, crossMapSize);
   s->generationalMaps.crossMapLength = crossMapLength;
 
-  totalMapSize = cardMapSize + crossMapSize;
   /* The card map starts at the end of the heap. */
+  assert (s->heap.withMapsSize == s->heap.size + cardMapSize + crossMapSize);
   s->generationalMaps.cardMap =
-    (GC_cardMap) (h->start + size);
+    (GC_cardMap) (s->heap.start + s->heap.size);
   s->generationalMaps.crossMap =
-    (GC_crossMap) (s->generationalMaps.cardMap + (cardMapSize / CARD_MAP_ELEM_SIZE));
-  if (DEBUG_MEM or s->controls.messages)
-    fprintf (stderr,
-             "[GC: Created card/cross map at "FMTPTR" of size %s bytes.]\n",
-             (uintptr_t)(s->generationalMaps.cardMap),
-             uintmaxToCommaString(totalMapSize));
-  if (DEBUG_CARD_MARKING)
-    fprintf (stderr, "cardMap = "FMTPTR"  crossMap = "FMTPTR"\n",
-             (uintptr_t)s->generationalMaps.cardMap,
-             (uintptr_t)s->generationalMaps.crossMap);
+    (GC_crossMap) (s->heap.start + s->heap.size + cardMapSize);
   setCardMapAbsolute (s);
+  clearCardMapAndCrossMap (s);
 }
 
-void createCardMapAndCrossMap (GC_state s) {
-  initCardMapAndCrossMap (s, &s->heap, s->heap.size);
-  if (s->mutatorMarksCards) {
-    clearCardMap (s);
-    clearCrossMap (s);
-  }
-}
-
-/* This function is called before the given heap becomes the new current heap
-   used to store the program datas.
-   The 2 heaps can have a different size. */
-void copyCardMapAndCrossMap (GC_state s, GC_heap h) {
-  if (s->mutatorMarksCards) {
-    GC_cardMap oldCardMap;
-    size_t oldCardMapSize;
-    GC_crossMap oldCrossMap;
-    size_t oldCrossMapSize;
-
-    oldCardMap = s->generationalMaps.cardMap;
-    oldCardMapSize = s->generationalMaps.cardMapLength * CARD_MAP_ELEM_SIZE;
-    oldCrossMap = s->generationalMaps.crossMap;
-    oldCrossMapSize = s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE;
-
-    initCardMapAndCrossMap (s, h, h->size);
-
-    clearCardMap (s);
-    GC_memcpy ((pointer)oldCardMap, (pointer)s->generationalMaps.cardMap,
-               min (s->generationalMaps.cardMapLength * CARD_MAP_ELEM_SIZE,
-                    oldCardMapSize));
-    clearCrossMap (s);
-    GC_memcpy ((pointer)oldCrossMap, (pointer)s->generationalMaps.crossMap,
-               min (s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE,
-                    oldCrossMapSize));
-  }
-}
-
-/* This function is called before we shrink the heap buffer which contains the
-   card/cross map datas. */
-void shrinkCardMapAndCrossMap (GC_state s, size_t keep) {
-  if (s->mutatorMarksCards) {
-    GC_crossMap oldCrossMap;
-
-    oldCrossMap = s->generationalMaps.crossMap;
-
-    initCardMapAndCrossMap (s, &s->heap, keep);
-
-    GC_memmove ((pointer)oldCrossMap, (pointer)s->generationalMaps.crossMap,
-                s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE);
-    clearCardMap (s);
-  }
-}
-
-/* This function is called after we remap the heap buffer which contains the
-   card/cross map datas.
-   The remapped heap must be bigger than the original one. */
-void remapCardMapAndCrossMap (GC_state s, pointer orig) {
-  if (s->mutatorMarksCards) {
-    GC_cardMap oldCardMap;
-    size_t oldCardMapSize;
-    GC_crossMap oldCrossMap;
-    size_t oldCrossMapSize;
-
-    oldCardMap = (GC_cardMap) ((pointer) s->generationalMaps.cardMap + (s->heap.start - orig));
-    oldCardMapSize = s->generationalMaps.cardMapLength * CARD_MAP_ELEM_SIZE;
-    oldCrossMap = (GC_crossMap) (oldCardMap + (oldCardMapSize / CARD_MAP_ELEM_SIZE));
-    oldCrossMapSize = s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE;
-
-    initCardMapAndCrossMap (s, &s->heap, s->heap.size);
-
-    if (DEBUG_MEM or s->controls.messages) {
-      fprintf (stderr, "[GC: oldCardMap = "FMTPTR"  oldCrossMap = "FMTPTR"]\n",
-               (uintptr_t)oldCardMap,
-               (uintptr_t)oldCrossMap);
-      fprintf (stderr,
-               "[GC: oldCardMapSize = %s bytes  oldCrossMapSize = %s bytes]\n",
-               uintmaxToCommaString(oldCardMapSize), uintmaxToCommaString(oldCrossMapSize));
-      fprintf (stderr, "[GC: cardMap = "FMTPTR"  crossMap = "FMTPTR"]\n",
-               (uintptr_t)s->generationalMaps.cardMap,
-               (uintptr_t)s->generationalMaps.crossMap);
-    }
-    GC_memmove ((pointer)oldCrossMap, (pointer)s->generationalMaps.crossMap,
-                oldCrossMapSize);
-    if (DEBUG_MEM or s->controls.messages) {
-      fprintf (stderr,
-               "[GC: crossMapSize = %s bytes]\n",
-               uintmaxToCommaString(s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE));
-    }
-    memset((pointer)s->generationalMaps.crossMap + oldCrossMapSize, CROSS_MAP_EMPTY,
-           s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE - oldCrossMapSize);
-    if (DEBUG_MEM or s->controls.messages) {
-      fprintf(stderr, "[GC: cross map OK]\n");
-    }
-    clearCardMap (s);
-    if (DEBUG_MEM or s->controls.messages) {
-      fprintf(stderr, "[GC: card map OK]\n");
-    }
-  }
-}
-
 #if ASSERT
 /* isCrossMapOk is a slower, but easier to understand, way of
  * computing the crossMap.  updateCrossMap (below) incrementally

Modified: mlton/trunk/runtime/gc/generational.h
===================================================================
--- mlton/trunk/runtime/gc/generational.h	2008-08-20 00:43:42 UTC (rev 6775)
+++ mlton/trunk/runtime/gc/generational.h	2008-08-20 00:43:47 UTC (rev 6776)
@@ -84,10 +84,8 @@
 
 static inline void clearCardMap (GC_state s);
 static inline void clearCrossMap (GC_state s);
-static void createCardMapAndCrossMap (GC_state s);
-static void copyCardMapAndCrossMap (GC_state s, GC_heap h);
-static void shrinkCardMapAndCrossMap (GC_state s, size_t keep);
-static void remapCardMapAndCrossMap (GC_state s, pointer orig);
+static inline void clearCardMapAndCrossMap (GC_state s);
+static void setCardMapAndCrossMap (GC_state s);
 
 #if ASSERT
 static bool isCrossMapOk (GC_state s);

Modified: mlton/trunk/runtime/gc/heap.c
===================================================================
--- mlton/trunk/runtime/gc/heap.c	2008-08-20 00:43:42 UTC (rev 6775)
+++ mlton/trunk/runtime/gc/heap.c	2008-08-20 00:43:47 UTC (rev 6776)
@@ -12,11 +12,13 @@
           "\t\tnursery = "FMTPTR"\n"
           "\t\toldGenSize = %"PRIuMAX"\n"
           "\t\tsize = %"PRIuMAX"\n"
-          "\t\tstart = "FMTPTR"\n",
+          "\t\tstart = "FMTPTR"\n"
+          "\t\twithMapsSize = %"PRIuMAX"\n",
           (uintptr_t)heap->nursery,
           (uintmax_t)heap->oldGenSize,
           (uintmax_t)heap->size,
-          (uintptr_t)heap->start);
+          (uintptr_t)heap->start,
+          (uintmax_t)heap->withMapsSize);
 }
 
 
@@ -26,6 +28,7 @@
   h->oldGenSize = 0;
   h->size = 0;
   h->start = NULL;
+  h->withMapsSize = 0;
 }
 
 /* sizeofHeapDesired (s, l, cs)
@@ -114,30 +117,32 @@
              "[GC: Releasing heap at "FMTPTR" of size %s bytes.]\n",
              (uintptr_t)(h->start),
              uintmaxToCommaString(h->size));
-  GC_release (h->start, h->size + sizeofCardMapAndCrossMap (s, h->size));
+  GC_release (h->start, h->withMapsSize);
   initHeap (s, h);
 }
 
-void shrinkHeap (GC_state s, GC_heap h, size_t keep) {
-  assert (keep <= h->size);
-  if (0 == keep) {
+/* shrinkHeap (s, h, keepSize)
+ */
+void shrinkHeap (GC_state s, GC_heap h, size_t keepSize) {
+  assert (keepSize <= h->size);
+  if (0 == keepSize) {
     releaseHeap (s, h);
     return;
   }
-  keep = align (keep, s->sysvals.pageSize);
-  if (keep < h->size) {
-    size_t oldMapSize, newMapSize;
+  keepSize = align (keepSize, s->sysvals.pageSize);
+  if (keepSize < h->size) {
+    size_t keepWithMapsSize;
     if (DEBUG or s->controls.messages)
       fprintf (stderr,
                "[GC: Shrinking heap at "FMTPTR" of size %s bytes to size %s bytes.]\n",
                (uintptr_t)(h->start),
                uintmaxToCommaString(h->size),
-               uintmaxToCommaString(keep));
-    shrinkCardMapAndCrossMap (s, keep);
-    oldMapSize = sizeofCardMapAndCrossMap (s, h->size);
-    newMapSize = sizeofCardMapAndCrossMap (s, keep);
-    GC_decommit (h->start + keep + newMapSize, h->size - keep + oldMapSize - newMapSize);
-    h->size = keep;
+               uintmaxToCommaString(keepSize));
+    keepWithMapsSize = keepSize + sizeofCardMapAndCrossMap (s, keepSize);
+    assert (keepWithMapsSize <= h->withMapsSize);
+    GC_decommit (h->start + keepWithMapsSize, h->withMapsSize - keepWithMapsSize);
+    h->size = keepSize;
+    h->withMapsSize = keepWithMapsSize;
   }
 }
 
@@ -208,6 +213,7 @@
         direction = not direction;
         h->start = newStart;
         h->size = newSize;
+        h->withMapsSize = newWithMapsSize;
         if (h->size > s->cumulativeStatistics.maxHeapSize)
           s->cumulativeStatistics.maxHeapSize = h->size;
         assert (minSize <= h->size and h->size <= desiredSize);
@@ -289,6 +295,7 @@
     unless ((void*)-1 == newStart) {
       h->start = newStart;
       h->size = newSize;
+      h->withMapsSize = newWithMapsSize;
       if (h->size > s->cumulativeStatistics.maxHeapSize)
         s->cumulativeStatistics.maxHeapSize = h->size;
       assert (minSize <= h->size and h->size <= desiredSize);
@@ -328,12 +335,11 @@
   GC_heap curHeapp;
   struct GC_heap newHeap;
 
-  pointer orig;
+  pointer origStart;
   size_t size;
 
   assert (desiredSize >= s->heap.size);
-  /* Now the card/cross map is stored at the end of the heap buffer, make sure we
-     won't actually shrink the heap. */
+  /* If desiredSize >= s->heap.size, then don't shrink the heap. */
   if (minSize < s->heap.size)
     minSize = s->heap.size;
   if (DEBUG_RESIZING or s->controls.messages) {
@@ -347,11 +353,10 @@
              uintmaxToCommaString(minSize));
   }
   curHeapp = &s->heap;
-  orig = curHeapp->start;
+  origStart = curHeapp->start;
   size = curHeapp->oldGenSize;
   assert (size <= s->heap.size);
   if (remapHeap (s, curHeapp, desiredSize, minSize)) {
-    remapCardMapAndCrossMap (s, orig);
     goto done;
   }
   shrinkHeap (s, curHeapp, size);
@@ -365,24 +370,20 @@
     from = curHeapp->start + size;
     to = newHeap.start + size;
     remaining = size;
-    copyCardMapAndCrossMap(s, &newHeap);
-    GC_decommit(orig + curHeapp->size, sizeofCardMapAndCrossMap (s, curHeapp->size));
+    GC_decommit (origStart + curHeapp->size, sizeofCardMapAndCrossMap (s, curHeapp->size));
 copy:
     assert (remaining == (size_t)(from - curHeapp->start)
             and from >= curHeapp->start
             and to >= newHeap.start);
     if (remaining < COPY_CHUNK_SIZE) {
-      GC_memcpy (orig, newHeap.start, remaining);
-      GC_release (orig, curHeapp->size);
+      GC_memcpy (origStart, newHeap.start, remaining);
+      GC_release (origStart, curHeapp->size);
     } else {
-      size_t keep;
       remaining -= COPY_CHUNK_SIZE;
       from -= COPY_CHUNK_SIZE;
       to -= COPY_CHUNK_SIZE;
       GC_memcpy (from, to, COPY_CHUNK_SIZE);
-      keep = align (remaining, s->sysvals.pageSize);
-      GC_decommit (orig + keep, (size_t)(curHeapp->size - keep));
-      curHeapp->size = keep;
+      shrinkHeap (s, curHeapp, remaining);
       goto copy;
     }
     newHeap.oldGenSize = size;
@@ -394,25 +395,21 @@
     if (DEBUG or s->controls.messages) {
       fprintf (stderr,
                "[GC: Writing heap at "FMTPTR" of size %s bytes to disk.]\n",
-               (uintptr_t)orig,
+               (uintptr_t)origStart,
                uintmaxToCommaString(size));
     }
-    data = GC_diskBack_write (orig, size);
+    data = GC_diskBack_write (origStart, size);
     releaseHeap (s, curHeapp);
     if (createHeap (s, curHeapp, desiredSize, minSize)) {
       if (DEBUG or s->controls.messages) {
         fprintf (stderr,
-                 "[GC: Reading heap at "FMTPTR" of size %s bytes from disk.]\n",
-                 (uintptr_t)orig,
+                 "[GC: Reading heap to "FMTPTR" of size %s bytes from disk.]\n",
+                 (uintptr_t)(curHeapp->start),
                  uintmaxToCommaString(size));
       }
       GC_diskBack_read (data, curHeapp->start, size);
       GC_diskBack_close (data);
       curHeapp->oldGenSize = size;
-      if (s->mutatorMarksCards) {
-        createCardMapAndCrossMap (s);
-        updateCrossMap (s);
-      }
     } else {
       GC_diskBack_close (data);
       if (s->controls.messages)
@@ -427,9 +424,8 @@
          uintmaxToCommaString(minSize));
   }
 done:
-  unless (orig == s->heap.start) {
-    translateHeap (s, orig, s->heap.start, s->heap.oldGenSize);
-    setCardMapAbsolute (s);
+  unless (origStart == s->heap.start) {
+    translateHeap (s, origStart, s->heap.start, s->heap.oldGenSize);
   }
 }
 

Modified: mlton/trunk/runtime/gc/heap.h
===================================================================
--- mlton/trunk/runtime/gc/heap.h	2008-08-20 00:43:42 UTC (rev 6775)
+++ mlton/trunk/runtime/gc/heap.h	2008-08-20 00:43:47 UTC (rev 6776)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
+/* Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-2000 NEC Research Institute.
  *
@@ -12,13 +12,14 @@
  * All ML objects (including ML execution stacks) are allocated in a
  * contiguous heap.  The heap has the following general layout:
  * 
- *  ----------------------------------------------------
- *  |    old generation    |               |  nursery  |
- *  ----------------------------------------------------
+ *  -------------------------------------------------------------------------
+ *  |    old generation    |               |  nursery  | cardMap | crossMap |
+ *  -------------------------------------------------------------------------
  *  |------oldGenSize------|
  *  |-----------------------size-----------------------|
  *  ^                                      ^
  *  start                                  nursery
+ *  |------------------------------withMapsSize-----------------------------|
 */
 
 typedef struct GC_heap {
@@ -26,6 +27,7 @@
   size_t oldGenSize; /* size of old generation */
   size_t size; /* size of heap */
   pointer start; /* start of heap (and old generation) */
+  size_t withMapsSize; /* size of heap with card/cross maps */
 } *GC_heap;
 
 #define GC_HEAP_LIMIT_SLOP 512
@@ -51,7 +53,7 @@
 static inline size_t sizeofHeapDesired (GC_state s, size_t live, size_t currentSize);
 
 static inline void releaseHeap (GC_state s, GC_heap h);
-static void shrinkHeap (GC_state s, GC_heap h, size_t keep);
+static void shrinkHeap (GC_state s, GC_heap h, size_t keepSize);
 static bool createHeap (GC_state s, GC_heap h, size_t desiredSize, size_t minSize);
 static bool createHeapSecondary (GC_state s, size_t desiredSize);
 static bool remapHeap (GC_state s, GC_heap h, size_t desiredSize, size_t minSize);

Modified: mlton/trunk/runtime/gc/init-world.c
===================================================================
--- mlton/trunk/runtime/gc/init-world.c	2008-08-20 00:43:42 UTC (rev 6775)
+++ mlton/trunk/runtime/gc/init-world.c	2008-08-20 00:43:47 UTC (rev 6776)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
+/* Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-2000 NEC Research Institute.
  *
@@ -144,7 +144,7 @@
   createHeap (s, &s->heap,
               sizeofHeapDesired (s, s->lastMajorStatistics.bytesLive, 0),
               s->lastMajorStatistics.bytesLive);
-  createCardMapAndCrossMap (s);
+  setCardMapAndCrossMap (s);
   start = alignFrontier (s, s->heap.start);
   s->frontier = start;
   s->limitPlusSlop = s->heap.start + s->heap.size;

Modified: mlton/trunk/runtime/gc/mark-compact.c
===================================================================
--- mlton/trunk/runtime/gc/mark-compact.c	2008-08-20 00:43:42 UTC (rev 6775)
+++ mlton/trunk/runtime/gc/mark-compact.c	2008-08-20 00:43:47 UTC (rev 6776)
@@ -391,7 +391,6 @@
   foreachGlobalObjptr (s, threadInternalObjptr);
   updateForwardPointersForMarkCompact (s, currentStack);
   updateBackwardPointersAndSlideForMarkCompact (s, currentStack);
-  clearCrossMap (s);
   bytesHashConsed = s->lastMajorStatistics.bytesHashConsed;
   s->cumulativeStatistics.bytesHashConsed += bytesHashConsed;
   bytesMarkCompacted = s->heap.oldGenSize;

Modified: mlton/trunk/runtime/gc/pack.c
===================================================================
--- mlton/trunk/runtime/gc/pack.c	2008-08-20 00:43:42 UTC (rev 6775)
+++ mlton/trunk/runtime/gc/pack.c	2008-08-20 00:43:47 UTC (rev 6776)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
+/* Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-2000 NEC Research Institute.
  *
@@ -23,6 +23,7 @@
   keep = s->heap.oldGenSize * 1.1;
   if (keep <= s->heap.size) {
     shrinkHeap (s, &s->heap, keep);
+    setCardMapAndCrossMap (s);
     setGCStateCurrentHeap (s, 0, 0);
     setGCStateCurrentThreadAndStack (s);
   }
@@ -49,6 +50,7 @@
   enterGC (s);
   minorGC (s);
   resizeHeap (s, s->heap.oldGenSize);
+  setCardMapAndCrossMap (s);
   resizeHeapSecondary (s);
   setGCStateCurrentHeap (s, 0, 0);
   setGCStateCurrentThreadAndStack (s);

Modified: mlton/trunk/runtime/gc/world.c
===================================================================
--- mlton/trunk/runtime/gc/world.c	2008-08-20 00:43:42 UTC (rev 6775)
+++ mlton/trunk/runtime/gc/world.c	2008-08-20 00:43:47 UTC (rev 6776)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
+/* Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-2000 NEC Research Institute.
  *
@@ -25,7 +25,7 @@
   createHeap (s, &s->heap,
               sizeofHeapDesired (s, s->heap.oldGenSize, 0),
               s->heap.oldGenSize);
-  createCardMapAndCrossMap (s);
+  setCardMapAndCrossMap (s);
   fread_safe (s->heap.start, 1, s->heap.oldGenSize, f);
   if ((*(s->loadGlobals)) (f) != 0) diee("couldn't load globals");
   // unless (EOF == fgetc (file))

Modified: mlton/trunk/runtime/gc.h
===================================================================
--- mlton/trunk/runtime/gc.h	2008-08-20 00:43:42 UTC (rev 6775)
+++ mlton/trunk/runtime/gc.h	2008-08-20 00:43:47 UTC (rev 6776)
@@ -38,8 +38,8 @@
 #include "gc/int-inf.h"
 #include "gc/string.h"
 #include "gc/object-size.h"
+#include "gc/generational.h"
 #include "gc/heap.h"
-#include "gc/generational.h"
 #include "gc/current.h"
 #include "gc/foreach.h"
 #include "gc/translate.h"




More information about the MLton-commit mailing list