dnl Process this file with autoconf to produce a configure script.
- AC_INIT(cacao, 0.99rc5, cacao@cacaojvm.org)
+ AC_INIT(cacao, 1.1.0pre, cacao@cacaojvm.org)
AC_CONFIG_SRCDIR(src/cacao/cacao.c)
AC_CANONICAL_HOST
AC_PREREQ(2.59)
- AM_INIT_AUTOMAKE([1.9.0 dist-bzip2])
+ AM_INIT_AUTOMAKE([1.9.0 dist-bzip2 tar-ustar])
AM_MAINTAINER_MODE
AM_CONFIG_HEADER([config.h])
AC_PREFIX_DEFAULT(/usr/local/cacao)
- dnl set optimization and debugging for all architectures and systems
+ dnl Set optimization and debugging for all architectures and systems.
if test x"$CFLAGS" = "x"; then
- OPT_CFLAGS="-O0 -g3"
+ OPT_CFLAGS="-O0 -g"
else
OPT_CFLAGS=$CFLAGS
fi
+ if test x"$CXXFLAGS" = "x"; then
+ OPT_CXXFLAGS="-O0 -g"
+ else
+ OPT_CXXFLAGS=$CXXFLAGS
+ fi
+
dnl system type
case "$host_cpu" in
alpha | alphaev56 | alphapca56 )
ARCH_DIR="alpha"
- ARCH_CFLAGS="-mieee -D__ALPHA__"
+ ARCH_FLAGS="-mieee -D__ALPHA__"
JAVA_ARCH="alpha"
;;
arm | armv4 | armv4tl | armv5b | armv5l )
ARCH_DIR="arm"
- ARCH_CFLAGS="-D__ARM__"
+ ARCH_FLAGS="-D__ARM__"
JAVA_ARCH="arm"
;;
hppa2.0 )
ARCH_DIR="parisc"
- ARCH_CFLAGS="-D__PARISC__"
+ ARCH_FLAGS="-D__PARISC__"
JAVA_ARCH="hppa"
;;
i386 | i486 | i586 | i686 )
ARCH_DIR="i386"
- ARCH_CFLAGS="-D__I386__"
+ ARCH_FLAGS="-D__I386__"
JAVA_ARCH="i386"
;;
m68k )
ARCH_DIR="m68k"
- ARCH_CFLAGS="-D__M68K__"
+ ARCH_FLAGS="-D__M68K__"
JAVA_ARCH="m68k"
;;
mips | mipsel )
ARCH_DIR="mips"
- ARCH_CFLAGS="-D__MIPS__"
+ ARCH_FLAGS="-D__MIPS__"
dnl Is this correct for mipsel?
JAVA_ARCH="mips"
;;
powerpc )
ARCH_DIR="powerpc"
- ARCH_CFLAGS="-D__POWERPC__"
+ ARCH_FLAGS="-D__POWERPC__"
JAVA_ARCH="ppc"
;;
powerpc64 )
ARCH_DIR="powerpc64"
- ARCH_CFLAGS="-D__POWERPC64__"
+ ARCH_FLAGS="-D__POWERPC64__"
JAVA_ARCH="ppc64"
;;
s390 )
ARCH_DIR="s390"
- ARCH_CFLAGS="-D__S390__"
+ ARCH_FLAGS="-D__S390__"
JAVA_ARCH="s390"
;;
sparc | sparc64 )
ARCH_DIR="sparc64"
- ARCH_CFLAGS="-mcpu=v9 -m64 -D__SPARC_64__"
+ ARCH_FLAGS="-mcpu=v9 -m64 -D__SPARC_64__"
dnl Is this correct for 64-bits?
JAVA_ARCH="sparc"
;;
x86_64 )
ARCH_DIR="x86_64"
- ARCH_CFLAGS="-D__X86_64__"
+ ARCH_FLAGS="-m64 -D__X86_64__"
JAVA_ARCH="amd64"
;;
xdspcore )
ARCH_DIR="xdspcore"
ENABLE_STATICVM="yes"
- ARCH_CFLAGS="-D__XDSPCORE__"
+ ARCH_FLAGS="-D__XDSPCORE__"
USE_SCHEDULER="1"
;;
case "$host_os" in
*cygwin* )
OS_DIR="cygwin"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -Wall -Wno-long-long"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -ansi -pedantic -Wall -Wno-long-long"
+ OS_FLAGS="-D__WINDOWS__ -D__CYGWIN__"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*darwin* )
OS_DIR="darwin"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -Wall -Wno-long-long"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -ansi -pedantic -Wall -Wno-long-long"
+ OS_FLAGS="-D__DARWIN__"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
+ ;;
+
+ dnl Must be BEFORE *freebsd*.
+ *kfreebsd*-gnu)
+ OS_DIR="freebsd"
+ OS_FLAGS="-D__FREEBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*freebsd* )
OS_DIR="freebsd"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -ansi -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED"
+ OS_FLAGS="-D__FREEBSD__ -D_XOPEN_SOURCE_EXTENDED"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*irix* )
OS_DIR="irix"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__IRIX__"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__IRIX__"
+ OS_FLAGS="-D__IRIX__"
+ CC_FLAGS=""
+ CXX_FLAGS=""
+ INTRP_CFLAGS="$ARCH_FLAGS $OS_FLAGS"
;;
- *kfreebsd*-gnu)
- OS_DIR="freebsd"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
- ;;
-
- dnl must be before *linux*
+ dnl Must be BEFORE *linux*.
*uclinux | *elf )
OS_DIR="uclinux"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*linux* | *Linux* )
OS_DIR="linux"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*netbsd* )
OS_DIR="netbsd"
- INTRP_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ OS_FLAGS="-D__NETBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
*solaris* )
OS_DIR="solaris"
- dnl on solaris the architecture defines 'sparc','sun','unix' are not set when cpp is called with -ansi
- dnl therefore we add them here
- INTRP_CFLAGS="$ARCH_CFLAGS -D__SOLARIS__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ -D_BSD_SOURCE -Dsparc -Dsun -Dunix"
- ARCH_CFLAGS="$ARCH_CFLAGS -D__SOLARIS__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ -D_BSD_SOURCE -Dsparc -Dsun -Dunix"
+ dnl On solaris the architecture defines 'sparc', 'sun', 'unix' are
+ dnl not set when cpp is called with -std=c99, therefore we add them
+ dnl here.
+ OS_FLAGS="-D__SOLARIS__ -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_BSD_SOURCE"
+ CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE=600"
+ CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+ INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
;;
* )
dnl temporary set the CFLAGS for configure tests (e.g. inline keyword)
dnl we set it properly at the end of this file
- CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
+ CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS"
+ CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS"
dnl set interpreter flags
AC_SUBST(INTRP_CFLAGS)
AC_DEFINE_UNQUOTED([ARCH_DIR], "${ARCH_DIR}", [architecture directory])
AC_DEFINE_UNQUOTED([JAVA_ARCH], "${JAVA_ARCH}", [Java architecture name])
AC_SUBST(ARCH_DIR)
+ AC_SUBST(JAVA_ARCH)
AC_SUBST(OS_DIR)
AC_SUBST(USE_SCHEDULER)
dnl Checks for programs.
AC_PROG_CC
+ AC_PROG_CXX
AM_PROG_AS
AC_PROG_LD
AC_PROG_LD_GNU
- AC_PROG_RANLIB
AC_PROG_LN_S
AC_PROG_MAKE_SET
AM_PROG_MKDIR_P
AC_HEADER_DIRENT
AC_HEADER_STDC
+ dnl Crucial header files.
+ AC_CHECK_HEADERS([stdbool.h],, [AC_MSG_ERROR(cannot find stdbool.h)])
+ AC_CHECK_HEADERS([stdint.h],, [AC_MSG_ERROR(cannot find stdint.h)])
+
dnl keep them alpha-sorted!
AC_CHECK_HEADERS([assert.h])
AC_CHECK_HEADERS([errno.h])
AC_CHECK_HEADERS([sys/time.h])
AC_CHECK_HEADERS([sys/types.h])
- dnl this is for fdlibm
- AC_CHECK_HEADERS([inttypes.h])
- AC_CHECK_HEADERS([sys/config.h])
- AC_CHECK_HEADERS([sys/types.h])
- AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t]))
- AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t]))
- AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, [Define to 1 if you have BSD u_int32_t]))
- AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, [Define to 1 if you have BSD u_int32_t]))
-
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
dnl Checks for libraries (NOTE: Should be done before function checks,
dnl as some functions may be in libraries we check for).
- AC_CHECK_LIB(dl, dlopen,,)
+
+ case "${OS_DIR}" in
+ solaris )
+ AC_CHECK_LIB([socket], [gethostname],, [AC_MSG_ERROR(cannot find libsocket)])
+ ;;
+ esac
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_SUBST(CACAO_LIBDIR)
- AC_CHECK_ENABLE_LTDL
-
+ AC_CHECK_ENABLE_DL
AC_CHECK_ENABLE_JAVA
AC_CHECK_ENABLE_JIT
AC_CHECK_ENABLE_GC
AC_CHECK_ENABLE_DEBUG
AC_CHECK_ENABLE_DUMP
-
-
- dnl check for memcheck support
- AC_MSG_CHECKING(whether debugging memory checks should be enabled)
- AC_ARG_ENABLE([memcheck],
- [AS_HELP_STRING(--enable-memcheck,enable debugging memory checks [[default=no]])],
- [case "${enableval}" in
- yes) ENABLE_MEMCHECK=yes;;
- *) ENABLE_MEMCHECK=no;;
- esac],
- [ENABLE_MEMCHECK=no])
- AC_MSG_RESULT(${ENABLE_MEMCHECK})
- AM_CONDITIONAL([ENABLE_MEMCHECK], test x"${ENABLE_MEMCHECK}" = "xyes")
-
- if test x"${ENABLE_MEMCHECK}" = "xyes"; then
- AC_DEFINE([ENABLE_MEMCHECK], 1, [perform debugging memory checks])
- fi
-
-
- dnl check for handles (indirection cells) support
- AC_MSG_CHECKING(whether handles (indirection cells) should be enabled)
- AC_ARG_ENABLE([handles],
- [AS_HELP_STRING(--enable-handles,enable handles (indirection cells) [[default=no]])],
- [case "${enableval}" in
- yes) ENABLE_HANDLES=yes;;
- *) ENABLE_HANDLES=no;;
- esac],
- [ENABLE_HANDLES=no])
- AC_MSG_RESULT(${ENABLE_HANDLES})
- AM_CONDITIONAL([ENABLE_HANDLES], test x"${ENABLE_HANDLES}" = "xyes")
-
- if test x"${ENABLE_HANDLES}" = "xyes"; then
- AC_DEFINE([ENABLE_HANDLES], 1, [enable handles (indirection cells)])
- fi
-
-
- dnl check for vmlog support
- AC_MSG_CHECKING(whether vmlog tracing should be enabled)
- AC_ARG_ENABLE([vmlog],
- [AS_HELP_STRING(--enable-vmlog,enable vmlog tracing [[default=no]])],
- [case "${enableval}" in
- yes) ENABLE_VMLOG=yes;;
- *) ENABLE_VMLOG=no;;
- esac],
- [ENABLE_VMLOG=no])
- AC_MSG_RESULT(${ENABLE_VMLOG})
- AM_CONDITIONAL([ENABLE_VMLOG], test x"${ENABLE_VMLOG}" = "xyes")
-
- if test x"${ENABLE_VMLOG}" = "xyes"; then
- AC_DEFINE([ENABLE_VMLOG], 1, [enable vmlog tracing code])
- fi
-
-
- dnl check for disassembler support
- AC_MSG_CHECKING(whether disassembler should be enabled)
- AC_ARG_ENABLE([disassembler],
- [AS_HELP_STRING(--enable-disassembler,enable disassembler [[default=no]])],
- [case "${enableval}" in
- yes) ENABLE_DISASSEMBLER=yes;;
- *) ENABLE_DISASSEMBLER=no;;
- esac],
- [ENABLE_DISASSEMBLER=no])
- AC_MSG_RESULT(${ENABLE_DISASSEMBLER})
- AM_CONDITIONAL([ENABLE_DISASSEMBLER], test x"${ENABLE_DISASSEMBLER}" = "xyes")
-
- if test x"${ENABLE_DISASSEMBLER}" = "xyes"; then
- AC_DEFINE([ENABLE_DISASSEMBLER], 1, [enable disassembler])
-
- dnl check for binutils headers and libraries on some architectures for the
- dnl disassembler
- case "${ARCH_DIR}" in
- arm | i386 | powerpc | x86_64 | sparc64 | powerpc64 | s390 | m68k)
- AC_CHECK_HEADER([ansidecl.h],, [AC_MSG_ERROR(cannot find ansidecl.h)])
- AC_CHECK_HEADER([symcat.h],, [AC_MSG_ERROR(cannot find symcat.h)])
- AC_CHECK_HEADER([bfd.h],, [AC_MSG_ERROR(cannot find bfd.h)])
- AC_CHECK_HEADER([dis-asm.h],, [AC_MSG_ERROR(cannot find dis-asm.h)])
-
- case "${OS_DIR}" in
- cygwin | darwin | netbsd | solaris)
- AC_CHECK_LIB(intl, dcgettext,, [AC_MSG_ERROR(cannot find libintl (from binutils))])
- ;;
- esac
-
- case "${OS_DIR}" in
- solaris)
- AC_CHECK_LIB(rt, sem_init,, [AC_MSG_ERROR(cannot find librt)])
- ;;
- esac
-
-
- AC_CHECK_LIB(iberty, xstrerror,, [AC_MSG_ERROR(cannot find libiberty (from binutils))])
- AC_CHECK_LIB(bfd, bfd_get_arch,, [AC_MSG_ERROR(cannot find libbfd (from binutils))])
- AC_CHECK_LIB(opcodes, disassembler,, [AC_MSG_ERROR(cannot find libopcodes (from binutils))])
- AC_DEFINE([WITH_BINUTILS_DISASSEMBLER], 1, [use binutils disassembler])
- AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [true])
- ;;
- * )
- AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
- ;;
- esac
- else
- AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
- fi
-
-
- dnl check for statistics
- AC_MSG_CHECKING(whether statistics generation should be enabled)
- AC_ARG_ENABLE([statistics],
- [AS_HELP_STRING(--enable-statistics,enable statistics generation [[default=no]])],
- [case "${enableval}" in
- yes) ENABLE_STATISTICS=yes;;
- *) ENABLE_STATISTICS=no;;
- esac],
- [ENABLE_STATISTICS=no])
- AC_MSG_RESULT(${ENABLE_STATISTICS})
- AM_CONDITIONAL([ENABLE_STATISTICS], test x"${ENABLE_STATISTICS}" = "xyes")
-
- if test x"${ENABLE_STATISTICS}" = "xyes"; then
- AC_DEFINE([ENABLE_STATISTICS], 1, [enable statistics])
- fi
-
-
- dnl check for verifier
- AC_MSG_CHECKING(whether classfile verification should be enabled)
- AC_ARG_ENABLE([verifier],
- [AS_HELP_STRING(--disable-verifier,disable classfile verification [[default=enabled]])],
- [case "${enableval}" in
- no) ENABLE_VERIFIER=no;;
- *) ENABLE_VERIFIER=yes;;
- esac],
- [ENABLE_VERIFIER=yes])
- AC_MSG_RESULT(${ENABLE_VERIFIER})
- AM_CONDITIONAL([ENABLE_VERIFIER], test x"${ENABLE_VERIFIER}" = "xyes")
-
- if test x"${ENABLE_VERIFIER}" = "xyes"; then
- AC_DEFINE([ENABLE_VERIFIER], 1, [enable classfile verification])
- fi
-
-
- dnl check for compiler timing
- AC_MSG_CHECKING(whether real-time timing should be enabled)
- AC_ARG_ENABLE([rt-timing],
- [AS_HELP_STRING(--enable-rt-timing,enable real-time timing [[default=no]])],
- [case "${enableval}" in
- yes) ENABLE_RT_TIMING=yes;;
- *) ENABLE_RT_TIMING=no;;
- esac],
- [ENABLE_RT_TIMING=no])
- AC_MSG_RESULT(${ENABLE_RT_TIMING})
- AM_CONDITIONAL([ENABLE_RT_TIMING], test x"${ENABLE_RT_TIMING}" = "xyes")
-
- if test x"${ENABLE_RT_TIMING}" = "xyes"; then
- AC_DEFINE([ENABLE_RT_TIMING], 1, [enable real-time timing])
- fi
-
-
- dnl check for cycle count statistics
- AC_MSG_CHECKING(whether cycle count statistics should be enabled)
- AC_ARG_ENABLE([cycles-stats],
- [AS_HELP_STRING(--enable-cycles-stats,enable cycle count statistics [[default=no]])],
- [case "${enableval}" in
- yes) ENABLE_CYCLES_STATS=yes;;
- *) ENABLE_CYCLES_STATS=no;;
- esac],
- [ENABLE_CYCLES_STATS=no])
- AC_MSG_RESULT(${ENABLE_CYCLES_STATS})
- AM_CONDITIONAL([ENABLE_CYCLES_STATS], test x"${ENABLE_CYCLES_STATS}" = "xyes")
-
- if test x"${ENABLE_CYCLES_STATS}" = "xyes"; then
- AC_DEFINE([ENABLE_CYCLES_STATS], 1, [enable cycle count statistics])
- fi
-
-
- dnl check for JVMTI
- AC_MSG_CHECKING(whether to compile JVMTI support)
- AC_ARG_ENABLE([jvmti],
- [AS_HELP_STRING(--enable-jvmti,enable JVMTI [[default=no]])],
- [case "${enableval}" in
- yes) ENABLE_JVMTI=yes;;
- *) ENABLE_JVMTI=no;;
- esac],
- [ENABLE_JVMTI=no])
- AC_MSG_RESULT(${ENABLE_JVMTI})
- AM_CONDITIONAL([ENABLE_JVMTI], test x"${ENABLE_JVMTI}" = "xyes")
-
- if test x"${ENABLE_JVMTI}" = "xyes"; then
- AC_DEFINE([ENABLE_JVMTI], 1, [use JVMTI])
- fi
-
-
+ AC_CHECK_ENABLE_MEMCHECK
+ AC_CHECK_ENABLE_HANDLES
+ AC_CHECK_ENABLE_VMLOG
+ AC_CHECK_ENABLE_DISASSEMBLER
+ AC_CHECK_ENABLE_STATISTICS
+ AC_CHECK_ENABLE_VERIFIER
+ AC_CHECK_ENABLE_RT_TIMING
+ AC_CHECK_ENABLE_CYCLE_STATS
+ AC_CHECK_ENABLE_JVMTI
AC_CHECK_ENABLE_THREADS
-
-
- dnl check if if-conversion should be supported
- AC_MSG_CHECKING(whether if-conversion should be supported)
- AC_ARG_ENABLE([ifconv],
- [AS_HELP_STRING(--disable-ifconv,disable if-conversion [[default=enabled]])],
- [case "${enableval}" in
- no) ENABLE_IFCONV=no;;
- *) ENABLE_IFCONV=yes;;
- esac],
- [ENABLE_IFCONV=yes])
- AC_MSG_RESULT(${ENABLE_IFCONV})
- AM_CONDITIONAL([ENABLE_IFCONV], test x"${ENABLE_IFCONV}" = "xyes")
-
- if test x"${ENABLE_IFCONV}" = "xyes"; then
- AC_DEFINE([ENABLE_IFCONV], 1, [enable if-conversion])
- fi
-
-
- dnl check for inlining
- AC_MSG_CHECKING(whether method inlining should be supported)
- AC_ARG_ENABLE([inlining],
- [AS_HELP_STRING(--enable-inlining,enable method inlining [[default=no]])],
- [case "${enableval}" in
- yes) ENABLE_INLINING=yes;;
- *) ENABLE_INLINING=no;;
- esac],
- [ENABLE_INLINING=no])
- AC_MSG_RESULT(${ENABLE_INLINING})
- AM_CONDITIONAL([ENABLE_INLINING], test x"${ENABLE_INLINING}" = "xyes")
-
- if test x"${ENABLE_INLINING}" = "xyes"; then
- AC_DEFINE([ENABLE_INLINING], 1, [use method inlining])
- fi
-
-
- dnl check for inlining debug options
- AC_MSG_CHECKING(whether method inlining debug options should be enabled)
- AC_ARG_ENABLE([inlining-debug],
- [AS_HELP_STRING(--enable-inlining-debug,enable method inlining debug options [[default=no]])],
- [case "${enableval}" in
- yes) ENABLE_INLINING_DEBUG=yes;;
- *) ENABLE_INLINING_DEBUG=no;;
- esac],
- [ENABLE_INLINING_DEBUG=no])
- AC_MSG_RESULT(${ENABLE_INLINING_DEBUG})
- AM_CONDITIONAL([ENABLE_INLINING_DEBUG], test x"${ENABLE_INLINING_DEBUG}" = "xyes")
-
- if test x"${ENABLE_INLINING_DEBUG}" = "xyes"; then
- AC_DEFINE([ENABLE_INLINING_DEBUG], 1, [enable method inlining debug options])
- fi
-
-
- dnl check for replacement
- AC_MSG_CHECKING(whether on-stack replacement should be supported)
- AC_ARG_ENABLE([replacement],
- [AS_HELP_STRING(--enable-replacement,enable on-stack replacement [[default=no]])],
- [case "${enableval}" in
- yes) ENABLE_REPLACEMENT=yes;;
- *) ENABLE_REPLACEMENT=no;;
- esac],
- [ENABLE_REPLACEMENT=no])
- AC_MSG_RESULT(${ENABLE_REPLACEMENT})
- AM_CONDITIONAL([ENABLE_REPLACEMENT], test x"${ENABLE_REPLACEMENT}" = "xyes")
-
- if test x"${ENABLE_REPLACEMENT}" = "xyes"; then
- AC_DEFINE([ENABLE_REPLACEMENT], 1, [use on-stack replacement])
- fi
-
+ AC_CHECK_ENABLE_IFCONV
+ AC_CHECK_ENABLE_INLINING
+ AC_CHECK_ENABLE_INLINING_DEBUG
+ AC_CHECK_ENABLE_REPLACEMENT
dnl check for loop optimization
AC_MSG_CHECKING(whether loop optimization should be supported)
AM_CONDITIONAL([ENABLE_SSA], test x"${ENABLE_SSA}" = "xyes")
AM_CONDITIONAL([ENABLE_ESCAPE], test x"${ENABLE_SSA}" = "xyes")
AM_CONDITIONAL([ENABLE_ESCAPE_CHECK], test x"${ENABLE_SSA}" = "xyes")
+AM_CONDITIONAL([ENABLE_TLH], test x"${ENABLE_SSA}" = "xyes")
if test x"${ENABLE_SSA}" = "xyes"; then
AC_DEFINE([ENABLE_SSA], 1, [enable lsra with ssa])
AC_DEFINE([ENABLE_ESCAPE], 1, [enable escape analysis with ssa])
AC_DEFINE([ENABLE_ESCAPE_CHECK], 1, [enable generating code to validate escape analysis results])
+ AC_DEFINE([ENABLE_TLH], 1, [enable thread local heap])
ENABLE_LSRA="no"
fi
AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_PREFIX
AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_CLASSES
+ AC_CHECK_WITH_BUILD_JAVA_RUNTIME_LIBRARY_CLASSES
if test x"${ENABLE_JRE_LAYOUT}" = "xno"; then
AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_LIBDIR
;;
esac
+ AC_CHECK_WITH_JASMIN_JAR
+ AC_CHECK_WITH_JUNIT_JAR
AC_CHECK_HEADERS(
[regex.h],
dnl define some stuff required for --fullversion
AC_DEFINE_UNQUOTED(VERSION_CONFIGURE_ARGS, "$ac_configure_args", [configure arguments])
AC_DEFINE_UNQUOTED(VERSION_CC, "$CC", [CC used])
- AC_DEFINE_UNQUOTED(VERSION_CFLAGS, "$OPT_CFLAGS $ARCH_CFLAGS $CPPFLAGS", [CFLAGS used])
+ AC_DEFINE_UNQUOTED(VERSION_CXX, "$CXX", [CXX used])
+ AC_DEFINE_UNQUOTED(VERSION_CFLAGS, "$OPT_CFLAGS $ARCH_CFLAGS $CC_FLAGS $CPPFLAGS", [CFLAGS used])
+ AC_DEFINE_UNQUOTED(VERSION_CXXFLAGS, "$OPT_CXXFLAGS $ARCH_CXXFLAGS $CXX_FLAGS $CPPFLAGS", [CXXFLAGS used])
- dnl finally pass CFLAGS to Makefiles via AM_CFLAGS
+ dnl Finally pass flags to Makefiles.
CFLAGS="$OPT_CFLAGS"
- AM_CFLAGS=$ARCH_CFLAGS
+ CXXFLAGS="$OPT_CXXFLAGS"
+
+ AM_CFLAGS="$CC_FLAGS $ARCH_FLAGS $OS_FLAGS"
+ AM_CXXFLAGS="$CXX_FLAGS $ARCH_FLAGS $OS_FLAGS"
AM_CPPFLAGS="$CPPFLAGS"
+
AC_SUBST(AM_CFLAGS)
+ AC_SUBST(AM_CXXFLAGS)
AC_SUBST(AM_CPPFLAGS)
[src/vmcore/Makefile]
[tests/Makefile]
[tests/regression/Makefile]
- [tests/regression/bugzilla/Makefile]
[tests/regression/assertion/Makefile]
+ [tests/regression/base/Makefile]
+ [tests/regression/bugzilla/Makefile]
[tests/regression/jasmin/Makefile]
- [tests/regression/junit/Makefile]
[tests/regression/native/Makefile]
[tests/regression/resolving/Makefile]
[tests/regression/resolving/classes1/Makefile]
)
- dnl now configure subpackages with OPT_CFLAGS and ARCH_CFLAGS
- export OPT_CFLAGS
- export ARCH_CFLAGS
+ dnl We only build the shared library objects but we use it as
+ dnl noinst_LTLIBRARIES.
+ ac_configure_args="$ac_configure_args --disable-static"
AC_CONFIG_SUBDIRS(src/mm/boehm-gc)
#include "arch.h"
- #if !defined(USE_FAKE_ATOMIC_INSTRUCTIONS)
- # include "machine-instr.h"
- #else
- # include "threads/posix/generic-primitives.h"
- #endif
-
#include "mm/gc-common.h"
#include "mm/memory.h"
# include "native/include/java_lang_VMThread.h"
#endif
+ #include "threads/condition.hpp"
#include "threads/lock-common.h"
- #include "threads/mutex.h"
+ #include "threads/mutex.hpp"
#include "threads/threadlist.h"
#include "threads/thread.h"
#endif
#if !defined(__DARWIN__)
- # if defined(__LINUX__)
- # define GC_LINUX_THREADS
- # elif defined(__IRIX__)
- # define GC_IRIX_THREADS
- # endif
# include <semaphore.h>
- # if defined(ENABLE_GC_BOEHM)
- # include "mm/boehm-gc/include/gc.h"
- # endif
+ #endif
+
+ #if defined(__LINUX__)
+ # define GC_LINUX_THREADS
+ #elif defined(__IRIX__)
+ # define GC_IRIX_THREADS
+ #elif defined(__DARWIN__)
+ # define GC_DARWIN_THREADS
+ #endif
+
+ #if defined(ENABLE_GC_BOEHM)
+ /* We need to include Boehm's gc.h here because it overrides
+ pthread_create and friends. */
+ # include "mm/boehm-gc/include/gc.h"
#endif
#if defined(ENABLE_JVMTI)
sem->value = value;
- mutex_init(&sem->mutex);
+ sem->mutex = Mutex_new();
if (pthread_cond_init(&sem->cond, NULL) < 0)
return -1;
static int sem_post(sem_t *sem)
{
- mutex_lock(&sem->mutex);
+ Mutex_lock(sem->mutex);
sem->value++;
if (pthread_cond_signal(&sem->cond) < 0) {
- mutex_unlock(&sem->mutex);
+ Mutex_unlock(sem->mutex);
return -1;
}
- mutex_unlock(&sem->mutex);
+ Mutex_unlock(sem->mutex);
return 0;
}
static int sem_wait(sem_t *sem)
{
- mutex_lock(&sem->mutex);
+ Mutex_lock(sem->mutex);
while (sem->value == 0) {
+ #error We cannot call pthread_cond_wait on a Mutex-class pointer.
pthread_cond_wait(&sem->cond, &sem->mutex);
}
sem->value--;
- mutex_unlock(&sem->mutex);
+ Mutex_unlock(sem->mutex);
return 0;
}
if (pthread_cond_destroy(&sem->cond) < 0)
return -1;
- mutex_destroy(&sem->mutex);
+ Mutex_destroy(sem->mutex);
return 0;
}
#endif /* defined(__DARWIN__) */
- /* internally used constants **************************************************/
-
- /* CAUTION: Do not change these values. Boehm GC code depends on them. */
- #define STOPWORLD_FROM_GC 1
- #define STOPWORLD_FROM_CLASS_NUMBERING 2
-
-
/* startupinfo *****************************************************************
Struct used to pass info from threads_start_thread to
#endif
/* global mutex for stop-the-world */
- static mutex_t stopworldlock;
+ static Mutex* stopworldlock;
#if defined(ENABLE_GC_CACAO)
/* global mutex for the GC */
- static mutex_t mutex_gc;
+ static Mutex* mutex_gc;
#endif
/* global mutex and condition for joining threads on exit */
- static mutex_t mutex_join;
- static pthread_cond_t cond_join;
-
- /* this is one of the STOPWORLD_FROM_ constants, telling why the world is */
- /* being stopped */
- static volatile int stopworldwhere;
+ static Mutex* mutex_join;
+ static Condition* cond_join;
#if defined(ENABLE_GC_CACAO)
-
/* semaphore used for acknowleding thread suspension */
static sem_t suspend_ack;
- #if defined(__IRIX__)
- static mutex_t suspend_ack_lock = MUTEX_INITIALIZER;
- static pthread_cond_t suspend_cond = PTHREAD_COND_INITIALIZER;
- #endif
-
- #endif /* ENABLE_GC_CACAO */
-
- /* mutexes used by the fake atomic instructions */
- #if defined(USE_FAKE_ATOMIC_INSTRUCTIONS)
- mutex_t _cas_lock = MUTEX_INITIALIZER;
- mutex_t _mb_lock = MUTEX_INITIALIZER;
#endif
}
- /* lock_stopworld **************************************************************
-
- Enter the stopworld lock, specifying why the world shall be stopped.
-
- IN:
- where........ STOPWORLD_FROM_GC (1) from within GC
- STOPWORLD_FROM_CLASS_NUMBERING (2) class numbering
-
- ******************************************************************************/
-
- void lock_stopworld(int where)
- {
- mutex_lock(&stopworldlock);
- /* stopworldwhere = where; */
- }
-
-
- /* unlock_stopworld ************************************************************
-
- Release the stopworld lock.
-
- ******************************************************************************/
-
- void unlock_stopworld(void)
- {
- /* stopworldwhere = 0; */
- mutex_unlock(&stopworldlock);
- }
-
- /* XXX We disable that whole bunch of code until we have the exact-GC
- running. Some of it may only be needed by the old Boehm-based
- suspension handling. */
-
- #if 0
-
- #if !defined(__DARWIN__)
- /* Caller must hold threadlistlock */
- static s4 threads_cast_sendsignals(s4 sig)
- {
- threadobject *t;
- threadobject *self;
- s4 count;
-
- self = THREADOBJECT;
-
- /* iterate over all started threads */
-
- count = 0;
-
- for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) {
- /* don't send the signal to ourself */
-
- if (t == self)
- continue;
-
- /* don't send the signal to NEW threads (because they are not
- completely initialized) */
-
- if (t->state == THREAD_STATE_NEW)
- continue;
-
- /* send the signal */
-
- pthread_kill(t->tid, sig);
-
- /* increase threads count */
-
- count++;
- }
-
- return count;
- }
-
- #else
-
- static void threads_cast_darwinstop(void)
- {
- threadobject *tobj = mainthreadobj;
- threadobject *self = THREADOBJECT;
-
- do {
- if (tobj != self)
- {
- thread_state_flavor_t flavor = MACHINE_THREAD_STATE;
- mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT;
- #if defined(__I386__)
- i386_thread_state_t thread_state;
- #else
- ppc_thread_state_t thread_state;
- #endif
- mach_port_t thread = tobj->mach_thread;
- kern_return_t r;
-
- r = thread_suspend(thread);
-
- if (r != KERN_SUCCESS)
- vm_abort("thread_suspend failed");
-
- r = thread_get_state(thread, flavor, (natural_t *) &thread_state,
- &thread_state_count);
-
- if (r != KERN_SUCCESS)
- vm_abort("thread_get_state failed");
-
- md_critical_section_restart((ucontext_t *) &thread_state);
-
- r = thread_set_state(thread, flavor, (natural_t *) &thread_state,
- thread_state_count);
-
- if (r != KERN_SUCCESS)
- vm_abort("thread_set_state failed");
- }
-
- tobj = tobj->next;
- } while (tobj != mainthreadobj);
- }
-
- static void threads_cast_darwinresume(void)
- {
- threadobject *tobj = mainthreadobj;
- threadobject *self = THREADOBJECT;
-
- do {
- if (tobj != self)
- {
- mach_port_t thread = tobj->mach_thread;
- kern_return_t r;
-
- r = thread_resume(thread);
-
- if (r != KERN_SUCCESS)
- vm_abort("thread_resume failed");
- }
-
- tobj = tobj->next;
- } while (tobj != mainthreadobj);
- }
-
- #endif
-
- #if defined(__IRIX__)
- static void threads_cast_irixresume(void)
- {
- mutex_lock(&suspend_ack_lock);
- pthread_cond_broadcast(&suspend_cond);
- mutex_unlock(&suspend_ack_lock);
- }
- #endif
-
- #if defined(ENABLE_GC_BOEHM) && !defined(__DARWIN__)
- static void threads_sigsuspend_handler(ucontext_t *_uc)
- {
- int sig;
- sigset_t sigs;
-
- /* XXX TWISTI: this is just a quick hack */
- #if defined(ENABLE_JIT)
- md_critical_section_restart(_uc);
- #endif
-
- /* Do as Boehm does. On IRIX a condition variable is used for wake-up
- (not POSIX async-safe). */
- #if defined(__IRIX__)
- mutex_lock(&suspend_ack_lock);
- threads_sem_post(&suspend_ack);
- pthread_cond_wait(&suspend_cond, &suspend_ack_lock);
- mutex_unlock(&suspend_ack_lock);
- #elif defined(__CYGWIN__)
- /* TODO */
- assert(0);
- #else
-
- sig = GC_signum2();
- sigfillset(&sigs);
- sigdelset(&sigs, sig);
- sigsuspend(&sigs);
- #endif
- }
- #endif
-
-
/* threads_stopworld ***********************************************************
Stops the world from turning. All threads except the calling one
*******************************************************************************/
+ #if defined(ENABLE_GC_CACAO)
void threads_stopworld(void)
{
#if !defined(__DARWIN__) && !defined(__CYGWIN__)
s4 count, i;
#endif
- lock_stopworld(STOPWORLD_FROM_CLASS_NUMBERING);
+ Mutex_lock(stopworldlock);
/* lock the threads lists */
non-signaled NEW threads can't change their state and execute
code. */
}
+ #endif
/* threads_startworld **********************************************************
*******************************************************************************/
+ #if defined(ENABLE_GC_CACAO)
void threads_startworld(void)
{
#if !defined(__DARWIN__) && !defined(__CYGWIN__)
threadlist_unlock();
- unlock_stopworld();
+ Mutex_unlock(stopworldlock);
}
-
#endif
void threads_impl_thread_init(threadobject *t)
{
- int result;
-
/* initialize the mutex and the condition */
- mutex_init(&t->flc_lock);
+ t->flc_lock = Mutex_new();
+ t->flc_cond = Condition_new();
- result = pthread_cond_init(&t->flc_cond, NULL);
- if (result != 0)
- vm_abort_errnum(result, "threads_impl_thread_new: pthread_cond_init failed");
-
- mutex_init(&(t->waitmutex));
-
- result = pthread_cond_init(&(t->waitcond), NULL);
- if (result != 0)
- vm_abort_errnum(result, "threads_impl_thread_new: pthread_cond_init failed");
-
- mutex_init(&(t->suspendmutex));
+ t->waitmutex = Mutex_new();
+ t->waitcond = Condition_new();
- result = pthread_cond_init(&(t->suspendcond), NULL);
- if (result != 0)
- vm_abort_errnum(result, "threads_impl_thread_new: pthread_cond_init failed");
+ t->suspendmutex = Mutex_new();
+ t->suspendcond = Condition_new();
+
+#if defined(ENABLE_TLH)
+ tlh_init(&(t->tlh));
+#endif
}
/* threads_impl_thread_clear ***************************************************
t->interrupted = false;
t->signaled = false;
- t->sleeping = false;
t->suspended = false;
t->suspend_reason = 0;
/* not really needed */
t->flc_object = NULL;
+
+#if defined(ENABLE_TLH)
+ tlh_destroy(&(t->tlh));
+ tlh_init(&(t->tlh));
+#endif
}
/* Destroy the mutex and the condition. */
- mutex_destroy(&(t->flc_lock));
+ Mutex_delete(t->flc_lock);
result = pthread_cond_destroy(&(t->flc_cond));
if (result != 0)
vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed");
- mutex_destroy(&(t->waitmutex));
+ Mutex_delete(t->waitmutex);
result = pthread_cond_destroy(&(t->waitcond));
if (result != 0)
vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed");
- mutex_destroy(&(t->suspendmutex));
+ Mutex_delete(t->suspendmutex);
result = pthread_cond_destroy(&(t->suspendcond));
{
int result;
- mutex_init(&stopworldlock);
+ stopworldlock = Mutex_new();
/* initialize exit mutex and condition (on exit we join all
threads) */
- mutex_init(&mutex_join);
-
- result = pthread_cond_init(&cond_join, NULL);
- if (result != 0)
- vm_abort_errnum(result, "threads_impl_preinit: pthread_cond_init failed");
+ mutex_join = Mutex_new();
+ cond_join = Condition_new();
#if defined(ENABLE_GC_CACAO)
/* initialize the GC mutex & suspend semaphore */
- mutex_init(&mutex_gc);
+ mutex_gc = Mutex_new();
threads_sem_init(&suspend_ack, 0, 0);
#endif
#if defined(ENABLE_GC_CACAO)
void threads_mutex_gc_lock(void)
{
- mutex_lock(&mutex_gc);
+ Mutex_lock(mutex_gc);
}
#endif
#if defined(ENABLE_GC_CACAO)
void threads_mutex_gc_unlock(void)
{
- mutex_unlock(&mutex_gc);
+ Mutex_unlock(mutex_gc);
}
#endif
void threads_mutex_join_lock(void)
{
- mutex_lock(&mutex_join);
+ Mutex_lock(mutex_join);
}
void threads_mutex_join_unlock(void)
{
- mutex_unlock(&mutex_join);
+ Mutex_unlock(mutex_join);
}
java_handle_t *o;
functionptr function;
+ #if defined(ENABLE_GC_BOEHM)
+ # if !defined(__DARWIN__)
+ struct GC_stack_base sb;
+ int result;
+ # endif
+ #endif
+
#if defined(ENABLE_INTRP)
u1 *intrp_thread_stack;
+ #endif
+ #if defined(ENABLE_INTRP)
/* create interpreter stack */
if (opt_intrp) {
thread_set_current(t);
+ #if defined(ENABLE_GC_BOEHM)
+ # if defined(__DARWIN__)
+ // This is currently not implemented in Boehm-GC. Just fail silently.
+ # else
+ /* Register the thread with Boehm-GC. This must happen before the
+ thread allocates any memory from the GC heap.*/
+
+ result = GC_get_stack_base(&sb);
+
+ if (result != 0)
+ vm_abort("threads_startup_thread: GC_get_stack_base failed: result=%d", result);
+
+ GC_register_my_thread(&sb);
+ # endif
+ #endif
+
/* get the java.lang.Thread object for this thread */
object = (java_lang_Thread *) thread_get_object(t);
/* We ignore the return value. */
- (void) threads_detach_thread(t);
+ (void) thread_detach_current_thread();
/* set ThreadMXBean variables */
}
- /* threads_detach_thread *******************************************************
-
- Detaches the passed thread from the VM. Used in JNI.
-
- *******************************************************************************/
-
- bool threads_detach_thread(threadobject *t)
+ /**
+ * Detaches the current thread from the VM.
+ *
+ * @return true on success, false otherwise
+ */
+ bool thread_detach_current_thread(void)
{
+ threadobject *t;
bool result;
java_lang_Thread *object;
java_handle_t *o;
methodinfo *m;
#endif
+ t = thread_get_current();
+
+ /* Sanity check. */
+
+ assert(t != NULL);
+
/* If the given thread has already been detached, this operation
is a no-op. */
/* Signal that this thread has finished and leave the mutex. */
- pthread_cond_signal(&cond_join);
+ Condition_signal(cond_join);
threads_mutex_join_unlock();
return true;
}
- #if defined(ENABLE_GC_CACAO)
-
/* threads_suspend_thread ******************************************************
Suspend the passed thread. Execution stops until the thread
bool threads_suspend_thread(threadobject *thread, s4 reason)
{
/* acquire the suspendmutex */
- mutex_lock(&(thread->suspendmutex));
+ Mutex_lock(thread->suspendmutex);
if (thread->suspended) {
- mutex_unlock(&(thread->suspendmutex));
+ Mutex_unlock(thread->suspendmutex);
return false;
}
*******************************************************************************/
+ #if defined(ENABLE_GC_CACAO)
void threads_suspend_ack(u1* pc, u1* sp)
{
threadobject *thread;
DEBUGTHREADS("suspending", thread);
/* release the suspension mutex and wait till we are resumed */
- pthread_cond_wait(&(thread->suspendcond), &(thread->suspendmutex));
+ Condition_wait(thread->suspendcond, thread->suspendmutex);
DEBUGTHREADS("resuming", thread);
/* TODO: free dump memory */
/* release the suspendmutex */
- mutex_unlock(&(thread->suspendmutex));
+ Mutex_unlock(thread->suspendmutex);
}
+ #endif
/* threads_resume_thread *******************************************************
*******************************************************************************/
+ #if defined(ENABLE_GC_CACAO)
bool threads_resume_thread(threadobject *thread)
{
/* acquire the suspendmutex */
- mutex_lock(&(thread->suspendmutex));
+ Mutex_lock(thread->suspendmutex);
if (!thread->suspended) {
- mutex_unlock(&(thread->suspendmutex));
+ Mutex_unlock(thread->suspendmutex);
return false;
}
/* tell everyone that the thread should resume */
assert(thread != THREADOBJECT);
- pthread_cond_broadcast(&(thread->suspendcond));
+ Condition_broadcast(thread->suspendcond);
/* release the suspendmutex */
- mutex_unlock(&(thread->suspendmutex));
+ Mutex_unlock(thread->suspendmutex);
return true;
}
-
#endif
+
/* threads_join_all_threads ****************************************************
Join all non-daemon threads.
non-daemon thread. */
while (threadlist_get_non_daemons() > 1)
- pthread_cond_wait(&cond_join, &mutex_join);
+ Condition_wait(cond_join, mutex_join);
/* leave join mutex */
{
/* acquire the waitmutex */
- mutex_lock(&t->waitmutex);
-
- /* mark us as sleeping */
-
- t->sleeping = true;
+ Mutex_lock(t->waitmutex);
/* wait on waitcond */
{
thread_set_state_timed_waiting(t);
- pthread_cond_timedwait(&t->waitcond, &t->waitmutex,
- wakeupTime);
+ Condition_timedwait(t->waitcond, t->waitmutex, wakeupTime);
thread_set_state_runnable(t);
}
while (!t->interrupted && !t->signaled) {
thread_set_state_waiting(t);
- pthread_cond_wait(&t->waitcond, &t->waitmutex);
+ Condition_wait(t->waitcond, t->waitmutex);
thread_set_state_runnable(t);
}
}
- t->sleeping = false;
-
/* release the waitmutex */
- mutex_unlock(&t->waitmutex);
+ Mutex_unlock(t->waitmutex);
}
void threads_thread_interrupt(threadobject *thread)
{
+ #if defined(__LINUX__) && defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+ /* See openjdk/jdk/src/solaris/native/java/net/linux_close.c, "sigWakeup" */
+ int sig = (__SIGRTMAX - 2);
+ #else
+ int sig = SIGHUP;
+ #endif
/* Signal the thread a "waitcond" and tell it that it has been
interrupted. */
- mutex_lock(&thread->waitmutex);
+ Mutex_lock(thread->waitmutex);
DEBUGTHREADS("interrupted", thread);
/* Interrupt blocking system call using a signal. */
- pthread_kill(thread->tid, SIGHUP);
+ pthread_kill(thread->tid, sig);
- if (thread->sleeping)
- pthread_cond_signal(&thread->waitcond);
+ Condition_signal(thread->waitcond);
thread->interrupted = true;
- mutex_unlock(&thread->waitmutex);
+ Mutex_unlock(thread->waitmutex);
}
sched_yield();
}
+#if defined(ENABLE_TLH)
+
+void threads_tlh_add_frame() {
+ tlh_add_frame(&(THREADOBJECT->tlh));
+}
+
+void threads_tlh_remove_frame() {
+ tlh_remove_frame(&(THREADOBJECT->tlh));
+}
+
+#endif
/*
* These are local overrides for various environment variables in Emacs.
#include "mm/memory.h"
+#if defined(ENABLE_TLH)
+#include "mm/tlh.h"
+#endif
+
#include "native/localref.h"
- #include "threads/mutex.h"
+ #include "threads/condition.hpp"
+ #include "threads/mutex.hpp"
#include "threads/posix/lock.h"
#endif
+
/* current threadobject *******************************************************/
#if defined(HAVE___THREAD)
struct threadobject *flc_list; /* FLC list head for this thread */
struct threadobject *flc_next; /* next pointer for FLC list */
java_handle_t *flc_object;
- mutex_t flc_lock; /* controlling access to these fields */
- pthread_cond_t flc_cond;
+ Mutex* flc_lock; /* controlling access to these fields */
+ Condition* flc_cond;
/* these are used for the wait/notify implementation */
- mutex_t waitmutex;
- pthread_cond_t waitcond;
+ Mutex* waitmutex;
+ Condition* waitcond;
- mutex_t suspendmutex; /* lock before suspending this thread */
- pthread_cond_t suspendcond; /* notify to resume this thread */
+ Mutex* suspendmutex; /* lock before suspending this thread */
+ Condition* suspendcond; /* notify to resume this thread */
bool interrupted;
bool signaled;
- bool sleeping;
bool suspended; /* is this thread suspended? */
s4 suspend_reason; /* reason for suspending */
u4 tracejavacallcount;
#endif
+#if defined(ENABLE_TLH)
+ tlh_t tlh;
+#endif
+
+#if defined(ENABLE_ESCAPE_REASON)
+ void *escape_reasons;
+#endif
+
listnode_t linkage; /* threads-list */
listnode_t linkage_free; /* free-list */
};
void threads_set_thread_priority(pthread_t tid, int priority);
- bool threads_detach_thread(threadobject *thread);
-
#if defined(ENABLE_GC_CACAO)
bool threads_suspend_thread(threadobject *thread, s4 reason);
void threads_suspend_ack(u1* pc, u1* sp);
void threads_thread_interrupt(threadobject *thread);
+#if defined(ENABLE_TLH)
+void threads_tlh_add_frame();
+void threads_tlh_remove_frame();
+#endif
+
#endif /* _THREAD_POSIX_H */
#include "vm/exceptions.h"
#include "vm/global.h"
#include "vm/initialize.h"
- #include "vm/primitive.h"
+ #include "vm/primitive.hpp"
#include "vm/stringlocal.h"
#include "vm/jit/asmpart.h"
*******************************************************************************/
- bool builtin_instanceof(java_handle_t *o, classinfo *class)
+ bool builtin_instanceof(java_handle_t *o, classinfo *c)
{
- classinfo *c;
+ classinfo *oc;
if (o == NULL)
return 0;
- LLNI_class_get(o, c);
+ LLNI_class_get(o, oc);
- return class_isanysubclass(c, class);
+ return class_isanysubclass(oc, c);
}
*******************************************************************************/
- bool builtin_checkcast(java_handle_t *o, classinfo *class)
+ bool builtin_checkcast(java_handle_t *o, classinfo *c)
{
- classinfo *c;
+ classinfo *oc;
if (o == NULL)
return 1;
- LLNI_class_get(o, c);
+ LLNI_class_get(o, oc);
- if (class_isanysubclass(c, class))
+ if (class_isanysubclass(oc, c))
return 1;
return 0;
return o;
}
+#if defined(ENABLE_ESCAPE_REASON)
+java_handle_t *builtin_escape_reason_new(classinfo *c) {
+ print_escape_reasons();
+ return builtin_java_new(c);
+}
+#endif
+
+#if defined(ENABLE_TLH)
+java_handle_t *builtin_tlh_new(classinfo *c)
+{
+ java_handle_t *o;
+#if defined(ENABLE_RT_TIMING)
+ struct timespec time_start, time_end;
+#endif
+#if defined(ENABLE_CYCLES_STATS)
+ u8 cycles_start, cycles_end;
+#endif
+
+ RT_TIMING_GET_TIME(time_start);
+ CYCLES_STATS_GET(cycles_start);
+
+ /* is the class loaded */
+
+ assert(c->state & CLASS_LOADED);
+
+ /* check if we can instantiate this class */
+
+ if (c->flags & ACC_ABSTRACT) {
+ exceptions_throw_instantiationerror(c);
+ return NULL;
+ }
+
+ /* is the class linked */
+
+ if (!(c->state & CLASS_LINKED))
+ if (!link_class(c))
+ return NULL;
+
+ if (!(c->state & CLASS_INITIALIZED)) {
+#if !defined(NDEBUG)
+ if (initverbose)
+ log_message_class("Initialize class (from builtin_new): ", c);
+#endif
+
+ if (!initialize_class(c))
+ return NULL;
+ }
+
+ /*
+ o = tlh_alloc(&(THREADOBJECT->tlh), c->instancesize);
+ */
+ o = NULL;
+
+ if (o == NULL) {
+ o = heap_alloc(c->instancesize, c->flags & ACC_CLASS_HAS_POINTERS,
+ c->finalizer, true);
+ }
+
+ if (!o)
+ return NULL;
+
+#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES)
+ /* XXX this is only a dirty hack to make Boehm work with handles */
+
+ o = LLNI_WRAP((java_object_t *) o);
+#endif
+
+ LLNI_vftbl_direct(o) = c->vftbl;
+
+#if defined(ENABLE_THREADS)
+ lock_init_object_lock(LLNI_DIRECT(o));
+#endif
+
+ CYCLES_STATS_GET(cycles_end);
+ RT_TIMING_GET_TIME(time_end);
+
+/*
+ CYCLES_STATS_COUNT(builtin_new,cycles_end - cycles_start);
+ RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_OBJECT);
+*/
+
+ return o;
+#endif
+}
/* builtin_java_new ************************************************************
return;
}
- /* we try to throw exception with the same message as SUN does */
+ // Check if offsets and length are positive.
+ if ((srcStart < 0) || (destStart < 0) || (len < 0)) {
+ exceptions_throw_arrayindexoutofboundsexception();
+ return;
+ }
- if ((len < 0) || (srcStart < 0) || (destStart < 0) ||
- (srcStart + len < 0) || (srcStart + len > LLNI_array_size(src)) ||
- (destStart + len < 0) || (destStart + len > LLNI_array_size(dest))) {
+ // Check if ranges are valid.
+ if ((((uint32_t) srcStart + (uint32_t) len) > (uint32_t) LLNI_array_size(src)) ||
+ (((uint32_t) destStart + (uint32_t) len) > (uint32_t) LLNI_array_size(dest))) {
exceptions_throw_arrayindexoutofboundsexception();
return;
}
+ // Special case.
+ if (len == 0) {
+ return;
+ }
+
if (sdesc->componentvftbl == ddesc->componentvftbl) {
/* We copy primitive values or references of exactly the same type */
#ifndef _BUILTIN_H
#define _BUILTIN_H
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
/* forward typedefs ***********************************************************/
typedef struct builtintable_entry builtintable_entry;
* ICMD_BUILTIN3.)
*/
- bool builtin_instanceof(java_handle_t *obj, classinfo *class);
+ bool builtin_instanceof(java_handle_t *obj, classinfo *c);
/* NOT AN OP */
- bool builtin_checkcast(java_handle_t *obj, classinfo *class);
+ bool builtin_checkcast(java_handle_t *obj, classinfo *c);
/* NOT AN OP */
bool builtin_arrayinstanceof(java_handle_t *h, classinfo *targetclass);
/* NOT AN OP */
/* NOT AN OP */
java_handle_t *builtin_java_new(java_handle_t *c);
#define BUILTIN_new (functionptr) builtin_java_new
+
+#if defined(ENABLE_TLH)
+#define BUILTIN_tlh_new (functionptr) builtin_tlh_new
+java_handle_t *builtin_tlh_new(classinfo *c);
+#endif
+
+#if defined(ENABLE_ESCAPE_REASON)
+#define BUILTIN_escape_reason_new (functionptr)builtin_escape_reason_new
+java_handle_t *builtin_escape_reason_new(classinfo *c);
+#endif
+
java_object_t *builtin_fast_new(classinfo *c);
#define BUILTIN_FAST_new (functionptr) builtin_fast_new
void builtin_print_cycles_stats(FILE *file);
#endif
+ #ifdef __cplusplus
+ }
+ #endif
+
#endif /* _BUILTIN_H */
#include "config.h"
+ #include <stdbool.h>
#include <stdint.h>
#include "vm/types.h"
typedef void (*functionptr) (void); /* generic function pointer */
typedef u1* methodptr;
- typedef unsigned int bool; /* boolean data type */
-
- #define true 1
- #define false 0
-
#if defined(ENABLE_SSA)
/* immediate to get an addidional target Local Var Index */
/* for IINC in Combination with SSA */
#define ACC_METHOD_IMPLEMENTED 0x00020000 /* there is an implementation */
#define ACC_METHOD_MONOMORPHIC 0x00040000 /* currently monomorphic method */
#define ACC_METHOD_EA 0x00080000 /* method being escape analyzed */
+#define ACC_METHOD_MONOMORPHY_USED \
+ 0x00100000
+#define ACC_METHOD_PARENT_MONOMORPHY_USED \
+ 0x00200000
/* data structures of the runtime system **************************************/
#include "vm/builtin.h"
#include "vm/exceptions.h"
#include "vm/global.h"
+ #include "vm/primitive.hpp"
#include "vm/stringlocal.h"
#include "vm/vm.h"
if (bptr->bitflags & BBFLAG_REPLACEMENT) {
if (cd->replacementpoint[-1].flags & RPLPOINT_FLAG_COUNTDOWN) {
MCODECHECK(32);
- disp = (s4) &(m->hitcountdown);
- M_ISUB_IMM_MEMABS(1, disp);
- M_BS(0);
+ emit_trap_countdown(cd, &(m->hitcountdown));
}
}
#endif
break;
case ICMD_PUTSTATIC: /* ..., value ==> ... */
-
+
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
uf = iptr->sx.s23.s3.uf;
fieldtype = uf->fieldref->parseddesc.fd->type;
bte = iptr->sx.s23.s3.bte;
md = bte->md;
+
+#if defined(ENABLE_ESCAPE_REASON)
+ if (bte->fp == BUILTIN_escape_reason_new) {
+ void set_escape_reasons(void *);
+ M_ASUB_IMM(8, REG_SP);
+ M_MOV_IMM(iptr->escape_reasons, REG_ITMP1);
+ M_AST(EDX, REG_SP, 4);
+ M_AST(REG_ITMP1, REG_SP, 0);
+ M_MOV_IMM(set_escape_reasons, REG_ITMP1);
+ M_CALL(REG_ITMP1);
+ M_ALD(EDX, REG_SP, 4);
+ M_AADD_IMM(8, REG_SP);
+ }
+#endif
+
goto gen_method;
case ICMD_INVOKESTATIC: /* ..., [arg1, [arg2 ...]] ==> ... */
supervftbl = super->vftbl;
}
- if ((super == NULL) || !(super->flags & ACC_INTERFACE))
- CODEGEN_CRITICAL_SECTION_NEW;
-
s1 = emit_load_s1(jd, iptr, REG_ITMP1);
/* if class is not resolved, check which code to call */
M_MOV_IMM(supervftbl, REG_ITMP3);
- CODEGEN_CRITICAL_SECTION_START;
-
M_ILD32(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
/* if (s1 != REG_ITMP1) { */
M_MOV_IMM(supervftbl, REG_ITMP3);
M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval));
- CODEGEN_CRITICAL_SECTION_END;
-
/* } */
M_CMP(REG_ITMP3, REG_ITMP2);
supervftbl = super->vftbl;
}
- if ((super == NULL) || !(super->flags & ACC_INTERFACE))
- CODEGEN_CRITICAL_SECTION_NEW;
-
s1 = emit_load_s1(jd, iptr, REG_ITMP1);
d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
M_MOV_IMM(supervftbl, REG_ITMP2);
- CODEGEN_CRITICAL_SECTION_START;
-
M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, diffval));
M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
- CODEGEN_CRITICAL_SECTION_END;
-
M_ISUB(REG_ITMP2, REG_ITMP1);
M_CLR(d); /* may be REG_ITMP2 */
M_CMP(REG_ITMP3, REG_ITMP1);
switch (md->returntype.type) {
case TYPE_INT:
case TYPE_ADR:
+ switch (md->returntype.decltype) {
+ case PRIMITIVETYPE_BOOLEAN:
+ M_BZEXT(REG_RESULT, REG_RESULT);
+ break;
+ case PRIMITIVETYPE_BYTE:
+ M_BSEXT(REG_RESULT, REG_RESULT);
+ break;
+ case PRIMITIVETYPE_CHAR:
+ M_CZEXT(REG_RESULT, REG_RESULT);
+ break;
+ case PRIMITIVETYPE_SHORT:
+ M_SSEXT(REG_RESULT, REG_RESULT);
+ break;
+ }
M_IST(REG_RESULT, REG_SP, 1 * 8);
break;
case TYPE_LNG:
M_ALD_MEM(REG_METHODPTR, TRAP_COMPILER);
}
+/* emit_trap_countdown *********************************************************
+
+ Emit a countdown trap.
+
+ counter....absolute address of the counter variable
+
+*******************************************************************************/
+
+void emit_trap_countdown(codegendata *cd, s4 *counter)
+{
+ M_ISUB_IMM_MEMABS(1, (s4) counter);
+ M_BNS(6);
+ M_ALD_MEM(REG_METHODPTR, TRAP_COUNTDOWN);
+}
/* emit_trap *******************************************************************
}
+ void emit_movsbl_reg_reg(codegendata *cd, s4 a, s4 b)
+ {
+ assert(a < 4); /* Can only operate on al, bl, cl, dl. */
+ *(cd->mcodeptr++) = 0x0f;
+ *(cd->mcodeptr++) = 0xbe;
+ emit_reg((b),(a));
+ }
+
+
void emit_movsbl_memindex_reg(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
{
COUNT(count_mov_mem_reg);
}
+ void emit_movzbl_reg_reg(codegendata *cd, s4 a, s4 b)
+ {
+ assert(a < 4); /* Can only operate on al, bl, cl, dl. */
+ *(cd->mcodeptr++) = 0x0f;
+ *(cd->mcodeptr++) = 0xb6;
+ emit_reg((b),(a));
+ }
+
+
void emit_movzwl_reg_reg(codegendata *cd, s4 a, s4 b)
{
*(cd->mcodeptr++) = 0x0f;
_mc->gregs[REG_EIP] = (uintptr_t) p;
}
}
+#if defined(ENABLE_REPLACEMENT)
+ else if (type == TRAP_COUNTDOWN) {
+ /* context has been written by md_replace_executionstate_write */
+ }
+#endif
else {
_mc->gregs[REG_EAX] = (uintptr_t) p;
_mc->gregs[REG_ECX] = (uintptr_t) xpc; /* REG_ITMP2_XPC */
}
- /* md_critical_section_restart *************************************************
-
- Search the critical sections tree for a matching section and set
- the PC to the restart point, if necessary.
-
- *******************************************************************************/
-
- #if defined(ENABLE_THREADS)
- void md_critical_section_restart(ucontext_t *_uc)
- {
- mcontext_t *_mc;
- u1 *pc;
- u1 *npc;
-
- _mc = &_uc->uc_mcontext;
-
- pc = (u1 *) _mc->gregs[REG_EIP];
-
- npc = critical_find_restart_point(pc);
-
- if (npc != NULL)
- _mc->gregs[REG_EIP] = (ptrint) npc;
- }
- #endif
-
-
/*
* 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
#include "md-trap.h"
+ #include "mm/memory.h"
+
#include "native/llni.h"
#include "toolbox/logging.h"
p = jit_compile_handle(m, sfi.pv, ra, (void *) val);
break;
+#if defined(ENABLE_REPLACEMENT)
+ case TRAP_COUNTDOWN:
+#if defined(__I386__)
+ replace_me_wrapper((char*)xpc - 13, context);
+#endif
+ p = NULL;
+ break;
+#endif
+
default:
/* Let's try to get a backtrace. */
#include "vm/access.h"
#include "vm/array.h"
#include "vm/exceptions.h"
- #include "vm/primitive.h"
+ #include "vm/primitive.hpp"
#include "vm/stringlocal.h"
#include "vm/vm.h"
if ((ms->flags & ACC_METHOD_IMPLEMENTED) && ms->name != utf_init) {
do {
+
+#if defined(ENABLE_TLH)
+ if (mg->flags & ACC_METHOD_MONOMORPHY_USED) {
+ printf("%s/%s is evil! the siner is %s/%s\n", mg->clazz->name->text, mg->name->text,
+ ms->clazz->name->text, ms->name->text);
+ ms->flags |= ACC_METHOD_PARENT_MONOMORPHY_USED;
+ }
+#endif
+
if (mg->flags & ACC_METHOD_IMPLEMENTED) {
/* this adds another implementation */
{
LOCK_MONITOR_ENTER(linker_classrenumber_lock);
- #if 0 && defined(ENABLE_THREADS) && !defined(DISABLE_GC)
- threads_stopworld();
- #endif
-
if (!(c->flags & ACC_INTERFACE)) {
c->nextsub = NULL;
c->sub = NULL;
linker_compute_class_values(class_java_lang_Object);
LOCK_MONITOR_EXIT(linker_classrenumber_lock);
-
- #if 0 && defined(ENABLE_THREADS) && !defined(DISABLE_GC)
- threads_startworld();
- #endif
}