[MLton-commit] r4549

Matthew Fluet MLton@mlton.org
Wed, 17 May 2006 14:18:17 -0700


Added
  typedef const unsigned char* code_pointer;

This is used for time profiling with coverage via code labels (which,
is only enabled by default on x86 with the native-codegen).  This also
fixes issues with commits r4541 and r4545.


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

U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/darwin.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/freebsd.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/getText.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/hpux.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/linux.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/netbsd.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/openbsd.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform/solaris.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/platform.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/util/pointer.h

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

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.c	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.c	2006-05-17 21:18:10 UTC (rev 4549)
@@ -315,7 +315,7 @@
 
 static GC_state handleSigProfState;
 
-void GC_handleSigProf (pointer pc) {
+void GC_handleSigProf (code_pointer pc) {
   GC_frameIndex frameIndex;
   GC_state s;
   GC_sourceSeqIndex sourceSeqsIndex;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.h	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/profiling.h	2006-05-17 21:18:10 UTC (rev 4549)
@@ -123,5 +123,5 @@
 
 #endif /* (defined (MLTON_GC_INTERNAL_BASIS)) */
 
-void GC_handleSigProf (pointer pc);
+void GC_handleSigProf (code_pointer pc);
 

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.c	2006-05-17 21:18:10 UTC (rev 4549)
@@ -56,16 +56,16 @@
 
 void initTextSources (GC_state s) {
   GC_sourceLabelIndex i;
-  pointer p;
+  code_pointer p;
   GC_sourceSeqIndex sourceSeqIndex;
 
   sortSourceLabels (s);
   /* Initialize s->sourceMaps.textSources. */
-  s->sourceMaps.textEnd = (pointer)(GC_getTextEnd());
-  s->sourceMaps.textStart = (pointer)(GC_getTextStart());
+  s->sourceMaps.textEnd = GC_getTextEnd();
+  s->sourceMaps.textStart = GC_getTextStart();
   if (ASSERT)
     for (i = 0; i < s->sourceMaps.sourceLabelsLength; i++) {
-      pointer label;
+      code_pointer label;
 
       label = s->sourceMaps.sourceLabels[i].label;
       assert (0 == label
@@ -73,7 +73,7 @@
                   and label < s->sourceMaps.textEnd));
     }
   s->sourceMaps.textSources =
-    (uint32_t*)
+    (GC_sourceSeqIndex *)
     (calloc_safe((size_t)(s->sourceMaps.textEnd - s->sourceMaps.textStart), 
                  sizeof(*(s->sourceMaps.textSources))));
   p = s->sourceMaps.textStart;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.h	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/sources.h	2006-05-17 21:18:10 UTC (rev 4549)
@@ -36,7 +36,7 @@
 } *GC_source;
 
 typedef struct GC_sourceLabel {
-  pointer label;
+  code_pointer label;
   GC_sourceSeqIndex sourceSeqIndex;
 } *GC_sourceLabel;
 
@@ -63,12 +63,12 @@
    */
   struct GC_source *sources;
   uint32_t sourcesLength;
-  pointer textEnd;
+  code_pointer textEnd;
   /* An array of indices, one entry for each address in the text
    * segment, giving an index into sourceSeqs.
    */
   GC_sourceSeqIndex *textSources;
-  pointer textStart;
+  code_pointer textStart;
 };
 
 #endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/darwin.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/darwin.c	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/darwin.c	2006-05-17 21:18:10 UTC (rev 4549)
@@ -8,17 +8,17 @@
 #include "mmap-protect.c"
 #include "use-mmap.c"
 
-void *GC_getTextEnd (void) {
-        return (const void*)(long)(get_etext ());
+code_pointer GC_getTextEnd (void) {
+        return (code_pointer)(long)(get_etext ());
 }
 
-void *GC_getTextStart (void) {
+code_pointer GC_getTextStart (void) {
         void *address;
         const struct mach_header *mh;
 
         _dyld_lookup_and_bind ("_main", &address, 0);
         mh = _dyld_get_image_header_containing_address (address);
-        return mh;
+        return (code_pointer)mh;
 }
 
 void GC_displayMem (void) {
@@ -30,9 +30,9 @@
 }
 
 static void catcher (__attribute__ ((unused)) int sig,  
-                        __attribute__ ((unused)) siginfo_t *sip, 
-                        ucontext_t *ucp) {
-        GC_handleSigProf ((pointer) ucp->uc_mcontext->ss.srr0);
+                     __attribute__ ((unused)) siginfo_t *sip, 
+                     ucontext_t *ucp) {
+        GC_handleSigProf ((code_pointer) ucp->uc_mcontext->ss.srr0);
 }
 
 void GC_setSigProfHandler (struct sigaction *sa) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/freebsd.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/freebsd.c	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/freebsd.c	2006-05-17 21:18:10 UTC (rev 4549)
@@ -13,9 +13,9 @@
 }
 
 static void catcher (__attribute__ ((unused)) int sig,
-                        __attribute__ ((unused)) siginfo_t *sip, 
-                        ucontext_t *ucp) {
-        GC_handleSigProf ((pointer) ucp->uc_mcontext.mc_eip);
+                     __attribute__ ((unused)) siginfo_t *sip, 
+                     ucontext_t *ucp) {
+        GC_handleSigProf ((code_pointer) ucp->uc_mcontext.mc_eip);
 }
 
 void GC_setSigProfHandler (struct sigaction *sa) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/getText.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/getText.c	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/getText.c	2006-05-17 21:18:10 UTC (rev 4549)
@@ -1,11 +1,11 @@
 /* To get the beginning and end of the text segment. */
-extern char _start;
-extern char etext;
+extern unsigned char _start;
+extern unsigned char etext;
 
-void *GC_getTextStart (void) {
+code_pointer GC_getTextStart (void) {
         return &_start;
 }
 
-void *GC_getTextEnd (void) {
+code_pointer GC_getTextEnd (void) {
         return &etext;
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/hpux.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/hpux.c	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/hpux.c	2006-05-17 21:18:10 UTC (rev 4549)
@@ -12,14 +12,14 @@
 #include "mkdir2.c"
 #include "setenv.putenv.c"
 
-extern void *__text_start;
-extern void *etext;
+extern unsigned char __text_start;
+extern unsigned_char etext;
 
-void *getTextStart () {
+code_pointer getTextStart () {
         return &__text_start;
 }
 
-void *getTextEnd () {
+code_pointer getTextEnd () {
         return &etext;
 }
 
@@ -91,10 +91,10 @@
 
 
 static void catcher (__attribute__ ((unused)) int sig,
-                        __attribute__ ((unused)) siginfo_t* sip,
-                        void* mystery) {
+                     __attribute__ ((unused)) siginfo_t* sip,
+                     void* mystery) {
         ucontext_t* ucp = (ucontext_t*)mystery;
-        GC_handleSigProf ((pointer) (ucp->uc_link));
+        GC_handleSigProf ((code_pointer) (ucp->uc_link));
 }
 
 void GC_setSigProfHandler (struct sigaction *sa) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/linux.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/linux.c	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/linux.c	2006-05-17 21:18:10 UTC (rev 4549)
@@ -29,23 +29,23 @@
 #define REG_RIP REG_INDEX(rip) /* seems to be 16 */
 #endif
         ucontext_t* ucp = (ucontext_t*)mystery;
-        GC_handleSigProf ((pointer) ucp->uc_mcontext.gregs[REG_RIP]);
+        GC_handleSigProf ((code_pointer) ucp->uc_mcontext.gregs[REG_RIP]);
 #elif (defined (__hppa__))
         ucontext_t* ucp = (ucontext_t*)mystery;
-        GC_handleSigProf ((pointer) (ucp->uc_mcontext.sc_iaoq[0] & ~0x3UL));
+        GC_handleSigProf ((code_pointer) (ucp->uc_mcontext.sc_iaoq[0] & ~0x3UL));
 #elif (defined (__ppc__)) || (defined (__powerpc__))
         ucontext_t* ucp = (ucontext_t*)mystery;
-        GC_handleSigProf ((pointer) ucp->uc_mcontext.regs->nip);
+        GC_handleSigProf ((code_pointer) ucp->uc_mcontext.regs->nip);
 #elif (defined (__sparc__))
         struct sigcontext* scp = (struct sigcontext*)mystery;
 #if __WORDSIZE == 64
-        GC_handleSigProf ((pointer) scp->sigc_regs.tpc);
+        GC_handleSigProf ((code_pointer) scp->sigc_regs.tpc);
 #else
-        GC_handleSigProf ((pointer) scp->si_regs.pc);
+        GC_handleSigProf ((code_pointer) scp->si_regs.pc);
 #endif
 #elif (defined (__i386__))
         ucontext_t* ucp = (ucontext_t*)mystery;
-        GC_handleSigProf ((pointer) ucp->uc_mcontext.gregs[EIP]);
+        GC_handleSigProf ((code_pointer) ucp->uc_mcontext.gregs[EIP]);
 #else
 #error Profiling handler is missing for this architecture
 #endif

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/netbsd.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/netbsd.c	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/netbsd.c	2006-05-17 21:18:10 UTC (rev 4549)
@@ -8,9 +8,9 @@
 #include "use-mmap.c"
 
 static void catcher (__attribute__ ((unused)) int sig,
-                        __attribute__ ((unused)) int code, 
-                        struct sigcontext *ucp) {
-        GC_handleSigProf ((pointer) ucp->sc_eip);
+                     __attribute__ ((unused)) int code, 
+                     struct sigcontext *ucp) {
+        GC_handleSigProf ((code_pointer) ucp->sc_eip);
 }
 
 void GC_setSigProfHandler (struct sigaction *sa) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/openbsd.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/openbsd.c	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/openbsd.c	2006-05-17 21:18:10 UTC (rev 4549)
@@ -8,9 +8,9 @@
 #include "use-mmap.c"
 
 static void catcher (__attribute__ ((unused)) int sig,
-                        __attribute__ ((unused)) siginfo_t *sip,
-                        ucontext_t *ucp) {
-        GC_handleSigProf ((pointer) ucp->sc_eip);
+                     __attribute__ ((unused)) siginfo_t *sip,
+                     ucontext_t *ucp) {
+        GC_handleSigProf ((code_pointer) ucp->sc_eip);
 }
 
 void GC_setSigProfHandler (struct sigaction *sa) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform/solaris.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform/solaris.c	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform/solaris.c	2006-05-17 21:18:10 UTC (rev 4549)
@@ -71,7 +71,7 @@
 static void catcher (__attribute__ ((unused)) int sig,
                      __attribute__ ((unused)) siginfo_t *sip, 
                      ucontext_t *ucp) {
-        GC_handleSigProf ((pointer) ucp->uc_mcontext.gregs[REG_PC]);
+        GC_handleSigProf ((code_pointer) ucp->uc_mcontext.gregs[REG_PC]);
 }
 
 void GC_setSigProfHandler (struct sigaction *sa) {

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/platform.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/platform.h	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/platform.h	2006-05-17 21:18:10 UTC (rev 4549)
@@ -149,8 +149,8 @@
 /*                Text Segment                       */
 /* ------------------------------------------------- */
 
-void *GC_getTextEnd (void);
-void *GC_getTextStart (void);
+code_pointer GC_getTextEnd (void);
+code_pointer GC_getTextStart (void);
 
 /* ------------------------------------------------- */
 /*                SigProf Handler                    */

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/util/pointer.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/util/pointer.h	2006-05-16 03:02:10 UTC (rev 4548)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/util/pointer.h	2006-05-17 21:18:10 UTC (rev 4549)
@@ -13,3 +13,5 @@
 
 #define POINTER_SIZE sizeof(pointer)
 #define FMTPTR "0x%016"PRIxPTR
+
+typedef const unsigned char* code_pointer;