* src/vm/jit/jit.c: Moved to .cpp.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 21 Aug 2008 14:48:14 +0000 (16:48 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 21 Aug 2008 14:48:14 +0000 (16:48 +0200)
* src/vm/jit/jit.h: Likewise.
* src/vm/jit/jit.cpp: New file.
* src/vm/jit/jit.hpp: Likewise.
* src/native/jni.cpp,
src/native/native.c,
src/vm/builtintable.inc,
src/vm/exceptions.cpp,
src/vm/jit/Makefile.am,
src/vm/jit/abi.h,
src/vm/jit/allocator/liveness.c,
src/vm/jit/allocator/simplereg.h,
src/vm/jit/alpha/codegen.c,
src/vm/jit/alpha/codegen.h,
src/vm/jit/alpha/emit.c,
src/vm/jit/alpha/md.c,
src/vm/jit/arm/codegen.c,
src/vm/jit/arm/emit.c,
src/vm/jit/cfg.c,
src/vm/jit/cfg.h,
src/vm/jit/codegen-common.c,
src/vm/jit/codegen-common.h,
src/vm/jit/dseg.h,
src/vm/jit/emit-common.c,
src/vm/jit/emit-common.h,
src/vm/jit/exceptiontable.c,
src/vm/jit/exceptiontable.h,
src/vm/jit/i386/codegen.c,
src/vm/jit/i386/codegen.h,
src/vm/jit/i386/emit.c,
src/vm/jit/i386/md.c,
src/vm/jit/inline/inline.c,
src/vm/jit/inline/inline.h,
src/vm/jit/intrp/codegen.c,
src/vm/jit/ir/instruction.hpp,
src/vm/jit/linenumbertable.h,
src/vm/jit/loop/analyze.c,
src/vm/jit/loop/analyze.h,
src/vm/jit/loop/graph.c,
src/vm/jit/loop/loop.c,
src/vm/jit/loop/loop.h,
src/vm/jit/loop/tracing.h,
src/vm/jit/m68k/codegen.c,
src/vm/jit/mips/codegen.c,
src/vm/jit/mips/codegen.h,
src/vm/jit/mips/emit.c,
src/vm/jit/mips/md.c,
src/vm/jit/optimizing/dominators.c,
src/vm/jit/optimizing/escape.c,
src/vm/jit/optimizing/escape.h,
src/vm/jit/optimizing/graph.c,
src/vm/jit/optimizing/ifconv.c,
src/vm/jit/optimizing/ifconv.h,
src/vm/jit/optimizing/lifetimes.c,
src/vm/jit/optimizing/lsra.c,
src/vm/jit/optimizing/profile.c,
src/vm/jit/optimizing/recompile.c,
src/vm/jit/optimizing/reorder.c,
src/vm/jit/optimizing/reorder.h,
src/vm/jit/optimizing/ssa.c,
src/vm/jit/optimizing/ssa2.c,
src/vm/jit/optimizing/ssa3.c,
src/vm/jit/optimizing/ssa_phi.c,
src/vm/jit/optimizing/ssa_rename.c,
src/vm/jit/parse.c,
src/vm/jit/parse.h,
src/vm/jit/patcher-common.c,
src/vm/jit/patcher-common.h,
src/vm/jit/powerpc/codegen.c,
src/vm/jit/powerpc/codegen.h,
src/vm/jit/powerpc/emit.c,
src/vm/jit/powerpc/md.c,
src/vm/jit/powerpc64/codegen.c,
src/vm/jit/powerpc64/codegen.h,
src/vm/jit/powerpc64/emit.c,
src/vm/jit/powerpc64/md.c,
src/vm/jit/powerpc64/md.h,
src/vm/jit/python.h,
src/vm/jit/reg.h,
src/vm/jit/replace.c,
src/vm/jit/replace.h,
src/vm/jit/s390/codegen.c,
src/vm/jit/s390/codegen.h,
src/vm/jit/s390/emit.c,
src/vm/jit/s390/md-abi.c,
src/vm/jit/show.c,
src/vm/jit/show.h,
src/vm/jit/sparc64/codegen.c,
src/vm/jit/sparc64/codegen.h,
src/vm/jit/sparc64/emit.c,
src/vm/jit/sparc64/md.c,
src/vm/jit/stack.c,
src/vm/jit/stack.h,
src/vm/jit/stubs.cpp,
src/vm/jit/trap.c,
src/vm/jit/verify/typecheck-common.h,
src/vm/jit/verify/typecheck-typeinferer.c,
src/vm/jit/verify/typecheck-typeinferer.h,
src/vm/jit/verify/typecheck.c,
src/vm/jit/verify/typecheck.h,
src/vm/jit/verify/typeinfo.c,
src/vm/jit/x86_64/codegen.c,
src/vm/jit/x86_64/codegen.h,
src/vm/jit/x86_64/emit.c,
src/vm/jit/x86_64/emit.h,
src/vm/jit/x86_64/md-abi.c,
src/vm/jit/x86_64/md.c,
src/vm/loader.c,
src/vm/resolve.c,
src/vm/resolve.h,
src/vm/statistics.h,
src/vm/vm.cpp: Include changes or extern "C".

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

112 files changed:
src/native/jni.cpp
src/native/native.c
src/vm/builtintable.inc
src/vm/exceptions.cpp
src/vm/jit/Makefile.am
src/vm/jit/abi.h
src/vm/jit/allocator/liveness.c
src/vm/jit/allocator/simplereg.h
src/vm/jit/alpha/codegen.c
src/vm/jit/alpha/codegen.h
src/vm/jit/alpha/emit.c
src/vm/jit/alpha/md.c
src/vm/jit/arm/codegen.c
src/vm/jit/arm/emit.c
src/vm/jit/cfg.c
src/vm/jit/cfg.h
src/vm/jit/codegen-common.c
src/vm/jit/codegen-common.h
src/vm/jit/dseg.h
src/vm/jit/emit-common.c
src/vm/jit/emit-common.h
src/vm/jit/exceptiontable.c
src/vm/jit/exceptiontable.h
src/vm/jit/i386/codegen.c
src/vm/jit/i386/codegen.h
src/vm/jit/i386/emit.c
src/vm/jit/i386/md.c
src/vm/jit/inline/inline.c
src/vm/jit/inline/inline.h
src/vm/jit/intrp/codegen.c
src/vm/jit/ir/instruction.hpp
src/vm/jit/jit.c [deleted file]
src/vm/jit/jit.cpp [new file with mode: 0644]
src/vm/jit/jit.h [deleted file]
src/vm/jit/jit.hpp [new file with mode: 0644]
src/vm/jit/linenumbertable.h
src/vm/jit/loop/analyze.c
src/vm/jit/loop/analyze.h
src/vm/jit/loop/graph.c
src/vm/jit/loop/loop.c
src/vm/jit/loop/loop.h
src/vm/jit/loop/tracing.h
src/vm/jit/m68k/codegen.c
src/vm/jit/mips/codegen.c
src/vm/jit/mips/codegen.h
src/vm/jit/mips/emit.c
src/vm/jit/mips/md.c
src/vm/jit/optimizing/dominators.c
src/vm/jit/optimizing/escape.c
src/vm/jit/optimizing/escape.h
src/vm/jit/optimizing/graph.c
src/vm/jit/optimizing/ifconv.c
src/vm/jit/optimizing/ifconv.h
src/vm/jit/optimizing/lifetimes.c
src/vm/jit/optimizing/lsra.c
src/vm/jit/optimizing/profile.c
src/vm/jit/optimizing/recompile.c
src/vm/jit/optimizing/reorder.c
src/vm/jit/optimizing/reorder.h
src/vm/jit/optimizing/ssa.c
src/vm/jit/optimizing/ssa2.c
src/vm/jit/optimizing/ssa3.c
src/vm/jit/optimizing/ssa_phi.c
src/vm/jit/optimizing/ssa_rename.c
src/vm/jit/parse.c
src/vm/jit/parse.h
src/vm/jit/patcher-common.c
src/vm/jit/patcher-common.h
src/vm/jit/powerpc/codegen.c
src/vm/jit/powerpc/codegen.h
src/vm/jit/powerpc/emit.c
src/vm/jit/powerpc/md.c
src/vm/jit/powerpc64/codegen.c
src/vm/jit/powerpc64/codegen.h
src/vm/jit/powerpc64/emit.c
src/vm/jit/powerpc64/md.c
src/vm/jit/powerpc64/md.h
src/vm/jit/python.h
src/vm/jit/reg.h
src/vm/jit/replace.c
src/vm/jit/replace.h
src/vm/jit/s390/codegen.c
src/vm/jit/s390/codegen.h
src/vm/jit/s390/emit.c
src/vm/jit/s390/md-abi.c
src/vm/jit/show.c
src/vm/jit/show.h
src/vm/jit/sparc64/codegen.c
src/vm/jit/sparc64/codegen.h
src/vm/jit/sparc64/emit.c
src/vm/jit/sparc64/md.c
src/vm/jit/stack.c
src/vm/jit/stack.h
src/vm/jit/stubs.cpp
src/vm/jit/trap.c
src/vm/jit/verify/typecheck-common.h
src/vm/jit/verify/typecheck-typeinferer.c
src/vm/jit/verify/typecheck-typeinferer.h
src/vm/jit/verify/typecheck.c
src/vm/jit/verify/typecheck.h
src/vm/jit/verify/typeinfo.c
src/vm/jit/x86_64/codegen.c
src/vm/jit/x86_64/codegen.h
src/vm/jit/x86_64/emit.c
src/vm/jit/x86_64/emit.h
src/vm/jit/x86_64/md-abi.c
src/vm/jit/x86_64/md.c
src/vm/loader.c
src/vm/resolve.c
src/vm/resolve.h
src/vm/statistics.h
src/vm/vm.cpp

index 00b6afd8f8fcd49853d74493c61f84035ad51a7b..7789aeb62822c38549d028e044e691ddb95da054 100644 (file)
@@ -65,7 +65,7 @@
 
 #include "vm/jit/argument.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/stacktrace.hpp"
 
 
index e55452bee087e494e6fe96e6ce28e882c76fd9c9..d9cbffd71d96fcfce52b4f0fd1bc3338abee0370 100644 (file)
@@ -57,7 +57,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #if defined(ENABLE_JVMTI)
 #include "native/jvmti/cacaodbg.h"
index 3f5781fe261a27bff1c1cd70173e64ea41011157..3280f023522877f413d8ca5af066965e98830743 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "vm/builtin.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* internal and not automatically replaced functions **************************/
index c547f5486c818efd083cdb9f3b642906cbb68ce7..a8b5ddb87a98be418ca2f1f640577169d1dfbfde 100644 (file)
@@ -59,7 +59,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/show.h"
index ee480933eb62220fd2121587bb989503a9d45522..02535f30b3030784a471cc186a6704f97090e4df 100644 (file)
@@ -164,8 +164,8 @@ libjit_la_SOURCES = \
        exceptiontable.h \
        executionstate.c \
        executionstate.h \
-       jit.c \
-       jit.h \
+       jit.cpp \
+       jit.hpp \
        linenumbertable.c \
        linenumbertable.h \
        methodtree.c \
index 7a8cd9d6717cfb4d6adac69f4270d65145ec0514..2bd0e8b8b3af254500c39153d4ed046741be12eb 100644 (file)
@@ -32,7 +32,7 @@
 #include "arch.h"
 
 #include "vm/jit/abi-asm.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/stack.h"
 
 
index d6d6acc1002aef18fa983f49d241ab026391d7c2..e91ff170d99ed6b83439b3121abbdadae9af5423 100644 (file)
@@ -41,7 +41,7 @@
 #include "vm/method.h"
 #include "vm/resolve.h"
 #include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/allocator/lsra.h"
 #include "vm/jit/allocator/liveness.h"
 
index e7f2c44e7ecb38fc6f41aa2efbfbd52dc451f8bf..1e56a8225ca085bdd4ac9f2a31b5a1be2e7527c2 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/allocator/simplereg.h - register allocator header
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes: Christian Ullrich
-
 */
 
 
 #include "arch.h"
 
 #include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/inline/inline.h"
 
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool regalloc(jitdata *jd);
 
 #if defined(ENABLE_STATISTICS)
 void simplereg_make_statistics(jitdata *jd);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _SIMPLE_REG_H */
 
 
index ce26e9fa78b8ad5e839946f4ea82ceadff2d2416..341bf901c350a1ec1fc9941f31aaaaaa68732827 100644 (file)
@@ -55,7 +55,7 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.h"
index 641173bae2f1e90f2df3fe97508c2e995c54c6f9..17953240b186e95ed0f8fb61e39ec8ae4b3d7ceb 100644 (file)
@@ -30,7 +30,7 @@
 #include "config.h"
 #include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* additional functions and macros to generate code ***************************/
index 93267b78c2e6198baac85d3b20f72199876ca5c9..eae793e6ba02ea3d05aa7456e292a5d0acbecc36 100644 (file)
@@ -44,7 +44,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/trace.hpp"
index 2958813c47ee7fad1d2dbb46fce1bce23dfbd051..9ad99b7474b6f982d1c66ea557be178a04f453a7 100644 (file)
@@ -39,7 +39,7 @@ extern void ieee_set_fp_control(unsigned long fp_control);
 #include "vm/jit/alpha/md.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/trap.h"
 
 
index aa6e70d2def7d1515bee64e073b355681cdfdd12..7d9bf2fd7b9cc286b513eb807e1e73b20049d3d4 100644 (file)
@@ -54,7 +54,7 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/parse.h"
index f27c558dfc61e2bbbe2386c1570b50389054249f..847e9c38809c75eaa3f4e2a0d414314833b01fff 100644 (file)
@@ -43,7 +43,7 @@
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/trace.hpp"
index da46ee966b02b3beadb2ee23c3391c9a4e7f89dc..4772b95f2f71d984b7cb776122ff305233e7527e 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "vm/global.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/stack.h"
 
 
index a82b75ad7036f4b3a9ed619c013743f642712df8..a9d787a11a05242913f5b55c1beee45bcd0c5886 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/cfg.h - build a control-flow graph
 
-   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,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -32,7 +30,7 @@
 
 #include "vm/global.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* defines ********************************************************************/
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool cfg_build(jitdata *jd);
 
 void cfg_add_root(jitdata *jd);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _CFG_H */
 
 
index d4e27608045102988ed4d0dc3704f3efd71b8167..240bf1a78def9a7e69c4684bc237254222cf1123 100644 (file)
@@ -83,7 +83,7 @@
 
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/methodtree.h"
index 3daee60923d3ffda65e5ac43aa475bfc7cd1b344..3b27daa3b1aa866de58a5743e685d770dca2ad16 100644 (file)
@@ -47,7 +47,7 @@ typedef struct linenumberref          linenumberref;
 #include "vm/references.h"
 
 #include "vm/jit/dseg.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
 #include "vm/jit/code.h"
 #include "vm/jit/replace.h"
index c377ffd4e30a0546451c08140a99e050af75e7ad..85885e3660b9ac18ce87d518c8b69ddcdc26e02b 100644 (file)
@@ -38,7 +38,7 @@ typedef struct dsegentry dsegentry;
 
 #include "vm/references.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/codegen-common.h"
 
 
index 22422e22d381a7e8ce7e59b20c67586e40ba2756..32001deb38e1bc6d98b8f4605333aea930fae749 100644 (file)
@@ -37,7 +37,7 @@
 #include "vm/statistics.h"
 
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.h"
 
 
index 1b47d53ab3c62d5008de3ac8356be4e3d0e205c5..3fec792ab6f01a729ccaf8afb49b572f31fa1321 100644 (file)
@@ -34,7 +34,7 @@
 #include "arch.h"
 
 #include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* branch labels **************************************************************/
index 102f455149a7ace0650b50342fb1bb954cb68b73..39fafa54c1d52028eb4a86f3cb3787b5e894fd77 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "vm/jit/code.h"
 #include "vm/jit/exceptiontable.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* exceptiontable_create *******************************************************
index 903b250f26125de9c673263c0243cab151b384d9..3bd31695a3233d8462946ad9eb48d5211b2eea77 100644 (file)
@@ -37,7 +37,7 @@ typedef struct exceptiontable_entry_t exceptiontable_entry_t;
 #include <stdint.h>
 
 #include "vm/jit/code.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* exceptiontable_t ***********************************************************/
index 6138f385fd5b76ac9bedfcd26aad259f2def7b7f..4f70c2a8605c8553ca5e87a023ed1e423cab342c 100644 (file)
@@ -57,7 +57,7 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.h"
index 7a40b1b276cbeb793731909b74265b5c448f3821..2efb24532981093b2619f8ef40198b84ae0c039c 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "vm/jit/i386/emit.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 #if defined(ENABLE_LSRA)
index a23d4c0e60a1b3bd4a2f3fd702b7c5de982a8031..8d8940a3430648d2764829dee8ffe42fe507185d 100644 (file)
@@ -44,7 +44,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/trace.hpp"
index cc93cd855bcb5cbc64250d54f4c0b70144be520c..191cddabd02cdb6d88b8b99a1b62b38dd6598c02 100644 (file)
@@ -34,7 +34,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* md_init *********************************************************************
index d5108a6dfce3326d72003f8bdf0315e9aff50651..dfb63a10c455c8166f5b52f8f146d3361992dd2f 100644 (file)
@@ -47,7 +47,7 @@
 #include "vm/options.h"
 #include "vm/statistics.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/parse.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/show.h"
index cdd41ee4daeeac32ee13b8396d09673fdbb5111b..629f649a9dca2a570603b0cefb8ede76fdc63a2c 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/inline/inline.h - code inliner
 
-   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
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
 
 #include "config.h"
 
-#include "vm/global.h"
+#include <stdbool.h>
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool inline_inline(jitdata *jd);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _INLINE_H */
 
 /*
index ec35739dab3dc1bbe9d7130749748ed4789b5586..3534b5ab48c3f4289d7431161794de68b1674a4e 100644 (file)
@@ -57,7 +57,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher.h"
 #include "vm/jit/stack.h"
index e176b2ba652a9f4e8409c27a8cef5a407c237583..7beb2e2d22c72707774b40a96cf9d6b3bac89a41 100644 (file)
@@ -37,7 +37,7 @@ typedef struct insinfo_inline insinfo_inline;
 
 #include "vm/descriptor.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/replace.h"
 
 #include "vm/jit/ir/icmd.hpp"
diff --git a/src/vm/jit/jit.c b/src/vm/jit/jit.c
deleted file mode 100644 (file)
index 0b6a580..0000000
+++ /dev/null
@@ -1,1190 +0,0 @@
-/* src/vm/jit/jit.c - calls the code generation functions
-
-   Copyright (C) 1996-2005, 2006, 2007, 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 <assert.h>
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "md.h"
-
-#include "mm/memory.h"
-
-#include "native/native.h"
-
-#include "toolbox/logging.h"
-
-#include "threads/lock-common.h"
-
-#include "vm/class.h"
-#include "vm/global.h"
-#include "vm/globals.hpp"
-#include "vm/initialize.h"
-#include "vm/loader.h"
-#include "vm/method.h"
-#include "vm/options.h"
-#include "vm/rt-timing.h"
-#include "vm/statistics.h"
-
-#include "vm/jit/asmpart.h"
-
-#include "vm/jit/cfg.h"
-
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/disass.h"
-#include "vm/jit/dseg.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/parse.h"
-#include "vm/jit/reg.h"
-
-#include "vm/jit/show.h"
-#include "vm/jit/stack.h"
-#include "vm/jit/stubs.hpp"
-
-#if defined(ENABLE_OPAGENT)
-#include "vm/jit/oprofile-agent.hpp"
-#endif
-
-#include "vm/jit/allocator/simplereg.h"
-#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
-# include "vm/jit/allocator/lsra.h"
-#endif
-
-#if defined(ENABLE_SSA)
-# include "vm/jit/optimizing/lsra.h"
-# include "vm/jit/optimizing/ssa.h"
-#endif
-
-#if defined(ENABLE_INLINING)
-# include "vm/jit/inline/inline.h"
-#endif
-
-#include "vm/jit/ir/bytecode.h"
-
-#include "vm/jit/loop/analyze.h"
-#include "vm/jit/loop/graph.h"
-#include "vm/jit/loop/loop.h"
-
-#if defined(ENABLE_IFCONV)
-# include "vm/jit/optimizing/ifconv.h"
-#endif
-
-#include "vm/jit/optimizing/reorder.h"
-
-#if defined(ENABLE_PYTHON)
-# include "vm/jit/python.h"
-#endif
-
-#include "vm/jit/verify/typecheck.h"
-
-
-/* debug macros ***************************************************************/
-
-#if !defined(NDEBUG)
-#define DEBUG_JIT_COMPILEVERBOSE(x)                            \
-    do {                                                                               \
-        if (compileverbose) {                                  \
-            log_message_method(x, m);                  \
-        }                                                                              \
-    } while (0)
-#else
-#define DEBUG_JIT_COMPILEVERBOSE(x)    /* nothing */
-#endif
-
-#if !defined(NDEBUG)
-# define TRACECOMPILERCALLS()                                                          \
-       do {                                                                                                    \
-               if (opt_TraceCompilerCalls) {                                           \
-                       log_start();                                                                    \
-                       log_print("[JIT compiler started: method=");    \
-                       method_print(m);                                                                \
-                       log_print("]");                                                                 \
-                       log_finish();                                                                   \
-               }                                                                                                       \
-       } while (0)
-#else
-# define TRACECOMPILERCALLS()
-#endif
-
-
-/* jit_init ********************************************************************
-
-   Initializes the JIT subsystem.
-
-*******************************************************************************/
-
-void jit_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("jit_init");
-
-#if defined(ENABLE_JIT)
-       /* initialize stack analysis subsystem */
-
-       (void) stack_init();
-#endif
-
-       /* initialize show subsystem */
-
-#if !defined(NDEBUG)
-       (void) show_init();
-#endif
-
-       /* initialize codegen subsystem */
-
-       codegen_init();
-
-       /* initialize code subsystem */
-
-       (void) code_init();
-
-       /* Machine dependent initialization. */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               intrp_md_init();
-       else
-# endif
-               md_init();
-#else
-       intrp_md_init();
-#endif
-
-#if defined(ENABLE_OPAGENT)
-       if (opt_EnableOpagent)
-               OprofileAgent_initialize();
-#endif
-}
-
-
-/* jit_close *******************************************************************
-
-   Close the JIT subsystem.
-
-*******************************************************************************/
-
-void jit_close(void)
-{
-#if defined(ENABLE_OPAGENT)
-       if (opt_EnableOpagent)
-               OprofileAgent_close();
-#endif
-}
-
-
-/* dummy function, used when there is no JavaVM code available                */
-
-static u1 *do_nothing_function(void)
-{
-       return NULL;
-}
-
-
-/* jit_jitdata_new *************************************************************
-
-   Allocates and initalizes a new jitdata structure.
-
-*******************************************************************************/
-
-jitdata *jit_jitdata_new(methodinfo *m)
-{
-       jitdata  *jd;
-       codeinfo *code;
-
-       /* allocate jitdata structure and fill it */
-
-       jd = DNEW(jitdata);
-
-       jd->m     = m;
-       jd->cd    = DNEW(codegendata);
-       jd->rd    = DNEW(registerdata);
-#if defined(ENABLE_LOOP)
-       jd->ld    = DNEW(loopdata);
-#endif
-
-       /* Allocate codeinfo memory from the heap as we need to keep them. */
-
-       code = code_codeinfo_new(m);
-
-       /* Set codeinfo flags. */
-
-#if defined(ENABLE_THREADS)
-       if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               code_flag_synchronized(code);
-
-       if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               code_unflag_leafmethod(code);
-       else
-#endif
-               code_flag_leafmethod(code);
-
-       /* initialize variables */
-
-       jd->code                 = code;
-       jd->flags                = 0;
-       jd->exceptiontable       = NULL;
-       jd->exceptiontablelength = 0;
-       jd->returncount          = 0;
-       jd->branchtoentry        = false;
-       jd->branchtoend          = false;
-       jd->returncount          = 0;
-       jd->returnblock          = NULL;
-       jd->maxlocals            = m->maxlocals;
-
-       return jd;
-}
-
-
-/* jit_compile *****************************************************************
-
-   Translates one method to machine code.
-
-*******************************************************************************/
-
-static u1 *jit_compile_intern(jitdata *jd);
-
-u1 *jit_compile(methodinfo *m)
-{
-       u1      *r;
-       jitdata *jd;
-       int32_t  dumpmarker;
-
-       STATISTICS(count_jit_calls++);
-
-       /* Initialize the static function's class. */
-
-       /* ATTENTION: This MUST be done before the method lock is aquired,
-          otherwise we could run into a deadlock with <clinit>'s that
-          call static methods of it's own class. */
-
-       if ((m->flags & ACC_STATIC) && !(m->clazz->state & CLASS_INITIALIZED)) {
-#if !defined(NDEBUG)
-               if (initverbose)
-                       log_message_class("Initialize class ", m->clazz);
-#endif
-
-               if (!initialize_class(m->clazz))
-                       return NULL;
-
-               /* check if the method has been compiled during initialization */
-
-               if ((m->code != NULL) && (m->code->entrypoint != NULL))
-                       return m->code->entrypoint;
-       }
-
-       /* enter a monitor on the method */
-
-       LOCK_MONITOR_ENTER(m);
-
-       /* if method has been already compiled return immediately */
-
-       if (m->code != NULL) {
-               LOCK_MONITOR_EXIT(m);
-
-               assert(m->code->entrypoint);
-               return m->code->entrypoint;
-       }
-
-       TRACECOMPILERCALLS();
-
-       STATISTICS(count_methods++);
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getcompilingtime)
-               compilingtime_start();
-#endif
-
-       /* mark start of dump memory area */
-
-       DMARKER;
-
-       /* create jitdata structure */
-
-       jd = jit_jitdata_new(m);
-
-       /* set the flags for the current JIT run */
-
-       jd->flags = JITDATA_FLAG_PARSE;
-
-#if defined(ENABLE_VERIFIER)
-       if (opt_verify)
-               jd->flags |= JITDATA_FLAG_VERIFY;
-#endif
-
-#if defined(ENABLE_PROFILING)
-       if (opt_prof)
-               jd->flags |= JITDATA_FLAG_INSTRUMENT;
-#endif
-
-#if defined(ENABLE_IFCONV)
-       if (opt_ifconv)
-               jd->flags |= JITDATA_FLAG_IFCONV;
-#endif
-
-#if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG)
-       if (opt_Inline && opt_InlineAll)
-               jd->flags |= JITDATA_FLAG_INLINE;
-#endif
-
-       if (opt_showintermediate)
-               jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
-
-       if (opt_showdisassemble)
-               jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
-
-       if (opt_verbosecall)
-               jd->flags |= JITDATA_FLAG_VERBOSECALL;
-
-#if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING)
-       if (opt_Inline && (jd->m->hitcountdown > 0) && (jd->code->optlevel == 0)) {
-               jd->flags |= JITDATA_FLAG_COUNTDOWN;
-       }
-#endif
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (!opt_intrp)
-# endif
-               /* initialize the register allocator */
-       {
-               reg_setup(jd);
-       }
-#endif
-
-       /* setup the codegendata memory */
-
-       codegen_setup(jd);
-
-       /* now call internal compile function */
-
-       r = jit_compile_intern(jd);
-
-       if (r == NULL) {
-               /* We had an exception! Finish stuff here if necessary. */
-
-               /* release codeinfo */
-
-               code_codeinfo_free(jd->code);
-
-#if defined(ENABLE_PROFILING)
-               /* Release memory for basic block profiling information. */
-
-               if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
-                       if (jd->code->bbfrequency != NULL)
-                               MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount);
-#endif
-       }
-       else {
-               DEBUG_JIT_COMPILEVERBOSE("Running: ");
-       }
-
-       /* release dump area */
-
-       DRELEASE;
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getcompilingtime)
-               compilingtime_stop();
-#endif
-
-#if defined(ENABLE_OPAGENT)
-       if (opt_EnableOpagent)
-               OprofileAgent_newmethod(m);
-#endif
-
-       /* leave the monitor */
-
-       LOCK_MONITOR_EXIT(m);
-
-       /* return pointer to the methods entry point */
-
-       return r;
-}
-
-
-/* jit_recompile ***************************************************************
-
-   Recompiles a Java method.
-
-*******************************************************************************/
-
-u1 *jit_recompile(methodinfo *m)
-{
-       u1      *r;
-       jitdata *jd;
-       u1       optlevel;
-       int32_t  dumpmarker;
-
-       /* check for max. optimization level */
-
-       optlevel = (m->code) ? m->code->optlevel : 0;
-
-#if 0
-       if (optlevel == 1) {
-/*             log_message_method("not recompiling: ", m); */
-               return NULL;
-       }
-#endif
-
-       DEBUG_JIT_COMPILEVERBOSE("Recompiling start: ");
-
-       STATISTICS(count_jit_calls++);
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getcompilingtime)
-               compilingtime_start();
-#endif
-
-       /* mark start of dump memory area */
-
-       DMARKER;
-
-       /* create jitdata structure */
-
-       jd = jit_jitdata_new(m);
-
-       /* set the current optimization level to the previous one plus 1 */
-
-       jd->code->optlevel = optlevel + 1;
-
-       /* get the optimization flags for the current JIT run */
-
-#if defined(ENABLE_VERIFIER)
-       jd->flags |= JITDATA_FLAG_VERIFY;
-#endif
-
-       /* jd->flags |= JITDATA_FLAG_REORDER; */
-       if (opt_showintermediate)
-               jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
-       if (opt_showdisassemble)
-               jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
-       if (opt_verbosecall)
-               jd->flags |= JITDATA_FLAG_VERBOSECALL;
-
-#if defined(ENABLE_INLINING)
-       if (opt_Inline)
-               jd->flags |= JITDATA_FLAG_INLINE;
-#endif
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (!opt_intrp)
-# endif
-               /* initialize the register allocator */
-
-               reg_setup(jd);
-#endif
-
-       /* setup the codegendata memory */
-
-       codegen_setup(jd);
-
-       /* now call internal compile function */
-
-       r = jit_compile_intern(jd);
-
-       if (r == NULL) {
-               /* We had an exception! Finish stuff here if necessary. */
-
-               /* release codeinfo */
-
-               code_codeinfo_free(jd->code);
-       }
-
-       /* release dump area */
-
-       DRELEASE;
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getcompilingtime)
-               compilingtime_stop();
-#endif
-
-#if defined(ENABLE_OPAGENT)
-       if (opt_EnableOpagent)
-               OprofileAgent_newmethod(m);
-#endif
-
-       DEBUG_JIT_COMPILEVERBOSE("Recompiling done: ");
-
-       /* return pointer to the methods entry point */
-
-       return r;
-}
-
-#if defined(ENABLE_PM_HACKS)
-#include "vm/jit/jit_pm_1.inc"
-#endif
-
-/* jit_compile_intern **********************************************************
-
-   Static internal function which does the actual compilation.
-
-*******************************************************************************/
-
-static u1 *jit_compile_intern(jitdata *jd)
-{
-       methodinfo  *m;
-       codegendata *cd;
-       codeinfo    *code;
-
-#if defined(ENABLE_RT_TIMING)
-       struct timespec time_start,time_checks,time_parse,time_stack,
-                                       time_typecheck,time_loop,time_ifconv,time_alloc,
-                                       time_codegen;
-#endif
-       
-       RT_TIMING_GET_TIME(time_start);
-
-       /* get required compiler data */
-
-#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
-       jd->ls = NULL;
-#endif
-       m    = jd->m;
-       code = jd->code;
-       cd   = jd->cd;
-       
-#if defined(ENABLE_DEBUG_FILTER)
-       show_filters_apply(jd->m);
-#endif
-
-       /* Handle native methods and create a native stub. */
-
-       if (m->flags & ACC_NATIVE) {
-               functionptr f;
-
-               f = native_method_resolve(m);
-
-               if (f == NULL)
-                       return NULL;
-
-               code = NativeStub_generate(m, f);
-
-               /* Native methods are never recompiled. */
-               
-               assert(!m->code);
-
-               m->code = code;
-               
-               return code->entrypoint;
-       }
-
-       /* if there is no javacode, print error message and return empty method   */
-
-       if (m->jcode == NULL) {
-               DEBUG_JIT_COMPILEVERBOSE("No code given for: ");
-
-               code->entrypoint = (u1 *) (ptrint) do_nothing_function;
-               m->code = code;
-
-               return code->entrypoint;        /* return empty method                */
-       }
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat) {
-               count_javacodesize += m->jcodelength + 18;
-               count_tryblocks    += jd->exceptiontablelength;
-               count_javaexcsize  += jd->exceptiontablelength * SIZEOF_VOID_P;
-       }
-#endif
-
-       RT_TIMING_GET_TIME(time_checks);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-       /* Code for Sun's OpenJDK (see
-          hotspot/src/share/vm/classfile/verifier.cpp
-          (Verifier::is_eligible_for_verification)): Don't verify
-          dynamically-generated bytecodes. */
-
-# if defined(ENABLE_VERIFIER)
-       if (class_issubclass(m->clazz, class_sun_reflect_MagicAccessorImpl))
-               jd->flags &= ~JITDATA_FLAG_VERIFY;
-# endif
-#endif
-
-       /* call the compiler passes ***********************************************/
-
-       DEBUG_JIT_COMPILEVERBOSE("Parsing: ");
-
-       /* call parse pass */
-
-       if (!parse(jd)) {
-               DEBUG_JIT_COMPILEVERBOSE("Exception while parsing: ");
-
-               return NULL;
-       }
-       RT_TIMING_GET_TIME(time_parse);
-
-       DEBUG_JIT_COMPILEVERBOSE("Parsing done: ");
-       
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (!opt_intrp) {
-# endif
-               DEBUG_JIT_COMPILEVERBOSE("Analysing: ");
-
-               /* call stack analysis pass */
-
-               if (!stack_analyse(jd)) {
-                       DEBUG_JIT_COMPILEVERBOSE("Exception while analysing: ");
-
-                       return NULL;
-               }
-               RT_TIMING_GET_TIME(time_stack);
-
-               DEBUG_JIT_COMPILEVERBOSE("Analysing done: ");
-
-#ifdef ENABLE_VERIFIER
-               if (JITDATA_HAS_FLAG_VERIFY(jd)) {
-                       DEBUG_JIT_COMPILEVERBOSE("Typechecking: ");
-
-                       /* call typecheck pass */
-                       if (!typecheck(jd)) {
-                               DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: ");
-
-                               return NULL;
-                       }
-
-                       DEBUG_JIT_COMPILEVERBOSE("Typechecking done: ");
-               }
-#endif
-               RT_TIMING_GET_TIME(time_typecheck);
-
-#if defined(ENABLE_LOOP)
-               if (opt_loops) {
-                       depthFirst(jd);
-                       analyseGraph(jd);
-                       optimize_loops(jd);
-                       jit_renumber_basicblocks(jd);
-               }
-#endif
-               RT_TIMING_GET_TIME(time_loop);
-
-#if defined(ENABLE_IFCONV)
-               if (JITDATA_HAS_FLAG_IFCONV(jd)) {
-                       if (!ifconv_static(jd))
-                               return NULL;
-                       jit_renumber_basicblocks(jd);
-               }
-#endif
-               RT_TIMING_GET_TIME(time_ifconv);
-
-               /* inlining */
-
-#if defined(ENABLE_INLINING) && (!defined(ENABLE_ESCAPE) || 1)
-               if (JITDATA_HAS_FLAG_INLINE(jd)) {
-                       if (!inline_inline(jd))
-                               return NULL;
-               }
-#endif
-
-#if defined(ENABLE_SSA)
-               if (opt_lsra) {
-                       fix_exception_handlers(jd);
-               }
-#endif
-
-               /* Build the CFG.  This has to be done after stack_analyse, as
-                  there happens the JSR elimination. */
-
-               if (!cfg_build(jd))
-                       return NULL;
-
-#if defined(ENABLE_PROFILING)
-               /* Basic block reordering.  I think this should be done after
-                  if-conversion, as we could lose the ability to do the
-                  if-conversion. */
-
-               if (JITDATA_HAS_FLAG_REORDER(jd)) {
-                       if (!reorder(jd))
-                               return NULL;
-                       jit_renumber_basicblocks(jd);
-               }
-#endif
-
-#if defined(ENABLE_PM_HACKS)
-#include "vm/jit/jit_pm_2.inc"
-#endif
-               DEBUG_JIT_COMPILEVERBOSE("Allocating registers: ");
-
-#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
-               /* allocate registers */
-               if (opt_lsra) {
-                       if (!lsra(jd))
-                               return NULL;
-
-                       STATISTICS(count_methods_allocated_by_lsra++);
-
-               } else
-# endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */
-#if defined(ENABLE_SSA)
-               /* allocate registers */
-               if (
-                       (opt_lsra &&
-                       jd->code->optlevel > 0) 
-                       /* strncmp(jd->m->name->text, "hottie", 6) == 0*/
-                       /*&& jd->exceptiontablelength == 0*/
-               ) {
-                       /*printf("=== %s ===\n", jd->m->name->text);*/
-                       jd->ls = DNEW(lsradata);
-                       jd->ls = NULL;
-                       ssa(jd);
-                       /*lsra(jd);*/ regalloc(jd);
-                       /*eliminate_subbasicblocks(jd);*/
-                       STATISTICS(count_methods_allocated_by_lsra++);
-
-               } else
-# endif /* defined(ENABLE_SSA) */
-               {
-                       STATISTICS(count_locals_conflicts += (jd->maxlocals - 1) * (jd->maxlocals));
-
-                       regalloc(jd);
-               }
-
-               STATISTICS(simplereg_make_statistics(jd));
-
-               DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: ");
-# if defined(ENABLE_INTRP)
-       }
-# endif
-#endif /* defined(ENABLE_JIT) */
-       RT_TIMING_GET_TIME(time_alloc);
-
-#if defined(ENABLE_PROFILING)
-       /* Allocate memory for basic block profiling information. This
-          _must_ be done after loop optimization and register allocation,
-          since they can change the basic block count. */
-
-       if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
-               code->bbfrequency = MNEW(u4, jd->basicblockcount);
-#endif
-
-       DEBUG_JIT_COMPILEVERBOSE("Generating code: ");
-
-       /* now generate the machine code */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp) {
-#if defined(ENABLE_VERIFIER)
-               if (opt_verify) {
-                       DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): ");
-
-                       if (!typecheck_stackbased(jd)) {
-                               DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): ");
-                               return NULL;
-                       }
-               }
-#endif
-               if (!intrp_codegen(jd)) {
-                       DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
-
-                       return NULL;
-               }
-       } else
-# endif
-               {
-                       if (!codegen_generate(jd)) {
-                               DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
-
-                               return NULL;
-                       }
-               }
-#else
-       if (!intrp_codegen(jd)) {
-               DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
-
-               return NULL;
-       }
-#endif
-       RT_TIMING_GET_TIME(time_codegen);
-
-       DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
-
-#if !defined(NDEBUG) && defined(ENABLE_REPLACEMENT)
-       /* activate replacement points inside newly created code */
-
-       if (opt_TestReplacement)
-               replace_activate_replacement_points(code, false);
-#endif
-
-#if !defined(NDEBUG)
-#if defined(ENABLE_DEBUG_FILTER)
-       if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
-#endif
-       {
-               /* intermediate and assembly code listings */
-               
-               if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
-                       show_method(jd, SHOW_CODE);
-               }
-               else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
-# if defined(ENABLE_DISASSEMBLER)
-                       DISASSEMBLE(code->entrypoint,
-                                               code->entrypoint + (code->mcodelength - cd->dseglen));
-# endif
-               }
-
-               if (opt_showddatasegment)
-                       dseg_display(jd);
-       }
-#endif
-
-       /* switch to the newly generated code */
-
-       assert(code);
-       assert(code->entrypoint);
-
-       /* add the current compile version to the methodinfo */
-
-       code->prev = m->code;
-       m->code = code;
-
-       RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS);
-       RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE);
-       RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK);
-       RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK);
-       RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP);
-       RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC);
-       RT_TIMING_TIME_DIFF(time_alloc,time_codegen,RT_TIMING_JIT_CODEGEN);
-       RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL);
-
-       /* return pointer to the methods entry point */
-
-       return code->entrypoint;
-} 
-
-
-/* jit_invalidate_code *********************************************************
-
-   Mark the compiled code of the given method as invalid and take care that
-   it is replaced if necessary.
-
-   XXX Not fully implemented, yet.
-
-*******************************************************************************/
-
-void jit_invalidate_code(methodinfo *m)
-{
-       codeinfo *code;
-
-       code = m->code;
-
-       if (code == NULL || code_is_invalid(code))
-               return;
-
-       code_flag_invalid(code);
-
-       /* activate mappable replacement points */
-
-#if defined(ENABLE_REPLACEMENT)
-       replace_activate_replacement_points(code, true);
-#else
-       vm_abort("invalidating code only works with ENABLE_REPLACEMENT");
-#endif
-}
-
-
-/* jit_request_optimization ****************************************************
-
-   Request optimization of the given method. If the code of the method is
-   unoptimized, it will be invalidated, so the next jit_get_current_code(m)
-   triggers an optimized recompilation.
-   If the method is already optimized, this function does nothing.
-
-   IN:
-       m................the method
-
-*******************************************************************************/
-
-void jit_request_optimization(methodinfo *m)
-{
-       codeinfo *code;
-
-       code = m->code;
-
-       if (code && code->optlevel == 0)
-               jit_invalidate_code(m);
-}
-
-
-/* jit_get_current_code ********************************************************
-
-   Get the currently valid code for the given method. If there is no valid
-   code, (re)compile the method.
-
-   IN:
-       m................the method
-
-   RETURN VALUE:
-       the codeinfo* for the current code, or
-          NULL if an exception has been thrown during recompilation.
-
-*******************************************************************************/
-
-codeinfo *jit_get_current_code(methodinfo *m)
-{
-       assert(m);
-
-       /* if we have valid code, return it */
-
-       if (m->code && !code_is_invalid(m->code))
-               return m->code;
-
-       /* otherwise: recompile */
-
-       if (!jit_recompile(m))
-               return NULL;
-
-       assert(m->code);
-
-       return m->code;
-}
-
-
-/* jit_asm_compile *************************************************************
-
-   This method is called from asm_vm_call_method and does:
-
-     - create stackframe info for exceptions
-     - compile the method
-     - patch the entrypoint of the method into the calculated address in
-       the JIT code
-     - flushes the instruction cache.
-
-*******************************************************************************/
-
-#if defined(ENABLE_JIT)
-#if !defined(JIT_COMPILER_VIA_SIGNAL)
-u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra)
-{
-       stackframeinfo_t  sfi;
-       u1               *entrypoint;
-       u1               *pa;
-       ptrint           *p;
-
-       /* create the stackframeinfo (subtract 1 from RA as it points to the */
-       /* instruction after the call)                                       */
-
-       stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra-1);
-
-       /* actually compile the method */
-
-       entrypoint = jit_compile(m);
-
-       /* remove the stackframeinfo */
-
-       stacktrace_stackframeinfo_remove(&sfi);
-
-       /* there was a problem during compilation */
-
-       if (entrypoint == NULL)
-               return NULL;
-
-       /* get the method patch address */
-
-       pa = md_jit_method_patch_address(sfi.pv, (void *) ra, mptr);
-
-       /* patch the method entry point */
-
-       p = (ptrint *) pa;
-
-       *p = (ptrint) entrypoint;
-
-       /* flush the instruction cache */
-
-       md_icacheflush(pa, SIZEOF_VOID_P);
-
-       return entrypoint;
-}
-#endif
-
-/* jit_compile_handle **********************************************************
-
-   This method is called from the appropriate signal handler which
-   handles compiler-traps and does the following:
-
-     - compile the method
-     - patch the entrypoint of the method into the calculated address in
-       the JIT code
-     - flush the instruction cache
-
-*******************************************************************************/
-
-void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
-{
-       void      *newpv;                               /* new compiled method PV */
-       void      *pa;                                           /* patch address */
-       uintptr_t *p;                                      /* convenience pointer */
-
-       /* Compile the method. */
-
-       newpv = jit_compile(m);
-
-       /* There was a problem during compilation. */
-
-       if (newpv == NULL)
-               return NULL;
-
-       /* Get the method patch address. */
-
-       pa = md_jit_method_patch_address(pv, ra, mptr);
-
-       /* Patch the method entry point. */
-
-       p = (uintptr_t *) pa;
-
-       *p = (uintptr_t) newpv;
-
-       /* Flush both caches. */
-
-       md_cacheflush(pa, SIZEOF_VOID_P);
-
-       return newpv;
-}
-#endif /* defined(ENABLE_JIT) */
-
-
-/* jit_complement_condition ****************************************************
-
-   Returns the complement of the passed conditional instruction.
-
-   We use the order of the different conditions, e.g.:
-
-   ICMD_IFEQ         153
-   ICMD_IFNE         154
-
-   If the passed opcode is odd, we simply add 1 to get the complement.
-   If the opcode is even, we subtract 1.
-
-   Exception:
-
-   ICMD_IFNULL       198
-   ICMD_IFNONNULL    199
-
-*******************************************************************************/
-
-s4 jit_complement_condition(s4 opcode)
-{
-       switch (opcode) {
-       case ICMD_IFNULL:
-               return ICMD_IFNONNULL;
-
-       case ICMD_IFNONNULL:
-               return ICMD_IFNULL;
-
-       default:
-               /* check if opcode is odd */
-
-               if (opcode & 0x1)
-                       return opcode + 1;
-               else
-                       return opcode - 1;
-       }
-}
-
-
-/* jit_renumber_basicblocks ****************************************************
-
-   Set the ->nr of all blocks so it increases when traversing ->next.
-
-   IN:
-       jitdata..........the current jitdata
-
-*******************************************************************************/
-
-void jit_renumber_basicblocks(jitdata *jd)
-{
-       s4          nr;
-       basicblock *bptr;
-
-       nr = 0;
-       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
-               bptr->nr = nr++;
-       }
-
-       /* we have one block more than jd->basicblockcount (the end marker) */
-
-       assert(nr == jd->basicblockcount + 1);
-}
-
-
-/* jit_check_basicblock_numbers ************************************************
-
-   Assert that the ->nr of the first block is zero and increases by 1 each
-   time ->next is traversed.
-   This function should be called before any analysis that relies on
-   the basicblock numbers.
-
-   IN:
-       jitdata..........the current jitdata
-
-   NOTE: Aborts with an assertion if the condition is not met!
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void jit_check_basicblock_numbers(jitdata *jd)
-{
-       s4          nr;
-       basicblock *bptr;
-
-       nr = 0;
-       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
-               assert(bptr->nr == nr);
-               nr++;
-       }
-
-       /* we have one block more than jd->basicblockcount (the end marker) */
-
-       assert(nr == jd->basicblockcount + 1);
-}
-#endif /* !defined(NDEBUG) */
-
-
-/*
- * 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/jit.cpp b/src/vm/jit/jit.cpp
new file mode 100644 (file)
index 0000000..8d476a0
--- /dev/null
@@ -0,0 +1,1190 @@
+/* src/vm/jit/jit.cpp - Just-In-Time compiler
+
+   Copyright (C) 1996-2005, 2006, 2007, 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 <assert.h>
+#include <stdint.h>
+
+#include "vm/types.h"
+
+#include "md.h"
+
+#include "mm/memory.h"
+
+#include "native/native.h"
+
+#include "toolbox/logging.h"
+
+#include "threads/lock-common.h"
+
+#include "vm/class.h"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+#include "vm/initialize.h"
+#include "vm/loader.h"
+#include "vm/method.h"
+#include "vm/options.h"
+#include "vm/rt-timing.h"
+#include "vm/statistics.h"
+
+#include "vm/jit/asmpart.h"
+
+#include "vm/jit/cfg.h"
+
+#include "vm/jit/codegen-common.h"
+#include "vm/jit/disass.h"
+#include "vm/jit/dseg.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/parse.h"
+#include "vm/jit/reg.h"
+
+#include "vm/jit/show.h"
+#include "vm/jit/stack.h"
+#include "vm/jit/stubs.hpp"
+
+#if defined(ENABLE_OPAGENT)
+#include "vm/jit/oprofile-agent.hpp"
+#endif
+
+#include "vm/jit/allocator/simplereg.h"
+#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
+# include "vm/jit/allocator/lsra.h"
+#endif
+
+#if defined(ENABLE_SSA)
+# include "vm/jit/optimizing/lsra.h"
+# include "vm/jit/optimizing/ssa.h"
+#endif
+
+#if defined(ENABLE_INLINING)
+# include "vm/jit/inline/inline.h"
+#endif
+
+#include "vm/jit/ir/bytecode.h"
+
+#include "vm/jit/loop/analyze.h"
+#include "vm/jit/loop/graph.h"
+#include "vm/jit/loop/loop.h"
+
+#if defined(ENABLE_IFCONV)
+# include "vm/jit/optimizing/ifconv.h"
+#endif
+
+#include "vm/jit/optimizing/reorder.h"
+
+#if defined(ENABLE_PYTHON)
+# include "vm/jit/python.h"
+#endif
+
+#include "vm/jit/verify/typecheck.h"
+
+
+/* debug macros ***************************************************************/
+
+#if !defined(NDEBUG)
+#define DEBUG_JIT_COMPILEVERBOSE(x)                            \
+    do {                                                                               \
+        if (compileverbose) {                                  \
+            log_message_method(x, m);                  \
+        }                                                                              \
+    } while (0)
+#else
+#define DEBUG_JIT_COMPILEVERBOSE(x)    /* nothing */
+#endif
+
+#if !defined(NDEBUG)
+# define TRACECOMPILERCALLS()                                                          \
+       do {                                                                                                    \
+               if (opt_TraceCompilerCalls) {                                           \
+                       log_start();                                                                    \
+                       log_print("[JIT compiler started: method=");    \
+                       method_print(m);                                                                \
+                       log_print("]");                                                                 \
+                       log_finish();                                                                   \
+               }                                                                                                       \
+       } while (0)
+#else
+# define TRACECOMPILERCALLS()
+#endif
+
+
+/* jit_init ********************************************************************
+
+   Initializes the JIT subsystem.
+
+*******************************************************************************/
+
+void jit_init(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("jit_init");
+
+#if defined(ENABLE_JIT)
+       /* initialize stack analysis subsystem */
+
+       (void) stack_init();
+#endif
+
+       /* initialize show subsystem */
+
+#if !defined(NDEBUG)
+       (void) show_init();
+#endif
+
+       /* initialize codegen subsystem */
+
+       codegen_init();
+
+       /* initialize code subsystem */
+
+       (void) code_init();
+
+       /* Machine dependent initialization. */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               intrp_md_init();
+       else
+# endif
+               md_init();
+#else
+       intrp_md_init();
+#endif
+
+#if defined(ENABLE_OPAGENT)
+       if (opt_EnableOpagent)
+               OprofileAgent_initialize();
+#endif
+}
+
+
+/* jit_close *******************************************************************
+
+   Close the JIT subsystem.
+
+*******************************************************************************/
+
+void jit_close(void)
+{
+#if defined(ENABLE_OPAGENT)
+       if (opt_EnableOpagent)
+               OprofileAgent_close();
+#endif
+}
+
+
+/* dummy function, used when there is no JavaVM code available                */
+
+static u1 *do_nothing_function(void)
+{
+       return NULL;
+}
+
+
+/* jit_jitdata_new *************************************************************
+
+   Allocates and initalizes a new jitdata structure.
+
+*******************************************************************************/
+
+jitdata *jit_jitdata_new(methodinfo *m)
+{
+       jitdata  *jd;
+       codeinfo *code;
+
+       /* allocate jitdata structure and fill it */
+
+       jd = DNEW(jitdata);
+
+       jd->m     = m;
+       jd->cd    = DNEW(codegendata);
+       jd->rd    = DNEW(registerdata);
+#if defined(ENABLE_LOOP)
+       jd->ld    = DNEW(loopdata);
+#endif
+
+       /* Allocate codeinfo memory from the heap as we need to keep them. */
+
+       code = code_codeinfo_new(m);
+
+       /* Set codeinfo flags. */
+
+#if defined(ENABLE_THREADS)
+       if (checksync && (m->flags & ACC_SYNCHRONIZED))
+               code_flag_synchronized(code);
+
+       if (checksync && (m->flags & ACC_SYNCHRONIZED))
+               code_unflag_leafmethod(code);
+       else
+#endif
+               code_flag_leafmethod(code);
+
+       /* initialize variables */
+
+       jd->code                 = code;
+       jd->flags                = 0;
+       jd->exceptiontable       = NULL;
+       jd->exceptiontablelength = 0;
+       jd->returncount          = 0;
+       jd->branchtoentry        = false;
+       jd->branchtoend          = false;
+       jd->returncount          = 0;
+       jd->returnblock          = NULL;
+       jd->maxlocals            = m->maxlocals;
+
+       return jd;
+}
+
+
+/* jit_compile *****************************************************************
+
+   Translates one method to machine code.
+
+*******************************************************************************/
+
+static u1 *jit_compile_intern(jitdata *jd);
+
+u1 *jit_compile(methodinfo *m)
+{
+       u1      *r;
+       jitdata *jd;
+       int32_t  dumpmarker;
+
+       STATISTICS(count_jit_calls++);
+
+       /* Initialize the static function's class. */
+
+       /* ATTENTION: This MUST be done before the method lock is aquired,
+          otherwise we could run into a deadlock with <clinit>'s that
+          call static methods of it's own class. */
+
+       if ((m->flags & ACC_STATIC) && !(m->clazz->state & CLASS_INITIALIZED)) {
+#if !defined(NDEBUG)
+               if (initverbose)
+                       log_message_class("Initialize class ", m->clazz);
+#endif
+
+               if (!initialize_class(m->clazz))
+                       return NULL;
+
+               /* check if the method has been compiled during initialization */
+
+               if ((m->code != NULL) && (m->code->entrypoint != NULL))
+                       return m->code->entrypoint;
+       }
+
+       /* enter a monitor on the method */
+
+       LOCK_MONITOR_ENTER(m);
+
+       /* if method has been already compiled return immediately */
+
+       if (m->code != NULL) {
+               LOCK_MONITOR_EXIT(m);
+
+               assert(m->code->entrypoint);
+               return m->code->entrypoint;
+       }
+
+       TRACECOMPILERCALLS();
+
+       STATISTICS(count_methods++);
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getcompilingtime)
+               compilingtime_start();
+#endif
+
+       /* mark start of dump memory area */
+
+       DMARKER;
+
+       /* create jitdata structure */
+
+       jd = jit_jitdata_new(m);
+
+       /* set the flags for the current JIT run */
+
+       jd->flags = JITDATA_FLAG_PARSE;
+
+#if defined(ENABLE_VERIFIER)
+       if (opt_verify)
+               jd->flags |= JITDATA_FLAG_VERIFY;
+#endif
+
+#if defined(ENABLE_PROFILING)
+       if (opt_prof)
+               jd->flags |= JITDATA_FLAG_INSTRUMENT;
+#endif
+
+#if defined(ENABLE_IFCONV)
+       if (opt_ifconv)
+               jd->flags |= JITDATA_FLAG_IFCONV;
+#endif
+
+#if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG)
+       if (opt_Inline && opt_InlineAll)
+               jd->flags |= JITDATA_FLAG_INLINE;
+#endif
+
+       if (opt_showintermediate)
+               jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
+
+       if (opt_showdisassemble)
+               jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
+
+       if (opt_verbosecall)
+               jd->flags |= JITDATA_FLAG_VERBOSECALL;
+
+#if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING)
+       if (opt_Inline && (jd->m->hitcountdown > 0) && (jd->code->optlevel == 0)) {
+               jd->flags |= JITDATA_FLAG_COUNTDOWN;
+       }
+#endif
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (!opt_intrp)
+# endif
+               /* initialize the register allocator */
+       {
+               reg_setup(jd);
+       }
+#endif
+
+       /* setup the codegendata memory */
+
+       codegen_setup(jd);
+
+       /* now call internal compile function */
+
+       r = jit_compile_intern(jd);
+
+       if (r == NULL) {
+               /* We had an exception! Finish stuff here if necessary. */
+
+               /* release codeinfo */
+
+               code_codeinfo_free(jd->code);
+
+#if defined(ENABLE_PROFILING)
+               /* Release memory for basic block profiling information. */
+
+               if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
+                       if (jd->code->bbfrequency != NULL)
+                               MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount);
+#endif
+       }
+       else {
+               DEBUG_JIT_COMPILEVERBOSE("Running: ");
+       }
+
+       /* release dump area */
+
+       DRELEASE;
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getcompilingtime)
+               compilingtime_stop();
+#endif
+
+#if defined(ENABLE_OPAGENT)
+       if (opt_EnableOpagent)
+               OprofileAgent_newmethod(m);
+#endif
+
+       /* leave the monitor */
+
+       LOCK_MONITOR_EXIT(m);
+
+       /* return pointer to the methods entry point */
+
+       return r;
+}
+
+
+/* jit_recompile ***************************************************************
+
+   Recompiles a Java method.
+
+*******************************************************************************/
+
+u1 *jit_recompile(methodinfo *m)
+{
+       u1      *r;
+       jitdata *jd;
+       u1       optlevel;
+       int32_t  dumpmarker;
+
+       /* check for max. optimization level */
+
+       optlevel = (m->code) ? m->code->optlevel : 0;
+
+#if 0
+       if (optlevel == 1) {
+/*             log_message_method("not recompiling: ", m); */
+               return NULL;
+       }
+#endif
+
+       DEBUG_JIT_COMPILEVERBOSE("Recompiling start: ");
+
+       STATISTICS(count_jit_calls++);
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getcompilingtime)
+               compilingtime_start();
+#endif
+
+       /* mark start of dump memory area */
+
+       DMARKER;
+
+       /* create jitdata structure */
+
+       jd = jit_jitdata_new(m);
+
+       /* set the current optimization level to the previous one plus 1 */
+
+       jd->code->optlevel = optlevel + 1;
+
+       /* get the optimization flags for the current JIT run */
+
+#if defined(ENABLE_VERIFIER)
+       jd->flags |= JITDATA_FLAG_VERIFY;
+#endif
+
+       /* jd->flags |= JITDATA_FLAG_REORDER; */
+       if (opt_showintermediate)
+               jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
+       if (opt_showdisassemble)
+               jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
+       if (opt_verbosecall)
+               jd->flags |= JITDATA_FLAG_VERBOSECALL;
+
+#if defined(ENABLE_INLINING)
+       if (opt_Inline)
+               jd->flags |= JITDATA_FLAG_INLINE;
+#endif
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (!opt_intrp)
+# endif
+               /* initialize the register allocator */
+
+               reg_setup(jd);
+#endif
+
+       /* setup the codegendata memory */
+
+       codegen_setup(jd);
+
+       /* now call internal compile function */
+
+       r = jit_compile_intern(jd);
+
+       if (r == NULL) {
+               /* We had an exception! Finish stuff here if necessary. */
+
+               /* release codeinfo */
+
+               code_codeinfo_free(jd->code);
+       }
+
+       /* release dump area */
+
+       DRELEASE;
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getcompilingtime)
+               compilingtime_stop();
+#endif
+
+#if defined(ENABLE_OPAGENT)
+       if (opt_EnableOpagent)
+               OprofileAgent_newmethod(m);
+#endif
+
+       DEBUG_JIT_COMPILEVERBOSE("Recompiling done: ");
+
+       /* return pointer to the methods entry point */
+
+       return r;
+}
+
+#if defined(ENABLE_PM_HACKS)
+#include "vm/jit/jit_pm_1.inc"
+#endif
+
+/* jit_compile_intern **********************************************************
+
+   Static internal function which does the actual compilation.
+
+*******************************************************************************/
+
+static u1 *jit_compile_intern(jitdata *jd)
+{
+       methodinfo  *m;
+       codegendata *cd;
+       codeinfo    *code;
+
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start,time_checks,time_parse,time_stack,
+                                       time_typecheck,time_loop,time_ifconv,time_alloc,
+                                       time_codegen;
+#endif
+       
+       RT_TIMING_GET_TIME(time_start);
+
+       /* get required compiler data */
+
+#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
+       jd->ls = NULL;
+#endif
+       m    = jd->m;
+       code = jd->code;
+       cd   = jd->cd;
+       
+#if defined(ENABLE_DEBUG_FILTER)
+       show_filters_apply(jd->m);
+#endif
+
+       /* Handle native methods and create a native stub. */
+
+       if (m->flags & ACC_NATIVE) {
+               functionptr f;
+
+               f = native_method_resolve(m);
+
+               if (f == NULL)
+                       return NULL;
+
+               code = NativeStub::generate(m, f);
+
+               /* Native methods are never recompiled. */
+               
+               assert(!m->code);
+
+               m->code = code;
+               
+               return code->entrypoint;
+       }
+
+       /* if there is no javacode, print error message and return empty method   */
+
+       if (m->jcode == NULL) {
+               DEBUG_JIT_COMPILEVERBOSE("No code given for: ");
+
+               code->entrypoint = (u1 *) (ptrint) do_nothing_function;
+               m->code = code;
+
+               return code->entrypoint;        /* return empty method                */
+       }
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat) {
+               count_javacodesize += m->jcodelength + 18;
+               count_tryblocks    += jd->exceptiontablelength;
+               count_javaexcsize  += jd->exceptiontablelength * SIZEOF_VOID_P;
+       }
+#endif
+
+       RT_TIMING_GET_TIME(time_checks);
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       /* Code for Sun's OpenJDK (see
+          hotspot/src/share/vm/classfile/verifier.cpp
+          (Verifier::is_eligible_for_verification)): Don't verify
+          dynamically-generated bytecodes. */
+
+# if defined(ENABLE_VERIFIER)
+       if (class_issubclass(m->clazz, class_sun_reflect_MagicAccessorImpl))
+               jd->flags &= ~JITDATA_FLAG_VERIFY;
+# endif
+#endif
+
+       /* call the compiler passes ***********************************************/
+
+       DEBUG_JIT_COMPILEVERBOSE("Parsing: ");
+
+       /* call parse pass */
+
+       if (!parse(jd)) {
+               DEBUG_JIT_COMPILEVERBOSE("Exception while parsing: ");
+
+               return NULL;
+       }
+       RT_TIMING_GET_TIME(time_parse);
+
+       DEBUG_JIT_COMPILEVERBOSE("Parsing done: ");
+       
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (!opt_intrp) {
+# endif
+               DEBUG_JIT_COMPILEVERBOSE("Analysing: ");
+
+               /* call stack analysis pass */
+
+               if (!stack_analyse(jd)) {
+                       DEBUG_JIT_COMPILEVERBOSE("Exception while analysing: ");
+
+                       return NULL;
+               }
+               RT_TIMING_GET_TIME(time_stack);
+
+               DEBUG_JIT_COMPILEVERBOSE("Analysing done: ");
+
+#ifdef ENABLE_VERIFIER
+               if (JITDATA_HAS_FLAG_VERIFY(jd)) {
+                       DEBUG_JIT_COMPILEVERBOSE("Typechecking: ");
+
+                       /* call typecheck pass */
+                       if (!typecheck(jd)) {
+                               DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: ");
+
+                               return NULL;
+                       }
+
+                       DEBUG_JIT_COMPILEVERBOSE("Typechecking done: ");
+               }
+#endif
+               RT_TIMING_GET_TIME(time_typecheck);
+
+#if defined(ENABLE_LOOP)
+               if (opt_loops) {
+                       depthFirst(jd);
+                       analyseGraph(jd);
+                       optimize_loops(jd);
+                       jit_renumber_basicblocks(jd);
+               }
+#endif
+               RT_TIMING_GET_TIME(time_loop);
+
+#if defined(ENABLE_IFCONV)
+               if (JITDATA_HAS_FLAG_IFCONV(jd)) {
+                       if (!ifconv_static(jd))
+                               return NULL;
+                       jit_renumber_basicblocks(jd);
+               }
+#endif
+               RT_TIMING_GET_TIME(time_ifconv);
+
+               /* inlining */
+
+#if defined(ENABLE_INLINING) && (!defined(ENABLE_ESCAPE) || 1)
+               if (JITDATA_HAS_FLAG_INLINE(jd)) {
+                       if (!inline_inline(jd))
+                               return NULL;
+               }
+#endif
+
+#if defined(ENABLE_SSA)
+               if (opt_lsra) {
+                       fix_exception_handlers(jd);
+               }
+#endif
+
+               /* Build the CFG.  This has to be done after stack_analyse, as
+                  there happens the JSR elimination. */
+
+               if (!cfg_build(jd))
+                       return NULL;
+
+#if defined(ENABLE_PROFILING)
+               /* Basic block reordering.  I think this should be done after
+                  if-conversion, as we could lose the ability to do the
+                  if-conversion. */
+
+               if (JITDATA_HAS_FLAG_REORDER(jd)) {
+                       if (!reorder(jd))
+                               return NULL;
+                       jit_renumber_basicblocks(jd);
+               }
+#endif
+
+#if defined(ENABLE_PM_HACKS)
+#include "vm/jit/jit_pm_2.inc"
+#endif
+               DEBUG_JIT_COMPILEVERBOSE("Allocating registers: ");
+
+#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
+               /* allocate registers */
+               if (opt_lsra) {
+                       if (!lsra(jd))
+                               return NULL;
+
+                       STATISTICS(count_methods_allocated_by_lsra++);
+
+               } else
+# endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */
+#if defined(ENABLE_SSA)
+               /* allocate registers */
+               if (
+                       (opt_lsra &&
+                       jd->code->optlevel > 0) 
+                       /* strncmp(jd->m->name->text, "hottie", 6) == 0*/
+                       /*&& jd->exceptiontablelength == 0*/
+               ) {
+                       /*printf("=== %s ===\n", jd->m->name->text);*/
+                       jd->ls = DNEW(lsradata);
+                       jd->ls = NULL;
+                       ssa(jd);
+                       /*lsra(jd);*/ regalloc(jd);
+                       /*eliminate_subbasicblocks(jd);*/
+                       STATISTICS(count_methods_allocated_by_lsra++);
+
+               } else
+# endif /* defined(ENABLE_SSA) */
+               {
+                       STATISTICS(count_locals_conflicts += (jd->maxlocals - 1) * (jd->maxlocals));
+
+                       regalloc(jd);
+               }
+
+               STATISTICS(simplereg_make_statistics(jd));
+
+               DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: ");
+# if defined(ENABLE_INTRP)
+       }
+# endif
+#endif /* defined(ENABLE_JIT) */
+       RT_TIMING_GET_TIME(time_alloc);
+
+#if defined(ENABLE_PROFILING)
+       /* Allocate memory for basic block profiling information. This
+          _must_ be done after loop optimization and register allocation,
+          since they can change the basic block count. */
+
+       if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
+               code->bbfrequency = MNEW(u4, jd->basicblockcount);
+#endif
+
+       DEBUG_JIT_COMPILEVERBOSE("Generating code: ");
+
+       /* now generate the machine code */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+       if (opt_intrp) {
+#if defined(ENABLE_VERIFIER)
+               if (opt_verify) {
+                       DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): ");
+
+                       if (!typecheck_stackbased(jd)) {
+                               DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): ");
+                               return NULL;
+                       }
+               }
+#endif
+               if (!intrp_codegen(jd)) {
+                       DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
+
+                       return NULL;
+               }
+       } else
+# endif
+               {
+                       if (!codegen_generate(jd)) {
+                               DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
+
+                               return NULL;
+                       }
+               }
+#else
+       if (!intrp_codegen(jd)) {
+               DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
+
+               return NULL;
+       }
+#endif
+       RT_TIMING_GET_TIME(time_codegen);
+
+       DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
+
+#if !defined(NDEBUG) && defined(ENABLE_REPLACEMENT)
+       /* activate replacement points inside newly created code */
+
+       if (opt_TestReplacement)
+               replace_activate_replacement_points(code, false);
+#endif
+
+#if !defined(NDEBUG)
+#if defined(ENABLE_DEBUG_FILTER)
+       if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
+#endif
+       {
+               /* intermediate and assembly code listings */
+               
+               if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
+                       show_method(jd, SHOW_CODE);
+               }
+               else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
+# if defined(ENABLE_DISASSEMBLER)
+                       DISASSEMBLE(code->entrypoint,
+                                               code->entrypoint + (code->mcodelength - cd->dseglen));
+# endif
+               }
+
+               if (opt_showddatasegment)
+                       dseg_display(jd);
+       }
+#endif
+
+       /* switch to the newly generated code */
+
+       assert(code);
+       assert(code->entrypoint);
+
+       /* add the current compile version to the methodinfo */
+
+       code->prev = m->code;
+       m->code = code;
+
+       RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS);
+       RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE);
+       RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK);
+       RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK);
+       RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP);
+       RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC);
+       RT_TIMING_TIME_DIFF(time_alloc,time_codegen,RT_TIMING_JIT_CODEGEN);
+       RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL);
+
+       /* return pointer to the methods entry point */
+
+       return code->entrypoint;
+} 
+
+
+/* jit_invalidate_code *********************************************************
+
+   Mark the compiled code of the given method as invalid and take care that
+   it is replaced if necessary.
+
+   XXX Not fully implemented, yet.
+
+*******************************************************************************/
+
+void jit_invalidate_code(methodinfo *m)
+{
+       codeinfo *code;
+
+       code = m->code;
+
+       if (code == NULL || code_is_invalid(code))
+               return;
+
+       code_flag_invalid(code);
+
+       /* activate mappable replacement points */
+
+#if defined(ENABLE_REPLACEMENT)
+       replace_activate_replacement_points(code, true);
+#else
+       vm_abort("invalidating code only works with ENABLE_REPLACEMENT");
+#endif
+}
+
+
+/* jit_request_optimization ****************************************************
+
+   Request optimization of the given method. If the code of the method is
+   unoptimized, it will be invalidated, so the next jit_get_current_code(m)
+   triggers an optimized recompilation.
+   If the method is already optimized, this function does nothing.
+
+   IN:
+       m................the method
+
+*******************************************************************************/
+
+void jit_request_optimization(methodinfo *m)
+{
+       codeinfo *code;
+
+       code = m->code;
+
+       if (code && code->optlevel == 0)
+               jit_invalidate_code(m);
+}
+
+
+/* jit_get_current_code ********************************************************
+
+   Get the currently valid code for the given method. If there is no valid
+   code, (re)compile the method.
+
+   IN:
+       m................the method
+
+   RETURN VALUE:
+       the codeinfo* for the current code, or
+          NULL if an exception has been thrown during recompilation.
+
+*******************************************************************************/
+
+codeinfo *jit_get_current_code(methodinfo *m)
+{
+       assert(m);
+
+       /* if we have valid code, return it */
+
+       if (m->code && !code_is_invalid(m->code))
+               return m->code;
+
+       /* otherwise: recompile */
+
+       if (!jit_recompile(m))
+               return NULL;
+
+       assert(m->code);
+
+       return m->code;
+}
+
+
+/* jit_asm_compile *************************************************************
+
+   This method is called from asm_vm_call_method and does:
+
+     - create stackframe info for exceptions
+     - compile the method
+     - patch the entrypoint of the method into the calculated address in
+       the JIT code
+     - flushes the instruction cache.
+
+*******************************************************************************/
+
+#if defined(ENABLE_JIT)
+#if !defined(JIT_COMPILER_VIA_SIGNAL)
+u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra)
+{
+       stackframeinfo_t  sfi;
+       u1               *entrypoint;
+       u1               *pa;
+       ptrint           *p;
+
+       /* create the stackframeinfo (subtract 1 from RA as it points to the */
+       /* instruction after the call)                                       */
+
+       stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra-1);
+
+       /* actually compile the method */
+
+       entrypoint = jit_compile(m);
+
+       /* remove the stackframeinfo */
+
+       stacktrace_stackframeinfo_remove(&sfi);
+
+       /* there was a problem during compilation */
+
+       if (entrypoint == NULL)
+               return NULL;
+
+       /* get the method patch address */
+
+       pa = md_jit_method_patch_address(sfi.pv, (void *) ra, mptr);
+
+       /* patch the method entry point */
+
+       p = (ptrint *) pa;
+
+       *p = (ptrint) entrypoint;
+
+       /* flush the instruction cache */
+
+       md_icacheflush(pa, SIZEOF_VOID_P);
+
+       return entrypoint;
+}
+#endif
+
+/* jit_compile_handle **********************************************************
+
+   This method is called from the appropriate signal handler which
+   handles compiler-traps and does the following:
+
+     - compile the method
+     - patch the entrypoint of the method into the calculated address in
+       the JIT code
+     - flush the instruction cache
+
+*******************************************************************************/
+
+void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
+{
+       void      *newpv;                               /* new compiled method PV */
+       void      *pa;                                           /* patch address */
+       uintptr_t *p;                                      /* convenience pointer */
+
+       /* Compile the method. */
+
+       newpv = jit_compile(m);
+
+       /* There was a problem during compilation. */
+
+       if (newpv == NULL)
+               return NULL;
+
+       /* Get the method patch address. */
+
+       pa = md_jit_method_patch_address(pv, ra, mptr);
+
+       /* Patch the method entry point. */
+
+       p = (uintptr_t *) pa;
+
+       *p = (uintptr_t) newpv;
+
+       /* Flush both caches. */
+
+       md_cacheflush(pa, SIZEOF_VOID_P);
+
+       return newpv;
+}
+#endif /* defined(ENABLE_JIT) */
+
+
+/* jit_complement_condition ****************************************************
+
+   Returns the complement of the passed conditional instruction.
+
+   We use the order of the different conditions, e.g.:
+
+   ICMD_IFEQ         153
+   ICMD_IFNE         154
+
+   If the passed opcode is odd, we simply add 1 to get the complement.
+   If the opcode is even, we subtract 1.
+
+   Exception:
+
+   ICMD_IFNULL       198
+   ICMD_IFNONNULL    199
+
+*******************************************************************************/
+
+s4 jit_complement_condition(s4 opcode)
+{
+       switch (opcode) {
+       case ICMD_IFNULL:
+               return ICMD_IFNONNULL;
+
+       case ICMD_IFNONNULL:
+               return ICMD_IFNULL;
+
+       default:
+               /* check if opcode is odd */
+
+               if (opcode & 0x1)
+                       return opcode + 1;
+               else
+                       return opcode - 1;
+       }
+}
+
+
+/* jit_renumber_basicblocks ****************************************************
+
+   Set the ->nr of all blocks so it increases when traversing ->next.
+
+   IN:
+       jitdata..........the current jitdata
+
+*******************************************************************************/
+
+void jit_renumber_basicblocks(jitdata *jd)
+{
+       s4          nr;
+       basicblock *bptr;
+
+       nr = 0;
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
+               bptr->nr = nr++;
+       }
+
+       /* we have one block more than jd->basicblockcount (the end marker) */
+
+       assert(nr == jd->basicblockcount + 1);
+}
+
+
+/* jit_check_basicblock_numbers ************************************************
+
+   Assert that the ->nr of the first block is zero and increases by 1 each
+   time ->next is traversed.
+   This function should be called before any analysis that relies on
+   the basicblock numbers.
+
+   IN:
+       jitdata..........the current jitdata
+
+   NOTE: Aborts with an assertion if the condition is not met!
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void jit_check_basicblock_numbers(jitdata *jd)
+{
+       s4          nr;
+       basicblock *bptr;
+
+       nr = 0;
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
+               assert(bptr->nr == nr);
+               nr++;
+       }
+
+       /* we have one block more than jd->basicblockcount (the end marker) */
+
+       assert(nr == jd->basicblockcount + 1);
+}
+#endif /* !defined(NDEBUG) */
+
+
+/*
+ * 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/jit.h b/src/vm/jit/jit.h
deleted file mode 100644 (file)
index acd6085..0000000
+++ /dev/null
@@ -1,495 +0,0 @@
-/* src/vm/jit/jit.h - code generation header
-
-   Copyright (C) 1996-2005, 2006, 2007, 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 _JIT_H
-#define _JIT_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct jitdata jitdata;
-typedef struct basicblock basicblock;
-typedef struct exception_entry exception_entry;
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-#include "vm/method.h"
-#include "vm/references.h"
-#include "vm/resolve.h"
-
-#if defined(ENABLE_STATISTICS)
-# include "vm/statistics.h"
-#endif
-
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stack.h"
-#include "vm/jit/stacktrace.hpp"
-
-#if defined(ENABLE_INLINING)
-# include "vm/jit/inline/inline.h"
-#endif
-
-#include "vm/jit/ir/bytecode.h"
-#include "vm/jit/ir/instruction.hpp"
-
-#if defined(ENABLE_LOOP)
-# include "vm/jit/loop/loop.h"
-#endif
-#if defined(ENABLE_SSA) 
-# include "vm/jit/optimizing/lsra.h"
-#endif
-#if defined(ENABLE_LSRA)
-# include "vm/jit/allocator/lsra.h"
-#endif
-
-#include "vm/jit/verify/typeinfo.h"
-
-
-/* common jit/codegen macros **************************************************/
-
-#if defined(ENABLE_STATISTICS)
-# define COUNT(x)        (x)++
-# define COUNT_SPILLS             /* use COUNT_(READ|WRITE)_SPILLS instead */
-# define COUNT_READ_SPILLS(var) \
-       switch(var->type) { \
-       case TYPE_FLT: count_spills_read_flt++; break; \
-       case TYPE_DBL: count_spills_read_dbl++; break; \
-       default: count_spills_read_ila++; break; \
-       }
-
-# define COUNT_WRITE_SPILLS(var) \
-       switch(var->type) { \
-       case TYPE_FLT: count_spills_write_flt++; break; \
-       case TYPE_DBL: count_spills_write_dbl++; break; \
-       default: count_spills_write_ila++; break; \
-       }
-
-#else
-# define COUNT(x)                /* nothing */
-# define COUNT_SPILLS            /* nothing */
-# define COUNT_READ_SPILLS(x)    /* nothing */
-# define COUNT_WRITE_SPILLS(x)   /* nothing */
-#endif
-
-typedef struct interface_info interface_info;
-
-struct interface_info {
-       s4 flags;
-       s4 regoff;
-};
-
-
-/* jitdata ********************************************************************/
-
-struct jitdata {
-       methodinfo      *m;               /* methodinfo of the method compiled    */
-       codeinfo        *code;
-       codegendata     *cd;
-       registerdata    *rd;
-#if defined(ENABLE_LOOP)
-       loopdata        *ld;
-#endif
-#if defined(ENABLE_SSA) || defined(ENABLE_LSRA)
-       lsradata        *ls;
-#endif
-
-       u4               flags;           /* contains JIT compiler flags          */
-
-       instruction     *instructions;    /* ICMDs, valid between parse and stack */
-       basicblock      *basicblocks;     /* start of basic block list            */
-       stackelement_t  *stack;           /* XXX should become stack.c internal   */
-       s4               instructioncount;/* XXX remove this?                     */
-       s4               basicblockcount; /* number of basic blocks               */
-       s4               stackcount;      /* number of stackelements to allocate  */
-                                      /* (passed from parse to stack)         */
-
-       varinfo         *var;             /* array of variables                   */
-       s4               vartop;          /* next free index in var array         */
-
-       s4               varcount;        /* number of variables in var array     */
-       s4               localcount;      /* number of locals at start of var ar. */
-    s4              *local_map;       /* map for renaming (de-coallescing)    */
-                                        /* locals and keeping the coalescing info for simplereg. */
-                        /* local_map[javaindex * 5 + type] =                     */
-                        /*     >= 0......index into jd->var, or                  */
-                                        /*     UNUSED....this (javaindex,type) pair is not used  */
-
-       s4              *reverselocalmap; /* map from CACAO varindex to javaindex */
-                                         /* (varindex must be < localcount)      */
-
-       s4               maxlocals;       /* max. number of javalocals            */
-
-       interface_info  *interface_map;   /* interface variables (for simplereg)  */
-       s4               maxinterfaces;   /* max. number of interface variables   */
-
-       s4               exceptiontablelength; /* exceptiontable length           */
-       exception_entry *exceptiontable;       /* the exceptiontable              */
-
-       basicblock      *returnblock;          /* block containing the *RETURN    */
-                                              /* (only use if returncount==1)    */
-       s4               returncount;          /* number of return instructions   */
-       bool             branchtoentry;        /* true if first block is a target */
-       bool             branchtoend;          /* true if end dummy is a target   */
-};
-
-#define FOR_EACH_BASICBLOCK(jd, it) \
-       for ((it) = (jd)->basicblocks; (it) != NULL; (it) = (it)->next)
-
-#define UNUSED                     -1
-
-#define JITDATA_FLAG_PARSE               0x00000001
-#define JITDATA_FLAG_VERIFY              0x00000002
-
-#define JITDATA_FLAG_INSTRUMENT          0x00000004
-
-#define JITDATA_FLAG_IFCONV              0x00000008
-#define JITDATA_FLAG_REORDER             0x00000010
-#define JITDATA_FLAG_INLINE              0x00000020
-
-#define JITDATA_FLAG_COUNTDOWN           0x00000100
-
-#define JITDATA_FLAG_SHOWINTERMEDIATE    0x20000000
-#define JITDATA_FLAG_SHOWDISASSEMBLE     0x40000000
-#define JITDATA_FLAG_VERBOSECALL         0x80000000
-
-
-#define JITDATA_HAS_FLAG_PARSE(jd) \
-    ((jd)->flags & JITDATA_FLAG_PARSE)
-
-#define JITDATA_HAS_FLAG_VERIFY(jd) \
-    ((jd)->flags & JITDATA_FLAG_VERIFY)
-
-#define JITDATA_HAS_FLAG_INSTRUMENT(jd) \
-    ((jd)->flags & JITDATA_FLAG_INSTRUMENT)
-
-#define JITDATA_HAS_FLAG_IFCONV(jd) \
-    ((jd)->flags & JITDATA_FLAG_IFCONV)
-
-#define JITDATA_HAS_FLAG_REORDER(jd) \
-    ((jd)->flags & JITDATA_FLAG_REORDER)
-
-#define JITDATA_HAS_FLAG_INLINE(jd) \
-    ((jd)->flags & JITDATA_FLAG_INLINE)
-
-#define JITDATA_HAS_FLAG_COUNTDOWN(jd) \
-    ((jd)->flags & JITDATA_FLAG_COUNTDOWN)
-
-#define JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd) \
-    ((jd)->flags & JITDATA_FLAG_SHOWINTERMEDIATE)
-
-#define JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) \
-    ((jd)->flags & JITDATA_FLAG_SHOWDISASSEMBLE)
-
-#define JITDATA_HAS_FLAG_VERBOSECALL(jd) \
-    ((jd)->flags & JITDATA_FLAG_VERBOSECALL)
-
-
-/* exception_entry ************************************************************/
-
-struct exception_entry {
-       basicblock           *start;
-       basicblock           *end;
-       basicblock           *handler;
-       classref_or_classinfo catchtype; /* catchtype of exc. (NULL == catchall)  */
-       exception_entry      *next;      /* next in list of exceptions when       */
-                                                                        /* loops are copied                      */
-       exception_entry      *down;      /* next exception_entry                  */
-};
-
-
-/* macros for accessing variables *********************************************
-   Use VAROP for s1, s2, s3 and dst operands (eg. VAROP(iptr->s1)),
-   use VAR if you have the variable index (eg. VAR(iptr->sx.s23.s2.args[0])).
-
-******************************************************************************/
-
-#define VAROP(v) (jd->var + (v).varindex)
-#define VAR(i)   (jd->var + (i))
-
-static inline bool var_is_local(const jitdata *jd, s4 i) {
-       return (i < jd->localcount);
-}
-
-static inline bool var_is_prealloc(const jitdata *jd, s4 i) {
-       return ((i >= jd->localcount) && (jd->var[i].flags & PREALLOC));
-}
-
-static inline bool var_is_inout(const jitdata *jd, s4 i) {
-       const varinfo *v = jd->var + i;
-       return (
-               (i >= jd->localcount) && (
-                       (!(v->flags & PREALLOC) && (v->flags & INOUT)) ||
-                       /* special case of TYPE_RET, used with JSR */
-                       ((v->flags & PREALLOC) && (v->flags & INOUT) && (v->type == TYPE_RET))
-               )
-       );
-}
-
-static inline bool var_is_temp(const jitdata *jd, s4 i) {
-       const varinfo *v = jd->var + i;
-       return ((i >= jd->localcount) && !(v->flags & PREALLOC) && !(v->flags & INOUT));
-}
-
-static inline bool var_is_saved(const jitdata *jd, s4 i) {
-       return (jd->var[i].flags & SAVEDVAR);
-}
-
-
-/* basicblock *****************************************************************/
-
-/* flags */
-
-#define BBDELETED            -2
-#define BBUNDEF              -1
-#define BBREACHED            0
-#define BBFINISHED           1
-
-#define BBTYPECHECK_UNDEF    2
-#define BBTYPECHECK_REACHED  3
-
-#define BBTYPE_STD           0  /* standard basic block type                  */
-#define BBTYPE_EXH           1  /* exception handler basic block type         */
-#define BBTYPE_SBR           2  /* subroutine basic block type                */
-
-#define BBFLAG_REPLACEMENT   0x01  /* put a replacement point at the start    */
-
-/* XXX basicblock wastes quite a lot of memory by having four flag fields     */
-/* (flags, bitflags, type and lflags). Probably the last three could be       */
-/* combined without loss of efficiency. The first one could be combined with  */
-/* the others by using bitfields.                                             */
-
-/* XXX "flags" should probably be called "state", as it is an integer state   */
-
-struct basicblock {
-       s4            nr;           /* basic block number                         */
-       s4            flags;        /* used during stack analysis, init with -1   */
-       s4            bitflags;     /* OR of BBFLAG_... constants, init with 0    */
-       s4            type;         /* basic block type (std, xhandler, subroutine*/
-       s4            lflags;       /* used during loop copying, init with 0      */
-
-       s4            icount;       /* number of intermediate code instructions   */
-       instruction  *iinstr;       /* pointer to intermediate code instructions  */
-
-       varinfo      *inlocals;     /* copy of locals on block entry              */
-       s4           *javalocals;   /* map from java locals to cacao variables[+] */
-       s4           *invars;       /* array of in-variables at begin of block    */
-       s4           *outvars;      /* array of out-variables at end of block     */
-       s4            indepth;      /* stack depth at begin of basic block        */
-       s4            outdepth;     /* stack depth end of basic block             */
-       s4            varstart;     /* index of first non-invar block variable    */
-       s4            varcount;     /* number of non-invar block variables        */
-
-       s4            predecessorcount;
-       s4            successorcount;
-       basicblock  **predecessors; /* array of predecessor basic blocks          */
-       basicblock  **successors;   /* array of successor basic blocks            */
-
-       branchref    *branchrefs;   /* list of branches to be patched             */
-
-       basicblock   *next;         /* used to build a BB list (instead of array) */
-       basicblock   *copied_to;    /* points to the copy of this basic block     */
-                                /* when loop nodes are copied                 */
-       basicblock   *original;     /* block of which this block is a clone       */
-                                   /* NULL for the original block itself         */
-       methodinfo   *method;       /* method this block belongs to               */
-       insinfo_inline *inlineinfo; /* inlineinfo for the start of this block     */
-
-       s4            mpc;          /* machine code pc at start of block          */
-
-       /* TODO: those fields are probably usefull for other passes as well. */
-
-#if defined(ENABLE_SSA)         
-       basicblock   *idom;         /* Immediate dominator, parent in dominator tree */
-       basicblock  **domsuccessors;/* Children in dominator tree                 */
-       s4            domsuccessorcount;
-
-       basicblock  **domfrontier;  /* Dominance frontier                         */
-       s4            domfrontiercount;
-
-       basicblock  **exhandlers;   /* Exception handlers for this block */
-       s4            exhandlercount;
-       basicblock  **expredecessors; /* Blocks this block is exception handler for */
-       s4            expredecessorcount;
-       s4            exouts;       /* Number of exceptional exits */
-
-       instruction  *phis;         /* Phi functions */
-       s4            phicount;     /* Number of phi functions */
-
-       void         *vp;           /* Freely used by different passes            */
-#endif
-};
-
-#define FOR_EACH_SUCCESSOR(bptr, it) \
-       for ((it) = (bptr)->successors; (it) != (bptr)->successors + (bptr)->successorcount; ++(it))
-
-#define FOR_EACH_PREDECESSOR(bptr, it) \
-       for ( \
-               (it) = (bptr)->predecessors; \
-               (it) != (bptr)->predecessors + ((bptr)->predecessorcount < 0 ? 0 : (bptr)->predecessorcount); \
-               ++(it) \
-       )
-
-#define FOR_EACH_INSTRUCTION(bptr, it) \
-       for ((it) = (bptr)->iinstr; (it) != (bptr)->iinstr + (bptr)->icount; ++(it))
-
-#define FOR_EACH_INSTRUCTION_REV(bptr, it) \
-       for ((it) = (bptr)->iinstr + (bptr)->icount - 1; (it) != (bptr)->iinstr - 1; --(it))
-
-#if defined(ENABLE_SSA)
-
-#define FOR_EACH_EXHANDLER(bptr, it) \
-       for ((it) = (bptr)->exhandlers; (it) != (bptr)->exhandlers + (bptr)->exhandlercount; ++(it))
-
-#define FOR_EACH_EXPREDECESSOR(bptr, it) \
-       for ((it) = (bptr)->expredecessors; (it) != (bptr)->expredecessors + (bptr)->expredecessorcount; ++(it))
-
-#endif
-
-/* [+]...the javalocals array: This array is indexed by the javaindex (the    */
-/*       local variable index ocurring in the original bytecode). An element  */
-/*       javalocals[javaindex] encodes where to find the contents of the      */
-/*       original variable at this point in the program.                      */
-/*       There are three cases for javalocals[javaindex]:                     */
-/*           >= 0.......it's an index into the jd->var array, where the       */
-/*                      CACAO variable corresponding to the original local    */
-/*                      can be found.                                         */
-/*           UNUSED.....the original variable is not live at this point       */
-/*           < UNUSED...the original variable contains a returnAddress at     */
-/*                      this point. The number of the block to return to can  */
-/*                      be calculated using RETADDR_FROM_JAVALOCAL:           */
-/*                                                                            */
-/*                      javalocals[javaindex] == JAVALOCAL_FROM_RETADDR(nr)   */
-/*                      RETADDR_FROM_JAVALOCAL(javalocals[javaindex]) == nr   */
-
-#define JAVALOCAL_FROM_RETADDR(nr)  (UNUSED - (1 + (nr)))
-#define RETADDR_FROM_JAVALOCAL(jl)  (UNUSED - (1 + (jl)))
-
-
-/* Macro for initializing newly allocated basic block's. It does not
-   need to zero fields, as we zero out the whole basic block array. */
-
-#define BASICBLOCK_INIT(bptr,m)                        \
-       do {                                               \
-               bptr->mpc    = -1;                             \
-               bptr->flags  = -1;                             \
-               bptr->type   = BBTYPE_STD;                     \
-               bptr->method = (m);                            \
-       } while (0)
-
-static inline bool basicblock_reached(const basicblock *bptr) {
-       return (bptr->flags >= BBREACHED);
-}
-
-
-
-/***************************** register types *********************************/
-
-#define REG_RES   0         /* reserved register for OS or code generator     */
-#define REG_RET   1         /* return value register                          */
-#define REG_EXC   2         /* exception value register                       */
-#define REG_SAV   3         /* (callee) saved register                        */
-#define REG_TMP   4         /* scratch temporary register (caller saved)      */
-#define REG_ARG   5         /* argument register (caller saved)               */
-
-#define REG_END   -1        /* last entry in tables                           */
-#define PARAMMODE_NUMBERED  0 
-#define PARAMMODE_STUFFED   1
-
-
-/* function prototypes ********************************************************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* compiler initialisation */
-void jit_init(void);
-
-/* compiler finalisation */
-void jit_close(void);
-
-/* create a new jitdata */
-jitdata *jit_jitdata_new(methodinfo *m);
-
-/* compile a method with jit compiler */
-u1 *jit_compile(methodinfo *m);
-u1 *jit_recompile(methodinfo *m);
-
-void jit_invalidate_code(methodinfo *m);
-codeinfo *jit_get_current_code(methodinfo *m);
-void jit_request_optimization(methodinfo *m);
-
-/* patch the method entrypoint */
-#if !defined(JIT_COMPILER_VIA_SIGNAL)
-u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra);
-#endif
-void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr);
-
-s4 jit_complement_condition(s4 opcode);
-
-void jit_renumber_basicblocks(jitdata *jd);
-#if !defined(NDEBUG)
-void jit_check_basicblock_numbers(jitdata *jd);
-#endif
-
-
-/* machine dependent functions ************************************************/
-
-#if defined(ENABLE_JIT)
-void md_init(void);
-#endif
-
-#if defined(ENABLE_INTRP)
-void intrp_md_init(void);
-#endif
-
-void *md_jit_method_patch_address(void *pv, void *ra, void *mptr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _JIT_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/jit.hpp b/src/vm/jit/jit.hpp
new file mode 100644 (file)
index 0000000..fb1c7da
--- /dev/null
@@ -0,0 +1,495 @@
+/* src/vm/jit/jit.hpp - Just-In-Time compiler
+
+   Copyright (C) 1996-2005, 2006, 2007, 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 _JIT_HPP
+#define _JIT_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct jitdata jitdata;
+typedef struct basicblock basicblock;
+typedef struct exception_entry exception_entry;
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/global.h"
+#include "vm/method.h"
+#include "vm/references.h"
+#include "vm/resolve.h"
+
+#if defined(ENABLE_STATISTICS)
+# include "vm/statistics.h"
+#endif
+
+#include "vm/jit/codegen-common.h"
+#include "vm/jit/reg.h"
+#include "vm/jit/replace.h"
+#include "vm/jit/stack.h"
+#include "vm/jit/stacktrace.hpp"
+
+#if defined(ENABLE_INLINING)
+# include "vm/jit/inline/inline.h"
+#endif
+
+#include "vm/jit/ir/bytecode.h"
+#include "vm/jit/ir/instruction.hpp"
+
+#if defined(ENABLE_LOOP)
+# include "vm/jit/loop/loop.h"
+#endif
+#if defined(ENABLE_SSA) 
+# include "vm/jit/optimizing/lsra.h"
+#endif
+#if defined(ENABLE_LSRA)
+# include "vm/jit/allocator/lsra.h"
+#endif
+
+#include "vm/jit/verify/typeinfo.h"
+
+
+/* common jit/codegen macros **************************************************/
+
+#if defined(ENABLE_STATISTICS)
+# define COUNT(x)        (x)++
+# define COUNT_SPILLS             /* use COUNT_(READ|WRITE)_SPILLS instead */
+# define COUNT_READ_SPILLS(var) \
+       switch(var->type) { \
+       case TYPE_FLT: count_spills_read_flt++; break; \
+       case TYPE_DBL: count_spills_read_dbl++; break; \
+       default: count_spills_read_ila++; break; \
+       }
+
+# define COUNT_WRITE_SPILLS(var) \
+       switch(var->type) { \
+       case TYPE_FLT: count_spills_write_flt++; break; \
+       case TYPE_DBL: count_spills_write_dbl++; break; \
+       default: count_spills_write_ila++; break; \
+       }
+
+#else
+# define COUNT(x)                /* nothing */
+# define COUNT_SPILLS            /* nothing */
+# define COUNT_READ_SPILLS(x)    /* nothing */
+# define COUNT_WRITE_SPILLS(x)   /* nothing */
+#endif
+
+typedef struct interface_info interface_info;
+
+struct interface_info {
+       s4 flags;
+       s4 regoff;
+};
+
+
+/* jitdata ********************************************************************/
+
+struct jitdata {
+       methodinfo      *m;               /* methodinfo of the method compiled    */
+       codeinfo        *code;
+       codegendata     *cd;
+       registerdata    *rd;
+#if defined(ENABLE_LOOP)
+       loopdata        *ld;
+#endif
+#if defined(ENABLE_SSA) || defined(ENABLE_LSRA)
+       lsradata        *ls;
+#endif
+
+       u4               flags;           /* contains JIT compiler flags          */
+
+       instruction     *instructions;    /* ICMDs, valid between parse and stack */
+       basicblock      *basicblocks;     /* start of basic block list            */
+       stackelement_t  *stack;           /* XXX should become stack.c internal   */
+       s4               instructioncount;/* XXX remove this?                     */
+       s4               basicblockcount; /* number of basic blocks               */
+       s4               stackcount;      /* number of stackelements to allocate  */
+                                      /* (passed from parse to stack)         */
+
+       varinfo         *var;             /* array of variables                   */
+       s4               vartop;          /* next free index in var array         */
+
+       s4               varcount;        /* number of variables in var array     */
+       s4               localcount;      /* number of locals at start of var ar. */
+    s4              *local_map;       /* map for renaming (de-coallescing)    */
+                                        /* locals and keeping the coalescing info for simplereg. */
+                        /* local_map[javaindex * 5 + type] =                     */
+                        /*     >= 0......index into jd->var, or                  */
+                                        /*     UNUSED....this (javaindex,type) pair is not used  */
+
+       s4              *reverselocalmap; /* map from CACAO varindex to javaindex */
+                                         /* (varindex must be < localcount)      */
+
+       s4               maxlocals;       /* max. number of javalocals            */
+
+       interface_info  *interface_map;   /* interface variables (for simplereg)  */
+       s4               maxinterfaces;   /* max. number of interface variables   */
+
+       s4               exceptiontablelength; /* exceptiontable length           */
+       exception_entry *exceptiontable;       /* the exceptiontable              */
+
+       basicblock      *returnblock;          /* block containing the *RETURN    */
+                                              /* (only use if returncount==1)    */
+       s4               returncount;          /* number of return instructions   */
+       bool             branchtoentry;        /* true if first block is a target */
+       bool             branchtoend;          /* true if end dummy is a target   */
+};
+
+#define FOR_EACH_BASICBLOCK(jd, it) \
+       for ((it) = (jd)->basicblocks; (it) != NULL; (it) = (it)->next)
+
+#define UNUSED                     -1
+
+#define JITDATA_FLAG_PARSE               0x00000001
+#define JITDATA_FLAG_VERIFY              0x00000002
+
+#define JITDATA_FLAG_INSTRUMENT          0x00000004
+
+#define JITDATA_FLAG_IFCONV              0x00000008
+#define JITDATA_FLAG_REORDER             0x00000010
+#define JITDATA_FLAG_INLINE              0x00000020
+
+#define JITDATA_FLAG_COUNTDOWN           0x00000100
+
+#define JITDATA_FLAG_SHOWINTERMEDIATE    0x20000000
+#define JITDATA_FLAG_SHOWDISASSEMBLE     0x40000000
+#define JITDATA_FLAG_VERBOSECALL         0x80000000
+
+
+#define JITDATA_HAS_FLAG_PARSE(jd) \
+    ((jd)->flags & JITDATA_FLAG_PARSE)
+
+#define JITDATA_HAS_FLAG_VERIFY(jd) \
+    ((jd)->flags & JITDATA_FLAG_VERIFY)
+
+#define JITDATA_HAS_FLAG_INSTRUMENT(jd) \
+    ((jd)->flags & JITDATA_FLAG_INSTRUMENT)
+
+#define JITDATA_HAS_FLAG_IFCONV(jd) \
+    ((jd)->flags & JITDATA_FLAG_IFCONV)
+
+#define JITDATA_HAS_FLAG_REORDER(jd) \
+    ((jd)->flags & JITDATA_FLAG_REORDER)
+
+#define JITDATA_HAS_FLAG_INLINE(jd) \
+    ((jd)->flags & JITDATA_FLAG_INLINE)
+
+#define JITDATA_HAS_FLAG_COUNTDOWN(jd) \
+    ((jd)->flags & JITDATA_FLAG_COUNTDOWN)
+
+#define JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd) \
+    ((jd)->flags & JITDATA_FLAG_SHOWINTERMEDIATE)
+
+#define JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) \
+    ((jd)->flags & JITDATA_FLAG_SHOWDISASSEMBLE)
+
+#define JITDATA_HAS_FLAG_VERBOSECALL(jd) \
+    ((jd)->flags & JITDATA_FLAG_VERBOSECALL)
+
+
+/* exception_entry ************************************************************/
+
+struct exception_entry {
+       basicblock           *start;
+       basicblock           *end;
+       basicblock           *handler;
+       classref_or_classinfo catchtype; /* catchtype of exc. (NULL == catchall)  */
+       exception_entry      *next;      /* next in list of exceptions when       */
+                                                                        /* loops are copied                      */
+       exception_entry      *down;      /* next exception_entry                  */
+};
+
+
+/* macros for accessing variables *********************************************
+   Use VAROP for s1, s2, s3 and dst operands (eg. VAROP(iptr->s1)),
+   use VAR if you have the variable index (eg. VAR(iptr->sx.s23.s2.args[0])).
+
+******************************************************************************/
+
+#define VAROP(v) (jd->var + (v).varindex)
+#define VAR(i)   (jd->var + (i))
+
+static inline bool var_is_local(const jitdata *jd, s4 i) {
+       return (i < jd->localcount);
+}
+
+static inline bool var_is_prealloc(const jitdata *jd, s4 i) {
+       return ((i >= jd->localcount) && (jd->var[i].flags & PREALLOC));
+}
+
+static inline bool var_is_inout(const jitdata *jd, s4 i) {
+       const varinfo *v = jd->var + i;
+       return (
+               (i >= jd->localcount) && (
+                       (!(v->flags & PREALLOC) && (v->flags & INOUT)) ||
+                       /* special case of TYPE_RET, used with JSR */
+                       ((v->flags & PREALLOC) && (v->flags & INOUT) && (v->type == TYPE_RET))
+               )
+       );
+}
+
+static inline bool var_is_temp(const jitdata *jd, s4 i) {
+       const varinfo *v = jd->var + i;
+       return ((i >= jd->localcount) && !(v->flags & PREALLOC) && !(v->flags & INOUT));
+}
+
+static inline bool var_is_saved(const jitdata *jd, s4 i) {
+       return (jd->var[i].flags & SAVEDVAR);
+}
+
+
+/* basicblock *****************************************************************/
+
+/* flags */
+
+#define BBDELETED            -2
+#define BBUNDEF              -1
+#define BBREACHED            0
+#define BBFINISHED           1
+
+#define BBTYPECHECK_UNDEF    2
+#define BBTYPECHECK_REACHED  3
+
+#define BBTYPE_STD           0  /* standard basic block type                  */
+#define BBTYPE_EXH           1  /* exception handler basic block type         */
+#define BBTYPE_SBR           2  /* subroutine basic block type                */
+
+#define BBFLAG_REPLACEMENT   0x01  /* put a replacement point at the start    */
+
+/* XXX basicblock wastes quite a lot of memory by having four flag fields     */
+/* (flags, bitflags, type and lflags). Probably the last three could be       */
+/* combined without loss of efficiency. The first one could be combined with  */
+/* the others by using bitfields.                                             */
+
+/* XXX "flags" should probably be called "state", as it is an integer state   */
+
+struct basicblock {
+       s4            nr;           /* basic block number                         */
+       s4            flags;        /* used during stack analysis, init with -1   */
+       s4            bitflags;     /* OR of BBFLAG_... constants, init with 0    */
+       s4            type;         /* basic block type (std, xhandler, subroutine*/
+       s4            lflags;       /* used during loop copying, init with 0      */
+
+       s4            icount;       /* number of intermediate code instructions   */
+       instruction  *iinstr;       /* pointer to intermediate code instructions  */
+
+       varinfo      *inlocals;     /* copy of locals on block entry              */
+       s4           *javalocals;   /* map from java locals to cacao variables[+] */
+       s4           *invars;       /* array of in-variables at begin of block    */
+       s4           *outvars;      /* array of out-variables at end of block     */
+       s4            indepth;      /* stack depth at begin of basic block        */
+       s4            outdepth;     /* stack depth end of basic block             */
+       s4            varstart;     /* index of first non-invar block variable    */
+       s4            varcount;     /* number of non-invar block variables        */
+
+       s4            predecessorcount;
+       s4            successorcount;
+       basicblock  **predecessors; /* array of predecessor basic blocks          */
+       basicblock  **successors;   /* array of successor basic blocks            */
+
+       branchref    *branchrefs;   /* list of branches to be patched             */
+
+       basicblock   *next;         /* used to build a BB list (instead of array) */
+       basicblock   *copied_to;    /* points to the copy of this basic block     */
+                                /* when loop nodes are copied                 */
+       basicblock   *original;     /* block of which this block is a clone       */
+                                   /* NULL for the original block itself         */
+       methodinfo   *method;       /* method this block belongs to               */
+       insinfo_inline *inlineinfo; /* inlineinfo for the start of this block     */
+
+       s4            mpc;          /* machine code pc at start of block          */
+
+       /* TODO: those fields are probably usefull for other passes as well. */
+
+#if defined(ENABLE_SSA)         
+       basicblock   *idom;         /* Immediate dominator, parent in dominator tree */
+       basicblock  **domsuccessors;/* Children in dominator tree                 */
+       s4            domsuccessorcount;
+
+       basicblock  **domfrontier;  /* Dominance frontier                         */
+       s4            domfrontiercount;
+
+       basicblock  **exhandlers;   /* Exception handlers for this block */
+       s4            exhandlercount;
+       basicblock  **expredecessors; /* Blocks this block is exception handler for */
+       s4            expredecessorcount;
+       s4            exouts;       /* Number of exceptional exits */
+
+       instruction  *phis;         /* Phi functions */
+       s4            phicount;     /* Number of phi functions */
+
+       void         *vp;           /* Freely used by different passes            */
+#endif
+};
+
+#define FOR_EACH_SUCCESSOR(bptr, it) \
+       for ((it) = (bptr)->successors; (it) != (bptr)->successors + (bptr)->successorcount; ++(it))
+
+#define FOR_EACH_PREDECESSOR(bptr, it) \
+       for ( \
+               (it) = (bptr)->predecessors; \
+               (it) != (bptr)->predecessors + ((bptr)->predecessorcount < 0 ? 0 : (bptr)->predecessorcount); \
+               ++(it) \
+       )
+
+#define FOR_EACH_INSTRUCTION(bptr, it) \
+       for ((it) = (bptr)->iinstr; (it) != (bptr)->iinstr + (bptr)->icount; ++(it))
+
+#define FOR_EACH_INSTRUCTION_REV(bptr, it) \
+       for ((it) = (bptr)->iinstr + (bptr)->icount - 1; (it) != (bptr)->iinstr - 1; --(it))
+
+#if defined(ENABLE_SSA)
+
+#define FOR_EACH_EXHANDLER(bptr, it) \
+       for ((it) = (bptr)->exhandlers; (it) != (bptr)->exhandlers + (bptr)->exhandlercount; ++(it))
+
+#define FOR_EACH_EXPREDECESSOR(bptr, it) \
+       for ((it) = (bptr)->expredecessors; (it) != (bptr)->expredecessors + (bptr)->expredecessorcount; ++(it))
+
+#endif
+
+/* [+]...the javalocals array: This array is indexed by the javaindex (the    */
+/*       local variable index ocurring in the original bytecode). An element  */
+/*       javalocals[javaindex] encodes where to find the contents of the      */
+/*       original variable at this point in the program.                      */
+/*       There are three cases for javalocals[javaindex]:                     */
+/*           >= 0.......it's an index into the jd->var array, where the       */
+/*                      CACAO variable corresponding to the original local    */
+/*                      can be found.                                         */
+/*           UNUSED.....the original variable is not live at this point       */
+/*           < UNUSED...the original variable contains a returnAddress at     */
+/*                      this point. The number of the block to return to can  */
+/*                      be calculated using RETADDR_FROM_JAVALOCAL:           */
+/*                                                                            */
+/*                      javalocals[javaindex] == JAVALOCAL_FROM_RETADDR(nr)   */
+/*                      RETADDR_FROM_JAVALOCAL(javalocals[javaindex]) == nr   */
+
+#define JAVALOCAL_FROM_RETADDR(nr)  (UNUSED - (1 + (nr)))
+#define RETADDR_FROM_JAVALOCAL(jl)  (UNUSED - (1 + (jl)))
+
+
+/* Macro for initializing newly allocated basic block's. It does not
+   need to zero fields, as we zero out the whole basic block array. */
+
+#define BASICBLOCK_INIT(bptr,m)                        \
+       do {                                               \
+               bptr->mpc    = -1;                             \
+               bptr->flags  = -1;                             \
+               bptr->type   = BBTYPE_STD;                     \
+               bptr->method = (m);                            \
+       } while (0)
+
+static inline bool basicblock_reached(const basicblock *bptr) {
+       return (bptr->flags >= BBREACHED);
+}
+
+
+
+/***************************** register types *********************************/
+
+#define REG_RES   0         /* reserved register for OS or code generator     */
+#define REG_RET   1         /* return value register                          */
+#define REG_EXC   2         /* exception value register                       */
+#define REG_SAV   3         /* (callee) saved register                        */
+#define REG_TMP   4         /* scratch temporary register (caller saved)      */
+#define REG_ARG   5         /* argument register (caller saved)               */
+
+#define REG_END   -1        /* last entry in tables                           */
+#define PARAMMODE_NUMBERED  0 
+#define PARAMMODE_STUFFED   1
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* compiler initialisation */
+void jit_init(void);
+
+/* compiler finalisation */
+void jit_close(void);
+
+/* create a new jitdata */
+jitdata *jit_jitdata_new(methodinfo *m);
+
+/* compile a method with jit compiler */
+u1 *jit_compile(methodinfo *m);
+u1 *jit_recompile(methodinfo *m);
+
+void jit_invalidate_code(methodinfo *m);
+codeinfo *jit_get_current_code(methodinfo *m);
+void jit_request_optimization(methodinfo *m);
+
+/* patch the method entrypoint */
+#if !defined(JIT_COMPILER_VIA_SIGNAL)
+u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra);
+#endif
+void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr);
+
+s4 jit_complement_condition(s4 opcode);
+
+void jit_renumber_basicblocks(jitdata *jd);
+#if !defined(NDEBUG)
+void jit_check_basicblock_numbers(jitdata *jd);
+#endif
+
+
+/* machine dependent functions ************************************************/
+
+#if defined(ENABLE_JIT)
+void md_init(void);
+#endif
+
+#if defined(ENABLE_INTRP)
+void intrp_md_init(void);
+#endif
+
+void *md_jit_method_patch_address(void *pv, void *ra, void *mptr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _JIT_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 6dc5d1480757b29f7f08a41d3a7fc75d326e6ba4..37bd18fb7686912d8c31b81fa6c15db3b1ca830c 100644 (file)
@@ -41,7 +41,7 @@ typedef struct linenumbertable_list_entry_t linenumbertable_list_entry_t;
 
 #include "vm/method.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/code.h"
 #include "vm/jit/codegen-common.h"
 
index 43a7dad53c6e7c8558b960f94509082155f61706..211e492bde7e519dbeb908ffbeac72f5714d2c5a 100644 (file)
@@ -35,7 +35,7 @@
 #include "mm/memory.h"
 #include "toolbox/logging.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/stack.h"
 
 #include "vm/jit/loop/analyze.h"
index d8fbc5e0196904fef374d279455e8c6f5169d3f0..5b6650b2460413f140ab9b1e05d655088bee9dc0 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "config.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* function prototypes ********************************************************/
index 09cd21d5384dca04ab91ecc15a5570d94a83763d..91f580d4bdcf3a21cfdbad0d4ac9a610df44bc66 100644 (file)
@@ -38,7 +38,7 @@
 
 #include "mm/memory.h"
 #include "toolbox/logging.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/loop/graph.h"
 #include "vm/jit/loop/loop.h"
 
index e817f02ba0dc012836bb7d64f915f5bdc9fe4986..56d4ee09ffd0cf9f9b3ac7d722471b09209b49c3 100644 (file)
@@ -43,7 +43,7 @@
 #include "mm/memory.h"
 #include "toolbox/logging.h"
 #include "vm/global.h" 
-#include "vm/jit/jit.h"        
+#include "vm/jit/jit.hpp"      
 #include "vm/jit/loop/loop.h"
 #include "vm/jit/loop/graph.h"
 #include "vm/jit/loop/tracing.h"
index 586c729a3ee04d41f3966e1f4036a4bb12953029..0a2eaa54affa43b9861c776aec7223e1c88ab1b5 100644 (file)
@@ -32,7 +32,7 @@
 #include "vm/global.h"
 #include "vm/method.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /*     Different types for struct Trace                                                                                */
index d506be50e45d59500dcbf01dad8314599b70e2cd..fe4653be221cba35b10f2c2c7ae923c73c0a142f 100644 (file)
@@ -33,7 +33,7 @@
 #ifndef _TRACING_H
 #define _TRACING_H
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 typedef struct Trace Trace;
index 446548af82791ed58c79cec86d34adcde76edab7..62b9a178201c4cf243efe3f16ccee0a71b5deb2e 100644 (file)
@@ -55,7 +55,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/abi.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/reg.h"
index eb73de9b99e70b7a36385ec5c781a552158f10f4..8ef9892d15079ada4b9aa7851c819633a0871825 100644 (file)
@@ -53,7 +53,7 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/reg.h"
index 3d096e5f67e95700f5867a3812630c00e7fa97d9..188ad6eb779cbc60e39a8692ccfa42ec19783d4e 100644 (file)
@@ -29,7 +29,7 @@
 #include "config.h"
 #include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* additional functions and macros to generate code ***************************/
index ef30af384eced91c0d588da6b9c1de8aee28aa83..a5d0ffd03e0b78c6b8d35598c6853ce7be21e706 100644 (file)
@@ -44,7 +44,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/trap.h"
index af5f92fc1ab74d57fd369f933311801ca4ef17bf..6a83c92da84516d42e7cbce2bf635b4c12416333 100644 (file)
@@ -37,7 +37,7 @@
 #include "vm/global.h"
 #include "vm/vm.hpp"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* md_jit_method_patch_address *************************************************
index 657452687d8dc59bda442228165039dab9f173b6..9b17a67553b5ad655869ea91d58db36f1814da42 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "toolbox/bitvector.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #include "vm/jit/optimizing/graph.h"
 #include "vm/jit/optimizing/dominators.h"
index cca121315a344b1328a5d83dbce6e3abf5f2522c..b0565836fd03817f3fdd74f6779a9e5deb8d9123 100644 (file)
@@ -28,7 +28,7 @@
 #include "vm/class.h"
 #include "vm/classcache.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/optimizing/escape.h"
 
 #include <stdarg.h>
index bb7cf7bb34081930a20d5a18b10c35dc9be4bf95..4b9b9ec4e1097bc100e84650f24e5814c8f8bc2b 100644 (file)
@@ -24,7 +24,7 @@
 #ifndef _VM_JIT_OPTIMIZING_ESCAPE_H
 #define _VM_JIT_OPTIMIZING_ESCAPE_H
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/method.h"
 
 typedef enum {
index 99af008421ebd61726cc3b3622e014f402269289..fdde38c0c9fa9ff75a0b245758ccaf3f9e69cce7 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "toolbox/bitvector.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #include "vm/jit/optimizing/lsra.h"
 #include "vm/jit/optimizing/ssa.h"
index 2decc95532b2ca74cef8801230a06ef1b1480083..17889a45826abb9d4f8b66dae8c991040d398af2 100644 (file)
@@ -33,7 +33,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
 #include "vm/jit/show.h"
 
index f10ced797fbf7b59ad0531288a18b9ef4702a5fa..92c32f6c4dff5396af37e4213a1002f72903ec25 100644 (file)
 #define _IFCONV_H
 
 #include "config.h"
-#include "vm/types.h"
 
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/reg.h"
+#include <stdbool.h>
+
+#include "vm/jit/jit.hpp"
 
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool ifconv_static(jitdata *jd);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _IFCONV_H */
 
 
index c7fdb8d4d7495561b8f62364c2bf5e9f90b89d08..4bc5fc36b5ad9906d9437bca351565b784bb9d75 100644 (file)
@@ -38,7 +38,7 @@
 #include "vm/exceptions.hpp"
 #include "vm/string.hpp"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #include "vm/jit/optimizing/graph.h"
 #include "vm/jit/optimizing/lsra.h"
index b5a1b62bae86d153dc6c837191b81e1dea7a22ea..be33abe5fc1195123aa6d5fe6d734a9165609132 100644 (file)
@@ -41,7 +41,7 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/reg.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #include "vm/jit/optimizing/graph.h"
 #include "vm/jit/optimizing/lifetimes.h"
index 35ad152d909a28132a53ec65df1765c4acf330f0..466776097ad45a1dce02413a36b77bab4252a6be 100644 (file)
@@ -42,7 +42,7 @@
 #include "vm/options.h"
 #include "vm/string.hpp"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/methodtree.h"
 
index 3b302d809d16681c1feeb04ce21bcc93d651ab5b..520992b78bbfec6f1ee7e09aa059b2a3abbe7f85 100644 (file)
@@ -44,7 +44,7 @@
 #include "vm/string.hpp"
 
 #include "vm/jit/code.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #include "vm/jit/optimizing/recompile.h"
 
index bd43c368579dc04a8f6bb7cdaecb7c37c77e929c..2b135943f62a20f0473c95bf7340dfa646c8a183 100644 (file)
@@ -38,7 +38,7 @@
 #include "vm/types.h"
 
 #include "mm/memory.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* reorder_place_next_unplaced_block *******************************************
index d76b463519aed72456924fd1beac55f60998345c..fccc8e77e6b7dc4ea1852034fa36d853af03fab2 100644 (file)
@@ -1,9 +1,7 @@
-/* src/vm/reorder.h - basic block reordering
+/* src/vm/optimizing/reorder.h - basic block reordering
 
-   Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
 */
 
 
 #define _REORDER_H
 
 #include "config.h"
-#include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include <stdbool.h>
+
+#include "vm/jit/jit.hpp"
 
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool reorder(jitdata *jd);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _REORDER_H */
 
 
index 258fbf9f401a084d3deb0f64023a34c1378603aa..d3c9b82864ecbdc6612672eb9fbd03bf0821f310 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "vm/builtin.h"
 
-#include "vm/jit/jit.h" /* icmd_table */
+#include "vm/jit/jit.hpp" /* icmd_table */
 
 #include "vm/jit/ir/bytecode.h"
 
index 0246777420daef9c473e51785734a2d1d113e163..ad1038a853d2902b2a48a6aa5f18f49585d3250d 100644 (file)
@@ -33,7 +33,7 @@
 #include "toolbox/worklist.h"
 
 #include "vm/global.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #if 1
 #define printf(...) do { if (getenv("VERB")) printf(__VA_ARGS__); } while (0)
index 6dd7441ca78a4c0bf5379c4bc357fc22e8b350a1..4e891051b3f42f4844d9d85ebd75f7d892e18dc1 100644 (file)
@@ -38,7 +38,7 @@
    * Unify access to phi args.
 */
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/global.h"
 #include "mm/memory.h"
 #include "mm/dumpmemory.h"
index 40e04fd6681241d1083c3ef437b11986f6339783..88dd6a90495bce129fbbead02134d50d0ab4d094 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "vm/builtin.h"
 
-#include "vm/jit/jit.h" /* icmd_table */
+#include "vm/jit/jit.hpp" /* icmd_table */
 
 #include "vm/jit/optimizing/dominators.h"
 #include "vm/jit/optimizing/graph.h"
index b299fab262847d29ba1d6f19464af0803e2d95c2..26fe8ff83af7afea89f14c977b5a5cdf29279fda 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "vm/builtin.h"
 
-#include "vm/jit/jit.h" /* icmd_table */
+#include "vm/jit/jit.hpp" /* icmd_table */
 
 #include "vm/jit/optimizing/dominators.h"
 #include "vm/jit/optimizing/graph.h"
index f85b999d2b1f11c2705ba4f7dc91c697608a3e6d..e616f3cf55f5440ff3cac8bb9d5a27d0577fefc4 100644 (file)
@@ -54,7 +54,7 @@
 #include "vm/suck.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/parse.h"
 #include "vm/jit/loop/loop.h"
 
index 55917d6a27db984ffbef144c7c108d196ad0699d..69bd17eb50a6309785bc2a829ee091cfb81a0307 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/parse.h - parser header
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Author:  Christian Thalinger
-            Edwin Steiner
-
 */
 
 
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool parse(jitdata *jd);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _PARSE_H */
 
 
index c6e2da2c79ac3018a8d6c199b281258c7be34425..816052c9f3cd48c3ef8c8a1083dc52f631b5b87a 100644 (file)
@@ -47,7 +47,7 @@
 
 #include "vm/jit/code.h"
 #include "vm/jit/disass.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.h"
 
 
index 9beaae392312d84b98d6d3fb4cbc30a984572b50..6ca4f58cf2950a215af004b2032a2ddaf5cc778a 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "vm/global.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* patchref_t ******************************************************************
index f8d36f10cd03a0181785ebd35e650a6dd9c62bf7..8b22847c676c947551a2e08ec61866b010718207 100644 (file)
@@ -56,7 +56,7 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/parse.h"
index c1c0541293964adcfbd8506e91c896ea013facd8..d43c38ccd20ac075e59bd8adcaa49464067c9bca 100644 (file)
@@ -32,7 +32,7 @@
 #include "md-abi.h"
 
 #include "vm/global.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
 
 
index 17cb85c1ae77355ad7e1d6743c8dd8bbf73b04ca..21f03e35a90d3de28743ae77128684a86c96eb1c 100644 (file)
@@ -45,7 +45,7 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/replace.h"
 #include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
index 80257ab60cc5e958d33c29123feec1cf6c70ad0d..3595f407a4c2688c48b44d5e280a53e974c7329f 100644 (file)
@@ -37,7 +37,7 @@
 #include "vm/global.h"
 #include "vm/vm.hpp"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* md_init *********************************************************************
index aac1b5707e2d75fc69f6171c4842734ca4691896..211082c893ccd62db28cbc5eabb162e2c00ed053 100644 (file)
@@ -57,7 +57,7 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.h"
index 6f7f6fcb7b0a021b0252a745072584c69645588e..34a710bcb84a30a888e7418b0c7165198f980be6 100644 (file)
@@ -32,7 +32,7 @@
 #include "md-abi.h"
 
 #include "vm/global.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
 
 
index 26f2147600a0ede5786f1cada4d0c23c45be3a3f..088eeb75040ce1feda90c2bb74cc47dcf6a24f59 100644 (file)
@@ -42,7 +42,7 @@
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
 
index 842937ca3291b323200efc483da1aa2c45198f70..15b564227e38b010872290989fd36e2874bfdd83 100644 (file)
@@ -39,7 +39,7 @@
 
 #include "vm/global.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/trap.h"
 
 
index 992f8439d5c53627c591c37475ee8ff0fb19f3e8..b70509f86130e849b1ef14677104dc89303e045c 100644 (file)
@@ -37,7 +37,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* md_stacktrace_get_returnaddress *********************************************
index 56a44d4294751dac3ba81bd1636fc663a4dcea8d..5d63784134e088fbb85f8b99120d5d29cc60bf47 100644 (file)
@@ -26,7 +26,7 @@
 #define _VM_JIT_PYTHON_H
 #if defined(ENABLE_PYTHON)
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 void pythonpass_init();
 void pythonpass_cleanup();
index 6bb12627721797981f24a760441b74b9e77c54a2..3efd2b1ef115ea4f5824ec39ca6bbb95eefd0be6 100644 (file)
@@ -37,7 +37,7 @@ typedef struct registerdata registerdata;
 
 #include "arch.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/verify/typeinfo.h"
 
 
index dea13b1ed821ff41bddc65c387ed80f5c7dfbfeb..8708e320c4be798838001880749ef99d05816466 100644 (file)
@@ -55,7 +55,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/disass.h"
 #include "vm/jit/executionstate.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/show.h"
index 76cf0819be547cc793571be0b11b254e1946eeb1..e27c6ce68f64b2326ea259c98e2ef9984b74dff3 100644 (file)
@@ -239,6 +239,10 @@ struct sourcestate_t {
 
 /*** prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool replace_create_replacement_points(jitdata *jd);
 void replace_free_replacement_points(codeinfo *code);
 
@@ -263,6 +267,10 @@ void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert);
 
 #endif /* defined(ENABLE_REPLACEMENT) */
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _REPLACE_H */
 
 
index f7290916181c97651f064c9a720273c772c431b7..e10a1239a267bc8ab14a543a4be8da81ff41a623 100644 (file)
@@ -58,7 +58,7 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/parse.h"
index 33e945f89e8e1042d2eb7e9e4fbe56774e796745..3e5262d459631f77cad2ac7bf499570b7a9d1f61 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* MCODECHECK(icnt) */
index 00467f338d486b82f1af6986c5b03f39cbd472e6..e395099dc077e9123a0fe3cf861017998e1a6e65 100644 (file)
@@ -45,7 +45,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/trace.hpp"
index 7f9017ca4fab272b70e198f8e2143e78eb2021ec..95ad22ac5d0e1e6be847fa5f99c2d56d075a872f 100644 (file)
@@ -29,7 +29,7 @@
 #include "vm/global.h"
 #include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/stack.h"
 
 #include "vm/jit/s390/md-abi.h"
index 55e3592c1f13d68bd2ecec751725f6ca36124184..bcaa323818ab92826bb61c8e796a5f0c7840cf48 100644 (file)
@@ -41,7 +41,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/abi.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/show.h"
 #include "vm/jit/disass.h"
 #include "vm/jit/stack.h"
index 024d2233e1d064f120c4140412ac75fab79784bf..8e0c4c720992293639fead465b9cb0bf650383a7 100644 (file)
@@ -33,7 +33,7 @@ extern "C" {
 #include "config.h"
 #include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* compiler stage defines *****************************************************/
index fc5cba71fcaa7bcd8de657783632883811ec80ec..0712c8c8c32b99a432cdc6e3e8b88b1c10924dd9 100644 (file)
@@ -53,7 +53,7 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher.h"
index 749650670f06c4fa3fb477152eb0d5d67948670b..b64cf4fc656ed4f6bf991b7ae42fee51ee512caf 100644 (file)
@@ -29,7 +29,7 @@
 #include "config.h"
 #include "vm/types.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 #include "md-abi.h" /* for INT_NATARG_CNT */
 
index db4b4ba05f5bb99796fb2ca354f4896f8b909a3d..9fc43a4fa95076df9c59830a6437b772b94c2216 100644 (file)
@@ -43,7 +43,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/replace.h"
 
 #include "vm/jit/sparc64/solaris/macro_rename.h"
index ab2b30708acd7ec9b540e205b177e61767d82f33..31b64b9f2e56eb868690dba2e8e35501a6e9e398 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* assembler function prototypes **********************************************/
index 4ecac4876426e7fe74d17cd2ae4e1f63edb3ee48..71998ccde71fe7a196c8916ebd288c7af635acc1 100644 (file)
@@ -61,7 +61,7 @@
 # include "vm/jit/disass.h"
 #endif
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/stack.h"
 
 #if 0
index 4663cc034c585a40ca81119cee09e9bc7e44f372..803d2db11d83ed7ae3d5c3e5c561e6554613e1bd 100644 (file)
@@ -39,7 +39,7 @@ typedef struct stackelement_t stackelement_t;
 
 #include "vm/global.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
 
 
@@ -161,12 +161,20 @@ struct stackelement_t {
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 bool stack_init(void);
 
 bool stack_analyse(jitdata *jd);
 
 void stack_javalocals_store(instruction *iptr, s4 *javalocals);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _STACK_H */
 
 
index b4ecad73f84b4203115a0fefccb5bdd80bab0f6c..0adbe4534a7a7aaead11a28e9353269455869c7a 100644 (file)
@@ -41,7 +41,7 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/disass.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/show.h"
 #include "vm/jit/stubs.hpp"
 
index c6f441d5cc5d4b3debaab66b366ce8106486fbbf..0b8b1bca6f5ee6ca19df7b76031e048c0e501d2a 100644 (file)
@@ -44,7 +44,7 @@
 
 #include "vm/jit/code.h"
 #include "vm/jit/disass.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/methodtree.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
index fd3f6ab6fe631fdd42b242a38f639564314a3d1b..226113f165b1b75dcb179c3bbdd2cdc0a9ad7d97 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <assert.h>
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /****************************************************************************/
index 1cfeba69da3483b2484e7b0e57817c183671a10c..3bda890361dce6e68bbd31de14ba72c89f0d7010 100644 (file)
@@ -46,7 +46,7 @@
 #include "vm/resolve.h"
 #include "vm/vm.hpp"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/show.h"
 #include "vm/jit/parse.h"
 
index 530a5e1e2870c45bcacccd9adfd4841c1c5f9dcf..6684ac9393229ebe3cb47dad02a8fc5b17d7d128 100644 (file)
@@ -36,7 +36,7 @@
 #include "config.h"
 
 #include "vm/global.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* function prototypes ********************************************************/
index afe2fb62108170213373322bb9e052f0a99189ad..c18c1eb536fb1ba58bf84398de0d08185efd7510 100644 (file)
@@ -158,7 +158,7 @@ error reporting.
 #include "vm/primitive.hpp"
 #include "vm/resolve.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/parse.h"
 #include "vm/jit/show.h"
 
index 01492ea53e041e4314d43d9caaea139a5b253509..dac58ca419cd757c977cf3182d0663e6c9bb6e7b 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/verify/typecheck.h - type checking header
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-
 */
 
 
 #include "config.h"
 
 #include "vm/global.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if defined(ENABLE_VERIFIER)
 bool typecheck(jitdata *jd);
 bool typecheck_stackbased(jitdata *jd);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _TYPECHECK_H */
 
 
index b39ca9a61716592f1f56c168bb61d9c57eccc151..78407dbbd863b28ac0c1d4c72d1bbb0084a17a73 100644 (file)
@@ -41,7 +41,7 @@
 #include "vm/primitive.hpp"
 #include "vm/resolve.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/verify/typeinfo.h"
 
 
index 7be6ad90058875f0819472d3c45ae5594149a139..623978d42c2ebedc8a8e21b0c05e630bc9fea2db 100644 (file)
@@ -60,7 +60,7 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/parse.h"
index 452992ce1cd089151a4570e80b302e917d20b601..53e005f2cf60d4beaaae2b7e379ef0177641a8e9 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "vm/jit/x86_64/emit.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* additional functions and macros to generate code ***************************/
index 92bf938ab92ce85e360fa6e46c0b711bf6d6f3f6..240be04005a55c83cdbd147b461f184b4a318f16 100644 (file)
@@ -44,7 +44,7 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/trace.hpp"
index 34bb44d055f219a0e1007c07b77387609160ddf6..d68434daae06791f0a0f11467e9f9fa2b02fb336 100644 (file)
@@ -32,7 +32,7 @@
 #include "vm/types.h"
 
 #include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* macros to create code ******************************************************/
index d0ef903056b2c0a7fdbfa0b999ea69f7f1390982..fd248a596b4743b2fee491ed2acc697a56b58653 100644 (file)
@@ -32,7 +32,7 @@
 #include "vm/global.h"
 
 #include "vm/jit/abi.h"
-#include "vm/jit/jit.h" /* for REG_* (maybe can be removed) */
+#include "vm/jit/jit.hpp" /* for REG_* (maybe can be removed) */
 #include "vm/jit/stack.h"
 
 
index 75a61687a8a2e4126f4d47d1a4ea1c557f4f2341..1ffd5b7c49491db9ab4227877bc78f7282472013 100644 (file)
@@ -34,7 +34,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/codegen-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 
 
 /* md_init *********************************************************************
index 7564a136773c3e1d0307a364428bbae665c230de..46c403c228d22012c4c56dfd1368be418a20081c 100644 (file)
@@ -72,6 +72,8 @@
 # include "vm/zip.h"
 #endif
 
+#include "vm/jit/stubs.hpp"
+
 #if defined(ENABLE_JVMTI)
 # include "native/jvmti/cacaodbg.h"
 #endif
index cd4d5c5416052ecd63b2a8c9f3d9cc4d1605443a..e09ae3157fb40cdedda7e182a1c2404e6874833c 100644 (file)
@@ -43,7 +43,7 @@
 #include "vm/primitive.hpp"
 #include "vm/resolve.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/verify/typeinfo.h"
 
 
index 897c9fead4443e3f9de471168ec5cd647dfd8590..bf88132432128eec790c7e891d6cdac1f4413810 100644 (file)
@@ -43,7 +43,7 @@ typedef struct unresolved_subtype_set unresolved_subtype_set;
 #include "vm/method.h"
 #include "vm/references.h"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
 
 #include "vm/jit/ir/instruction.hpp"
index 15142d00d7f3197c8d310464041a5b691cd98898..484fba15c27fd800151b073896b17f50f093b4d4 100644 (file)
@@ -229,6 +229,10 @@ extern s4 count_schedule_critical_path;
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 s8 getcputime(void);
 
 void loadingtime_start(void);
@@ -249,6 +253,10 @@ void compiledinvokation(void);
 void jnicallXmethodnvokation(void);
 void jniinvokation(void);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _STATISTICS_H */
 
 
index 5bdaf1ea5f04219e4fd1710939c33b83e73beb09..a7636ccb85db4dd89b7c9ad46d9da6cab773ec47 100644 (file)
@@ -89,7 +89,7 @@
 # include "vm/jit/disass.h"
 #endif
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/methodtree.h"
 
 #if defined(ENABLE_PROFILING)