[MLton-commit] r4209

Matthew Fluet MLton@mlton.org
Sat, 12 Nov 2005 11:55:59 -0800


Changed the semantics of numNonObjptrs for normal objects to mean
bytes of non-objptr data, rather than number of 32-bit words of
non-objptr data.  Renamed the field to bytesNonObjptrs.


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

U   mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.fun
U   mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.sig
U   mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/array-allocate.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/dfs-mark.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/forward.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/hash-cons.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/mark-compact.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/weak.c

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

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.fun	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/backend/rep-type.fun	2005-11-12 19:55:50 UTC (rev 4209)
@@ -415,16 +415,16 @@
                      val (b, p) = Type.bytesAndPointers elt
                   in
                      R.Array {hasIdentity = hasIdentity,
-                              nonPointer = b,
-                              pointers = p}
+                              bytesNonPointers = b,
+                              numPointers = p}
                   end
              | Normal {hasIdentity, ty} =>
                   let
                      val (b, p) = Type.bytesAndPointers ty
                   in
                      R.Normal {hasIdentity = hasIdentity,
-                               nonPointer = Bytes.toWords b,
-                               pointers = p}
+                               bytesNonPointers = b,
+                               numPointers = p}
                   end
              | Stack => R.Stack
              | Weak _ => R.Weak

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.fun	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.fun	2005-11-12 19:55:50 UTC (rev 4209)
@@ -107,11 +107,11 @@
    struct
       datatype t =
          Array of {hasIdentity: bool,
-                   nonPointer: Bytes.t,
-                   pointers: int}
+                   bytesNonPointers: Bytes.t,
+                   numPointers: int}
        | Normal of {hasIdentity: bool,
-                    nonPointer: Words.t,
-                    pointers: int}
+                    bytesNonPointers: Bytes.t,
+                    numPointers: int}
        | Stack
        | Weak
        | WeakGone
@@ -121,16 +121,16 @@
             open Layout
          in
             case t of
-               Array {hasIdentity, nonPointer = np, pointers = p} =>
+               Array {hasIdentity, bytesNonPointers = np, numPointers = p} =>
                   seq [str "Array ",
                        record [("hasIdentity", Bool.layout hasIdentity),
-                               ("nonPointer", Bytes.layout np),
-                               ("pointers", Int.layout p)]]
-             | Normal {hasIdentity, nonPointer = np, pointers = p} =>
+                               ("bytesNonPointers", Bytes.layout np),
+                               ("numPointers", Int.layout p)]]
+             | Normal {hasIdentity, bytesNonPointers = np, numPointers = p} =>
                   seq [str "Normal ",
                        record [("hasIdentity", Bool.layout hasIdentity),
-                               ("nonPointer", Words.layout np),
-                               ("pointers", Int.layout p)]]
+                               ("bytesNonPointers", Bytes.layout np),
+                               ("numPointers", Int.layout p)]]
              | Stack => str "Stack"
              | Weak => str "Weak"
              | WeakGone => str "WeakGone"

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.sig
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.sig	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/backend/runtime.sig	2005-11-12 19:55:50 UTC (rev 4209)
@@ -54,11 +54,11 @@
          sig
             datatype t =
                Array of {hasIdentity: bool,
-                         nonPointer: Bytes.t,
-                         pointers: int}
+                         bytesNonPointers: Bytes.t,
+                         numPointers: int}
              | Normal of {hasIdentity: bool,
-                          nonPointer: Words.t,
-                          pointers: int}
+                          bytesNonPointers: Bytes.t,
+                          numPointers: int}
              | Stack
              | Weak
              | WeakGone

Modified: mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/mlton/codegen/c-codegen/c-codegen.fun	2005-11-12 19:55:50 UTC (rev 4209)
@@ -324,27 +324,37 @@
           fn (_, ty) =>
           let
              datatype z = datatype Runtime.RObjectType.t
-             val (tag, hasIdentity, nonPointers, pointers) =
+             val (tag, hasIdentity, bytesNonPointers, numPointers) =
                 case ObjectType.toRuntime ty of
-                   Array {hasIdentity, nonPointer, pointers} =>
-                      (0, hasIdentity, Bytes.toInt nonPointer, pointers)
-                 | Normal {hasIdentity, nonPointer, pointers} =>
-                      (1, hasIdentity, Words.toInt nonPointer, pointers)
+                   Array {hasIdentity, bytesNonPointers, numPointers} =>
+                      (0, hasIdentity, 
+                       Bytes.toInt bytesNonPointers, numPointers)
+                 | Normal {hasIdentity, bytesNonPointers, numPointers} =>
+                      (1, hasIdentity, 
+                       Bytes.toInt bytesNonPointers, numPointers)
                  | Stack =>
                       (2, false, 0, 0)
                  | Weak =>
                       (case !Control.align of
-                          Control.Align4 => (3, false, 1, 1)
-                        | Control.Align8 => (3, false, 2, 1))
+                          Control.Align4 => 
+                             (3, false, 
+                              Bytes.toInt (Words.toBytes (Words.fromInt 1)), 1)
+                        | Control.Align8 => 
+                             (3, false, 
+                              Bytes.toInt (Words.toBytes (Words.fromInt 2)), 1))
                  | WeakGone =>
                       (case !Control.align of
-                          Control.Align4 => (3, false, 2, 0)
-                        | Control.Align8 => (3, false, 3, 0))
+                          Control.Align4 => 
+                             (3, false, 
+                              Bytes.toInt (Words.toBytes (Words.fromInt 2)), 0)
+                        | Control.Align8 => 
+                             (3, false, 
+                              Bytes.toInt (Words.toBytes (Words.fromInt 3)), 0))
           in
              concat ["{ ", C.int tag, ", ",
                      C.bool hasIdentity, ", ",
-                     C.int nonPointers, ", ",
-                     C.int pointers, " }"]
+                     C.int bytesNonPointers, ", ",
+                     C.int numPointers, " }"]
           end)
       fun declareMain () =
          let

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -6,7 +6,7 @@
  * See the file MLton-LICENSE for details.
  */
 
-static inline size_t pad (GC_state s, size_t bytes, size_t extra) {
+static inline size_t alignWithExtra (GC_state s, size_t bytes, size_t extra) {
   return align (bytes + extra, s->alignment) - extra;
 }
 
@@ -21,7 +21,7 @@
 pointer alignFrontier (GC_state s, pointer p) {
   size_t res;
 
-  res = pad (s, (size_t)p, GC_NORMAL_HEADER_SIZE);
+  res = alignWithExtra (s, (size_t)p, GC_NORMAL_HEADER_SIZE);
   assert (isFrontierAligned (s, (pointer)res));
   return (pointer)res;
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/array-allocate.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/array-allocate.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/array-allocate.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -13,19 +13,17 @@
   uintmax_t arraySizeMax;
   size_t arraySize;
   size_t bytesPerElement;
-  uint16_t numNonObjptrs;
+  uint16_t bytesNonObjptrs;
   uint16_t numObjptrs;
   pointer frontier;
   pointer last;
   pointer res;
 
-  splitHeader(s, header, NULL, NULL, &numNonObjptrs, &numObjptrs);
+  splitHeader(s, header, NULL, NULL, &bytesNonObjptrs, &numObjptrs);
   if (DEBUG)
     fprintf (stderr, "GC_arrayAllocate (%zu, "FMTARRLEN", "FMTHDR")\n",
              ensureBytesFree, numElements, header);
-  bytesPerElement = 
-    sizeofNumNonObjptrs (ARRAY_TAG, numNonObjptrs) 
-    + (numObjptrs * OBJPTR_SIZE);
+  bytesPerElement = bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE);
   arraySizeMax = 
     alignMax ((uintmax_t)bytesPerElement * (uintmax_t)numElements + GC_ARRAY_HEADER_SIZE,
               s->alignment);
@@ -76,22 +74,20 @@
   if (1 <= numObjptrs and 0 < numElements) {
     pointer p;
     
-    if (0 == numNonObjptrs)
+    if (0 == bytesNonObjptrs)
       for (p = frontier; p < last; p += OBJPTR_SIZE)
         *((objptr*)p) = BOGUS_OBJPTR;
     else {
       /* Array with a mix of pointers and non-pointers. */
-      size_t nonObjptrBytes;
-      size_t objptrBytes;
-        
-      nonObjptrBytes = sizeofNumNonObjptrs (ARRAY_TAG, numNonObjptrs);
-      objptrBytes = numObjptrs * OBJPTR_SIZE;
+      size_t bytesObjptrs;
 
+      bytesObjptrs = numObjptrs * OBJPTR_SIZE;
+
       for (p = frontier; p < last; ) {
         pointer next;
         
-        p += nonObjptrBytes;
-        next = p + objptrBytes;
+        p += bytesNonObjptrs;
+        next = p + bytesObjptrs;
         assert (next <= last);
         for ( ; p < next; p += OBJPTR_SIZE)
           *((objptr*)p) = BOGUS_OBJPTR;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -47,24 +47,18 @@
                                   GC_arrayCounter arrayIndex,
                                   uint32_t pointerIndex) {
   GC_header header;
-  uint16_t numNonObjptrs;
+  uint16_t bytesNonObjptrs;
   uint16_t numObjptrs;
   GC_objectTypeTag tag;
   
   header = getHeader (a);
-  splitHeader(s, header, &tag, NULL, &numNonObjptrs, &numObjptrs);
+  splitHeader(s, header, &tag, NULL, &bytesNonObjptrs, &numObjptrs);
   assert (tag == ARRAY_TAG);
 
-  size_t nonObjptrBytesPerElement =
-    sizeofNumNonObjptrs (ARRAY_TAG, numNonObjptrs);
-  size_t bytesPerElement =
-    nonObjptrBytesPerElement
-    + (numObjptrs * OBJPTR_SIZE);
-
   return a
-    + arrayIndex * bytesPerElement
-    + nonObjptrBytesPerElement
-    + pointerIndex * OBJPTR_SIZE;
+    + (arrayIndex * (bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE)))
+    + bytesNonObjptrs
+    + (pointerIndex * OBJPTR_SIZE);
 }
 
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/dfs-mark.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/dfs-mark.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/dfs-mark.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -46,7 +46,7 @@
   pointer todo; /* A pointer to the pointer in cur to next. */
   GC_header header;
   GC_header* headerp;
-  uint16_t numNonObjptrs;
+  uint16_t bytesNonObjptrs;
   uint16_t numObjptrs;
   GC_objectTypeTag tag;
   uint32_t index; /* The i'th pointer in the object (element) being marked. */
@@ -114,11 +114,11 @@
    * would see the object as unmarked and traverse it again.
    */
   *headerp = header;
-  splitHeader (s, header, &tag, NULL, &numNonObjptrs, &numObjptrs);
+  splitHeader (s, header, &tag, NULL, &bytesNonObjptrs, &numObjptrs);
   if (NORMAL_TAG == tag) {
     size += 
       GC_NORMAL_HEADER_SIZE 
-      + sizeofNumNonObjptrs (tag, numNonObjptrs) 
+      + bytesNonObjptrs 
       + (numObjptrs * OBJPTR_SIZE);
     if (0 == numObjptrs) {
       /* There is nothing to mark. */
@@ -127,7 +127,7 @@
         cur = hashConsPointer (s, cur, TRUE);
       goto ret;
     }
-    todo = cur + sizeofNumNonObjptrs (NORMAL_TAG, numNonObjptrs);
+    todo = cur + bytesNonObjptrs;
     index = 0;
 markInNormal:
     if (DEBUG_DFS_MARK)
@@ -169,7 +169,7 @@
      */
     size += 
       GC_ARRAY_HEADER_SIZE
-      + sizeofArrayNoHeader (s, getArrayLength (cur), numNonObjptrs, numObjptrs);
+      + sizeofArrayNoHeader (s, getArrayLength (cur), bytesNonObjptrs, numObjptrs);
     if (0 == numObjptrs or 0 == getArrayLength (cur)) {
       /* There is nothing to mark. */
 arrayDone:
@@ -184,7 +184,7 @@
     assert (arrayIndex < getArrayLength (cur));
     index = 0;
     /* Skip to the first pointer. */
-    todo += sizeofNumNonObjptrs (ARRAY_TAG, numNonObjptrs);
+    todo += bytesNonObjptrs;
 markInArray:
     if (DEBUG_DFS_MARK)
       fprintf (stderr, "markInArray arrayIndex = %"PRIu32" index = %"PRIu32"\n",
@@ -288,13 +288,13 @@
   cur = prev;
   headerp = getHeaderp (cur);
   header = *headerp;
-  splitHeader (s, header, &tag, NULL, &numNonObjptrs, &numObjptrs);
+  splitHeader (s, header, &tag, NULL, &bytesNonObjptrs, &numObjptrs);
   /* It's impossible to get a WEAK_TAG here, since we would never
    * follow the weak object pointer.
    */
   assert (WEAK_TAG != tag);
   if (NORMAL_TAG == tag) {
-    todo = cur + sizeofNumNonObjptrs (tag, numNonObjptrs);
+    todo = cur + bytesNonObjptrs;
     index = (header & COUNTER_MASK) >> COUNTER_SHIFT;
     todo += index * OBJPTR_SIZE;
     // prev = *(pointer*)todo;
@@ -304,10 +304,9 @@
     goto markNextInNormal;
   } else if (ARRAY_TAG == tag) {
     arrayIndex = getArrayCounter (cur);
-    todo = cur + arrayIndex * (sizeofNumNonObjptrs (ARRAY_TAG, numNonObjptrs)
-                               + (numObjptrs * OBJPTR_SIZE));
+    todo = cur + arrayIndex * (bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE));
     index = (header & COUNTER_MASK) >> COUNTER_SHIFT;
-    todo += sizeofNumNonObjptrs (ARRAY_TAG, numNonObjptrs) + index * OBJPTR_SIZE;
+    todo += bytesNonObjptrs + index * OBJPTR_SIZE;
     // prev = *(pointer*)todo;
     prev = fetchObjptrToPointer (todo, s->heap.start);
     // *(pointer*)todo = next;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -40,23 +40,23 @@
 pointer foreachObjptrInObject (GC_state s, pointer p,
                                GC_foreachObjptrFun f, bool skipWeaks) {
   GC_header header;
-  uint16_t numNonObjptrs;
+  uint16_t bytesNonObjptrs;
   uint16_t numObjptrs;
   GC_objectTypeTag tag;
 
   header = getHeader (p);
-  splitHeader(s, header, &tag, NULL, &numNonObjptrs, &numObjptrs);
+  splitHeader(s, header, &tag, NULL, &bytesNonObjptrs, &numObjptrs);
   if (DEBUG_DETAILED)
     fprintf (stderr, 
              "foreachObjptrInObject ("FMTPTR")"
              "  header = "FMTHDR
              "  tag = %s"
-             "  numNonObjptrs = %d"
+             "  bytesNonObjptrs = %d"
              "  numObjptrs = %d\n", 
              (uintptr_t)p, header, objectTypeTagToString (tag), 
-             numNonObjptrs, numObjptrs);
+             bytesNonObjptrs, numObjptrs);
   if (NORMAL_TAG == tag) {
-    p += sizeofNumNonObjptrs (NORMAL_TAG, numNonObjptrs);
+    p += bytesNonObjptrs;
     pointer max = p + (numObjptrs * OBJPTR_SIZE);
     /* Apply f to all internal pointers. */
     for ( ; p < max; p += OBJPTR_SIZE) {
@@ -67,23 +67,19 @@
       callIfIsObjptr (s, f, (objptr*)p);
     }
   } else if (WEAK_TAG == tag) {
-    p += sizeofNumNonObjptrs (WEAK_TAG, numNonObjptrs);
+    p += bytesNonObjptrs;
     if (1 == numObjptrs) {
       if (not skipWeaks)
         callIfIsObjptr (s, f, (objptr*)p);
       p += OBJPTR_SIZE;
     }
   } else if (ARRAY_TAG == tag) {
-    size_t bytesPerElement;
     size_t dataBytes;
     pointer last;
     GC_arrayLength numElements;
     
     numElements = getArrayLength (p);
-    bytesPerElement = 
-      sizeofNumNonObjptrs (ARRAY_TAG, numNonObjptrs) 
-      + (numObjptrs * OBJPTR_SIZE);
-    dataBytes = numElements * bytesPerElement;
+    dataBytes = numElements * (bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE));
     /* Must check 0 == dataBytes before 0 == numPointers to correctly
      * handle arrays when both are true.
      */
@@ -95,25 +91,23 @@
       ;
     else {
       last = p + dataBytes;
-      if (0 == numNonObjptrs)
+      if (0 == bytesNonObjptrs)
         /* Array with only pointers. */
         for ( ; p < last; p += OBJPTR_SIZE)
           callIfIsObjptr (s, f, (objptr*)p);
       else {
         /* Array with a mix of pointers and non-pointers. */
-        size_t nonObjptrBytes;
-        size_t objptrBytes;
+        size_t bytesObjptrs;
         
-        nonObjptrBytes = sizeofNumNonObjptrs (ARRAY_TAG, numNonObjptrs);
-        objptrBytes = numObjptrs * OBJPTR_SIZE;
+        bytesObjptrs = numObjptrs * OBJPTR_SIZE;
 
         /* For each array element. */
         for ( ; p < last; ) {
           pointer next;
           
           /* Skip the non-pointers. */
-          p += nonObjptrBytes;
-          next = p + objptrBytes;
+          p += bytesNonObjptrs;
+          next = p + bytesObjptrs;
           /* For each internal pointer. */
           for ( ; p < next; p += OBJPTR_SIZE) 
             callIfIsObjptr (s, f, (objptr*)p);
@@ -122,7 +116,7 @@
       assert (p == last);
       p -= dataBytes;
     }
-    p += pad (s, dataBytes, GC_ARRAY_HEADER_SIZE);
+    p += alignWithExtra (s, dataBytes, GC_ARRAY_HEADER_SIZE);
   } else { /* stack */
     GC_stack stack; 
     pointer top, bottom; 

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-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/forward.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -41,22 +41,22 @@
   if (DEBUG_DETAILED and header == GC_FORWARDED)
     fprintf (stderr, "  already FORWARDED\n");
   if (header != GC_FORWARDED) { /* forward the object */
-    uint16_t numNonObjptrs, numObjptrs;
+    uint16_t bytesNonObjptrs, numObjptrs;
     GC_objectTypeTag tag;
 
-    splitHeader(s, header, &tag, NULL, &numNonObjptrs, &numObjptrs);
+    splitHeader(s, header, &tag, NULL, &bytesNonObjptrs, &numObjptrs);
 
     size_t headerBytes, objectBytes, size, skip;
 
     /* Compute the space taken by the header and object body. */
     if ((NORMAL_TAG == tag) or (WEAK_TAG == tag)) { /* Fixed size object. */
       headerBytes = GC_NORMAL_HEADER_SIZE;
-      objectBytes = sizeofNormalNoHeader (s, numNonObjptrs, numObjptrs);
+      objectBytes = bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE);
       skip = 0;
     } else if (ARRAY_TAG == tag) {
       headerBytes = GC_ARRAY_HEADER_SIZE;
       objectBytes = sizeofArrayNoHeader (s, getArrayLength (p), 
-                                         numNonObjptrs, numObjptrs);
+                                         bytesNonObjptrs, numObjptrs);
       skip = 0;
     } else { /* Stack. */
       GC_stack stack;

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-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/hash-cons.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -226,7 +226,7 @@
 pointer hashConsPointer (GC_state s, pointer object, bool countBytesHashConsed) {
   GC_objectHashTable t;
   GC_header header;
-  uint16_t numNonObjptrs;
+  uint16_t bytesNonObjptrs;
   uint16_t numObjptrs;
   bool hasIdentity;
   GC_objectTypeTag tag;
@@ -239,19 +239,19 @@
     fprintf (stderr, "hashCons ("FMTPTR")\n", (uintptr_t)object);
   t = s->objectHashTable;
   header = getHeader (object);
-  splitHeader(s, header, &tag, &hasIdentity, &numNonObjptrs, &numObjptrs);
+  splitHeader(s, header, &tag, &hasIdentity, &bytesNonObjptrs, &numObjptrs);
   if (hasIdentity) {
     /* Don't hash cons. */
     res = object;
     goto done;
   }
-  assert (ARRAY_TAG == tag or NORMAL_TAG == tag);
+  assert ((ARRAY_TAG == tag) or (NORMAL_TAG == tag));
   max = 
     object
     + (ARRAY_TAG == tag
        ? (sizeofArrayNoHeader (s, getArrayLength (object),
-                               numNonObjptrs, numObjptrs))
-       : (sizeofNormalNoHeader (s, numNonObjptrs, numObjptrs)));
+                               bytesNonObjptrs, numObjptrs))
+       : (bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE)));
   // Compute the hash.
   hash = (GC_hash)header;
   for (p = (GC_hash*)object; p < (GC_hash*)max; ++p)

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/init.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -218,7 +218,7 @@
   assert (isAligned (sizeof (struct GC_stack), s->alignment));
   assert (isAligned (GC_NORMAL_HEADER_SIZE + sizeof (struct GC_thread),
                      s->alignment));
-  // While the following assert is manifestly true,
+  // While the following asserts is manifestly true,
   // it checks the asserts in sizeofWeak.
   assert (sizeofWeak (s) == sizeofWeak (s));
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/mark-compact.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/mark-compact.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/mark-compact.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -64,12 +64,12 @@
 void clearIfWeakAndUnmarkedForMarkCompact (GC_state s, pointer p) {
   GC_header header;
   GC_header *headerp;
-  uint16_t numNonObjptrs, numObjptrs;
+  uint16_t bytesNonObjptrs, numObjptrs;
   GC_objectTypeTag tag;
 
   headerp = getHeaderp (p);
   header = *headerp;
-  splitHeader(s, *headerp, &tag, NULL, &numNonObjptrs, &numObjptrs);
+  splitHeader(s, *headerp, &tag, NULL, &bytesNonObjptrs, &numObjptrs);
   if (WEAK_TAG == tag and 1 == numObjptrs) {
     GC_header objptrHeader;
     GC_weak w;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -6,57 +6,18 @@
  * See the file MLton-LICENSE for details.
  */
 
-size_t sizeofNumNonObjptrs (GC_objectTypeTag tag, uint16_t numNonObjptrs) {
-  switch (tag) {
-  case ARRAY_TAG:
-    return (size_t)(numNonObjptrs);
-  case NORMAL_TAG:
-    return (size_t)(numNonObjptrs) * 4;
-  case WEAK_TAG:
-    return (size_t)(numNonObjptrs) * 4;
-  default:
-    die ("bad GC_objectTypeTag %u", tag);
-  }
-}
-
-size_t sizeofNormalNoHeader (__attribute__ ((unused)) GC_state s,
-                             uint16_t numNonObjptrs,
-                             uint16_t numObjptrs) {
-  size_t result;
-
-  result = 
-    sizeofNumNonObjptrs (NORMAL_TAG, numNonObjptrs)
-    + (numObjptrs * OBJPTR_SIZE);
-  return result;
-}
-
 size_t sizeofArrayNoHeader (GC_state s, 
                             GC_arrayLength numElements,
-                            uint16_t numNonObjptrs, uint16_t numObjptrs) {
-  size_t bytesPerElement;
+                            uint16_t bytesNonObjptrs, uint16_t numObjptrs) {
   size_t result;
         
-  bytesPerElement = 
-    sizeofNumNonObjptrs (ARRAY_TAG, numNonObjptrs) 
-    + (numObjptrs * OBJPTR_SIZE);
-  result = numElements * bytesPerElement;
+  result = numElements * (bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE));
   /* Empty arrays have OBJPTR_SIZE bytes for the forwarding pointer. */
   if (0 == result) 
     result = OBJPTR_SIZE;
-  return pad (s, result, GC_ARRAY_HEADER_SIZE);
+  return alignWithExtra (s, result, GC_ARRAY_HEADER_SIZE);
 }
 
-size_t sizeofWeakNoHeader (__attribute__ ((unused)) GC_state s,
-                           uint16_t numNonObjptrs,
-                           uint16_t numObjptrs) {
-  size_t result;
-
-  result = 
-    sizeofNumNonObjptrs (WEAK_TAG, numNonObjptrs)
-    + (numObjptrs * OBJPTR_SIZE);
-  return result;
-}
-
 size_t sizeofStackNoHeader (__attribute__ ((unused)) GC_state s,
                             GC_stack stack) {
   size_t result;
@@ -69,20 +30,17 @@
   size_t headerBytes, objectBytes;
   GC_header header;
   GC_objectTypeTag tag;
-  uint16_t numNonObjptrs, numObjptrs;
+  uint16_t bytesNonObjptrs, numObjptrs;
   
   header = getHeader (p);
-  splitHeader (s, header, &tag, NULL, &numNonObjptrs, &numObjptrs);
-  if (NORMAL_TAG == tag) { 
+  splitHeader (s, header, &tag, NULL, &bytesNonObjptrs, &numObjptrs);
+  if ((NORMAL_TAG == tag) or (WEAK_TAG == tag)) { 
     headerBytes = GC_NORMAL_HEADER_SIZE;
-    objectBytes = sizeofNormalNoHeader (s, numNonObjptrs, numObjptrs);
+    objectBytes = bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE);
   } else if (ARRAY_TAG == tag) {
     headerBytes = GC_ARRAY_HEADER_SIZE;
     objectBytes = sizeofArrayNoHeader (s, getArrayLength (p), 
-                                       numNonObjptrs, numObjptrs);
-  } else if (WEAK_TAG == tag) {
-    headerBytes = GC_NORMAL_HEADER_SIZE;
-    objectBytes = sizeofWeakNoHeader (s, numNonObjptrs, numObjptrs);
+                                       bytesNonObjptrs, numObjptrs);
   } else { /* Stack. */
     assert (STACK_TAG == tag);
     headerBytes = GC_STACK_HEADER_SIZE;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.h	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/object-size.h	2005-11-12 19:55:50 UTC (rev 4209)
@@ -6,14 +6,8 @@
  * See the file MLton-LICENSE for details.
  */
 
-size_t sizeofNumNonObjptrs (GC_objectTypeTag tag, 
-                            uint16_t numNonObjptrs);
-size_t sizeofNormalNoHeader (GC_state s, 
-                             uint16_t numNonObjptrs, uint16_t numObjptrs);
 size_t sizeofArrayNoHeader (GC_state s, GC_arrayLength numElements, 
                             uint16_t numNonObjptrs, uint16_t numObjptrs);
-size_t sizeofWeakNoHeader (GC_state s, 
-                           uint16_t numNonObjptrs, uint16_t numObjptrs);
 size_t sizeofStackNoHeader (GC_state s, GC_stack stack);
 
 size_t sizeofObject (GC_state s, pointer p);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -48,12 +48,12 @@
 
 void splitHeader(GC_state s, GC_header header,
                  GC_objectTypeTag *tagRet, bool *hasIdentityRet,
-                 uint16_t *numNonObjptrsRet, uint16_t *numObjptrsRet) {
+                 uint16_t *bytesNonObjptrsRet, uint16_t *numObjptrsRet) {
   unsigned int objectTypeIndex; 
   GC_objectType objectType; 
   GC_objectTypeTag tag;
   bool hasIdentity;
-  uint16_t numNonObjptrs, numObjptrs;
+  uint16_t bytesNonObjptrs, numObjptrs;
 
   assert (1 == (header & GC_VALID_HEADER_MASK)); 
   objectTypeIndex = (header & TYPE_INDEX_MASK) >> TYPE_INDEX_SHIFT; 
@@ -61,7 +61,7 @@
   objectType = &(s->objectTypes[objectTypeIndex]);
   tag = objectType->tag; 
   hasIdentity = objectType->hasIdentity; 
-  numNonObjptrs = objectType->numNonObjptrs; 
+  bytesNonObjptrs = objectType->bytesNonObjptrs; 
   numObjptrs = objectType->numObjptrs; 
 
   if (DEBUG_DETAILED) 
@@ -70,20 +70,20 @@
              "  objectTypeIndex = %u"
              "  tag = %s" 
              "  hasIdentity = %s" 
-             "  numNonObjptrs = %"PRIu16 
+             "  bytesNonObjptrs = %"PRIu16 
              "  numObjptrs = %"PRIu16"\n", 
              header, 
              objectTypeIndex,
              objectTypeTagToString(tag), 
              boolToString(hasIdentity), 
-             numNonObjptrs, numObjptrs); 
+             bytesNonObjptrs, numObjptrs); 
 
   if (tagRet != NULL)
     *tagRet = tag;
   if (hasIdentityRet != NULL)
     *hasIdentityRet = hasIdentity;
-  if (numNonObjptrsRet != NULL)
-    *numNonObjptrsRet = numNonObjptrs;
+  if (bytesNonObjptrsRet != NULL)
+    *bytesNonObjptrsRet = bytesNonObjptrs;
   if (numObjptrsRet != NULL)
     *numObjptrsRet = numObjptrs;
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h	2005-11-12 19:55:50 UTC (rev 4209)
@@ -82,21 +82,21 @@
  * of object types that is emitted for each compiled program.  The
  * hasIdentity field indicates whether or not the object has mutable
  * fields, in which case it may not be hash-cons-ed.  In a normal
- * object, the numNonObjptrs field indicates the number of 32-bit
- * words of non heap-pointer data, while the numObjptrs field
- * indicates the number of heap pointers.  In an array object, the
- * numNonObjptrs field indicates the number of bytes of non
- * heap-pointer data, while the numObjptrs field indicates the number
- * of heap pointers.  In a stack object, the numNonObjptrs and
- * numObjptrs fields are irrelevant.  In a weak object, the
- * numNonObjptrs and numObjptrs fields are interpreted as in a normal
- * object (and, hence, must be (2,1) or (3,0)).
+ * object, the bytesNonObjptrs field indicates the number of bytes of
+ * non heap-pointer data, while the numObjptrs field indicates the
+ * number of heap pointers.  In an array object, the bytesNonObjptrs
+ * field indicates the number of bytes of non heap-pointer data in a
+ * single array element, while the numObjptrs field indicates the
+ * number of heap pointers in a single array element.  In a stack
+ * object, the bytesNonObjptrs and numObjptrs fields are irrelevant.
+ * In a weak object, the bytesNonObjptrs and numObjptrs fields are
+ * interpreted as in a normal object.
 */
 typedef struct GC_objectType {
   /* Keep tag first, at zero offset, since it is referenced most often. */
   GC_objectTypeTag tag;
   bool hasIdentity;
-  uint16_t numNonObjptrs;
+  uint16_t bytesNonObjptrs;
   uint16_t numObjptrs;
 } *GC_objectType;
 enum {
@@ -118,7 +118,7 @@
 
 void splitHeader (GC_state s, GC_header header,
                   GC_objectTypeTag *tagRet, bool *hasIdentityRet,
-                  uint16_t *numNonObjptrsRet, uint16_t *numObjptrsRet);
+                  uint16_t *bytesNonObjptrsRet, uint16_t *numObjptrsRet);
 
 pointer advanceToObjectData (GC_state s, pointer p);
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -101,7 +101,7 @@
 size_t alignStackReserved (GC_state s, size_t reserved) {
   size_t res;
   
-  res = pad (s, reserved, GC_STACK_HEADER_SIZE + sizeof (struct GC_stack));
+  res = alignWithExtra (s, reserved, GC_STACK_HEADER_SIZE + sizeof (struct GC_stack));
   if (DEBUG_STACKS)
     fprintf (stderr, "%zu = alignStackReserved (%zu)\n", res, reserved);
   assert (isStackReservedAligned (s, res));

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -26,10 +26,10 @@
   res = GC_NORMAL_HEADER_SIZE + sizeof (struct GC_thread);
   if (DEBUG) {
     size_t check;
-    uint16_t numNonObjptrs, numObjptrs;
+    uint16_t bytesNonObjptrs, numObjptrs;
 
-    splitHeader (s, GC_THREAD_HEADER, NULL, NULL, &numNonObjptrs, &numObjptrs);
-    check = GC_NORMAL_HEADER_SIZE + sizeofNormalNoHeader (s, numNonObjptrs, numObjptrs);
+    splitHeader (s, GC_THREAD_HEADER, NULL, NULL, &bytesNonObjptrs, &numObjptrs);
+    check = GC_NORMAL_HEADER_SIZE + (bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE));
     if (DEBUG_DETAILED) 
       fprintf (stderr,
                "sizeofThread: res = %zu  check = %zu\n",

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/weak.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/weak.c	2005-11-12 17:29:46 UTC (rev 4208)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/weak.c	2005-11-12 19:55:50 UTC (rev 4209)
@@ -13,10 +13,10 @@
   res = align (res, s->alignment);
   if (DEBUG) {
     size_t check;
-    uint16_t numNonObjptrs, numObjptrs;
+    uint16_t bytesNonObjptrs, numObjptrs;
 
-    splitHeader (s, GC_WEAK_GONE_HEADER, NULL, NULL, &numNonObjptrs, &numObjptrs);
-    check = GC_NORMAL_HEADER_SIZE + sizeofWeakNoHeader (s, numNonObjptrs, numObjptrs);
+    splitHeader (s, GC_WEAK_GONE_HEADER, NULL, NULL, &bytesNonObjptrs, &numObjptrs);
+    check = GC_NORMAL_HEADER_SIZE + (bytesNonObjptrs + (numObjptrs * OBJPTR_SIZE));
     assert (check == res);
   }
   assert (isAligned (res, s->alignment));