* src/vm/jit/codegen-common.c: Moved to .cpp.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Tue, 26 Aug 2008 17:47:01 +0000 (13:47 -0400)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Tue, 26 Aug 2008 17:47:01 +0000 (13:47 -0400)
* src/vm/jit/codegen-common.h: Likewise.
* src/vm/jit/codegen-common.cpp: New file.
* src/vm/jit/codegen-common.hpp: Likewise.
* src/vm/jit/Makefile.am,
src/vm/jit/allocator/liveness.c,
src/vm/jit/allocator/simplereg.h,
src/vm/jit/alpha/codegen.c,
src/vm/jit/alpha/md.h,
src/vm/jit/arm/codegen.c,
src/vm/jit/arm/md.h,
src/vm/jit/code.c,
src/vm/jit/dseg.c,
src/vm/jit/dseg.h,
src/vm/jit/emit-common.hpp,
src/vm/jit/exceptiontable.h,
src/vm/jit/i386/codegen.c,
src/vm/jit/i386/emit.h,
src/vm/jit/i386/md.h,
src/vm/jit/intrp/codegen.c,
src/vm/jit/intrp/intrp.h,
src/vm/jit/jit.cpp,
src/vm/jit/jit.hpp,
src/vm/jit/linenumbertable.c,
src/vm/jit/linenumbertable.h,
src/vm/jit/m68k/codegen.c,
src/vm/jit/m68k/emit.h,
src/vm/jit/m68k/md.h,
src/vm/jit/mips/codegen.c,
src/vm/jit/mips/irix/md-os.c,
src/vm/jit/optimizing/ifconv.c,
src/vm/jit/parse.h,
src/vm/jit/patcher-common.h,
src/vm/jit/powerpc/codegen.c,
src/vm/jit/powerpc/emit.c,
src/vm/jit/powerpc/md.h,
src/vm/jit/powerpc64/codegen.c,
src/vm/jit/s390/codegen.c,
src/vm/jit/s390/emit.c,
src/vm/jit/s390/md.c,
src/vm/jit/s390/md.h,
src/vm/jit/sparc64/codegen.c,
src/vm/jit/sparc64/md.c,
src/vm/jit/sparc64/md.h,
src/vm/jit/stack.c,
src/vm/jit/stacktrace.cpp,
src/vm/jit/stubs.cpp,
src/vm/jit/trace.cpp,
src/vm/jit/x86_64/codegen.c,
src/vm/jit/x86_64/emit.c,
src/vm/jit/x86_64/emit.h,
src/vm/jit/x86_64/md.c,
src/vm/jit/x86_64/md.h: Related changes.

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

53 files changed:
src/vm/jit/Makefile.am
src/vm/jit/allocator/liveness.c
src/vm/jit/allocator/simplereg.h
src/vm/jit/alpha/codegen.c
src/vm/jit/alpha/md.h
src/vm/jit/arm/codegen.c
src/vm/jit/arm/md.h
src/vm/jit/code.c
src/vm/jit/codegen-common.c [deleted file]
src/vm/jit/codegen-common.cpp [new file with mode: 0644]
src/vm/jit/codegen-common.h [deleted file]
src/vm/jit/codegen-common.hpp [new file with mode: 0644]
src/vm/jit/dseg.c
src/vm/jit/dseg.h
src/vm/jit/emit-common.hpp
src/vm/jit/exceptiontable.h
src/vm/jit/i386/codegen.c
src/vm/jit/i386/emit.h
src/vm/jit/i386/md.h
src/vm/jit/intrp/codegen.c
src/vm/jit/intrp/intrp.h
src/vm/jit/jit.cpp
src/vm/jit/jit.hpp
src/vm/jit/linenumbertable.c
src/vm/jit/linenumbertable.h
src/vm/jit/m68k/codegen.c
src/vm/jit/m68k/emit.h
src/vm/jit/m68k/md.h
src/vm/jit/mips/codegen.c
src/vm/jit/mips/irix/md-os.c
src/vm/jit/optimizing/ifconv.c
src/vm/jit/parse.h
src/vm/jit/patcher-common.h
src/vm/jit/powerpc/codegen.c
src/vm/jit/powerpc/emit.c
src/vm/jit/powerpc/md.h
src/vm/jit/powerpc64/codegen.c
src/vm/jit/s390/codegen.c
src/vm/jit/s390/emit.c
src/vm/jit/s390/md.c
src/vm/jit/s390/md.h
src/vm/jit/sparc64/codegen.c
src/vm/jit/sparc64/md.c
src/vm/jit/sparc64/md.h
src/vm/jit/stack.c
src/vm/jit/stacktrace.cpp
src/vm/jit/stubs.cpp
src/vm/jit/trace.cpp
src/vm/jit/x86_64/codegen.c
src/vm/jit/x86_64/emit.c
src/vm/jit/x86_64/emit.h
src/vm/jit/x86_64/md.c
src/vm/jit/x86_64/md.h

index ca4879870cd7d3885861fdd940d171391db22be1..79390c666022a2fe807a9fd864d4dbfe31bf9fe4 100644 (file)
@@ -155,8 +155,8 @@ libjit_la_SOURCES = \
        builtintable.inc \
        code.c \
        code.h \
-       codegen-common.c \
-       codegen-common.h \
+       codegen-common.cpp \
+       codegen-common.hpp \
        disass.h \
        $(DISASS_SOURCES) \
        dseg.c \
index 0b638f2bb0b2fb1ff6a250a509acebb790edc86d..7ceaea22813165d80a9a2593f0337e4fe204eef9 100644 (file)
@@ -40,7 +40,7 @@
 #include "vm/global.h"
 #include "vm/method.h"
 #include "vm/resolve.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/allocator/lsra.h"
 #include "vm/jit/allocator/liveness.h"
index 1e56a8225ca085bdd4ac9f2a31b5a1be2e7527c2..9ca4373a65fda07b4c20debf2ed17e45cfdce5db 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "arch.h"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/inline/inline.h"
 
index ef63f752e25f9c676a06da877faf905d05336a33..9045721080fdde6ce306a448e44887eac1443dde 100644 (file)
@@ -52,7 +52,7 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
index da186e3c0560a7efcf4c197104056e0f82ed8573..e939d3803677cc45c07092b70cbb23d87038db05 100644 (file)
@@ -37,7 +37,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* global variables ***********************************************************/
index caf895697f69f249d82e36d1342cdb4057f264ff..e2fc7f95f163982f9aa901ba490ae86503779b2e 100644 (file)
@@ -51,7 +51,7 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
index 7627d1010dcfe982b53912877091f120d169ab66..9ce156470118f432c10e3919b93da57270615ef0 100644 (file)
@@ -34,7 +34,7 @@
 #include "vm/types.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* md_stacktrace_get_returnaddress *********************************************
index 02c3a2d2fa594a39776796e745104a8de99f1a6d..c277cb999209638c87b51e685e0b5f663ae02db7 100644 (file)
@@ -36,7 +36,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/methodtree.h"
 
diff --git a/src/vm/jit/codegen-common.c b/src/vm/jit/codegen-common.c
deleted file mode 100644 (file)
index a5f830b..0000000
+++ /dev/null
@@ -1,1086 +0,0 @@
-/* src/vm/jit/codegen-common.c - architecture independent code generator stuff
-
-   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.
-
-   All functions assume the following code area / data area layout:
-
-   +-----------+
-   |           |
-   | code area | code area grows to higher addresses
-   |           |
-   +-----------+ <-- start of procedure
-   |           |
-   | data area | data area grows to lower addresses
-   |           |
-   +-----------+
-
-   The functions first write into a temporary code/data area allocated by
-   "codegen_init". "codegen_finish" copies the code and data area into permanent
-   memory. All functions writing values into the data area return the offset
-   relative the begin of the code area (start of procedure).   
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <string.h>
-
-#include "vm/types.h"
-
-#include "codegen.h"
-#include "md.h"
-#include "md-abi.h"
-
-#include "mm/memory.h"
-
-#include "toolbox/avl.h"
-#include "toolbox/list.h"
-#include "toolbox/logging.h"
-
-#include "native/llni.h"
-#include "native/localref.h"
-#include "native/native.h"
-
-#include "threads/thread.hpp"
-
-#include "vm/jit/builtin.hpp"
-#include "vm/exceptions.hpp"
-#include "vm/method.h"
-#include "vm/options.h"
-#include "vm/string.hpp"
-
-# include "vm/statistics.h"
-
-
-#include "vm/jit/abi.h"
-#include "vm/jit/asmpart.h"
-#include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
-
-#if defined(ENABLE_DISASSEMBLER)
-# include "vm/jit/disass.h"
-#endif
-
-#include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.hpp"
-#include "vm/jit/jit.hpp"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/methodheader.h"
-#include "vm/jit/methodtree.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/replace.hpp"
-#if defined(ENABLE_SSA)
-# include "vm/jit/optimizing/lsra.h"
-# include "vm/jit/optimizing/ssa.h"
-#endif
-#include "vm/jit/stacktrace.hpp"
-#include "vm/jit/trace.hpp"
-
-#if defined(ENABLE_INTRP)
-#include "vm/jit/intrp/intrp.h"
-#endif
-
-#if defined(ENABLE_VMLOG)
-#include <vmlog_cacao.h>
-#endif
-
-#include "show.h"
-
-
-/* codegen_init ****************************************************************
-
-   TODO
-
-*******************************************************************************/
-
-void codegen_init(void)
-{
-}
-
-
-/* codegen_setup ***************************************************************
-
-   Allocates and initialises code area, data area and references.
-
-*******************************************************************************/
-
-void codegen_setup(jitdata *jd)
-{
-       methodinfo  *m;
-       codegendata *cd;
-
-       /* get required compiler data */
-
-       m  = jd->m;
-       cd = jd->cd;
-
-       /* initialize members */
-
-       cd->flags        = 0;
-
-       cd->mcodebase    = DMNEW(u1, MCODEINITSIZE);
-       cd->mcodeend     = cd->mcodebase + MCODEINITSIZE;
-       cd->mcodesize    = MCODEINITSIZE;
-
-       /* initialize mcode variables */
-
-       cd->mcodeptr     = cd->mcodebase;
-       cd->lastmcodeptr = cd->mcodebase;
-
-#if defined(ENABLE_INTRP)
-       /* native dynamic superinstructions variables */
-
-       if (opt_intrp) {
-               cd->ncodebase = DMNEW(u1, NCODEINITSIZE);
-               cd->ncodesize = NCODEINITSIZE;
-
-               /* initialize ncode variables */
-       
-               cd->ncodeptr = cd->ncodebase;
-
-               cd->lastinstwithoutdispatch = ~0; /* no inst without dispatch */
-               cd->superstarts = NULL;
-       }
-#endif
-
-       cd->dseg           = NULL;
-       cd->dseglen        = 0;
-
-       cd->jumpreferences = NULL;
-
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
-       cd->datareferences = NULL;
-#endif
-
-       cd->brancheslabel  = list_create_dump(OFFSET(branch_label_ref_t, linkage));
-       cd->linenumbers    = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage));
-}
-
-
-/* codegen_reset ***************************************************************
-
-   Resets the codegen data structure so we can recompile the method.
-
-*******************************************************************************/
-
-static void codegen_reset(jitdata *jd)
-{
-       codeinfo    *code;
-       codegendata *cd;
-       basicblock  *bptr;
-
-       /* get required compiler data */
-
-       code = jd->code;
-       cd   = jd->cd;
-
-       /* reset error flag */
-
-       cd->flags          &= ~CODEGENDATA_FLAG_ERROR;
-
-       /* reset some members, we reuse the code memory already allocated
-          as this should have almost the correct size */
-
-       cd->mcodeptr        = cd->mcodebase;
-       cd->lastmcodeptr    = cd->mcodebase;
-
-       cd->dseg            = NULL;
-       cd->dseglen         = 0;
-
-       cd->jumpreferences  = NULL;
-
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
-       cd->datareferences  = NULL;
-#endif
-
-       cd->brancheslabel   = list_create_dump(OFFSET(branch_label_ref_t, linkage));
-       cd->linenumbers     = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage));
-       
-       /* We need to clear the mpc and the branch references from all
-          basic blocks as they will definitely change. */
-
-       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
-               bptr->mpc        = -1;
-               bptr->branchrefs = NULL;
-       }
-
-       /* We need to clear all the patcher references from the codeinfo
-          since they all will be regenerated */
-
-       patcher_list_reset(code);
-
-#if defined(ENABLE_REPLACEMENT)
-       code->rplpoints     = NULL;
-       code->rplpointcount = 0;
-       code->regalloc      = NULL;
-       code->regalloccount = 0;
-       code->globalcount   = 0;
-#endif
-}
-
-
-/* codegen_generate ************************************************************
-
-   Generates the code for the currently compiled method.
-
-*******************************************************************************/
-
-bool codegen_generate(jitdata *jd)
-{
-       codegendata *cd;
-
-       /* get required compiler data */
-
-       cd = jd->cd;
-
-       /* call the machine-dependent code generation function */
-
-       if (!codegen_emit(jd))
-               return false;
-
-       /* check for an error */
-
-       if (CODEGENDATA_HAS_FLAG_ERROR(cd)) {
-               /* check for long-branches flag, if it is set we recompile the
-                  method */
-
-#if !defined(NDEBUG)
-        if (compileverbose)
-            log_message_method("Re-generating code: ", jd->m);
-#endif
-
-               /* XXX maybe we should tag long-branches-methods for recompilation */
-
-               if (CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) {
-                       /* we have to reset the codegendata structure first */
-
-                       codegen_reset(jd);
-
-                       /* and restart the compiler run */
-
-                       if (!codegen_emit(jd))
-                               return false;
-               }
-               else {
-                       vm_abort("codegen_generate: unknown error occurred during codegen_emit: flags=%x\n", cd->flags);
-               }
-
-#if !defined(NDEBUG)
-        if (compileverbose)
-            log_message_method("Re-generating code done: ", jd->m);
-#endif
-       }
-
-       /* reallocate the memory and finish the code generation */
-
-       codegen_finish(jd);
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* codegen_close ***************************************************************
-
-   TODO
-
-*******************************************************************************/
-
-void codegen_close(void)
-{
-       /* TODO: release avl tree on i386 and x86_64 */
-}
-
-
-/* codegen_increase ************************************************************
-
-   Doubles code area.
-
-*******************************************************************************/
-
-void codegen_increase(codegendata *cd)
-{
-       u1 *oldmcodebase;
-
-       /* save old mcodebase pointer */
-
-       oldmcodebase = cd->mcodebase;
-
-       /* reallocate to new, doubled memory */
-
-       cd->mcodebase = DMREALLOC(cd->mcodebase,
-                                                         u1,
-                                                         cd->mcodesize,
-                                                         cd->mcodesize * 2);
-       cd->mcodesize *= 2;
-       cd->mcodeend   = cd->mcodebase + cd->mcodesize;
-
-       /* set new mcodeptr */
-
-       cd->mcodeptr = cd->mcodebase + (cd->mcodeptr - oldmcodebase);
-
-#if defined(__I386__) || defined(__MIPS__) || defined(__X86_64__) || defined(__M68K__) || defined(ENABLE_INTRP) \
- || defined(__SPARC_64__)
-       /* adjust the pointer to the last patcher position */
-
-       if (cd->lastmcodeptr != NULL)
-               cd->lastmcodeptr = cd->mcodebase + (cd->lastmcodeptr - oldmcodebase);
-#endif
-}
-
-
-/* codegen_ncode_increase ******************************************************
-
-   Doubles code area.
-
-*******************************************************************************/
-
-#if defined(ENABLE_INTRP)
-u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr)
-{
-       u1 *oldncodebase;
-
-       /* save old ncodebase pointer */
-
-       oldncodebase = cd->ncodebase;
-
-       /* reallocate to new, doubled memory */
-
-       cd->ncodebase = DMREALLOC(cd->ncodebase,
-                                                         u1,
-                                                         cd->ncodesize,
-                                                         cd->ncodesize * 2);
-       cd->ncodesize *= 2;
-
-       /* return the new ncodeptr */
-
-       return (cd->ncodebase + (ncodeptr - oldncodebase));
-}
-#endif
-
-
-/* codegen_add_branch_ref ******************************************************
-
-   Prepends an branch to the list.
-
-*******************************************************************************/
-
-void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options)
-{
-       branchref *br;
-       s4         branchmpc;
-
-       STATISTICS(count_branches_unresolved++);
-
-       /* calculate the mpc of the branch instruction */
-
-       branchmpc = cd->mcodeptr - cd->mcodebase;
-
-       br = DNEW(branchref);
-
-       br->branchmpc = branchmpc;
-       br->condition = condition;
-       br->reg       = reg;
-       br->options   = options;
-       br->next      = target->branchrefs;
-
-       target->branchrefs = br;
-}
-
-
-/* codegen_resolve_branchrefs **************************************************
-
-   Resolves and patches the branch references of a given basic block.
-
-*******************************************************************************/
-
-void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr)
-{
-       branchref *br;
-       u1        *mcodeptr;
-
-       /* Save the mcodeptr because in the branch emitting functions
-          we generate code somewhere inside already generated code,
-          but we're still in the actual code generation phase. */
-
-       mcodeptr = cd->mcodeptr;
-
-       /* just to make sure */
-
-       assert(bptr->mpc >= 0);
-
-       for (br = bptr->branchrefs; br != NULL; br = br->next) {
-               /* temporary set the mcodeptr */
-
-               cd->mcodeptr = cd->mcodebase + br->branchmpc;
-
-               /* emit_bccz and emit_branch emit the correct code, even if we
-                  pass condition == BRANCH_UNCONDITIONAL or reg == -1. */
-
-               emit_bccz(cd, bptr, br->condition, br->reg, br->options);
-       }
-
-       /* restore mcodeptr */
-
-       cd->mcodeptr = mcodeptr;
-}
-
-
-/* codegen_branch_label_add ****************************************************
-
-   Append an branch to the label-branch list.
-
-*******************************************************************************/
-
-void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options)
-{
-       list_t             *l;
-       branch_label_ref_t *br;
-       s4                  mpc;
-
-       /* Get the label list. */
-
-       l = cd->brancheslabel;
-       
-       /* calculate the current mpc */
-
-       mpc = cd->mcodeptr - cd->mcodebase;
-
-       br = DNEW(branch_label_ref_t);
-
-       br->mpc       = mpc;
-       br->label     = label;
-       br->condition = condition;
-       br->reg       = reg;
-       br->options   = options;
-
-       /* Add the branch to the list. */
-
-       list_add_last(l, br);
-}
-
-
-/* codegen_set_replacement_point_notrap ****************************************
-
-   Record the position of a non-trappable replacement point.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-#if !defined(NDEBUG)
-void codegen_set_replacement_point_notrap(codegendata *cd, s4 type)
-#else
-void codegen_set_replacement_point_notrap(codegendata *cd)
-#endif
-{
-       assert(cd->replacementpoint);
-       assert(cd->replacementpoint->type == type);
-       assert(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP);
-
-       cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
-
-       cd->replacementpoint++;
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
-/* codegen_set_replacement_point ***********************************************
-
-   Record the position of a trappable replacement point.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-#if !defined(NDEBUG)
-void codegen_set_replacement_point(codegendata *cd, s4 type)
-#else
-void codegen_set_replacement_point(codegendata *cd)
-#endif
-{
-       assert(cd->replacementpoint);
-       assert(cd->replacementpoint->type == type);
-       assert(!(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP));
-
-       cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
-
-       cd->replacementpoint++;
-
-#if !defined(NDEBUG)
-       /* XXX actually we should use an own REPLACEMENT_NOPS here! */
-       if (opt_TestReplacement)
-               PATCHER_NOPS;
-#endif
-
-       /* XXX assert(cd->lastmcodeptr <= cd->mcodeptr); */
-
-       cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE;
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
-/* codegen_finish **************************************************************
-
-   Finishes the code generation. A new memory, large enough for both
-   data and code, is allocated and data and code are copied together
-   to their final layout, unresolved jumps are resolved, ...
-
-*******************************************************************************/
-
-void codegen_finish(jitdata *jd)
-{
-       codeinfo    *code;
-       codegendata *cd;
-       s4           mcodelen;
-#if defined(ENABLE_INTRP)
-       s4           ncodelen;
-#endif
-       s4           alignedmcodelen;
-       jumpref     *jr;
-       u1          *epoint;
-       s4           alignedlen;
-
-       /* get required compiler data */
-
-       code = jd->code;
-       cd   = jd->cd;
-
-       /* prevent compiler warning */
-
-#if defined(ENABLE_INTRP)
-       ncodelen = 0;
-#endif
-
-       /* calculate the code length */
-
-       mcodelen = (s4) (cd->mcodeptr - cd->mcodebase);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat) {
-               count_code_len += mcodelen;
-               count_data_len += cd->dseglen;
-       }
-#endif
-
-       alignedmcodelen = MEMORY_ALIGN(mcodelen, MAX_ALIGN);
-
-#if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               ncodelen = cd->ncodeptr - cd->ncodebase;
-       else {
-               ncodelen = 0; /* avoid compiler warning */
-       }
-#endif
-
-       cd->dseglen = MEMORY_ALIGN(cd->dseglen, MAX_ALIGN);
-       alignedlen = alignedmcodelen + cd->dseglen;
-
-#if defined(ENABLE_INTRP)
-       if (opt_intrp) {
-               alignedlen += ncodelen;
-       }
-#endif
-
-       /* allocate new memory */
-
-       code->mcodelength = mcodelen + cd->dseglen;
-       code->mcode       = CNEW(u1, alignedlen);
-
-       /* set the entrypoint of the method */
-       
-       assert(code->entrypoint == NULL);
-       code->entrypoint = epoint = (code->mcode + cd->dseglen);
-
-       /* fill the data segment (code->entrypoint must already be set!) */
-
-       dseg_finish(jd);
-
-       /* copy code to the new location */
-
-       MCOPY((void *) code->entrypoint, cd->mcodebase, u1, mcodelen);
-
-#if defined(ENABLE_INTRP)
-       /* relocate native dynamic superinstruction code (if any) */
-
-       if (opt_intrp) {
-               cd->mcodebase = code->entrypoint;
-
-               if (ncodelen > 0) {
-                       u1 *ncodebase = code->mcode + cd->dseglen + alignedmcodelen;
-
-                       MCOPY((void *) ncodebase, cd->ncodebase, u1, ncodelen);
-
-                       /* flush the instruction and data caches */
-
-                       md_cacheflush(ncodebase, ncodelen);
-
-                       /* set some cd variables for dynamic_super_rerwite */
-
-                       cd->ncodebase = ncodebase;
-
-               } else {
-                       cd->ncodebase = NULL;
-               }
-
-               dynamic_super_rewrite(cd);
-       }
-#endif
-
-       /* Create the exception table. */
-
-       exceptiontable_create(jd);
-
-       /* Create the linenumber table. */
-
-       linenumbertable_create(jd);
-
-       /* jump table resolving */
-
-       for (jr = cd->jumpreferences; jr != NULL; jr = jr->next)
-               *((functionptr *) ((ptrint) epoint + jr->tablepos)) =
-                       (functionptr) ((ptrint) epoint + (ptrint) jr->target->mpc);
-
-       /* patcher resolving */
-
-       patcher_resolve(jd);
-
-#if defined(ENABLE_REPLACEMENT)
-       /* replacement point resolving */
-       {
-               int i;
-               rplpoint *rp;
-
-               rp = code->rplpoints;
-               for (i=0; i<code->rplpointcount; ++i, ++rp) {
-                       rp->pc = (u1*) ((ptrint) epoint + (ptrint) rp->pc);
-               }
-       }
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-       /* Insert method into methodtree to find the entrypoint. */
-
-       methodtree_insert(code->entrypoint, code->entrypoint + mcodelen);
-
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
-       /* resolve data segment references */
-
-       dseg_resolve_datareferences(jd);
-#endif
-
-       /* flush the instruction and data caches */
-
-       md_cacheflush(code->mcode, code->mcodelength);
-}
-
-
-/* codegen_start_native_call ***************************************************
-
-   Prepares the stuff required for a native (JNI) function call:
-
-   - adds a stackframe info structure to the chain, for stacktraces
-   - prepares the local references table on the stack
-
-   The layout of the native stub stackframe should look like this:
-
-   +---------------------------+ <- java SP (of parent Java function)
-   | return address            |
-   +---------------------------+ <- data SP
-   |                           |
-   | stackframe info structure |
-   |                           |
-   +---------------------------+
-   |                           |
-   | local references table    |
-   |                           |
-   +---------------------------+
-   |                           |
-   | saved registers (if any)  |
-   |                           |
-   +---------------------------+
-   |                           |
-   | arguments (if any)        |
-   |                           |
-   +---------------------------+ <- current SP (native stub)
-
-*******************************************************************************/
-
-java_handle_t *codegen_start_native_call(u1 *sp, u1 *pv)
-{
-       stackframeinfo_t *sfi;
-       localref_table   *lrt;
-       methodinfo       *m;
-       int32_t           framesize;
-
-       uint8_t  *datasp;
-       uint8_t  *javasp;
-       uint64_t *arg_regs;
-       uint64_t *arg_stack;
-
-       STATISTICS(count_calls_java_to_native++);
-
-       /* Get the methodinfo. */
-
-       m = code_get_methodinfo_for_pv(pv);
-
-       assert(m);
-
-       framesize = *((int32_t *) (pv + FrameSize));
-
-       assert(framesize >= sizeof(stackframeinfo_t) + sizeof(localref_table));
-
-       /* calculate needed values */
-
-#if defined(__ALPHA__) || defined(__ARM__)
-       datasp    = sp + framesize - SIZEOF_VOID_P;
-       javasp    = sp + framesize;
-       arg_regs  = (uint64_t *) sp;
-       arg_stack = (uint64_t *) javasp;
-#elif defined(__MIPS__)
-       /* MIPS always uses 8 bytes to store the RA */
-       datasp    = sp + framesize - 8;
-       javasp    = sp + framesize;
-#elif defined(__S390__)
-       datasp    = sp + framesize - 8;
-       javasp    = sp + framesize;
-       arg_regs  = (uint64_t *) (sp + 96);
-       arg_stack = (uint64_t *) javasp;
-#elif defined(__I386__) || defined(__M68K__) || defined(__X86_64__)
-       datasp    = sp + framesize;
-       javasp    = sp + framesize + SIZEOF_VOID_P;
-       arg_regs  = (uint64_t *) sp;
-       arg_stack = (uint64_t *) javasp;
-#elif defined(__POWERPC__)
-       datasp    = sp + framesize;
-       javasp    = sp + framesize;
-       arg_regs  = (uint64_t *) (sp + LA_SIZE + 4 * SIZEOF_VOID_P);
-       arg_stack = (uint64_t *) javasp;
-#elif defined(__POWERPC64__)
-       datasp    = sp + framesize;
-       javasp    = sp + framesize;
-       arg_regs  = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 4 * SIZEOF_VOID_P);
-       arg_stack = (uint64_t *) javasp;
-#else
-       /* XXX is was unable to do this port for SPARC64, sorry. (-michi) */
-       /* XXX maybe we need to pass the RA as argument there */
-       vm_abort("codegen_start_native_call: unsupported architecture");
-#endif
-
-       /* get data structures from stack */
-
-       sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t));
-       lrt = (localref_table *)   (datasp - sizeof(stackframeinfo_t) - 
-                                                               sizeof(localref_table));
-
-#if defined(ENABLE_JNI)
-       /* add current JNI local references table to this thread */
-
-       localref_table_add(lrt);
-#endif
-
-#if !defined(NDEBUG)
-# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
-       /* print the call-trace if necesarry */
-       /* BEFORE: filling the local reference table */
-
-       if (opt_TraceJavaCalls)
-               trace_java_call_enter(m, arg_regs, arg_stack);
-# endif
-#endif
-
-#if defined(ENABLE_HANDLES)
-       /* place all references into the local reference table */
-       /* BEFORE: creating stackframeinfo */
-
-       localref_native_enter(m, arg_regs, arg_stack);
-#endif
-
-       /* Add a stackframeinfo for this native method.  We don't have RA
-          and XPC here.  These are determined in
-          stacktrace_stackframeinfo_add. */
-
-       stacktrace_stackframeinfo_add(sfi, pv, sp, NULL, NULL);
-
-       /* Return a wrapped classinfo for static methods. */
-
-       if (m->flags & ACC_STATIC)
-               return (java_handle_t *) LLNI_classinfo_wrap(m->clazz);
-       else
-               return NULL;
-}
-
-
-/* codegen_finish_native_call **************************************************
-
-   Removes the stuff required for a native (JNI) function call.
-   Additionally it checks for an exceptions and in case, get the
-   exception object and clear the pointer.
-
-*******************************************************************************/
-
-java_object_t *codegen_finish_native_call(u1 *sp, u1 *pv)
-{
-       stackframeinfo_t *sfi;
-       java_handle_t    *e;
-       java_object_t    *o;
-       codeinfo         *code;
-       methodinfo       *m;
-       int32_t           framesize;
-
-       uint8_t  *datasp;
-       uint64_t *ret_regs;
-
-       /* get information from method header */
-
-       code = code_get_codeinfo_for_pv(pv);
-
-       framesize = *((int32_t *) (pv + FrameSize));
-
-       assert(code);
-
-       /* get the methodinfo */
-
-       m = code->m;
-       assert(m);
-
-       /* calculate needed values */
-
-#if defined(__ALPHA__) || defined(__ARM__)
-       datasp   = sp + framesize - SIZEOF_VOID_P;
-       ret_regs = (uint64_t *) sp;
-#elif defined(__MIPS__)
-       /* MIPS always uses 8 bytes to store the RA */
-       datasp   = sp + framesize - 8;
-#elif defined(__S390__)
-       datasp   = sp + framesize - 8;
-       ret_regs = (uint64_t *) (sp + 96);
-#elif defined(__I386__)
-       datasp   = sp + framesize;
-       ret_regs = (uint64_t *) (sp + 2 * SIZEOF_VOID_P);
-#elif defined(__M68K__)
-       datasp   = sp + framesize;
-       ret_regs = (uint64_t *) (sp + 2 * 8);
-#elif defined(__X86_64__)
-       datasp   = sp + framesize;
-       ret_regs = (uint64_t *) sp;
-#elif defined(__POWERPC__)
-       datasp   = sp + framesize;
-       ret_regs = (uint64_t *) (sp + LA_SIZE + 2 * SIZEOF_VOID_P);
-#elif defined(__POWERPC64__)
-       datasp   = sp + framesize;
-       ret_regs = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 2 * SIZEOF_VOID_P);
-#else
-       vm_abort("codegen_finish_native_call: unsupported architecture");
-#endif
-
-       /* get data structures from stack */
-
-       sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t));
-
-       /* Remove current stackframeinfo from chain. */
-
-       stacktrace_stackframeinfo_remove(sfi);
-
-#if defined(ENABLE_HANDLES)
-       /* unwrap the return value from the local reference table */
-       /* AFTER: removing the stackframeinfo */
-       /* BEFORE: releasing the local reference table */
-
-       localref_native_exit(m, ret_regs);
-#endif
-
-       /* get and unwrap the exception */
-       /* AFTER: removing the stackframe info */
-       /* BEFORE: releasing the local reference table */
-
-       e = exceptions_get_and_clear_exception();
-       o = LLNI_UNWRAP(e);
-
-#if defined(ENABLE_JNI)
-       /* release JNI local references table for this thread */
-
-       localref_frame_pop_all();
-       localref_table_remove();
-#endif
-
-#if !defined(NDEBUG)
-# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
-       /* print the call-trace if necesarry */
-       /* AFTER: unwrapping the return value */
-
-       if (opt_TraceJavaCalls)
-               trace_java_call_exit(m, ret_regs);
-# endif
-#endif
-
-       return o;
-}
-
-
-/* codegen_reg_of_var **********************************************************
-
-   This function determines a register, to which the result of an
-   operation should go, when it is ultimatively intended to store the
-   result in pseudoregister v.  If v is assigned to an actual
-   register, this register will be returned.  Otherwise (when v is
-   spilled) this function returns tempregnum.  If not already done,
-   regoff and flags are set in the stack location.
-       
-*******************************************************************************/
-
-s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum)
-{
-       if (!(v->flags & INMEMORY))
-               return v->vv.regoff;
-
-       return tempregnum;
-}
-
-
-/* codegen_reg_of_dst **********************************************************
-
-   This function determines a register, to which the result of an
-   operation should go, when it is ultimatively intended to store the
-   result in iptr->dst.var.  If dst.var is assigned to an actual
-   register, this register will be returned.  Otherwise (when it is
-   spilled) this function returns tempregnum.  If not already done,
-   regoff and flags are set in the stack location.
-       
-*******************************************************************************/
-
-s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum)
-{
-       return codegen_reg_of_var(iptr->opc, VAROP(iptr->dst), tempregnum);
-}
-
-
-/* codegen_emit_phi_moves ****************************************************
-
-   Emits phi moves at the end of the basicblock.
-
-*******************************************************************************/
-
-#if defined(ENABLE_SSA)
-void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr)
-{
-       int lt_d,lt_s,i;
-       lsradata *ls;
-       codegendata *cd;
-       varinfo *s, *d;
-       instruction tmp_i;
-
-       cd = jd->cd;
-       ls = jd->ls;
-
-       MCODECHECK(512);
-
-       /* Moves from phi functions with highest indices have to be */
-       /* inserted first, since this is the order as is used for   */
-       /* conflict resolution */
-
-       for(i = ls->num_phi_moves[bptr->nr] - 1; i >= 0 ; i--) {
-               lt_d = ls->phi_moves[bptr->nr][i][0];
-               lt_s = ls->phi_moves[bptr->nr][i][1];
-#if defined(SSA_DEBUG_VERBOSE)
-               if (compileverbose)
-                       printf("BB %3i Move %3i <- %3i ", bptr->nr, lt_d, lt_s);
-#endif
-               if (lt_s == UNUSED) {
-#if defined(SSA_DEBUG_VERBOSE)
-               if (compileverbose)
-                       printf(" ... not processed \n");
-#endif
-                       continue;
-               }
-                       
-               d = VAR(ls->lifetime[lt_d].v_index);
-               s = VAR(ls->lifetime[lt_s].v_index);
-               
-
-               if (d->type == -1) {
-#if defined(SSA_DEBUG_VERBOSE)
-                       if (compileverbose)
-                               printf("...returning - phi lifetimes where joined\n");
-#endif
-                       continue;
-               }
-
-               if (s->type == -1) {
-#if defined(SSA_DEBUG_VERBOSE)
-                       if (compileverbose)
-                               printf("...returning - phi lifetimes where joined\n");
-#endif
-                       continue;
-               }
-
-               tmp_i.opc = 0;
-               tmp_i.s1.varindex = ls->lifetime[lt_s].v_index;
-               tmp_i.dst.varindex = ls->lifetime[lt_d].v_index;
-               emit_copy(jd, &tmp_i);
-
-#if defined(SSA_DEBUG_VERBOSE)
-               if (compileverbose) {
-                       if (IS_INMEMORY(d->flags) && IS_INMEMORY(s->flags)) {
-                               /* mem -> mem */
-                               printf("M%3i <- M%3i",d->vv.regoff,s->vv.regoff);
-                       }
-                       else if (IS_INMEMORY(s->flags)) {
-                               /* mem -> reg */
-                               printf("R%3i <- M%3i",d->vv.regoff,s->vv.regoff);
-                       }
-                       else if (IS_INMEMORY(d->flags)) {
-                               /* reg -> mem */
-                               printf("M%3i <- R%3i",d->vv.regoff,s->vv.regoff);
-                       }
-                       else {
-                               /* reg -> reg */
-                               printf("R%3i <- R%3i",d->vv.regoff,s->vv.regoff);
-                       }
-                       printf("\n");
-               }
-#endif /* defined(SSA_DEBUG_VERBOSE) */
-       }
-}
-#endif /* defined(ENABLE_SSA) */
-
-
-/* REMOVEME When we have exception handling in C. */
-
-void *md_asm_codegen_get_pv_from_pc(void *ra)
-{
-       return md_codegen_get_pv_from_pc(ra);
-}
-
-
-/*
- * 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/codegen-common.cpp b/src/vm/jit/codegen-common.cpp
new file mode 100644 (file)
index 0000000..53b4005
--- /dev/null
@@ -0,0 +1,1085 @@
+/* src/vm/jit/codegen-common.cpp - architecture independent code generator stuff
+
+   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.
+
+   All functions assume the following code area / data area layout:
+
+   +-----------+
+   |           |
+   | code area | code area grows to higher addresses
+   |           |
+   +-----------+ <-- start of procedure
+   |           |
+   | data area | data area grows to lower addresses
+   |           |
+   +-----------+
+
+   The functions first write into a temporary code/data area allocated by
+   "codegen_init". "codegen_finish" copies the code and data area into permanent
+   memory. All functions writing values into the data area return the offset
+   relative the begin of the code area (start of procedure).   
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "codegen.h"
+#include "md.h"
+#include "md-abi.h"
+
+#include "mm/memory.h"
+
+#include "toolbox/avl.h"
+#include "toolbox/list.h"
+#include "toolbox/logging.h"
+
+#include "native/llni.h"
+#include "native/localref.h"
+#include "native/native.h"
+
+#include "threads/thread.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
+#include "vm/method.h"
+#include "vm/options.h"
+#include "vm/string.hpp"
+
+# include "vm/statistics.h"
+
+
+#include "vm/jit/abi.h"
+#include "vm/jit/asmpart.h"
+#include "vm/jit/code.h"
+#include "vm/jit/codegen-common.hpp"
+
+#if defined(ENABLE_DISASSEMBLER)
+# include "vm/jit/disass.h"
+#endif
+
+#include "vm/jit/dseg.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/linenumbertable.h"
+#include "vm/jit/methodheader.h"
+#include "vm/jit/methodtree.h"
+#include "vm/jit/patcher-common.h"
+#include "vm/jit/replace.hpp"
+#if defined(ENABLE_SSA)
+# include "vm/jit/optimizing/lsra.h"
+# include "vm/jit/optimizing/ssa.h"
+#endif
+#include "vm/jit/stacktrace.hpp"
+#include "vm/jit/trace.hpp"
+
+#if defined(ENABLE_INTRP)
+#include "vm/jit/intrp/intrp.h"
+#endif
+
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
+#include "show.h"
+
+
+/* codegen_init ****************************************************************
+
+   TODO
+
+*******************************************************************************/
+
+void codegen_init(void)
+{
+}
+
+
+/* codegen_setup ***************************************************************
+
+   Allocates and initialises code area, data area and references.
+
+*******************************************************************************/
+
+void codegen_setup(jitdata *jd)
+{
+       methodinfo  *m;
+       codegendata *cd;
+
+       /* get required compiler data */
+
+       m  = jd->m;
+       cd = jd->cd;
+
+       /* initialize members */
+
+       cd->flags        = 0;
+
+       cd->mcodebase    = (u1*) DumpMemory::allocate(MCODEINITSIZE);
+       cd->mcodeend     = cd->mcodebase + MCODEINITSIZE;
+       cd->mcodesize    = MCODEINITSIZE;
+
+       /* initialize mcode variables */
+
+       cd->mcodeptr     = cd->mcodebase;
+       cd->lastmcodeptr = cd->mcodebase;
+
+#if defined(ENABLE_INTRP)
+       /* native dynamic superinstructions variables */
+
+       if (opt_intrp) {
+               cd->ncodebase = (u1*) DumpMemory::allocate(NCODEINITSIZE);
+               cd->ncodesize = NCODEINITSIZE;
+
+               /* initialize ncode variables */
+       
+               cd->ncodeptr = cd->ncodebase;
+
+               cd->lastinstwithoutdispatch = ~0; /* no inst without dispatch */
+               cd->superstarts = NULL;
+       }
+#endif
+
+       cd->dseg           = NULL;
+       cd->dseglen        = 0;
+
+       cd->jumpreferences = NULL;
+
+#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
+       cd->datareferences = NULL;
+#endif
+
+       cd->brancheslabel  = list_create_dump(OFFSET(branch_label_ref_t, linkage));
+       cd->linenumbers    = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage));
+}
+
+
+/* codegen_reset ***************************************************************
+
+   Resets the codegen data structure so we can recompile the method.
+
+*******************************************************************************/
+
+static void codegen_reset(jitdata *jd)
+{
+       codeinfo    *code;
+       codegendata *cd;
+       basicblock  *bptr;
+
+       /* get required compiler data */
+
+       code = jd->code;
+       cd   = jd->cd;
+
+       /* reset error flag */
+
+       cd->flags          &= ~CODEGENDATA_FLAG_ERROR;
+
+       /* reset some members, we reuse the code memory already allocated
+          as this should have almost the correct size */
+
+       cd->mcodeptr        = cd->mcodebase;
+       cd->lastmcodeptr    = cd->mcodebase;
+
+       cd->dseg            = NULL;
+       cd->dseglen         = 0;
+
+       cd->jumpreferences  = NULL;
+
+#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
+       cd->datareferences  = NULL;
+#endif
+
+       cd->brancheslabel   = list_create_dump(OFFSET(branch_label_ref_t, linkage));
+       cd->linenumbers     = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage));
+       
+       /* We need to clear the mpc and the branch references from all
+          basic blocks as they will definitely change. */
+
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
+               bptr->mpc        = -1;
+               bptr->branchrefs = NULL;
+       }
+
+       /* We need to clear all the patcher references from the codeinfo
+          since they all will be regenerated */
+
+       patcher_list_reset(code);
+
+#if defined(ENABLE_REPLACEMENT)
+       code->rplpoints     = NULL;
+       code->rplpointcount = 0;
+       code->regalloc      = NULL;
+       code->regalloccount = 0;
+       code->globalcount   = 0;
+#endif
+}
+
+
+/* codegen_generate ************************************************************
+
+   Generates the code for the currently compiled method.
+
+*******************************************************************************/
+
+bool codegen_generate(jitdata *jd)
+{
+       codegendata *cd;
+
+       /* get required compiler data */
+
+       cd = jd->cd;
+
+       /* call the machine-dependent code generation function */
+
+       if (!codegen_emit(jd))
+               return false;
+
+       /* check for an error */
+
+       if (CODEGENDATA_HAS_FLAG_ERROR(cd)) {
+               /* check for long-branches flag, if it is set we recompile the
+                  method */
+
+#if !defined(NDEBUG)
+        if (compileverbose)
+            log_message_method("Re-generating code: ", jd->m);
+#endif
+
+               /* XXX maybe we should tag long-branches-methods for recompilation */
+
+               if (CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) {
+                       /* we have to reset the codegendata structure first */
+
+                       codegen_reset(jd);
+
+                       /* and restart the compiler run */
+
+                       if (!codegen_emit(jd))
+                               return false;
+               }
+               else {
+                       vm_abort("codegen_generate: unknown error occurred during codegen_emit: flags=%x\n", cd->flags);
+               }
+
+#if !defined(NDEBUG)
+        if (compileverbose)
+            log_message_method("Re-generating code done: ", jd->m);
+#endif
+       }
+
+       /* reallocate the memory and finish the code generation */
+
+       codegen_finish(jd);
+
+       /* everything's ok */
+
+       return true;
+}
+
+
+/* codegen_close ***************************************************************
+
+   TODO
+
+*******************************************************************************/
+
+void codegen_close(void)
+{
+       /* TODO: release avl tree on i386 and x86_64 */
+}
+
+
+/* codegen_increase ************************************************************
+
+   Doubles code area.
+
+*******************************************************************************/
+
+void codegen_increase(codegendata *cd)
+{
+       u1 *oldmcodebase;
+
+       /* save old mcodebase pointer */
+
+       oldmcodebase = cd->mcodebase;
+
+       /* reallocate to new, doubled memory */
+
+       cd->mcodebase = (u1*) DumpMemory::reallocate(cd->mcodebase,
+                                                                                                cd->mcodesize,
+                                                                                                cd->mcodesize * 2);
+       cd->mcodesize *= 2;
+       cd->mcodeend   = cd->mcodebase + cd->mcodesize;
+
+       /* set new mcodeptr */
+
+       cd->mcodeptr = cd->mcodebase + (cd->mcodeptr - oldmcodebase);
+
+#if defined(__I386__) || defined(__MIPS__) || defined(__X86_64__) || defined(__M68K__) || defined(ENABLE_INTRP) \
+ || defined(__SPARC_64__)
+       /* adjust the pointer to the last patcher position */
+
+       if (cd->lastmcodeptr != NULL)
+               cd->lastmcodeptr = cd->mcodebase + (cd->lastmcodeptr - oldmcodebase);
+#endif
+}
+
+
+/* codegen_ncode_increase ******************************************************
+
+   Doubles code area.
+
+*******************************************************************************/
+
+#if defined(ENABLE_INTRP)
+u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr)
+{
+       u1 *oldncodebase;
+
+       /* save old ncodebase pointer */
+
+       oldncodebase = cd->ncodebase;
+
+       /* reallocate to new, doubled memory */
+
+       cd->ncodebase = DMREALLOC(cd->ncodebase,
+                                                         u1,
+                                                         cd->ncodesize,
+                                                         cd->ncodesize * 2);
+       cd->ncodesize *= 2;
+
+       /* return the new ncodeptr */
+
+       return (cd->ncodebase + (ncodeptr - oldncodebase));
+}
+#endif
+
+
+/* codegen_add_branch_ref ******************************************************
+
+   Prepends an branch to the list.
+
+*******************************************************************************/
+
+void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options)
+{
+       branchref *br;
+       s4         branchmpc;
+
+       STATISTICS(count_branches_unresolved++);
+
+       /* calculate the mpc of the branch instruction */
+
+       branchmpc = cd->mcodeptr - cd->mcodebase;
+
+       br = (branchref*) DumpMemory::allocate(sizeof(branchref));
+
+       br->branchmpc = branchmpc;
+       br->condition = condition;
+       br->reg       = reg;
+       br->options   = options;
+       br->next      = target->branchrefs;
+
+       target->branchrefs = br;
+}
+
+
+/* codegen_resolve_branchrefs **************************************************
+
+   Resolves and patches the branch references of a given basic block.
+
+*******************************************************************************/
+
+void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr)
+{
+       branchref *br;
+       u1        *mcodeptr;
+
+       /* Save the mcodeptr because in the branch emitting functions
+          we generate code somewhere inside already generated code,
+          but we're still in the actual code generation phase. */
+
+       mcodeptr = cd->mcodeptr;
+
+       /* just to make sure */
+
+       assert(bptr->mpc >= 0);
+
+       for (br = bptr->branchrefs; br != NULL; br = br->next) {
+               /* temporary set the mcodeptr */
+
+               cd->mcodeptr = cd->mcodebase + br->branchmpc;
+
+               /* emit_bccz and emit_branch emit the correct code, even if we
+                  pass condition == BRANCH_UNCONDITIONAL or reg == -1. */
+
+               emit_bccz(cd, bptr, br->condition, br->reg, br->options);
+       }
+
+       /* restore mcodeptr */
+
+       cd->mcodeptr = mcodeptr;
+}
+
+
+/* codegen_branch_label_add ****************************************************
+
+   Append an branch to the label-branch list.
+
+*******************************************************************************/
+
+void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options)
+{
+       list_t             *l;
+       branch_label_ref_t *br;
+       s4                  mpc;
+
+       /* Get the label list. */
+
+       l = cd->brancheslabel;
+       
+       /* calculate the current mpc */
+
+       mpc = cd->mcodeptr - cd->mcodebase;
+
+       br = (branch_label_ref_t*) DumpMemory::allocate(sizeof(branch_label_ref_t));
+
+       br->mpc       = mpc;
+       br->label     = label;
+       br->condition = condition;
+       br->reg       = reg;
+       br->options   = options;
+
+       /* Add the branch to the list. */
+
+       list_add_last(l, br);
+}
+
+
+/* codegen_set_replacement_point_notrap ****************************************
+
+   Record the position of a non-trappable replacement point.
+
+*******************************************************************************/
+
+#if defined(ENABLE_REPLACEMENT)
+#if !defined(NDEBUG)
+void codegen_set_replacement_point_notrap(codegendata *cd, s4 type)
+#else
+void codegen_set_replacement_point_notrap(codegendata *cd)
+#endif
+{
+       assert(cd->replacementpoint);
+       assert(cd->replacementpoint->type == type);
+       assert(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP);
+
+       cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
+
+       cd->replacementpoint++;
+}
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+
+/* codegen_set_replacement_point ***********************************************
+
+   Record the position of a trappable replacement point.
+
+*******************************************************************************/
+
+#if defined(ENABLE_REPLACEMENT)
+#if !defined(NDEBUG)
+void codegen_set_replacement_point(codegendata *cd, s4 type)
+#else
+void codegen_set_replacement_point(codegendata *cd)
+#endif
+{
+       assert(cd->replacementpoint);
+       assert(cd->replacementpoint->type == type);
+       assert(!(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP));
+
+       cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
+
+       cd->replacementpoint++;
+
+#if !defined(NDEBUG)
+       /* XXX actually we should use an own REPLACEMENT_NOPS here! */
+       if (opt_TestReplacement)
+               PATCHER_NOPS;
+#endif
+
+       /* XXX assert(cd->lastmcodeptr <= cd->mcodeptr); */
+
+       cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE;
+}
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+
+/* codegen_finish **************************************************************
+
+   Finishes the code generation. A new memory, large enough for both
+   data and code, is allocated and data and code are copied together
+   to their final layout, unresolved jumps are resolved, ...
+
+*******************************************************************************/
+
+void codegen_finish(jitdata *jd)
+{
+       codeinfo    *code;
+       codegendata *cd;
+       s4           mcodelen;
+#if defined(ENABLE_INTRP)
+       s4           ncodelen;
+#endif
+       s4           alignedmcodelen;
+       jumpref     *jr;
+       u1          *epoint;
+       s4           alignedlen;
+
+       /* get required compiler data */
+
+       code = jd->code;
+       cd   = jd->cd;
+
+       /* prevent compiler warning */
+
+#if defined(ENABLE_INTRP)
+       ncodelen = 0;
+#endif
+
+       /* calculate the code length */
+
+       mcodelen = (s4) (cd->mcodeptr - cd->mcodebase);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat) {
+               count_code_len += mcodelen;
+               count_data_len += cd->dseglen;
+       }
+#endif
+
+       alignedmcodelen = MEMORY_ALIGN(mcodelen, MAX_ALIGN);
+
+#if defined(ENABLE_INTRP)
+       if (opt_intrp)
+               ncodelen = cd->ncodeptr - cd->ncodebase;
+       else {
+               ncodelen = 0; /* avoid compiler warning */
+       }
+#endif
+
+       cd->dseglen = MEMORY_ALIGN(cd->dseglen, MAX_ALIGN);
+       alignedlen = alignedmcodelen + cd->dseglen;
+
+#if defined(ENABLE_INTRP)
+       if (opt_intrp) {
+               alignedlen += ncodelen;
+       }
+#endif
+
+       /* allocate new memory */
+
+       code->mcodelength = mcodelen + cd->dseglen;
+       code->mcode       = CNEW(u1, alignedlen);
+
+       /* set the entrypoint of the method */
+       
+       assert(code->entrypoint == NULL);
+       code->entrypoint = epoint = (code->mcode + cd->dseglen);
+
+       /* fill the data segment (code->entrypoint must already be set!) */
+
+       dseg_finish(jd);
+
+       /* copy code to the new location */
+
+       MCOPY((void *) code->entrypoint, cd->mcodebase, u1, mcodelen);
+
+#if defined(ENABLE_INTRP)
+       /* relocate native dynamic superinstruction code (if any) */
+
+       if (opt_intrp) {
+               cd->mcodebase = code->entrypoint;
+
+               if (ncodelen > 0) {
+                       u1 *ncodebase = code->mcode + cd->dseglen + alignedmcodelen;
+
+                       MCOPY((void *) ncodebase, cd->ncodebase, u1, ncodelen);
+
+                       /* flush the instruction and data caches */
+
+                       md_cacheflush(ncodebase, ncodelen);
+
+                       /* set some cd variables for dynamic_super_rerwite */
+
+                       cd->ncodebase = ncodebase;
+
+               } else {
+                       cd->ncodebase = NULL;
+               }
+
+               dynamic_super_rewrite(cd);
+       }
+#endif
+
+       /* Create the exception table. */
+
+       exceptiontable_create(jd);
+
+       /* Create the linenumber table. */
+
+       linenumbertable_create(jd);
+
+       /* jump table resolving */
+
+       for (jr = cd->jumpreferences; jr != NULL; jr = jr->next)
+               *((functionptr *) ((ptrint) epoint + jr->tablepos)) =
+                       (functionptr) ((ptrint) epoint + (ptrint) jr->target->mpc);
+
+       /* patcher resolving */
+
+       patcher_resolve(jd);
+
+#if defined(ENABLE_REPLACEMENT)
+       /* replacement point resolving */
+       {
+               int i;
+               rplpoint *rp;
+
+               rp = code->rplpoints;
+               for (i=0; i<code->rplpointcount; ++i, ++rp) {
+                       rp->pc = (u1*) ((ptrint) epoint + (ptrint) rp->pc);
+               }
+       }
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+       /* Insert method into methodtree to find the entrypoint. */
+
+       methodtree_insert(code->entrypoint, code->entrypoint + mcodelen);
+
+#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
+       /* resolve data segment references */
+
+       dseg_resolve_datareferences(jd);
+#endif
+
+       /* flush the instruction and data caches */
+
+       md_cacheflush(code->mcode, code->mcodelength);
+}
+
+
+/* codegen_start_native_call ***************************************************
+
+   Prepares the stuff required for a native (JNI) function call:
+
+   - adds a stackframe info structure to the chain, for stacktraces
+   - prepares the local references table on the stack
+
+   The layout of the native stub stackframe should look like this:
+
+   +---------------------------+ <- java SP (of parent Java function)
+   | return address            |
+   +---------------------------+ <- data SP
+   |                           |
+   | stackframe info structure |
+   |                           |
+   +---------------------------+
+   |                           |
+   | local references table    |
+   |                           |
+   +---------------------------+
+   |                           |
+   | saved registers (if any)  |
+   |                           |
+   +---------------------------+
+   |                           |
+   | arguments (if any)        |
+   |                           |
+   +---------------------------+ <- current SP (native stub)
+
+*******************************************************************************/
+
+java_handle_t *codegen_start_native_call(u1 *sp, u1 *pv)
+{
+       stackframeinfo_t *sfi;
+       localref_table   *lrt;
+       methodinfo       *m;
+       int32_t           framesize;
+
+       uint8_t  *datasp;
+       uint8_t  *javasp;
+       uint64_t *arg_regs;
+       uint64_t *arg_stack;
+
+       STATISTICS(count_calls_java_to_native++);
+
+       /* Get the methodinfo. */
+
+       m = code_get_methodinfo_for_pv(pv);
+
+       assert(m);
+
+       framesize = *((int32_t *) (pv + FrameSize));
+
+       assert(framesize >= (int32_t) (sizeof(stackframeinfo_t) + sizeof(localref_table)));
+
+       /* calculate needed values */
+
+#if defined(__ALPHA__) || defined(__ARM__)
+       datasp    = sp + framesize - SIZEOF_VOID_P;
+       javasp    = sp + framesize;
+       arg_regs  = (uint64_t *) sp;
+       arg_stack = (uint64_t *) javasp;
+#elif defined(__MIPS__)
+       /* MIPS always uses 8 bytes to store the RA */
+       datasp    = sp + framesize - 8;
+       javasp    = sp + framesize;
+#elif defined(__S390__)
+       datasp    = sp + framesize - 8;
+       javasp    = sp + framesize;
+       arg_regs  = (uint64_t *) (sp + 96);
+       arg_stack = (uint64_t *) javasp;
+#elif defined(__I386__) || defined(__M68K__) || defined(__X86_64__)
+       datasp    = sp + framesize;
+       javasp    = sp + framesize + SIZEOF_VOID_P;
+       arg_regs  = (uint64_t *) sp;
+       arg_stack = (uint64_t *) javasp;
+#elif defined(__POWERPC__)
+       datasp    = sp + framesize;
+       javasp    = sp + framesize;
+       arg_regs  = (uint64_t *) (sp + LA_SIZE + 4 * SIZEOF_VOID_P);
+       arg_stack = (uint64_t *) javasp;
+#elif defined(__POWERPC64__)
+       datasp    = sp + framesize;
+       javasp    = sp + framesize;
+       arg_regs  = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 4 * SIZEOF_VOID_P);
+       arg_stack = (uint64_t *) javasp;
+#else
+       /* XXX is was unable to do this port for SPARC64, sorry. (-michi) */
+       /* XXX maybe we need to pass the RA as argument there */
+       vm_abort("codegen_start_native_call: unsupported architecture");
+#endif
+
+       /* get data structures from stack */
+
+       sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t));
+       lrt = (localref_table *)   (datasp - sizeof(stackframeinfo_t) - 
+                                                               sizeof(localref_table));
+
+#if defined(ENABLE_JNI)
+       /* add current JNI local references table to this thread */
+
+       localref_table_add(lrt);
+#endif
+
+#if !defined(NDEBUG)
+# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
+       /* print the call-trace if necesarry */
+       /* BEFORE: filling the local reference table */
+
+       if (opt_TraceJavaCalls)
+               trace_java_call_enter(m, arg_regs, arg_stack);
+# endif
+#endif
+
+#if defined(ENABLE_HANDLES)
+       /* place all references into the local reference table */
+       /* BEFORE: creating stackframeinfo */
+
+       localref_native_enter(m, arg_regs, arg_stack);
+#endif
+
+       /* Add a stackframeinfo for this native method.  We don't have RA
+          and XPC here.  These are determined in
+          stacktrace_stackframeinfo_add. */
+
+       stacktrace_stackframeinfo_add(sfi, pv, sp, NULL, NULL);
+
+       /* Return a wrapped classinfo for static methods. */
+
+       if (m->flags & ACC_STATIC)
+               return (java_handle_t *) LLNI_classinfo_wrap(m->clazz);
+       else
+               return NULL;
+}
+
+
+/* codegen_finish_native_call **************************************************
+
+   Removes the stuff required for a native (JNI) function call.
+   Additionally it checks for an exceptions and in case, get the
+   exception object and clear the pointer.
+
+*******************************************************************************/
+
+java_object_t *codegen_finish_native_call(u1 *sp, u1 *pv)
+{
+       stackframeinfo_t *sfi;
+       java_handle_t    *e;
+       java_object_t    *o;
+       codeinfo         *code;
+       methodinfo       *m;
+       int32_t           framesize;
+
+       uint8_t  *datasp;
+       uint64_t *ret_regs;
+
+       /* get information from method header */
+
+       code = code_get_codeinfo_for_pv(pv);
+
+       framesize = *((int32_t *) (pv + FrameSize));
+
+       assert(code);
+
+       /* get the methodinfo */
+
+       m = code->m;
+       assert(m);
+
+       /* calculate needed values */
+
+#if defined(__ALPHA__) || defined(__ARM__)
+       datasp   = sp + framesize - SIZEOF_VOID_P;
+       ret_regs = (uint64_t *) sp;
+#elif defined(__MIPS__)
+       /* MIPS always uses 8 bytes to store the RA */
+       datasp   = sp + framesize - 8;
+#elif defined(__S390__)
+       datasp   = sp + framesize - 8;
+       ret_regs = (uint64_t *) (sp + 96);
+#elif defined(__I386__)
+       datasp   = sp + framesize;
+       ret_regs = (uint64_t *) (sp + 2 * SIZEOF_VOID_P);
+#elif defined(__M68K__)
+       datasp   = sp + framesize;
+       ret_regs = (uint64_t *) (sp + 2 * 8);
+#elif defined(__X86_64__)
+       datasp   = sp + framesize;
+       ret_regs = (uint64_t *) sp;
+#elif defined(__POWERPC__)
+       datasp   = sp + framesize;
+       ret_regs = (uint64_t *) (sp + LA_SIZE + 2 * SIZEOF_VOID_P);
+#elif defined(__POWERPC64__)
+       datasp   = sp + framesize;
+       ret_regs = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 2 * SIZEOF_VOID_P);
+#else
+       vm_abort("codegen_finish_native_call: unsupported architecture");
+#endif
+
+       /* get data structures from stack */
+
+       sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t));
+
+       /* Remove current stackframeinfo from chain. */
+
+       stacktrace_stackframeinfo_remove(sfi);
+
+#if defined(ENABLE_HANDLES)
+       /* unwrap the return value from the local reference table */
+       /* AFTER: removing the stackframeinfo */
+       /* BEFORE: releasing the local reference table */
+
+       localref_native_exit(m, ret_regs);
+#endif
+
+       /* get and unwrap the exception */
+       /* AFTER: removing the stackframe info */
+       /* BEFORE: releasing the local reference table */
+
+       e = exceptions_get_and_clear_exception();
+       o = LLNI_UNWRAP(e);
+
+#if defined(ENABLE_JNI)
+       /* release JNI local references table for this thread */
+
+       localref_frame_pop_all();
+       localref_table_remove();
+#endif
+
+#if !defined(NDEBUG)
+# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
+       /* print the call-trace if necesarry */
+       /* AFTER: unwrapping the return value */
+
+       if (opt_TraceJavaCalls)
+               trace_java_call_exit(m, ret_regs);
+# endif
+#endif
+
+       return o;
+}
+
+
+/* codegen_reg_of_var **********************************************************
+
+   This function determines a register, to which the result of an
+   operation should go, when it is ultimatively intended to store the
+   result in pseudoregister v.  If v is assigned to an actual
+   register, this register will be returned.  Otherwise (when v is
+   spilled) this function returns tempregnum.  If not already done,
+   regoff and flags are set in the stack location.
+       
+*******************************************************************************/
+
+s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum)
+{
+       if (!(v->flags & INMEMORY))
+               return v->vv.regoff;
+
+       return tempregnum;
+}
+
+
+/* codegen_reg_of_dst **********************************************************
+
+   This function determines a register, to which the result of an
+   operation should go, when it is ultimatively intended to store the
+   result in iptr->dst.var.  If dst.var is assigned to an actual
+   register, this register will be returned.  Otherwise (when it is
+   spilled) this function returns tempregnum.  If not already done,
+   regoff and flags are set in the stack location.
+       
+*******************************************************************************/
+
+s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum)
+{
+       return codegen_reg_of_var(iptr->opc, VAROP(iptr->dst), tempregnum);
+}
+
+
+/* codegen_emit_phi_moves ****************************************************
+
+   Emits phi moves at the end of the basicblock.
+
+*******************************************************************************/
+
+#if defined(ENABLE_SSA)
+void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr)
+{
+       int lt_d,lt_s,i;
+       lsradata *ls;
+       codegendata *cd;
+       varinfo *s, *d;
+       instruction tmp_i;
+
+       cd = jd->cd;
+       ls = jd->ls;
+
+       MCODECHECK(512);
+
+       /* Moves from phi functions with highest indices have to be */
+       /* inserted first, since this is the order as is used for   */
+       /* conflict resolution */
+
+       for(i = ls->num_phi_moves[bptr->nr] - 1; i >= 0 ; i--) {
+               lt_d = ls->phi_moves[bptr->nr][i][0];
+               lt_s = ls->phi_moves[bptr->nr][i][1];
+#if defined(SSA_DEBUG_VERBOSE)
+               if (compileverbose)
+                       printf("BB %3i Move %3i <- %3i ", bptr->nr, lt_d, lt_s);
+#endif
+               if (lt_s == UNUSED) {
+#if defined(SSA_DEBUG_VERBOSE)
+               if (compileverbose)
+                       printf(" ... not processed \n");
+#endif
+                       continue;
+               }
+                       
+               d = VAR(ls->lifetime[lt_d].v_index);
+               s = VAR(ls->lifetime[lt_s].v_index);
+               
+
+               if (d->type == -1) {
+#if defined(SSA_DEBUG_VERBOSE)
+                       if (compileverbose)
+                               printf("...returning - phi lifetimes where joined\n");
+#endif
+                       continue;
+               }
+
+               if (s->type == -1) {
+#if defined(SSA_DEBUG_VERBOSE)
+                       if (compileverbose)
+                               printf("...returning - phi lifetimes where joined\n");
+#endif
+                       continue;
+               }
+
+               tmp_i.opc = 0;
+               tmp_i.s1.varindex = ls->lifetime[lt_s].v_index;
+               tmp_i.dst.varindex = ls->lifetime[lt_d].v_index;
+               emit_copy(jd, &tmp_i);
+
+#if defined(SSA_DEBUG_VERBOSE)
+               if (compileverbose) {
+                       if (IS_INMEMORY(d->flags) && IS_INMEMORY(s->flags)) {
+                               /* mem -> mem */
+                               printf("M%3i <- M%3i",d->vv.regoff,s->vv.regoff);
+                       }
+                       else if (IS_INMEMORY(s->flags)) {
+                               /* mem -> reg */
+                               printf("R%3i <- M%3i",d->vv.regoff,s->vv.regoff);
+                       }
+                       else if (IS_INMEMORY(d->flags)) {
+                               /* reg -> mem */
+                               printf("M%3i <- R%3i",d->vv.regoff,s->vv.regoff);
+                       }
+                       else {
+                               /* reg -> reg */
+                               printf("R%3i <- R%3i",d->vv.regoff,s->vv.regoff);
+                       }
+                       printf("\n");
+               }
+#endif /* defined(SSA_DEBUG_VERBOSE) */
+       }
+}
+#endif /* defined(ENABLE_SSA) */
+
+
+/* REMOVEME When we have exception handling in C. */
+
+void *md_asm_codegen_get_pv_from_pc(void *ra)
+{
+       return md_codegen_get_pv_from_pc(ra);
+}
+
+
+/*
+ * 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/codegen-common.h b/src/vm/jit/codegen-common.h
deleted file mode 100644 (file)
index f037e5b..0000000
+++ /dev/null
@@ -1,287 +0,0 @@
-/* src/vm/jit/codegen-common.h - architecture independent code generator stuff
-
-   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 _CODEGEN_COMMON_H
-#define _CODEGEN_COMMON_H
-
-/* forward typedefs ***********************************************************/
-
-typedef struct codegendata            codegendata;
-typedef struct branchref              branchref;
-typedef struct branch_label_ref_t     branch_label_ref_t;
-typedef struct jumpref                jumpref;
-typedef struct dataref                dataref;
-typedef struct exceptionref           exceptionref;
-typedef struct linenumberref          linenumberref;
-
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/jit/builtin.hpp"
-#include "vm/descriptor.h"
-#include "vm/global.h"
-#include "vm/method.h"
-#include "vm/references.h"
-
-#include "vm/jit/dseg.h"
-#include "vm/jit/jit.hpp"
-#include "vm/jit/reg.h"
-#include "vm/jit/code.h"
-#include "vm/jit/replace.hpp"
-
-
-#define MCODEINITSIZE (1<<15)       /* 32 Kbyte code area initialization size */
-#define DSEGINITSIZE  (1<<12)       /*  4 Kbyte data area initialization size */
-
-#define NCODEINITSIZE (1<<15)       /* 32 Kbyte code area initialization size */
-
-
-/* Register Pack/Unpack Macros ************************************************/
-
-/* ATTENTION: Don't change the order where low and high bits are
-   stored! At least mips32 relies in one case on that order. */
-
-#define PACK_REGS(low,high) \
-    ( (((high) & 0x0000ffff) << 16) | ((low) & 0x0000ffff) )
-
-#define GET_LOW_REG(a)      ((a) & 0x0000ffff)
-#define GET_HIGH_REG(a)    (((a) & 0xffff0000) >> 16)
-
-
-/* branch conditions **********************************************************/
-
-#define BRANCH_UNCONDITIONAL    -1
-
-#define BRANCH_EQ               (ICMD_IFEQ - ICMD_IFEQ)
-#define BRANCH_NE               (ICMD_IFNE - ICMD_IFEQ)
-#define BRANCH_LT               (ICMD_IFLT - ICMD_IFEQ)
-#define BRANCH_GE               (ICMD_IFGE - ICMD_IFEQ)
-#define BRANCH_GT               (ICMD_IFGT - ICMD_IFEQ)
-#define BRANCH_LE               (ICMD_IFLE - ICMD_IFEQ)
-
-#define BRANCH_ULT              256
-#define BRANCH_ULE              257
-#define BRANCH_UGE              258
-#define BRANCH_UGT              259
-
-#define BRANCH_NAN              260
-
-
-/* common branch options ******************************************************/
-
-#define BRANCH_OPT_NONE         0
-
-
-/* codegendata ****************************************************************/
-
-struct codegendata {
-       u4              flags;          /* code generator flags                   */
-       u1             *mcodebase;      /* base pointer of code area              */
-       u1             *mcodeend;       /* pointer to end of code area            */
-       s4              mcodesize;      /* complete size of code area (bytes)     */
-       u1             *mcodeptr;       /* code generation pointer                */
-       u1             *lastmcodeptr;   /* last patcher position of basic block   */
-
-#if defined(ENABLE_INTRP)
-       u1             *ncodebase;      /* base pointer of native code area       */
-       s4              ncodesize;      /* complete size of native code area      */
-       u1             *ncodeptr;       /* native code generation pointer         */
-
-       u4              lastinstwithoutdispatch; /* ~0 if there was a dispatch    */
-
-       s4              lastpatcheroffset; /* -1 if current super has no patcher  */
-       s4              dynsuperm;      /* offsets of start of current dynamic ...*/
-       s4              dynsupern;      /* ... superinstruction starts            */
-       struct superstart *superstarts; /* list of supers without patchers        */
-#endif
-
-       dsegentry      *dseg;           /* chain of data segment entries          */
-       s4              dseglen;        /* used size of data area (bytes)         */
-                                    /* data area grows from top to bottom     */
-
-       jumpref        *jumpreferences; /* list of jumptable target addresses     */
-
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) || defined(__S390__)
-       dataref        *datareferences; /* list of data segment references        */
-#endif
-
-       list_t         *brancheslabel;
-       list_t         *linenumbers;    /* list of line numbers                   */
-
-       methodinfo     *method;
-
-       s4              stackframesize;    /* stackframe size of this method      */
-
-#if defined(ENABLE_REPLACEMENT)
-       rplpoint       *replacementpoint;  /* current replacement point           */
-#endif
-};
-
-
-#define CODEGENDATA_FLAG_ERROR           0x00000001
-#define CODEGENDATA_FLAG_LONGBRANCHES    0x00000002
-
-
-#define CODEGENDATA_HAS_FLAG_ERROR(cd) \
-    ((cd)->flags & CODEGENDATA_FLAG_ERROR)
-
-#define CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd) \
-    ((cd)->flags & CODEGENDATA_FLAG_LONGBRANCHES)
-
-
-/* branchref *****************************************************************/
-
-struct branchref {
-       s4         branchmpc;       /* patching position in code segment          */
-       s4         condition;       /* conditional branch condition               */
-       s4         reg;             /* register number to check                   */
-       u4         options;         /* branch options                             */
-       branchref *next;            /* next element in branchref list             */
-};
-
-
-/* branch_label_ref_t *********************************************************/
-
-struct branch_label_ref_t {
-       s4         mpc;             /* position in code segment                   */
-       s4         label;           /* label number                               */
-       s4         condition;       /* conditional branch condition               */
-       s4         reg;             /* register number to check                   */
-       u4         options;         /* branch options                             */
-       listnode_t linkage;
-};
-
-
-/* jumpref ********************************************************************/
-
-struct jumpref {
-       s4          tablepos;       /* patching position in data segment          */
-       basicblock *target;         /* target basic block                         */
-       jumpref    *next;           /* next element in jumpref list               */
-};
-
-
-/* dataref ********************************************************************/
-
-struct dataref {
-       s4       datapos;           /* patching position in generated code        */
-       dataref *next;              /* next element in dataref list               */
-};
-
-
-/* linenumberref **************************************************************/
-
-struct linenumberref {
-       s4             tablepos;    /* patching position in data segment          */
-       s4             linenumber;  /* line number, used for inserting into the   */
-                                   /* table and for validity checking            */
-                                   /* -1......start of inlined body              */
-                                   /* -2......end of inlined body                */
-                                   /* <= -3...special entry with methodinfo *    */
-                                                               /* (see doc/inlining_stacktrace.txt)          */
-       ptrint         targetmpc;   /* machine code program counter of first      */
-                                   /* instruction for given line                 */
-                                                               /* NOTE: for linenumber <= -3 this is a the   */
-                                   /* (methodinfo *) of the inlined method       */
-       linenumberref *next;        /* next element in linenumberref list         */
-};
-
-
-/* function prototypes ********************************************************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void codegen_init(void);
-void codegen_setup(jitdata *jd);
-
-bool codegen_generate(jitdata *jd);
-bool codegen_emit(jitdata *jd);
-
-#if defined(ENABLE_INTRP)
-bool intrp_codegen(jitdata *jd);
-#endif
-
-void codegen_close(void);
-
-void codegen_increase(codegendata *cd);
-
-#if defined(ENABLE_INTRP)
-u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr);
-#endif
-
-void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options);
-void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr);
-
-void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options);
-
-#if defined(ENABLE_REPLACEMENT)
-#if !defined(NDEBUG)
-void codegen_set_replacement_point_notrap(codegendata *cd, s4 type);
-void codegen_set_replacement_point(codegendata *cd, s4 type);
-#else
-void codegen_set_replacement_point_notrap(codegendata *cd);
-void codegen_set_replacement_point(codegendata *cd);
-#endif
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-void codegen_finish(jitdata *jd);
-
-java_handle_t *codegen_start_native_call(u1 *currentsp, u1 *pv);
-java_object_t *codegen_finish_native_call(u1 *currentsp, u1 *pv);
-
-s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum);
-s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum);
-
-#if defined(ENABLE_SSA)
-void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr);
-#endif
-
-// REMOVEME
-void codegen_emit_stub_compiler(jitdata *jd);
-void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int skipparams);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _CODEGEN_COMMON_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/codegen-common.hpp b/src/vm/jit/codegen-common.hpp
new file mode 100644 (file)
index 0000000..51d4569
--- /dev/null
@@ -0,0 +1,287 @@
+/* src/vm/jit/codegen-common.h - architecture independent code generator stuff
+
+   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 _CODEGEN_COMMON_HPP
+#define _CODEGEN_COMMON_HPP
+
+/* forward typedefs ***********************************************************/
+
+typedef struct codegendata            codegendata;
+typedef struct branchref              branchref;
+typedef struct branch_label_ref_t     branch_label_ref_t;
+typedef struct jumpref                jumpref;
+typedef struct dataref                dataref;
+typedef struct exceptionref           exceptionref;
+typedef struct linenumberref          linenumberref;
+
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/descriptor.h"
+#include "vm/global.h"
+#include "vm/method.h"
+#include "vm/references.h"
+
+#include "vm/jit/dseg.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/reg.h"
+#include "vm/jit/code.h"
+#include "vm/jit/replace.hpp"
+
+
+#define MCODEINITSIZE (1<<15)       /* 32 Kbyte code area initialization size */
+#define DSEGINITSIZE  (1<<12)       /*  4 Kbyte data area initialization size */
+
+#define NCODEINITSIZE (1<<15)       /* 32 Kbyte code area initialization size */
+
+
+/* Register Pack/Unpack Macros ************************************************/
+
+/* ATTENTION: Don't change the order where low and high bits are
+   stored! At least mips32 relies in one case on that order. */
+
+#define PACK_REGS(low,high) \
+    ( (((high) & 0x0000ffff) << 16) | ((low) & 0x0000ffff) )
+
+#define GET_LOW_REG(a)      ((a) & 0x0000ffff)
+#define GET_HIGH_REG(a)    (((a) & 0xffff0000) >> 16)
+
+
+/* branch conditions **********************************************************/
+
+#define BRANCH_UNCONDITIONAL    -1
+
+#define BRANCH_EQ               (ICMD_IFEQ - ICMD_IFEQ)
+#define BRANCH_NE               (ICMD_IFNE - ICMD_IFEQ)
+#define BRANCH_LT               (ICMD_IFLT - ICMD_IFEQ)
+#define BRANCH_GE               (ICMD_IFGE - ICMD_IFEQ)
+#define BRANCH_GT               (ICMD_IFGT - ICMD_IFEQ)
+#define BRANCH_LE               (ICMD_IFLE - ICMD_IFEQ)
+
+#define BRANCH_ULT              256
+#define BRANCH_ULE              257
+#define BRANCH_UGE              258
+#define BRANCH_UGT              259
+
+#define BRANCH_NAN              260
+
+
+/* common branch options ******************************************************/
+
+#define BRANCH_OPT_NONE         0
+
+
+/* codegendata ****************************************************************/
+
+struct codegendata {
+       u4              flags;          /* code generator flags                   */
+       u1             *mcodebase;      /* base pointer of code area              */
+       u1             *mcodeend;       /* pointer to end of code area            */
+       s4              mcodesize;      /* complete size of code area (bytes)     */
+       u1             *mcodeptr;       /* code generation pointer                */
+       u1             *lastmcodeptr;   /* last patcher position of basic block   */
+
+#if defined(ENABLE_INTRP)
+       u1             *ncodebase;      /* base pointer of native code area       */
+       s4              ncodesize;      /* complete size of native code area      */
+       u1             *ncodeptr;       /* native code generation pointer         */
+
+       u4              lastinstwithoutdispatch; /* ~0 if there was a dispatch    */
+
+       s4              lastpatcheroffset; /* -1 if current super has no patcher  */
+       s4              dynsuperm;      /* offsets of start of current dynamic ...*/
+       s4              dynsupern;      /* ... superinstruction starts            */
+       struct superstart *superstarts; /* list of supers without patchers        */
+#endif
+
+       dsegentry      *dseg;           /* chain of data segment entries          */
+       s4              dseglen;        /* used size of data area (bytes)         */
+                                    /* data area grows from top to bottom     */
+
+       jumpref        *jumpreferences; /* list of jumptable target addresses     */
+
+#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) || defined(__S390__)
+       dataref        *datareferences; /* list of data segment references        */
+#endif
+
+       list_t         *brancheslabel;
+       list_t         *linenumbers;    /* list of line numbers                   */
+
+       methodinfo     *method;
+
+       s4              stackframesize;    /* stackframe size of this method      */
+
+#if defined(ENABLE_REPLACEMENT)
+       rplpoint       *replacementpoint;  /* current replacement point           */
+#endif
+};
+
+
+#define CODEGENDATA_FLAG_ERROR           0x00000001
+#define CODEGENDATA_FLAG_LONGBRANCHES    0x00000002
+
+
+#define CODEGENDATA_HAS_FLAG_ERROR(cd) \
+    ((cd)->flags & CODEGENDATA_FLAG_ERROR)
+
+#define CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd) \
+    ((cd)->flags & CODEGENDATA_FLAG_LONGBRANCHES)
+
+
+/* branchref *****************************************************************/
+
+struct branchref {
+       s4         branchmpc;       /* patching position in code segment          */
+       s4         condition;       /* conditional branch condition               */
+       s4         reg;             /* register number to check                   */
+       u4         options;         /* branch options                             */
+       branchref *next;            /* next element in branchref list             */
+};
+
+
+/* branch_label_ref_t *********************************************************/
+
+struct branch_label_ref_t {
+       s4         mpc;             /* position in code segment                   */
+       s4         label;           /* label number                               */
+       s4         condition;       /* conditional branch condition               */
+       s4         reg;             /* register number to check                   */
+       u4         options;         /* branch options                             */
+       listnode_t linkage;
+};
+
+
+/* jumpref ********************************************************************/
+
+struct jumpref {
+       s4          tablepos;       /* patching position in data segment          */
+       basicblock *target;         /* target basic block                         */
+       jumpref    *next;           /* next element in jumpref list               */
+};
+
+
+/* dataref ********************************************************************/
+
+struct dataref {
+       s4       datapos;           /* patching position in generated code        */
+       dataref *next;              /* next element in dataref list               */
+};
+
+
+/* linenumberref **************************************************************/
+
+struct linenumberref {
+       s4             tablepos;    /* patching position in data segment          */
+       s4             linenumber;  /* line number, used for inserting into the   */
+                                   /* table and for validity checking            */
+                                   /* -1......start of inlined body              */
+                                   /* -2......end of inlined body                */
+                                   /* <= -3...special entry with methodinfo *    */
+                                                               /* (see doc/inlining_stacktrace.txt)          */
+       ptrint         targetmpc;   /* machine code program counter of first      */
+                                   /* instruction for given line                 */
+                                                               /* NOTE: for linenumber <= -3 this is a the   */
+                                   /* (methodinfo *) of the inlined method       */
+       linenumberref *next;        /* next element in linenumberref list         */
+};
+
+
+/* function prototypes ********************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void codegen_init(void);
+void codegen_setup(jitdata *jd);
+
+bool codegen_generate(jitdata *jd);
+bool codegen_emit(jitdata *jd);
+
+#if defined(ENABLE_INTRP)
+bool intrp_codegen(jitdata *jd);
+#endif
+
+void codegen_close(void);
+
+void codegen_increase(codegendata *cd);
+
+#if defined(ENABLE_INTRP)
+u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr);
+#endif
+
+void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options);
+void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr);
+
+void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options);
+
+#if defined(ENABLE_REPLACEMENT)
+#if !defined(NDEBUG)
+void codegen_set_replacement_point_notrap(codegendata *cd, s4 type);
+void codegen_set_replacement_point(codegendata *cd, s4 type);
+#else
+void codegen_set_replacement_point_notrap(codegendata *cd);
+void codegen_set_replacement_point(codegendata *cd);
+#endif
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+void codegen_finish(jitdata *jd);
+
+java_handle_t *codegen_start_native_call(u1 *currentsp, u1 *pv);
+java_object_t *codegen_finish_native_call(u1 *currentsp, u1 *pv);
+
+s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum);
+s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum);
+
+#if defined(ENABLE_SSA)
+void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr);
+#endif
+
+// REMOVEME
+void codegen_emit_stub_compiler(jitdata *jd);
+void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int skipparams);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _CODEGEN_COMMON_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 5de1e5da21791e7df22439de2126405a80fa509c..b66da4bd4c3ed83bfe60b8ffedcbe78056ab76cc 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "vm/options.h"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/methodheader.h"
 
 
index 85885e3660b9ac18ce87d518c8b69ddcdc26e02b..d2a097c37c70be0dcc73de660ad2171b1be25104 100644 (file)
@@ -39,7 +39,7 @@ typedef struct dsegentry dsegentry;
 #include "vm/references.h"
 
 #include "vm/jit/jit.hpp"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* convenience macros *********************************************************/
index f5d350ff1e208bafe08b612731d59f0c497be51e..880f633cd648caffac9e3be970f8e3947da0a451 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "arch.h"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/jit.hpp"
 
 
index 3bd31695a3233d8462946ad9eb48d5211b2eea77..350db739bf62dd63d551f7257dd896a94430e49e 100644 (file)
@@ -60,6 +60,10 @@ struct exceptiontable_entry_t {
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void exceptiontable_create(jitdata *jd);
 void exceptiontable_free(codeinfo *code);
 
@@ -67,6 +71,10 @@ void exceptiontable_free(codeinfo *code);
 void exceptiontable_print(codeinfo *code);
 #endif
 
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
 #endif /* _EXCEPTIONTABLE_H */
 
 
index 96986f91deae92a8f9258d7bc087222bd93d7489..efb7f8c76b0185bec418ec47b130045f11ede66a 100644 (file)
@@ -54,7 +54,7 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
index 8082aab78459e68b3e109c827dcd1dcd27f21887..56bd05a6547aa1b9ac10b18319d4055ed7dbdfc5 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "vm/types.h"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 #define REG_AL       0
index f5f2f915781ef1aea746413b348c4a65a1ed2f9a..562736be4f66d47c4fb2fd343d16a7d75a525a48 100644 (file)
@@ -31,7 +31,7 @@
 #include <assert.h>
 #include <stdint.h>
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/methodtree.h"
 
 
index 8e288486e770286e2948f54330dc465cd8854590..b732399e1502c3aa5fb586e48c371ee28d71a808 100644 (file)
@@ -55,7 +55,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/parse.h"
index 366f1d9cce9f6d9760e3ec0e596f6f0fd947213c..8b1e0da6e968e89ebc41d970665255c569674d2e 100644 (file)
@@ -51,7 +51,7 @@ typedef s4 Cell;
 #include "vm/references.h"
 #include "vm/resolve.h"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 typedef void *Label;
index ece45abeb3c27048e1a8f5c9ae2f9ccb79976aca..baada57fef79badded260c7f1e14953d491ba8aa 100644 (file)
@@ -54,7 +54,7 @@
 
 #include "vm/jit/cfg.h"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/disass.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/jit.hpp"
index bc896adcf29ceb48a3d725ee22ce227c3a585ce3..bb28fceeb5cacf4ca1457f5657b42139c7de224c 100644 (file)
@@ -45,7 +45,7 @@ typedef struct exception_entry exception_entry;
 # include "vm/statistics.h"
 #endif
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/stack.h"
index 9568e3a4da6cf687496dc4723ed01d2f87e4d995..cef9e51518c5cec16601336b601cc835c6d4378d 100644 (file)
@@ -36,7 +36,7 @@
 #endif
 
 #include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/linenumbertable.h"
 
 
index 37bd18fb7686912d8c31b81fa6c15db3b1ca830c..dc001699b0deeb7252bd7d7d25ad733a1cf45482 100644 (file)
@@ -43,7 +43,7 @@ typedef struct linenumbertable_list_entry_t linenumbertable_list_entry_t;
 
 #include "vm/jit/jit.hpp"
 #include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 #include "vm/jit/ir/instruction.hpp"
 
index 67c554329aef650a081cf1dcbe16940946cf22af..e020a3b4e09c5662aac7db4152a346b61a7b5574 100644 (file)
@@ -50,7 +50,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/dseg.h"
 #include "vm/jit/linenumbertable.h"
index 20fa2ea8e119c5235fcfc445aa62f72caf545643..c0358ea8d3a661d3e33a6d65c9abd9b4acacb8ae 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "vm/types.h"
 #include "vm/vm.hpp"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 void emit_mov_imm_reg (codegendata *cd, s4 imm, s4 dreg);
 void emit_mov_imm_areg(codegendata *cd, s4 imm, s4 dreg);
index bc64f4c73587868764b66054f8b02db2dbde342b..5514cc4b885b87ba0c3d5111058a262d8010f7d7 100644 (file)
@@ -33,7 +33,7 @@
 #include <assert.h>
 #include <stdint.h>
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/methodtree.h"
 
 
index 19f1706a90b3b9edabdcf718d845540e0a313e2b..bcd85630485e2c051dde10cd8b0314bab334551b 100644 (file)
@@ -50,7 +50,7 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
index 8b54c15e80fce91954669a7666b5aa18baf97f67..39117af25e977df19bae4686bfbf16433def1c09 100644 (file)
@@ -41,7 +41,7 @@
 #include "vm/signallocal.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* md_init *********************************************************************
index 17889a45826abb9d4f8b66dae8c991040d398af2..ca31ee84eb6b2d013658ad35bc38209e52ef4d27 100644 (file)
@@ -32,7 +32,7 @@
 #include "vm/method.h"
 #include "vm/vm.hpp"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
 #include "vm/jit/show.h"
index 69bd17eb50a6309785bc2a829ee091cfb81a0307..b10d7dad582cdea9ca75e4be02f009ba70dfd654 100644 (file)
@@ -30,7 +30,7 @@
 #include "vm/types.h"
 
 #include "vm/global.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* macros for verifier checks during parsing **********************************/
index 6ca4f58cf2950a215af004b2032a2ddaf5cc778a..e2cea59f0ba754e97c1d669c6be9e680d5cf087f 100644 (file)
@@ -62,6 +62,10 @@ typedef struct patchref_t {
 
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void patcher_list_create(codeinfo *code);
 void patcher_list_reset(codeinfo *code);
 void patcher_list_free(codeinfo *code);
@@ -184,6 +188,9 @@ bool patcher_instanceof_class(patchref_t *pr);
 
 #endif /* defined(__I386__) */
 
+#ifdef __cplusplus
+} // extern "C"
+#endif
 
 #endif /* _PATCHER_COMMON_H */
 
index 0d29184276c0a9ec5180f5b98bfa69678bd48a84..62742e385caf939bff26e2ba5e89ef917f7c02b5 100644 (file)
@@ -53,7 +53,7 @@
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
index c52c86146ef926c1d28f0f4eebb76dfe7fda543a..724ff58f1b7b5c817b5c49e9f997aaa304277e43 100644 (file)
@@ -42,7 +42,7 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
index dbf367765b12b5bab33d59c36610af40d070f948..33724ab14ae24b774b90f4536e4fcb9448d95a1e 100644 (file)
@@ -37,7 +37,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* md_stacktrace_get_returnaddress *********************************************
index d3a5ba495239b477a3bfafdee797c43440221119..6b2fa8cf714277704e2dfc0e947173f9db026ae5 100644 (file)
@@ -54,7 +54,7 @@
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
index 7b42a7e8f71a05a27366bbe1a4e9a6af79d3a399..82612b5c5e58ffc902ac3898c306eb2b96702778 100644 (file)
@@ -55,7 +55,7 @@
 # include "vm/jit/allocator/lsra.h"
 #endif
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
index e5b049a8be94d9638dec69d843eb22c50092ecbc..c3696fd39b6cf1f3022b2ff8f2056d3ca94bf146 100644 (file)
@@ -43,7 +43,7 @@
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.h"
index 917e17a3c93ee2ab4f7edd0e69363f2216329685..5e11280ac1dc33ceeb731e5cd3ec03929b100126 100644 (file)
@@ -52,7 +52,7 @@
 #include "vm/jit/disass.h" /* XXX debug */
 #endif
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/s390/codegen.h"
 #include "vm/jit/s390/md.h"
 
index 1664cd4172cbfa4b9faa37f3394edc8f04e569ad..cbb7f9b6df26dd1609b9144d02f7a4548aa306be 100644 (file)
@@ -31,7 +31,7 @@
 #include <assert.h>
 #include <stdint.h>
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/methodtree.h"
 
 
index e8dd622a706e8dd857d6096ed1bb0d5244775f49..87e3084cd7129e77932d72dd1a93b7f164b0ec50 100644 (file)
@@ -50,7 +50,7 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
index 31b64b9f2e56eb868690dba2e8e35501a6e9e398..398fb809d974b3723fd7bce3b92aad02af6d071e 100644 (file)
@@ -33,7 +33,7 @@
 #include "vm/jit/sparc64/md-abi.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/jit.hpp"
 
 
index a66b2552a84a819f7a300a13bd6ff03addca647e..f47f7750d88747e331d0b228e4231be8ffb36ace 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "vm/types.h"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 
 
 /* md_stacktrace_get_returnaddress *********************************************
index 8931c8a3a2923ae58dc67877e652c4ae88b92315..8d40f084fbfdedb9799dd2b8db32973ef40e3624 100644 (file)
@@ -53,7 +53,7 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/cfg.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/parse.h"
 #include "vm/jit/show.h"
 
index 8c0bd1b89140c4abb08f3f8309d410ebc4857b78..8f6f4fca77cb273b68509590b6ee5404497fee83 100644 (file)
@@ -59,7 +59,7 @@
 #include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/methodtree.h"
index 98e00bb584273a567fe5976dd9314993fd223d8a..ded759a50ea03812ade47a610e8c942df4fa464d 100644 (file)
@@ -38,7 +38,7 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/disass.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
index 5de9fb5f0ffd33eccaf9340d5da01d95dacb8ac8..e3b735b54060fbc6400faa76e1e9e91ceec211fd 100644 (file)
@@ -46,7 +46,7 @@
 #include "vm/utf8.h"
 
 #include "vm/jit/argument.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/trace.hpp"
 #include "vm/jit/show.h"
 
index 6835e08860de4197d7ff60db3178aa18b43389aa..aa07a1a8872fc02d026bfc54e389ef5f91416caf 100644 (file)
@@ -57,7 +57,7 @@
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/code.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
index 0395d09b1bf4ebec9a9f0f80c62b87d8cd0b6889..d1076f2db186949b1d7348c79f054628372ea009 100644 (file)
@@ -42,7 +42,7 @@
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/emit-common.hpp"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.h"
index d68434daae06791f0a0f11467e9f9fa2b02fb336..1669fd52046742272e7478993237ad9713227bf8 100644 (file)
@@ -31,7 +31,7 @@
 #include "config.h"
 #include "vm/types.h"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/jit.hpp"
 
 
index 1ffd5b7c49491db9ab4227877bc78f7282472013..586550cfd485340406a80c301f65564c815e50f2 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "vm/vm.hpp"
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/jit.hpp"
 
 
index 6b6c55a364cd9aa3f97e292d03012c46ed89f596..6495479a83f794fcdccf442809275630f85cf087 100644 (file)
@@ -31,7 +31,7 @@
 #include <assert.h>
 #include <stdint.h>
 
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
 #include "vm/jit/methodtree.h"