* src/vm/jit/jit.c (jit_compile): instrument code only if compiled for the first...
authorPeter Molnar <pm@complang.tuwien.ac.at>
Fri, 4 Jul 2008 09:36:07 +0000 (11:36 +0200)
committerPeter Molnar <pm@complang.tuwien.ac.at>
Fri, 4 Jul 2008 09:36:07 +0000 (11:36 +0200)
* 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.

src/vm/jit/jit.c
src/vm/jit/replace.c
src/vm/jit/trap.c

index 4f4d93afef7491c9375cea8cc797e2f3b00bc7e4..45bea30c9d16df90e7e0878ac8f9a3c8a66db9b3 100644 (file)
@@ -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);
index b58ab724109a2103ad38960be8e5975dce76ca6c..12d77508841b455e3bb7b0a10c097af70b3dfef7 100644 (file)
@@ -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; i<code->rplpointcount; ++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 */
 
index f3cd2257457354c70002ed4b3ad7a28935afd230..233b7b996a2175fcd9134df667dae2340808ca7e 100644 (file)
@@ -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. */