[MLton-commit] r6602

Matthew Fluet fluet at mlton.org
Tue Apr 22 17:22:52 PDT 2008


GC messages for creating/releasing card/cross map.

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

U   mlton/trunk/runtime/gc/done.c
U   mlton/trunk/runtime/gc/generational.c
U   mlton/trunk/runtime/gc/generational.h

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

Modified: mlton/trunk/runtime/gc/done.c
===================================================================
--- mlton/trunk/runtime/gc/done.c	2008-04-22 16:42:27 UTC (rev 6601)
+++ mlton/trunk/runtime/gc/done.c	2008-04-23 00:22:51 UTC (rev 6602)
@@ -93,4 +93,11 @@
   }
   releaseHeap (s, &s->heap);
   releaseHeap (s, &s->secondaryHeap);
+  if (s->mutatorMarksCards) {
+    releaseCardMapAndCrossMap (s,
+                               s->generationalMaps.cardMap,
+                               s->generationalMaps.cardMapLength * CARD_MAP_ELEM_SIZE,
+                               s->generationalMaps.crossMap,
+                               s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE);
+  }
 }

Modified: mlton/trunk/runtime/gc/generational.c
===================================================================
--- mlton/trunk/runtime/gc/generational.c	2008-04-22 16:42:27 UTC (rev 6601)
+++ mlton/trunk/runtime/gc/generational.c	2008-04-23 00:22:51 UTC (rev 6602)
@@ -147,13 +147,15 @@
   s->generationalMaps.crossMapLength = crossMapLength;
 
   totalMapSize = cardMapSize + crossMapSize;
-  if (DEBUG_MEM)
-    fprintf (stderr, "Creating card/cross map of size %s\n",
-             uintmaxToCommaString(totalMapSize));
   s->generationalMaps.cardMap =
     GC_mmapAnon_safe (NULL, totalMapSize);
   s->generationalMaps.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,
@@ -163,6 +165,24 @@
   clearCrossMap (s);
 }
 
+void releaseCardMapAndCrossMap (GC_state s,
+                                GC_cardMap cardMap,
+                                size_t cardMapSize,
+                                __attribute__ ((unused)) GC_crossMap crossMap,
+                                size_t crossMapSize) {
+
+  size_t totalMapSize;
+
+  assert (crossMap == cardMap + (cardMapSize / CARD_MAP_ELEM_SIZE));
+  totalMapSize = cardMapSize + crossMapSize;
+  if (DEBUG_MEM or s->controls.messages)
+    fprintf (stderr,
+             "[GC: Releasing card/cross map at "FMTPTR" of size %s bytes.]\n",
+             (uintptr_t)cardMap,
+             uintmaxToCommaString(totalMapSize));
+  GC_release (cardMap, totalMapSize);
+}
+
 void resizeCardMapAndCrossMap (GC_state s) {
   if (s->mutatorMarksCards
       and (s->generationalMaps.cardMapLength * CARD_MAP_ELEM_SIZE)
@@ -180,9 +200,7 @@
     GC_memcpy ((pointer)oldCrossMap, (pointer)s->generationalMaps.crossMap,
                min (s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE,
                     oldCrossMapSize));
-    if (DEBUG_MEM)
-      fprintf (stderr, "Releasing card/cross map.\n");
-    GC_release (oldCardMap, oldCardMapSize + oldCrossMapSize);
+    releaseCardMapAndCrossMap (s, oldCardMap, oldCardMapSize, oldCrossMap, oldCrossMapSize);
   }
 }
 

Modified: mlton/trunk/runtime/gc/generational.h
===================================================================
--- mlton/trunk/runtime/gc/generational.h	2008-04-22 16:42:27 UTC (rev 6601)
+++ mlton/trunk/runtime/gc/generational.h	2008-04-23 00:22:51 UTC (rev 6602)
@@ -77,6 +77,9 @@
 static inline void clearCardMap (GC_state s);
 static inline void clearCrossMap (GC_state s);
 static void createCardMapAndCrossMap (GC_state s);
+static void releaseCardMapAndCrossMap (GC_state s,
+                                       GC_cardMap cardMap, size_t cardMapSize,
+                                       GC_crossMap crossMap, size_t crossMapSize);
 static void resizeCardMapAndCrossMap (GC_state s);
 
 #if ASSERT




More information about the MLton-commit mailing list