36 #include "codegen.hpp"
60 #define DEBUG_NAME "Patcher"
120 struct find_patcher :
public std::binary_function<PatcherPtrTy, void*, bool> {
123 const void*
pc)
const {
124 return (pr->get_mpc() == (uintptr_t) pc);
133 PatcherListTy::iterator it = std::find_if(code->
patchers->begin(),
134 code->
patchers->end(), std::bind2nd(find_patcher(), pc));
152 for (PatcherListTy::iterator
i = code->
patchers->begin(),
177 #if defined(ALIGN_PATCHER_TRAP)
185 os::abort(
"patcher_add_patch_ref: different patchers at same position.");
188 #if defined(USES_PATCHABLE_MEMORY_BARRIER)
211 #if defined(ENABLE_JIT) && (defined(__I386__) || defined(__SPARC_64__) || defined(__X86_64__))
227 return legacy->
get();
238 for (PatcherListTy::iterator
i = code->
patchers->begin(),
243 LOG2(
"Patcher " << pr->get_name() <<
" reposition: " << pr->get_mpc() <<
cacao::nl);
263 return (*pr)->check_is_patched();
284 #define TRACE_PATCHER_INDENT for (i=0; i<patcher_depth; i++) printf("\t")
307 os::abort(
"patcher_handler: Unable to find patcher reference.");
311 if (pr->is_patched()) {
314 log_println(
"patcher_handler: double-patching detected!");
328 printf(
"\tmachine code before = ");
330 # if defined(ENABLE_DISASSEMBLER)
333 printf(
"%x at %p (disassembler disabled)\n", *((uint32_t*) pr->get_mpc()), (
void*) pr->get_mpc());
337 assert(patcher_depth > 0);
343 result = pr->patch();
347 assert(patcher_depth > 0);
351 printf(
"\tmachine code after = ");
353 # if defined(ENABLE_DISASSEMBLER)
356 printf(
"%x at %p (disassembler disabled)\n", *((uint32_t*) pr->get_mpc()), (
void*) pr->get_mpc());
359 if (result ==
false) {
411 #ifdef ENABLE_VERIFIER
449 datap = (uint8_t *) pr->
datap;
461 *((intptr_t*) datap) = (intptr_t) f;
bool patcher_handler(u1 *pc)
#define STATISTICS(x)
Wrapper for statistics only code.
void method_print(methodinfo *m)
Table containing all native methods registered with the VM.
NativeMethods & get_nativemethods()
u1 * disassinstr(u1 *code)
#define TRACE_PATCHER_INDENT
#define PATCHER_CALL_SIZE
bool patcher_resolve_native_function(patchref_t *pr)
void resolve_handle_pending_exception(bool throwError)
typedef void(JNICALL *jvmtiEventSingleStep)(jvmtiEnv *jvmti_env
classinfo * resolve_class_eager_no_access_check(unresolved_class *ref)
static void md_dcacheflush(void *addr, int nbytes)
patchref_t * patcher_add_patch_ref(jitdata *jd, functionptr patcher, void *ref, s4 disp)
void patcher_resolve(codeinfo *code)
Resolve all patchers in the current JIT run.
This structure contains information about a breakpoint.
void log_println(const char *text,...)
void(* functionptr)(void)
bool is_oneshot
Indicates a "one-shot".
codeinfo * code_find_codeinfo_for_pc(void *pc)
bool patcher_resolve_class(patchref_t *pr)
static PatcherPtrTy * patcher_list_find(codeinfo *code, void *pc)
void patcher_list_show(codeinfo *code)
Show the content of the whole patcher reference list for debugging purposes.
void patcher_patch_code(patchref_t *pr)
void patcher_list_create(codeinfo *code)
void patcher_list_reset(codeinfo *code)
LockedList< PatcherPtrTy > PatcherListTy
cacao::shared_ptr< cacao::Patcher > PatcherPtrTy
bool initialize_class(classinfo *c)
void * resolve_method(methodinfo *m)
Resolves a native method, maybe from a dynamic library.
bool patcher_initialize_class(patchref_t *pr)
void breakpoint(Breakpoint *bp)
void emit_patcher_alignment(codegendata *cd)
bool patcher_breakpoint(patchref_t *pr)
Deals with breakpoint instructions (ICMD_BREAKPOINT) compiled into a JIT method.
#define STAT_DECLARE_VAR(type, var, init)
Declare an external statistics variable.
patchref_t * get()
return the raw resource
void patcher_list_free(codeinfo *code)
static VM * get_current()
bool patcher_is_patched_at(void *pc)