* src/vm/jit/code.c: Moved to .cpp.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Tue, 26 Aug 2008 18:25:27 +0000 (14:25 -0400)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Tue, 26 Aug 2008 18:25:27 +0000 (14:25 -0400)
* src/vm/jit/code.h: Likewise.
* src/vm/jit/code.cpp: New file.
* src/vm/jit/code.hpp: Likewise.
* src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp,
src/vm/jit/Makefile.am,
src/vm/jit/codegen-common.cpp,
src/vm/jit/codegen-common.hpp,
src/vm/jit/exceptiontable.c,
src/vm/jit/exceptiontable.h,
src/vm/jit/executionstate.h,
src/vm/jit/linenumbertable.c,
src/vm/jit/linenumbertable.h,
src/vm/jit/oprofile-agent.cpp,
src/vm/jit/optimizing/bytecode_escape.c,
src/vm/jit/optimizing/recompile.c,
src/vm/jit/patcher-common.c,
src/vm/jit/stacktrace.hpp,
src/vm/jit/stubs.cpp,
src/vm/jit/stubs.hpp,
src/vm/jit/trap.c,
src/vm/jit/x86_64/codegen.c,
src/vm/method.c,
src/vm/statistics.c,
src/vm/vm.cpp: Related changes.

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

25 files changed:
src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp
src/vm/jit/Makefile.am
src/vm/jit/code.c [deleted file]
src/vm/jit/code.cpp [new file with mode: 0644]
src/vm/jit/code.h [deleted file]
src/vm/jit/code.hpp [new file with mode: 0644]
src/vm/jit/codegen-common.cpp
src/vm/jit/codegen-common.hpp
src/vm/jit/exceptiontable.c
src/vm/jit/exceptiontable.h
src/vm/jit/executionstate.h
src/vm/jit/linenumbertable.c
src/vm/jit/linenumbertable.h
src/vm/jit/oprofile-agent.cpp
src/vm/jit/optimizing/bytecode_escape.c
src/vm/jit/optimizing/recompile.c
src/vm/jit/patcher-common.c
src/vm/jit/stacktrace.hpp
src/vm/jit/stubs.cpp
src/vm/jit/stubs.hpp
src/vm/jit/trap.c
src/vm/jit/x86_64/codegen.c
src/vm/method.c
src/vm/statistics.c
src/vm/vm.cpp

index 92f180047a6ee08e90f643f803f5e5b8768c8481..a3c26cf1b829cd1ed558849302c5916f831c90a9 100644 (file)
@@ -46,7 +46,7 @@
 #include "vm/loader.hpp"
 #include "vm/string.hpp"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/linenumbertable.h"
 #include "vm/jit/stacktrace.hpp"
 
index 79390c666022a2fe807a9fd864d4dbfe31bf9fe4..c51c8e1754c17f863ab133d03535a806243863bd 100644 (file)
@@ -153,8 +153,8 @@ libjit_la_SOURCES = \
        builtin.cpp \
        builtin.hpp \
        builtintable.inc \
-       code.c \
-       code.h \
+       code.cpp \
+       code.hpp \
        codegen-common.cpp \
        codegen-common.hpp \
        disass.h \
diff --git a/src/vm/jit/code.c b/src/vm/jit/code.c
deleted file mode 100644 (file)
index c277cb9..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/* src/vm/jit/code.c - codeinfo struct for representing compiled code
-
-   Copyright (C) 1996-2005, 2006, 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdint.h>
-
-#include "arch.h"
-
-#include "mm/memory.h"
-
-#include "vm/options.h"
-#include "vm/vm.hpp"
-
-#include "vm/jit/code.h"
-#include "vm/jit/codegen-common.hpp"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/methodtree.h"
-
-
-/* code_init *******************************************************************
-
-   Initialize the code-subsystem.
-
-*******************************************************************************/
-
-void code_init(void)
-{
-       /* Check if offset of codeinfo.m == 0 (see comment in code.h). */
-
-       if (OFFSET(codeinfo, m) != 0)
-               vm_abort("code_init: offset of codeinfo.m != 0: %d != 0", OFFSET(codeinfo, m));
-}
-
-
-/* code_codeinfo_new ***********************************************************
-
-   Create a new codeinfo for the given method.
-   
-   IN:
-       m................method to create a new codeinfo for
-
-   The following fields are set in codeinfo:
-       m
-       patchers
-
-   RETURN VALUE:
-       a new, initialized codeinfo, or
-          NULL if an exception occurred.
-  
-*******************************************************************************/
-
-codeinfo *code_codeinfo_new(methodinfo *m)
-{
-       codeinfo *code;
-
-       code = NEW(codeinfo);
-
-       code->m = m;
-
-       patcher_list_create(code);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_codeinfo += sizeof(codeinfo);
-#endif
-
-       return code;
-}
-
-
-/* code_find_codeinfo_for_pc ***************************************************
-
-   Return the codeinfo for the compilation unit that contains the
-   given PC.
-
-   ARGUMENTS:
-       pc...............machine code position
-
-   RETURN VALUE:
-       the codeinfo * for the given PC
-
-*******************************************************************************/
-
-codeinfo *code_find_codeinfo_for_pc(void *pc)
-{
-       void *pv;
-
-       pv = methodtree_find(pc);
-
-       return code_get_codeinfo_for_pv(pv);
-}
-
-
-/* code_find_codeinfo_for_pc ***************************************************
-
-   Return the codeinfo for the compilation unit that contains the
-   given PC. This method does not check the return value and is used
-   by the GC.
-
-   IN:
-       pc...............machine code position
-
-   RETURN VALUE:
-       the codeinfo * for the given PC, or NULL
-
-*******************************************************************************/
-
-codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc)
-{
-       void *pv;
-
-       pv = methodtree_find_nocheck(pc);
-
-       if (pv == NULL)
-               return NULL;
-
-       return code_get_codeinfo_for_pv(pv);
-}
-
-
-/* code_get_methodinfo_for_pv **************************************************
-
-   Return the methodinfo for the given PV.
-
-   IN:
-       pv...............PV
-
-   RETURN VALUE:
-       the methodinfo *
-
-*******************************************************************************/
-
-methodinfo *code_get_methodinfo_for_pv(void *pv)
-{
-       codeinfo *code;
-
-       code = code_get_codeinfo_for_pv(pv);
-
-       /* This is the case for asm_vm_call_method. */
-
-       if (code == NULL)
-               return NULL;
-
-       return code->m;
-}
-
-
-/* code_get_sync_slot_count ****************************************************
-
-   Return the number of stack slots used for storing the synchronized object
-   (and the return value around lock_monitor_exit calls) by the given code.
-   
-   IN:
-       code.............the codeinfo of the code in question
-                           (must be != NULL)
-
-   RETURN VALUE:
-       the number of stack slots used for synchronization
-  
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-int code_get_sync_slot_count(codeinfo *code)
-{
-#ifdef ENABLE_THREADS
-       int count;
-       
-       assert(code);
-
-       if (!checksync)
-               return 0;
-
-       if (!code_is_synchronized(code))
-               return 0;
-
-       count = 1;
-
-#ifdef HAS_4BYTE_STACKSLOT
-       /* long and double need 2 4-byte slots */
-       if (IS_2_WORD_TYPE(code->m->parseddesc->returntype.type))
-               count++;
-#endif
-
-#if defined(__POWERPC__)
-       /* powerpc needs an extra slot */
-       count++;
-#endif
-
-       return count;
-
-#else /* !ENABLE_THREADS */
-       
-       return 0;
-
-#endif /* ENABLE_THREADS */
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
-/* code_codeinfo_free **********************************************************
-
-   Free the memory used by a codeinfo.
-   
-   IN:
-       code.............the codeinfo to free
-
-*******************************************************************************/
-
-void code_codeinfo_free(codeinfo *code)
-{
-       if (code == NULL)
-               return;
-
-       if (code->mcode != NULL)
-               CFREE((void *) (ptrint) code->mcode, code->mcodelength);
-
-       patcher_list_free(code);
-
-#if defined(ENABLE_REPLACEMENT)
-       replace_free_replacement_points(code);
-#endif
-
-       FREE(code, codeinfo);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_codeinfo -= sizeof(codeinfo);
-#endif
-}
-
-
-/* code_free_code_of_method ****************************************************
-
-   Free all codeinfos of the given method
-   
-   IN:
-       m................the method of which the codeinfos are to be freed
-
-*******************************************************************************/
-
-void code_free_code_of_method(methodinfo *m)
-{
-       codeinfo *nextcode;
-       codeinfo *code;
-
-       if (!m)
-               return;
-       
-       nextcode = m->code;
-       while (nextcode) {
-               code = nextcode;
-               nextcode = code->prev;
-               code_codeinfo_free(code);
-       }
-
-       m->code = NULL;
-}
-
-/*
- * 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/code.cpp b/src/vm/jit/code.cpp
new file mode 100644 (file)
index 0000000..d9470f0
--- /dev/null
@@ -0,0 +1,295 @@
+/* src/vm/jit/code.cpp - codeinfo struct for representing compiled code
+
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "arch.h"
+
+#include "mm/memory.h"
+
+#include "vm/options.h"
+#include "vm/vm.hpp"
+
+#include "vm/jit/code.hpp"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/patcher-common.h"
+#include "vm/jit/methodtree.h"
+
+
+/* code_init *******************************************************************
+
+   Initialize the code-subsystem.
+
+*******************************************************************************/
+
+void code_init(void)
+{
+       /* Check if offset of codeinfo.m == 0 (see comment in code.h). */
+
+       if (OFFSET(codeinfo, m) != 0)
+               vm_abort("code_init: offset of codeinfo.m != 0: %d != 0", OFFSET(codeinfo, m));
+}
+
+
+/* code_codeinfo_new ***********************************************************
+
+   Create a new codeinfo for the given method.
+   
+   IN:
+       m................method to create a new codeinfo for
+
+   The following fields are set in codeinfo:
+       m
+       patchers
+
+   RETURN VALUE:
+       a new, initialized codeinfo, or
+          NULL if an exception occurred.
+  
+*******************************************************************************/
+
+codeinfo *code_codeinfo_new(methodinfo *m)
+{
+       codeinfo *code;
+
+       code = NEW(codeinfo);
+
+       code->m = m;
+
+       patcher_list_create(code);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_codeinfo += sizeof(codeinfo);
+#endif
+
+       return code;
+}
+
+
+/* code_find_codeinfo_for_pc ***************************************************
+
+   Return the codeinfo for the compilation unit that contains the
+   given PC.
+
+   ARGUMENTS:
+       pc...............machine code position
+
+   RETURN VALUE:
+       the codeinfo * for the given PC
+
+*******************************************************************************/
+
+codeinfo *code_find_codeinfo_for_pc(void *pc)
+{
+       void *pv;
+
+       pv = methodtree_find(pc);
+
+       return code_get_codeinfo_for_pv(pv);
+}
+
+
+/* code_find_codeinfo_for_pc ***************************************************
+
+   Return the codeinfo for the compilation unit that contains the
+   given PC. This method does not check the return value and is used
+   by the GC.
+
+   IN:
+       pc...............machine code position
+
+   RETURN VALUE:
+       the codeinfo * for the given PC, or NULL
+
+*******************************************************************************/
+
+codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc)
+{
+       void *pv;
+
+       pv = methodtree_find_nocheck(pc);
+
+       if (pv == NULL)
+               return NULL;
+
+       return code_get_codeinfo_for_pv(pv);
+}
+
+
+/* code_get_methodinfo_for_pv **************************************************
+
+   Return the methodinfo for the given PV.
+
+   IN:
+       pv...............PV
+
+   RETURN VALUE:
+       the methodinfo *
+
+*******************************************************************************/
+
+methodinfo *code_get_methodinfo_for_pv(void *pv)
+{
+       codeinfo *code;
+
+       code = code_get_codeinfo_for_pv(pv);
+
+       /* This is the case for asm_vm_call_method. */
+
+       if (code == NULL)
+               return NULL;
+
+       return code->m;
+}
+
+
+/* code_get_sync_slot_count ****************************************************
+
+   Return the number of stack slots used for storing the synchronized object
+   (and the return value around lock_monitor_exit calls) by the given code.
+   
+   IN:
+       code.............the codeinfo of the code in question
+                           (must be != NULL)
+
+   RETURN VALUE:
+       the number of stack slots used for synchronization
+  
+*******************************************************************************/
+
+#if defined(ENABLE_REPLACEMENT)
+int code_get_sync_slot_count(codeinfo *code)
+{
+#ifdef ENABLE_THREADS
+       int count;
+       
+       assert(code);
+
+       if (!checksync)
+               return 0;
+
+       if (!code_is_synchronized(code))
+               return 0;
+
+       count = 1;
+
+#ifdef HAS_4BYTE_STACKSLOT
+       /* long and double need 2 4-byte slots */
+       if (IS_2_WORD_TYPE(code->m->parseddesc->returntype.type))
+               count++;
+#endif
+
+#if defined(__POWERPC__)
+       /* powerpc needs an extra slot */
+       count++;
+#endif
+
+       return count;
+
+#else /* !ENABLE_THREADS */
+       
+       return 0;
+
+#endif /* ENABLE_THREADS */
+}
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+
+/* code_codeinfo_free **********************************************************
+
+   Free the memory used by a codeinfo.
+   
+   IN:
+       code.............the codeinfo to free
+
+*******************************************************************************/
+
+void code_codeinfo_free(codeinfo *code)
+{
+       if (code == NULL)
+               return;
+
+       if (code->mcode != NULL)
+               CFREE((void *) (ptrint) code->mcode, code->mcodelength);
+
+       patcher_list_free(code);
+
+#if defined(ENABLE_REPLACEMENT)
+       replace_free_replacement_points(code);
+#endif
+
+       FREE(code, codeinfo);
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_codeinfo -= sizeof(codeinfo);
+#endif
+}
+
+
+/* code_free_code_of_method ****************************************************
+
+   Free all codeinfos of the given method
+   
+   IN:
+       m................the method of which the codeinfos are to be freed
+
+*******************************************************************************/
+
+void code_free_code_of_method(methodinfo *m)
+{
+       codeinfo *nextcode;
+       codeinfo *code;
+
+       if (!m)
+               return;
+       
+       nextcode = m->code;
+       while (nextcode) {
+               code = nextcode;
+               nextcode = code->prev;
+               code_codeinfo_free(code);
+       }
+
+       m->code = NULL;
+}
+
+/*
+ * 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/code.h b/src/vm/jit/code.h
deleted file mode 100644 (file)
index 4e88fb0..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/* src/vm/jit/code.h - codeinfo struct for representing compiled code
-
-   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 _CODE_H
-#define _CODE_H
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdint.h>
-
-#include "vm/types.h"
-
-#include "toolbox/list.h"
-
-#include "vm/global.h"
-#include "vm/method.h"
-
-#include "vm/jit/exceptiontable.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/methodheader.h"
-#include "vm/jit/replace.hpp"
-
-
-/* constants ******************************************************************/
-
-#define CODE_FLAG_INVALID         0x0001
-#define CODE_FLAG_LEAFMETHOD      0x0002
-#define CODE_FLAG_SYNCHRONIZED    0x0004
-#define CODE_FLAG_TLH             0x0008
-
-
-/* codeinfo *******************************************************************
-
-   A codeinfo represents a particular realization of a method in
-   machine code.
-
-   ATTENTION: The methodinfo entry in the code-structure MUST have the
-   offset 0, otherwise we have a problem in our compiler stub. This is
-   checked with an assert in code_init().
-
-*******************************************************************************/
-
-struct codeinfo {
-       methodinfo   *m;                    /* method this is a realization of    */
-       codeinfo     *prev;                 /* previous codeinfo of this method   */
-
-       uint32_t      flags;                /* OR of CODE_FLAG_ constants         */
-
-       u1            optlevel;             /* optimization level of this code    */
-       s4            basicblockcount;      /* number of basic blocks             */
-
-       int32_t       synchronizedoffset;   /* stack offset of synchronized obj.  */
-
-       /* machine code */
-       u1           *mcode;                /* pointer to machine code            */
-       u1           *entrypoint;           /* machine code entry point           */
-       s4            mcodelength;          /* length of generated machine code   */
-
-       exceptiontable_t  *exceptiontable;
-       linenumbertable_t *linenumbertable;
-
-       /* patcher list */
-       list_t       *patchers;
-
-       /* replacement */                                   
-       s4            stackframesize;       /* size of the stackframe in slots    */
-
-#if defined(ENABLE_REPLACEMENT)
-       rplpoint     *rplpoints;            /* replacement points                 */
-       rplalloc     *regalloc;             /* register allocation info           */
-       s4            rplpointcount;        /* number of replacement points       */
-       s4            globalcount;          /* number of global allocations       */
-       s4            regalloccount;        /* number of total allocations        */
-       s4            memuse;               /* number of arg + local slots        */
-       u1            savedintcount;        /* number of callee saved int regs    */
-       u1            savedfltcount;        /* number of callee saved flt regs    */
-# if defined(HAS_ADDRESS_REGISTER_FILE)
-       u1            savedadrcount;        /* number of callee saved adr regs    */
-# endif
-       u1           *savedmcode;           /* saved code under patches           */
-#endif
-
-#if defined(ENABLE_PROFILING)
-       u4            frequency;            /* number of method invocations       */
-       u4           *bbfrequency;                  
-       s8            cycles;               /* number of cpu cycles               */
-#endif
-};
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* inline functions ***********************************************************/
-
-/* code_xxx_invalid ************************************************************
-
-   Functions for CODE_FLAG_INVALID.
-
-*******************************************************************************/
-
-inline static int code_is_invalid(codeinfo *code)
-{
-       return (code->flags & CODE_FLAG_INVALID);
-}
-
-inline static void code_flag_invalid(codeinfo *code)
-{
-       code->flags |= CODE_FLAG_INVALID;
-}
-
-inline static void code_unflag_invalid(codeinfo *code)
-{
-       code->flags &= ~CODE_FLAG_INVALID;
-}
-
-
-/* code_xxx_leafmethod *********************************************************
-
-   Functions for CODE_FLAG_LEAFMETHOD.
-
-*******************************************************************************/
-
-inline static int code_is_leafmethod(codeinfo *code)
-{
-       return (code->flags & CODE_FLAG_LEAFMETHOD);
-}
-
-inline static void code_flag_leafmethod(codeinfo *code)
-{
-       code->flags |= CODE_FLAG_LEAFMETHOD;
-}
-
-inline static void code_unflag_leafmethod(codeinfo *code)
-{
-       code->flags &= ~CODE_FLAG_LEAFMETHOD;
-}
-
-
-/* code_xxx_synchronized *******************************************************
-
-   Functions for CODE_FLAG_SYNCHRONIZED.
-
-*******************************************************************************/
-
-inline static int code_is_synchronized(codeinfo *code)
-{
-       return (code->flags & CODE_FLAG_SYNCHRONIZED);
-}
-
-inline static void code_flag_synchronized(codeinfo *code)
-{
-       code->flags |= CODE_FLAG_SYNCHRONIZED;
-}
-
-inline static void code_unflag_synchronized(codeinfo *code)
-{
-       code->flags &= ~CODE_FLAG_SYNCHRONIZED;
-}
-
-
-/* code_get_codeinfo_for_pv ****************************************************
-
-   Return the codeinfo for the given PV.
-
-   IN:
-       pv...............PV
-
-   RETURN VALUE:
-       the codeinfo *
-
-*******************************************************************************/
-
-inline static codeinfo *code_get_codeinfo_for_pv(void *pv)
-{
-       codeinfo *code;
-
-       assert(pv != NULL);
-
-       code = *((codeinfo **) (((uintptr_t) pv) + CodeinfoPointer));
-
-       return code;
-}
-
-
-/* function prototypes ********************************************************/
-
-void code_init(void);
-
-codeinfo *code_codeinfo_new(methodinfo *m);
-void code_codeinfo_free(codeinfo *code);
-
-codeinfo *code_find_codeinfo_for_pc(void *pc);
-codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc);
-
-methodinfo *code_get_methodinfo_for_pv(void *pv);
-
-#if defined(ENABLE_REPLACEMENT)
-int code_get_sync_slot_count(codeinfo *code);
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-void code_free_code_of_method(methodinfo *m);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _CODE_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/code.hpp b/src/vm/jit/code.hpp
new file mode 100644 (file)
index 0000000..deac0e1
--- /dev/null
@@ -0,0 +1,247 @@
+/* src/vm/jit/code.hpp - codeinfo struct for representing compiled code
+
+   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 _CODE_HPP
+#define _CODE_HPP
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "vm/types.h"
+
+#include "toolbox/list.h"
+
+#include "vm/global.h"
+#include "vm/method.h"
+
+#include "vm/jit/exceptiontable.h"
+#include "vm/jit/linenumbertable.h"
+#include "vm/jit/methodheader.h"
+#include "vm/jit/replace.hpp"
+
+
+/* constants ******************************************************************/
+
+#define CODE_FLAG_INVALID         0x0001
+#define CODE_FLAG_LEAFMETHOD      0x0002
+#define CODE_FLAG_SYNCHRONIZED    0x0004
+#define CODE_FLAG_TLH             0x0008
+
+
+/* codeinfo *******************************************************************
+
+   A codeinfo represents a particular realization of a method in
+   machine code.
+
+   ATTENTION: The methodinfo entry in the code-structure MUST have the
+   offset 0, otherwise we have a problem in our compiler stub. This is
+   checked with an assert in code_init().
+
+*******************************************************************************/
+
+struct codeinfo {
+       methodinfo   *m;                    /* method this is a realization of    */
+       codeinfo     *prev;                 /* previous codeinfo of this method   */
+
+       uint32_t      flags;                /* OR of CODE_FLAG_ constants         */
+
+       u1            optlevel;             /* optimization level of this code    */
+       s4            basicblockcount;      /* number of basic blocks             */
+
+       int32_t       synchronizedoffset;   /* stack offset of synchronized obj.  */
+
+       /* machine code */
+       u1           *mcode;                /* pointer to machine code            */
+       u1           *entrypoint;           /* machine code entry point           */
+       s4            mcodelength;          /* length of generated machine code   */
+
+       exceptiontable_t  *exceptiontable;
+       linenumbertable_t *linenumbertable;
+
+       /* patcher list */
+       list_t       *patchers;
+
+       /* replacement */                                   
+       s4            stackframesize;       /* size of the stackframe in slots    */
+
+#if defined(ENABLE_REPLACEMENT)
+       rplpoint     *rplpoints;            /* replacement points                 */
+       rplalloc     *regalloc;             /* register allocation info           */
+       s4            rplpointcount;        /* number of replacement points       */
+       s4            globalcount;          /* number of global allocations       */
+       s4            regalloccount;        /* number of total allocations        */
+       s4            memuse;               /* number of arg + local slots        */
+       u1            savedintcount;        /* number of callee saved int regs    */
+       u1            savedfltcount;        /* number of callee saved flt regs    */
+# if defined(HAS_ADDRESS_REGISTER_FILE)
+       u1            savedadrcount;        /* number of callee saved adr regs    */
+# endif
+       u1           *savedmcode;           /* saved code under patches           */
+#endif
+
+#if defined(ENABLE_PROFILING)
+       u4            frequency;            /* number of method invocations       */
+       u4           *bbfrequency;                  
+       s8            cycles;               /* number of cpu cycles               */
+#endif
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* inline functions ***********************************************************/
+
+/* code_xxx_invalid ************************************************************
+
+   Functions for CODE_FLAG_INVALID.
+
+*******************************************************************************/
+
+inline static int code_is_invalid(codeinfo *code)
+{
+       return (code->flags & CODE_FLAG_INVALID);
+}
+
+inline static void code_flag_invalid(codeinfo *code)
+{
+       code->flags |= CODE_FLAG_INVALID;
+}
+
+inline static void code_unflag_invalid(codeinfo *code)
+{
+       code->flags &= ~CODE_FLAG_INVALID;
+}
+
+
+/* code_xxx_leafmethod *********************************************************
+
+   Functions for CODE_FLAG_LEAFMETHOD.
+
+*******************************************************************************/
+
+inline static int code_is_leafmethod(codeinfo *code)
+{
+       return (code->flags & CODE_FLAG_LEAFMETHOD);
+}
+
+inline static void code_flag_leafmethod(codeinfo *code)
+{
+       code->flags |= CODE_FLAG_LEAFMETHOD;
+}
+
+inline static void code_unflag_leafmethod(codeinfo *code)
+{
+       code->flags &= ~CODE_FLAG_LEAFMETHOD;
+}
+
+
+/* code_xxx_synchronized *******************************************************
+
+   Functions for CODE_FLAG_SYNCHRONIZED.
+
+*******************************************************************************/
+
+inline static int code_is_synchronized(codeinfo *code)
+{
+       return (code->flags & CODE_FLAG_SYNCHRONIZED);
+}
+
+inline static void code_flag_synchronized(codeinfo *code)
+{
+       code->flags |= CODE_FLAG_SYNCHRONIZED;
+}
+
+inline static void code_unflag_synchronized(codeinfo *code)
+{
+       code->flags &= ~CODE_FLAG_SYNCHRONIZED;
+}
+
+
+/* code_get_codeinfo_for_pv ****************************************************
+
+   Return the codeinfo for the given PV.
+
+   IN:
+       pv...............PV
+
+   RETURN VALUE:
+       the codeinfo *
+
+*******************************************************************************/
+
+inline static codeinfo *code_get_codeinfo_for_pv(void *pv)
+{
+       codeinfo *code;
+
+       assert(pv != NULL);
+
+       code = *((codeinfo **) (((uintptr_t) pv) + CodeinfoPointer));
+
+       return code;
+}
+
+
+/* function prototypes ********************************************************/
+
+void code_init(void);
+
+codeinfo *code_codeinfo_new(methodinfo *m);
+void code_codeinfo_free(codeinfo *code);
+
+codeinfo *code_find_codeinfo_for_pc(void *pc);
+codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc);
+
+methodinfo *code_get_methodinfo_for_pv(void *pv);
+
+#if defined(ENABLE_REPLACEMENT)
+int code_get_sync_slot_count(codeinfo *code);
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+void code_free_code_of_method(methodinfo *m);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _CODE_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 53b4005f26fb47fc258b3a364b18e60812b7b32d..9c16a260d32a4ae3313e61636bd68dd6f22d44e0 100644 (file)
@@ -74,7 +74,7 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/codegen-common.hpp"
 
 #if defined(ENABLE_DISASSEMBLER)
index 51d45696483a53cb8f5e468f9b6dc87403325487..a9b3bd43b9003828a2571340ee73da25ecfa7fdc 100644 (file)
@@ -49,7 +49,7 @@ typedef struct linenumberref          linenumberref;
 #include "vm/jit/dseg.h"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/replace.hpp"
 
 
index 39fafa54c1d52028eb4a86f3cb3787b5e894fd77..9130543d24762d806416a9e9774bd7369b3ddd33 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "mm/memory.h"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/exceptiontable.h"
 #include "vm/jit/jit.hpp"
 
index 350db739bf62dd63d551f7257dd896a94430e49e..d4733aefba4de85cef912646b7d053c0932e511a 100644 (file)
@@ -36,7 +36,7 @@ typedef struct exceptiontable_entry_t exceptiontable_entry_t;
 
 #include <stdint.h>
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/jit.hpp"
 
 
index 4ae8ab6c2ba1dad7729ddbf0cb39d760ca7fe6c5..59e14ea4be23ef7e8ce7c6c47e12e0feff8842f5 100644 (file)
@@ -38,7 +38,7 @@ typedef struct executionstate_t executionstate_t;
 #include "arch.h"
 #include "md-abi.h"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 
 
 /* executionstate_t ************************************************************
index cef9e51518c5cec16601336b601cc835c6d4378d..e906a06f7951b54a39b043759b7d1a4d635fb4a5 100644 (file)
@@ -35,7 +35,7 @@
 # include "vm/statistics.h"
 #endif
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/codegen-common.hpp"
 #include "vm/jit/linenumbertable.h"
 
index dc001699b0deeb7252bd7d7d25ad733a1cf45482..94ede9b1083d1de6ba5dc5a6709eaca9da3ccadf 100644 (file)
@@ -42,7 +42,7 @@ typedef struct linenumbertable_list_entry_t linenumbertable_list_entry_t;
 #include "vm/method.h"
 
 #include "vm/jit/jit.hpp"
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/codegen-common.hpp"
 
 #include "vm/jit/ir/instruction.hpp"
index ddf3d930f44b4d2b5fcf2698ce4280009e54b6dd..cce16b84d7550c6ad30adf6ca228f1cae8485bde 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "mm/memory.h"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/oprofile-agent.hpp"
 
 #include <string.h>
index ac9456ab0b40f90a50ad232567b4a36ea7b3c6c4..4eb9bdc7ca850d3d06c81a18f96b71f2b734690e 100644 (file)
@@ -38,7 +38,7 @@
 #include "vm/references.h"
 #include "vm/resolve.h"
 
-#include "vm/jit/ir/bytecode.h"
+#include "vm/jit/ir/bytecode.hpp"
 #include "vm/jit/optimizing/escape.h"
 
 #include <assert.h>
index 4cd12cd8675cf47ed670d75a22732f358a1c99a5..19809bfe484985434e543dcb377d4c1c3b4ef02c 100644 (file)
@@ -44,7 +44,7 @@
 #include "vm/options.h"
 #include "vm/string.hpp"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/jit.hpp"
 
 #include "vm/jit/optimizing/recompile.h"
index 816052c9f3cd48c3ef8c8a1083dc52f631b5b87a..b099bbdc29b4e7aab5b5d366639efb878cff7820 100644 (file)
@@ -45,7 +45,7 @@
 #include "vm/resolve.h"
 #include "vm/vm.hpp"                     /* for vm_abort */
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/disass.h"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/patcher-common.h"
index a3e847162b351412a73332237f868995d190133f..d37064edac12fb8541ec1e09c2effe9ded79b847 100644 (file)
@@ -45,7 +45,7 @@ typedef struct stacktrace_t       stacktrace_t;
 #include "vm/class.h"
 #include "vm/global.h"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 
 
 /* stackframeinfo **************************************************************
index ded759a50ea03812ade47a610e8c942df4fa464d..bc458af5c1f38272584147b2f893620a068a9ee6 100644 (file)
@@ -37,7 +37,7 @@
 #include "vm/options.h"
 
 #include "vm/jit/abi.h"
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/codegen-common.hpp"
 #include "vm/jit/disass.h"
 #include "vm/jit/emit-common.hpp"
index 53b66a5a99f2b08f03a3c93391f25bf5d71dbebe..ac4041f391184a853aa8d140d2853bcf77571566 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "vm/method.h"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 
 
 #ifdef __cplusplus
index c40c5f31d33158ca13eafec901591bde9596489d..b6f96f1851ec9213fc9a4fa14017b76871b27ab6 100644 (file)
@@ -42,7 +42,7 @@
 #include "vm/os.hpp"
 #include "vm/vm.hpp"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/disass.h"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/methodtree.h"
index aa07a1a8872fc02d026bfc54e389ef5f91416caf..fec4c97067b511378cb2b8df7121baa0d933e9d2 100644 (file)
@@ -56,7 +56,7 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/codegen-common.hpp"
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.hpp"
index d4ca50b702da7962953ede83dd8457e6b91f180a..814240698ca6d5c56601cdba07e91955f267b2a2 100644 (file)
@@ -52,7 +52,7 @@
 #include "vm/utf8.h"
 #include "vm/vm.hpp"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/stubs.hpp"
 
index 9b4720713239846b767ca841a5a20c27dc6d41df..878e8b822de83089a51416a584ed2d265e36a3a7 100644 (file)
@@ -53,7 +53,7 @@
 #include "vm/options.h"
 #include "vm/statistics.h"
 
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 
 
 /* global variables ***********************************************************/
index 2f5459ce18bcccb8e4bb2b8843530a988e701d70..c82eac8ce5de942fa126d394f7fa0da16a378d5d 100644 (file)
@@ -83,7 +83,7 @@
 
 #include "vm/jit/argument.h"
 #include "vm/jit/asmpart.h"
-#include "vm/jit/code.h"
+#include "vm/jit/code.hpp"
 
 #if defined(ENABLE_DISASSEMBLER)
 # include "vm/jit/disass.h"