New clinit patch code.
[cacao.git] / src / vm / jit / inline / parseRTstats.c
index 34124c443f9f691e40d9596f8661e3bd65a756b8..225c1cd3fa1a61d4e0a17b09f1c3648a9ff69c64 100644 (file)
 
    Authors: Carolyn Oates
 
-   $Id: parseRTstats.c 557 2003-11-02 22:51:59Z twisti $
+   $Id: parseRTstats.c 1553 2004-11-19 15:47:13Z carolyn $
 
 */
-
-
 #include <stdio.h>
-#include "parseRT.h"
+#include "toolbox/list.h"
+#include "options.h"
+#include "tables.h"
+#include "statistics.h"
 #include "loader.h"
-#include "toolbox/loging.h"
+#include "parseRT.h"
+#include "parseRTstats.h"
 
+int pClassHeirStatsOnly = 2;
+int pClassHeir = 2;
 
-/*--- Statistics ----------------------------------------------------------*/
+/*--- Statistics ---------------------------------------------------------*/
 
 int unRTclassHeirCnt=0;
 int unRTmethodCnt = 0;
@@ -80,128 +84,52 @@ int RTmethodAbstract = 0;
 int subRedefsCnt =0;
 int subRedefsCntUsed =0;
 
-/*------------- RTAprint flags ------------------------------------------------------------------*/
-int pCallgraph  = 0;    /* 0 - dont print 1 - print at end from main                             */ 
-/* 2 - print at end of RT parse call                                     */
-/* 3- print after each method RT parse                                   */
-int pClassHeir  = 1;    /* 0 - dont print 1 - print at end from main                             */
-/* 2 - print at end of RT parse call  3-print after each method RT parse */
-int pClassHeirStatsOnly = 1;  /* usually 2 Print only the statistical summary info for class heirarchy     */
-
-int pOpcodes    = 0;    /* 0 - don't print 1- print in parse RT 2- print in parse                */
-/* 3 - print in both                                                     */
-int pWhenMarked = 0;    /* 0 - don't print 1 - print when added to callgraph + when native parsed*/
-/* 2 - print when marked+methods called                                  */
-/* 3 - print when class/method looked at                                 */
-int pStats = 0;         /* 0 - don't print; 1= analysis only; 2= whole unanalysed class heirarchy*/
-
-/*-----------------------------------------------------------------------------------------------*/
-/*-----------------------------------------------------------------------------------------------*/
-void printXTACallgraph ()
-{ 
-       int i;
-
-       if (XTAdebug >= 1) {
-               printf("----- XTA Callgraph Worklist:<%i>\n",methXTAlast);
-               for (i=0;i<=methXTAlast;i++) {
-                       printf("  (%i): ",i);
-                       utf_display(XTAcallgraph[i]->class->name);
-                       printf(":");
-                       method_display(XTAcallgraph[i]);
-               }
 
-               printf("\n\n");
-       }
-}
 
-/*-----------------------------------------------------------------------------------------------*/
-/*-----------------------------------------------------------------------------------------------*/
+/*--------------------------------------------------------------*/
+void printCallgraph (list *rtaWorkList)
+{ 
+    int i = 1;
+    rtaNode    *rta;
+    methodinfo *rt_meth;  
 
-void printCallgraph ()
-{ int i;
+ printf("-*-*-*-*- RTA Callgraph Worklist:<%i>\n",count_methods_marked_used);
 
- printf("----- RTA Callgraph Worklist:<%i>\n",methRTlast);
- for (i=0;i<=methRTlast;i++) {
-        printf("  (%i): ",i);
-        utf_display(callgraph[i]->class->name);
-        printf(":");
-        method_display(callgraph[i]);
- }
+   for (rta =list_first(rtaWorkList);
+         rta != NULL;
+         rta =list_next(rtaWorkList,rta))
+       {
+        rt_meth = rta->method;
+
+         printf("  (%i): ",i++); 
+         method_display_w_class(rt_meth);
+       }
 
  printf("\n\n");
-}
-/*--------------------------------------------------------------*/
-void printObjectClassHeirarchy1() {
-       if (pStats >= 1) {
-        unRTclassHeirCnt=0;
-        unRTmethodCnt = 0;
-               printObjectClassHeirarchy(class_java_lang_Object);
-        printf("\n >>>>>>>>>>>>>>>>>>>>  END of unanalysed Class Heirarchy: #%i classes /  #%i methods\n\n",
-                          unRTclassHeirCnt,unRTmethodCnt);
-       }
 
 }
 /*--------------------------------------------------------------*/
-void printObjectClassHeirarchy(classinfo  *class) {
-  
-       classinfo  *subs;
-       methodinfo *meth;
-       int t,m,cnt;
-
-       if (class == NULL) {return;}
-       unRTclassHeirCnt++; unRTmethodCnt += class->methodscount;
-       if (pStats == 2) {
-               printf("\n");
-               /* Class Name */
-               for (t=0;t<class->index;t++) printf("\t"); 
-               if (class->flags & ACC_INTERFACE) printf("ABSTRACT ");
-
-               printf("Class: "); 
-               utf_display(class->name);    
-               printf(" <%i> (depth=%i) \n",class->classUsed,class->index);
-               /* Print methods used */
-               cnt=0; 
-               for (m=0; m < class->methodscount; m++) {
-            meth = &class->methods[m];
-                       if (cnt == 0) {
-                               for (t=0;t<class->index;t++) printf("\t");
-                               printf("aMethods used:\n");
-                       }
-                       for (t=0;t<class->index;t++) printf("\t");
-                       printf("\t");
-                       utf_display(meth->class->name); 
-                       printf(".");
-                       method_display(meth);
-                       cnt++;
-           }
-               if (cnt > 0) printf("> %i of %i methods\n",cnt, class->methodscount);
-    }
-
-    for (subs = class->sub;subs != NULL;subs = subs->nextsub) {
-               printObjectClassHeirarchy(subs);
-       }
-
-}
 /*--------------------------------------------------------------*/
 /*--------------------------------------------------------------*/
 int subdefd(methodinfo *meth) {
     classinfo *subs;
     methodinfo *submeth;
 
-       /*printf("subdefd for:");utf_display(meth->class->name);printf(".");method_display(meth); fflush(stdout);*/
+       printf("subdefd for:");
+       method_display_w_class(meth);
 
     if (  (meth->flags & ACC_STATIC) && (meth->flags & ACC_FINAL ) )  
-       panic("Possible Poly call for FINAL or STATIC\n");
+       printf("\n\n\nPossible Poly call for FINAL or STATIC\n\n\n");
 
     if ((meth->class->sub == NULL)  && (!(meth->flags & ACC_ABSTRACT )) ) { 
                return 0;
        }
     if (meth->flags & ACC_ABSTRACT ) ; /*printf("AB\n"); fflush(stdout); */
 
-       /*printf("s exist for:");utf_display(meth->class->name);printf(".");method_display(meth);*/
+       printf("sub exist for:");method_display_w_class(meth);
 
     for (subs = meth->class->sub;subs != NULL;subs = subs->nextsub) {
-               submeth = class_findmethod(subs, meth->name, meth->descriptor); 
+               submeth = class_findmethod_approx(subs, meth->name, meth->descriptor); 
                if (submeth != NULL) {
                        subRedefsCnt++;
                        if (submeth->methodUsed == USED) {
@@ -217,8 +145,48 @@ int subdefd(methodinfo *meth) {
     if (subRedefsCntUsed > 0) return 1;
     return 0;
 }
+
+/*--------------------------------------------------------------*/
+#define CLASSINFO(cls,txt)  { \
+  printf(txt); fflush(stdout); \
+    printf(" <c%i>(depth=%i) ",cls->classUsed,cls->index); \
+    printf("\tbase/diff =%3d/%3d\t", \
+                                  cls->vftbl->baseval, \
+                                  cls->vftbl->diffval); \
+  utf_display(cls->name); printf("\n"); fflush(stdout); } 
+
 /*--------------------------------------------------------------*/
 
+void printRTClassHeirarchy2(classinfo  *class) {
+classinfo  *s;
+  methodinfo *meth;
+  int m;
+
+  if (class == NULL) {return;}
+  CLASSINFO(class,"CLASS: ");
+  for (s = class->super; s != NULL; s = s->super) {
+    CLASSINFO(s,"SUPER:: ");
+    }
+
+  printf("METHODs: "); fflush(stdout);
+
+  for (m=0; m < class->methodscount; m++) {
+    meth = &class->methods[m];
+    printf("(%i) ",m);
+    METHINFOx(meth);
+    }
+  printf("---------------------------\n");fflush(stdout);
+
+    if (class->sub != NULL) printf("SUBS:\n:");
+    else printf("NO SUBS\n");
+    fflush(stdout);
+
+    for (s = class->sub; s != NULL; s = s->nextsub) {
+               printRTClassHeirarchy2(s);
+               printf("---------------------------\n");fflush(stdout);
+       }
+}
+
 void printRTClassHeirarchy(classinfo  *class) {
   
        classinfo  *subs;
@@ -235,16 +203,18 @@ void printRTClassHeirarchy(classinfo  *class) {
                        meth = &class->methods[m];
                        if (meth->methodUsed == USED) {
                                if (pClassHeirStatsOnly >= 2) {
-                                       printf("METHOD marked used in CLASS marked NOTUSED: "); 
-                                       utf_display(class->name);
-                                       printf(".");
-                                       method_display(meth);
+                                       printf("\nMETHOD marked used in CLASS marked NOTUSED: \n\t"); 
+                                       method_display_w_class(meth);
                                        printf("<%i>\n\t",meth->methodUsed);
                                        fflush(stdout);
-                                       printf("\n\n\n\nMETHOD marked used in CLASS marked NOTUSED\n\n\n\n"); 
+                                       printf("\nMETHOD marked used in CLASS marked NOTUSED\n\n\n\n"); 
                                }
+                       }       
+                       else {
+                               printf(" UNUSED METHOD "); fflush(stdout);
+                               method_display_w_class(meth);
                        }
-               }
+               }       
        }
 
     if (class->classUsed != NOTUSED) {
@@ -316,8 +286,7 @@ void printRTClassHeirarchy(classinfo  *class) {
                                        if (meth->flags & ACC_ABSTRACT ) {
                                                if (pClassHeirStatsOnly >= 2) {
                                                        printf("STATS: abstract_method=");
-                                                       utf_display(meth->class->name);printf(".");
-                                                       method_display(meth);
+                                                       method_display_w_class(meth);
                                                }
                                        }
                                        else    {
@@ -339,22 +308,19 @@ void printRTClassHeirarchy(classinfo  *class) {
                                        }
                                        cnt++;
                                        printf("\t");
-                                       utf_display(meth->class->name); 
-                                       printf(".");
-                                       method_display(meth);
+                                       method_display_w_class(meth);
                                        printf("\t\t");
-                                       if (meth->monoPoly != MONO) printf("\t\tRedefs used/total<%i/%i>\t", meth->subRedefsUsed, meth->subRedefs);
-                                       if ( (XTAOPTbypass3) || (opt_xta)) {
-                                               if (meth->xta->XTAclassSet == NULL)
-                                                       printf("class set never created\n");
-                                               else
-                                                       printSet(meth->xta->XTAclassSet->head);
-                                       }
+                                       if (meth->monoPoly != MONO) printf("\t\tRedefs used/total<%i/%i>\n", meth->subRedefsUsed, meth->subRedefs);
                                }
                        }
                }
                if (pClassHeirStatsOnly >= 2) {
-                       if (cnt > 0) printf("> %i of %i methods used\n",cnt, class->methodscount);
+                       if (cnt > 0) {
+                               if (class->classUsed == PARTUSED)
+                                 printf("> %i of %i methods (part)used\n",cnt, class->methodscount);
+                               if (class->classUsed == USED)
+                                 printf("> %i of %i methods used\n",cnt, class->methodscount);
+                               }
                }
        }
 
@@ -408,7 +374,8 @@ void printRTInterfaceClasses() {
                                printf("\n");
                        }
                        if (inBy->classType->classUsed == NOTUSED) 
-                               panic("printRTInterfaceClasses: class in the implemented list without being used!!!??");
+                               printf("\n\n\nprintRTInterfaceClasses: class in the implemented list without being used!!!??\n\n\n");
+                       fflush(stdout);
                }
                if (pClassHeir >= 2) {
                        printf("\t\t\tImpld by: %i\n",impldBycnt);
@@ -432,7 +399,7 @@ void printRTInterfaceClasses() {
                                        RTmethodInterfaceMethodUsedCnt++;
                                        if (pClassHeirStatsOnly >= 2) {
                                                printf("\t\t"); 
-                                               utf_display(ici->name);printf(".");method_display(imi);fflush(stdout);
+                                               method_display_w_class(imi);
                                        }
                                        if (impldBycnt == 1) {
                                                classinfo  *cii;
@@ -442,16 +409,16 @@ void printRTInterfaceClasses() {
                                        inBy = ici->impldBy;
                                                cii = inBy->classType;
                                                
-                                               mii = class_findmethod(cii, imi->name, imi->descriptor); 
+                                               mii = class_fetchmethod(cii, imi->name, imi->descriptor); 
                                                if (mii == NULL) {
                                                        /* assume its resolved up the heirarchy and just 1 possiblity so MONO1 */
                                                        imi->monoPoly = MONO1;
                                                        RTmethodInterfacePolyReallyMonoCnt++;
                                                }
                                                else    {
-                                                       if (imi->monoPoly != POLY) 
-                                                               panic ("interface monopoly not POLY");
-
+                                                       /**if (imi->monoPoly != POLY) 
+                                                               printf("\n\n\ninterface monopoly not POLY\n\n\n");
+                                                       **/
                                                        if (mii->monoPoly != POLY) {
                                                                imi->monoPoly = MONO1;
                                                                RTmethodInterfacePolyReallyMonoCnt++;
@@ -479,6 +446,12 @@ void printRTInterfaceClasses() {
                           RTmethodInterfaceMethodNotUsedCnt,RTmethodInterfaceMethodUsedCnt, RTmethodInterfacePolyReallyMonoCnt);
        }
 }
+
+/*--------------------------------------------------------------*/
+
+
+
+/*--------------------------------------------------------------*/
 /*--------------------------------------------------------------*/
 
 void printRThierarchyInfo(methodinfo *m) {
@@ -495,24 +468,24 @@ void printRThierarchyInfo(methodinfo *m) {
        RTmethodMarkedCnt= 0;  
 
 
+printf("RT Heirarchy:------------\n"); fflush(stdout);
        /*-- --*/
-       if (pClassHeirStatsOnly >= 2) {
                printf("\nRT Class Hierarchy for ");
-               printf("--- start of RT info --------------- after :\n");
                if (m != NULL) {
-                       utf_display(m->class->name); 
-                       printf(".");
-                       method_display(m);
+                       method_display_w_class(m);
                        printf("\n");
-               }
-    }
-       printRTClassHeirarchy(class_java_lang_Object);
-       if (pClassHeirStatsOnly >= 2) {
-               printf("--- end  of RT info ---------------\n");
-    }
-       if (pClassHeirStatsOnly >= 1) {
-
+                       }
+               else {  
+                    printf(" called with NULL method\n"); 
+                    return;
+                    }
+       /**printRTClassHeirarchy(class_java_lang_Object); **/
+       printRTClassHeirarchy(m->class);
+       printf("--- end  of RT info ---------------\n");
+
+       if (pClassHeirStatsOnly >= 10) {
                /*--  statistic results --*/
+               if (opt_rt)
                printRTInterfaceClasses();
        
                printf("\n  >>>>>>>>>>>>>>>>>>>>  Analysed Class Hierarchy Statistics:\n"); 
@@ -544,6 +517,8 @@ void printRThierarchyInfo(methodinfo *m) {
 }
 
 
+/*--------------------------------------------------------------*/
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where
@@ -556,3 +531,4 @@ void printRThierarchyInfo(methodinfo *m) {
  * tab-width: 4
  * End:
  */
+