src/vm/cycles-stats.h: Switched from asm_get_cycle_count to md_get_cycle_count.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 11 Nov 2009 15:24:13 +0000 (16:24 +0100)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 11 Nov 2009 15:24:13 +0000 (16:24 +0100)
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
src/vm/jit/asmpart.h
src/vm/jit/i386/asmpart.S
src/vm/jit/i386/darwin/md-asm.h
src/vm/jit/i386/md.h
src/vm/jit/x86_64/asmpart.S
src/vm/jit/x86_64/md.h

index d70c9d1cbde582cad5bc9ce380875dd45a1c1a64..53e267f93f78aa1b12ead1b33b58a1a271cd8762 100644 (file)
@@ -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.
 
    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 <stdio.h>
 
+#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 {                                                                    \
     } 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) */
 
index 9ea6f4da5c97ce6efaca10364e1e50a84fb40d84..8769403d7392d8aae2776f220cd5489846f349d7 100644 (file)
@@ -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)
index 72653f436afe572c8b5df04d783478245f0e48b2..b9be6e191288c242139bfc018248b49e875043d0 100644 (file)
@@ -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:
index d610cc3ce1dc3a24803ccab9cf12b4332aa7eb40..588811a39a7844d92d52d7966dac589c755e9480 100644 (file)
 #define builtin_d2i                           _builtin_d2i
 #define builtin_d2l                           _builtin_d2l
 
-#define asm_get_cycle_count                   _asm_get_cycle_count
-
 #endif /* _MD_ASM_H */
 
 
index 9bfa133732d07630da8dfad573d31a59e366fbeb..0756bb26a1db78dbc07a19eb7538b34116e9b38e 100644 (file)
@@ -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 */
 
 
index 5807491ecbac01e65242b9c65be0c10615d4faaa..e72711d14ba9788a007f937a30100bf510d4f696 100644 (file)
@@ -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__)
index 9a65d6b6597df307116132f144011ea18d49bd45..68f99e57e88d3529630bfa20cc65e20c29f151ef 100644 (file)
@@ -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 */