From: Peter Molnar Date: Fri, 4 Jul 2008 09:36:07 +0000 (+0200) Subject: * src/vm/jit/jit.c (jit_compile): instrument code only if compiled for the first... X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=a87e56e4877bf4b69c48d62f791db1dbc5a9c3c9;p=cacao.git * src/vm/jit/jit.c (jit_compile): instrument code only if compiled for the first time. * src/vm/jit/replace.c (replace_read_executionstate) [__I386__]: the instance can always be read from the stack, (replace_patch_future_calls) [__I386__]: patch future calls to virtual method also if not at method entry, don't patch statically bound calls, if they are to be patched, (replace_find_replacement_point_for_pc): there may be more than one replacement point for a given PC, extend the function to chose the best fitting one, (replace_recover_source_state): adapted to changes * src/vm/jit/trap.c (trap_handle): fixed TRAP_COUNTDOWN handling. --- diff --git a/src/vm/jit/jit.c b/src/vm/jit/jit.c index 4f4d93afe..45bea30c9 100644 --- a/src/vm/jit/jit.c +++ b/src/vm/jit/jit.c @@ -390,8 +390,9 @@ u1 *jit_compile(methodinfo *m) jd->flags |= JITDATA_FLAG_VERBOSECALL; #if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING) - if (opt_Inline) + if (opt_Inline && (jd->m->hitcountdown > 0) && (jd->code->optlevel == 0)) { jd->flags |= JITDATA_FLAG_COUNTDOWN; + } #endif #if defined(ENABLE_JIT) @@ -733,7 +734,7 @@ static u1 *jit_compile_intern(jitdata *jd) /* inlining */ -#if defined(ENABLE_INLINING) +#if defined(ENABLE_INLINING) && !defined(ENABLE_ESCAPE) if (JITDATA_HAS_FLAG_INLINE(jd)) { if (!inline_inline(jd)) return NULL; @@ -774,7 +775,7 @@ static u1 *jit_compile_intern(jitdata *jd) /*&& strncmp(jd->m->name->text, "banana", 6) == 0*/ /*&& jd->exceptiontablelength == 0*/ ) { - /* printf("=== %s ===\n", jd->m->name->text); */ + /*printf("=== %s ===\n", jd->m->name->text);*/ jd->ls = DNEW(lsradata); jd->ls = NULL; ssa(jd); diff --git a/src/vm/jit/replace.c b/src/vm/jit/replace.c index b58ab7241..12d775088 100644 --- a/src/vm/jit/replace.c +++ b/src/vm/jit/replace.c @@ -1228,6 +1228,12 @@ static void replace_read_executionstate(rplpoint *rp, replace_read_value(es, &instra, &(frame->instance)); #endif } +#if defined(__I386__) + else if (!(rp->method->flags & ACC_STATIC)) { + /* On i386 we always pass the first argument on stack. */ + frame->instance.a = *(java_object_t **)(basesp + 1); + } +#endif #endif /* defined(REPLACE_PATCH_DYNAMIC_CALL) */ /* read stack slots */ @@ -1995,8 +2001,11 @@ void replace_patch_future_calls(u1 *ra, /* we can only patch such calls if we are at the entry point */ +#if !defined(__I386__) + /* On i386 we always know the instance argument. */ if (!atentry) return; +#endif assert((calleem->flags & ACC_STATIC) == 0); @@ -2024,6 +2033,11 @@ void replace_patch_future_calls(u1 *ra, else { /* the call was statically bound */ +#if defined(__I386__) + /* It happens that there is a patcher trap. (pm) */ + if (*(u2 *)(patchpos - 1) == 0x0b0f) { + } else +#endif replace_patch_method_pointer((methodptr *) patchpos, entrypoint, "static "); } } @@ -2212,7 +2226,7 @@ no_match: *******************************************************************************/ -rplpoint *replace_find_replacement_point_for_pc(codeinfo *code, u1 *pc) +rplpoint *replace_find_replacement_point_for_pc(codeinfo *code, u1 *pc, unsigned desired_flags) { rplpoint *found; rplpoint *rp; @@ -2226,14 +2240,20 @@ rplpoint *replace_find_replacement_point_for_pc(codeinfo *code, u1 *pc) rp = code->rplpoints; for (i=0; irplpointcount; ++i, ++rp) { DOLOG( replace_replacement_point_println(rp, 2); ); - if (rp->pc <= pc && rp->pc + rp->callsize >= pc) - found = rp; + if (rp->pc <= pc && rp->pc + rp->callsize >= pc) { + if (desired_flags) { + if (rp->flags & desired_flags) { + found = rp; + } + } else { + found = rp; + } + } } return found; } - /* replace_pop_native_frame **************************************************** Unroll a native frame in the execution state and create a source frame @@ -2560,7 +2580,7 @@ sourcestate_t *replace_recover_source_state(rplpoint *rp, /* find the replacement point at the call site */ after_machine_frame: - rp = replace_find_replacement_point_for_pc(es->code, es->pc); + rp = replace_find_replacement_point_for_pc(es->code, es->pc, 0); if (rp == NULL) vm_abort("could not find replacement point while unrolling call"); @@ -2964,7 +2984,7 @@ bool replace_me_wrapper(u1 *pc, void *context) /* search for a replacement point at the given PC */ - rp = replace_find_replacement_point_for_pc(code, pc); + rp = replace_find_replacement_point_for_pc(code, pc, (RPLPOINT_FLAG_ACTIVE | RPLPOINT_FLAG_COUNTDOWN)); /* check if the replacement point belongs to given PC and is active */ diff --git a/src/vm/jit/trap.c b/src/vm/jit/trap.c index f3cd22574..233b7b996 100644 --- a/src/vm/jit/trap.c +++ b/src/vm/jit/trap.c @@ -133,15 +133,6 @@ void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xp pv = NULL; break; -#if defined(ENABLE_REPLACEMENT) - case TRAP_COUNTDOWN: -#if defined(__I386__) - replace_me_wrapper((char*)xpc - 13, context); -#endif - p = NULL; - break; -#endif - default: /* do nothing */ break; @@ -191,6 +182,15 @@ void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xp p = jit_compile_handle(m, sfi.pv, ra, (void *) val); break; +#if defined(ENABLE_REPLACEMENT) + case TRAP_COUNTDOWN: +#if defined(__I386__) + replace_me_wrapper((char*)xpc - 13, context); +#endif + p = NULL; + break; +#endif + default: /* Let's try to get a backtrace. */