* Updated header: Added 2006. Changed address of FSF. Changed email
[cacao.git] / src / vm / jit / inline / inline.c
index feeea9b8472128374a003a08a7219987c654ca49..6ca958d0a972fc5a4e9d9622a79508e36107db68 100644 (file)
@@ -1,9 +1,9 @@
 /* src/vm/jit/inline/inline.c - code inliner
 
-   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
+   Contact: cacao@cacaojvm.org
 
    Authors: Dieter Thuernbeck
 
-   $Id: inline.c 2788 2005-06-22 16:08:51Z edwin $
+   Changes: Christian Thalinger
+
+   $Id: inline.c 4357 2006-01-22 23:33:38Z twisti $
 
 */
 
@@ -66,7 +68,6 @@ Method to be inlined must:
 #include "vm/global.h"
 #include "vm/linker.h"
 #include "vm/loader.h"
-#include "vm/tables.h"
 #include "vm/options.h"
 #include "vm/resolve.h"
 #include "vm/statistics.h"
@@ -83,20 +84,20 @@ Method to be inlined must:
         printf("<j%i/l%i/s%i/(p)%i>\t", \
                 (mm)->jcodelength,(mm)->maxlocals, \
                (mm)->maxstack, (mm)->paramcount);  \
-        method_display_w_class(mm); }
+        method_println(mm); }
 
 #define METHINFOx(mm) \
     { \
         printf("<c%i/m%i/p%i>\t", \
                 (mm)->class->classUsed,(mm)->methodUsed, (mm)->monoPoly); \
-        method_display_w_class(mm); }
+        method_println(mm); }
 
 #define METHINFO(m) \
-  method_display_w_class(m); 
+  method_println(m); 
 
 #define IMETHINFO(m) \
   utf_display(m->class->name); printf("."); fflush(stdout); \
-  method_display(m); fflush(stdout); \
+  method_println(m); fflush(stdout); \
   printf("\tm->jcodelength=%i; ",m->jcodelength); fflush(stdout); \
   printf("m->jcode=%p;\n",m->jcode); fflush(stdout); \
   printf("\tm->maxlocals=%i; ",m->maxlocals); fflush(stdout); \
@@ -129,7 +130,7 @@ void inlining_init0(methodinfo *m, t_inlining_globals *inline_env)
        inline_env->inlining_stack = NULL;
        inline_env->inlining_rootinfo = NULL;
 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
        if (in_stats1) {
                int ii;
                for (ii=0; ii<512; ii++) count_in_not[ii]=0;
@@ -147,13 +148,6 @@ void inlining_setup(methodinfo *m, t_inlining_globals *inline_env)
 /*     t_inlining_globals *inline_env = DNEW(t_inlining_globals); */
         inlining_init0(m,inline_env);
 
-/* define in options.h; Used in main.c, jit.c & inline.c */
-#ifdef INAFTERMAIN
-if ((utf_new_char("main") == m->name) && (useinliningm)) {
-       useinlining = true;
-       }
-#endif
-
 if (useinlining)
         {
                #ifdef DEBUGi
@@ -401,7 +395,7 @@ if ((inline_env->cummethods < INLINING_MAXMETHODS) &&
      ((opcode != JAVA_INVOKEVIRTUAL) ||
       (opcode != JAVA_INVOKEINTERFACE)) ) &&
     (inlineexceptions || (imi->exceptiontablelength == 0)))  {
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
        count_in++;
        if (inlinevirtuals) { 
                if   (opcode == JAVA_INVOKEVIRTUAL) {
@@ -425,7 +419,7 @@ if (!can) {
 
 if  (imi->flags & ACC_NATIVE) return can; 
 if  (imi->flags & ACC_ABSTRACT) return can; 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
   count_in_rejected++;
 #endif
                                                if (opt_verbose) 
@@ -441,14 +435,14 @@ if  (imi->flags & ACC_ABSTRACT) return can;
 
   if  (!(inlineoutsiders) && (m->class->name != imr->classref->name)) {
        /*** if ((!mult) && (whycannot > 0)) mult = true;  *** First time not needed ***/
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
        count_in_outsiders++;
 #endif
        whycannot = whycannot | IN_OUTSIDERS; /* outsider */ 
        }
   if (inline_env->cummethods >= INLINING_MAXMETHODS) { 
        if ((!mult) && (whycannot > 0)) mult = true; 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
        count_in_maxDepth++;
 #endif
        whycannot = whycannot | IN_MAXDEPTH;  
@@ -471,13 +465,13 @@ if  (imi->flags & ACC_ABSTRACT) return can;
        if (uniqueVirt )   { 
                /* so know why (and that) a unique virtual was rejected for another reason */ 
                if (opcode == JAVA_INVOKEVIRTUAL) { 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
                        count_in_uniqueVirt_not_inlined++;
 #endif
                        whycannot = whycannot | IN_UNIQUEVIRT;  
                        }
                else    {
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
                        count_in_uniqueInterface_not_inlined++;
 #endif
                        whycannot = whycannot | IN_UNIQUE_INTERFACE;  
@@ -496,12 +490,12 @@ if  (imi->flags & ACC_ABSTRACT) return can;
 
   if  (inlineoutsiders && (m->class->name != imr->classref->name)) {
        whycannot = whycannot | IN_OUTSIDERS; /* outsider */ 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
        count_in_outsiders++;
 #endif
        }
 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
   if (mult)  
        count_in_rejected_mult++;
 #endif
@@ -509,7 +503,7 @@ if  (imi->flags & ACC_ABSTRACT) return can;
          log_text("Inline Whynot is too large???");
          assert(0);
   }
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
   count_in_not[whycannot]++; 
 #endif
   }
@@ -704,7 +698,7 @@ inlining_methodinfo *inlining_analyse_method(methodinfo *m,
                if (opt_stat) { 
                        if ((!isnotrootlevel) && !maxdepthHit) {
                                maxdepthHit = true;
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
                                count_in_maxDepth++;
 #endif
                        }
@@ -732,6 +726,8 @@ inlining_methodinfo *inlining_analyse_method(methodinfo *m,
 
                                        if (opcode ==JAVA_INVOKEINTERFACE) {
                                            imr = class_getconstant(m->class, i, CONSTANT_InterfaceMethodref);
+                                               if (!imr)
+                                                       return NULL;
                                                if (!resolve_classref(m,imr->classref,resolveEager,true, true,&imrclass)) {
                                                        log_text("Could not resolve class reference");
                                                        assert(0);
@@ -750,6 +746,8 @@ inlining_methodinfo *inlining_analyse_method(methodinfo *m,
 
                                        } else {
                                                imr = class_getconstant(m->class, i, CONSTANT_Methodref);
+                                               if (!imr)
+                                                       return NULL;
                                                if (!resolve_classref(m,imr->classref,resolveEager,true, true,&imrclass)) {
                                                        log_text("Could not resolve class reference");
                                                        assert(0);
@@ -944,7 +942,7 @@ printf("\n\tinlining_methodinfo for:"); fflush(stdout);
 
 if (r->method != NULL) {
   utf_display(r->method->class->name); printf("."); fflush(stdout); \
-  method_display(r->method); fflush(stdout); \
+  method_println(r->method); fflush(stdout); \
   }
 else {
   printf(" NULL!!!!!\n");fflush(stdout);