[MLton-commit] r4095

Matthew Fluet MLton@mlton.org
Thu, 15 Sep 2005 19:27:21 -0700


Display functions
----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile
A   mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c

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

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile	2005-09-14 02:50:33 UTC (rev 4094)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile	2005-09-16 02:27:15 UTC (rev 4095)
@@ -74,6 +74,7 @@
 	thread.c							\
 	generational.c							\
 	heap.c   							\
+	gc_state.c   							\
 	invariant.c   							\
 	foreach.c							\
 	cheney-copy.c							\

Copied: mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.c (from rev 4094, mlton/branches/on-20050822-x86_64-branch/runtime/gc.c)
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc.c	2005-09-14 02:50:33 UTC (rev 4094)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/gc_state.c	2005-09-16 02:27:15 UTC (rev 4095)
@@ -0,0 +1,28 @@
+/* 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.
+ */
+
+void displayGCState (GC_state s, FILE *stream) {
+  fprintf (stream,
+           "GC state\n");
+  fprintf (stream, "\tcurrentThread"FMTOBJPTR"\n", s->currentThread);
+  displayThread (s, (GC_thread)(objptrToPointer (s->currentThread, s->heap.start)), 
+                 stream);
+  fprintf (stream, "\tgenerational\n");
+  displayGenerationalMaps (s, &s->generational, 
+                           stream);
+  fprintf (stream, "\theap\n");
+  displayHeap (s, &s->heap, 
+               stream);
+  fprintf (stream,
+           "\tlimit = "FMTPTR"\n"
+           "\tstackBottom = "FMTPTR"\n"
+           "\tstackTop = "FMTPTR"\n",
+           (uintptr_t)s->limit,
+           (uintptr_t)s->stackBottom,
+           (uintptr_t)s->stackTop);
+}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c	2005-09-14 02:50:33 UTC (rev 4094)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/generational.c	2005-09-16 02:27:15 UTC (rev 4095)
@@ -235,3 +235,30 @@
     GC_munmap (oldCardMap, oldCardMapSize + oldCrossMapSize);
   }
 }
+
+void displayGenerationalMaps (GC_state s,
+                              struct GC_generationalMaps *generational,
+                              FILE *stream) {
+  fprintf(stream,
+          "\t\tcardMap ="FMTPTR"\n"
+          "\t\tcardMapAbsolute = "FMTPTR"\n"
+          "\t\tcardMapLength = %zu\n"
+          "\t\tcrossMap = "FMTPTR"\n"
+          "\t\tcrossMapLength = %zu\n"
+          "\t\tcrossMapValidSize = %zu\n",
+          (uintptr_t)generational->cardMap, 
+          (uintptr_t)generational->cardMapAbsolute,
+          generational->cardMapLength, 
+          (uintptr_t)generational->crossMap,
+          generational->crossMapLength,
+          generational->crossMapValidSize);
+  if (DEBUG_GENERATIONAL and DEBUG_DETAILED) {
+    unsigned int i;
+
+    fprintf (stderr, "crossMap trues\n");
+    for (i = 0; i < generational->crossMapLength; ++i)
+      unless (CROSS_MAP_EMPTY == generational->crossMap[i])
+        fprintf (stderr, "\t%u\n", i);
+    fprintf (stderr, "\n");
+  }               
+}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.c	2005-09-14 02:50:33 UTC (rev 4094)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/heap.c	2005-09-16 02:27:15 UTC (rev 4095)
@@ -45,3 +45,17 @@
   p = objptrToPointer (op, s->heap.start);
   return pointerIsInNursery (s, p);
 }
+
+void displayHeap (GC_state s,
+                  GC_heap heap,
+                  FILE *stream) {
+  fprintf(stream,
+          "\t\tnursery ="FMTPTR"\n"
+          "\t\toldGenSize = %zu\n"
+          "\t\tstart = "FMTPTR"\n"
+          "\t\tsize = %zu\n",
+          (uintptr_t)heap->nursery,
+          heap->oldGenSize,
+          (uintptr_t)heap->start,
+          heap->size);
+}

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c	2005-09-14 02:50:33 UTC (rev 4094)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.c	2005-09-16 02:27:15 UTC (rev 4095)
@@ -82,3 +82,13 @@
 static inline size_t stackNeedsReserved (GC_state s, GC_stack stack) {
   return stack->used + stackSlop (s) - topFrameSize(s, stack);
 }
+
+void displayStack (GC_state s,
+                   GC_stack stack, 
+                   FILE *stream) {
+  fprintf(stream,
+          "\t\treserved = %zu\n"
+          "\t\tused = %zu\n",
+          stack->reserved,
+          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-14 02:50:33 UTC (rev 4094)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/stack.h	2005-09-16 02:27:15 UTC (rev 4095)
@@ -46,5 +46,6 @@
    * reserved bytes hold space for the stack.
    */
 } *GC_stack;
+
 #define GC_STACK_HEADER_SIZE GC_HEADER_SIZE
 #define GC_STACK_SIZE sizeof(struct GC_stack);

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c	2005-09-14 02:50:33 UTC (rev 4094)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/thread.c	2005-09-16 02:27:15 UTC (rev 4095)
@@ -15,3 +15,17 @@
   GC_thread ct = currentThread (s);
   return ct->stack;
 }
+
+void displayThread (GC_state s,
+                    GC_thread thread, 
+                    FILE *stream) {
+  fprintf(stream,
+          "\t\texnStack = %"PRIu32"\n"
+          "\t\tbytesNeeded = %"PRIu32"\n"
+          "\t\tstack = "FMTOBJPTR"\n",
+          thread->exnStack,
+          thread->bytesNeeded,
+          thread->stack);
+  displayStack (s, (GC_stack)(objptrToPointer (thread->stack, s->heap.start)),
+                stream);
+}