[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog engine/jitc.c engine/jitc_call.c...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog engine/jitc.c engine/jitc_call.c... |
Date: |
Sun, 01 Oct 2006 17:11:24 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Changes by: Klaus Treichel <ktreichel> 06/10/01 17:11:24
Modified files:
. : ChangeLog
engine : jitc.c jitc_call.c jitc_setup.c Makefile.am
Added files:
engine : jitc_profile.c
Log message:
Add simple method profiling support. The number of calls is counted but
the
summing of the executiontime per method is still TODO.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3365&r2=1.3366
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc.c?cvsroot=dotgnu-pnet&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_call.c?cvsroot=dotgnu-pnet&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_setup.c?cvsroot=dotgnu-pnet&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/Makefile.am?cvsroot=dotgnu-pnet&r1=1.88&r2=1.89
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_profile.c?cvsroot=dotgnu-pnet&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3365
retrieving revision 1.3366
diff -u -b -r1.3365 -r1.3366
--- ChangeLog 25 Sep 2006 18:34:07 -0000 1.3365
+++ ChangeLog 1 Oct 2006 17:11:23 -0000 1.3366
@@ -1,3 +1,16 @@
+2006-10-01 Klaus Treichel <address@hidden>
+
+ * engine/jitc.c: Implement _ILDumpMethodProfile and add the signature
for
+ ILInterlockedIncrement.
+
+ * engine/jitc_call.c, engine/jitc_setup.c: Emit the code for method
+ profiling on entry of a function or inlined calling of internal
functions
+ and pinvokes.
+
+ * engine/jitc_profile.c: Added for profiling functions.
+
+ * engine/Makefile.am: Add jitc_profile.c to jit coder sources.
+
2006-09-25 Kirill Kononenko <address@hidden>
* engine/jitc_pinvoke.c: Add missing jump target for the case that the
Index: engine/jitc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- engine/jitc.c 24 Sep 2006 18:16:21 -0000 1.50
+++ engine/jitc.c 1 Oct 2006 17:11:24 -0000 1.51
@@ -34,6 +34,7 @@
#endif
#include "lib_defs.h"
#include "jitc_gen.h"
+#include "interlocked.h"
#ifdef __cplusplus
extern "C" {
@@ -277,6 +278,11 @@
static ILJitType _ILJitSignature_MarshalCustomToObject = 0;
/*
+ * ILInt32 ILInterlockedIncrement(ILInt32 *destination)
+ */
+static ILJitType _ILJitSignature_ILInterlockedIncrement = 0;
+
+/*
* Define offsetof macro if not present.
*/
#ifndef offsetof
@@ -2269,6 +2275,14 @@
return 0;
}
+ args[0] = _IL_JIT_TYPE_VPTR;
+ returnType = _IL_JIT_TYPE_INT32;
+ if(!(_ILJitSignature_ILInterlockedIncrement =
+ jit_type_create_signature(IL_JIT_CALLCONV_CDECL, returnType,
args, 1, 1)))
+ {
+ return 0;
+ }
+
return 1;
}
/*
@@ -3028,6 +3042,7 @@
return 0;
}
+#include "jitc_profile.c"
#include "jitc_alloc.c"
#include "jitc_delegate.c"
#include "jitc_pinvoke.c"
@@ -3832,8 +3847,101 @@
*/
int _ILDumpMethodProfile(FILE *stream, ILExecProcess *process)
{
- /* TODO */
+ ILJITCoder *coder = (ILJITCoder *)(process->coder);
+ ILUInt32 count = 0;
+ ILUInt32 current = 0;
+ ILJitFunction function = 0;
+ int haveCounts = 0;
+ ILMethod *method;
+ ILMethod **methods;
+ ILMethod **temp;
+
+ /* Get the number of created and called functions */
+ function = jit_function_next(coder->context, 0);
+ while(function)
+ {
+ method = (ILMethod *)jit_function_get_meta(function,
IL_JIT_META_METHOD);
+ if(method)
+ {
+ if(method->count > 0)
+ {
+ count++;
+ }
+ }
+ function = jit_function_next(coder->context, function);
+ }
+
+ /* Allocate the array for the methods. */
+ if(!(methods = (ILMethod **)ILMalloc((count + 1) * sizeof(ILMethod *))))
+ {
return 0;
+ }
+
+ /* Now fill the array. */
+ function = jit_function_next(coder->context, 0);
+ while(function)
+ {
+ method = (ILMethod *)jit_function_get_meta(function,
IL_JIT_META_METHOD);
+ if(method)
+ {
+ if((method->count > 0) && (current < count))
+ {
+ methods[current] = method;
+ current++;
+ }
+ }
+ function = jit_function_next(coder->context, function);
+ }
+ /* Mark the end of the list. */
+ methods[current] = 0;
+
+ /* Sort the method list into decreasing order of count */
+ if(methods[0] != 0 && methods[1] != 0)
+ {
+ ILMethod **outer;
+ ILMethod **inner;
+ for(outer = methods; outer[1] != 0; ++outer)
+ {
+ for(inner = outer + 1; inner[0] != 0; ++inner)
+ {
+ if(outer[0]->count < inner[0]->count)
+ {
+ method = outer[0];
+ outer[0] = inner[0];
+ inner[0] = method;
+ }
+ }
+ }
+ }
+
+ /* Print the method information */
+ temp = methods;
+#ifdef ENHANCED_PROFILER
+ printf (" Count Total Average\n time time\n");
+#endif
+ while((method = *temp++) != 0)
+ {
+ if(!(method->count))
+ {
+ continue;
+ }
+#ifdef ENHANCED_PROFILER
+ printf("%8lu %8lu %8lu ", (unsigned long)(method->count),
+ (unsigned long)(method->time), (unsigned
long)(method->time) / (unsigned long)(method->count));
+#else
+ printf("%8lu ", (unsigned long)(method->count));
+#endif
+ ILDumpMethodType(stdout, ILProgramItem_Image(method),
+ ILMethod_Signature(method), 0,
+ ILMethod_Owner(method),
ILMethod_Name(method), 0);
+ putc('\n', stdout);
+ haveCounts = 1;
+ }
+
+ /* Clean up and exit */
+
+ ILFree(methods);
+ return haveCounts;
}
#endif /* !IL_CONFIG_REDUCE_CODE */
Index: engine/jitc_call.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc_call.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- engine/jitc_call.c 24 Sep 2006 18:16:21 -0000 1.24
+++ engine/jitc_call.c 1 Oct 2006 17:11:24 -0000 1.25
@@ -647,6 +647,14 @@
{
ILJitValue thread = _ILJitCoderGetThread(jitCoder);
+ #ifndef IL_CONFIG_REDUCE_CODE
+ /* Emit the code to increase the call count of the method if
profiling is enabled. */
+ if(jitCoder->flags & IL_CODER_FLAG_METHOD_PROFILE)
+ {
+ _ILJitProfileIncreaseMethodCallCount(jitCoder,
methodInfo);
+ }
+ #endif
+
/* Call the engine function directly with the supplied args. */
JITC_ADJUST(jitCoder, -argCount);
returnValue = _ILJitCallInternal(jitCoder->jitFunction, thread,
@@ -700,6 +708,13 @@
ILPInvoke *pinv = ILPInvokeFind(methodInfo);
if(pinv &&
((ILJitMethodInfo*)(methodInfo->userData))->fnInfo.func)
{
+ #ifndef IL_CONFIG_REDUCE_CODE
+ /* Emit the code to increase the call count of the
method if profiling is enabled. */
+ if(jitCoder->flags & IL_CODER_FLAG_METHOD_PROFILE)
+ {
+ _ILJitProfileIncreaseMethodCallCount(jitCoder,
methodInfo);
+ }
+ #endif
returnValue = _ILJitInlinePinvoke(jitCoder, methodInfo,
jitParams);
}
else
Index: engine/jitc_setup.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc_setup.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- engine/jitc_setup.c 17 Sep 2006 18:32:31 -0000 1.18
+++ engine/jitc_setup.c 1 Oct 2006 17:11:24 -0000 1.19
@@ -49,6 +49,14 @@
}
#endif
+#ifndef IL_CONFIG_REDUCE_CODE
+ /* Emit the code to increase the call count of the method if profiling
is enabled. */
+ if(coder->flags & IL_CODER_FLAG_METHOD_PROFILE)
+ {
+ _ILJitProfileIncreaseMethodCallCount(coder, method);
+ }
+#endif
+
if(ILMethod_IsStaticConstructor(method))
{
/* We have to take care that the method is executed only once.
*/
Index: engine/Makefile.am
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/Makefile.am,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -b -r1.88 -r1.89
--- engine/Makefile.am 11 Jul 2006 17:29:37 -0000 1.88
+++ engine/Makefile.am 1 Oct 2006 17:11:24 -0000 1.89
@@ -27,6 +27,7 @@
jitc_locals.c \
jitc_obj.c \
jitc_pinvoke.c \
+ jitc_profile.c \
jitc_ptr.c \
jitc_setup.c \
jitc_stack.c \
Index: engine/jitc_profile.c
===================================================================
RCS file: engine/jitc_profile.c
diff -N engine/jitc_profile.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ engine/jitc_profile.c 1 Oct 2006 17:11:24 -0000 1.1
@@ -0,0 +1,53 @@
+/*
+ * jitc_profile.c - Profiling functions for the JIT Coder.
+ *
+ * Copyright (C) 2001 Southern Storm Software, Pty Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Emit the code to increase the call count of a method.
+ */
+static void _ILJitProfileIncreaseMethodCallCount(ILJITCoder *jitCoder,
ILMethod *method)
+{
+ ILJitValue callCounter =
jit_value_create_nint_constant(jitCoder->jitFunction,
+
_IL_JIT_TYPE_VPTR,
+
(jit_nint)(&(method->count)));
+#ifdef ENHANCED_PROFILER
+ /* If the enhanced profiler is selected then don't count when
+ * profiling is disabled
+ * (e.g. via DotGNU.Misc.Profiling.StopProfiling())
+ */
+ jit_label_t label = jit_label_undefined;
+ ILJitValue thread = _ILJitCoderGetThread(jitCoder);
+ ILJitValue profilingEnabled =
jit_insn_load_relative(jitCoder->jitFunction,
+
thread,
+
offsetof(ILExecThread, profilingEnabled),
+
jit_type_sys_int);
+ jit_insn_branch_if_not(jitCoder->jitFunction, profilingEnabled, &label);
+#endif
+
+ jit_insn_call_native(jitCoder->jitFunction,
+ "ILInterlockedIncrement",
+ ILInterlockedIncrement,
+
_ILJitSignature_ILInterlockedIncrement,
+ &callCounter, 1,
JIT_CALL_NOTHROW);
+#ifdef ENHANCED_PROFILER
+ jit_insn_label(jitCoder->jitFunction, &label);
+#endif
+}
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ChangeLog engine/jitc.c engine/jitc_call.c...,
Klaus Treichel <=