[MLton-commit] r6607

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


Share code for releasing current card/cross map.

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

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

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

Modified: mlton/trunk/runtime/gc/done.c
===================================================================
--- mlton/trunk/runtime/gc/done.c	2008-04-23 00:23:05 UTC (rev 6606)
+++ mlton/trunk/runtime/gc/done.c	2008-04-23 00:23:08 UTC (rev 6607)
@@ -93,11 +93,5 @@
   }
   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);
-  }
+  releaseCardMapAndCrossMap (s);
 }

Modified: mlton/trunk/runtime/gc/generational.c
===================================================================
--- mlton/trunk/runtime/gc/generational.c	2008-04-23 00:23:05 UTC (rev 6606)
+++ mlton/trunk/runtime/gc/generational.c	2008-04-23 00:23:08 UTC (rev 6607)
@@ -165,11 +165,11 @@
   clearCrossMap (s);
 }
 
-void releaseCardMapAndCrossMap (GC_state s,
-                                GC_cardMap cardMap,
-                                size_t cardMapSize,
-                                __attribute__ ((unused)) GC_crossMap crossMap,
-                                size_t crossMapSize) {
+void releaseCardMapAndCrossMapAux (GC_state s,
+                                   GC_cardMap cardMap,
+                                   size_t cardMapSize,
+                                   __attribute__ ((unused)) GC_crossMap crossMap,
+                                   size_t crossMapSize) {
 
   size_t totalMapSize;
 
@@ -183,6 +183,22 @@
   GC_release (cardMap, totalMapSize);
 }
 
+void releaseCardMapAndCrossMap (GC_state s) {
+  unless (s->mutatorMarksCards)
+    return;
+
+  GC_cardMap cardMap;
+  size_t cardMapSize;
+  GC_crossMap crossMap;
+  size_t crossMapSize;
+
+  cardMap = s->generationalMaps.cardMap;
+  cardMapSize = s->generationalMaps.cardMapLength * CARD_MAP_ELEM_SIZE;
+  crossMap = s->generationalMaps.crossMap;
+  crossMapSize = s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE;
+  releaseCardMapAndCrossMapAux (s, cardMap, cardMapSize, crossMap, crossMapSize);
+}
+
 void resizeCardMapAndCrossMap (GC_state s) {
   if (s->mutatorMarksCards
       and (s->generationalMaps.cardMapLength * CARD_MAP_ELEM_SIZE)
@@ -200,7 +216,9 @@
     GC_memcpy ((pointer)oldCrossMap, (pointer)s->generationalMaps.crossMap,
                min (s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE,
                     oldCrossMapSize));
-    releaseCardMapAndCrossMap (s, oldCardMap, oldCardMapSize, oldCrossMap, oldCrossMapSize);
+    releaseCardMapAndCrossMapAux (s,
+                                  oldCardMap, oldCardMapSize,
+                                  oldCrossMap, oldCrossMapSize);
   }
 }
 

Modified: mlton/trunk/runtime/gc/generational.h
===================================================================
--- mlton/trunk/runtime/gc/generational.h	2008-04-23 00:23:05 UTC (rev 6606)
+++ mlton/trunk/runtime/gc/generational.h	2008-04-23 00:23:08 UTC (rev 6607)
@@ -77,9 +77,10 @@
 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 releaseCardMapAndCrossMap (GC_state s);
+static void releaseCardMapAndCrossMapAux (GC_state s,
+                                          GC_cardMap cardMap, size_t cardMapSize,
+                                          GC_crossMap crossMap, size_t crossMapSize);
 static void resizeCardMapAndCrossMap (GC_state s);
 
 #if ASSERT

Modified: mlton/trunk/runtime/gc/heap.c
===================================================================
--- mlton/trunk/runtime/gc/heap.c	2008-04-23 00:23:05 UTC (rev 6606)
+++ mlton/trunk/runtime/gc/heap.c	2008-04-23 00:23:08 UTC (rev 6607)
@@ -351,13 +351,7 @@
     }
     data = GC_diskBack_write (orig, size);
     releaseHeap (s, curHeapp);
-    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);
-    }
+    releaseCardMapAndCrossMap (s);
     if (createHeap (s, curHeapp, desiredSize, minSize)) {
       if (DEBUG or s->controls.messages) {
         fprintf (stderr,




More information about the MLton-commit mailing list