[MLton-commit] r4222

Matthew Fluet MLton@mlton.org
Mon, 14 Nov 2005 21:02:25 -0800


Fixed bug in sorting of profile labels
----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.h

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

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c	2005-11-15 04:55:53 UTC (rev 4221)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c	2005-11-15 05:02:23 UTC (rev 4222)
@@ -15,13 +15,12 @@
   return s->sourceMaps.sourceNames[s->sourceMaps.sources[i].sourceNameIndex];
 }
 
-static int compareSourceLabels (const void *v1, const void *v2) {
-  uintptr_t ui1;
-  uintptr_t ui2;
+int compareSourceLabels (const void *v1, const void *v2) {
+  const struct GC_sourceLabel* l1 = (const struct GC_sourceLabel*)v1;
+  const struct GC_sourceLabel* l2 = (const struct GC_sourceLabel*)v2;
+  uintptr_t ui1 = (uintptr_t)(l1->label);
+  uintptr_t ui2 = (uintptr_t)(l2->label);
 
-  ui1 = (uintptr_t)v1;
-  ui2 = (uintptr_t)v2;
-
   if (ui1 < ui2)
     return -1;
   else if (ui1 == ui2)
@@ -39,7 +38,7 @@
          sizeof (*s->sourceMaps.sourceLabels),
          compareSourceLabels);
   if (0 == s->sourceMaps.sourceLabels[s->sourceMaps.sourceLabelsLength - 1].label)
-    die ("Max profile label is 0 -- something is wrong.");
+    die ("Max source label is 0 -- something is wrong.");
   if (DEBUG_SOURCES)
     for (i = 0; i < s->sourceMaps.sourceLabelsLength; i++)
       fprintf (stderr, FMTPTR"  %"PRIu32"\n",

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.h	2005-11-15 04:55:53 UTC (rev 4221)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.h	2005-11-15 05:02:23 UTC (rev 4222)
@@ -76,6 +76,7 @@
 
 static GC_sourceSeqIndex getStackTopFrameSourceSeqIndex (GC_state s, GC_stack stack);
 
+static int compareSourceLabels (const void *v1, const void *v2);
 static void sortSourceLabels (GC_state s);
 static void initTextSources (GC_state s);