* src/vm/jit/x86_64/codegen.c (codegen_emit): Builtin stubs are called
authormichi <none@none>
Mon, 23 Apr 2007 19:57:45 +0000 (19:57 +0000)
committermichi <none@none>
Mon, 23 Apr 2007 19:57:45 +0000 (19:57 +0000)
for ICMD_BUILTIN if available.

* src/vm/jit/i386/codegen.c (codegen_emit): Likewise.
(codegen_emit_stub_builtin): Adapted to new signature and a bugfix.

--HG--
branch : exact-gc

16 files changed:
configure.ac
contrib/vmlog/Makefile [new file with mode: 0644]
contrib/vmlog/README [new file with mode: 0644]
contrib/vmlog/vmlog_cacao.patch [new file with mode: 0644]
src/toolbox/list.c
src/toolbox/list.h
src/vm/Makefile.am
src/vm/exceptions.c
src/vm/jit/i386/codegen.c
src/vm/jit/intrp/asmpart.c
src/vm/jit/m68k/linux/md-abi.c [new file with mode: 0644]
src/vm/jit/m68k/linux/md-os.c [new file with mode: 0644]
src/vm/jit/m68k/linux/md-os.h [new file with mode: 0644]
src/vm/jit/powerpc/darwin/md-os.c
src/vm/jit/stacktrace.c
src/vm/jit/x86_64/codegen.c

index 4a982fd6c5bf78be96417ec10a2da815ab3b647b..cfbabe42ff01e2db53ec9eab4500defcb8694d08 100644 (file)
@@ -22,7 +22,7 @@ dnl along with this program; if not, write to the Free Software
 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 dnl 02110-1301, USA.
 dnl 
-dnl $Id: configure.ac 7650 2007-04-03 13:48:10Z twisti $
+dnl $Id: configure.ac 7667 2007-04-05 00:16:05Z michi $
 
 dnl Process this file with autoconf to produce a configure script.
 
diff --git a/contrib/vmlog/Makefile b/contrib/vmlog/Makefile
new file mode 100644 (file)
index 0000000..3821b68
--- /dev/null
@@ -0,0 +1,50 @@
+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)
diff --git a/contrib/vmlog/README b/contrib/vmlog/README
new file mode 100644 (file)
index 0000000..b95a813
--- /dev/null
@@ -0,0 +1,125 @@
+vmlog - high-speed logging for free VMs
+Copyright (c) 2006 Edwin Steiner <edwin.steiner@gmx.net>
+-----------------------------------------------------------------------
+
+About
+-----
+
+vmlog is a software module for doing fast call logging in free Java VMs and a
+set of tools for examining the created logfiles.
+
+Some features of vmlog:
+
+       * high data density because of binary formats with hashed strings
+       * high speed (ie. you can run big applications with full logging)
+       * small, non-intrusive interface to several VMs
+       * clean separation of threads
+       * can ignore a user-specified list of methods
+
+Right now there are complete interfaces for the following VMs:
+
+       * CACAO
+       * jamvm 1.4.2
+
+       
+License
+-------
+       
+vmlog is free software distributed under the GPL. See the file COPYING
+for details.
+
+
+How to compile a VM with vmlog
+------------------------------
+
+You need to do two things:
+
+       * patch the VM code with the provided vmlog_<vm>.patch
+       * configure the VM with CFLAGS that include -Ivmlogdir
+         where vmlogdir is the directory the contains the vmlog
+         source code
+
+You can then compile your VM with vmlog. 
+
+
+Using vmlog
+-----------
+
+To use it call the VM with at least the following option added to the command
+line:
+
+       -vmlog:prefix PREFIX
+
+PREFIX is an arbitrary string that will be used as a prefix for the generated
+file names.
+
+Note: For cacao you currently also have to add `-verbose:call` to activate
+the logging.
+
+
+Ignore Lists
+------------
+
+If you want vmlog to ignore certain methods do the following:
+
+       * put the full names of the methods (as displayed by vmlog)
+         into a file, say "vmloginore.txt".
+
+       * type
+
+               vmlogindex vmloginore vmloginore.txt
+
+       * add the following option to your VM command line:
+
+               -vmlog:ignore vmloginore
+
+
+The Tools
+---------
+
+After running something with your prepared VM, you will find the following
+files:
+
+    PREFIX.idx          string index
+       PREFIX.str          string data
+       PREFIX.#.log        log for thread number #
+
+Some things you can do now:
+
+       * Count called methods:
+
+               vmlogdump PREFIX -c
+
+       * Show open call frames at the end of the log:
+
+               vmlogdump PREFIX -o
+       
+       * Dump all strings in the hash:
+
+               vmlogdump PREFIX -s
+
+       * Print an indented call trace:
+
+               vmlogdump PREFIX
+
+
+Comparing logs
+--------------
+
+An important feature of vmlog is that you can compare the logs created by
+different VMs. To do this first do a normal vmlog run with the first VM.
+Then start the second VM with theese options:
+
+       -vmlog:prefix OTHERPREFIX -vmlog:strings PREFIX
+
+where PREFIX is the PREFIX you used for the first VM run and OTHERPREFIX
+is a different string.
+
+You can now compare the logs (for example of the first thread):
+
+       vmlogdiff OTHERPREFIX PREFIX.0.log OTHERPREFIX.0.log
+
+Note: vmlogdiff is currently not fast enough, yet. You can add the
+`-v` option to it to see what it is doing (on stderr) at least.
+
+
diff --git a/contrib/vmlog/vmlog_cacao.patch b/contrib/vmlog/vmlog_cacao.patch
new file mode 100644 (file)
index 0000000..0849ab4
--- /dev/null
@@ -0,0 +1,235 @@
+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) {
index d6da79efb2fc982e3e01d12091d220e4ef843ccb..33fefd713f9bc586f32dec54d0129e5b90e6235d 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: list.c 7596 2007-03-28 21:05:53Z twisti $
+   $Id: list.c 7601 2007-03-28 23:02:50Z michi $
 
 */
 
index 1feaa1b03dd56b91909474041d6f740e25155aca..b6a3ed7031a10f3ee77a726c1d1b4bfc9d9065da 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: list.h 7596 2007-03-28 21:05:53Z twisti $
+   $Id: list.h 7601 2007-03-28 23:02:50Z michi $
 
 */
 
index 0e84aa1c7492f971dbd0c24b095843692db4f788..0161a9c70a0ea7964674379082cbe68cbd7d97d7 100644 (file)
@@ -22,7 +22,7 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 ##
-## $Id: Makefile.am 7486 2007-03-08 13:50:07Z twisti $
+## $Id: Makefile.am 7483 2007-03-08 13:17:40Z michi $
 
 ## Process this file with automake to produce Makefile.in
 
index 20c80fb5f8b72bf3a46f22ce24ae9efae655155e..a32993fda98a37cedbe373fb92e8b14a42599298 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: exceptions.c 7671 2007-04-05 12:06:28Z twisti $
+   $Id: exceptions.c 7674 2007-04-05 13:27:11Z michi $
 
 */
 
index 6c9811d3d796f1bf08c560ab85de40c72708ed80..beeb23075eb81067f1384c0ca32adee4bd89588b 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: codegen.c 7794 2007-04-23 19:57:45Z michi $
 
 */
 
@@ -2979,10 +2979,13 @@ gen_method:
 
                        switch (iptr->opc) {
                        case ICMD_BUILTIN:
-                               disp = (ptrint) bte->fp;
                                d = md->returntype.type;
 
-                               M_MOV_IMM(disp, REG_ITMP1);
+                               if (bte->stub == NULL) {
+                                       M_MOV_IMM(bte->fp, REG_ITMP1);
+                               } else {
+                                       M_MOV_IMM(bte->stub, REG_ITMP1);
+                               }
                                M_CALL(REG_ITMP1);
 
                                emit_exception_check(cd, iptr);
@@ -3723,10 +3726,11 @@ void codegen_emit_stub_compiler(jitdata *jd)
 
 *******************************************************************************/
 
-void codegen_emit_stub_builtin(jitdata *jd, methoddesc *md, functionptr f)
+void codegen_emit_stub_builtin(jitdata *jd, builtintable_entry *bte)
 {
        codeinfo    *code;
        codegendata *cd;
+       methoddesc  *md;
        s4           i;
        s4           disp;
        s4           s1, s2;
@@ -3736,6 +3740,10 @@ void codegen_emit_stub_builtin(jitdata *jd, methoddesc *md, functionptr f)
        code = jd->code;
        cd   = jd->cd;
 
+       /* set some variables */
+
+       md = bte->md;
+
        /* calculate stack frame size */
 
        cd->stackframesize =
@@ -3802,7 +3810,7 @@ void codegen_emit_stub_builtin(jitdata *jd, methoddesc *md, functionptr f)
 
                } else {       /* float/double in memory can be copied like int/longs */
                        s1 = (md->params[i].regoff + cd->stackframesize + 1) * 4;
-                       s2 = md->params[i].regoff;
+                       s2 = md->params[i].regoff * 4;
 
                        M_ILD(REG_ITMP1, REG_SP, s1);
                        M_IST(REG_ITMP1, REG_SP, s2);
@@ -3816,7 +3824,7 @@ void codegen_emit_stub_builtin(jitdata *jd, methoddesc *md, functionptr f)
 
        /* call the builtin function */
 
-       M_MOV_IMM(f, REG_ITMP3);
+       M_MOV_IMM(bte->fp, REG_ITMP3);
        M_CALL(REG_ITMP3);
 
        /* save return value */
index 085c39deca064cc5a9b963fab34960284061ca5b..4a3ec9a5de600a4e81d8b6dac2e989d6b24cb75f 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: asmpart.c 7675 2007-04-05 14:23:04Z michi $
+   $Id: asmpart.c 7688 2007-04-12 09:05:12Z michi $
 
 */
 
diff --git a/src/vm/jit/m68k/linux/md-abi.c b/src/vm/jit/m68k/linux/md-abi.c
new file mode 100644 (file)
index 0000000..b315acf
--- /dev/null
@@ -0,0 +1,175 @@
+/* src/vm/jit/m68k/linux/md-abi.c - linux specific abi functions
+
+   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
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   $Id: arch.h 5330 2006-09-05 18:43:12Z edwin $
+
+*/
+
+
+
+#include "config.h"
+
+#include <assert.h>
+
+#include "md-abi.h"
+
+#include "vm/types.h"
+
+#include "vm/jit/abi.h"
+
+/* Integer register description */
+/*                        D0,      D1,   ITMP1,   ITMP2,   ITMP3,      D5,      D6,      D7 */
+s4 nregdescint[] = { REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_SAV, REG_SAV, REG_SAV, REG_END };
+
+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_temporary[]     = {0,1};
+
+/* Address register description */
+/* A6 is used as framepointer by native code, so be sure it is REG_RES */
+/*                        A0,      A1,   ATMP1,   ATMP2,   ATMP3,      A5,  REG_FP, REG_SP */
+s4 nregdescadr[] = { REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_SAV, REG_RES, REG_RES, REG_END };
+
+
+/* Floatingpoint register description */
+/*                        F0,      F1,   FTMP1,   FTMP2,   FTMP3,      F5,      F6,      F7 */
+#if !defined(ENABLE_SOFTFLOAT)
+s4 nregdescfloat[] = { REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_SAV, REG_SAV, REG_SAV, REG_END };
+#else
+s4 nregdescfloat[] = { REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_RES, REG_END };
+#endif
+
+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_temporary[]       = {0,1};
+
+
+/* md_param_alloc_native *******************************************************
+ *
+ *    Pre-allocate arguments according the native ABI.
+ *
+ *    *******************************************************************************/
+
+void md_param_alloc_native(methoddesc *md)
+{
+               /* For now use system ABI */
+               md_param_alloc(md);
+}
+
+
+/* md_param_alloc **************************************************************
+ *
+ *    Allocate Arguments to Stackslots according the Calling Conventions
+ *
+ *       --- in
+ *       md->paramcount:           Number of arguments for this method
+ *       md->paramtypes[].type:    Argument types
+ *
+ *       --- out
+ *       md->params[].inmemory:    Argument spilled on stack
+ *       md->params[].regoff:      Stack offset or rd->arg[int|flt]regs index
+ *       md->memuse:               Stackslots needed for argument spilling
+ *       md->argintreguse:         max number of integer arguments used
+ *       md->argfltreguse:         max number of float arguments used
+ *
+ ********************************************************************************/
+void md_param_alloc(methoddesc *md)
+{
+       paramdesc       *pd;
+       s4      stacksize;
+       s4      i;
+
+       pd = md->params;
+       stacksize = 0;
+
+       for (i=0; i<md->paramcount; i++, pd++)  {
+               pd->inmemory = true;
+               pd->regoff = stacksize;
+               stacksize += IS_2_WORD_TYPE(md->paramtypes[i].type) ? 2:1;
+       }
+
+       md->memuse = stacksize;
+       md->argintreguse = 0;
+       md->argfltreguse = 0;
+       md->argadrreguse = 0;
+}
+
+/* md_return_alloc *************************************************************
+
+   Precolor the Java Stackelement containing the Return Value, if
+   possible. We stick to the abi as closed as possible and therefore use
+   %d0 for all word types %d0-%d1 for 2 word types. %f0-%f1 for floats/doubles
+*******************************************************************************/
+
+void md_return_alloc(jitdata *jd, stackptr stackslot)
+{ 
+
+/* The Problem: %a0, %a1, %d0 and %d1 are scratch registers by platform abi
+ * so they are defined REG_TMP, which i think is correct. But a preallocated
+ * register has to be REG_SAV it seems. One could make theese REG_SAV but 
+ * then there would be a abi mismatch with native functions...for now no
+ * return_alloc.*/
+
+#if 0
+       methodinfo   *m;
+       registerdata *rd;
+       methoddesc   *md;
+
+       /* get required compiler data */
+
+       m  = jd->m;
+       rd = jd->rd;
+
+       md = m->parseddesc;
+
+       /* XXX wondering if this is correct */
+       assert(rd->argintreguse == 0);
+       assert(rd->argadrreguse == 0);
+       assert(rd->argfltreguse == 0);
+
+       VAR(stackslot->varnum)->flags = PREALLOC;
+       switch (md->returntype.type)    {
+               case TYPE_INT:
+               case TYPE_ADR:
+                       VAR(stackslot->varnum)->vv.regoff = REG_RESULT;
+                       break;
+               case TYPE_LNG:
+                       VAR(stackslot->varnum)->vv.regoff = REG_RESULT_PACKED;
+                       break;
+
+               case TYPE_FLT:
+               case TYPE_DBL:
+                       VAR(stackslot->varnum)->vv.regoff = REG_FRESULT;
+                       break;
+
+               default: assert(0);
+       }
+#endif
+
+}
+
diff --git a/src/vm/jit/m68k/linux/md-os.c b/src/vm/jit/m68k/linux/md-os.c
new file mode 100644 (file)
index 0000000..f334bb1
--- /dev/null
@@ -0,0 +1,145 @@
+/* src/vm/jit/m68k/linux/md-os.c - linux specific functions
+
+   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
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   $Id: arch.h 5330 2006-09-05 18:43:12Z edwin $
+
+*/
+
+#include "config.h"
+
+#include "md-os.h"
+#include "md-abi.h"
+
+#include "vm/vm.h"
+#include "vm/exceptions.h"
+#include "vm/jit/asmpart.h"
+
+#include <assert.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <stdint.h>
+#include <sys/ucontext.h> /* has br0ken ucontext_t*/
+
+/*
+ *  The glibc bundeled with my devels system ucontext.h differs with kernels ucontext.h. Not good.
+ *  The following stuff is taken from 2.6.10 + freescale coldfire patches:
+ */
+typedef struct actual_fpregset {
+       int f_fpcntl[3];
+       int f_fpregs[8*3];
+} actual_fpregset_t;
+
+typedef struct actual_mcontext {
+       int version;
+       gregset_t gregs;        /* 0...7 = %d0-%d7, 8...15 = %a0-%a7 */
+       actual_fpregset_t fpregs;
+} actual_mcontext_t;
+
+typedef struct actual_ucontext {
+       unsigned long     uc_flags;
+       struct actual_ucontext  *uc_link;
+       stack_t           uc_stack;
+       struct actual_mcontext   uc_mcontext;
+       unsigned long     uc_filler[80];
+       sigset_t          uc_sigmask;   /* mask last for extensibility */
+} actual_ucontext_t;
+
+
+/*
+ *     linux specific initializations
+ */
+void md_init_linux()
+{
+       struct sigaction act;
+       
+       act.sa_sigaction = md_signal_handler_sigill;
+       act.sa_flags     = SA_NODEFER | SA_SIGINFO;
+
+       if (sigaction(SIGILL, &act, NULL) == -1)        {
+               vm_abort("md_linux_init: Error registering signal handler");
+       }
+}
+
+/* md_signal_handler_sigsegv ******************************************
+ *
+ * BLA BLA
+ */
+void md_signal_handler_sigsegv(/*int sig, siginfo_t *siginfo, void *_p*/) 
+{      
+       assert(0); 
+}
+
+/*
+ * 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;
+       uint16_t        opc;
+       uint32_t        type;
+       uint32_t        val, regval;
+       java_objectheader *e;
+       mcontext_t      *_mc;
+
+       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.
+        */
+       switch (type)   {
+               case EXCEPTION_HARDWARE_CLASSCAST: 
+                       regval = *(uint16_t*)(xpc-4);
+                       assert( (regval&0xfff0) == 0x4a00 );
+                       /* was in a address register */
+                       regval = _mc->gregs[ 8 + (regval & 0x7) ];
+                       break;
+               default: assert(0);
+       }
+
+       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[R_PC]          = (ptrint) asm_handle_exception;
+}
diff --git a/src/vm/jit/m68k/linux/md-os.h b/src/vm/jit/m68k/linux/md-os.h
new file mode 100644 (file)
index 0000000..dfba624
--- /dev/null
@@ -0,0 +1,33 @@
+/* src/vm/jit/m68k/linux/md-os.h - linux specific functions
+
+   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
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   $Id: arch.h 5330 2006-09-05 18:43:12Z edwin $
+
+*/
+
+#include "config.h"
+
+
+void md_signal_handler_sigill();
+void md_init_linux();
index 3a23bf810d325b6a6cd68d5fceb61dfa207cb59e..d3200f7855e5cc9537f46be98fdc20b7793142a0 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: md-os.c 7596 2007-03-28 21:05:53Z twisti $
+   $Id: md-os.c 7601 2007-03-28 23:02:50Z michi $
 
 */
 
index 01f1fb797730d16fbbc9255a1e8096b8f058a029..be19c29f391255bb6ffa61819f7ae7bc62c5b228 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: stacktrace.c 7657 2007-04-03 15:51:52Z twisti $
+   $Id: stacktrace.c 7667 2007-04-05 00:16:05Z michi $
 
 */
 
index ead76ad0102c4f1c0ca77a86beffd460e9a7b02f..7a2b087add676f777cf6dc2e5485c8ccd3630be6 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: codegen.c 7794 2007-04-23 19:57:45Z michi $
 
 */
 
@@ -2418,7 +2418,11 @@ gen_method:
 
                        switch (iptr->opc) {
                        case ICMD_BUILTIN:
-                               M_MOV_IMM(bte->fp, REG_ITMP1);
+                               if (bte->stub == NULL) {
+                                       M_MOV_IMM(bte->fp, REG_ITMP1);
+                               } else {
+                                       M_MOV_IMM(bte->stub, REG_ITMP1);
+                               }
                                M_CALL(REG_ITMP1);
 
                                emit_exception_check(cd, iptr);