[MLton-commit] r4196
Matthew Fluet
MLton@mlton.org
Thu, 10 Nov 2005 20:10:55 -0800
Scale crossMap offsets
----------------------------------------------------------------------
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/forward.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.h
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.h
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.h
U mlton/branches/on-20050822-x86_64-branch/runtime/gc/objptr.h
----------------------------------------------------------------------
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/forward.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/forward.c 2005-11-11 00:14:33 UTC (rev 4195)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/forward.c 2005-11-11 04:10:53 UTC (rev 4196)
@@ -230,14 +230,15 @@
goto checkCard;
} else {
unless (CROSS_MAP_EMPTY == crossMap[cardIndex])
- objectStart = cardStart + (size_t)(crossMap[cardIndex]);
+ objectStart = cardStart + (size_t)(crossMap[cardIndex] * CROSS_MAP_OFFSET_SCALE);
if (DEBUG_GENERATIONAL)
fprintf (stderr,
"card %zu is not marked"
" crossMap[%zu] == %zu"
" objectStart = "FMTPTR"\n",
cardIndex, cardIndex,
- (size_t)(crossMap[cardIndex]), (uintptr_t)objectStart);
+ (size_t)(crossMap[cardIndex] * CROSS_MAP_OFFSET_SCALE),
+ (uintptr_t)objectStart);
cardIndex++;
cardStart += CARD_SIZE;
goto checkAll;
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.h 2005-11-11 00:14:33 UTC (rev 4195)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.h 2005-11-11 04:10:53 UTC (rev 4196)
@@ -6,7 +6,6 @@
* See the file MLton-LICENSE for details.
*/
-#ifdef MLTON_GC_INTERNAL
struct GC_state {
size_t alignment; /* */
bool amInGC;
@@ -61,7 +60,6 @@
uint32_t vectorInitsLength;
GC_weak weaks; /* Linked list of (live) weak pointers */
};
-#endif
void displayGCState (GC_state s, FILE *stream);
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c 2005-11-11 00:14:33 UTC (rev 4195)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c 2005-11-11 04:10:53 UTC (rev 4196)
@@ -28,8 +28,9 @@
fprintf (stderr, "crossMap trues\n");
for (i = 0; i < generational->crossMapLength; i++)
unless (CROSS_MAP_EMPTY == generational->crossMap[i])
- fprintf (stderr, "\t"FMTCMI" "FMTCME"\n",
- i, generational->crossMap[i]);
+ fprintf (stderr, "\t"FMTCMI" "FMTCME" "FMTCME"\n",
+ i, generational->crossMap[i],
+ CROSS_MAP_OFFSET_SCALE * generational->crossMap[i]);
fprintf (stderr, "\n");
}
}
@@ -198,7 +199,7 @@
assert (front <= back);
cardStart = getCrossMapCardStart (s, front);
cardIndex = sizeToCardMapIndex (cardStart - s->heap.start);
- map[cardIndex] = (front - cardStart);
+ map[cardIndex] = (front - cardStart) / CROSS_MAP_OFFSET_SCALE;
if (front < back) {
front += sizeofObject (s, advanceToObjectData (s, front));
goto loopObjects;
@@ -220,6 +221,7 @@
fprintf (stderr, "updateCrossMap starting\n");
displayGenerationalMaps (s, &s->generationalMaps, stderr);
}
+ assert (isAligned (s->alignment, CROSS_MAP_OFFSET_SCALE));
if (s->generationalMaps.crossMapValidSize == s->heap.oldGenSize)
goto done;
oldGenEnd = s->heap.start + s->heap.oldGenSize;
@@ -254,7 +256,7 @@
*/
size_t offset;
- offset = (objectStart - cardStart);
+ offset = (objectStart - cardStart) / CROSS_MAP_OFFSET_SCALE;
assert (offset < CROSS_MAP_EMPTY);
if (DEBUG_GENERATIONAL)
fprintf (stderr, "crossMap[%zu] = %zu\n",
@@ -268,7 +270,8 @@
if (objectStart < oldGenEnd)
goto loopObjects;
assert (objectStart == oldGenEnd);
- s->generationalMaps.crossMap[cardIndex] = (GC_crossMapElem)(oldGenEnd - cardStart);
+ s->generationalMaps.crossMap[cardIndex] =
+ (GC_crossMapElem)(oldGenEnd - cardStart) / CROSS_MAP_OFFSET_SCALE;
s->generationalMaps.crossMapValidSize = s->heap.oldGenSize;
done:
assert (s->generationalMaps.crossMapValidSize == s->heap.oldGenSize);
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.h 2005-11-11 00:14:33 UTC (rev 4195)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.h 2005-11-11 04:10:53 UTC (rev 4196)
@@ -17,6 +17,7 @@
#define CARD_MAP_ELEM_SIZE sizeof(GC_cardMapElem)
#define CROSS_MAP_ELEM_SIZE sizeof(GC_crossMapElem)
#define CROSS_MAP_EMPTY ((GC_crossMapElem)255)
+#define CROSS_MAP_OFFSET_SCALE 4
#define FMTCMI "%zu"
#define FMTCME "%"PRIu8
@@ -33,9 +34,9 @@
GC_cardMapIndex cardMapLength;
/* crossMap is an array with cardinality equal to the size of the
* heap divided by card size. Each element in the array is
- * interpreted as a byte offset; the offset indicates the start of
- * the last object in the corresponding card from the start of the
- * card.
+ * interpreted as a byte offset (scaled by CARD_MAP_OFFSET_SCALE);
+ * the offset indicates the start of the last object in the
+ * corresponding card from the start of the card.
*/
GC_crossMapElem *crossMap;
GC_crossMapIndex crossMapLength;
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.h 2005-11-11 00:14:33 UTC (rev 4195)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.h 2005-11-11 04:10:53 UTC (rev 4196)
@@ -135,8 +135,6 @@
manageable set for users.
*/
-#if (defined (MLTON_GC_INTERNAL))
-
#if (defined (GC_MODEL_A) || defined (GC_MODEL_NATIVE32))
#define GC_MODEL_BITSIZE 32
#define GC_MODEL_SHIFT 0
@@ -207,5 +205,3 @@
#endif
#define GC_MODEL_NONOBJPTR ((GC_MODEL_MINALIGN_SHIFT - GC_MODEL_SHIFT) > 0)
#define GC_MODEL_MINALIGN TWOPOWER(GC_MODEL_MINALIGN_SHIFT)
-
-#endif /* (defined (MLTON_GC_INTERNAL)) */
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/objptr.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/objptr.h 2005-11-11 00:14:33 UTC (rev 4195)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/objptr.h 2005-11-11 04:10:53 UTC (rev 4196)
@@ -5,8 +5,6 @@
* See the file MLton-LICENSE for details.
*/
-#if (defined (MLTON_GC_INTERNAL))
-
#define OBJPTR_TYPE__(z) uint ## z ## _t
#define OBJPTR_TYPE_(z) OBJPTR_TYPE__(z)
#define OBJPTR_TYPE OBJPTR_TYPE_(GC_MODEL_BITSIZE)
@@ -28,5 +26,3 @@
objptr pointerToObjptr (pointer P, pointer B);
pointer fetchObjptrToPointer (pointer OP, pointer B);
void storeObjptrFromPointer (pointer OP, pointer P, pointer B);
-
-#endif /* (defined (MLTON_GC_INTERNAL)) */