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 - macros for cycle count statistics
/* 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.
This file is part of CACAO.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Edwin Steiner
-
- Changes:
-
*/
#ifndef _CYCLES_STATS_H
*/
#ifndef _CYCLES_STATS_H
#define CYCLES_STATS_DECLARE(name,nbins,divisor) \
static const int CYCLES_STATS_##name##_MAX = (nbins); \
static const int CYCLES_STATS_##name##_DIV = (divisor); \
#define CYCLES_STATS_DECLARE(name,nbins,divisor) \
static const int CYCLES_STATS_##name##_MAX = (nbins); \
static const int CYCLES_STATS_##name##_DIV = (divisor); \
static u8 cycles_stats_##name##_min = 1000000000;
#define CYCLES_STATS_GET(var) \
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 { \
#define CYCLES_STATS_COUNT(name,cyclesexpr) \
do { \
} while (0)
#define CYCLES_STATS_DECLARE_AND_START \
} 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_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) \
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_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);
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);
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) */
#else /* !defined(ENABLE_CYCLES_STATS) */
/* cache flush function */
void asm_cacheflush(void* addr, int nbytes);
/* 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)
void *md_asm_codegen_get_pv_from_pc(void *ra);
#if defined(ENABLE_ESCAPE_CHECK)
.globl asm_compare_and_swap
.globl asm_memory_barrier
.globl asm_compare_and_swap
.globl asm_memory_barrier
- .globl asm_get_cycle_count
-
#if defined(ENABLE_ESCAPE_CHECK)
.globl asm_escape_check
#endif
#if defined(ENABLE_ESCAPE_CHECK)
.globl asm_escape_check
#endif
-
-/* 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:
#if defined(ENABLE_ESCAPE_CHECK)
asm_escape_check:
#define builtin_d2i _builtin_d2i
#define builtin_d2l _builtin_d2l
#define builtin_d2i _builtin_d2i
#define builtin_d2l _builtin_d2l
-#define asm_get_cycle_count _asm_get_cycle_count
-
__asm__ __volatile__ ("" : : : "memory");
}
__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 */
#endif /* _VM_JIT_I386_MD_H */
.globl asm_builtin_d2i
.globl asm_builtin_d2l
.globl asm_builtin_d2i
.globl asm_builtin_d2l
- .globl asm_get_cycle_count
-
/********************* function asm_calljavafunction ***************************
* *
/********************* function asm_calljavafunction ***************************
* *
-/* 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__)
/* disable exec-stacks ********************************************************/
#if defined(__linux__) && defined(__ELF__)
/* src/vm/jit/x86_64/md.h - machine dependent x86_64 functions
/* 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.
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
__asm__ __volatile__ ("" : : : "memory");
}
__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 */
#endif /* _VM_JIT_X86_64_MD_H */