From d62d56aa9150bb2156dac82966795fdcbd7562e0 Mon Sep 17 00:00:00 2001 From: Michael Starzinger Date: Wed, 11 Nov 2009 16:24:13 +0100 Subject: [PATCH] src/vm/cycles-stats.h: Switched from asm_get_cycle_count to md_get_cycle_count. src/vm/jit/asmpart.h (asm_get_cycle_count): Removed obsolete declaration. src/vm/jit/i386/md.h (md_get_cycle_count): Added as inline assembler. src/vm/jit/x86_64/md.h: Likewise. src/vm/jit/i386/asmpart.S (asm_get_cycle_count): Removed assembler function. src/vm/jit/i386/darwin/md-asm.h: Likewise. src/vm/jit/x86_64/asmpart.S: Likewise. --- src/vm/cycles-stats.h | 34 +++++++++++++++++---------------- src/vm/jit/asmpart.h | 2 -- src/vm/jit/i386/asmpart.S | 12 ------------ src/vm/jit/i386/darwin/md-asm.h | 2 -- src/vm/jit/i386/md.h | 17 +++++++++++++++++ src/vm/jit/x86_64/asmpart.S | 16 ---------------- src/vm/jit/x86_64/md.h | 19 +++++++++++++++++- 7 files changed, 53 insertions(+), 49 deletions(-) diff --git a/src/vm/cycles-stats.h b/src/vm/cycles-stats.h index d70c9d1cb..53e267f93 100644 --- a/src/vm/cycles-stats.h +++ b/src/vm/cycles-stats.h @@ -1,9 +1,7 @@ /* src/vm/cycles-stats.h - macros for cycle count statistics - 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 + Copyright (C) 1996-2005, 2006, 2009 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Edwin Steiner - - Changes: - */ #ifndef _CYCLES_STATS_H @@ -40,6 +32,8 @@ #include +#include "md.h" + #define CYCLES_STATS_DECLARE(name,nbins,divisor) \ static const int CYCLES_STATS_##name##_MAX = (nbins); \ static const int CYCLES_STATS_##name##_DIV = (divisor); \ @@ -50,7 +44,7 @@ static u8 cycles_stats_##name##_min = 1000000000; #define CYCLES_STATS_GET(var) \ - (var) = asm_get_cycle_count() \ + (var) = md_get_cycle_count() \ #define CYCLES_STATS_COUNT(name,cyclesexpr) \ do { \ @@ -94,28 +88,36 @@ } while (0) #define CYCLES_STATS_DECLARE_AND_START \ - u8 cycles_start = asm_get_cycle_count(); \ + u8 cycles_start = md_get_cycle_count(); \ u8 cycles_end; #define CYCLES_STATS_DECLARE_AND_START_WITH_OVERHEAD \ - u8 cycles_start = asm_get_cycle_count(); \ - u8 cycles_overhead = asm_get_cycle_count(); \ + u8 cycles_start = md_get_cycle_count(); \ + u8 cycles_overhead = md_get_cycle_count(); \ u8 cycles_end; #define CYCLES_STATS_END(name) \ - cycles_end = asm_get_cycle_count(); \ + cycles_end = md_get_cycle_count(); \ CYCLES_STATS_COUNT(name, cycles_end - cycles_start); #define CYCLES_STATS_END_WITH_OVERHEAD(name,ovname) \ - cycles_end = asm_get_cycle_count(); \ + cycles_end = md_get_cycle_count(); \ CYCLES_STATS_COUNT(ovname, cycles_overhead - cycles_start); \ CYCLES_STATS_COUNT(name, cycles_end - cycles_overhead); +#ifdef __cplusplus +extern "C" { +#endif + void cycles_stats_print(FILE *file, const char *name, int nbins, int div, u4 *bins, u8 count, u8 total, u8 min, u8 max, int overhead); +#ifdef __cplusplus +} +#endif + #else /* !defined(ENABLE_CYCLES_STATS) */ diff --git a/src/vm/jit/asmpart.h b/src/vm/jit/asmpart.h index 9ea6f4da5..8769403d7 100644 --- a/src/vm/jit/asmpart.h +++ b/src/vm/jit/asmpart.h @@ -102,8 +102,6 @@ void asm_patcher_wrapper(void); /* cache flush function */ void asm_cacheflush(void* addr, int nbytes); -u8 asm_get_cycle_count(void); - void *md_asm_codegen_get_pv_from_pc(void *ra); #if defined(ENABLE_ESCAPE_CHECK) diff --git a/src/vm/jit/i386/asmpart.S b/src/vm/jit/i386/asmpart.S index 72653f436..b9be6e191 100644 --- a/src/vm/jit/i386/asmpart.S +++ b/src/vm/jit/i386/asmpart.S @@ -62,8 +62,6 @@ .globl asm_compare_and_swap .globl asm_memory_barrier - .globl asm_get_cycle_count - #if defined(ENABLE_ESCAPE_CHECK) .globl asm_escape_check #endif @@ -416,16 +414,6 @@ asm_memory_barrier: lock; add $0,0(sp) ret - -/* asm_get_cycle_count ********************************************************* - - Get the current time-stamp counter from the CPU. - -*******************************************************************************/ - -asm_get_cycle_count: - rdtsc - ret #if defined(ENABLE_ESCAPE_CHECK) asm_escape_check: diff --git a/src/vm/jit/i386/darwin/md-asm.h b/src/vm/jit/i386/darwin/md-asm.h index d610cc3ce..588811a39 100644 --- a/src/vm/jit/i386/darwin/md-asm.h +++ b/src/vm/jit/i386/darwin/md-asm.h @@ -117,8 +117,6 @@ #define builtin_d2i _builtin_d2i #define builtin_d2l _builtin_d2l -#define asm_get_cycle_count _asm_get_cycle_count - #endif /* _MD_ASM_H */ diff --git a/src/vm/jit/i386/md.h b/src/vm/jit/i386/md.h index 9bfa13373..0756bb26a 100644 --- a/src/vm/jit/i386/md.h +++ b/src/vm/jit/i386/md.h @@ -139,6 +139,23 @@ inline static void md_dcacheflush(void *addr, int nbytes) __asm__ __volatile__ ("" : : : "memory"); } + +/* md_get_cycle_count ********************************************************** + + Get the current time-stamp counter from the CPU. + +*******************************************************************************/ + +inline static uint64_t md_get_cycle_count() +{ + uint64_t cycles; + + // Get current cycles count from the CPU. + __asm__ __volatile__ ("rdtsc" : "=A" (cycles)); + + return cycles; +} + #endif /* _VM_JIT_I386_MD_H */ diff --git a/src/vm/jit/x86_64/asmpart.S b/src/vm/jit/x86_64/asmpart.S index 5807491ec..e72711d14 100644 --- a/src/vm/jit/x86_64/asmpart.S +++ b/src/vm/jit/x86_64/asmpart.S @@ -56,8 +56,6 @@ .globl asm_builtin_d2i .globl asm_builtin_d2l - .globl asm_get_cycle_count - /********************* function asm_calljavafunction *************************** * * @@ -389,20 +387,6 @@ asm_builtin_d2l: ret -/* asm_get_cycle_count ********************************************************* - - Get the current time-stamp counter from the CPU. - -*******************************************************************************/ - -asm_get_cycle_count: - rdtsc - shl $0x20, %rdx - mov %eax, %eax - or %rdx, %rax - ret - - /* disable exec-stacks ********************************************************/ #if defined(__linux__) && defined(__ELF__) diff --git a/src/vm/jit/x86_64/md.h b/src/vm/jit/x86_64/md.h index 9a65d6b65..68f99e57e 100644 --- a/src/vm/jit/x86_64/md.h +++ b/src/vm/jit/x86_64/md.h @@ -1,6 +1,6 @@ /* src/vm/jit/x86_64/md.h - machine dependent x86_64 functions - Copyright (C) 1996-2005, 2006, 2007, 2008 + Copyright (C) 1996-2005, 2006, 2007, 2008, 2009 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -130,6 +130,23 @@ inline static void md_dcacheflush(void* addr, int nbytes) __asm__ __volatile__ ("" : : : "memory"); } + +/* md_get_cycle_count ********************************************************** + + Get the current time-stamp counter from the CPU. + +*******************************************************************************/ + +inline static uint64_t md_get_cycle_count() +{ + uint64_t cycles; + + // Get current cycles count from the CPU. + __asm__ __volatile__ ("rdtsc" : "=A" (cycles)); + + return cycles; +} + #endif /* _VM_JIT_X86_64_MD_H */ -- 2.25.1