dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
dnl 02110-1301, USA.
dnl
-dnl $Id: configure.ac 7667 2007-04-05 00:16:05Z michi $
+dnl $Id: configure.ac 7796 2007-04-23 20:04:44Z twisti $
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(cacao, 0.97+svn, cacao@cacaojvm.org)
+AC_INIT(cacao, 0.98rc, cacao@cacaojvm.org)
AC_CONFIG_SRCDIR(src/cacao/cacao.c)
AC_CANONICAL_HOST
AC_PREREQ(2.59)
ARCH_CFLAGS="-D__POWERPC64__"
;;
+s390 )
+ ARCH_DIR="s390"
+ ARCH_CFLAGS="-D__S390__"
+ ;;
+
sparc | sparc64 )
ARCH_DIR="sparc64"
ARCH_CFLAGS="-mcpu=v9 -m64 -D__SPARC_64__"
USE_SCHEDULER="1"
;;
-s390 )
- ARCH_DIR="s390"
- ARCH_CFLAGS="-D__S390__"
- ;;
-
-
* )
AC_MSG_ERROR($host_cpu systems are not supported at this time)
;;
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],
AC_SUBST(CACAO_VM_ZIP)
-dnl which Java core library are we using?
-AC_MSG_CHECKING(which Java core library to use)
-AC_ARG_WITH([classpath],
- [AS_HELP_STRING(--with-classpath=<type>,specifies which type of classpath to use as Java core library (gnu) [[default=gnu]])],
- [case "${withval}" in
- cldc1.1)
- WITH_CLASSPATH=cldc1.1
- AC_DEFINE([WITH_CLASSPATH_CLDC1_1], 1, [use Sun's CLDC1.1 classes])
- AC_SUBST(WITH_CLASSPATH_CLDC1_1)
- ;;
- gnu)
- WITH_CLASSPATH=gnu
- AC_DEFINE([WITH_CLASSPATH_GNU], 1, [use GNU Classpath])
- AC_SUBST(WITH_CLASSPATH_GNU)
- ;;
- *)
- AC_MSG_ERROR(unknown classpath ${withval})
- ;;
- esac],
- [WITH_CLASSPATH=gnu
- AC_DEFINE([WITH_CLASSPATH_GNU], 1, [use GNU Classpath])
- AC_SUBST(WITH_CLASSPATH_GNU)])
-AC_MSG_RESULT(${WITH_CLASSPATH})
-AM_CONDITIONAL([WITH_CLASSPATH_CLDC1_1], test x"${WITH_CLASSPATH}" = "xcldc1.1")
-AM_CONDITIONAL([WITH_CLASSPATH_GNU], test x"${WITH_CLASSPATH}" = "xgnu")
-
-
-dnl where is Java core library installed?
-AC_MSG_CHECKING(where Java core library is installed)
-AC_ARG_WITH([classpath-prefix],
- [AS_HELP_STRING(--with-classpath-prefix=<dir>,installation directory of Java core library [[default=/usr/local/classpath]])],
- [CLASSPATH_PREFIX=${withval}],
- [CLASSPATH_PREFIX=/usr/local/classpath])
-AC_MSG_RESULT(${CLASSPATH_PREFIX})
-AC_DEFINE_UNQUOTED([CLASSPATH_PREFIX], "${CLASSPATH_PREFIX}", [Java core library installation directory])
-AC_SUBST(CLASSPATH_PREFIX)
-
-
-dnl where are Java core library classes installed?
-AC_MSG_CHECKING(where Java core library classes are installed)
-AC_ARG_WITH([classpath-classes],
- [AS_HELP_STRING(--with-classpath-classes=<path>,path to Java core library classes (includes the name of the file and may be flat) [[default=/usr/local/classpath/share/classpath/glibj.zip]])],
- [CLASSPATH_CLASSES=${withval}],
- [CLASSPATH_CLASSES=${CLASSPATH_PREFIX}/share/classpath/glibj.zip])
-AC_MSG_RESULT(${CLASSPATH_CLASSES})
-AC_DEFINE_UNQUOTED([CLASSPATH_CLASSES], "${CLASSPATH_CLASSES}", [Java core library classes])
-AC_SUBST(CLASSPATH_CLASSES)
-
-
-dnl where are Java core library native libraries installed?
-AC_MSG_CHECKING(where Java core library native libraries are installed)
-AC_ARG_WITH([classpath-libdir],
- [AS_HELP_STRING(--with-classpath-libdir=<dir>,installation directory of Java core library native libraries [[default=/usr/local/classpath/lib]])],
- [CLASSPATH_LIBDIR=${withval}],
- [CLASSPATH_LIBDIR=${CLASSPATH_PREFIX}/lib])
-AC_MSG_RESULT(${CLASSPATH_LIBDIR})
-
-dnl expand CLASSPATH_LIBDIR to something that is usable in C code
-AS_AC_EXPAND([CLASSPATH_LIBDIR], ${CLASSPATH_LIBDIR})
-AC_DEFINE_UNQUOTED([CLASSPATH_LIBDIR], "${CLASSPATH_LIBDIR}", [Java core library native libraries installation directory])
-AC_SUBST(CLASSPATH_LIBDIR)
-
-
-dnl where are Java core library headers installed?
-AC_MSG_CHECKING(where Java core library headers are installed)
-AC_ARG_WITH([classpath-includedir],
- [AS_HELP_STRING(--with-classpath-includedir=<dir>,installation directory of Java core library headers [[default=/usr/local/classpath/include]])],
- [CLASSPATH_INCLUDEDIR=${withval}],
- [CLASSPATH_INCLUDEDIR=${CLASSPATH_PREFIX}/include])
-AC_MSG_RESULT(${CLASSPATH_INCLUDEDIR})
-
-AC_CHECK_HEADER([${CLASSPATH_INCLUDEDIR}/jni.h],
- [AC_DEFINE_UNQUOTED([CLASSPATH_JNI_H], "${CLASSPATH_INCLUDEDIR}/jni.h", [Java core library jni.h header])],
- [AC_MSG_ERROR(cannot find jni.h)])
+AC_CHECK_WITH_CLASSPATH
+AC_CHECK_WITH_CLASSPATH_PREFIX
+AC_CHECK_WITH_CLASSPATH_CLASSES
+AC_CHECK_WITH_CLASSPATH_LIBDIR
+AC_CHECK_WITH_CLASSPATH_INCLUDEDIR
dnl if we compile for a JRE-style directory layout
[contrib/Makefile]
[contrib/setenvinstalled]
[contrib/setenvsource]
+ [contrib/vmlog/Makefile]
+ [contrib/vmlog/t/Makefile]
[doc/Makefile]
[doc/handbook/Makefile]
[man/Makefile]
##
## Changes:
##
-## $Id: Makefile.am 4357 2006-01-22 23:33:38Z twisti $
+## $Id: Makefile.am 7789 2007-04-21 16:42:52Z edwin $
## Process this file with automake to produce Makefile.in
+SUBDIRS = vmlog
+
noinst_DATA = \
setenvinstalled.in \
setenvsource.in
+++ /dev/null
-VERSION=0.0.5
-RELEASENAME=vmlog-$(VERSION)
-TARBALL=releases/$(RELEASENAME).tar.gz
-
-CFLAGS=-g -ansi -std=c99 -pedantic -Wall -Wno-long-long -Wno-unused-function -I/home/edwin/local/classpath/include
-#CFLAGS_TOOL=-O2 -DNDEBUG -ansi -std=c99 -march=pentium4m -pedantic -Wall -Wno-long-long
-CFLAGS_TOOL=-g3 -pedantic -ansi -std=c99 -Wall -Wno-long-long -Wno-unused-function
-
-all: vmlog.o vmlogdump vmlogindex vmlogdiff
-
-runtests: t/hash.run t/memdup.run t/string.run t/threadhash.run t/file.run t/log.run t/concat.run t/ring.run t/opt.run t/tags.run
-
-test: cleantests runtests
- cat TESTRESULTS
-
-cleantests:
- @rm -f TESTIDX TESTSTR TESTLOG? TESTFILE TESTRESULTS
-
-%.run: %.c t/prolog.h vmlog.c vmlog.h
- $(CC) $(CFLAGS) -I. -o $* $<
- echo $* >>TESTRESULTS
- { $* || echo "FAILED: exitcode == $$?" ; } | uniq -c >>TESTRESULTS
-
-vmlogdump: vmlogdump.c vmlog.c vmlog.h
- $(CC) $(CFLAGS_TOOL) -o $@ vmlogdump.c vmlog.c
-vmlogindex: vmlogindex.c vmlog.c vmlog.h
- $(CC) $(CFLAGS_TOOL) -o $@ vmlogindex.c vmlog.c
-vmlogdiff: vmlogdiff.c vmlog.c vmlog.h
- $(CC) $(CFLAGS_TOOL) -o $@ vmlogdiff.c vmlog.c
-
-cscope:
- cscope -b *.[ch] t/*.[ch]
-
-clean: cleantests
- rm -f *.o
- rm -f vmlogdump vmlogindex vmlogdiff
- rm -f cscope.out
- rm -f t/hash t/memdup t/string t/threadhash t/file t/log t/concat t/ring t/opt t/tags
-
-checkedin:
- if (cg-status | grep ^[AMD]) ; then echo "difference to repository!"; exit 1; else /bin/true ; fi
-
-distprep: clean all test clean
- mkdir $(RELEASENAME)
- cp -a --parents `git-ls-files` $(RELEASENAME)
- tar cfz $(TARBALL) $(RELEASENAME)/*
- rm -rf $(RELEASENAME)
-
-dist: checkedin distprep
- cg-tag $(VERSION)
How to compile a VM with vmlog
------------------------------
-You need to do two things:
+CACAO has vmlog support built-in. Use the configure flag --enable-vmlog
+to build it.
+
+For other VMs, you need to do two things:
* patch the VM code with the provided vmlog_<vm>.patch
* configure the VM with CFLAGS that include -Ivmlogdir
+++ /dev/null
-diff --git a/src/threads/native/lock.c b/src/threads/native/lock.c
-index 6eeec82..b6909f1 100644
---- a/src/threads/native/lock.c
-+++ b/src/threads/native/lock.c
-@@ -53,6 +53,8 @@
- # include "vmcore/statistics.h"
- #endif
-
-+#include <vmlog_cacao.h>
-+
- /* arch.h must be here because it defines USE_FAKE_ATOMIC_INSTRUCTIONS */
-
- #include "arch.h"
-@@ -222,6 +224,8 @@ void lock_init(void)
- pthread_mutex_init(&lock_global_pool_lock, NULL);
-
- lock_hashtable_init();
-+
-+ vmlog_cacao_init_lock();
- }
-
-
-diff --git a/src/vm/builtin.c b/src/vm/builtin.c
-index a2298c9..168d950 100644
---- a/src/vm/builtin.c
-+++ b/src/vm/builtin.c
-@@ -81,6 +81,8 @@
- #include "vmcore/options.h"
- #include "vmcore/rt-timing.h"
-
-+#include <vmlog_cacao.h>
-+
-
- /* include builtin tables *****************************************************/
-
-@@ -1149,6 +1151,8 @@ java_objectheader *builtin_trace_exception(java_objectheader *xptr,
- s4 dumpsize;
- codeinfo *code;
-
-+ return xptr;
-+
- if (opt_verbosecall && indent)
- methodindent--;
-
-@@ -1420,6 +1424,9 @@ void builtin_verbosecall_enter(s8 a0, s8 a1,
- s4 i;
- s4 pos;
-
-+ vmlog_cacao_enter_method(m);
-+ return;
-+
- md = m->parseddesc;
-
- /* calculate message length */
-@@ -1591,6 +1598,9 @@ void builtin_verbosecall_exit(s8 l, double d, float f, methodinfo *m)
- s4 pos;
- imm_union val;
-
-+ vmlog_cacao_leave_method(m);
-+ return;
-+
- md = m->parseddesc;
-
- /* calculate message length */
-@@ -2683,6 +2693,9 @@ java_objectheader *builtin_clone(void *env, java_objectheader *o)
- return co;
- }
-
-+#define NDEBUG
-+#include <vmlog_cacao.c>
-+
-
- /*
- * These are local overrides for various environment variables in Emacs.
-diff --git a/src/vm/exceptions.c b/src/vm/exceptions.c
-index 6754a62..11c3e3c 100644
---- a/src/vm/exceptions.c
-+++ b/src/vm/exceptions.c
-@@ -70,6 +70,8 @@
- #include "vmcore/loader.h"
- #include "vmcore/options.h"
-
-+#include <vmlog_cacao.h>
-+
-
- /* for raising exceptions from native methods *********************************/
-
-@@ -1771,6 +1773,8 @@ u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp
- builtin_trace_exception(xptr, m, xpc, 1);
- #endif
-
-+ vmlog_cacao_throw(xptr);
-+
- for (i = 0; i < exceptiontablelength; i++) {
- /* ATTENTION: keep this here, as we need to decrement the
- pointer before the loop executes! */
-@@ -1795,6 +1799,8 @@ u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp
- #if !defined(NDEBUG)
- /* Print stacktrace of exception when caught. */
-
-+ vmlog_cacao_catch(xptr);
-+
- if (opt_verboseexception) {
- exceptions_print_exception(xptr);
- stacktrace_print_trace(xptr);
-@@ -1852,6 +1858,8 @@ u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp
- #if !defined(NDEBUG)
- /* Print stacktrace of exception when caught. */
-
-+ vmlog_cacao_catch(xptr);
-+
- if (opt_verboseexception) {
- exceptions_print_exception(xptr);
- stacktrace_print_trace(xptr);
-@@ -1884,6 +1892,8 @@ u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp
-
- /* none of the exceptions catch this one */
-
-+ vmlog_cacao_unwnd_method(m);
-+
- return NULL;
- }
- #endif /* defined(ENABLE_JIT) */
-diff --git a/src/vm/jit/codegen-common.c b/src/vm/jit/codegen-common.c
-index 5981383..a5581b3 100644
---- a/src/vm/jit/codegen-common.c
-+++ b/src/vm/jit/codegen-common.c
-@@ -101,6 +101,8 @@
-
- # include "vmcore/statistics.h"
-
-+#include <vmlog_cacao.h>
-+
-
- /* in this tree we store all method addresses *********************************/
-
-@@ -640,6 +642,8 @@ u1 *codegen_get_pv_from_pc(u1 *pc)
- if (mte == NULL) {
- /* No method was found. Let's dump a stacktrace. */
-
-+ vmlog_cacao_signl("SIGSEGV");
-+
- log_println("We received a SIGSEGV and tried to handle it, but we were");
- log_println("unable to find a Java method at:");
- log_println("");
-diff --git a/src/vm/jit/intrp/asmpart.c b/src/vm/jit/intrp/asmpart.c
-index 52ec0d4..e9bcc50 100644
---- a/src/vm/jit/intrp/asmpart.c
-+++ b/src/vm/jit/intrp/asmpart.c
-@@ -53,6 +53,8 @@
- #include "vmcore/loader.h"
- #include "vmcore/options.h"
-
-+#include <vmlog_cacao.h>
-+
-
- static bool intrp_asm_vm_call_method_intern(methodinfo *m, s4 vmargscount,
- vm_arg *vmargs)
-@@ -206,6 +208,8 @@ Inst *intrp_asm_handle_exception(Inst *ip, java_objectheader *o, Cell *fp, Cell
- builtin_trace_exception(o, m, ip, 1);
- #endif
-
-+ vmlog_cacao_throw(o);
-+
- for (i = 0; i < exceptiontablelength; i++) {
- ex--;
-
-@@ -260,6 +264,8 @@ Inst *intrp_asm_handle_exception(Inst *ip, java_objectheader *o, Cell *fp, Cell
- if (ip-1 >= (Inst *) ex->startpc && ip-1 < (Inst *) ex->endpc &&
- (c == NULL || builtin_instanceof(o, c)))
- {
-+ vmlog_cacao_catch(o);
-+
- *new_spp = (Cell *)(((u1 *)fp) - framesize - SIZEOF_VOID_P);
- *new_fpp = fp;
- return (Inst *) (ex->handlerpc);
-@@ -289,6 +295,8 @@ Inst *intrp_asm_handle_exception(Inst *ip, java_objectheader *o, Cell *fp, Cell
-
- /* unwind stack frame */
-
-+ vmlog_cacao_unwnd_method(m);
-+
- ip = (Inst *)access_local_cell(-framesize - SIZEOF_VOID_P);
- fp = (Cell *)access_local_cell(-framesize);
- }
-diff --git a/src/vm/jit/replace.c b/src/vm/jit/replace.c
-index e16217b..7bbeeb6 100644
---- a/src/vm/jit/replace.c
-+++ b/src/vm/jit/replace.c
-@@ -57,6 +57,7 @@
- #define REPLACE_PATCH_DYNAMIC_CALL
- /*#define REPLACE_PATCH_ALL*/
-
-+#include <vmlog_cacao.h>
-
- /*** architecture-dependent configuration *************************************/
-
-@@ -2309,6 +2310,7 @@ sourcestate_t *replace_recover_source_state(rplpoint *rp,
- replace_replacement_point_println(rp, 1); );
-
- replace_read_executionstate(rp, es, ss, ss->frames == NULL);
-+ vmlog_cacao_unrol_method(ss->frames->method);
-
- #if defined(REPLACE_STATISTICS)
- REPLACE_COUNT(stat_frames);
-@@ -2529,6 +2531,7 @@ static void replace_build_execution_state_intern(sourcestate_t *ss,
-
- es->code = ss->frames->tocode;
- prevframe = ss->frames;
-+ vmlog_cacao_rerol_method(ss->frames->method);
- replace_write_executionstate(rp, es, ss, ss->frames->down == NULL);
-
- DOLOG( replace_executionstate_println(es); );
-diff --git a/src/vm/vm.c b/src/vm/vm.c
-index 362e2fd..0396243 100644
---- a/src/vm/vm.c
-+++ b/src/vm/vm.c
-@@ -82,6 +82,8 @@
- # include "native/jvmti/cacaodbg.h"
- #endif
-
-+#include <vmlog_cacao.h>
-+
-
- /* Invocation API variables ***************************************************/
-
-@@ -739,6 +741,8 @@ bool vm_create(JavaVMInitArgs *vm_args)
- jdwp = agentbypath = false;
- #endif
-
-+ vmlog_cacao_init(vm_args);
-+
- /* check the JNI version requested */
-
- switch (vm_args->version) {
void exceptions_print_current_exception(void)
{
+ abort();
}
void exceptions_throw_abstractmethoderror(void)
abort();
}
-void exceptions_throw_outofmemoryerror(void)
-{
- fprintf(stderr, "java.lang.OutOfMemoryError\n");
-
- abort();
-}
-
void exceptions_throw_verifyerror(methodinfo *m, const char *message)
{
fprintf(stderr, "java.lang.VerifyError: ");
abort();
}
-void exceptions_throw_illegalaccessexception(classinfo *c)
-{
- fprintf(stderr, "java.lang.IllegalAccessException: ");
-
- if (c != NULL)
- utf_fprint_printable_ascii_classname(stderr, c->name);
-
- fputc('\n', stderr);
-
- abort();
-}
-
void exceptions_throw_nullpointerexception(void)
{
fprintf(stderr, "java.lang.NullPointerException\n");
/* Global Variables ***********************************************************/
-list *final_list;
+list_t *final_list;
/* Global Variables ***********************************************************/
-extern list *final_list;
+extern list_t *final_list;
/* Structures *****************************************************************/
#define FINAL_FINALIZED 4
struct final_entry {
- listnode linkage;
+ listnode_t linkage;
u4 type;
java_objectheader *o;
methodinfo *finalizer;
/* check for error and throw one in case */
if (result == 0) {
- name = javastring_toutf(libName, 0);
+ name = javastring_toutf((java_objectheader *) libName, false);
exceptions_throw_unsatisfiedlinkerror(name);
}
}
-/* src/native/vm/java_lang_System.c
+/* src/native/vm/cldc1.1/java_lang_System.c
- Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+ Copyright (C) 2006, 2007 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
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Phil Tomsich
- Christian Thalinger
-
$Id: java_lang_VMRuntime.c 5900 2006-11-04 17:30:44Z michi $
*/
java_objectheader *so;
char* key;
char* value;
- java_lang_String* result;
+ java_objectheader *result;
so = (java_objectheader *) s;
result = javastring_new_from_ascii(value);
- return result;
+ return (java_lang_String *) result;
}
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
##
-## $Id: Makefile.am 7338 2007-02-13 00:17:22Z twisti $
+## $Id: Makefile.am 7786 2007-04-21 12:37:47Z edwin $
## Process this file with automake to produce Makefile.in
-AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) -I$(top_builddir)/src
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) -I$(top_builddir)/src -I$(top_srcdir)/contrib/vmlog
LIBS =
# include "vmcore/statistics.h"
#endif
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
/* arch.h must be here because it defines USE_FAKE_ATOMIC_INSTRUCTIONS */
#include "arch.h"
pthread_mutex_init(&lock_global_pool_lock, NULL);
lock_hashtable_init();
+
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_init_lock();
+#endif
}
#include "vm/types.h"
#include "vm/global.h"
+
+#include "native/jni.h"
+
#include "native/include/java_lang_Thread.h"
#if defined(ENABLE_THREADS)
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: list.c 7601 2007-03-28 23:02:50Z michi $
+ $Id: list.c 7784 2007-04-20 13:51:41Z twisti $
*/
*******************************************************************************/
-list *list_create(s4 nodeoffset)
+list_t *list_create(s4 nodeoffset)
{
- list *l;
+ list_t *l;
- l = NEW(list);
+ l = NEW(list_t);
#if defined(ENABLE_THREADS)
lock_init_object_lock((java_objectheader *) l);
l->first = NULL;
l->last = NULL;
l->nodeoffset = nodeoffset;
+ l->size = 0;
return l;
}
*******************************************************************************/
-list *list_create_dump(s4 nodeoffset)
+list_t *list_create_dump(s4 nodeoffset)
{
- list *l;
+ list_t *l;
- l = DNEW(list);
+ l = DNEW(list_t);
l->first = NULL;
l->last = NULL;
l->nodeoffset = nodeoffset;
+ l->size = 0;
return l;
}
-void list_add_first(list *l, void *element)
+/* list_add_first **************************************************************
+
+ Adds the element as first element.
+
+*******************************************************************************/
+
+void list_add_first(list_t *l, void *element)
{
- listnode *ln;
+ listnode_t *ln;
- ln = (listnode *) (((u1 *) element) + l->nodeoffset);
+ ln = (listnode_t *) (((u1 *) element) + l->nodeoffset);
LOCK_MONITOR_ENTER(l);
l->first = ln;
}
+ /* increase number of elements */
+
+ l->size++;
+
LOCK_MONITOR_EXIT(l);
}
*******************************************************************************/
-void list_add_last(list *l, void *element)
+void list_add_last(list_t *l, void *element)
{
LOCK_MONITOR_ENTER(l);
*******************************************************************************/
-void list_add_last_unsynced(list *l, void *element)
+void list_add_last_unsynced(list_t *l, void *element)
{
- listnode *ln;
+ listnode_t *ln;
- ln = (listnode *) (((u1 *) element) + l->nodeoffset);
+ ln = (listnode_t *) (((u1 *) element) + l->nodeoffset);
if (l->last) {
ln->prev = l->last;
l->last = ln;
l->first = ln;
}
+
+ /* increase number of elements */
+
+ l->size++;
}
*******************************************************************************/
-void list_add_before(list *l, void *element, void *newelement)
+void list_add_before(list_t *l, void *element, void *newelement)
{
- listnode *ln;
- listnode *newln;
+ listnode_t *ln;
+ listnode_t *newln;
- ln = (listnode *) (((u1 *) element) + l->nodeoffset);
- newln = (listnode *) (((u1 *) newelement) + l->nodeoffset);
+ ln = (listnode_t *) (((u1 *) element) + l->nodeoffset);
+ newln = (listnode_t *) (((u1 *) newelement) + l->nodeoffset);
LOCK_MONITOR_ENTER(l);
if (l->last == ln)
l->last = newln;
+ /* increase number of elements */
+
+ l->size++;
+
LOCK_MONITOR_EXIT(l);
}
*******************************************************************************/
-void list_remove(list *l, void *element)
+void list_remove(list_t *l, void *element)
{
LOCK_MONITOR_ENTER(l);
*******************************************************************************/
-void list_remove_unsynced(list *l, void *element)
+void list_remove_unsynced(list_t *l, void *element)
{
- listnode *ln;
+ listnode_t *ln;
- ln = (listnode *) (((u1 *) element) + l->nodeoffset);
+ ln = (listnode_t *) (((u1 *) element) + l->nodeoffset);
if (ln->next)
ln->next->prev = ln->prev;
ln->next = NULL;
ln->prev = NULL;
+
+ /* decrease number of elements */
+
+ l->size--;
}
*******************************************************************************/
-void *list_first(list *l)
+void *list_first(list_t *l)
{
void *el;
*******************************************************************************/
-void *list_first_unsynced(list *l)
+void *list_first_unsynced(list_t *l)
{
void *el;
*******************************************************************************/
-void *list_last(list *l)
+void *list_last(list_t *l)
{
void *el;
*******************************************************************************/
-void *list_last_unsynced(list *l)
+void *list_last_unsynced(list_t *l)
{
void *el;
*******************************************************************************/
-void *list_next(list *l, void *element)
+void *list_next(list_t *l, void *element)
{
void *el;
*******************************************************************************/
-void *list_next_unsynced(list *l, void *element)
+void *list_next_unsynced(list_t *l, void *element)
{
- listnode *ln;
+ listnode_t *ln;
void *el;
- ln = (listnode *) (((u1 *) element) + l->nodeoffset);
+ ln = (listnode_t *) (((u1 *) element) + l->nodeoffset);
if (ln->next == NULL)
el = NULL;
*******************************************************************************/
-void *list_prev(list *l, void *element)
+void *list_prev(list_t *l, void *element)
{
void *el;
*******************************************************************************/
-void *list_prev_unsynced(list *l, void *element)
+void *list_prev_unsynced(list_t *l, void *element)
{
- listnode *ln;
+ listnode_t *ln;
void *el;
- ln = (listnode *) (((u1 *) element) + l->nodeoffset);
+ ln = (listnode_t *) (((u1 *) element) + l->nodeoffset);
if (ln->prev == NULL)
el = NULL;
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: list.h 7601 2007-03-28 23:02:50Z michi $
+ $Id: list.h 7784 2007-04-20 13:51:41Z twisti $
*/
*/
-/* listnode *******************************************************************/
+/* listnode_t *****************************************************************/
-typedef struct listnode listnode;
+typedef struct listnode_t listnode_t;
-struct listnode {
- listnode *next;
- listnode *prev;
+struct listnode_t {
+ listnode_t *next;
+ listnode_t *prev;
};
-/* list ***********************************************************************/
+/* list_t *********************************************************************/
-typedef struct list list;
+typedef struct list_t list_t;
-struct list {
+struct list_t {
#if defined(ENABLE_THREADS)
java_objectheader lock; /* threads lock object */
#endif
- listnode *first;
- listnode *last;
+ listnode_t *first;
+ listnode_t *last;
s4 nodeoffset;
+ s4 size; /* number of elements in the list */
};
/* function prototypes ********************************************************/
-list *list_create(s4 nodeoffset);
-list *list_create_dump(s4 nodeoffset);
+list_t *list_create(s4 nodeoffset);
+list_t *list_create_dump(s4 nodeoffset);
-void list_add_first(list *l, void *element);
+void list_add_first(list_t *l, void *element);
-void list_add_last(list *l, void *element);
-void list_add_last_unsynced(list *l, void *element);
+void list_add_last(list_t *l, void *element);
+void list_add_last_unsynced(list_t *l, void *element);
-void list_add_before(list *l, void *element, void *newelement);
+void list_add_before(list_t *l, void *element, void *newelement);
-void list_remove(list *l, void *element);
-void list_remove_unsynced(list *l, void *element);
-
-void *list_first(list *l);
-void *list_first_unsynced(list *l);
+void list_remove(list_t *l, void *element);
+void list_remove_unsynced(list_t *l, void *element);
-void *list_last(list *l);
-void *list_last_unsynced(list *l);
+void *list_first(list_t *l);
+void *list_first_unsynced(list_t *l);
-void *list_next(list *l, void *element);
-void *list_next_unsynced(list *l, void *element);
+void *list_last(list_t *l);
+void *list_last_unsynced(list_t *l);
-void *list_prev(list *l, void *element);
-void *list_prev_unsynced(list *l, void *element);
+void *list_next(list_t *l, void *element);
+void *list_next_unsynced(list_t *l, void *element);
+
+void *list_prev(list_t *l, void *element);
+void *list_prev_unsynced(list_t *l, void *element);
#endif /* _LIST_H */
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
##
-## $Id: Makefile.am 7483 2007-03-08 13:17:40Z michi $
+## $Id: Makefile.am 7786 2007-04-21 12:37:47Z edwin $
## Process this file with automake to produce Makefile.in
-AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) -I$(top_builddir)/src
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) -I$(top_builddir)/src -I$(top_srcdir)/contrib/vmlog
LIBS =
calls instead of machine instructions, using the C calling
convention.
- $Id: builtin.c 7764 2007-04-19 12:50:37Z twisti $
+ $Id: builtin.c 7797 2007-04-23 20:12:39Z michi $
*/
#include "vmcore/options.h"
#include "vmcore/rt-timing.h"
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
/* include builtin tables *****************************************************/
s4 dumpsize;
codeinfo *code;
+#if defined(ENABLE_VMLOG)
+ return xptr;
+#endif
+
if (opt_verbosecall && indent)
methodindent--;
s4 i;
s4 pos;
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_enter_method(m);
+ return;
+#endif
+
md = m->parseddesc;
/* calculate message length */
s4 pos;
imm_union val;
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_leave_method(m);
+ return;
+#endif
+
md = m->parseddesc;
/* calculate message length */
return co;
}
+#if defined(ENABLE_VMLOG)
+#define NDEBUG
+#include <vmlog_cacao.c>
+#endif
+
/*
* These are local overrides for various environment variables in Emacs.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: builtin.h 7710 2007-04-15 15:33:35Z michi $
+ $Id: builtin.h 7797 2007-04-23 20:12:39Z michi $
*/
#include "vm/types.h"
#include "arch.h"
+#include "md-abi.h"
#include "toolbox/logging.h"
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: exceptions.c 7674 2007-04-05 13:27:11Z michi $
+ $Id: exceptions.c 7785 2007-04-21 10:55:30Z edwin $
*/
#include "vmcore/loader.h"
#include "vmcore/options.h"
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
/* for raising exceptions from native methods *********************************/
builtin_trace_exception(xptr, m, xpc, 1);
#endif
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_throw(xptr);
+#endif
+
for (i = 0; i < exceptiontablelength; i++) {
/* ATTENTION: keep this here, as we need to decrement the
pointer before the loop executes! */
#if !defined(NDEBUG)
/* Print stacktrace of exception when caught. */
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_catch(xptr);
+#endif
+
if (opt_verboseexception) {
exceptions_print_exception(xptr);
stacktrace_print_trace(xptr);
#if !defined(NDEBUG)
/* Print stacktrace of exception when caught. */
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_catch(xptr);
+#endif
+
if (opt_verboseexception) {
exceptions_print_exception(xptr);
stacktrace_print_trace(xptr);
/* none of the exceptions catch this one */
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_unwnd_method(m);
+#endif
+
return NULL;
}
#endif /* defined(ENABLE_JIT) */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: exceptions.h 7609 2007-03-29 17:09:48Z michi $
+ $Id: exceptions.h 7773 2007-04-19 19:44:54Z twisti $
*/
8-byte boundaries, since normal loads could have such offsets with
a base of NULL which should result in a NullPointerException.
+ NOTE: In signal_init() we have an assert checking that the offset
+ of java_objectheader.data[0] is greater than the largest
+ displacement defined below. Otherwise normal array loads/stores
+ could trigger an exception.
+
*******************************************************************************/
#define EXCEPTION_HARDWARE_NULLPOINTER 0
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
##
-## $Id: Makefile.am 7727 2007-04-16 21:18:43Z michi $
+## $Id: Makefile.am 7786 2007-04-21 12:37:47Z edwin $
## Process this file with automake to produce Makefile.in
-AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) -I$(top_builddir)/src
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) -I$(top_builddir)/src -I$(top_srcdir)/contrib/vmlog
LIBS =
memory. All functions writing values into the data area return the offset
relative the begin of the code area (start of procedure).
- $Id: codegen-common.c 7766 2007-04-19 13:24:48Z michi $
+ $Id: codegen-common.c 7797 2007-04-23 20:12:39Z michi $
*/
# include "vmcore/statistics.h"
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
/* in this tree we store all method addresses *********************************/
void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options)
{
- list *list;
+ list_t *list;
branch_label_ref_t *br;
s4 mpc;
if (mte == NULL) {
/* No method was found. Let's dump a stacktrace. */
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_signl("SIGSEGV");
+#endif
+
log_println("We received a SIGSEGV and tried to handle it, but we were");
log_println("unable to find a Java method at:");
log_println("");
{
stackframeinfo *sfi;
stackframeinfo **psfi;
+#if defined(ENABLE_JAVASE)
localref_table *lrt;
localref_table *plrt;
s4 localframes;
+#endif
java_objectheader *e;
/* get data structures from stack */
sfi = (stackframeinfo *) (datasp - sizeof(stackframeinfo));
- lrt = (localref_table *) (datasp - sizeof(stackframeinfo) -
- sizeof(localref_table));
#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
/* clear the native world flag */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen-common.h 7764 2007-04-19 12:50:37Z twisti $
+ $Id: codegen-common.h 7797 2007-04-23 20:12:39Z michi $
*/
dataref *datareferences; /* list of data segment references */
#endif
-/* list *patchrefs; */
+/* list_t *patchrefs; */
patchref *patchrefs;
- list *brancheslabel;
+ list_t *brancheslabel;
linenumberref *linenumberreferences; /* list of line numbers and the */
/* program counters of their first */
s4 condition; /* conditional branch condition */
s4 reg; /* register number to check */
u4 options; /* branch options */
- listnode linkage;
+ listnode_t linkage;
};
void emit_label_bccz(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options)
{
- list *list;
+ list_t *list;
branch_label_ref_t *br;
s4 mpc;
s4 disp;
void emit_label(codegendata *cd, s4 label)
{
- list *list;
+ list_t *list;
branch_label_ref_t *br;
s4 mpc;
s4 disp;
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: asmpart.c 7688 2007-04-12 09:05:12Z michi $
+ $Id: asmpart.c 7785 2007-04-21 10:55:30Z edwin $
*/
#include "vmcore/loader.h"
#include "vmcore/options.h"
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
static bool intrp_asm_vm_call_method_intern(methodinfo *m, s4 vmargscount,
vm_arg *vmargs)
builtin_trace_exception(o, m, ip, 1);
#endif
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_throw(o);
+#endif
+
for (i = 0; i < exceptiontablelength; i++) {
ex--;
if (ip-1 >= (Inst *) ex->startpc && ip-1 < (Inst *) ex->endpc &&
(c == NULL || builtin_instanceof(o, c)))
{
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_catch(o);
+#endif
+
*new_spp = (Cell *)(((u1 *)fp) - framesize - SIZEOF_VOID_P);
*new_fpp = fp;
return (Inst *) (ex->handlerpc);
/* unwind stack frame */
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_unwnd_method(m);
+#endif
+
ip = (Inst *)access_local_cell(-framesize - SIZEOF_VOID_P);
fp = (Cell *)access_local_cell(-framesize);
}
#include "config.h"
#include "vm/jit/m68k/offsets.h"
+#include "md-abi.h"
+#include "vm/jit/methodheader.h"
.data
call_jit_dummy:
.globl asm_criticalsections
.globl asm_handle_exception
+.globl asm_handle_nat_exception
/*
* This functions implement the C prototyped funtion
* exception object pointer...%a2 exception raising address...%a3 *
* *
*******************************************************************************/
-asm_handle_exception:
asm_handle_nat_exception:
+ lea %sp@(4), %sp
+asm_handle_exception:
L_asm_handle_exception_stack_loop:
/* we need the dseg, figure it out */
/* %d0 contains address of exception handler */
moveal %d0, %a0
- jsr %a0@
+ jmp %a0@
L_asm_handle_exception_not_catched:
- jsr 0
+ /* we did not find an exception handler in this stackframe */
+ /* remove this frame and search in the one above */
+ /* %a2 containts exception object ptr, %d2 the actual pv */
+ moveal %d2, %a3
+ movel %a3@(FrameSize), %d2
+
+ moveal %sp, %a0
+ addal %d2, %a0 /* %a0 now points to top of stackframe, where saved regs are */
+
+ /* the saved registers have to be restored */
+ /* XXX ugly hack: intsave and adrsave share one field */
+ movel %a3@(IntSave), %d0
+ andil #0x0000ffff, %d0 /* this is IntSave */
+ cmpb #0,%d0
+ beq L_asm_handle_ex_int_done
+ movel (%a0)+, %d7
+
+ cmpb #1,%d0
+ beq L_asm_handle_ex_int_done
+ movel (%a0)+, %d6
+
+ cmpb #2,%d0
+ beq L_asm_handle_ex_int_done
+ movel (%a0)+, %d5
+
+L_asm_handle_ex_int_done:
+
+ movel %a3@(IntSave), %d0
+ andil #0xffff0000, %d0 /* this is AdrSave */
+ tstl %d0
+ beq L_handle_exception_nat_catched_no_adr
+ moveal (%a0)+, %a5
+L_handle_exception_nat_catched_no_adr:
+
+#if !defined(ENABLE_SOFTFLOAT)
+ FIXME
+#else
+ /* nothing to do */
+#endif
+ addal %d2, %sp /* remove old stackframe */
+ moveal %sp@(0), %a3 /* make return address, new exception rasing address */
+ addal #4,%sp /* remove return address fromstack */
+ subal #2, %a3 /* it was a jsr %aX, which is 4 bytes long */
+ jmp L_asm_handle_exception_stack_loop
+
+
illegal
.long 0x23234242
(void) dseg_add_unique_s4(cd, (rd->memuse + 1) * 4);/* IsSync */
else
#endif
- (void) dseg_add_unique_s4(cd, 0); /* IsSync */
+ (void) dseg_add_unique_s4(cd, 0); /* IsSync */
(void) dseg_add_unique_s4(cd, jd->isleafmethod); /* IsLeaf */
- (void) dseg_add_unique_s4(cd, INT_SAV_CNT - rd->savintreguse); /* IntSave */
+
+ /* XXX we use the IntSAce a split field for the adr now */
+ (void) dseg_add_unique_s4(cd, (ADR_SAV_CNT - rd->savadrreguse) << 16 | (INT_SAV_CNT - rd->savintreguse)); /* IntSave */
(void) dseg_add_unique_s4(cd, FLT_SAV_CNT - rd->savfltreguse); /* FltSave */
dseg_addlinenumbertablesize(cd);
emit_store_dst(jd, iptr, d);
break;
-#if 0
case ICMD_LALOAD: /* ..., arrayref, index ==> ..., value */
- s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+ s1 = emit_load_s1(jd, iptr, REG_ATMP1);
s2 = emit_load_s2(jd, iptr, REG_ITMP2);
d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
/* implicit null-pointer check */
emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
- M_SLL_IMM(s2, 3, REG_ITMP2);
- M_IADD(s1, REG_ITMP2, REG_ITMP2);
- M_LLD_INTERN(d, REG_ITMP2, OFFSET(java_longarray, data[0]));
+ M_INTMOVE(s2, REG_ITMP2);
+ M_ISSL_IMM(3, REG_ITMP2);
+ M_IADD(s1, REG_ITMP2);
+ M_LLD(d, REG_ITMP2, OFFSET(java_longarray, data[0]));
emit_store_dst(jd, iptr, d);
break;
case ICMD_FALOAD: /* ..., arrayref, index ==> ..., value */
- s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+ s1 = emit_load_s1(jd, iptr, REG_ATMP1);
s2 = emit_load_s2(jd, iptr, REG_ITMP2);
d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
- M_SLL_IMM(s2, 2, REG_ITMP2);
- M_IADD_IMM(REG_ITMP2, OFFSET(java_floatarray, data[0]), REG_ITMP2);
+ M_INTMOVE(s2, REG_ITMP2);
+ M_ISSL_IMM(2, REG_ITMP2);
+ M_IADD_IMM(OFFSET(java_floatarray, data[0]), REG_ITMP2);
+ M_ADRMOVE(s1, REG_ATMP1);
+ M_AADDINT(REG_ITMP2, REG_ATMP1);
/* implicit null-pointer check */
- M_LFSX(d, s1, REG_ITMP2);
+#if !defined(ENABLE_SOFTFLOAT)
+ M_LFSX(REG_ATMP1, d);
+#else
+ M_LWZX(REG_ATMP1, d);
+#endif
emit_store_dst(jd, iptr, d);
break;
case ICMD_DALOAD: /* ..., arrayref, index ==> ..., value */
- s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+ s1 = emit_load_s1(jd, iptr, REG_ATMP1);
s2 = emit_load_s2(jd, iptr, REG_ITMP2);
- d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
- M_SLL_IMM(s2, 3, REG_ITMP2);
- M_IADD_IMM(REG_ITMP2, OFFSET(java_doublearray, data[0]), REG_ITMP2);
+ M_INTMOVE(s2, REG_ITMP2);
+ M_ISSL_IMM(3, REG_ITMP2);
+ M_IADD_IMM(OFFSET(java_doublearray, data[0]), REG_ITMP2);
+ M_ADRMOVE(s1, REG_ATMP1);
+ M_AADDINT(REG_ITMP2, REG_ATMP1);
/* implicit null-pointer check */
- M_LFDX(d, s1, REG_ITMP2);
+#if !defined(ENABLE_SOFTFLOAT)
+ d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED); /* FIXME */
+ M_LFDX(REG_ATMP1, s3);
+#else
+ d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
+ /* implicit null-pointer check */
+ M_LWZX(REG_ATMP1, GET_LOW_REG(d));
+ M_AADD_IMM(REG_ATMP1, 4);
+ /* implicit null-pointer check */
+ M_LWZX(REG_ATMP1, GET_HIGH_REG(d));
+#endif
emit_store_dst(jd, iptr, d);
break;
- #endif
case ICMD_AALOAD: /* ..., arrayref, index ==> ..., value */
case ICMD_BASTORE: /* ..., arrayref, index, value ==> ... */
- s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+ s1 = emit_load_s1(jd, iptr, REG_ATMP1);
s2 = emit_load_s2(jd, iptr, REG_ITMP2);
emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
s3 = emit_load_s3(jd, iptr, REG_ITMP3);
M_STWX(REG_ATMP1, s3);
break;
-#if 0
case ICMD_LASTORE: /* ..., arrayref, index, value ==> ... */
s1 = emit_load_s1(jd, iptr, REG_ITMP1);
s2 = emit_load_s2(jd, iptr, REG_ITMP2);
emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
s3 = emit_load_s3_high(jd, iptr, REG_ITMP3);
+
M_INTMOVE(s2, REG_ITMP2);
- M_IADD_IMM(OFFSET(java_bytearray, data[0]), REG_ITMP2);
- M_ISSL_IMM(1, REG_ITMP2);
+ M_ISSL_IMM(3, REG_ITMP2);
+ M_IADD_IMM(OFFSET(java_longarray, data[0]), REG_ITMP2);
M_ADRMOVE(s1, REG_ATMP1);
M_AADDINT(REG_ITMP2, REG_ATMP1);
/* implicit null-pointer check */
- M_STWX(s3, s1, REG_ITMP2);
- M_IADD_IMM(REG_ITMP2, 4, REG_ITMP2);
+ M_STWX(REG_ATMP1, s3);
+ M_AADD_IMM(REG_ATMP1, 4);
s3 = emit_load_s3_low(jd, iptr, REG_ITMP3);
- M_STWX(s3, s1, REG_ITMP2);
+ /* implicit null-pointer check */
+ M_STWX(REG_ATMP1, s3);
break;
case ICMD_FASTORE: /* ..., arrayref, index, value ==> ... */
s2 = emit_load_s2(jd, iptr, REG_ITMP2);
emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
s3 = emit_load_s3(jd, iptr, REG_FTMP3);
- M_SLL_IMM(s2, 2, REG_ITMP2);
- M_IADD_IMM(REG_ITMP2, OFFSET(java_floatarray, data[0]), REG_ITMP2);
+ M_INTMOVE(s2, REG_ITMP2);
+ M_ISSL_IMM(2, REG_ITMP2);
+ M_IADD_IMM(OFFSET(java_floatarray, data[0]), REG_ITMP2);
+ M_ADRMOVE(s1, REG_ATMP1);
+ M_AADDINT(REG_ITMP2, REG_ATMP1);
/* implicit null-pointer check */
- M_STFSX(s3, s1, REG_ITMP2);
+#if !defined(ENABLE_SOFTFLOAT)
+ M_STFSX(REG_ATMP1, s3);
+#else
+ M_STWX(REG_ATMP1, s3);
+#endif
break;
case ICMD_DASTORE: /* ..., arrayref, index, value ==> ... */
s1 = emit_load_s1(jd, iptr, REG_ITMP1);
s2 = emit_load_s2(jd, iptr, REG_ITMP2);
emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
+ M_INTMOVE(s2, REG_ITMP2);
+ M_ISSL_IMM(3, REG_ITMP2);
+ M_IADD_IMM(OFFSET(java_doublearray, data[0]), REG_ITMP2);
+ M_ADRMOVE(s1, REG_ATMP1);
+ M_AADDINT(REG_ITMP2, REG_ATMP1);
+ /* implicit null-pointer check */
+#if !defined(ENABLE_SOFTFLOAT)
s3 = emit_load_s3(jd, iptr, REG_FTMP3);
- M_SLL_IMM(s2, 3, REG_ITMP2);
- M_IADD_IMM(REG_ITMP2, OFFSET(java_doublearray, data[0]), REG_ITMP2);
+ M_STFDX(REG_ATMP1, s3);
+#else
+ s3 = emit_load_s3_high(jd, iptr, REG_ITMP3);
+ /* implicit null-pointer check */
+ M_STWX(REG_ATMP1, s3);
+ M_AADD_IMM(REG_ATMP1, 4);
+ s3 = emit_load_s3_low(jd, iptr, REG_ITMP3);
/* implicit null-pointer check */
- M_STFDX(s3, s1, REG_ITMP2);
+ M_STWX(REG_ATMP1, s3);
+#endif
break;
- #endif
case ICMD_AASTORE: /* ..., arrayref, index, value ==> ... */
s1 = emit_load_s1(jd, iptr, REG_ATMP1);
M_AST(s1, REG_SP, 0*4);
M_AST(s3, REG_SP, 1*4);
M_JSR_IMM(BUILTIN_canstore);
- emit_exception_check_ireg(cd, iptr);
+ emit_exception_check(cd, iptr);
s1 = emit_load_s1(jd, iptr, REG_ATMP1);
s2 = emit_load_s2(jd, iptr, REG_ITMP1);
M_JSR_IMM(disp);
REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr);
- /*emit_exception_check(cd, iptr); TODO */
+ emit_exception_check(cd, iptr);
break;
case ICMD_INVOKESPECIAL:
codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
#endif
M_ISUB(REG_ITMP3, REG_ITMP1);
- M_ICMP(REG_ITMP1, REG_ITMP2);
- M_BGT(4);
+ M_ICMP(REG_ITMP2, REG_ITMP1);
+ M_BHI(4);
M_IMOV_IMM(1, d);
M_TPFW; /* overlaps next instruction */
M_ICLR(d);
codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
#endif
M_ILD(REG_ITMP3, REG_ATMP2, OFFSET(vftbl_t, baseval)); /* REG_ITMP3 == sub->vftbl->baseval */
-#if 0
- if (s1 != REG_ATMP1) {
-#endif
- M_ILD(REG_ITMP1, REG_ATMP3, OFFSET(vftbl_t, baseval));
- M_ILD(REG_ITMP2, REG_ATMP3, OFFSET(vftbl_t, diffval));
+ M_ILD(REG_ITMP1, REG_ATMP3, OFFSET(vftbl_t, baseval));
+ M_ILD(REG_ITMP2, REG_ATMP3, OFFSET(vftbl_t, diffval));
#if defined(ENABLE_THREADS)
codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
#endif
- M_ISUB(REG_ITMP1, REG_ITMP3);
- M_ICMP(REG_ITMP2, REG_ITMP1); /* XXX was CMPU */
-#if 0
- } else {
- assert(0);
- M_ILD(REG_ITMP2, REG_ATMP3, OFFSET(vftbl_t, baseval));
- M_ISUB(REG_ITMP3, REG_ITMP2);
- M_ILD(REG_ITMP3, REG_ATMP3, OFFSET(vftbl_t, diffval));
- M_ICMP(REG_ITMP2, REG_ITMP3); /* XXX was CMPU */
-#if defined(ENABLE_THREADS)
- codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
- }
-#endif
+ M_ISUB(REG_ITMP1, REG_ITMP3);
+ M_ICMP(REG_ITMP2, REG_ITMP3); /* XXX was CMPU */
+
emit_classcast_check(cd, iptr, BRANCH_UGT, REG_ITMP3, s1); /* XXX was BRANCH_GT */
if (super != NULL)
M_AMOV_IMM(iptr->sx.s23.s3.c.cls, REG_ATMP1);
}
- M_APUSH(s1);
M_APUSH(REG_ATMP1);
+ M_APUSH(s1);
M_JSR_IMM(BUILTIN_arraycheckcast);
M_AADD_IMM(2*4, REG_SP); /* pop arguments off stack */
M_ITST(REG_RESULT);
break;
}
+ case ICMD_MULTIANEWARRAY:/* ..., cnt1, [cnt2, ...] ==> ..., arrayref */
+
+ /* check for negative sizes and copy sizes to stack if necessary */
+ MCODECHECK((iptr->s1.argcount << 1) + 64);
+
+ for (s1 = iptr->s1.argcount; --s1 >= 0;) {
+ var = VAR(iptr->sx.s23.s2.args[s1]);
+
+ /* Already Preallocated? */
+ if (!(var->flags & PREALLOC)) {
+ s2 = emit_load(jd, iptr, var, REG_ITMP1);
+ M_IST(s2, REG_SP, (s1 + 3) * 4);
+ }
+ }
+
+ /* a0 = dimension count */
+ M_IMOV_IMM(iptr->s1.argcount, REG_ITMP1);
+ M_IST(REG_ITMP1, REG_SP, 0*4);
+
+ /* a1 = arraydescriptor */
+ if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
+ codegen_addpatchref(cd, PATCHER_resolve_classref_to_classinfo, iptr->sx.s23.s3.c.ref, 0);
+ M_AMOV_IMM(0, REG_ATMP1);
+ } else {
+ M_AMOV_IMM(iptr->sx.s23.s3.c.cls, REG_ATMP1);
+ }
+ M_AST(REG_ATMP1, REG_SP, 1*4);
+
+ /* a2 = pointer to dimensions = stack pointer */
+ M_AMOV(REG_SP, REG_ATMP1);
+ M_AADD_IMM(REG_ATMP1, 3*4);
+ M_AST(REG_ATMP1, REG_SP, 2*4);
+
+ M_JSR_IMM(BUILTIN_multianewarray);
+
+ /* check for exception before result assignment */
+ emit_exception_check(cd, iptr);
+
+ assert(VAROP(iptr->dst)->type == TYPE_ADR);
+ d = codegen_reg_of_dst(jd, iptr, REG_RESULT);
+ M_INT2ADRMOVE(REG_RESULT, d);
+ emit_store_dst(jd, iptr, d);
+ break;
+
+
default:
printf("UNKNOWN OPCODE %d\n", iptr->opc);
M_AMOV_IMM(m, REG_ATMP1);
M_AMOV_IMM(asm_call_jit_compiler, REG_ATMP3);
- M_JMP_IMM(asm_call_jit_compiler);
- M_RET;
+ M_JMP(REG_ATMP3);
+ M_JMP_IMM(0); /* FIXME: remove me */
}
M_AST(REG_ATMP3, REG_SP, 0 * 4); /* datasp */
M_JSR_IMM(codegen_finish_native_call);
- M_INT2ADRMOVE(REG_RESULT, REG_ATMP3);
+ M_INT2ADRMOVE(REG_RESULT, REG_ATMP1);
/* restore return value */
switch (md->returntype.type) {
case TYPE_VOID: break;
M_AADD_IMM(cd->stackframesize*4, REG_SP);
/* check for exception */
- M_ATST(REG_ATMP3);
+ M_ATST(REG_ATMP1);
M_BNE(2);
M_RET;
- /* handle exception */
- M_JSR_IMM(0); /* FIXME */
+ /* handle exception, REG_ATMP1 already contains exception object, REG_ATMP2 holds address */
+
+ M_ALD(REG_ATMP2_XPC, REG_SP, 0); /* take return address as faulting instruction */
+ M_AADD_IMM(-2, REG_ATMP2_XPC); /* which is off by 2 */
+ M_JMP_IMM(asm_handle_nat_exception);
+ /* should never be reached from within jit code*/
+ M_JSR_IMM(0);
/* generate patcher stub call code */
emit_patcher_stubs(jd);
#define M_BHI_16(a) BRANCH16(0x2, (a))
#define M_BHI_32(a) BRANCH32(0x2, (a))
+#define M_BLS(a) BRANCH8 (0x3, (a))
+
#define M_BMI(a) BRANCH8(0xb, (a))
#define M_BPL(a) BRANCH8(0xa, (a))
#define M_STWX(a,c) OPWORD( ( (2<<6) | ((a) << 3) | 2), 0, (c))
#define M_STAX(a,c) OPWORD( ( (2<<6) | ((a) << 3) | 2), 1, (c)) /* movea.l */
+#if !defined(ENABLE_SOFTFLOAT)
+ #define M_LFSX(a,c) M_ILLEGAL
+ #define M_LFDX(a,c) M_ILLEGAL
+ #define M_STFSX(a,c) M_ILLEGAL
+ #define M_STFDX(a,c) M_ILLEGAL
+#endif
+
#define M_BSEXT(a,b) OPWORD( ( (7<<6) | ((b) << 3) | 4), 0, (a)) /* mvs.b */
#define M_CZEXT(a,b) OPWORD( ( (7<<6) | ((b) << 3) | 7), 0, (a)) /* mvz.w */
#define M_SSEXT(a,b) OPWORD( ( (7<<6) | ((b) << 3) | 5), 0, (a)) /* mvs.w */
#include "mm/memory.h"
#include "codegen.h"
+#include "md-os.h"
/*
* Loads an immededat operand into data register
s4 disp;
s4 reg;
+#if !defined(ENABLE_SOFTFLOAT)
assert(src->type == TYPE_LNG);
+#else
+ assert(src->type == TYPE_LNG || src->type == TYPE_DBL);
+#endif
/* get required compiler data */
cd = jd->cd;
s4 disp;
s4 reg;
+#if !defined(ENABLE_SOFTFLOAT)
assert(src->type == TYPE_LNG);
-
+#else
+ assert(src->type == TYPE_LNG || src->type == TYPE_DBL);
+#endif
/* get required compiler data */
cd = jd->cd;
M_BLE(4);
break;
case BRANCH_UGT:
- M_BHI(4);
+ M_BLS(4);
break;
default:
vm_abort("emit_classcast_check: unknown condition %d", condition);
{
if (INSTRUCTION_MUST_CHECK(iptr)) {
M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));
- M_ICMP(REG_ITMP3, s2);
- M_BLT(2);
+ M_ICMP(s2, REG_ITMP3);
+ M_BHI(2);
/*M_ALD_INTERN(s2, REG_ZERO, EXCEPTION_LOAD_DISP_ARRAYINDEXOUTOFBOUNDS);*/
- M_ILLEGAL; /*FIXME */
+ M_TRAP(EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS);
}
}
{
if (INSTRUCTION_MUST_CHECK(iptr)) {
/* did like to assert on TYPE_ADR, but not possible in here */
- /* so assert before each emit_nullpointer_check */
M_ATST(reg);
M_BNE(2);
- /*M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_LOAD_DISP_NULLPOINTER);*/
- M_ILLEGAL;
+ M_TRAP(M68K_EXCEPTION_HARDWARE_NULLPOINTER);
}
}
}
}
+#if 0
/* emit_exception_check_areg **************************************************
*
Emit an Exception check, tested register is address REG_RESULT
M_ILLEGAL; /*FIXME*/
}
}
+#endif
+
/* emit_exception_check_ireg **************************************************
Emit an Exception check. Teste register is integer REG_RESULT
*******************************************************************************/
-void emit_exception_check_ireg(codegendata *cd, instruction *iptr)
+void emit_exception_check(codegendata *cd, instruction *iptr)
{
if (INSTRUCTION_MUST_CHECK(iptr)) {
M_ITST(REG_RESULT);
M_BNE(2);
/*M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_EXCEPTION);*/
- M_ILLEGAL; /*FIXME*/
+ M_TRAP(EXCEPTION_HARDWARE_EXCEPTION);
}
}
const char *abi_registers_integer_name [] = { "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7" };
const s4 abi_registers_integer_argument[] ;
-const s4 abi_registers_integer_saved[] = {2,3,4,5,6,7};
+const s4 abi_registers_integer_saved[] = {5,6,7};
const s4 abi_registers_integer_temporary[] = {0,1};
/* Address register description */
const char *abi_registers_float_name [] = { "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7" };
const s4 abi_registers_float_argument[] ;
-const s4 abi_registers_float_saved[] = {2,3,4,5,6,7};
+const s4 abi_registers_float_saved[] = {5,6,7};
const s4 abi_registers_float_temporary[] = {0,1};
actual_fpregset_t fpregs;
} actual_mcontext_t;
+#define GREGS_ADRREG_OFF 8
+
typedef struct actual_ucontext {
unsigned long uc_flags;
struct actual_ucontext *uc_link;
/* md_signal_handler_sigsegv ******************************************
*
- * BLA BLA
- */
-void md_signal_handler_sigsegv(/*int sig, siginfo_t *siginfo, void *_p*/)
+ * Invoked when a Nullpointerexception occured, or when the cm
+ * crashes, hard to tell the difference.
+ **********************************************************************/
+void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, actual_ucontext_t *_uc)
{
- assert(0);
+ uint32_t xpc, sp;
+ uint16_t opc;
+ uint32_t val, regval, off;
+ bool adrreg;
+ java_objectheader *e;
+ mcontext_t *_mc;
+
+ _mc = &_uc->uc_mcontext;
+ sp = _mc->gregs[R_SP];
+ xpc = _mc->gregs[R_PC];
+ opc = *(uint16_t*)xpc;
+
+ /* m68k uses a whole bunch of difficult to differ load instructions where null pointer check could occure */
+ /* the first two are 2*32bit sized */
+ adrreg = false;
+ off = 0;
+ if ((opc & ((2<<12) | (5<<3))) == ((2<<12) | (5<<3))) {
+ if (opc & (1<<6)) adrreg = true; /* M_XLD */
+ val = opc & 0x0007;
+ off = *(uint16_t*)(xpc+1);
+ } else if ((opc & ((2<<12) | (5<<6))) == ((2<<12) | (5<<6))) {
+ if (opc & (1<<3)) adrreg = true; /* M_XST */
+ val = (opc >> 9) & 0x0007;
+ off = *(uint16_t*)(xpc+1);
+ } else {
+ fprintf(stderr, "SEGV: short instructions %x\n", opc);
+ /* now check the 32 bit sized instructions */
+ if ((opc & (2<<3)) == (2<<3)) {
+ if (opc & (1<<6)) adrreg = true; /* M_L*X */
+ val = opc & 0x0007;
+ } else if ((opc & (2<<6)) == (2<<6)) {
+ if (opc & (1<<3)) adrreg = true; /* M_S*X */
+ val = (opc >> 9) & 0x0007;
+ } else {
+ vm_abort("md_signal_handler_sigsegv: unhandeled faulting opcode %x", opc);
+ }
+ }
+
+ /* val is now register number, adreg == true if it is an address regsiter */
+ regval = _mc->gregs[adrreg ? GREGS_ADRREG_OFF + val : val];
+ /*
+ if (regval != 0) {
+ vm_abort("md_signal_handler_sigsegv: faulting address is not NULL: addr=%p", regval);
+ }*/
+
+
+ fprintf(stderr, "SEGV: sp=%x, xpc=%x, regval=%x\n", sp, xpc, regval);
+ e = exceptions_new_hardware_exception(0, sp, xpc, xpc, EXCEPTION_HARDWARE_NULLPOINTER, regval);
+
+ _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1] = (ptrint) e;
+ _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP2_XPC] = (ptrint) xpc;
+ _mc->gregs[R_PC] = (ptrint) asm_handle_exception;
}
-/*
+/* md_signal_handler_sigill *******************************************
+ *
* This handler is used to generate hardware exceptions.
* Type of exception derived from trap number.
* If an object is needed a tst instruction (2 byte long) has
* been created directly before the trap instruction (2 bytes long).
* the last 3 bit of this tst instruction contain the register number.
- */
+ **********************************************************************/
void md_signal_handler_sigill(int sig, siginfo_t *siginfo, actual_ucontext_t *_uc)
{
uint32_t xpc, sp;
java_objectheader *e;
mcontext_t *_mc;
+ xpc = siginfo->si_addr;
+
+ if (siginfo->si_code == ILL_ILLOPC) {
+ vm_abort("md_signal_handler_sigill: the illegal instruction @ 0x%x, aborting", xpc);
+ }
if (siginfo->si_code != ILL_ILLTRP) {
vm_abort("md_signal_handler_sigill: Caught something not a trap");
}
- xpc = siginfo->si_addr;
opc = *(uint16_t*)(xpc-2);
- if (opc == 0x4afc) {
- vm_abort("md_signal_handler_sigill: the illegal instruction @ 0x%x, aborting", xpc);
- }
-
assert( (opc&0xfff0) == 0x4e40 );
type = opc & 0x000f; /* filter trap number */
_mc = &_uc->uc_mcontext;
sp = _mc->gregs[R_SP];
- /* Figure out in which register the object causing the exception resides for exceptions
- * appropiate.
+ /* Figure out in which register the object causing the exception resides for appropiate exceptions
*/
switch (type) {
+ case EXCEPTION_HARDWARE_EXCEPTION:
+ /* nothing */
+ break;
case EXCEPTION_HARDWARE_CLASSCAST:
regval = *(uint16_t*)(xpc-4);
assert( (regval&0xfff0) == 0x4a00 );
/* was in a address register */
- regval = _mc->gregs[ 8 + (regval & 0x7) ];
+ regval = _mc->gregs[ GREGS_ADRREG_OFF + (regval & 0x7) ];
break;
+ case EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS:
+ regval = 0; /* FIXME */
+ break;
+ case M68K_EXCEPTION_HARDWARE_NULLPOINTER:
+ type = EXCEPTION_HARDWARE_NULLPOINTER;
+ break;
+
default: assert(0);
}
- fprintf(stderr, "NEW HWE: sp=%x, xpc=%x, tpye=%x, regval=%x\n", sp, xpc, type, regval);
+ /*fprintf(stderr, "NEW HWE: sp=%x, xpc=%x, tpye=%x, regval=%x\n", sp, xpc, type, regval);*/
e = exceptions_new_hardware_exception(0, sp, xpc, xpc, type, regval);
- _mc->gregs[REG_ATMP1] = (ptrint) e;
- _mc->gregs[REG_ATMP2_XPC] = (ptrint) xpc;
+ _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1] = (ptrint) e;
+ _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP2_XPC] = (ptrint) xpc;
_mc->gregs[R_PC] = (ptrint) asm_handle_exception;
}
#include "config.h"
+/* XXX trap #0 is reserved and will not be delivered to signal handler */
+#define M68K_EXCEPTION_HARDWARE_NULLPOINTER 14
void md_signal_handler_sigill();
void md_init_linux();
#if !defined(NDEBUG)
void profile_printstats(void)
{
- list *l;
+ list_t *l;
list_method_entry *lme;
list_method_entry *tlme;
classinfo *c;
static threadobject *thread_recompile;
static java_objectheader *lock_thread_recompile;
-static list *list_recompile_methods;
+static list_t *list_recompile_methods;
/* recompile_init **************************************************************
-/* src/vm/jit/recompile.h - recompilation system
+/* src/vm/jit/optimizing/recompile.h - recompilation system
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 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, J. Wenninger, Institut f. Computersprachen - TU Wien
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Christian Thalinger
-
- Changes:
-
$Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
*/
struct list_method_entry {
methodinfo *m;
- listnode linkage;
+ listnode_t linkage;
};
/* src/vm/jit/powerpc/darwin/md-abi.c - functions for PowerPC Darwin ABI
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 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
Changes: Christian Ullrich
- $Id: md-abi.c 5634 2006-10-02 14:18:04Z edwin $
+ $Id: md-abi.c 7770 2007-04-19 19:39:06Z twisti $
*/
#include "vm/jit/powerpc/darwin/md-abi.h"
-#include "vm/descriptor.h"
#include "vm/global.h"
+
#include "vm/jit/abi.h"
+#include "vmcore/descriptor.h"
+
/* register descripton arrays *************************************************/
REG_END
};
-char *regs[] = {
+const char *abi_registers_integer_name[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
};
+const s4 abi_registers_integer_argument[] = {
+ 3, /* a0 */
+ 4, /* a1 */
+ 5, /* a2 */
+ 6, /* a3 */
+ 7, /* a4 */
+ 8, /* a5 */
+ 9, /* a6 */
+ 10, /* a7 */
+};
+
+const s4 abi_registers_integer_saved[] = {
+ 14, /* s0 */
+ 15, /* s1 */
+ 24, /* s2 */
+ 25, /* s3 */
+ 26, /* s4 */
+ 27, /* s5 */
+ 28, /* s6 */
+ 29, /* s7 */
+ 30, /* s8 */
+ 31, /* s9 */
+};
+
+const s4 abi_registers_integer_temporary[] = {
+ 2, /* t0 */
+ 17, /* t1 */
+ 18, /* t2 */
+ 19, /* t3 */
+ 20, /* t4 */
+ 21, /* t5 */
+ 22, /* t6 */
+ 23, /* t7 */
+};
+
s4 nregdescfloat[] = {
/*ftmp3, fa0/v0, fa1, fa2, fa3, fa4, fa5, fa6, */
REG_END
};
+const s4 abi_registers_float_argument[] = {
+ 1, /* fa0 */
+ 2, /* fa1 */
+ 3, /* fa2 */
+ 4, /* fa3 */
+ 5, /* fa4 */
+ 6, /* fa5 */
+ 7, /* fa6 */
+ 8, /* fa7 */
+ 9, /* fa8 */
+ 10, /* fa9 */
+ 11, /* fa10 */
+ 12, /* fa11 */
+ 13, /* fa12 */
+};
+
+const s4 abi_registers_float_saved[] = {
+ 14, /* fs0 */
+ 15, /* fs1 */
+ 24, /* fs2 */
+ 25, /* fs3 */
+ 26, /* fs4 */
+ 27, /* fs5 */
+ 28, /* fs6 */
+ 29, /* fs7 */
+ 30, /* fs8 */
+ 31, /* fs9 */
+};
+
+const s4 abi_registers_float_temporary[] = {
+ 17, /* ft5 */
+ 18, /* ft6 */
+ 19, /* ft7 */
+ 20, /* ft8 */
+ 21, /* ft9 */
+ 22, /* ft10 */
+ 23, /* ft11 */
+};
+
/* md_param_alloc **************************************************************
/* set default values */
- iarg = 0;
- farg = 0;
+ iarg = 0;
+ farg = 0;
stacksize = LA_SIZE_IN_POINTERS;
/* get params field of methoddesc */
case TYPE_ADR:
if (iarg < INT_ARG_CNT) {
pd->inmemory = false;
- pd->regoff = iarg; /* rd->arg[int|flt]regs index !! */
+ pd->regoff = abi_registers_integer_argument[iarg];
iarg++;
}
else {
pd->inmemory = true;
- pd->regoff = stacksize;
+ pd->regoff = stacksize;
}
stacksize++;
break;
case TYPE_LNG:
if (iarg < INT_ARG_CNT - 1) {
pd->inmemory = false;
- /* rd->arg[int|flt]regs index !! */
- pd->regoff = PACK_REGS(iarg + 1, iarg);
+ pd->regoff =
+ PACK_REGS(abi_registers_integer_argument[iarg + 1],
+ abi_registers_integer_argument[iarg]);
iarg += 2;
}
else {
pd->inmemory = true;
- pd->regoff = stacksize;
- iarg = INT_ARG_CNT;
+ pd->regoff = stacksize;
+ iarg = INT_ARG_CNT;
}
stacksize += 2;
break;
case TYPE_FLT:
if (farg < FLT_ARG_CNT) {
pd->inmemory = false;
- pd->regoff = farg; /* rd->arg[int|flt]regs index !! */
+ pd->regoff = abi_registers_float_argument[farg];
iarg++; /* skip 1 integer argument register */
farg++;
}
else {
pd->inmemory = true;
- pd->regoff = stacksize;
+ pd->regoff = stacksize;
}
stacksize++;
break;
case TYPE_DBL:
if (farg < FLT_ARG_CNT) {
pd->inmemory = false;
- pd->regoff = farg; /* rd->arg[int|flt]regs index !! */
+ pd->regoff = abi_registers_float_argument[farg];
iarg += 2; /* skip 2 integer argument registers */
farg++;
}
else {
pd->inmemory = true;
- pd->regoff = stacksize;
+ pd->regoff = stacksize;
}
stacksize += 2;
break;
}
+/* md_param_alloc_native *******************************************************
+
+ Pre-allocate arguments according the native ABI.
+
+*******************************************************************************/
+
+void md_param_alloc_native(methoddesc *md)
+{
+ /* On PowerPC we use the same ABI for JIT method calls as for
+ native method calls. */
+
+ md_param_alloc(md);
+}
+
+
/* md_return_alloc *************************************************************
Precolor the Java Stackelement containing the Return Value, if
/* src/vm/jit/powerpc/darwin/md-abi.h - defines for PowerPC Darwin ABI
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 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
Changes: Christian Ullrich
- $Id: md-abi.h 5382 2006-09-06 21:17:00Z twisti $
+ $Id: md-abi.h 7770 2007-04-19 19:39:06Z twisti $
*/
#define REG_IFTMP 0 /* temporary integer and floating point register */
+#define REG_FA0 1 /* define some argument registers */
+#define REG_FA1 2
+
#define INT_REG_CNT 32 /* number of integer registers */
#define INT_SAV_CNT 10 /* number of int callee saved registers */
/* packed register defines ****************************************************/
+#define REG_RESULT_PACKED PACK_REGS(REG_RESULT2, REG_RESULT)
+
+#define REG_A0_A1_PACKED PACK_REGS(REG_A1, REG_A0)
+#define REG_A2_A3_PACKED PACK_REGS(REG_A3, REG_A2)
+
#define REG_ITMP12_PACKED PACK_REGS(REG_ITMP2, REG_ITMP1)
#define REG_ITMP23_PACKED PACK_REGS(REG_ITMP3, REG_ITMP2)
-#define REG_RESULT_PACKED PACK_REGS(REG_RESULT2, REG_RESULT)
/* ABI defines ****************************************************************/
/* src/vm/jit/powerpc/darwin/md-os.c - machine dependent PowerPC Darwin functions
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 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
Authors: Christian Thalinger
- $Id: md-os.c 7601 2007-03-28 23:02:50Z michi $
+ $Id: md-os.c 7770 2007-04-19 19:39:06Z twisti $
*/
#include "vm/jit/powerpc/codegen.h"
#include "vm/jit/powerpc/darwin/md-abi.h"
+#if defined(ENABLE_THREADS)
+# include "threads/native/threads.h"
+#endif
+
#include "vm/exceptions.h"
#include "vm/global.h"
#include "vm/signallocal.h"
#include "vm/stringlocal.h"
+
#include "vm/jit/asmpart.h"
#include "vm/jit/stacktrace.h"
ucontext_t *_uc;
mcontext_t _mc;
ppc_thread_state_t *_ss;
+ ptrint *gregs;
u1 *pv;
u1 *sp;
u1 *ra;
s4 s1;
s4 disp;
s4 d;
- ptrint *gregs;
- ptrint addr;
- ptrint val;
- java_objectheader *e;
+ ptrint addr;
+ ptrint val;
+ s4 type;
+ java_objectheader *o;
_uc = (ucontext_t *) _p;
_mc = _uc->uc_mcontext;
_ss = &_mc->ss;
+ /* immitate a gregs array */
+
+ gregs = &_ss->r0;
+
/* get register values */
pv = (u1 *) _ss->r13;
disp = M_INSTR_OP2_IMM_I(mcode);
d = M_INSTR_OP2_IMM_D(mcode);
+ val = gregs[d];
+
+ /* check for special-load */
+
+ if (s1 == REG_ZERO) {
+ /* we use the exception type as load displacement */
+
+ type = disp;
+ }
+ else {
+ /* This is a normal NPE: addr must be NULL and the NPE-type
+ define is 0. */
+
+ addr = gregs[s1];
+ type = EXCEPTION_HARDWARE_NULLPOINTER;
+
+ if (addr != 0)
+ vm_abort("md_signal_handler_sigsegv: faulting address is not NULL: addr=%p", addr);
+ }
+
+ /* generate appropriate exception */
+
+ o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
+
+ /* set registers */
+
+ _ss->r11 = (ptrint) o;
+ _ss->r12 = (ptrint) xpc;
+ _ss->srr0 = (ptrint) asm_handle_exception;
+}
+
+
+/* md_signal_handler_sigtrap ***************************************************
+
+ Signal handler for hardware-traps.
+
+*******************************************************************************/
+
+void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p)
+{
+ ucontext_t *_uc;
+ mcontext_t _mc;
+ ppc_thread_state_t *_ss;
+ ptrint *gregs;
+ u1 *pv;
+ u1 *sp;
+ u1 *ra;
+ u1 *xpc;
+ u4 mcode;
+ s4 s1;
+ ptrint val;
+ s4 type;
+ java_objectheader *o;
+
+ _uc = (ucontext_t *) _p;
+ _mc = _uc->uc_mcontext;
+ _ss = &_mc->ss;
+
+ /* immitate a gregs array */
+
gregs = &_ss->r0;
- addr = gregs[s1];
- val = gregs[d];
- e = exceptions_new_hardware_exception(pv, sp, ra, xpc, s1, disp, addr, val);
+ /* get register values */
+
+ pv = (u1 *) _ss->r13;
+ sp = (u1 *) _ss->r1;
+ ra = (u1 *) _ss->lr; /* this is correct for leafs */
+ xpc = (u1 *) _ss->srr0;
+
+ /* get exception-throwing instruction */
+
+ mcode = *((u4 *) xpc);
+
+ s1 = M_OP3_GET_A(mcode);
+
+ /* for now we only handle ArrayIndexOutOfBoundsException */
+
+ type = EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS;
+ val = gregs[s1];
+
+ /* generate appropriate exception */
+
+ o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
/* set registers */
- _ss->r11 = (ptrint) e;
+ _ss->r11 = (ptrint) o;
_ss->r12 = (ptrint) xpc;
_ss->srr0 = (ptrint) asm_handle_exception;
}
#define REPLACE_PATCH_DYNAMIC_CALL
/*#define REPLACE_PATCH_ALL*/
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
/*** architecture-dependent configuration *************************************/
replace_read_executionstate(rp, es, ss, ss->frames == NULL);
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_unrol_method(ss->frames->method);
+#endif
+
#if defined(REPLACE_STATISTICS)
REPLACE_COUNT(stat_frames);
depth++;
es->code = ss->frames->tocode;
prevframe = ss->frames;
+
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_rerol_method(ss->frames->method);
+#endif
+
replace_write_executionstate(rp, es, ss, ss->frames->down == NULL);
DOLOG( replace_executionstate_println(es); );
#define U8_AVAILABLE 1
-#define SUPPORT_DIVISION 0
+#define SUPPORT_DIVISION 1
#define SUPPORT_LONG 1
#define SUPPORT_I2F 1
#define SUPPORT_L2F 1
#define SUPPORT_L2D 1
-#define SUPPORT_F2I 0
-#define SUPPORT_F2L 0
-#define SUPPORT_D2I 0
-#define SUPPORT_D2L 0
+#define SUPPORT_F2I 1
+#define SUPPORT_F2L 1
+#define SUPPORT_D2I 1
+#define SUPPORT_D2L 1
#define SUPPORT_LONG_ADD 1
#define SUPPORT_LONG_CMP 1
#define SUPPORT_LONG_LOGICAL 1
#define SUPPORT_LONG_SHIFT 1
#define SUPPORT_LONG_MUL 1
-#define SUPPORT_LONG_DIV 0
+#define SUPPORT_LONG_DIV 1
#define SUPPORT_CONST_LOGICAL 1 /* AND, OR, XOR with immediates */
#define SUPPORT_CONST_MUL 1 /* mutiply with immediate */
.global asm_criticalsections
.global asm_getclassvalues_atomic
+
+ .global asm_store_fp_state_reg
+ .global asm_load_fp_state_reg
/* asm_vm_call_method ******************************************************
.xword _crit_restart
#endif
.xword 0
+
+
+/* asm_store_fp_state_reg **************************************************
+ * *
+ * This function stores the 64-bit floating point state register to a *
+ * memory location. (which needs to be 8-byte aligned) *
+ * *
+ * C-prototype: *
+ * void asm_store_fp_state_reg(u8 *mem); *
+ * *
+ **************************************************************************/
+
+asm_store_fp_state_reg:
+ stx %fsr,[%o0]
+ retl /* return from leaf */
+ nop
+
+/* asm_load_fp_state_reg ***************************************************
+ * *
+ * This function loades the 64-bit floating point state register from a *
+ * memory location. (which needs to be 8-byte aligned) *
+ * *
+ * C-prototype: *
+ * void asm_load_fp_state_reg(u8 *mem); *
+ * *
+ **************************************************************************/
+
+asm_load_fp_state_reg:
+ ldx [%o0],%fsr
+ retl /* return from leaf */
+ nop
/* disable exec-stacks ********************************************************/
#include "vmcore/loader.h"
#include "vmcore/options.h"
+
+#define BUILTIN_FLOAT_ARGS 1
+
/* XXX use something like this for window control ?
* #define REG_PV (own_window?REG_PV_CALLEE:REG_PV_CALLER)
*/
/*s2 = rd->argintregs[s1];*/
/*s2 = REG_WINDOW_TRANSPOSE(s2);*/
- /* need the argument index here, not the register number */
- s1 = md->params[p].regoff - abi_registers_integer_argument[0];
+ /* need the argument index (p) here, not the register number */
if (!(var->flags & INMEMORY)) { /* reg arg -> register */
/*M_INTMOVE(s2, var->vv.regoff);*/
- M_LDX(var->vv.regoff, REG_SP, JITSTACK + (s1 * 8));
+ M_LDX(var->vv.regoff, REG_SP, JITSTACK + (p * 8));
} else { /* reg arg -> spilled */
/*M_STX(s2, REG_SP, (WINSAVE_CNT + var->vv.regoff) * 8);*/
- M_LDX(REG_ITMP1, REG_SP, JITSTACK + (s1 * 8));
+ M_LDX(REG_ITMP1, REG_SP, JITSTACK + (p * 8));
M_STX(REG_ITMP1, REG_SP, localbase + (var->vv.regoff * 8));
}
case ICMD_I2F:
s1 = emit_load_s1(jd, iptr, REG_ITMP1);
d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
- disp = dseg_add_float(cd, 0.0);
+ disp = dseg_add_unique_float(cd, 0.0);
M_IST (s1, REG_PV_CALLEE, disp);
M_FLD (d, REG_PV_CALLEE, disp);
M_CVTIF (d, d); /* rd gets translated to double target register */
case ICMD_I2D:
s1 = emit_load_s1(jd, iptr, REG_ITMP1);
d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
- disp = dseg_add_float(cd, 0.0);
+ disp = dseg_add_unique_float(cd, 0.0);
M_IST(s1, REG_PV_CALLEE, disp);
M_FLD(REG_FTMP2, REG_PV_CALLEE, disp); /* REG_FTMP2 needs to be a double temp */
M_CVTID (REG_FTMP2, d); /* rd gets translated to double target register */
case ICMD_L2F:
s1 = emit_load_s1(jd, iptr, REG_ITMP1);
d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
- disp = dseg_add_double(cd, 0.0);
+ disp = dseg_add_unique_double(cd, 0.0);
M_STX(s1, REG_PV_CALLEE, disp);
M_DLD(REG_FTMP3, REG_PV_CALLEE, disp);
M_CVTLF(REG_FTMP3, d);
case ICMD_L2D:
s1 = emit_load_s1(jd, iptr, REG_ITMP1);
d = codegen_reg_of_dst(jd, iptr, REG_FTMP3);
- disp = dseg_add_double(cd, 0.0);
+ disp = dseg_add_unique_double(cd, 0.0);
M_STX(s1, REG_PV_CALLEE, disp);
M_DLD(d, REG_PV_CALLEE, disp);
M_CVTLD(d, d);
case ICMD_F2I: /* ..., value ==> ..., (int) value */
s1 = emit_load_s1(jd, iptr, REG_FTMP1);
d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
- disp = dseg_add_float(cd, 0.0);
+ disp = dseg_add_unique_float(cd, 0.0);
+
+ /* check for NaN, SPARC overflow is noncompliant (see V9 spec B.5) */
+ M_FCMP(s1, s1);
+ M_FBU(5);
+ M_MOV(REG_ZERO, d); /* delay slot */
+
M_CVTFI(s1, REG_FTMP2);
M_FST(REG_FTMP2, REG_PV_CALLEE, disp);
M_ILD(d, REG_PV, disp);
case ICMD_D2I: /* ..., value ==> ..., (int) value */
s1 = emit_load_s1(jd, iptr, REG_FTMP1);
d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
- disp = dseg_add_float(cd, 0.0);
+ disp = dseg_add_unique_float(cd, 0.0);
+
+ /* check for NaN, SPARC overflow is noncompliant (see V9 spec B.5) */
+ M_DCMP(s1, s1);
+ M_FBU(5);
+ M_MOV(REG_ZERO, d); /* delay slot */
+
M_CVTDI(s1, REG_FTMP2);
M_FST(REG_FTMP2, REG_PV, disp);
M_ILD(d, REG_PV, disp);
case ICMD_F2L: /* ..., value ==> ..., (long) value */
s1 = emit_load_s1(jd, iptr, REG_FTMP1);
d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
- disp = dseg_add_double(cd, 0.0);
+ disp = dseg_add_unique_double(cd, 0.0);
+
+ /* check for NaN, SPARC overflow is noncompliant (see V9 spec B.5) */
+ M_FCMP(s1, s1);
+ M_FBU(5);
+ M_MOV(REG_ZERO, d); /* delay slot */
+
M_CVTFL(s1, REG_FTMP2); /* FTMP2 needs to be double reg */
M_DST(REG_FTMP2, REG_PV, disp);
M_LDX(d, REG_PV, disp);
case ICMD_D2L: /* ..., value ==> ..., (long) value */
s1 = emit_load_s1(jd, iptr, REG_FTMP1);
d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
- disp = dseg_add_double(cd, 0.0);
+ disp = dseg_add_unique_double(cd, 0.0);
+
+ /* check for NaN, SPARC overflow is noncompliant (see V9 spec B.5) */
+ M_DCMP(s1, s1);
+ M_FBU(5);
+ M_MOV(REG_ZERO, d); /* delay slot */
+
M_CVTDL(s1, REG_FTMP2); /* FTMP2 needs to be double reg */
M_DST(REG_FTMP2, REG_PV, disp);
M_LDX(d, REG_PV, disp);
MCODECHECK((s3 << 1) + 64);
+#ifdef BUILTIN_FLOAT_ARGS /* float args for builtins disabled */
+
/* copy float arguments according to ABI convention */
int num_fltregargs = 0;
/*printf("builtin float arg to target reg: %d ==> %d\n", s1+16, s1);*/
}
+#else
+ assert(md->argfltreguse == 0);
+#endif
+
goto gen_method;
case ICMD_INVOKESTATIC: /* ..., [arg1, [arg2 ...]] ==> ... */
}
}
else {
+#ifdef BUILTIN_FLOAT_ARGS
if (iptr->opc == ICMD_BUILTIN)
continue;
+#endif
if (!md->params[s3].inmemory) {
s1 = emit_load(jd, iptr, var, d);
#define M_BUGT(disp) M_BRACC(0x00,0x1,0xc,disp,0,1,0) /* br uns a>b */
#define M_BULT(disp) M_BRACC(0x00,0x1,0x5,disp,0,1,0) /* br uns a<b */
+/* branch on (fcc0) floating point condition codes */
+
+#define M_FBR(disp) M_BRACC(0x00,0x5,0x8,disp,0,1,0) /* branch */
+#define M_FBU(disp) M_BRACC(0x00,0x5,0x7,disp,0,1,0) /* unordered */
+#define M_FBG(disp) M_BRACC(0x00,0x5,0x6,disp,0,1,0) /* branch a>b */
+#define M_FBL(disp) M_BRACC(0x00,0x5,0x4,disp,0,1,0) /* branch a<b */
+#define M_FBO(disp) M_BRACC(0x00,0x5,0xf,disp,0,1,0) /* br ordered */
+
#define M_SAVE(rs1,rs2,rd) M_OP3(0x02,0x3c,rd,rs1,rs2,IMM)
for (i = 0; i < md->paramcount && i < INT_NATARG_CNT; i++) {
t = md->paramtypes[i].type;
- /* using all available argument registers, this adds complexity */
+ /* all available argument registers used, which adds a little complexity */
if (IS_INT_LNG_TYPE(t)) {
if (i < INT_ARG_CNT) {
}
}
else {
- assert(i < 5); /* XXX 5 float reg args right now! */
- if (IS_2_WORD_TYPE(t)) {
- M_DST(abi_registers_float_argument[i], REG_SP, JITSTACK);
- M_LDX(abi_registers_integer_argument[i], REG_SP, JITSTACK);
+ if (i < FLT_ARG_CNT) {
+
+ /* reg -> mem -> reg */
+
+ if (IS_2_WORD_TYPE(t)) {
+ M_DST(abi_registers_float_argument[i], REG_SP, JITSTACK);
+ M_LDX(abi_registers_integer_argument[i], REG_SP, JITSTACK);
+ }
+ else {
+ M_FST(abi_registers_float_argument[i], REG_SP, JITSTACK);
+ M_ILD(abi_registers_integer_argument[i], REG_SP, JITSTACK);
+ }
}
else {
- M_FST(abi_registers_float_argument[i], REG_SP, JITSTACK);
- M_ILD(abi_registers_integer_argument[i], REG_SP, JITSTACK);
+
+ /* mem -> reg */
+
+ assert(i == 5);
+ if (IS_2_WORD_TYPE(t)) {
+ M_LDX(REG_OUT5, REG_FP, JITSTACK);
+ }
+ else {
+ M_ILD(REG_OUT5, REG_FP, JITSTACK);
+ }
}
}
}
- /* method info pointer is passed in argument register 5 */
+ /* method info pointer is passed via stack */
disp = dseg_add_address(cd, m);
M_ALD(REG_ITMP1, REG_PV_CALLEE, disp);
M_AST(REG_ITMP1, REG_SP, CSTACK);
#include "vm/jit/asmpart.h"
#include "vm/jit/stacktrace.h"
+/* assembler function prototypes **********************************************/
+void asm_store_fp_state_reg(u8 *mem);
+void asm_load_fp_state_reg(u8 *mem);
+
+
/* shift away 13-bit immediate, mask rd and rs1 */
#define SHIFT_AND_MASK(instr) \
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: stacktrace.c 7667 2007-04-05 00:16:05Z michi $
+ $Id: stacktrace.c 7792 2007-04-22 20:02:05Z tbfg $
*/
if (!opt_intrp) {
# endif
-# if defined(__I386__) || defined(__X86_64__) || defined(__S390__)
+# if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__M68K__)
/* On i386 and x86_64 we always have to get the return address
from the stack. */
/* On S390 we use REG_RA as REG_ITMP3, so we have always to get
/* Set stack pointer to stackframe of parent Java
function of the current Java function. */
-#if defined(__I386__) || defined (__X86_64__)
+#if defined(__I386__) || defined (__X86_64__) || defined (__M68K__)
sp += framesize + SIZEOF_VOID_P;
#elif defined(__SPARC_64__)
sp = md_get_framepointer(sp);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: properties.c 7257 2007-01-29 23:07:40Z twisti $
+ $Id: properties.c 7783 2007-04-20 13:28:27Z twisti $
*/
typedef struct list_properties_entry list_properties_entry;
struct list_properties_entry {
- char *key;
- char *value;
- listnode linkage;
+ char *key;
+ char *value;
+ listnode_t linkage;
};
/* global variables ***********************************************************/
-static list *list_properties = NULL;
+static list_t *list_properties = NULL;
/* properties_init *************************************************************
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: signal.c 7601 2007-03-28 23:02:50Z michi $
+ $Id: signal.c 7797 2007-04-23 20:12:39Z michi $
*/
#include "config.h"
+#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
# include "threads/threads-common.h"
#endif
+#include "vm/exceptions.h"
#include "vm/signallocal.h"
#include "vm/vm.h"
#include "vmcore/options.h"
+#if defined(ENABLE_STATISTICS)
+# include "vmcore/statistics.h"
+#endif
+
/* global variables ***********************************************************/
(void) memory_mmap_anon(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_FIXED);
+ /* check if we get into trouble with our hardware-exceptions */
+
+ assert(OFFSET(java_bytearray, data) > EXCEPTION_HARDWARE_PATCHER);
+
/* Block the following signals (SIGINT for <ctrl>-c, SIGQUIT for
<ctrl>-\). We enable them later in signal_thread, but only for
this thread. */
if (sigemptyset(&mask) != 0)
vm_abort("signal_thread: sigemptyset failed: %s", strerror(errno));
- sigaddset(&mask, SIGINT);
+ if (sigaddset(&mask, SIGINT) != 0)
+ vm_abort("signal_thread: sigaddset failed: %s", strerror(errno));
+
#if !defined(__FREEBSD__)
- sigaddset(&mask, SIGQUIT);
+ if (sigaddset(&mask, SIGQUIT) != 0)
+ vm_abort("signal_thread: sigaddset failed: %s", strerror(errno));
#endif
while (true) {
/* just wait for a signal */
+ /* XXX We don't check for an error here, although the man-page
+ states sigwait does not return an error (which is wrong!),
+ but it seems to make problems with Boehm-GC. We should
+ revisit this code with our new exact-GC. */
+
+/* if (sigwait(&mask, &sig) != 0) */
+/* vm_abort("signal_thread: sigwait failed: %s", strerror(errno)); */
(void) sigwait(&mask, &sig);
switch (sig) {
#include "native/jni.h"
#include "native/native.h"
+#include "native/include/java_lang_String.h" /* required by java_lang_Class.h */
#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_String.h"
#if defined(ENABLE_THREADS)
# include "threads/native/threads.h"
# include "native/jvmti/cacaodbg.h"
#endif
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
/* Invocation API variables ***************************************************/
printf(" maximum heap size : %d\n", opt_heapmaxsize);
printf(" initial heap size : %d\n", opt_heapstartsize);
printf(" stack size : %d\n", opt_stacksize);
+ printf(" libjvm.so : %s\n", cacao_libjvm);
printf(" java.boot.class.path : %s\n", _Jv_bootclasspath);
printf(" gnu.classpath.boot.library.path: %s\n", classpath_libdir);
printf(" java.class.path : %s\n", _Jv_classpath);
jdwp = agentbypath = false;
#endif
+#if defined(ENABLE_VMLOG)
+ vmlog_cacao_init(vm_args);
+#endif
+
/* check the JNI version requested */
switch (vm_args->version) {
opt_stat = true;
# endif
}
+ else {
+ printf("Unknown -verbose option: %s\n", opt_arg);
+ usage();
+ }
#endif
break;
case OPT_DEBUGCOLOR:
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: class.c 7615 2007-03-29 23:10:59Z michi $
+ $Id: class.c 7797 2007-04-23 20:12:39Z michi $
*/
/* global variables ***********************************************************/
-list unlinkedclasses; /* this is only used for eager class */
+list_t unlinkedclasses; /* this is only used for eager class */
/* loading */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: class.h 7601 2007-03-28 23:02:50Z michi $
+ $Id: class.h 7797 2007-04-23 20:12:39Z michi $
*/
s4 methodscount; /* number of methods */
methodinfo *methods; /* method table */
- listnode listnode; /* linkage */
+ listnode_t listnode; /* linkage */
s4 state; /* current class state */
s4 index; /* hierarchy depth (classes) or index */
/* global variables ***********************************************************/
-extern list unlinkedclasses; /* this is only used for eager class loading */
+extern list_t unlinkedclasses; /* this is only used for eager class loading */
/* frequently used classes ****************************************************/
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: suck.c 7272 2007-02-01 15:35:09Z twisti $
+ $Id: suck.c 7783 2007-04-20 13:28:27Z twisti $
*/
/* global variables ***********************************************************/
-list *list_classpath_entries;
+list_t *list_classpath_entries;
/* suck_init *******************************************************************
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: suck.h 7246 2007-01-29 18:49:05Z twisti $
+ $Id: suck.h 7783 2007-04-20 13:28:27Z twisti $
*/
#if defined(ENABLE_ZLIB)
hashtable *htclasses;
#endif
- listnode linkage;
+ listnode_t linkage;
};
/* export variables ***********************************************************/
-extern list *list_classpath_entries;
+extern list_t *list_classpath_entries;
/* function prototypes ********************************************************/
endif
check: $(HARNESS_CLASS_FILES)
- @for t in $(TEST_NAMES) ; do echo "TEST $$t" ; { $(JAVAC) -d . $(srcdir)/$$t.java && LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs $(JAVA) $$t ; } || exit 1 ; done
+ @for t in $(TEST_NAMES) ; do echo "TEST $$t" ; { $(JAVAC) -d . -classpath . $(srcdir)/$$t.java && LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs $(JAVA) $(JAVAFLAGS) $$t ; } || exit 1 ; done
$(HARNESS_CLASS_FILES): $(HARNESS_SOURCE_FILES)
$(JAVAC) -d . $(HARNESS_SOURCE_FILES)