* src/vm/jit/trap.c: Moved to C++
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Sun, 28 Dec 2008 14:32:21 +0000 (15:32 +0100)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Sun, 28 Dec 2008 14:32:21 +0000 (15:32 +0100)
* src/vm/jit/trap.h: Likewise.
* src/vm/jit/trap.cpp: See above.
* src/vm/jit/trap.hpp: Likeiwse.

Adapted includes in the following files:
* src/vm/jit/alpha/codegen.c
* src/vm/jit/alpha/emit.c
* src/vm/jit/alpha/linux/md-os.c
* src/vm/jit/alpha/md.c
* src/vm/jit/arm/emit.c
* src/vm/jit/arm/linux/md-os.c
* src/vm/jit/i386/codegen.c
* src/vm/jit/i386/darwin/md-os.c
* src/vm/jit/i386/emit.c
* src/vm/jit/i386/freebsd/md-os.c
* src/vm/jit/i386/linux/md-os.c
* src/vm/jit/i386/solaris/md-os.c
* src/vm/jit/m68k/codegen.c
* src/vm/jit/m68k/emit.c
* src/vm/jit/m68k/linux/md-os.c
* src/vm/jit/mips/codegen.c
* src/vm/jit/mips/emit.c
* src/vm/jit/mips/linux/md-os.c
* src/vm/jit/powerpc/codegen.c
* src/vm/jit/powerpc/emit.c
* src/vm/jit/powerpc/linux/md-os.c
* src/vm/jit/powerpc64/codegen.c
* src/vm/jit/powerpc64/emit.c
* src/vm/jit/powerpc64/linux/md-os.c
* src/vm/jit/powerpc64/md.c
* src/vm/jit/s390/codegen.c
* src/vm/jit/s390/emit.c
* src/vm/jit/s390/md.c
* src/vm/jit/sparc64/linux/md-os.c
* src/vm/jit/sparc64/solaris/md-os.c
* src/vm/jit/x86_64/codegen.c
* src/vm/jit/x86_64/emit.c
* src/vm/jit/x86_64/linux/md-os.c
* src/vm/jit/x86_64/solaris/md-os.c
* src/vm/vm.cpp

--HG--
rename : src/vm/jit/trap.c => src/vm/jit/trap.cpp
rename : src/vm/jit/trap.h => src/vm/jit/trap.hpp

39 files changed:
src/vm/jit/alpha/codegen.c
src/vm/jit/alpha/emit.c
src/vm/jit/alpha/linux/md-os.c
src/vm/jit/alpha/md.c
src/vm/jit/arm/emit.c
src/vm/jit/arm/linux/md-os.c
src/vm/jit/i386/codegen.c
src/vm/jit/i386/darwin/md-os.c
src/vm/jit/i386/emit.c
src/vm/jit/i386/freebsd/md-os.c
src/vm/jit/i386/linux/md-os.c
src/vm/jit/i386/solaris/md-os.c
src/vm/jit/m68k/codegen.c
src/vm/jit/m68k/emit.c
src/vm/jit/m68k/linux/md-os.c
src/vm/jit/mips/codegen.c
src/vm/jit/mips/emit.c
src/vm/jit/mips/linux/md-os.c
src/vm/jit/powerpc/codegen.c
src/vm/jit/powerpc/emit.c
src/vm/jit/powerpc/linux/md-os.c
src/vm/jit/powerpc64/codegen.c
src/vm/jit/powerpc64/emit.c
src/vm/jit/powerpc64/linux/md-os.c
src/vm/jit/powerpc64/md.c
src/vm/jit/s390/codegen.c
src/vm/jit/s390/emit.c
src/vm/jit/s390/md.c
src/vm/jit/sparc64/linux/md-os.c
src/vm/jit/sparc64/solaris/md-os.c
src/vm/jit/trap.c [deleted file]
src/vm/jit/trap.cpp [new file with mode: 0644]
src/vm/jit/trap.h [deleted file]
src/vm/jit/trap.hpp [new file with mode: 0644]
src/vm/jit/x86_64/codegen.c
src/vm/jit/x86_64/emit.c
src/vm/jit/x86_64/linux/md-os.c
src/vm/jit/x86_64/solaris/md-os.c
src/vm/vm.cpp

index bb4c1fcb9758d10148f7aead4ab8b83c4517c925..21e536f7cf806a610f7e0ad333e789b3e697d4a5 100644 (file)
@@ -62,7 +62,7 @@
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 #if defined(ENABLE_SSA)
 # include "vm/jit/optimizing/lsra.h"
index 96fb6f0be0a72427f95e41a37e9ca06be35828b6..ac5d0ba12febe305ce5eb2bf8e0327ceb75d67e4 100644 (file)
@@ -48,7 +48,7 @@
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/trace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* emit_load *******************************************************************
index 1fe5e80861fb0c0e766639bc63a2ff5282229c28..b81ff2bc733c59c22b79348514f80e6cb1d06dab 100644 (file)
@@ -45,7 +45,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/disass.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index 9ad99b7474b6f982d1c66ea557be178a04f453a7..f769b3f7892b846a313c56cbb0e19b24a395770c 100644 (file)
@@ -40,7 +40,7 @@ extern void ieee_set_fp_control(unsigned long fp_control);
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/jit.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* global variables ***********************************************************/
index c6c922c2131a23f032395369989bd6a03925ca12..a9793ce7b7a7ded5733e36e27c9d45304ca16d88 100644 (file)
@@ -47,7 +47,7 @@
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/trace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 #include "toolbox/logging.hpp" /* XXX for debugging only */
 
index 10e7c13a2a80ce5239e60c7ff7cad6060d1ef0cc..0788aa26a9ecc9341dd3625a4b8a2c56c9903216 100644 (file)
@@ -59,7 +59,7 @@ typedef struct ucontext {
 #include "vm/jit/disass.h"
 #include "vm/jit/executionstate.h"
 #include "vm/jit/patcher-common.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index 8eab0fbf0511a4cce0d56cac92d930db7c06b8ed..0b2ae467161bfdfe3a5b293cd54b0516b548ba0b 100644 (file)
@@ -64,7 +64,7 @@
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 #if defined(ENABLE_SSA)
 # include "vm/jit/optimizing/lsra.h"
index b9f3afd9de575a9b1697f2dc96553ee273ff33eb..b18a66a27c8919fd5c49681010566edad9158b8c 100644 (file)
@@ -44,7 +44,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 #include "vm/jit/i386/codegen.h"
 
index 3a264f162542561af62ca4197e098192313699a4..27c60f5caf4bea7a24aa5183eae3216da0456953 100644 (file)
@@ -48,7 +48,7 @@
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/trace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* emit_load ******************************************************************
index 9a18831478fc3f327233a3c0c7725ad10d788f24..43800e6b1b4954217b7b2b33c318b3608118b508 100644 (file)
@@ -41,7 +41,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index 19be0e4b7fed8ee85218560bfc617fd88233d9f6..754b32124d55231dd08a52fe2a85e9ffe8c8973f 100644 (file)
@@ -43,7 +43,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index 16e649d6d41d92936af8dfbcec3339cf3d941040..e397050632d1683807c54b62ee7e149ece282544 100644 (file)
@@ -41,7 +41,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index 5c46894032a1423a32348317ed8de6b93f14b8be..12fd5184044329237c4489565e135ee28fdd25bc 100644 (file)
@@ -61,7 +61,7 @@
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 bool codegen_emit(jitdata *jd) 
index 63d74a8e6f5fed954cc43ca0bbcbdddbddd6102d..f0e3e5fbe7537981ad48419175ff565d6e923e6c 100644 (file)
@@ -37,7 +37,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/trace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* emit_mov_imm_reg **************************************************************************
index 36e85035df313b7dc366bfcab3037a91f2029308..45e1a34ffde91dd53740b1483c8d95782fd42d83 100644 (file)
@@ -32,7 +32,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 #include <assert.h>
 #include <stdlib.h>
index 7fac7239123a0ac7950dab501895bae3951acce0..3d98fce851cc9d606ab6ace50419538dc7ff4b2a 100644 (file)
@@ -58,7 +58,7 @@
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 #if defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
index 98e9b451fe4c21059433141c593cf52245bc19ae..60e4ceb75577a836dbfd9a340db53b9195fc1ac5 100644 (file)
@@ -47,7 +47,7 @@
 #include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/replace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* emit_load *******************************************************************
index e707d6ee2ec446aa96a1b707175c5c27c8c30cac..eef2a2dc6f272bacbddb5b7c08239f41d36fb8cc 100644 (file)
@@ -45,7 +45,7 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* md_init *********************************************************************
index 555f0cf8350dcdb650de97d349e35ab4fa183d28..832958f6b990731e06a83d98b066aa10f921f228 100644 (file)
@@ -64,7 +64,7 @@
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 #if defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
index 9569377aad1d700a664beea758decf578d318057..6065246b943c8de4a401b28c7f928537b8adee51 100644 (file)
@@ -48,7 +48,7 @@
 #include "vm/jit/jit.hpp"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/trace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* emit_load *******************************************************************
index 5d2bf98e4a62ba77153fdddf5cdad099418258b9..3980348dbd1a29c6ace0fd5eddf1975b1d213bb9 100644 (file)
@@ -51,7 +51,7 @@
 #endif
 
 #include "vm/jit/patcher-common.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index 7c609638f81d49574abc9c015c5ecee2967a24bf..4bfc7120698e3ece4147896d3accd50ec5c28e5d 100644 (file)
@@ -64,7 +64,7 @@
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 #if defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
index 0888baefe8a7696ca8e8db354b53a15ae67eec4d..3009eac9843545bcee8773b63c6a65f490127c61 100644 (file)
@@ -44,7 +44,7 @@
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/trace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* emit_load *******************************************************************
index 203cb007c24e4e673ae2037242b3dbfa7ac3d79d..25d0b1bf4d19ddfffc47a64763ae45fea8b71e3f 100644 (file)
@@ -50,7 +50,7 @@
 #endif
 
 #include "vm/jit/disass.h"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* md_signal_handler_sigsegv ***************************************************
index 15b564227e38b010872290989fd36e2874bfdd83..fd10194005ec08b1eda76b8b2dd65b2318f47424 100644 (file)
@@ -40,7 +40,7 @@
 #include "vm/global.h"
 
 #include "vm/jit/jit.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* md_init *********************************************************************
index b2780c05b58b1f3705da23e56a1a428e916b49ca..05055ba81b55bf7bf8f0de37697cf6d6f9659e09 100644 (file)
@@ -66,7 +66,7 @@
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* DO__LOG generates a call to do__log. No registers are destroyed,
index f4ed94218354bd2aee426b0a7943eb657343e3ac..0720e1387008dc512f22cb2aa7746bfb5adc7d79 100644 (file)
@@ -49,7 +49,7 @@
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/trace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* emit_load *******************************************************************
index 0788e45a16cd0ff09be8918b80c1ae3d80960963..bee38bb7d6b37128f6cb7c8f688aa6f51c680986 100644 (file)
@@ -45,7 +45,7 @@
 #include "vm/jit/methodheader.h"
 #include "vm/jit/methodtree.h"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 #if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
 #include "vm/options.h" /* XXX debug */
index 97c10e3f6d42808c6329fcf7ff7063ff89a8c606..5f38666e82ed92714fef2bcbe9241d5df31001d2 100644 (file)
@@ -38,7 +38,7 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 typedef struct sigcontext sigcontext;
index 8b13aa3f80d2fa1bbd5847e402ee68cf4c06db9b..f6911f670fe62b789c7d4ff5abc8cef2d43e5637 100644 (file)
@@ -41,7 +41,7 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 ptrint md_get_reg_from_context(mcontext_t *_mc, u4 rindex)
diff --git a/src/vm/jit/trap.c b/src/vm/jit/trap.c
deleted file mode 100644 (file)
index a5ab451..0000000
+++ /dev/null
@@ -1,321 +0,0 @@
-/* src/vm/jit/trap.c - hardware traps
-
-   Copyright (C) 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-/* Include machine dependent trap stuff. */
-
-#include "md.h"
-#include "md-trap.h"
-
-#include "mm/memory.hpp"
-
-#include "native/llni.h"
-
-#include "toolbox/logging.hpp"
-
-#include "vm/exceptions.hpp"
-#include "vm/options.h"
-#include "vm/os.hpp"
-#include "vm/vm.hpp"
-
-#include "vm/jit/asmpart.h"
-#include "vm/jit/code.hpp"
-#include "vm/jit/disass.h"
-#include "vm/jit/executionstate.h"
-#include "vm/jit/jit.hpp"
-#include "vm/jit/methodtree.h"
-#include "vm/jit/patcher-common.hpp"
-#include "vm/jit/replace.hpp"
-#include "vm/jit/stacktrace.hpp"
-
-
-/**
- * Mmap the first memory page to support hardware exceptions and check
- * the maximum hardware trap displacement on the architectures where
- * it is required (TRAP_INSTRUCTION_IS_LOAD defined to 1).
- */
-void trap_init(void)
-{
-#if !(defined(__ARM__) && defined(__LINUX__))
-       /* On arm-linux the first memory page can't be mmap'ed, as it
-          contains the exception vectors. */
-
-       int pagesize;
-
-       /* mmap a memory page at address 0x0, so our hardware-exceptions
-          work. */
-
-       pagesize = os_getpagesize();
-
-       (void) os_mmap_anonymous(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_FIXED);
-#endif
-
-       TRACESUBSYSTEMINITIALIZATION("trap_init");
-
-#if !defined(TRAP_INSTRUCTION_IS_LOAD)
-# error TRAP_INSTRUCTION_IS_LOAD is not defined in your md-trap.h
-#endif
-
-#if TRAP_INSTRUCTION_IS_LOAD == 1
-       /* Check if we get into trouble with our hardware-exceptions. */
-
-       if (TRAP_END > OFFSET(java_bytearray_t, data))
-               vm_abort("trap_init: maximum hardware trap displacement is greater than the array-data offset: %d > %d", TRAP_END, OFFSET(java_bytearray_t, data));
-#endif
-}
-
-
-/**
- * Handles the signal which is generated by trap instructions, caught
- * by a signal handler and calls the correct function.
- *
- * @param type trap number
- * @param 
- */
-void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xpc, void *context)
-{
-       executionstate_t  es;
-       stackframeinfo_t  sfi;
-       int32_t           index;
-       java_handle_t    *o;
-       methodinfo       *m;
-       java_handle_t    *p;
-
-#if !defined(NDEBUG)
-       if (opt_TraceTraps)
-               log_println("[signal_handle: trap %d]", type);
-#endif
-       
-#if defined(ENABLE_VMLOG)
-       vmlog_cacao_signl_type(type);
-#endif
-
-       /* Prevent compiler warnings. */
-
-       o = NULL;
-       m = NULL;
-
-#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__X86_64__)
-# if !defined(NDEBUG)
-       /* Perform a sanity check on our execution state functions. */
-
-       executionstate_sanity_check(context);
-# endif
-
-       /* Read execution state from current context. */
-
-       es.code = NULL;
-       md_executionstate_read(&es, context);
-#endif
-
-       /* wrap the value into a handle if it is a reference */
-       /* BEFORE: creating stackframeinfo */
-
-       switch (type) {
-       case TRAP_ClassCastException:
-               o = LLNI_WRAP((java_object_t *) val);
-               break;
-
-       case TRAP_COMPILER:
-               /* In this case the passed PV points to the compiler stub.  We
-                  get the methodinfo pointer here and set PV to NULL so
-                  stacktrace_stackframeinfo_add determines the PV for the
-                  parent Java method. */
-
-               m  = code_get_methodinfo_for_pv(pv);
-               pv = NULL;
-               break;
-
-       default:
-               /* do nothing */
-               break;
-       }
-
-       /* Fill and add a stackframeinfo. */
-
-       stacktrace_stackframeinfo_add(&sfi, pv, sp, ra, xpc);
-
-       switch (type) {
-       case TRAP_NullPointerException:
-               p = exceptions_new_nullpointerexception();
-               break;
-
-       case TRAP_ArithmeticException:
-               p = exceptions_new_arithmeticexception();
-               break;
-
-       case TRAP_ArrayIndexOutOfBoundsException:
-               index = (s4) val;
-               p = exceptions_new_arrayindexoutofboundsexception(index);
-               break;
-
-       case TRAP_ArrayStoreException:
-               p = exceptions_new_arraystoreexception();
-               break;
-
-       case TRAP_ClassCastException:
-               p = exceptions_new_classcastexception(o);
-               break;
-
-       case TRAP_CHECK_EXCEPTION:
-               p = exceptions_fillinstacktrace();
-               break;
-
-       case TRAP_PATCHER:
-#if defined(ENABLE_REPLACEMENT)
-               if (replace_me_wrapper(xpc, context)) {
-                       p = NULL;
-                       break;
-               }
-#endif
-               p = patcher_handler(xpc);
-               break;
-
-       case TRAP_COMPILER:
-               p = jit_compile_handle(m, sfi.pv, ra, (void *) val);
-               break;
-
-#if defined(ENABLE_REPLACEMENT)
-       case TRAP_COUNTDOWN:
-#if defined(__I386__)
-               replace_me_wrapper((char*)xpc - 13, context);
-#endif
-               p = NULL;
-               break;
-#endif
-
-       default:
-               /* Let's try to get a backtrace. */
-
-               (void) methodtree_find(xpc);
-
-               /* If that does not work, print more debug info. */
-
-               log_println("signal_handle: unknown hardware exception type %d", type);
-
-#if SIZEOF_VOID_P == 8
-               log_println("PC=0x%016lx", xpc);
-#else
-               log_println("PC=0x%08x", xpc);
-#endif
-
-#if defined(ENABLE_DISASSEMBLER)
-               log_println("machine instruction at PC:");
-               disassinstr(xpc);
-#endif
-
-               vm_abort("Exiting...");
-
-               /* keep compiler happy */
-
-               p = NULL;
-       }
-
-       /* Remove stackframeinfo. */
-
-       stacktrace_stackframeinfo_remove(&sfi);
-
-#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__X86_64__)
-       /* Update execution state and set registers. */
-       /* AFTER: removing stackframeinfo */
-
-       switch (type) {
-       case TRAP_COMPILER:
-               // The normal case for a compiler trap is to jump directly to
-               // the newly compiled method.
-
-               if (p != NULL) {
-                       es.pc = (uint8_t *) (uintptr_t) p;
-                       es.pv = (uint8_t *) (uintptr_t) p;
-                       break;
-               }
-
-               // In case of an exception during JIT compilation, we fetch
-               // the exception here and proceed with exception handling.
-
-               java_handle_t *e = exceptions_get_and_clear_exception();
-               assert(e != NULL);
-
-               // Get and set the PV from the parent Java method.
-
-               es.pv = md_codegen_get_pv_from_pc(ra);
-
-               // XXX: Make the code below a fall-through to default case!
-
-               es.intregs[REG_ITMP1_XPTR] = (uintptr_t) LLNI_DIRECT(e);
-               es.intregs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
-               es.pc                      = (uint8_t *) (uintptr_t) asm_handle_exception;
-               break;
-
-       case TRAP_PATCHER:
-               // The normal case for a patcher trap is to continue execution at
-               // the trap instruction. On some archs the PC may point after the
-               // trap instruction, so we reset it here.
-
-               if (p == NULL) {
-                       es.pc = (uint8_t *) (uintptr_t) xpc;
-                       break;
-               }
-
-               /* fall-through */
-
-       default:
-               if (p != NULL) {
-                       es.intregs[REG_ITMP1_XPTR] = (uintptr_t) LLNI_DIRECT(p);
-                       es.intregs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
-                       es.pc                      = (uint8_t *) (uintptr_t) asm_handle_exception;
-               }
-       }
-
-       /* Write back execution state to current context. */
-
-       md_executionstate_write(&es, context);
-#endif
-
-       /* unwrap and return the exception object */
-       /* AFTER: removing stackframeinfo */
-
-       if (type == TRAP_COMPILER)
-               return p;
-       else
-               return LLNI_UNWRAP(p);
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/vm/jit/trap.cpp b/src/vm/jit/trap.cpp
new file mode 100644 (file)
index 0000000..c1dc162
--- /dev/null
@@ -0,0 +1,329 @@
+/* src/vm/jit/trap.cpp - hardware traps
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+/* Include machine dependent trap stuff. */
+
+#include "md.h"
+#include "md-trap.h"
+
+#include "mm/memory.hpp"
+
+#include "native/llni.h"
+
+#include "toolbox/logging.hpp"
+
+#include "vm/exceptions.hpp"
+#include "vm/options.h"
+#include "vm/os.hpp"
+#include "vm/vm.hpp"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/code.hpp"
+#include "vm/jit/disass.h"
+#include "vm/jit/executionstate.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/methodtree.h"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Mmap the first memory page to support hardware exceptions and check
+ * the maximum hardware trap displacement on the architectures where
+ * it is required (TRAP_INSTRUCTION_IS_LOAD defined to 1).
+ */
+void trap_init(void)
+{
+#if !(defined(__ARM__) && defined(__LINUX__))
+       /* On arm-linux the first memory page can't be mmap'ed, as it
+          contains the exception vectors. */
+
+       int pagesize;
+
+       /* mmap a memory page at address 0x0, so our hardware-exceptions
+          work. */
+
+       pagesize = os::getpagesize();
+
+       (void) os::mmap_anonymous(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_FIXED);
+#endif
+
+       TRACESUBSYSTEMINITIALIZATION("trap_init");
+
+#if !defined(TRAP_INSTRUCTION_IS_LOAD)
+# error TRAP_INSTRUCTION_IS_LOAD is not defined in your md-trap.h
+#endif
+
+#if TRAP_INSTRUCTION_IS_LOAD == 1
+       /* Check if we get into trouble with our hardware-exceptions. */
+
+       if (TRAP_END > OFFSET(java_bytearray_t, data))
+               vm_abort("trap_init: maximum hardware trap displacement is greater than the array-data offset: %d > %d", TRAP_END, OFFSET(java_bytearray_t, data));
+#endif
+}
+
+
+/**
+ * Handles the signal which is generated by trap instructions, caught
+ * by a signal handler and calls the correct function.
+ *
+ * @param type trap number
+ * @param 
+ */
+void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xpc, void *context)
+{
+       executionstate_t es;
+       stackframeinfo_t sfi;
+
+#if !defined(NDEBUG)
+       if (opt_TraceTraps)
+               log_println("[signal_handle: trap %d]", type);
+#endif
+       
+#if defined(ENABLE_VMLOG)
+       vmlog_cacao_signl_type(type);
+#endif
+
+       /* Prevent compiler warnings. */
+
+       java_handle_t* o = NULL;
+       methodinfo*    m = NULL;
+
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__X86_64__)
+# if !defined(NDEBUG)
+       /* Perform a sanity check on our execution state functions. */
+
+       executionstate_sanity_check(context);
+# endif
+
+       /* Read execution state from current context. */
+
+       es.code = NULL;
+       md_executionstate_read(&es, context);
+#endif
+
+       /* Do some preparations before we enter the nativeworld. */
+       /* BEFORE: creating stackframeinfo */
+
+       switch (type) {
+       case TRAP_ClassCastException:
+               /* Wrap the value into a handle, as it is a reference. */
+
+               o = LLNI_WRAP((java_object_t *) val);
+               break;
+
+       case TRAP_COMPILER:
+               /* In this case the passed PV points to the compiler stub.  We
+                  get the methodinfo pointer here and set PV to NULL so
+                  stacktrace_stackframeinfo_add determines the PV for the
+                  parent Java method. */
+
+               m  = code_get_methodinfo_for_pv(pv);
+               pv = NULL;
+               break;
+
+       default:
+               /* do nothing */
+               break;
+       }
+
+       /* Fill and add a stackframeinfo. */
+
+       stacktrace_stackframeinfo_add(&sfi, pv, sp, ra, xpc);
+
+       /* Get resulting exception (or pointer to compiled method). */
+
+       int32_t        index;
+       java_handle_t* p;
+
+       switch (type) {
+       case TRAP_NullPointerException:
+               p = exceptions_new_nullpointerexception();
+               break;
+
+       case TRAP_ArithmeticException:
+               p = exceptions_new_arithmeticexception();
+               break;
+
+       case TRAP_ArrayIndexOutOfBoundsException:
+               index = (int32_t) val;
+               p = exceptions_new_arrayindexoutofboundsexception(index);
+               break;
+
+       case TRAP_ArrayStoreException:
+               p = exceptions_new_arraystoreexception();
+               break;
+
+       case TRAP_ClassCastException:
+               p = exceptions_new_classcastexception(o);
+               break;
+
+       case TRAP_CHECK_EXCEPTION:
+               p = exceptions_fillinstacktrace();
+               break;
+
+       case TRAP_PATCHER:
+#if defined(ENABLE_REPLACEMENT)
+               if (replace_me_wrapper((uint8_t*) xpc, context)) {
+                       p = NULL;
+                       break;
+               }
+#endif
+               p = patcher_handler((uint8_t*) xpc);
+               break;
+
+       case TRAP_COMPILER:
+               p = (java_handle_t*) jit_compile_handle(m, sfi.pv, ra, (void*) val);
+               break;
+
+#if defined(ENABLE_REPLACEMENT)
+       case TRAP_COUNTDOWN:
+# if defined(__I386__)
+               replace_me_wrapper((char*)xpc - 13, context);
+# endif
+               p = NULL;
+               break;
+#endif
+
+       default:
+               /* Let's try to get a backtrace. */
+
+               (void) methodtree_find(xpc);
+
+               /* If that does not work, print more debug info. */
+
+               log_println("signal_handle: unknown hardware exception type %d", type);
+
+#if SIZEOF_VOID_P == 8
+               log_println("PC=0x%016lx", xpc);
+#else
+               log_println("PC=0x%08x", xpc);
+#endif
+
+#if defined(ENABLE_DISASSEMBLER)
+               log_println("machine instruction at PC:");
+               disassinstr((uint8_t*) xpc);
+#endif
+
+               vm_abort("Exiting...");
+
+               /* keep compiler happy */
+
+               p = NULL;
+       }
+
+       /* Remove stackframeinfo. */
+
+       stacktrace_stackframeinfo_remove(&sfi);
+
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__X86_64__)
+       /* Update execution state and set registers. */
+       /* AFTER: removing stackframeinfo */
+
+       switch (type) {
+       case TRAP_COMPILER:
+               // The normal case for a compiler trap is to jump directly to
+               // the newly compiled method.
+
+               if (p != NULL) {
+                       es.pc = (uint8_t *) (uintptr_t) p;
+                       es.pv = (uint8_t *) (uintptr_t) p;
+                       break;
+               }
+
+               // In case of an exception during JIT compilation, we fetch
+               // the exception here and proceed with exception handling.
+
+               p = exceptions_get_and_clear_exception();
+               assert(p != NULL);
+
+               // Get and set the PV from the parent Java method.
+
+               es.pv = (uint8_t *) md_codegen_get_pv_from_pc(ra);
+
+               // Now fall-through to default exception handling.
+
+               goto trap_handle_exception;
+
+       case TRAP_PATCHER:
+               // The normal case for a patcher trap is to continue execution at
+               // the trap instruction. On some archs the PC may point after the
+               // trap instruction, so we reset it here.
+
+               if (p == NULL) {
+                       es.pc = (uint8_t *) (uintptr_t) xpc;
+                       break;
+               }
+
+               // Fall-through to default exception handling.
+
+       trap_handle_exception:
+       default:
+               if (p != NULL) {
+                       es.intregs[REG_ITMP1_XPTR] = (uintptr_t) LLNI_DIRECT(p);
+                       es.intregs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
+                       es.pc                      = (uint8_t *) (uintptr_t) asm_handle_exception;
+               }
+       }
+
+       /* Write back execution state to current context. */
+
+       md_executionstate_write(&es, context);
+#endif
+
+       /* Unwrap and return the exception object. */
+       /* AFTER: removing stackframeinfo */
+
+       if (type == TRAP_COMPILER)
+               return p;
+       else
+               return LLNI_UNWRAP(p);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/vm/jit/trap.h b/src/vm/jit/trap.h
deleted file mode 100644 (file)
index 6a18c35..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* src/vm/jit/trap.h - hardware traps
-
-   Copyright (C) 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#ifndef _TRAP_H
-#define _TRAP_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Include machine dependent trap stuff. */
-
-#include "md-trap.h"
-
-
-/* function prototypes ********************************************************/
-
-void  trap_init(void);
-void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xpc, void *context);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _TRAP_H */
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/vm/jit/trap.hpp b/src/vm/jit/trap.hpp
new file mode 100644 (file)
index 0000000..ce0c044
--- /dev/null
@@ -0,0 +1,66 @@
+/* src/vm/jit/trap.hpp - hardware traps
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#ifndef _TRAP_HPP
+#define _TRAP_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Include machine dependent trap stuff. */
+
+#include "md-trap.h"
+
+
+/* function prototypes ********************************************************/
+
+void  trap_init(void);
+void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xpc, void *context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _TRAP_HPP */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index 80c81af88b5c59ba9345d556d9b92f0adf58839d..0265db4591d859fb38544b217366a21eb613f8db 100644 (file)
@@ -68,7 +68,7 @@
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 #if defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
index 5f6f0d87a76fcfa7323255f0f2b4ba83246806a5..778f74916edf10cd220470cc72c64fad6243a1e0 100644 (file)
@@ -48,7 +48,7 @@
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/trace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* emit_load *******************************************************************
index 1c30b8bbf94fac72d746b7f3256e047461f258f6..ca42a1926749c1b32914fee6f36e6f4fe16db3be 100644 (file)
@@ -44,7 +44,7 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 #include "vm/jit/stacktrace.hpp"
 
 
index cce569be9344dbbb9bc937103d9c7d1e99efb58e..e9f7b838f487a55c99b1f74d78ac4864ca157c31 100644 (file)
@@ -42,7 +42,7 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 #include "vm/jit/stacktrace.hpp"
 
 
index 448e4a7e99992f0a3f506316c970979bf3ffd391..43fb31c9a402ac613579e143935f44c9c5dc6d4a 100644 (file)
 # include "vm/jit/python.h"
 #endif
 
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 #if defined(ENABLE_JVMTI)
 # include "native/jvmti/cacaodbg.h"