* src/vm/jit/alpha/emit.c [ENABLE_THREADS] (threads/native/lock.h):
[cacao.git] / src / vm / jit / patcher.h
index f3301a0e9738104d94d36e4d0a6ad39f500e3b5b..00f7de7591ea3647873557f01feab0c1141e1488 100644 (file)
@@ -26,9 +26,9 @@
 
    Authors: Christian Thalinger
 
-   Changes:
+   Changes: Edwin Steiner
 
-   $Id: patcher.h 4357 2006-01-22 23:33:38Z twisti $
+   $Id: patcher.h 5123 2006-07-12 21:45:34Z twisti $
 
 */
 
 #define _PATCHER_H
 
 #include "config.h"
+
+#include <assert.h>
+
 #include "vm/types.h"
 
+#if defined(ENABLE_THREADS)
+# include "threads/native/lock.h"
+#endif
+
 #include "vm/global.h"
 
 
 /* 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_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra);
+#define PATCHER_wrapper (functionptr) patcher_wrapper
+
 bool patcher_get_putstatic(u1 *sp);
 #define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
 
@@ -139,7 +154,7 @@ bool patcher_checkcast_instanceof_flags(u1 *sp);
 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__)
+#if defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)
 
 bool patcher_checkcast_class(u1 *sp);
 #define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
@@ -147,12 +162,12 @@ 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
@@ -160,16 +175,17 @@ bool patcher_clinit(u1 *sp);
 bool patcher_athrow_areturn(u1 *sp);
 #define PATCHER_athrow_areturn (functionptr) patcher_athrow_areturn
 
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
 bool patcher_resolve_native(u1 *sp);
 #define PATCHER_resolve_native (functionptr) patcher_resolve_native
-#endif /* !defined(ENABLE_STATICVM) */
+#endif
 
 
 /* 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);