Changes: Edwin Steiner
- $Id: patcher.h 4760 2006-04-12 20:06:23Z edwin $
+ $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
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
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