* configure.ac (static-classpath): Removed.
[cacao.git] / src / vm / jit / patcher.h
index 371016faaeeaf749c52ff620b635ce8e3495f59b..68b167468dd90272c52fbb9a7b7f6abf1e029b35 100644 (file)
@@ -1,9 +1,9 @@
 /* src/vm/jit/patcher.h - code patching functions
 
-   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
 
    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., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
+*/
 
-   Authors: Christian Thalinger
 
-   Changes:
+#ifndef _PATCHER_H
+#define _PATCHER_H
 
-   $Id: patcher.h 2659 2005-06-13 14:15:32Z twisti $
+#include "config.h"
 
-*/
+#include <assert.h>
 
-#ifndef _PATCHER_H
-#define _PATCHER_H
+#include "vm/types.h"
+
+#include "threads/lock-common.h"
 
-#include "types.h"
 #include "vm/global.h"
 
 
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__S390__)
+# error "you should no longer include this file"
+#else
+
+
 /* patcher macros *************************************************************/
 
-#if defined(USE_THREADS)
+#define PATCHER_FLAG_PATCHED    (vftbl_t *) 0xdeadbeef
+
+
+#if defined(ENABLE_THREADS)
 
 #define PATCHER_MONITORENTER \
        /* enter a monitor on the patching position */       \
                                                             \
-       builtin_monitorenter(o);                             \
+       lock_monitor_enter(o);                               \
                                                             \
        /* check if the position has already been patched */ \
                                                             \
-       if (o->vftbl) {                                      \
-               builtin_monitorexit(o);                          \
+       if (o->vftbl != NULL) {                              \
+        assert(o->vftbl == PATCHER_FLAG_PATCHED);        \
+                                                         \
+               lock_monitor_exit(o);                            \
                                                             \
-               return true;                                     \
+               return NULL;                                     \
        }                                                    \
 
 
 #define PATCHER_MONITOREXIT \
        /* leave the monitor on the patching position */     \
                                                             \
-       builtin_monitorexit(o);
+       lock_monitor_exit(o);
 
 
 #define PATCHER_MARK_PATCHED_MONITOREXIT \
        /* mark position as patched */                       \
                                                             \
-       o->vftbl = (vftbl_t *) 1;                            \
+       o->vftbl = PATCHER_FLAG_PATCHED;                     \
                                                             \
        PATCHER_MONITOREXIT
 
 #define PATCHER_MONITOREXIT                  /* nop */
 #define PATCHER_MARK_PATCHED_MONITOREXIT     /* nop */
 
-#endif /* defined(USE_THREADS) */
+#endif /* defined(ENABLE_THREADS) */
 
 
 /* function prototypes ********************************************************/
 
+java_object_t *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra);
+#define PATCHER_wrapper (functionptr) patcher_wrapper
+
+bool patcher_resolve_class(u1 *sp);
+#define PATCHER_resolve_class (functionptr) patcher_resolve_class
+
+bool patcher_initialize_class(u1 *sp);
+#define PATCHER_initialize_class (functionptr) patcher_initialize_class
+
+bool patcher_resolve_classref_to_classinfo(u1 *sp);
+#define PATCHER_resolve_classref_to_classinfo (functionptr) patcher_resolve_classref_to_classinfo
+
+bool patcher_resolve_classref_to_vftbl(u1 *sp);
+#define PATCHER_resolve_classref_to_vftbl (functionptr) patcher_resolve_classref_to_vftbl
+
+bool patcher_resolve_classref_to_flags(u1 *sp);
+#define PATCHER_resolve_classref_to_flags (functionptr) patcher_resolve_classref_to_flags
+
+bool patcher_resolve_native_function(u1 *sp);
+#define PATCHER_resolve_native_function (functionptr) patcher_resolve_native_function
+
+
 bool patcher_get_putstatic(u1 *sp);
 #define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
 
@@ -106,11 +138,8 @@ bool patcher_putfieldconst(u1 *sp);
 
 #endif /* defined(__I386__) || defined(__X86_64__) */
 
-bool patcher_builtin_new(u1 *sp);
-#define PATCHER_builtin_new (functionptr) patcher_builtin_new
-
-bool patcher_builtin_newarray(u1 *sp);
-#define PATCHER_builtin_newarray (functionptr) patcher_builtin_newarray
+bool patcher_aconst(u1 *sp);
+#define PATCHER_aconst (functionptr) patcher_aconst
 
 bool patcher_builtin_multianewarray(u1 *sp);
 #define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
@@ -118,9 +147,6 @@ bool patcher_builtin_multianewarray(u1 *sp);
 bool patcher_builtin_arraycheckcast(u1 *sp);
 #define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
 
-bool patcher_builtin_arrayinstanceof(u1 *sp);
-#define PATCHER_builtin_arrayinstanceof (functionptr) patcher_builtin_arrayinstanceof
-
 bool patcher_invokestatic_special(u1 *sp);
 #define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special
 
@@ -130,13 +156,25 @@ bool patcher_invokevirtual(u1 *sp);
 bool patcher_invokeinterface(u1 *sp);
 #define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
 
+
+/* only for interpreter */
+bool patcher_checkcast_instanceof(u1 *sp);
+#define PATCHER_checkcast_instanceof (functionptr) patcher_checkcast_instanceof
+
+
 bool patcher_checkcast_instanceof_flags(u1 *sp);
 #define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
 
 bool patcher_checkcast_instanceof_interface(u1 *sp);
 #define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
 
-#if defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__)
+bool patcher_checkcast_interface(u1 *sp);
+#define PATCHER_checkcast_interface (functionptr) patcher_checkcast_interface
+
+bool patcher_instanceof_interface(u1 *sp);
+#define PATCHER_instanceof_interface (functionptr) patcher_instanceof_interface
+
+#if defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)
 
 bool patcher_checkcast_class(u1 *sp);
 #define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
@@ -144,19 +182,41 @@ bool patcher_checkcast_class(u1 *sp);
 bool patcher_instanceof_class(u1 *sp);
 #define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
 
-#else /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) */
+#else /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)*/
 
 bool patcher_checkcast_instanceof_class(u1 *sp);
 #define PATCHER_checkcast_instanceof_class (functionptr) patcher_checkcast_instanceof_class
 
-#endif /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) */
+#endif /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)*/
 
 bool patcher_clinit(u1 *sp);
 #define PATCHER_clinit (functionptr) patcher_clinit
 
+bool patcher_athrow_areturn(u1 *sp);
+#define PATCHER_athrow_areturn (functionptr) patcher_athrow_areturn
+
 bool patcher_resolve_native(u1 *sp);
 #define PATCHER_resolve_native (functionptr) patcher_resolve_native
 
+
+/* stuff for the interpreter **************************************************/
+
+#if defined(ENABLE_INTRP)
+bool intrp_patcher_get_putstatic(u1 *sp);
+bool intrp_patcher_get_putstatic_clinit(u1 *sp);
+bool intrp_patcher_get_putfield(u1 *sp);
+bool intrp_patcher_aconst(u1 *sp);
+bool intrp_patcher_builtin_multianewarray(u1 *sp);
+bool intrp_patcher_builtin_arraycheckcast(u1 *sp);
+bool intrp_patcher_invokestatic_special(u1 *sp);
+bool intrp_patcher_invokevirtual(u1 *sp);
+bool intrp_patcher_invokeinterface(u1 *sp);
+bool intrp_patcher_checkcast_instanceof(u1 *sp);
+bool intrp_patcher_resolve_native(u1 *sp);
+#endif /* defined(ENABLE_INTRP) */
+
+#endif /* architecture list */
+
 #endif /* _PATCHER_H */