* src/vm/rt-timing.h: Likewise.
* src/vm/jit/jit.c: Moved real-time timing stuff to rt-timing.[ch]
* src/vm/jit/jit.h: Likewise.
* src/vm/vm.c (vm_exit_handler): Call rt_timing_print_time_stats.
* src/vm/Makefile.am (rt-timing.c, rt-timing.h): Added.
##
## Changes:
##
-## $Id: Makefile.am 4693 2006-03-28 10:42:04Z twisti $
+## $Id: Makefile.am 4762 2006-04-12 22:20:49Z edwin $
## Process this file with automake to produce Makefile.in
statistics.h
endif
+if ENABLE_RT_TIMING
+RT_TIMING_OBJ = \
+ rt-timing.c
+endif
+
if ENABLE_ZLIB
ZLIB_OBJ = \
zip.c \
references.h \
resolve.c \
resolve.h \
+ $(RT_TIMING_OBJ) \
+ rt-timing.h \
$(STATISTICS_OBJ) \
signal.c \
signallocal.h \
Christian Thalinger
Christian Ullrich
- $Id: jit.c 4737 2006-04-05 12:56:43Z edwin $
+ $Id: jit.c 4762 2006-04-12 22:20:49Z edwin $
*/
#include <assert.h>
-#if defined(ENABLE_RT_TIMING)
-#include <time.h>
-#include <errno.h>
-#endif
-
#include "mm/memory.h"
#include "native/native.h"
#include "toolbox/logging.h"
#include "vm/jit/loop/graph.h"
#include "vm/jit/loop/loop.h"
#include "vm/jit/verify/typecheck.h"
+#include "vm/rt-timing.h"
#if defined(USE_THREADS)
# if defined(NATIVE_THREADS)
return r;
}
-/*****************************************************************************/
-/* TIMING OF COMPILER PASSES */
-/*****************************************************************************/
-
-#if defined(ENABLE_RT_TIMING)
-
-#define JIT_GET_TIME(ts) \
- do { if (clock_gettime(CLOCK_THREAD_CPUTIME_ID,&(ts)) != 0) { \
- fprintf(stderr,"could not get time: %s\n",strerror(errno)); \
- abort(); \
- }} while (0)
-
-#define JITTIME_CHECKS 0
-#define JITTIME_PARSE 1
-#define JITTIME_STACK 2
-#define JITTIME_TYPECHECK 3
-#define JITTIME_LOOP 4
-#define JITTIME_IFCONV 5
-#define JITTIME_ALLOC 6
-#define JITTIME_RPLPOINTS 7
-#define JITTIME_CODEGEN 8
-#define JITTIME_TOTAL 9
-#define JITTIME_N 10
-
-struct jit_time_stat {
- int index;
- const char *name;
-};
-
-static struct jit_time_stat jit_time_stat_defs[] = {
- { JITTIME_CHECKS, "checks at beginning" },
- { JITTIME_PARSE, "parse" },
- { JITTIME_STACK, "analyse_stack" },
- { JITTIME_TYPECHECK, "typecheck" },
- { JITTIME_LOOP, "loop" },
- { JITTIME_IFCONV, "if conversion" },
- { JITTIME_ALLOC, "register allocation" },
- { JITTIME_RPLPOINTS, "replacement point generation" },
- { JITTIME_CODEGEN, "codegen" },
- { JITTIME_TOTAL, "total" },
- { 0, NULL }
-};
-
-static long long jit_time_sum[JITTIME_N] = { 0 };
-
-static long jit_time_diff_usec(struct timespec *a,struct timespec *b)
-{
- long diff;
- time_t atime;
-
- diff = (b->tv_nsec - a->tv_nsec) / 1000;
- atime = a->tv_sec;
- while (atime < b->tv_sec) {
- atime++;
- diff += 1000000;
- }
- return diff;
-}
-
-static void jit_time_diff(struct timespec *a,struct timespec *b,int index)
-{
- long diff;
-
- diff = jit_time_diff_usec(a,b);
- jit_time_sum[index] += diff;
-}
-
-void jit_print_time_stats(FILE *file)
-{
- struct jit_time_stat *stats;
- double total;
-
- stats = jit_time_stat_defs;
- total = jit_time_sum[JITTIME_TOTAL];
- while (stats->name) {
- fprintf(file,"%12lld usec %3.0f%% %s\n",
- jit_time_sum[stats->index],
- (total != 0.0) ? jit_time_sum[stats->index] / total * 100.0 : 0.0,
- stats->name);
- stats++;
- }
-}
-
-#else /* !defined(ENABLE_RT_TIMING) */
-
-#define JIT_GET_TIME(ts)
-
-#endif /* defined(ENABLE_RT_TIMING) */
-
/* jit_compile_intern **********************************************************
Static internal function which does the actual compilation.
time_rplpoints,time_codegen;
#endif
- JIT_GET_TIME(time_start);
+ RT_TIMING_GET_TIME(time_start);
/* get required compiler data */
}
#endif
- JIT_GET_TIME(time_checks);
+ RT_TIMING_GET_TIME(time_checks);
/* call the compiler passes ***********************************************/
return NULL;
}
- JIT_GET_TIME(time_parse);
+ RT_TIMING_GET_TIME(time_parse);
DEBUG_JIT_COMPILEVERBOSE("Parsing done: ");
DEBUG_JIT_COMPILEVERBOSE("Analysing: ");
return NULL;
}
- JIT_GET_TIME(time_stack);
+ RT_TIMING_GET_TIME(time_stack);
DEBUG_JIT_COMPILEVERBOSE("Analysing done: ");
DEBUG_JIT_COMPILEVERBOSE("Typechecking done: ");
}
#endif
- JIT_GET_TIME(time_typecheck);
+ RT_TIMING_GET_TIME(time_typecheck);
#if defined(ENABLE_LOOP)
if (opt_loops) {
optimize_loops(jd);
}
#endif
- JIT_GET_TIME(time_loop);
+ RT_TIMING_GET_TIME(time_loop);
#if defined(ENABLE_IFCONV)
if (jd->flags & JITDATA_FLAG_IFCONV)
if (!ifconv_static(jd))
return NULL;
#endif
- JIT_GET_TIME(time_ifconv);
+ RT_TIMING_GET_TIME(time_ifconv);
#if defined(ENABLE_JIT)
# if defined(ENABLE_INTRP)
}
# endif
#endif /* defined(ENABLE_JIT) */
- JIT_GET_TIME(time_alloc);
+ RT_TIMING_GET_TIME(time_alloc);
/* Allocate memory for basic block profiling information. This
_must_ be done after loop optimization and register allocation,
if (!replace_create_replacement_points(jd))
return NULL;
- JIT_GET_TIME(time_rplpoints);
+ RT_TIMING_GET_TIME(time_rplpoints);
/* now generate the machine code */
return NULL;
}
#endif
- JIT_GET_TIME(time_codegen);
+ RT_TIMING_GET_TIME(time_codegen);
DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
m->code = code;
#if defined(ENABLE_RT_TIMING)
- jit_time_diff(&time_start,&time_checks,JITTIME_CHECKS);
- jit_time_diff(&time_checks,&time_parse,JITTIME_PARSE);
- jit_time_diff(&time_parse,&time_stack,JITTIME_STACK);
- jit_time_diff(&time_stack,&time_typecheck,JITTIME_TYPECHECK);
- jit_time_diff(&time_typecheck,&time_loop,JITTIME_LOOP);
- jit_time_diff(&time_loop,&time_alloc,JITTIME_ALLOC);
- jit_time_diff(&time_alloc,&time_rplpoints,JITTIME_RPLPOINTS);
- jit_time_diff(&time_rplpoints,&time_codegen,JITTIME_CODEGEN);
- jit_time_diff(&time_start,&time_codegen,JITTIME_TOTAL);
+ rt_timing_time_diff(&time_start,&time_checks,RT_TIMING_JIT_CHECKS);
+ rt_timing_time_diff(&time_checks,&time_parse,RT_TIMING_JIT_PARSE);
+ rt_timing_time_diff(&time_parse,&time_stack,RT_TIMING_JIT_STACK);
+ rt_timing_time_diff(&time_stack,&time_typecheck,RT_TIMING_JIT_TYPECHECK);
+ rt_timing_time_diff(&time_typecheck,&time_loop,RT_TIMING_JIT_LOOP);
+ rt_timing_time_diff(&time_loop,&time_alloc,RT_TIMING_JIT_ALLOC);
+ rt_timing_time_diff(&time_alloc,&time_rplpoints,RT_TIMING_JIT_RPLPOINTS);
+ rt_timing_time_diff(&time_rplpoints,&time_codegen,RT_TIMING_JIT_CODEGEN);
+ rt_timing_time_diff(&time_start,&time_codegen,RT_TIMING_JIT_TOTAL);
#endif
/* return pointer to the methods entry point */
Changes: Christian Thalinger
Edwin Steiner
- $Id: jit.h 4758 2006-04-12 17:51:10Z edwin $
+ $Id: jit.h 4762 2006-04-12 22:20:49Z edwin $
*/
void intrp_md_init(void);
#endif
-#if defined(ENABLE_RT_TIMING)
-void jit_print_time_stats(FILE *file);
-#endif
-
#endif /* _JIT_H */
--- /dev/null
+/* src/vm/rt-timing.c - POSIX real-time timing utilities
+
+ Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, Institut f. Computersprachen - TU Wien
+
+ This file is part of CACAO.
+
+ 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, 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Contact: cacao@cacaojvm.org
+
+ Authors: Edwin Steiner
+
+ Changes:
+
+ $Id$
+
+*/
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include <assert.h>
+#include <time.h>
+#include <errno.h>
+
+#include "vm/rt-timing.h"
+#include "mm/memory.h"
+#include "vm/global.h"
+
+struct rt_timing_stat {
+ int index;
+ const char *name;
+};
+
+static struct rt_timing_stat rt_timing_stat_defs[] = {
+ { RT_TIMING_CHECKS, "checks at beginning" },
+ { RT_TIMING_PARSE, "parse" },
+ { RT_TIMING_STACK, "analyse_stack" },
+ { RT_TIMING_TYPECHECK, "typecheck" },
+ { RT_TIMING_LOOP, "loop" },
+ { RT_TIMING_IFCONV, "if conversion" },
+ { RT_TIMING_ALLOC, "register allocation" },
+ { RT_TIMING_RPLPOINTS, "replacement point generation" },
+ { RT_TIMING_CODEGEN, "codegen" },
+ { RT_TIMING_TOTAL, "total" },
+ { 0, NULL }
+};
+
+static long long rt_timing_sum[RT_TIMING_N] = { 0 };
+
+void rt_timing_gettime(struct timespec *ts)
+{
+ if (clock_gettime(CLOCK_THREAD_CPUTIME_ID,ts) != 0) {
+ fprintf(stderr,"could not get time by clock_gettime: %s\n",strerror(errno));
+ abort();
+ }
+}
+
+static long rt_timing_diff_usec(struct timespec *a,struct timespec *b)
+{
+ long diff;
+ time_t atime;
+
+ diff = (b->tv_nsec - a->tv_nsec) / 1000;
+ atime = a->tv_sec;
+ while (atime < b->tv_sec) {
+ atime++;
+ diff += 1000000;
+ }
+ return diff;
+}
+
+void rt_timing_diff(struct timespec *a,struct timespec *b,int index)
+{
+ long diff;
+
+ diff = rt_timing_diff_usec(a,b);
+ rt_timing_sum[index] += diff;
+}
+
+void rt_timing_print_time_stats(FILE *file)
+{
+ struct rt_timing_stat *stats;
+ double total;
+
+ stats = rt_timing_stat_defs;
+ total = rt_timing_sum[RT_TIMING_TOTAL];
+ while (stats->name) {
+ fprintf(file,"%12lld usec %3.0f%% %s\n",
+ rt_timing_sum[stats->index],
+ (total != 0.0) ? rt_timing_sum[stats->index] / total * 100.0 : 0.0,
+ stats->name);
+ stats++;
+ }
+}
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
--- /dev/null
+/* src/vm/rt-timing.h - POSIX real-time timing utilities
+
+ Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, Institut f. Computersprachen - TU Wien
+
+ This file is part of CACAO.
+
+ 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, 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Contact: cacao@cacaojvm.org
+
+ Authors: Edwin Steiner
+
+ Changes:
+
+ $Id$
+
+*/
+
+#ifndef _RT_TIMING_H
+#define _RT_TIMING_H
+
+#if defined(ENABLE_RT_TIMING)
+
+#include "config.h"
+#include "vm/types.h"
+
+#include <time.h>
+
+#include "mm/memory.h"
+#include "vm/global.h"
+
+#define RT_TIMING_GET_TIME(ts) \
+ rt_timing_gettime(&(ts));
+
+#define RT_TIMING_JIT_CHECKS 0
+#define RT_TIMING_JIT_PARSE 1
+#define RT_TIMING_JIT_STACK 2
+#define RT_TIMING_JIT_TYPECHECK 3
+#define RT_TIMING_JIT_LOOP 4
+#define RT_TIMING_JIT_IFCONV 5
+#define RT_TIMING_JIT_ALLOC 6
+#define RT_TIMING_JIT_RPLPOINTS 7
+#define RT_TIMING_JIT_CODEGEN 8
+#define RT_TIMING_JIT_TOTAL 9
+#define RT_TIMING_N 10
+
+void rt_timing_diff(struct timespec *a,struct timespec *b,int index);
+
+void rt_timing_print_time_stats(FILE *file);
+
+#else /* !defined(ENABLE_RT_TIMING) */
+
+#define RT_TIMING_GET_TIME(ts)
+
+#endif /* defined(ENABLE_RT_TIMING) */
+
+#endif /* _RT_TIMING_H */
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
#include "vm/jit/jit.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/profile/profile.h"
+#include "vm/rt-timing.h"
#if defined(ENABLE_JVMTI)
#include "native/jvmti/cacaodbg.h"
#endif
#if defined(ENABLE_RT_TIMING)
- jit_print_time_stats(stderr);
+ rt_timing_print_time_stats(stderr);
#endif
if (opt_verbose || getcompilingtime || opt_stat) {