[MLton-commit] r4079

Matthew Fluet MLton@mlton.org
Thu, 8 Sep 2005 18:04:19 -0700


Through foreachObjptrInObject
----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/TODO
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c
A   mlton/branches/on-20050822-x86_64-branch/runtime/gc/frame.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/frame.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/pointer.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/pointer.h
A   mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.h

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

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile	2005-09-09 01:04:14 UTC (rev 4079)
@@ -61,6 +61,8 @@
 	model.c								\
 	object.c							\
 	array.c								\
+	frame.c								\
+	stack.c								\
 	foreach.c							\
 	assumptions.c							\
 	gc_suffix.c
@@ -73,8 +75,8 @@
 	model.h								\
 	object.h							\
 	array.h								\
+	frame.h								\
 	stack.h								\
-	frame.h								\
 	thread.h							\
 	weak.h								\
 	heap.h								\

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/TODO
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/TODO	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/TODO	2005-09-09 01:04:14 UTC (rev 4079)
@@ -11,3 +11,7 @@
         the word after the header to get GC_weak to overlay properly.
 * what type should be used for the size field in GC_heap?  I'm using
         size_t currently, since that is the type needed by malloc.
+* I don't believe the comment concerning exnStack and the native
+        codegen in thread.h is still true; it used to be the case when
+        GC_switchToThread was implemented in codegens.  Now it should
+        be implemented in Backend.

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/align.c	2005-09-09 01:04:14 UTC (rev 4079)
@@ -6,7 +6,7 @@
  * See the file MLton-LICENSE for details.
  */
 
-static inline uintptr_t align (uintptr_t a, uintptr_t b) {
+static inline size_t align (size_t a, size_t b) {
   assert (a >= 0);
   assert (b >= 1);
   a += b - 1;
@@ -28,12 +28,12 @@
 }
 */
 
-static bool isAligned (uintptr_t a, size_t b) {
+static inline bool isAligned (uintptr_t a, size_t b) {
   return 0 == a % b;
 }
 
 #if ASSERT
-static bool isAlignedFrontier (GC_state s, pointer p) {
+static inline bool isAlignedFrontier (GC_state s, pointer p) {
   return isAligned ((uintptr_t)p + GC_NORMAL_HEADER_SIZE, s->alignment);
 }
 
@@ -49,15 +49,15 @@
   return align (bytes + extra, s->alignment) - extra;
 }
 
-/*
 static inline pointer alignFrontier (GC_state s, pointer p) {
-  return (pointer) pad (s, (uintptr_t)p, GC_NORMAL_HEADER_SIZE);
+  return (pointer) pad (s, (size_t)p, GC_NORMAL_HEADER_SIZE);
 }
 
 pointer GC_alignFrontier (GC_state s, pointer p) {
   return alignFrontier (s, p);
 }
 
+/*
 static inline uint stackReserved (GC_state s, uint r) {
   uint res;
   

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.c	2005-09-09 01:04:14 UTC (rev 4079)
@@ -7,17 +7,17 @@
  */
 
 #if ASSERT
-static pointer arrayPointer (GC_state s, 
-                             pointer a, 
-                             uint32_t arrayIndex, 
-                             uint32_t pointerIndex) {
+static inline pointer arrayIndexAtPointer (GC_state s, 
+                                           pointer a, 
+                                           uint32_t arrayIndex, 
+                                           uint32_t pointerIndex) {
   bool hasIdentity;
   GC_header header;
   uint16_t numNonObjptrs;
   uint16_t numObjptrs;
   GC_objectTypeTag tag;
   
-  header = GC_getHeader (a);
+  header = getHeader (a);
   SPLIT_HEADER();
   assert (tag == ARRAY_TAG);
 
@@ -41,7 +41,7 @@
   GC_arrayLength numElements;
   size_t result;
         
-  numElements = GC_arrayNumElements (p);
+  numElements = arrayNumElements (p);
   bytesPerElement = 
     numNonObjptrsToBytes(numNonObjptrs, ARRAY_TAG) 
     + (numObjptrs * OBJPTR_SIZE);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.h	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/array.h	2005-09-09 01:04:14 UTC (rev 4079)
@@ -19,16 +19,14 @@
  * individual layout as normal objects, omitting the header word.
  */
 typedef uint32_t GC_arrayLength;
-enum {
-  GC_ARRAY_LENGTH_SIZE =  sizeof(GC_arrayLength),
-  GC_ARRAY_COUNTER_SIZE = GC_ARRAY_LENGTH_SIZE,
-  GC_ARRAY_HEADER_SIZE =  GC_ARRAY_COUNTER_SIZE + GC_ARRAY_LENGTH_SIZE + GC_HEADER_SIZE,
-};
+#define GC_ARRAY_LENGTH_SIZE sizeof(GC_arrayLength)
+#define GC_ARRAY_COUNTER_SIZE GC_ARRAY_LENGTH_SIZE
+#define GC_ARRAY_HEADER_SIZE (GC_ARRAY_COUNTER_SIZE + GC_ARRAY_LENGTH_SIZE + GC_HEADER_SIZE)
 
-static inline GC_arrayLength* GC_arrayNumElementsp (pointer a) {
+static inline GC_arrayLength* arrayNumElementsp (pointer a) {
   return (GC_arrayLength*)(a - GC_HEADER_SIZE - GC_ARRAY_LENGTH_SIZE);
 }
 
-static inline GC_arrayLength GC_arrayNumElements (pointer a) {
-  return *(GC_arrayNumElementsp (a));
+static inline GC_arrayLength arrayNumElements (pointer a) {
+  return *(arrayNumElementsp (a));
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/foreach.c	2005-09-09 01:04:14 UTC (rev 4079)
@@ -9,16 +9,16 @@
 typedef void (*GC_pointerFun) (GC_state s, objptr *pp);
 
 static inline void maybeCall (GC_pointerFun f, GC_state s, objptr *pp) {
-  if (GC_isObjptr (*pp))
+  if (isObjptr (*pp))
     f (s, pp);
 }
 
-/* foreachGlobal (s, f)
+/* foreachGlobalObjptr (s, f)
  * 
  * Apply f to each global object pointer into the heap. 
  */
-static inline void foreachGlobal (GC_state s, GC_pointerFun f) {
-  for (int i = 0; i < s->globalsSize; ++i) {
+static inline void foreachGlobalObjptr (GC_state s, GC_pointerFun f) {
+  for (unsigned int i = 0; i < s->globalsSize; ++i) {
     if (DEBUG_DETAILED)
       fprintf (stderr, "foreachGlobal %u\n", i);
     maybeCall (f, s, &s->globals [i]);
@@ -32,33 +32,33 @@
 }
 
 
-/* foreachPointerInObject (s, p, skipWeaks, f) 
+/* foreachObjptrInObject (s, p, skipWeaks, f) 
  * 
  * Applies f to each object pointer in the object pointed to by p.
  * Returns pointer to the end of object, i.e. just past object.
  *
  * If skipWeaks, then the object pointer in weak objects is skipped.
  */
-static inline pointer foreachPointerInObject (GC_state s, 
-                                              pointer p,
-                                              bool skipWeaks,
-                                              GC_pointerFun f) {
+static inline pointer foreachObjptrInObject (GC_state s, 
+                                             pointer p,
+                                             bool skipWeaks,
+                                             GC_pointerFun f) {
   bool hasIdentity;
   GC_header header;
   uint16_t numNonObjptrs;
   uint16_t numObjptrs;
   GC_objectTypeTag tag;
 
-  header = GC_getHeader (p);
+  header = getHeader (p);
   SPLIT_HEADER();
   if (DEBUG_DETAILED)
     fprintf (stderr, 
-             "foreachPointerInObject ("FMTPTR")"
+             "foreachObjptrInObject ("FMTPTR")"
              "  header = "FMTHDR
              "  tag = %s"
              "  numNonObjptrs = %d"
              "  numObjptrs = %d\n", 
-             (intptr_t)p, header, tagToString (tag), 
+             (uintptr_t)p, header, tagToString (tag), 
              numNonObjptrs, numObjptrs);
   if (NORMAL_TAG == tag) {
     p += numNonObjptrsToBytes(numNonObjptrs, NORMAL_TAG);
@@ -67,8 +67,8 @@
     for ( ; p < max; p += OBJPTR_SIZE) {
       if (DEBUG_DETAILED)
         fprintf (stderr, 
-                 "p = "FMTPTR"  *p = "FMTOBJPTR"\n",
-                 (intptr_t)p, *(objptr*)p);
+                 "  p = "FMTPTR"  *p = "FMTOBJPTR"\n",
+                 (uintptr_t)p, *(objptr*)p);
       maybeCall (f, s, (objptr*)p);
     }
   } else if (WEAK_TAG == tag) {
@@ -83,7 +83,7 @@
     pointer max;
     GC_arrayLength numElements;
     
-    numElements = GC_arrayNumElements (p);
+    numElements = arrayNumElements (p);
     bytesPerElement = 
       numNonObjptrsToBytes(numNonObjptrs, ARRAY_TAG) 
       + (numObjptrs * OBJPTR_SIZE);
@@ -101,7 +101,7 @@
       max = p + dataBytes;
       if (0 == numNonObjptrs)
         /* Array with only pointers. */
-        for (; p < max; p += OBJPTR_SIZE)
+        for ( ; p < max; p += OBJPTR_SIZE)
           maybeCall (f, s, (objptr*)p);
       else {
         /* Array with a mix of pointers and non-pointers. */
@@ -128,70 +128,69 @@
     }
     p += pad (s, dataBytes, GC_ARRAY_HEADER_SIZE);
   } else { /* stack */
-/*     GC_stack stack; */
-/*     pointer top, bottom; */
-/*     int i; */
-/*     word returnAddress; */
-/*     GC_frameLayout *layout; */
-/*     GC_offsets frameOffsets; */
-    
-/*     assert (STACK_TAG == tag); */
-/*     stack = (GC_stack)p; */
-/*     bottom = stackBottom (s, stack); */
-/*     top = stackTop (s, stack); */
-/*     assert (stack->used <= stack->reserved); */
-/*     while (top > bottom) { */
-/*       /\* Invariant: top points just past a "return address". *\/ */
-/*       returnAddress = *(word*) (top - WORD_SIZE); */
-/*       if (DEBUG) { */
-/*         fprintf (stderr, "  top = %d  return address = ", */
-/*                  top - bottom); */
-/*         fprintf (stderr, "0x%08x.\n", returnAddress); */
-/*       } */
-/*       layout = getFrameLayout (s, returnAddress);  */
-/*       frameOffsets = layout->offsets; */
-/*       top -= layout->numBytes; */
-/*       for (i = 0 ; i < frameOffsets[0] ; ++i) { */
-/*         if (DEBUG) */
-/*           fprintf(stderr,  */
-/*                   "    offset %u  address 0x%08x\n",  */
-/*                   frameOffsets[i + 1], */
-/*                   (uint)(*(pointer*)(top + frameOffsets[i + 1]))); */
-/*         maybeCall(f, s,  */
-/*                   (pointer*) */
-/*                   (top + frameOffsets[i + 1])); */
-/*       } */
-/*     } */
-/*     assert(top == bottom); */
-/*     p += sizeof (struct GC_stack) + stack->reserved; */
+    GC_stack stack; 
+    pointer top, bottom; 
+    unsigned int i;
+    GC_returnAddress returnAddress; 
+    GC_frameLayout *frameLayout;
+    GC_frameOffsets frameOffsets;
+
+    assert (STACK_TAG == tag);
+    stack = (GC_stack)p;
+    bottom = stackBottom (s, stack); 
+    top = stackTop (s, stack);
+    if (DEBUG) {
+      fprintf (stderr, "  bottom = "FMTPTR"  top = "FMTPTR"\n",
+               (uintptr_t)bottom, (uintptr_t)top);
+    }
+    assert (stack->used <= stack->reserved);
+    while (top > bottom) {
+      /* Invariant: top points just past a "return address". */
+      returnAddress = *(GC_returnAddress*) (top - GC_RETURNADDRESS_SIZE);
+      if (DEBUG) {
+        fprintf (stderr, "  top = "FMTPTR"  return address = "FMTPTR"\n",
+                 (uintptr_t)top, returnAddress);
+      }
+      frameLayout = getFrameLayout (s, returnAddress);
+      frameOffsets = frameLayout->offsets;
+      top -= frameLayout->numBytes;
+      for (i = 0 ; i < frameOffsets[0] ; ++i) {
+        if (DEBUG)
+          fprintf(stderr, "  offset %"PRIx16"  address "FMTOBJPTR"\n",
+                  frameOffsets[i + 1], *(objptr*)(top + frameOffsets[i + 1]));
+        maybeCall(f, s, (objptr*)(top + frameOffsets[i + 1]));
+      }
+    }
+    assert(top == bottom);
+    p += sizeof (struct GC_stack) + stack->reserved;
   }
   return p;
 }
 
-/* foreachPointerInRange (s, front, back, skipWeaks, f)
+/* foreachObjptrInRange (s, front, back, skipWeaks, f)
  *
  * Apply f to each pointer between front and *back, which should be a
  * contiguous sequence of objects, where front points at the beginning
  * of the first object and *back points just past the end of the last
  * object.  f may increase *back (for example, this is done by
- * forward).  foreachPointerInRange returns a pointer to the end of
+ * forward).  foreachObjptrInRange returns a pointer to the end of
  * the last object it visits.
  *
  * If skipWeaks, then the object pointer in weak objects is skipped.
  */
 
-static inline pointer foreachPointerInRange (GC_state s, 
-                                             pointer front, 
-                                             pointer *back,
-                                             bool skipWeaks,
-                                             GC_pointerFun f) {
+static inline pointer foreachObjptrInRange (GC_state s, 
+                                            pointer front, 
+                                            pointer *back,
+                                            bool skipWeaks,
+                                            GC_pointerFun f) {
   pointer b;
 
   assert (isAlignedFrontier (s, front));
   if (DEBUG_DETAILED)
     fprintf (stderr, 
-             "foreachPointerInRange  front = "FMTPTR"  *back = "FMTPTR"\n",
-             (intptr_t)front, (intptr_t)(*back));
+             "foreachObjptrInRange  front = "FMTPTR"  *back = "FMTPTR"\n",
+             (uintptr_t)front, (uintptr_t)(*back));
   b = *back;
   assert (front <= b);
   while (front < b) {
@@ -199,9 +198,9 @@
       assert (isAligned ((uintptr_t)front, GC_MODEL_MINALIGN));
       if (DEBUG_DETAILED)
         fprintf (stderr, 
-                 "front = "FMTPTR"  *back = "FMTPTR"\n",
-                 (intptr_t)front, (intptr_t)(*back));
-      front = foreachPointerInObject (s, toData (s, front), skipWeaks, f);
+                 "  front = "FMTPTR"  *back = "FMTPTR"\n",
+                 (uintptr_t)front, (uintptr_t)(*back));
+      front = foreachObjptrInObject (s, toData (s, front), skipWeaks, f);
     }
     b = *back;
   }

Copied: mlton/branches/on-20050822-x86_64-branch/runtime/gc/frame.c (from rev 4078, mlton/branches/on-20050822-x86_64-branch/runtime/gc.c)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc.c	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/frame.c	2005-09-09 01:04:14 UTC (rev 4079)
@@ -0,0 +1,34 @@
+/* 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.
+ */
+
+static inline uint32_t getFrameIndex (GC_state s, GC_returnAddress ra) {
+  uint32_t res;
+
+  res = s->returnAddressToFrameIndex (ra);
+  if (DEBUG_DETAILED)
+    fprintf (stderr, "%"PRIu32" = getFrameIndex ("FMTRA")\n",
+             res, ra);
+  return res;
+}
+
+static inline GC_frameLayout * getFrameLayout (GC_state s, GC_returnAddress ra) {
+  GC_frameLayout *layout;
+  uint32_t index;
+
+  index = getFrameIndex (s, ra);
+  if (DEBUG_DETAILED)
+    fprintf (stderr, 
+             "returnAddress = "FMTRA
+             "  index = %"PRIx32
+             "  frameLayoutsSize = %"PRIu16"\n",
+             ra, index, s->frameLayoutsSize);
+  assert (0 <= index and index < s->frameLayoutsSize);
+  layout = &(s->frameLayouts[index]);
+  assert (layout->numBytes > 0);
+  return layout;
+}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/frame.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/frame.h	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/frame.h	2005-09-09 01:04:14 UTC (rev 4079)
@@ -25,15 +25,14 @@
  * array) whose elements record byte offsets from the bottom of the
  * frame at which live heap pointers are located.
  */
-typedef uint16_t *GC_offsets;
+typedef uint16_t *GC_frameOffsets;
 
 typedef struct GC_frameLayout {
-  /* Identifies whether or not the frame is for a C call.  */
   bool isC;
-  /* Number of bytes in frame, including space for return address. */
   uint16_t numBytes;
-  /* Offsets from stackTop pointing at bottom of frame at which
-   * pointers are located.
-   */
-  GC_offsets offsets;
+  GC_frameOffsets offsets;
 } GC_frameLayout;
+
+typedef uintptr_t GC_returnAddress;
+#define GC_RETURNADDRESS_SIZE sizeof(GC_returnAddress)
+#define FMTRA "0x%016"PRIxPTR

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-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.h	2005-09-09 01:04:14 UTC (rev 4079)
@@ -3,11 +3,14 @@
   size_t alignment; /* */
   objptr callFromCHandler; /* Handler for exported C calls (in heap). */
   objptr currentThread; /* Currently executing thread (in heap). */
+  GC_frameLayout *frameLayouts; /* Array of frame layouts. */
+  uint32_t frameLayoutsSize; /* Cardinality of frameLayouts array. */
   objptr *globals;
   uint32_t globalsSize;
   struct GC_heap heap;
   GC_objectType *objectTypes; /* Array of object types. */
   uint32_t objectTypesSize; /* Cardinality of objectTypes array. */
+  uint32_t (*returnAddressToFrameIndex) (GC_returnAddress ra);
   objptr savedThread; /* Result of GC_copyCurrentThread.
                        * Thread interrupted by arrival of signal.
                        */

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.h	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.h	2005-09-09 01:04:14 UTC (rev 4079)
@@ -18,6 +18,6 @@
 */
 
 typedef struct GC_heap {
-  size_t size;
-  pointer start;          /* start of memory area */
+  size_t numBytes; /* size of heap */
+  pointer start; /* start of heap */
 } *GC_heap;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c	2005-09-09 01:04:14 UTC (rev 4079)
@@ -21,7 +21,7 @@
   P_ = ((O_ << S_) + B_);
   P = (pointer)P_;
   if (DEBUG_DETAILED) 
-    fprintf (stderr, "objptrToPointer ("FMTOBJPTR") = "FMTPTR"\n", O, (intptr_t)P);
+    fprintf (stderr, "objptrToPointer ("FMTOBJPTR") = "FMTPTR"\n", O, (uintptr_t)P);
   
   return P;
 }
@@ -42,13 +42,13 @@
   O_ = ((P_ - B_) >> S_);
   O = (objptr)O_;
   if (DEBUG_DETAILED) 
-    fprintf (stderr, "pointerToObjptr ("FMTPTR") = "FMTOBJPTR"\n", (intptr_t)P, O);
+    fprintf (stderr, "pointerToObjptr ("FMTPTR") = "FMTOBJPTR"\n", (uintptr_t)P, O);
 
   return O;
 }
 
-/* GC_isObjptr returns true if p looks like an object pointer. */
-static inline bool GC_isObjptr (objptr p) {
+/* isObjptr returns true if p looks like an object pointer. */
+static inline bool isObjptr (objptr p) {
   if GC_MODEL_NONPTR {
     unsigned int shift = GC_MODEL_MINALIGN_SHIFT - GC_MODEL_SHIFT;
     objptr mask = ~((~((objptr)0)) << shift);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/object.h	2005-09-09 01:04:14 UTC (rev 4079)
@@ -27,10 +27,10 @@
  *      31   : mark bit, used by mark compact GC (initially 0)
  */
 typedef uint32_t GC_header;
+#define GC_HEADER_SIZE sizeof(GC_header)
 #define PRIxHDR PRIx32
 #define FMTHDR "0x%08"PRIxHDR
 enum {
-  GC_HEADER_SIZE =   sizeof(GC_header),
   TYPE_INDEX_BITS =  19,
   TYPE_INDEX_MASK =  0x000FFFFE,
   TYPE_INDEX_SHIFT = 1,
@@ -42,11 +42,11 @@
   MARK_SHIFT =       31
 };
 
-/* GC_getHeaderp (p)
+/* getHeaderp (p)
  *
  * Returns a pointer to the header for the object pointed to by p.
  */
-static inline GC_header* GC_getHeaderp (pointer p) {
+static inline GC_header* getHeaderp (pointer p) {
   return (GC_header*)(p - GC_HEADER_SIZE);
 }
 
@@ -54,8 +54,8 @@
  *
  * Returns the header for the object pointed to by p. 
  */
-static inline GC_header GC_getHeader (pointer p) {
-  return *(GC_getHeaderp(p));
+static inline GC_header getHeader (pointer p) {
+  return *(getHeaderp(p));
 }
 
 /*
@@ -72,9 +72,7 @@
  * Likewise, a primitive value may span multiple native words (e.g.,
  * Word64.word).
 */
-enum {
-  GC_NORMAL_HEADER_SIZE = GC_HEADER_SIZE,
-};
+#define GC_NORMAL_HEADER_SIZE GC_HEADER_SIZE
 
 /* Array objects are described in "array.h" */
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/pointer.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/pointer.c	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/pointer.c	2005-09-09 01:04:14 UTC (rev 4079)
@@ -6,8 +6,8 @@
  * See the file MLton-LICENSE for details.
  */
 
-/* GC_isPointer returns true if p looks like a pointer. */
-static inline bool GC_isPointer (pointer p) {
+/* isPointer returns true if p looks like a pointer. */
+static inline bool isPointer (pointer p) {
   uintptr_t mask = ~((~((uintptr_t)0)) << GC_MODEL_MINALIGN_SHIFT);
   return (0 == ((uintptr_t)p & mask));
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/pointer.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/pointer.h	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/pointer.h	2005-09-09 01:04:14 UTC (rev 4079)
@@ -7,5 +7,6 @@
  */
 
 typedef unsigned char* pointer;
+#define POINTER_SIZE sizeof(pointer);
 #define FMTPTR "0x%016"PRIxPTR
 #define BOGUS_POINTER 0x1

Copied: mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c (from rev 4078, mlton/branches/on-20050822-x86_64-branch/runtime/gc.c)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc.c	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c	2005-09-09 01:04:14 UTC (rev 4079)
@@ -0,0 +1,20 @@
+/* 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.
+ */
+
+static inline pointer stackBottom (GC_state s, GC_stack stack) {
+        pointer res;
+
+        res = ((pointer)stack) + sizeof (struct GC_stack);
+        assert (isAligned ((uintptr_t)res, s->alignment));
+        return res;
+}
+
+/* Pointer to the topmost word in use on the stack. */
+static inline pointer stackTop (GC_state s, GC_stack stack) {
+        return stackBottom (s, stack) + stack->used;
+}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.h	2005-09-07 00:47:05 UTC (rev 4078)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.h	2005-09-09 01:04:14 UTC (rev 4079)
@@ -46,3 +46,4 @@
    * reserved bytes hold space for the stack.
    */
 } *GC_stack;
+#define GC_STACK_SIZE sizeof(struct GC_stack);