dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnet ChangeLog engine/engine.h engine/jitc.c en...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog engine/engine.h engine/jitc.c en...
Date: Mon, 29 Sep 2008 10:53:07 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      08/09/29 10:53:07

Modified files:
        .              : ChangeLog 
        engine         : engine.h jitc.c jitc_profile.c lib_profiling.c 
        image          : program.h 
        include        : il_system.h 
        support        : time.c 

Log message:
        Change enhanced profiling to use a performance counter instead of time.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3567&r2=1.3568
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/engine.h?cvsroot=dotgnu-pnet&r1=1.127&r2=1.128
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc.c?cvsroot=dotgnu-pnet&r1=1.86&r2=1.87
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_profile.c?cvsroot=dotgnu-pnet&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/lib_profiling.c?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/pnet/image/program.h?cvsroot=dotgnu-pnet&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/pnet/include/il_system.h?cvsroot=dotgnu-pnet&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/pnet/support/time.c?cvsroot=dotgnu-pnet&r1=1.21&r2=1.22

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3567
retrieving revision 1.3568
diff -u -b -r1.3567 -r1.3568
--- ChangeLog   21 Sep 2008 17:40:36 -0000      1.3567
+++ ChangeLog   29 Sep 2008 10:53:06 -0000      1.3568
@@ -1,3 +1,26 @@
+2008-09-29  Klaus Treichel  <address@hidden>
+
+       * engine/engine.h (_ILProfilingStart, _ILProfilingEnd): Change the
+       profiling timestamp to the performance counter.
+
+       * engine/jitc.c: Remove the now obsolete jit type for ILCurrTime.
+
+       * engine/jitc_profile.c (_ILJitProfileStart, _ILJitProfileEnd): Replace 
the
+       timestamp with the performance counter.
+
+       * engine/lib_profiling (_ILProfilingStart, _ILProfilingEnd): Use the new
+       functions in support/time.c now to get the performance counter.
+
+       * image/progam.h: Change the profile time counter from ILUInt32 to 
ILUInt64
+       to be able to hold a performance counter.
+
+       * include/il_system.h (ILGetLocalTime, ILGetPerformanceCounterFrequency,
+       ILGetPerformanceCounter): Add prototypes.
+
+       * support/time.c (ILGetLocalTime): Add function to retrieve the local 
time.
+       (ILGetPerformanceCounterFrequency, ILGetPerformanceCounter): Add 
functions
+       for performance counter access.
+
 2008-09-21  Klaus Treichel  <address@hidden>
 
        * engine/jitc.c (ILJitGetVtablePointer): Add function to get the jit

Index: engine/engine.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/engine.h,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -b -r1.127 -r1.128
--- engine/engine.h     24 Aug 2008 17:45:29 -0000      1.127
+++ engine/engine.h     29 Sep 2008 10:53:06 -0000      1.128
@@ -911,18 +911,18 @@
 int _ILProfilingDump(FILE *stream, ILMethod **methods);
 #ifdef ENHANCED_PROFILER
 /*
- * Get the start profiling timestamp.
+ * Get the start profiling performance counter.
  */
-void _ILProfilingStart(ILCurrTime *timestamp);
+void _ILProfilingStart(ILInt64 *start);
 
 /*
  * End profiling for the method given and add the difference between the
- * timestamp given and the current time to the total execution time of
- * the method.
+ * performance counter given and the current performance counter to the total
+ * execution time of the method.
  * Increase the execution counter here too so that the number of executions
  * and spent time in the method matches.
  */
-void _ILProfilingEnd(ILMethod *method, ILCurrTime *startTimestamp);
+void _ILProfilingEnd(ILMethod *method, ILInt64 *start);
 #endif /* ENHANCED_PROFILER */
 #endif /* !IL_CONFIG_REDUCE_CODE && !IL_WITHOUT_TOOLS */
 

Index: engine/jitc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -b -r1.86 -r1.87
--- engine/jitc.c       21 Sep 2008 17:40:37 -0000      1.86
+++ engine/jitc.c       29 Sep 2008 10:53:06 -0000      1.87
@@ -153,15 +153,6 @@
 static ILObject *_ILJitAllocTyped(ILClass *classInfo);
 #endif /* IL_USE_TYPED_ALLOCATION */
 
-#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
-#ifdef ENHANCED_PROFILER
-/*
- * Type for the ILCurrTime used by profiling.
- */
-static ILJitType _ILJitTypeCurrTime = 0;
-#endif /* ENHANCED_PROFILER */
-#endif /* !IL_CONFIG_REDUCE_CODE && !IL_WITHOUT_TOOLS */
-
 /*
  * Definition of signatures of internal functions used by jitted code.
  * They have to be kept in sync with the corresponding engine funcions.
@@ -2313,18 +2304,6 @@
                                                                        
_IL_ALIGN_FOR_TYPE(void_p));
        _ILJitTypesInitBase(&_ILJitType_TYPEDREF, _ILJitTypedRef);
 
-#ifndef IL_CONFIG_REDUCE_CODE
-#ifdef ENHANCED_PROFILER
-       if(!(_ILJitTypeCurrTime = jit_type_create_struct(0, 0, 0)))
-       {
-               return 0;
-       }
-       jit_type_set_size_and_alignment(_ILJitTypeCurrTime,
-                                                                       
sizeof(ILCurrTime),
-                                                                       
_IL_ALIGN_FOR_TYPE(void_p));
-#endif /* ENHANCED_PROFILER */
-#endif /* !IL_CONFIG_REDUCE_CODE */
-
        /* Initialize the native method signatures. */
        returnType = _IL_JIT_TYPE_VPTR;
        if(!(_ILJitSignature_ILExecThreadCurrent = 

Index: engine/jitc_profile.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc_profile.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- engine/jitc_profile.c       24 Aug 2008 17:45:32 -0000      1.2
+++ engine/jitc_profile.c       29 Sep 2008 10:53:06 -0000      1.3
@@ -92,7 +92,7 @@
        if(!jitCoder->inlineTimestamp)
        {
                if(!(jitCoder->inlineTimestamp = 
jit_value_create(jitCoder->jitFunction,
-                                                                               
                                  _ILJitTypeCurrTime)))
+                                                                               
                                  _IL_JIT_TYPE_INT64)))
                {
                        return;
                } 
@@ -178,7 +178,7 @@
        if(!jitCoder->profileTimestamp)
        {
                if(!(jitCoder->profileTimestamp = 
jit_value_create(jitCoder->jitFunction,
-                                                                               
                                   _ILJitTypeCurrTime)))
+                                                                               
                                   _IL_JIT_TYPE_INT64)))
                {
                        return;
                } 

Index: engine/lib_profiling.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_profiling.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- engine/lib_profiling.c      25 Aug 2008 06:05:16 -0000      1.4
+++ engine/lib_profiling.c      29 Sep 2008 10:53:06 -0000      1.5
@@ -106,12 +106,30 @@
 }
 
 #ifdef ENHANCED_PROFILER
+static ILInt64 GetCurrentTime()
+{
+       ILCurrTime timeValue;
+
+       ILGetLocalTime(&timeValue);
+
+       return (timeValue.secs * (ILInt64)10000000) +
+                               (ILInt64)(timeValue.nsecs / (ILUInt32)100);
+}
+
 /*
  * Get the start profiling timestamp.
  */
-void _ILProfilingStart(ILCurrTime *timestamp)
+void _ILProfilingStart(ILInt64 *start)
 {
-       ILGetSinceRebootTime(timestamp);
+       if(!start)
+       {
+               return;
+       }
+
+       if(!ILGetPerformanceCounter(start))
+       {
+               *start = GetCurrentTime();
+       }
 }
 
 /*
@@ -121,35 +139,21 @@
  * Increase the execution counter here too so that the number of executions
  * and spent time in the method matches.
  */
-void _ILProfilingEnd(ILMethod *method, ILCurrTime *startTimestamp)
+void _ILProfilingEnd(ILMethod *method, ILInt64 *start)
 {
-       ILCurrTime timestamp;
-       ILInt64 seconds;
-       ILUInt32 nanoSeconds;
-       ILUInt32 timeDiff;
+       ILInt64 end;
 
-       if(!method || !startTimestamp)
+       if(!method || !start)
        {
                return;
        }
 
-       ILGetSinceRebootTime(&timestamp);
-
-       if(timestamp.nsecs < startTimestamp->nsecs)
+       if(!ILGetPerformanceCounter(&end))
        {
-               seconds = timestamp.secs - startTimestamp->secs - 1;
-               nanoSeconds = (timestamp.nsecs + 1000000000) - 
startTimestamp->nsecs;
+               end = GetCurrentTime();
        }
-       else
-       {
-               seconds = timestamp.secs - startTimestamp->secs;
-               nanoSeconds = timestamp.nsecs - startTimestamp->nsecs;
-       }
-
-       /* calculate the timedifference in microseconds */
-       timeDiff = (seconds * 1000000) + (nanoSeconds / 1000);
 
-       method->time += timeDiff;
+       method->time += (end - *start); 
        ++method->count;
 }
 #endif /* ENHANCED_PROFILER */

Index: image/program.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/program.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- image/program.h     30 Oct 2007 17:35:23 -0000      1.28
+++ image/program.h     29 Sep 2008 10:53:06 -0000      1.29
@@ -384,7 +384,7 @@
        ILUInt32                index;                          /* Data added 
by the runtime engine */
        ILUInt32                count;                          /* Profile 
count for the engine */
 #ifdef ENHANCED_PROFILER
-       ILUInt32                time;                           /* Profile time 
counter for the engine */
+       ILUInt64                time;                           /* Profile time 
counter for the engine */
 #endif
 };
 

Index: include/il_system.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/include/il_system.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- include/il_system.h 19 Sep 2003 02:12:44 -0000      1.19
+++ include/il_system.h 29 Sep 2008 10:53:07 -0000      1.20
@@ -119,15 +119,26 @@
    Use "ILFree" to free the path later */
 int ILFileExists(const char *filename, char **newExePath);
 
-/* Get the current time in nanoseconds since 12:00am Jan 1, 0001 */
+/* 
+ * Internal representation of a time in nanoseconds since 12:00am Jan 1, 0001
+ */
 typedef struct
 {
        ILInt64                 secs;
        ILUInt32                nsecs;
 
 } ILCurrTime;
+
+/*
+ * Get the current UTC time relative to Jan 01, 0001
+ */
 void ILGetCurrTime(ILCurrTime *timeValue);
 
+/*
+ * Get the current local time relative to Jan 01, 0001
+ */
+void ILGetLocalTime(ILCurrTime *timeValue);
+
 /* Get the current time in nanoseconds since the system was rebooted.
    If it isn't possible to get the since-reboot time, this returns zero */
 int ILGetSinceRebootTime(ILCurrTime *timeValue);
@@ -141,6 +152,14 @@
 /* Convert a time_t time to a DateTime time */
 ILInt64 ILUnixToCLITime(ILInt64 timeValue);
 
+/* Get the frequency of the perfornamce counter.
+   If no high res counter/timer is available zero is returned. */
+ILBool ILGetPerformanceCounterFrequency(ILInt64 *frequency);
+
+/* Get the current performance counter,
+   If no high res counter/timer is available zero is returned. */
+ILBool ILGetPerformanceCounter(ILInt64 *counter);
+
 /* Get platform directory pathname information */
 typedef struct
 {

Index: support/time.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/time.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- support/time.c      14 Aug 2008 08:51:25 -0000      1.21
+++ support/time.c      29 Sep 2008 10:53:07 -0000      1.22
@@ -2,7 +2,7 @@
  * time.c - Get the current system time.
  *
  * Copyright (C) 2001  Southern Storm Software, Pty Ltd.
- * Copyright (C) 2004  Free Software Foundation
+ * Copyright (C) 2004, 2008  Free Software Foundation
  *
  * Contributions from Thong Nguyen (address@hidden)
  *
@@ -79,6 +79,9 @@
  */
 #define        PALM_EPOCH_ADJUST       ((ILInt64)60052752000LL)
 
+/*
+ * Get the current UTC time relative to Jan 01, 0001
+ */
 void ILGetCurrTime(ILCurrTime *timeValue)
 {
 #ifdef HAVE_GETTIMEOFDAY
@@ -209,6 +212,84 @@
        return (timeValue + EPOCH_ADJUST) * (ILInt64)10000000;
 }
 
+/*
+ * Get the current local time relative to Jan 01, 0001
+ */
+void ILGetLocalTime(ILCurrTime *timeValue)
+{
+       ILGetCurrTime(timeValue);
+
+       timeValue->secs -= (ILInt64)(ILGetTimeZoneAdjust());
+}
+
+ILBool ILGetPerformanceCounterFrequency(ILInt64 *frequency)
+{
+       if(!frequency)
+       {
+               return (ILBool)0;
+       }
+       else
+       {
+#ifdef IL_WIN32_PLATFORM
+               LARGE_INTEGER freq;
+
+               if(QueryPerformanceFrequency(&freq))
+               {
+                       *frequency = (ILInt64)(freq.QuadPart);
+                       return (ILBool)1;
+               }
+#elif defined(HAVE_CLOCK_GETTIME) && \
+         (defined(CLOCK_PROCESS_CPUTIME_ID) || defined(CLOCK_MONOTONIC))
+               *frequency = 1000000000L;
+               return (ILBool)1;
+#endif
+       }
+       *frequency = 10000000L;
+       return (ILBool)0;
+}
+
+ILBool ILGetPerformanceCounter(ILInt64 *counter)
+{
+       if(!counter)
+       {
+               return (ILBool)0;
+       }
+       else
+       {
+#ifdef IL_WIN32_PLATFORM
+               LARGE_INTEGER ctr;
+
+               if(QueryPerformanceCounter(&ctr))
+               {
+                       *counter = (ILInt64)(ctr.QuadPart);
+                       return (ILBool)1;
+               }
+#elif defined(HAVE_CLOCK_GETTIME) && \
+         (defined(CLOCK_PROCESS_CPUTIME_ID) || defined(CLOCK_MONOTONIC))
+               struct timespec tp;
+               /*
+                * i'd prefer to use CLOCK_PROCESS_CPUTIME_ID in first place
+                * but the resolution of this timer is too low on some systems.
+                */
+#if defined(CLOCK_MONOTONIC)
+               if(clock_gettime(CLOCK_MONOTONIC, &tp) != 0)
+               {
+                       return (ILBool)0;
+               }
+#else
+               if(clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp) != 0)
+               {
+                       return (ILBool)0;
+               }
+#endif
+               *counter = ((tp.tv_sec * 1000000000L) + (ILInt64)tp.tv_nsec);
+               return (ILBool)1;
+#endif
+       }
+       /* TODO: return the local time if we get here */
+       return (ILBool)0;
+}
+
 #ifdef __cplusplus
 };
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]