/* src/vm/jit/patcher-common.h - architecture independent code patching stuff
- Copyright (C) 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
+ Copyright (C) 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include "vm/jit/jit.h"
+#if defined (ENABLE_JITCACHE)
+struct cached_ref_t;
+#endif
/* patchref_t ******************************************************************
ptrint datap; /* absolute position in data segment */
s4 disp; /* displacement of ref in the data segment */
functionptr patcher; /* patcher function to call */
- voidptr ref; /* reference passed */
+ void* ref; /* reference passed */
u8 mcode; /* machine code to be patched back in */
bool done; /* XXX preliminary: patch already applied? */
+#if defined (ENABLE_JITCACHE)
+ struct cachedref_t *attached_ref;
+ /* cached reference which must be resolved *
+ * patcher has been run. */
+#endif
listnode_t linkage;
} patchref_t;
void patcher_list_reset(codeinfo *code);
void patcher_list_free(codeinfo *code);
-void patcher_add_patch_ref(jitdata *jd, functionptr patcher, voidptr ref,
- s4 disp);
+void patcher_add_patch_ref(jitdata *jd, functionptr patcher, void* ref, s4 disp);
+
+void patcher_resolve(jitdata* jd);
java_handle_t *patcher_handler(u1 *pc);
-/* patcher prototypes and macros **********************************************/
+/* empty patcher (just patches back original mcode) ***************************/
+
+void patcher_patch_code(patchref_t *pr);
-#if defined(__ALPHA__) || defined(__ARM__) || defined(__MIPS__) || defined(__POWERPC__) || defined (__S390__)
+
+/* patcher prototypes and macros **********************************************/
/* new patcher functions */
bool patcher_resolve_classref_to_flags(patchref_t *pr);
#define PATCHER_resolve_classref_to_flags (functionptr) patcher_resolve_classref_to_flags
-#if !defined(WITH_STATIC_CLASSPATH)
bool patcher_resolve_native_function(patchref_t *pr);
#define PATCHER_resolve_native_function (functionptr) patcher_resolve_native_function
-#endif
/* old patcher functions */
bool patcher_invokeinterface(patchref_t *pr);
#define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
-#if defined(__ALPHA__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__S390__)
+#if defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__)
bool patcher_checkcast_interface(patchref_t *pr);
#define PATCHER_checkcast_interface (functionptr) patcher_checkcast_interface
bool patcher_instanceof_interface(patchref_t *pr);
#define PATCHER_instanceof_interface (functionptr) patcher_instanceof_interface
-#endif /* defined(__ALPHA__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__S390__) */
-
-/* very old patcher functions */
-/* XXX use newer patcher function names above! */
+#endif /* defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__) */
#if defined(__S390__)
-bool patcher_clinit(patchref_t *pr);
-#define PATCHER_clinit (functionptr) patcher_clinit
-
-bool patcher_athrow_areturn(patchref_t *pr);
-#define PATCHER_athrow_areturn (functionptr) patcher_athrow_areturn
-
bool patcher_checkcast_instanceof_interface(patchref_t *pr);
#define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
-#endif /* defined (__S390__) */
+#endif /* defined(__S390__) */
+
+#if defined(__I386__)
+
+bool patcher_aconst(patchref_t *pr);
+#define PATCHER_aconst (functionptr) patcher_aconst
+
+bool patcher_builtin_multianewarray(patchref_t *pr);
+#define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
-#endif /* architecture list */
+bool patcher_builtin_arraycheckcast(patchref_t *pr);
+#define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
+
+bool patcher_checkcast_instanceof_flags(patchref_t *pr);
+#define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
+
+bool patcher_checkcast_class(patchref_t *pr);
+#define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
+
+bool patcher_instanceof_class(patchref_t *pr);
+#define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
+
+#endif /* defined(__I386__) */
+void patch_md(s4 md_patch, ptrint dest, voidptr ref);
#endif /* _PATCHER_COMMON_H */