Authors: Carolyn Oates
- $Id: parseRTstats.c 907 2004-01-29 13:20:05Z carolyn $
+ $Id: parseRTstats.c 1553 2004-11-19 15:47:13Z carolyn $
*/
-
-
+#include <stdio.h>
+#include "toolbox/list.h"
+#include "options.h"
+#include "tables.h"
+#include "statistics.h"
+#include "loader.h"
#include "parseRT.h"
#include "parseRTstats.h"
+int pClassHeirStatsOnly = 2;
+int pClassHeir = 2;
-/*--- Statistics ----------------------------------------------------------*/
+/*--- Statistics ---------------------------------------------------------*/
int unRTclassHeirCnt=0;
int unRTmethodCnt = 0;
int subRedefsCnt =0;
int subRedefsCntUsed =0;
-/*-----------------------------------------------------------------------------------------------*/
-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("----- end of XTA Callgraph Worklist:<%i>\n",methXTAlast);
- printf("\n\n");
-// }
-}
-/*-----------------------------------------------------------------------------------------------*/
-/*-----------------------------------------------------------------------------------------------*/
+/*--------------------------------------------------------------*/
+void printCallgraph (list *rtaWorkList)
+{
+ int i = 1;
+ rtaNode *rta;
+ methodinfo *rt_meth;
+
+ printf("-*-*-*-*- RTA Callgraph Worklist:<%i>\n",count_methods_marked_used);
-void printCallgraph ()
-{ int i;
+ for (rta =list_first(rtaWorkList);
+ rta != NULL;
+ rta =list_next(rtaWorkList,rta))
+ {
+ rt_meth = rta->method;
- 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]);
- }
+ printf(" (%i): ",i++);
+ method_display_w_class(rt_meth);
+ }
printf("\n\n");
-}
-/*--------------------------------------------------------------*/
-void printObjectClassHeirarchyAll() {
- 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_fetchmethod(subs, meth->name, meth->descriptor);
+ submeth = class_findmethod_approx(subs, meth->name, meth->descriptor);
if (submeth != NULL) {
subRedefsCnt++;
if (submeth->methodUsed == USED) {
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) {
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) {
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 {
}
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 == NULL) {
- printf("class set never created\n");
- }
- else {
- 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);
+ }
}
}
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);
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;
}
else {
/**if (imi->monoPoly != POLY)
- panic ("interface monopoly not POLY");
+ printf("\n\n\ninterface monopoly not POLY\n\n\n");
**/
if (mii->monoPoly != POLY) {
imi->monoPoly = MONO1;
RTmethodInterfaceMethodNotUsedCnt,RTmethodInterfaceMethodUsedCnt, RTmethodInterfacePolyReallyMonoCnt);
}
}
+
+/*--------------------------------------------------------------*/
+
+
+
+/*--------------------------------------------------------------*/
/*--------------------------------------------------------------*/
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) {
- fflush(stdout);
- 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();
}
+/*--------------------------------------------------------------*/
+
/*
* 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
* tab-width: 4
* End:
*/
+