34 #include "md-trap.hpp"
80 #if !defined(TRAP_INSTRUCTION_IS_LOAD)
81 # error TRAP_INSTRUCTION_IS_LOAD is not defined in your md-trap.h
84 #if TRAP_INSTRUCTION_IS_LOAD == 1
110 vm_abort(
"trap_handle: The program counter is NULL!");
113 #if defined(__AARCH64__) || defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
114 # if !defined(NDEBUG)
126 # if !defined(NDEBUG) && defined(TRAP_TRACE_VERBOSE)
130 log_println(
"[trap_handle: dumping execution state BEFORE ...]");
139 #if defined(__I386__) || defined(__X86_64__)
150 if (!decode_result) {
157 log_println(
"trap_handle: Detected patcher race condition (PR85) at %p", xpc);
167 intptr_t val = trp.
value;
181 index = (int32_t) val;
209 #if !STACKFRAME_LEAFMETHODS_RA_REGISTER
211 sp = (
u1*) sp + SIZEOF_VOID_P;
212 es.
sp += SIZEOF_VOID_P;
226 log_println(
"[trap_handle: sig=%d, type=%d, val=%p, pv=%p, sp=%p, ra=%p, xpc=%p]", sig, type, val, pv, sp, ra, xpc);
238 bool was_patched =
false;
239 #if defined(ENABLE_REPLACEMENT)
270 #if defined(ENABLE_REPLACEMENT)
283 #if defined(__I386__) && defined(ENABLE_REPLACEMENT)
290 #if defined(__X86_64__) && defined(ENABLE_REPLACEMENT)
326 #if defined(__AARCH64__) || defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__)
336 es.
pc = (uint8_t *) (uintptr_t) entry;
351 es.
sp = (uint8_t*) sp;
359 goto trap_handle_exception;
362 #if defined(ENABLE_REPLACEMENT)
384 es.
pc = (uint8_t *) (uintptr_t)
xpc;
405 log_println(
"trap_handle: Detected reusable trap at %p", xpc);
407 es.
pc = (uint8_t *) (uintptr_t)
xpc;
414 trap_handle_exception:
417 #if defined(__AARCH64__) || defined(__ALPHA__) || defined(__MIPS__) || defined(__ARM__) || defined(__I386__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__X86_64__)
419 es.
pc = (uint8_t *) (uintptr_t)
xpc;
423 es.
pv = (uint8_t *) (uintptr_t) sfi.
pv;
440 # if !defined(NDEBUG) && defined(TRAP_TRACE_VERBOSE)
444 log_println(
"[trap_handle: dumping execution state AFTER ...]");
bool patcher_handler(u1 *pc)
intptr_t value
Value (numeric or address) passed with the trap.
bool opt_AlwaysMmapFirstPage
java_handle_t * exceptions_new_arraystoreexception(void)
void exceptions_print_stacktrace(void)
methodinfo * code_get_methodinfo_for_pv(void *pv)
void * jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
Contains information about a decoded trap instruction.
typedef void(JNICALL *jvmtiEventSingleStep)(jvmtiEnv *jvmti_env
void trap_init(void)
Mmap the first memory page to support hardware exceptions and check the maximum hardware trap displac...
java_handle_t * exceptions_new_nullpointerexception(void)
#define MD_TRAP_COMPILER_FIXUP(xpc, ra, sp, pv)
Macro to fixup a compiler stub.
void log_println(const char *text,...)
#define TRACESUBSYSTEMINITIALIZATION(text)
void vm_abort(const char *text,...)
java_handle_t * exceptions_new_classcastexception(java_handle_t *o)
java_handle_t * exceptions_new_arrayindexoutofboundsexception(s4 index)
void executionstate_println(executionstate_t *es)
static int getpagesize(void)
int type
Specific trap type (see md-trap.h).
#define exceptions_get_and_clear_exception
void executionstate_unwind_exception(executionstate_t *es, java_handle_t *e)
Performs stack unwinding in case of an exception.
void stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, void *pv, void *sp, void *ra, void *xpc)
void md_executionstate_write(executionstate_t *es, void *context)
static void * md_codegen_get_pv_from_pc(void *ra)
void asm_handle_exception(void)
static void * mmap_anonymous(void *addr, size_t len, int prot, int flags)
Maps anonymous memory, even on systems not defining MAP_ANON(YMOUS).
#define REPLACEMENT_PATCH_SIZE
void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi)
void md_executionstate_read(executionstate_t *es, void *context)
java_handle_t * exceptions_fillinstacktrace(void)
bool replace_handler(u1 *pc, executionstate_t *es)
bool md_trap_decode(trapinfo_t *trp, int sig, void *xpc, executionstate_t *es)
Decode the trap instruction at the given PC.
void trap_handle(int sig, void *xpc, void *context)
Handles the signal which is generated by trap instructions, caught by a signal handler and calls the ...
void executionstate_sanity_check(void *context)
java_handle_t * exceptions_get_exception(void)
uintptr_t intregs[INT_REG_CNT]
void vm_abort_disassemble(void *pc, int count, const char *text,...)
java_handle_t * exceptions_new_abstractmethoderror(void)
java_handle_t * exceptions_new_arithmeticexception(void)
bool patcher_is_patched_at(void *pc)