Defined PATCHER_MONITORENTER/EXIT macros (i have some problems to see where
authortwisti <none@none>
Wed, 25 May 2005 08:07:57 +0000 (08:07 +0000)
committertwisti <none@none>
Wed, 25 May 2005 08:07:57 +0000 (08:07 +0000)
macros can be used ;-)

src/vm/jit/alpha/patcher.c
src/vm/jit/patcher.h

index 4d4d521c40f3f6a7018ca804d07b24e2badc3a46..c00f4ca6223bbd95f7136d1226b75ef8ad70b2e2 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: patcher.c 2449 2005-05-11 13:34:47Z twisti $
+   $Id: patcher.c 2527 2005-05-25 08:07:57Z twisti $
 
 */
 
@@ -41,6 +41,7 @@
 #include "vm/references.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/helper.h"
+#include "vm/jit/patcher.h"
 
 
 /* patcher_get_putstatic *******************************************************
@@ -76,19 +77,7 @@ bool patcher_get_putstatic(u1 *sp)
        ra = ra - 4;
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
 
@@ -122,15 +111,7 @@ bool patcher_get_putstatic(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -165,19 +146,7 @@ bool patcher_get_putfield(u1 *sp)
        ra = ra - 4;
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
 
@@ -201,15 +170,7 @@ bool patcher_get_putfield(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -249,19 +210,7 @@ bool patcher_builtin_new(u1 *sp)
        ra = ra - (4 + 4);
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the classinfo */
 
@@ -297,15 +246,7 @@ bool patcher_builtin_new(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -345,19 +286,7 @@ bool patcher_builtin_newarray(u1 *sp)
        ra = ra - (4 + 4);
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the classinfo */
 
@@ -393,15 +322,7 @@ bool patcher_builtin_newarray(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -443,19 +364,7 @@ bool patcher_builtin_multianewarray(u1 *sp)
        ra = ra - 4;
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the classinfo */
 
@@ -483,15 +392,7 @@ bool patcher_builtin_multianewarray(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -531,19 +432,7 @@ bool patcher_builtin_arraycheckcast(u1 *sp)
        ra = ra - (2 * 4);
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the classinfo */
 
@@ -579,15 +468,7 @@ bool patcher_builtin_arraycheckcast(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -627,19 +508,7 @@ bool patcher_builtin_arrayinstanceof(u1 *sp)
        ra = ra - (4 + 4);
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the classinfo */
 
@@ -675,15 +544,7 @@ bool patcher_builtin_arrayinstanceof(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -722,19 +583,7 @@ bool patcher_invokestatic_special(u1 *sp)
        ra = ra - 4;
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
 
@@ -762,15 +611,7 @@ bool patcher_invokestatic_special(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -807,19 +648,7 @@ bool patcher_invokevirtual(u1 *sp)
        ra = ra - 4;
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
 
@@ -844,15 +673,7 @@ bool patcher_invokevirtual(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -890,19 +711,7 @@ bool patcher_invokeinterface(u1 *sp)
        ra = ra - 4;
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
 
@@ -932,15 +741,7 @@ bool patcher_invokeinterface(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -977,19 +778,7 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
        ra = ra - 4;
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
 
@@ -1017,15 +806,7 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -1064,19 +845,7 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
        ra = ra - 4;
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
 
@@ -1103,15 +872,7 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -1150,19 +911,7 @@ bool patcher_checkcast_instanceof_class(u1 *sp)
        ra = ra - 4;
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* get the fieldinfo */
 
@@ -1190,15 +939,7 @@ bool patcher_checkcast_instanceof_class(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
@@ -1229,19 +970,7 @@ bool patcher_clinit(u1 *sp)
        ra = ra - 4;
        *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the patching position */
-
-       builtin_monitorenter(o);
-
-       /* check if the position has already been patched */
-
-       if (o->vftbl) {
-               builtin_monitorexit(o);
-
-               return true;
-       }
-#endif
+       PATCHER_MONITORENTER;
 
        /* check if the class is initialized */
 
@@ -1257,15 +986,7 @@ bool patcher_clinit(u1 *sp)
 
        asm_sync_instruction_cache();
 
-#if defined(USE_THREADS)
-       /* this position has been patched */
-
-       o->vftbl = (vftbl_t *) 1;
-
-       /* leave the monitor on the patching position */
-
-       builtin_monitorexit(o);
-#endif
+       PATCHER_MONITOREXIT;
 
        return true;
 }
index bea7c49cb78a404ad94eab5d1c0e2fd5704d4f59..e4ba0bb235023ea1e2f2b0959963c40c44f7aada 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: patcher.h 2473 2005-05-13 14:01:19Z twisti $
+   $Id: patcher.h 2527 2005-05-25 08:07:57Z twisti $
 
 */
 
 #include "vm/global.h"
 
 
+/* patcher macros *************************************************************/
+
+#if defined(USE_THREADS)
+
+#define PATCHER_MONITORENTER \
+       /* enter a monitor on the patching position */       \
+                                                            \
+       builtin_monitorenter(o);                             \
+                                                            \
+       /* check if the position has already been patched */ \
+                                                            \
+       if (o->vftbl) {                                      \
+               builtin_monitorexit(o);                          \
+                                                            \
+               return true;                                     \
+       }                                                    \
+
+
+#define PATCHER_MONITOREXIT \
+       /* mark position as patched */                       \
+                                                            \
+       o->vftbl = (vftbl_t *) 1;                            \
+                                                            \
+       /* leave the monitor on the patching position */     \
+                                                            \
+       builtin_monitorexit(o);                              \
+
+#else
+
+#define PATCHER_MONITORENTER    /* nop */
+#define PATCHER_MONITOREXIT     /* nop */
+
+#endif /* defined(USE_THREADS) */
+
+
 /* function prototypes ********************************************************/
 
 bool patcher_get_putstatic(u1 *sp);