Lazy loading changes, #ifdef'd for x86_64.
authortwisti <none@none>
Wed, 6 Apr 2005 12:11:32 +0000 (12:11 +0000)
committertwisti <none@none>
Wed, 6 Apr 2005 12:11:32 +0000 (12:11 +0000)
src/vm/jit/parse.c
src/vm/jit/reg.inc
src/vm/jit/stack.c

index 5ac2e7231bc8c033b91780b643e87d9ccc6f7851..3c2458adaea726a68c048170bec87bbd22cdd592 100644 (file)
@@ -30,7 +30,7 @@
             Edwin Steiner
             Joseph Wenninger
 
-   $Id: parse.c 2195 2005-04-03 16:53:16Z edwin $
+   $Id: parse.c 2236 2005-04-06 12:11:32Z twisti $
 
 */
 
@@ -438,7 +438,7 @@ SHOWOPCODE(DEBUG4)
                pushconstantitem:
 
                        if (i >= inline_env->method->class->cpcount) 
-                               panic ("Attempt to access constant outside range");
+                               error("Attempt to access constant outside range: %d >= %d", i, inline_env->method->class->cpcount);
 
                        switch (inline_env->method->class->cptags[i]) {
                        case CONSTANT_Integer:
@@ -1047,6 +1047,70 @@ if (DEBUG4==true) {
                        break;
 
                case JAVA_INVOKESPECIAL:
+                       i = code_get_u2(p + 1,inline_env->method);
+                       {
+                               constant_FMIref *mr;
+                               methodinfo *mi;
+                               unresolved_method *um;
+
+                               inline_env->method->isleafmethod = false;
+
+                               mr = class_getconstant(inline_env->method->class, i, CONSTANT_Methodref);
+#if defined(__X86_64__)
+                               OP2A_NOINC(opcode, mr->parseddesc.md->paramcount + 1, mr, currentline);
+
+                               um = create_unresolved_method(inline_env->method->class,
+                                                                                         inline_env->method,
+                                                                                         iptr,
+                                                                                         NULL);
+
+                               if (!um)
+                                       return NULL;
+
+                               /* store the unresolved_method* */
+
+                               iptr->target = um;
+
+                               /* only with -noverify, otherwise the typechecker does this */
+
+                               if (!opt_verify) {
+                                       if (!resolve_method(um, resolveLazy, &mi))
+                                               return NULL;
+
+                                       iptr->val.a = mi;
+                               }
+                               PINC;
+#else
+                               if (!resolve_classref(inline_env->method,mr->classref,resolveEager,true,&mrclass))
+                                       return NULL;
+
+                               mi = class_resolveclassmethod(mrclass,
+                                                                                         mr->name,
+                                                                                         mr->descriptor,
+                                                                                         inline_env->method->class,
+                                                                                         true);
+
+                               if (!mi)
+                                       return NULL;
+
+if (DEBUG4==true) { 
+       method_display_w_class(mi); 
+       printf("\tINVOKE SPEC/VIRT\n");
+        fflush(stdout);}
+
+                               if (mi->flags & ACC_STATIC) {
+                                       *exceptionptr =
+                                               new_exception(string_java_lang_IncompatibleClassChangeError);
+                                       return NULL;
+                               }
+
+                               method_descriptor2types(mi);
+                               OP2A(opcode, mi->paramcount, mi, currentline);
+#endif
+                       }
+                       break;
+
+/*             case JAVA_INVOKESPECIAL: */
                case JAVA_INVOKEVIRTUAL:
                        i = code_get_u2(p + 1,inline_env->method);
                        {
@@ -1126,6 +1190,11 @@ if (DEBUG4==true) {
                case JAVA_NEW:
                        {
                                constant_classref *cr;
+#if defined(__X86_64__)
+                               i = code_get_u2(p + 1, inline_env->method);
+                               cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
+                               LOADCONST_A_BUILTIN(cr);
+#else
                                classinfo *cls;
                                
                                i = code_get_u2(p + 1,inline_env->method);
@@ -1133,6 +1202,7 @@ if (DEBUG4==true) {
                                if (!resolve_classref(inline_env->method,cr,resolveEager,true,&cls))
                                        return NULL;
                                LOADCONST_A_BUILTIN(cls);
+#endif
                                s_count++;
                                BUILTIN1(BUILTIN_new, TYPE_ADR, currentline);
                                OP(ICMD_CHECKEXCEPTION);
index 639e5176f939c7c52f672b9c414e34f6715b777a..e3e2d82ce753cc3535ad74c6b0366e87ef52b0c5 100644 (file)
    Changes: Stefan Ring
             Christian Thalinger
 
-   $Id: reg.inc 2219 2005-04-05 15:42:57Z christian $
+   $Id: reg.inc 2236 2005-04-06 12:11:32Z twisti $
 
 */
 
 
 #include "arch.h"
 #include "mm/memory.h"
+#include "vm/method.h"
+#include "vm/resolve.h"
 #include "vm/jit/reg.h"
 
 
@@ -1444,8 +1446,22 @@ static void allocate_scratch_registers(methodinfo *m, registerdata *rd)
 
                                        /* pop many push any */
                                        
-                               case ICMD_INVOKEVIRTUAL:
                                case ICMD_INVOKESPECIAL:
+                                       i = iptr->op1;
+                                       while (--i >= 0) {
+                                               reg_free_temp(rd, src);
+                                               src = src->prev;
+                                       }
+#if defined(__X86_64__)
+                                       if (((unresolved_method *) iptr->target)->methodref->parseddesc.md->returntype.type != TYPE_VOID)
+#else
+                                       if (((methodinfo *) iptr->val.a)->returntype != TYPE_VOID)
+#endif
+                                               reg_new_temp(rd, dst);
+                                       break;
+
+                               case ICMD_INVOKEVIRTUAL:
+/*                             case ICMD_INVOKESPECIAL: */
                                case ICMD_INVOKESTATIC:
                                case ICMD_INVOKEINTERFACE:
                                        i = iptr->op1;
index 4bc3ae2f898b9987be075ba557e7b0dbf321ffc0..0cc99e9fb6a1278d8314a47f304ffc74e7f8b287 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Edwin Steiner
             Christian Thalinger
 
-   $Id: stack.c 2221 2005-04-05 15:54:29Z christian $
+   $Id: stack.c 2236 2005-04-06 12:11:32Z twisti $
 
 */
 
@@ -46,6 +46,7 @@
 #include "vm/global.h"
 #include "vm/builtin.h"
 #include "vm/options.h"
+#include "vm/resolve.h"
 #include "vm/statistics.h"
 #include "vm/tables.h"
 #include "vm/jit/codegen.inc.h"
@@ -126,7 +127,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                NEWXSTACK;
        }
 
-#ifdef CONDITIONAL_LOADCONST
+#if CONDITIONAL_LOADCONST
        b_count = m->basicblockcount;
        bptr = m->basicblocks;
        while (--b_count >= 0) {
@@ -193,7 +194,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                }
                bptr++;
        }
-#endif
+#endif /* CONDITIONAL_LOADCONST */
 
 
        do {
@@ -233,7 +234,8 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                                b_index = bptr - m->basicblocks;
                                while (--len >= 0)  {
                                        opcode = iptr->opc;
-                                       iptr->target = NULL;
+                                       /* XXX TWISTI: why is this set to NULL here? */
+/*                                     iptr->target = NULL; */
 
 /*                                     dolog("p: %04d op: %s stack: %p", iptr - instr, icmd_names[opcode], curstack); */
 
@@ -535,6 +537,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                                                                iptr[0].op1 = iptr[1].op1;
                                                                bptr->icount--;
                                                                len--;
+#if 1
                                                                /* iptr[1].opc = ICMD_NOP; */
                                                                OP1_0(TYPE_INT);
                                                                tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
@@ -543,6 +546,9 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
 
                                                                MARKREACHED(tbptr, copy);
                                                                COUNT(count_pcmd_bra);
+#else
+                                                               goto icmd_if;
+#endif
                                                                break;
                                                        case ICMD_IF_ICMPLT:
                                                                iptr[0].opc = ICMD_IFLT;
@@ -1170,64 +1176,76 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                                        case ICMD_IFGE:
                                        case ICMD_IFGT:
                                        case ICMD_IFLE:
+#if 0
+                                       icmd_if:
+#endif
                                                COUNT(count_pcmd_bra);
-#ifdef CONDITIONAL_LOADCONST
-                                               {
-                                                       tbptr = m->basicblocks + b_index;
-                                                       if ((b_count >= 3) &&
-                                                           ((b_index + 2) == m->basicblockindex[iptr[0].op1]) &&
-                                                           (tbptr[1].pre_count == 1) &&
-                                                           (iptr[1].opc == ICMD_ICONST) &&
-                                                           (iptr[2].opc == ICMD_GOTO)   &&
-                                                           ((b_index + 3) == m->basicblockindex[iptr[2].op1]) &&
-                                                           (tbptr[2].pre_count == 1) &&
-                                                           (iptr[3].opc == ICMD_ICONST)) {
-                                                               OP1_1(TYPE_INT, TYPE_INT);
-                                                               switch (iptr[0].opc) {
-                                                               case ICMD_IFEQ:
-                                                                       iptr[0].opc = ICMD_IFNE_ICONST;
-                                                                       break;
-                                                               case ICMD_IFNE:
-                                                                       iptr[0].opc = ICMD_IFEQ_ICONST;
-                                                                       break;
-                                                               case ICMD_IFLT:
-                                                                       iptr[0].opc = ICMD_IFGE_ICONST;
-                                                                       break;
-                                                               case ICMD_IFGE:
-                                                                       iptr[0].opc = ICMD_IFLT_ICONST;
-                                                                       break;
-                                                               case ICMD_IFGT:
-                                                                       iptr[0].opc = ICMD_IFLE_ICONST;
-                                                                       break;
-                                                               case ICMD_IFLE:
-                                                                       iptr[0].opc = ICMD_IFGT_ICONST;
-                                                                       break;
-                                                               }
-                                                               iptr[0].val.i = iptr[1].val.i;
-                                                               iptr[1].opc = ICMD_ELSE_ICONST;
-                                                               iptr[1].val.i = iptr[3].val.i;
-                                                               iptr[2].opc = ICMD_NOP;
-                                                               iptr[3].opc = ICMD_NOP;
-                                                               tbptr[1].flags = BBDELETED;
-                                                               tbptr[2].flags = BBDELETED;
-                                                               tbptr[1].icount = 0;
-                                                               tbptr[2].icount = 0;
-                                                               if (tbptr[3].pre_count == 2) {
-                                                                       len += tbptr[3].icount + 3;
-                                                                       bptr->icount += tbptr[3].icount + 3;
-                                                                       tbptr[3].flags = BBDELETED;
-                                                                       tbptr[3].icount = 0;
-                                                                       b_index++;
-                                                               }
-                                                               else {
-                                                                       bptr->icount++;
-                                                                       len ++;
-                                                               }
-                                                               b_index += 2;
+#if CONDITIONAL_LOADCONST
+                                               tbptr = m->basicblocks + b_index;
+                                               if ((b_count >= 3) &&
+                                                       ((b_index + 2) == m->basicblockindex[iptr[0].op1]) &&
+                                                       (tbptr[1].pre_count == 1) &&
+                                                       (tbptr[1].iinstr[0].opc == ICMD_ICONST) &&
+                                                       (tbptr[1].iinstr[1].opc == ICMD_GOTO)   &&
+                                                       ((b_index + 3) == m->basicblockindex[tbptr[1].iinstr[1].op1]) &&
+                                                       (tbptr[2].pre_count == 1) &&
+                                                       (tbptr[2].iinstr[0].opc == ICMD_ICONST)) {
+                                                       OP1_1(TYPE_INT, TYPE_INT);
+                                                       switch (iptr[0].opc) {
+                                                       case ICMD_IFEQ:
+                                                               iptr[0].opc = ICMD_IFNE_ICONST;
+                                                               break;
+                                                       case ICMD_IFNE:
+                                                               iptr[0].opc = ICMD_IFEQ_ICONST;
+                                                               break;
+                                                       case ICMD_IFLT:
+                                                               iptr[0].opc = ICMD_IFGE_ICONST;
+                                                               break;
+                                                       case ICMD_IFGE:
+                                                               iptr[0].opc = ICMD_IFLT_ICONST;
+                                                               break;
+                                                       case ICMD_IFGT:
+                                                               iptr[0].opc = ICMD_IFLE_ICONST;
+                                                               break;
+                                                       case ICMD_IFLE:
+                                                               iptr[0].opc = ICMD_IFGT_ICONST;
                                                                break;
                                                        }
-                                               }
+#if 1
+                                                       iptr[0].val.i = iptr[1].val.i;
+                                                       iptr[1].opc = ICMD_ELSE_ICONST;
+                                                       iptr[1].val.i = iptr[3].val.i;
+                                                       iptr[2].opc = ICMD_NOP;
+                                                       iptr[3].opc = ICMD_NOP;
+#else
+                                                       /* HACK: save compare value in iptr[1].op1 */
+                                                       iptr[1].op1 = iptr[0].val.i;
+                                                       iptr[0].val.i = tbptr[1].iinstr[0].val.i;
+                                                       iptr[1].opc = ICMD_ELSE_ICONST;
+                                                       iptr[1].val.i = tbptr[2].iinstr[0].val.i;
+                                                       tbptr[1].iinstr[0].opc = ICMD_NOP;
+                                                       tbptr[1].iinstr[1].opc = ICMD_NOP;
+                                                       tbptr[2].iinstr[0].opc = ICMD_NOP;
 #endif
+                                                       tbptr[1].flags = BBDELETED;
+                                                       tbptr[2].flags = BBDELETED;
+                                                       tbptr[1].icount = 0;
+                                                       tbptr[2].icount = 0;
+                                                       if (tbptr[3].pre_count == 2) {
+                                                               len += tbptr[3].icount + 3;
+                                                               bptr->icount += tbptr[3].icount + 3;
+                                                               tbptr[3].flags = BBDELETED;
+                                                               tbptr[3].icount = 0;
+                                                               b_index++;
+                                                       }
+                                                       else {
+                                                               bptr->icount++;
+                                                               len ++;
+                                                       }
+                                                       b_index += 2;
+                                                       break;
+                                               }
+#endif /* CONDITIONAL_LOADCONST */
                                                OP1_0(TYPE_INT);
                                                tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
 
@@ -1854,8 +1872,44 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                                                call_returntype = iptr->op1;
                                                goto _callhandling;
 
-                                       case ICMD_INVOKEVIRTUAL:
                                        case ICMD_INVOKESPECIAL:
+                                               COUNT(count_pcmd_met);
+                                               {
+                                                       unresolved_method *um = iptr->target;
+/*                                                     if (lm->flags & ACC_STATIC) */
+/*                                                             {COUNT(count_check_null);} */
+                                                       call_argcount = iptr->op1;
+#if defined(__X86_64__)
+                                                       call_returntype =
+                                                               um->methodref->parseddesc.md->returntype.type;
+#else
+                                                       call_returntype = lm->returntype;
+#endif
+
+/*                                             _callhandling: */
+                                                       i = call_argcount;
+
+                                                       if (i > rd->arguments_num)
+                                                               rd->arguments_num = i;
+                                                       REQUIRE(i);
+
+                                                       /* Macro in codegen.h */
+                                                       SET_ARG_STACKSLOTS;
+
+                                                       while (copy) {
+                                                               copy->flags |= SAVEDVAR;
+                                                               copy = copy->prev;
+                                                       }
+                                                       i = call_argcount;
+
+                                                       POPMANY(i);
+                                                       if (call_returntype != TYPE_VOID)
+                                                               OP0_1(call_returntype);
+                                                       break;
+                                               }
+
+                                       case ICMD_INVOKEVIRTUAL:
+/*                                     case ICMD_INVOKESPECIAL: */
                                        case ICMD_INVOKEINTERFACE:
                                        case ICMD_INVOKESTATIC:
                                                COUNT(count_pcmd_met);
@@ -1887,6 +1941,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
                                                                OP0_1(call_returntype);
                                                        break;
                                                }
+
                                        case ICMD_INLINE_START:
                                        case ICMD_INLINE_END:
                                                SETDST;
@@ -2494,17 +2549,20 @@ void show_icmd(instruction *iptr, bool deadcode)
        case ICMD_LUSHRCONST:
        case ICMD_ICONST:
        case ICMD_ELSE_ICONST:
+       case ICMD_IASTORECONST:
+       case ICMD_BASTORECONST:
+       case ICMD_CASTORECONST:
+       case ICMD_SASTORECONST:
+               printf(" %d", iptr->val.i);
+               break;
+
        case ICMD_IFEQ_ICONST:
        case ICMD_IFNE_ICONST:
        case ICMD_IFLT_ICONST:
        case ICMD_IFGE_ICONST:
        case ICMD_IFGT_ICONST:
        case ICMD_IFLE_ICONST:
-       case ICMD_IASTORECONST:
-       case ICMD_BASTORECONST:
-       case ICMD_CASTORECONST:
-       case ICMD_SASTORECONST:
-               printf(" %d", iptr->val.i);
+               printf("(%d) %d", iptr[1].op1, iptr->val.i);
                break;
 
        case ICMD_LADDCONST:
@@ -2704,8 +2762,26 @@ void show_icmd(instruction *iptr, bool deadcode)
                printf(" %s", icmd_builtin_name((functionptr) iptr->val.fp));
                break;
 
-       case ICMD_INVOKEVIRTUAL:
        case ICMD_INVOKESPECIAL:
+#if defined(__X86_64__)
+               printf(" ");
+               utf_fprint(stdout,
+                                  ((unresolved_method *) iptr->target)->methodref->classref->name);
+               printf(".");
+               utf_fprint(stdout,
+                                  ((unresolved_method *) iptr->target)->methodref->name);
+#else
+               printf(" ");
+               utf_fprint(stdout,
+                                  ((methodinfo *) iptr->val.a)->class->name);
+               printf(".");
+               utf_fprint(stdout,
+                                  ((methodinfo *) iptr->val.a)->name);
+#endif
+               break;
+
+       case ICMD_INVOKEVIRTUAL:
+/*     case ICMD_INVOKESPECIAL: */
        case ICMD_INVOKESTATIC:
        case ICMD_INVOKEINTERFACE:
                printf(" ");