[MLton-commit] r5370

Matthew Fluet fluet at mlton.org
Wed Feb 28 18:10:47 PST 2007


Going to 64-bit headers and array lengths on 64-bit executables.

See commit r5322 for more details on preliminary 64-bit executables.

This commit "fixes" the mark-compact collector.  The issue is that the
mark-compact collector threads object pointers through headers.

We might be able to get by with 32-bit headers, if every object was
required to have 32-bits of non-object-pointers after the header.  (It
would be o.k. if these bits were from object data.)  However, this
wouldn't suffice for an array of object pointers, since adding another
32-bits at the beginning of the array would break offsets; and adding
32-bits to every element (just to get 32-bits at the beginning of the
object) is too much of a space waste.

So, we need to go with 64-bit headers.  However, advanceToObjectData
assumes that one can distinguish between the beginning of a normal
object header and the beginning of an array object header by looking
for the 0 of the array counter word.  So, array counters need to be
64-bits, and since the compiler currently assumes that the array
counter and the array length fields of an array header are the same
size, array lengths need to be 64-bits.

Note that the default integer size is still Int32.int, so Array.maxLen
(and array indexes) are still only 32-bits (from user code).

Haven't tested very large arrays with -default-ty int64.


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

U   mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h

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

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun	2007-03-01 01:53:20 UTC (rev 5369)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/main/main.fun	2007-03-01 02:10:46 UTC (rev 5370)
@@ -694,10 +694,10 @@
                    cpointer = word64,
                    cptrdiff = word64,
                    csize = word64,
-                   header = word32,
+                   header = word64,
                    mplimb = word64,
                    objptr = word64,
-                   seqIndex = word32}
+                   seqIndex = word64}
                end
           | _ =>
                let

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.h	2007-03-01 01:53:20 UTC (rev 5369)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.h	2007-03-01 02:10:46 UTC (rev 5370)
@@ -20,15 +20,28 @@
  * the number of elements in the array.  Array elements have the same
  * individual layout as normal objects, omitting the header word.
  */
+#ifdef GC_MODEL_NATIVE32
 typedef uint32_t GC_arrayLength;
 #define GC_ARRAY_LENGTH_SIZE sizeof(GC_arrayLength)
 #define PRIxARRLEN PRIu32
 #define FMTARRLEN "%"PRIxARRLEN
 typedef GC_arrayLength GC_arrayCounter;
 #define GC_ARRAY_COUNTER_SIZE sizeof(GC_arrayCounter)
-#define PRIxARRCTR PRIu32
+#define PRIxARRCTR PRIxARRLEN
 #define FMTARRCTR "%"PRIxARRCTR
 #define GC_ARRAY_HEADER_SIZE (GC_ARRAY_COUNTER_SIZE + GC_ARRAY_LENGTH_SIZE + GC_HEADER_SIZE)
+#endif
+#ifdef GC_MODEL_NATIVE64
+typedef uint64_t GC_arrayLength;
+#define GC_ARRAY_LENGTH_SIZE sizeof(GC_arrayLength)
+#define PRIxARRLEN PRIu64
+#define FMTARRLEN "%"PRIxARRLEN
+typedef GC_arrayLength GC_arrayCounter;
+#define GC_ARRAY_COUNTER_SIZE sizeof(GC_arrayCounter)
+#define PRIxARRCTR PRIxARRLEN
+#define FMTARRCTR "%"PRIxARRCTR
+#define GC_ARRAY_HEADER_SIZE (GC_ARRAY_COUNTER_SIZE + GC_ARRAY_LENGTH_SIZE + GC_HEADER_SIZE)
+#endif
 
 #endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h	2007-03-01 01:53:20 UTC (rev 5369)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h	2007-03-01 02:10:46 UTC (rev 5370)
@@ -39,20 +39,32 @@
  * 20 - 30   : counter bits, used by mark compact GC (initially 0)
  *      31   : mark bit, used by mark compact GC (initially 0)
  */
+#ifdef GC_MODEL_NATIVE32
 typedef uint32_t GC_header;
 #define GC_HEADER_SIZE sizeof(GC_header)
 #define PRIxHDR PRIx32
 #define FMTHDR "0x%08"PRIxHDR
+#endif
+#ifdef GC_MODEL_NATIVE64
+typedef uint64_t GC_header;
+#define GC_HEADER_SIZE sizeof(GC_header)
+#define PRIxHDR PRIx64
+#define FMTHDR "0x%08"PRIxHDR
+#endif
+#ifdef GC_HEADER_SIZE
+#else
+#error GC_header undefined
+#endif
 
 #define GC_VALID_HEADER_MASK ((GC_header)0x1)
 #define TYPE_INDEX_BITS    19
-#define TYPE_INDEX_MASK    0x000FFFFE
+#define TYPE_INDEX_MASK    ((GC_header)0x000FFFFE)
 #define TYPE_INDEX_SHIFT   1
 #define COUNTER_BITS       10
-#define COUNTER_MASK       0x7FF00000
+#define COUNTER_MASK       ((GC_header)0x7FF00000)
 #define COUNTER_SHIFT      20
 #define MARK_BITS          1
-#define MARK_MASK          0x80000000
+#define MARK_MASK          ((GC_header)0x80000000)
 #define MARK_SHIFT         31
 
 #endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */




More information about the MLton-commit mailing list