[MLton-commit] r4109

Matthew Fluet MLton@mlton.org
Sun, 16 Oct 2005 15:05:05 -0700


translateHeap
----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/hash-cons.c
A   mlton/branches/on-20050822-x86_64-branch/runtime/gc/translate.c

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

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile	2005-10-16 01:46:06 UTC (rev 4108)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile	2005-10-16 22:05:00 UTC (rev 4109)
@@ -105,6 +105,7 @@
 	dfs-mark.c							\
 	share.c								\
 	mark-compact.c							\
+	translate.c							\
 	assumptions.c							\
 	gc_suffix.c
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c	2005-10-16 01:46:06 UTC (rev 4108)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/cheney-copy.c	2005-10-16 22:05:00 UTC (rev 4109)
@@ -38,7 +38,7 @@
   return pointerIsInToSpace (p);
 }
 
-static void forward (GC_state s, objptr *opp) {
+static void forwardObjptr (GC_state s, objptr *opp) {
   objptr op;
   pointer p;
   GC_header header;
@@ -47,7 +47,7 @@
   p = objptrToPointer (op, s->heap.start);
   if (DEBUG_DETAILED)
     fprintf (stderr,
-             "forward  opp = "FMTPTR"  op = "FMTOBJPTR"  p = "FMTPTR"\n",
+             "forwardObjptr  opp = "FMTPTR"  op = "FMTOBJPTR"  p = "FMTPTR"\n",
              (uintptr_t)opp, op, (uintptr_t)p);
   assert (objptrIsInFromSpace (s, *opp));
   header = getHeader (p);
@@ -213,8 +213,8 @@
   assert (s->secondaryHeap.size >= s->heap.oldGenSize);
   toStart = alignFrontier (s, s->secondaryHeap.start);
   forwardState.back = toStart;
-  foreachGlobalObjptr (s, forward);
-  foreachObjptrInRange (s, toStart, &forwardState.back, TRUE, forward);
+  foreachGlobalObjptr (s, forwardObjptr);
+  foreachObjptrInRange (s, toStart, &forwardState.back, TRUE, forwardObjptr);
   updateWeaks (s);
   s->secondaryHeap.oldGenSize = forwardState.back - s->secondaryHeap.start;
   s->cumulativeStatistics.bytesCopied += s->secondaryHeap.oldGenSize;
@@ -234,7 +234,7 @@
 /*                 Minor Cheney Copying Collection                  */
 /* ---------------------------------------------------------------- */
 
-static inline void forwardIfInNursery (GC_state s, objptr *opp) {
+static inline void forwardObjptrIfInNursery (GC_state s, objptr *opp) {
   objptr op;
   pointer p;
 
@@ -244,10 +244,10 @@
     return;
   if (DEBUG_GENERATIONAL)
     fprintf (stderr,
-             "forwardIfInNursery  opp = "FMTPTR"  op = "FMTOBJPTR"  p = "FMTPTR"\n",
+             "forwardObjptrIfInNursery  opp = "FMTPTR"  op = "FMTOBJPTR"  p = "FMTPTR"\n",
              (uintptr_t)opp, op, (uintptr_t)p);
   assert (s->heap.nursery <= p and p < s->limitPlusSlop);
-  forward (s, opp);
+  forwardObjptr (s, opp);
 }
 
 /* Walk through all the cards and forward all intergenerational pointers. */
@@ -312,7 +312,7 @@
      * weaks, since the weak pointer will never be into the nursery.
      */
     objectStart = foreachObjptrInRange (s, objectStart, &cardEnd, 
-                                        FALSE, forwardIfInNursery);
+                                        FALSE, forwardObjptrIfInNursery);
     s->cumulativeStatistics.minorBytesScanned += objectStart - lastObject;
     if (objectStart == oldGenEnd)
       goto done;
@@ -373,10 +373,10 @@
     /* Forward all globals.  Would like to avoid doing this once all
      * the globals have been assigned.
      */
-    foreachGlobalObjptr (s, forwardIfInNursery);
+    foreachGlobalObjptr (s, forwardObjptrIfInNursery);
     forwardInterGenerationalObjptrs (s);
     foreachObjptrInRange (s, forwardState.toStart, &forwardState.back, 
-                          TRUE, forwardIfInNursery);
+                          TRUE, forwardObjptrIfInNursery);
     updateWeaks (s);
     bytesCopied = forwardState.back - forwardState.toStart;
     s->cumulativeStatistics.bytesCopiedMinor += bytesCopied;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/hash-cons.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/hash-cons.c	2005-10-16 01:46:06 UTC (rev 4108)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/hash-cons.c	2005-10-16 22:05:00 UTC (rev 4109)
@@ -94,7 +94,8 @@
 }
 
 static inline pointer 
-tableInsert (GC_state s, GC_objectHashTable t, 
+tableInsert (__attribute__ ((unused)) GC_state s, 
+             GC_objectHashTable t, 
              GC_hash hash, pointer object,
              bool mightBeThere, GC_header header, GC_objectTypeTag tag, pointer max) {
   static bool init = FALSE;

Copied: mlton/branches/on-20050822-x86_64-branch/runtime/gc/translate.c (from rev 4108, mlton/branches/on-20050822-x86_64-branch/runtime/gc.c)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc.c	2005-10-16 01:46:06 UTC (rev 4108)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/translate.c	2005-10-16 22:05:00 UTC (rev 4109)
@@ -0,0 +1,47 @@
+/* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ * Copyright (C) 1997-2000 NEC Research Institute.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ */
+
+/* ---------------------------------------------------------------- */
+/*                          translateHeap                           */
+/* ---------------------------------------------------------------- */
+
+struct translateState {
+  pointer from;
+  pointer to;
+};
+static struct translateState translateState;
+
+static void translateObjptr (__attribute__ ((unused)) GC_state s, 
+                             objptr *opp) {
+  pointer p;
+
+  p = objptrToPointer (*opp, translateState.from);
+  p = (p - translateState.from) + translateState.to;
+  *opp = pointerToObjptr (p, translateState.to);
+}
+
+/* translateHeap (s, from, to, size)
+ */
+static void translateHeap (GC_state s, pointer from, pointer to, size_t size) {
+  pointer limit;
+
+  if (DEBUG or s->controls.messages)
+    fprintf (stderr, "Translating heap of size %zd from "FMTPTR" to "FMTPTR".\n",
+             /*uintToCommaString*/(size),
+             (uintptr_t)from, (uintptr_t)to);
+  if (from == to)
+    return;
+  else {
+    translateState.from = from;
+    translateState.to = to;
+  }
+  /* Translate globals and heap. */
+  foreachGlobalObjptr (s, translateObjptr);
+  limit = to + size;
+  foreachObjptrInRange (s, alignFrontier (s, to), &limit, FALSE, translateObjptr);
+}