[MLton-commit] r6447

spoons at mlton.org spoons at mlton.org
Mon Mar 3 07:32:39 PST 2008


Debugging prints and comments in parallel runtime.

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

U   mlton/branches/shared-heap-multicore/runtime/gc/atomic.c
U   mlton/branches/shared-heap-multicore/runtime/gc/garbage-collection.c
U   mlton/branches/shared-heap-multicore/runtime/gc/handler.c
U   mlton/branches/shared-heap-multicore/runtime/gc/new-object.c
U   mlton/branches/shared-heap-multicore/runtime/gc/profiling.c
U   mlton/branches/shared-heap-multicore/runtime/gc/size.c
U   mlton/branches/shared-heap-multicore/runtime/gc/switch-thread.c
U   mlton/branches/shared-heap-multicore/runtime/gc/weak.c

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

Modified: mlton/branches/shared-heap-multicore/runtime/gc/atomic.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/atomic.c	2008-03-03 15:32:02 UTC (rev 6446)
+++ mlton/branches/shared-heap-multicore/runtime/gc/atomic.c	2008-03-03 15:32:38 UTC (rev 6447)
@@ -8,6 +8,7 @@
 
 void beginAtomic (GC_state s) {
   s->atomicState++;
+  /* XXX this seems ok but strange */
   if (0 == s->limit)
     s->limit = s->limitPlusSlop - GC_HEAP_LIMIT_SLOP;
 }

Modified: mlton/branches/shared-heap-multicore/runtime/gc/garbage-collection.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/garbage-collection.c	2008-03-03 15:32:02 UTC (rev 6446)
+++ mlton/branches/shared-heap-multicore/runtime/gc/garbage-collection.c	2008-03-03 15:32:38 UTC (rev 6447)
@@ -100,7 +100,8 @@
   size_t totalBytesRequested;
 
   enterGC (s);
-  if (DEBUG or s->controls.messages)
+
+  if (DEBUG or s->controls->messages)
     fprintf (stderr, "[GC: Starting gc; request %s nursery bytes and %s old-gen bytes.]\n",
              uintmaxToCommaString(nurseryBytesRequested),
              uintmaxToCommaString(oldGenBytesRequested));
@@ -416,10 +417,12 @@
 }
 
 void GC_collect (GC_state s, size_t bytesRequested, bool force,
-            char *file, int line) {
-  if (DEBUG)
-    fprintf (stderr, "%s %d: GC_collect\n", file, line);
-  enter (s);
+                 char *file, int line) {
+  
+  if (DEBUG or s->controls->messages)
+    fprintf (stderr, "%s %d: GC_collect [%d]\n", file, line,
+             Proc_processorNumber (s));
+
   /* When the mutator requests zero bytes, it may actually need as
    * much as GC_HEAP_LIMIT_SLOP.
    */

Modified: mlton/branches/shared-heap-multicore/runtime/gc/handler.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/handler.c	2008-03-03 15:32:02 UTC (rev 6446)
+++ mlton/branches/shared-heap-multicore/runtime/gc/handler.c	2008-03-03 15:32:38 UTC (rev 6447)
@@ -62,12 +62,14 @@
  */
 void GC_handler (GC_state s, int signum) {
   if (DEBUG_SIGNALS)
-    fprintf (stderr, "GC_handler signum = %d\n", signum);
+    fprintf (stderr, "GC_handler signum = %d [%d]\n", signum,
+             Proc_processorNumber (s));
   assert (sigismember (&s->signalsInfo.signalsHandled, signum));
   if (s->atomicState == 0)
     s->limit = 0;
   s->signalsInfo.signalIsPending = TRUE;
   sigaddset (&s->signalsInfo.signalsPending, signum);
   if (DEBUG_SIGNALS)
-    fprintf (stderr, "GC_handler done\n");
+    fprintf (stderr, "GC_handler done [%d]\n", 
+             Proc_processorNumber (s));
 }

Modified: mlton/branches/shared-heap-multicore/runtime/gc/new-object.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/new-object.c	2008-03-03 15:32:02 UTC (rev 6446)
+++ mlton/branches/shared-heap-multicore/runtime/gc/new-object.c	2008-03-03 15:32:38 UTC (rev 6447)
@@ -11,6 +11,7 @@
  * Allocate a new object in the heap.
  * bytesRequested includes the size of the header.
  */
+/* XXX DOC spoons must hold the runtime lock if allocInOldGen is true! */
 pointer newObject (GC_state s,
                    GC_header header,
                    size_t bytesRequested,
@@ -36,6 +37,7 @@
     frontier = s->frontier;
     s->frontier += bytesRequested;
   }
+  /* XXX unprotected concurrent access */
   GC_profileAllocInc (s, bytesRequested);
   *((GC_header*)frontier) = header;
   result = frontier + GC_NORMAL_HEADER_SIZE;

Modified: mlton/branches/shared-heap-multicore/runtime/gc/profiling.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/profiling.c	2008-03-03 15:32:02 UTC (rev 6446)
+++ mlton/branches/shared-heap-multicore/runtime/gc/profiling.c	2008-03-03 15:32:38 UTC (rev 6447)
@@ -200,7 +200,8 @@
 
 void GC_profileInc (GC_state s, size_t amount) {
   if (DEBUG_PROFILE)
-    fprintf (stderr, "GC_profileInc (%zu)\n", amount);
+    fprintf (stderr, "GC_profileInc (%zu) [%d]\n", amount,
+             Proc_processorNumber (s));
   incForProfiling (s, amount,
                    s->amInGC
                    ? SOURCE_SEQ_GC
@@ -210,7 +211,8 @@
 void GC_profileAllocInc (GC_state s, size_t amount) {
   if (s->profiling.isOn and (PROFILE_ALLOC == s->profiling.kind)) {
     if (DEBUG_PROFILE)
-      fprintf (stderr, "GC_profileAllocInc (%zu)\n", amount);
+      fprintf (stderr, "GC_profileAllocInc (%zu) [%d]\n", amount,
+               Proc_processorNumber (s));
     GC_profileInc (s, amount);
   }
 }
@@ -353,8 +355,10 @@
   GC_sourceSeqIndex sourceSeqsIndex;
 
   s = handleSigProfState;
+
   if (DEBUG_PROFILE)
-    fprintf (stderr, "GC_handleSigProf ("FMTPTR")\n", (uintptr_t)pc);
+    fprintf (stderr, "GC_handleSigProf ("FMTPTR") [%d]\n", (uintptr_t)pc,
+             Proc_processorNumber (s));
   if (s->amInGC)
     sourceSeqsIndex = SOURCE_SEQ_GC;
   else {

Modified: mlton/branches/shared-heap-multicore/runtime/gc/size.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/size.c	2008-03-03 15:32:02 UTC (rev 6446)
+++ mlton/branches/shared-heap-multicore/runtime/gc/size.c	2008-03-03 15:32:38 UTC (rev 6447)
@@ -10,10 +10,12 @@
   size_t res;
 
   if (DEBUG_SIZE)
-    fprintf (stderr, "GC_size marking\n");
+    fprintf (stderr, "GC_size marking [%d]\n",
+             Proc_processorNumber (s));
   res = dfsMarkByMode (s, root, MARK_MODE, FALSE);
   if (DEBUG_SIZE)
-    fprintf (stderr, "GC_size unmarking\n");
+    fprintf (stderr, "GC_size unmarking [%d]\n",
+             Proc_processorNumber (s));
   dfsMarkByMode (s, root, UNMARK_MODE, FALSE);
   return res;
 }

Modified: mlton/branches/shared-heap-multicore/runtime/gc/switch-thread.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/switch-thread.c	2008-03-03 15:32:02 UTC (rev 6446)
+++ mlton/branches/shared-heap-multicore/runtime/gc/switch-thread.c	2008-03-03 15:32:38 UTC (rev 6447)
@@ -23,10 +23,10 @@
 }
 
 void GC_switchToThread (GC_state s, pointer p, size_t ensureBytesFree) {
-  if (DEBUG_THREADS)
-    fprintf (stderr, "GC_switchToThread ("FMTPTR", %zu)\n", 
-             (uintptr_t)p, ensureBytesFree);
-  if (FALSE) {
+  if (DEBUG_THREADS or s->controls->messages)
+    fprintf (stderr, "GC_switchToThread ("FMTPTR", %zu) [%d]\n", 
+             (uintptr_t)p, ensureBytesFree, Proc_processorNumber (s));
+  if (TRUE) {
     /* This branch is slower than the else branch, especially
      * when debugging is turned on, because it does an invariant
      * check on every thread switch.

Modified: mlton/branches/shared-heap-multicore/runtime/gc/weak.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/weak.c	2008-03-03 15:32:02 UTC (rev 6446)
+++ mlton/branches/shared-heap-multicore/runtime/gc/weak.c	2008-03-03 15:32:38 UTC (rev 6447)
@@ -36,8 +36,9 @@
 
   res = GC_WEAK_GONE_HEADER != getHeader (p);
   if (DEBUG_WEAK)
-    fprintf (stderr, "%s = GC_weakCanGet ("FMTPTR")\n",
-             boolToString (res), (uintptr_t)p);
+    fprintf (stderr, "%s = GC_weakCanGet ("FMTPTR") [%d]\n",
+             boolToString (res), (uintptr_t)p,
+             Proc_processorNumber (s));
   return res;
 }
 




More information about the MLton-commit mailing list