more XTA updates
[cacao.git] / src / vm / jit / inline / parseRT.c
1 /* jit/parseRT.c - parser and print functions for Rapid Type Analyis
2
3    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4    R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
5    M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
6    P. Tomsich, J. Wenninger
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Carolyn Oates
28
29    $Id: parseRT.c 657 2003-11-20 15:18:33Z carolyn $
30
31 */
32
33
34 #include "parseRT.h"
35  
36 /*------------ global variables -----------------------------------------*/
37 #define MAXCALLGRAPH 5000
38
39 #include "parseRTflags.h"
40
41 int methRT = 0;
42 int methRTlast = -1;
43 int methRTmax = MAXCALLGRAPH;
44 methodinfo **callgraph;
45 /*methodinfo *callgraph[MAXCALLGRAPH];*/ 
46
47  
48 int methXTA = 0;            
49 int methXTAlast = -1;
50 int methXTAmax = MAXCALLGRAPH;        
51 methodinfo **XTAcallgraph;
52 /*methodinfo *XTAcallgraph[MAXCALLGRAPH];*/
53
54 static bool nativecallcompdone=0 ;
55
56 static bool firstCall= true;
57 static bool AfterMain = false;
58 static FILE *rtMissed;   /* Methods missed during RTA parse of Main  */
59 /*   so easier to build dynmanic calls file */
60
61 static utf *utf_MAIN;   /*  utf_new_char("main"); */
62 static utf *INIT    ;   /*  utf_new_char("<init>"); */
63 static utf *CLINIT  ;   /*  utf_new_char("<clinit>"); */
64 static utf *FINALIZE;   /*  utf_new_char("finalize"); */
65 static utf *EMPTY_DESC; /*  utf_new_char("V()");  */
66 static int missedCnt = 0;
67
68
69 /*--------------------------------------------------------------*/
70 /* addToCallgraph - adds to RTA callgraph and                   */ 
71 /*                  sets  meth->methodUsed  to USED             */
72 /*--------------------------------------------------------------*/  
73 //  if ((meth->methodUsed != USED) && (!(meth->flags & ACC_ABSTRACT)) ) { 
74 #define ADDTOCALLGRAPH(meth)  if ((meth->methodUsed != USED) && (!(meth->flags & ACC_ABSTRACT)) ) { \
75         if (opt_rt) {  \
76         callgraph[++methRTlast] = meth ; \
77         meth->methodUsed = USED; \
78                         if(pWhenMarked>=1) \
79                                 {printf("\n Added to Call Graph #%i:",  \
80                                          methRTlast); \
81                                 printf("\t <used flags c/m> <%i/%i> %i\t",  \
82                                   meth->class->classUsed, \
83                                   meth->methodUsed, \
84                                   USED);  \
85                                 printf(" method name =");   \
86                                 utf_display(meth->class->name);printf("."); \
87                                 method_display(meth);fflush(stdout);} \
88         } } 
89
90 /*--------------------------------------------------------------*/
91 bool rtaSubUsed(classinfo *class, methodinfo *meth) {
92         classinfo *subs;
93
94         for (subs=class->sub; subs != NULL; subs = subs->nextsub) {
95                 if (subs->classUsed == USED) {
96                         if (class_findmethod(class, meth->name, meth->descriptor) == NULL)
97                                 return false;
98                         else    
99                                 return true;
100                 }
101                 if (rtaSubUsed(subs, meth)) 
102                         return false;
103         }
104         return false;
105 }
106
107
108 /*--------------------------------------------------------------*/
109 /* Mark the method with same name /descriptor in topmethod      */
110 /* in class                                                     */
111 /*                                                              */
112 /* Class not marked USED and method defined in this class ->    */
113 /*    -> if Method NOTUSED mark method as MARKED                */
114 /* Class marked USED and method defined in this class ->        */
115 /*    -> mark method as USED                                    */
116 /*                                                              */
117 /* Class USED, but method not defined in this class ->          */
118 /*    -> search up the heirarchy and mark method where defined  */
119 /*       if class where method is defined is not USED ->        */
120 /*       -> mark class with defined method as PARTUSED          */
121 /*--------------------------------------------------------------*/
122
123 void rtaMarkMethod(classinfo *class, methodinfo *topmethod) {
124
125         utf *name = topmethod -> name; 
126         utf *descriptor = topmethod -> descriptor;
127         methodinfo *submeth;
128
129         submeth = class_resolvemethod(class, name, descriptor); 
130         if (submeth == NULL)
131                 panic("parse RT: Method not found in class hierarchy");
132         if (submeth->methodUsed == USED) return;
133   
134         if (submeth->class == class) { 
135
136                 /*--- Method defined in class -----------------------------*/
137         if (submeth->class->classUsed != USED) { 
138                         if (submeth->methodUsed == NOTUSED) { 
139
140                 /* Class NOT marked USED and method defined in this class -> */
141                                 /*    -> if Method NOTUSED mark method as  MARKED            */
142                                 if (pWhenMarked >= 1) {
143                                         printf("MARKED class.method\t"); 
144                                         utf_display(submeth->class->name);printf(".");method_display(submeth);
145                                 }
146                                 if (rtaSubUsed(submeth->class,submeth)) {
147                                         submeth->class->classUsed = PARTUSED;
148                                         ADDTOCALLGRAPH(submeth) 
149                                                 }
150                                 else    {
151                                         submeth->methodUsed = MARKED;
152                                         RTAPRINTmarkMethod1
153                                                 }
154                 } }
155         else    {
156                         /* Class IS  marked USED and method defined in this class -> */
157                         /*    -> mark method as USED  */
158                         ADDTOCALLGRAPH(submeth) 
159                                 }
160         } /* end defined in class */
161
162         else {
163                 /*--- Method NOT defined in class -----------------------------*/
164                 if (submeth->class->classUsed == NOTUSED) {
165                         submeth->class->classUsed = PARTUSED;
166                         if (class->classUsed != USED) {
167                                 submeth->methodUsed = MARKED;
168                         }
169                 }
170                 if ( (submeth->class->classUsed == USED) 
171                          || (class->classUsed == USED)) {
172                         ADDTOCALLGRAPH(submeth)
173                                 }
174         } /* end NOT defined in class */
175
176
177 /*-------------------------------------------------------------------------------*/
178 /* Mark the method with the same name and descriptor as topmethod                */
179 /*   and any subclass where the method is defined and/or class is used           */
180 /*                                                                               */
181 /*-------------------------------------------------------------------------------*/
182 void rtaMarkSubs(classinfo *class, methodinfo *topmethod) {
183                 RTAPRINTmarkSubs1
184         rtaMarkMethod(class, topmethod);   /* Mark method in class where it was found */
185         if (class->sub != NULL) {
186                 classinfo *subs;
187         
188                 if (!(topmethod->flags & ACC_FINAL )) {
189                         for (subs = class->sub;subs != NULL;subs = subs->nextsub) {
190                                         RTAPRINTmarkSubs1
191                                 rtaMarkSubs(subs, topmethod); 
192                                 }
193                         }
194                 }
195         return;
196 }
197
198 /*-------------------------------------------------------------------------------*/
199 /* Add Marked methods for input class ci                                         */
200 /* Add methods with the same name and descriptor as implemented interfaces       */
201 /*   with the same method name                                                   */
202 /*                                                                               */
203 /*-------------------------------------------------------------------------------*/
204 void addMarkedMethods(classinfo *ci) {
205         int ii,jj,mm;
206
207         /* add marked methods to callgraph */ 
208         for (ii=0; ii<ci->methodscount; ii++) { 
209                 methodinfo *mi = &(ci->methods[ii]);
210                 if (mi->methodUsed == MARKED) { 
211                         if (pWhenMarked >= 1) {
212                                 printf("ADDED a method that was MARKED\n");
213                                 }
214                         ADDTOCALLGRAPH(mi)  
215                         }
216                 else {
217         
218                         for (jj=0; jj < ci -> interfacescount; jj++) {
219                                 classinfo *ici = ci -> interfaces [jj];
220                                 /*  use resolve method....!!!! */
221                                 if (ici -> classUsed != NOTUSED) {
222                                         for (mm=0; mm< ici->methodscount; mm++) {
223                                                 methodinfo *imi = &(ici->methods[mm]);
224
225                                                 if  (      (imi->methodUsed == USED) 
226                                                                    &&    ( (imi->name == mi->name) 
227                                                                                    &&      (imi->descriptor == mi->descriptor))) {
228                                                         if (pWhenMarked >= 1) 
229                                                                 printf("ADDED a method that was used by an interface\n");
230                                                         ADDTOCALLGRAPH(mi)  
231                                                                 }
232                                         }
233                                 }
234                         }
235                 }
236         }
237 }    
238 /*-------------------------------------------------------------------------------*/
239 /*  XTA Functions                                                                */
240 /*-------------------------------------------------------------------------------*/
241
242 xtainfo *xtainfoInit(methodinfo *m)
243 {
244         if (m->xta != NULL)
245                 return m->xta;
246         m ->xta = (xtainfo *) NEW(xtainfo); 
247         m ->xta-> XTAmethodUsed = NOTUSED;
248         m ->xta-> XTAclassSet   = NULL;
249         m ->xta-> XTAclassSet   = add2ClassSet ( m ->xta-> XTAclassSet, m->class);
250
251         /* PartClassSet */
252         m->xta->paramClassSet = NULL;
253         m->xta->calls         = NULL;
254         m->xta->calledBy      = NULL;
255
256         m->xta->marked        = NULL;
257         /*m ->xta->markedBy     = NULL */
258         m->xta->fldsUsed      = NULL;
259         /*m ->xta->interfaceCalls    = NULL*/
260         m->xta->chgdSinceLastParse = false;
261         return m->xta;
262 }
263
264
265 xtafldinfo * xtafldinfoInit (fieldinfo *f)
266 {
267         if (f->xta != NULL)
268                 return f->xta;
269
270         f->xta = NEW(xtafldinfo);
271
272         f->xta->fieldChecked = false;   /*XTA*/
273         f->xta->fldClassType = NULL;    /*XTA*/
274         f->xta->XTAclassSet = NULL;     /*XTA*/
275
276         return f->xta;
277 }
278
279
280 bool xtaPassParams (methodinfo *SmCalled, methodinfo *SmCalls, methSetNode *lastptrInto)
281 {
282         classSetNode *p;
283         classSetNode *c;
284         classSetNode *c1;
285         classSetNode *cprev;
286         bool          rc = false;
287
288         if (XTAdebug >= 1) {
289                 printf("\n>>>>>>>>>>>>>>>>><<<xtaPassParams \n");fflush(stdout);
290
291                 printf("\tIN SmCalled set : "); 
292                 utf_display(SmCalled->class->name);printf("."); method_display(SmCalled);
293                 printClassSet(SmCalled->xta->XTAclassSet); printf("\n"); 
294
295                 printf("\tIN SmCalls set: "); 
296                 utf_display(SmCalls->class->name);printf("."); method_display(SmCalls);
297                 printClassSet(SmCalls->xta->XTAclassSet); printf("\n"); 
298                 
299                 printf("\tIN lastptrInto : (");
300                 if (lastptrInto->lastptrIntoClassSet2 != NULL) {
301                         utf_display(lastptrInto->lastptrIntoClassSet2->classType->name); printf(") ");
302                 }
303                 else {printf("NULL) ");}
304                 fflush(stdout);
305                 utf_display(lastptrInto->methRef->class->name);printf("."); fflush(stdout);
306                 method_display(lastptrInto->methRef); fflush(stdout);
307                 printf("\n");fflush(stdout);
308         }
309
310         /* Get SmCalled ParamType set if null */
311         if (SmCalled->xta->paramClassSet == NULL) {
312                 SmCalled->xta->paramClassSet = descriptor2typesL(SmCalled); 
313         }
314         if (XTAdebug >= 1) {
315                 printf("\tParamPassed\n"); fflush(stdout);
316                 printSet(SmCalled->xta->paramClassSet);fflush(stdout);
317                 printf("\n"); fflush(stdout);
318         }
319
320         if (lastptrInto->lastptrIntoClassSet2 == NULL) {
321                 if (SmCalls->xta->XTAclassSet != NULL) 
322                         c1 = SmCalls->xta->XTAclassSet->head;
323                 else
324                         c1 = NULL;
325         }
326         else    {
327                 /* start with type where left off */
328                 c1 = lastptrInto->lastptrIntoClassSet2;  
329                 c1 = c1 -> nextClass;  /* even if NULL */
330         }
331         cprev = NULL;
332         if (XTAdebug >= 1) {
333                 if (c1 == NULL){
334                         printf("\tIN SmCalls ... start with NULL\n"); fflush(stdout);
335                 }
336                 else    {
337                         printf("\tIN SmCalls ... start with :");fflush(stdout);
338                         utf_display(c1->classType->name); printf("\n");
339                 }
340         }
341
342         /* for each Param Class */
343         for (   p=SmCalled->xta->paramClassSet; p != NULL; p = p->nextClass) {
344
345                 /* for each SmCalls class */
346                 for (c=c1; c != NULL; c = c->nextClass) {
347                         vftbl *p_cl_vt = p->classType->vftbl; 
348                         vftbl *c_cl_vt = c->classType->vftbl; 
349
350                         /* if SmCalls class is in the Params Class range */
351                         if (  (p_cl_vt->baseval <=  c_cl_vt->baseval)
352                                   && (c_cl_vt->baseval <= (p_cl_vt->baseval+p_cl_vt->diffval)) ) {
353
354                                 /*    add SmCalls class to SmCalledBy Class set */
355                                 SmCalled->xta->XTAclassSet = SmCalled->xta->XTAclassSet = add2ClassSet(SmCalled->xta->XTAclassSet, c->classType); 
356                                 rc = true;
357                         }
358                         cprev = c;
359                 }       
360         }
361         lastptrInto->lastptrIntoClassSet2 = cprev;
362         if (XTAdebug >= 1) {
363                 printf("\tOUT SmCalled set: ");fflush(stdout);
364                 printClassSet(SmCalled->xta->XTAclassSet);fflush(stdout);
365
366                 printf("\tOUT SmCalls set: ");fflush(stdout);
367                 printClassSet(SmCalls->xta->XTAclassSet);fflush(stdout);
368
369                 printf("\tOUT  lastptrInto="); fflush(stdout);
370                 if (lastptrInto->lastptrIntoClassSet2 != NULL)
371                         utf_display(lastptrInto->lastptrIntoClassSet2->classType->name);
372
373                 printf("<rc=%i>\n",rc);fflush(stdout);
374         }
375         return rc;
376 }
377
378 /*-------------------------------------------------------------------------------*/
379 bool xtaPassReturnType(methodinfo *SmCalled, methodinfo *SmCalls) {
380
381         classSetNode* cs;
382         classSetNode* cs1;
383         bool          rc = false;
384
385         if (XTAdebug >= 1)
386                 printf("xtaPassReturnType \n");
387
388         /* Get SmCalled return class is null */
389         if ((SmCalled->returnclass == NULL) && (SmCalled->xta->paramClassSet == NULL)) {
390                 SmCalled->xta->paramClassSet = descriptor2typesL(SmCalled); 
391         }
392
393         if (SmCalled->returnclass == NULL) {
394                 if (XTAdebug >= 1)
395                         printf("\tReturn type is NULL\n");
396                 return rc;
397         }
398         
399         if (XTAdebug >= 1) {
400                 printf("\tReturn type is: ");
401                 utf_display(SmCalled->returnclass->name);
402                 printf("\n");
403
404                 printf("\tIN SmCalls set: ");
405                 utf_display(SmCalls->class->name); printf("."); method_display(SmCalls);
406                 printClassSet(SmCalls->xta->XTAclassSet);
407
408                 printf("\tIN SmCalled set: ");
409                 utf_display(SmCalled->class->name); printf("."); method_display(SmCalled);
410                 printClassSet(SmCalled->xta->XTAclassSet);
411         }
412
413
414         if (SmCalled->xta->XTAclassSet == NULL) 
415                 cs1 = NULL;
416         else
417                 cs1 =  SmCalled->xta->XTAclassSet->head;
418         for (cs =cs1; cs != NULL; cs = cs->nextClass) {
419                 classinfo *c = cs->classType;
420                 vftbl *r_cl_vt = SmCalled->returnclass->vftbl; 
421                 vftbl *c_cl_vt = c->vftbl; 
422
423                 /* if class is a subtype of the return type, then add to SmCalls class set (ie.interscection)*/
424                 if (  (r_cl_vt->baseval <=  r_cl_vt->baseval)
425                           && (c_cl_vt->baseval <= (r_cl_vt->baseval+r_cl_vt->diffval)) ) {
426                         SmCalls->xta->XTAclassSet = add2ClassSet(SmCalls->xta->XTAclassSet, c);  
427                         rc = true;
428                 }
429         } 
430
431         if (XTAdebug >= 1) {
432                 printf("\tOUT SmCalls set: ");
433                 printClassSet(SmCalls->xta->XTAclassSet);
434         }
435         return rc;
436 }
437
438 /*-------------------------------------------------------------------------------*/
439 void xtaAddCallEdges(methodinfo *mi, s4 monoPoly) {
440
441         if (mi->xta == NULL)
442                 mi->xta = xtainfoInit(mi);
443         if (mi->xta->XTAmethodUsed  != USED) {  /* if static method not in callgraph */
444                 mi->xta->XTAmethodUsed = USED;
445                 if (!(mi->flags & ACC_ABSTRACT)) { 
446                         XTAcallgraph[++methXTAlast] = mi;
447                                                 XTAPRINTcallgraph2 
448                         }
449
450                 }
451                         /*RTAprint*/ if(pWhenMarked>=1) {  
452                                 /*RTAprint*/ printf("\nxxxxxxxxxxxxxxxxx XTA set Used or Added to Call Graph #%i:", 
453                                 /*RTAprint*/       methXTAlast); 
454                                 /*RTAprint*/ printf(" method name ="); fflush(stdout);
455                                 /*RTAprint*/ utf_display(mi->class->name);fflush(stdout); printf(".");fflush(stdout); 
456                                 /*RTAprint*/ method_display(mi);fflush(stdout); 
457                                 /*RTAprint*/ printf("\t\t\t\tcalledBy:");
458                                 /*RTAprint*/ utf_display(rt_method->class->name);fflush(stdout); printf(".");fflush(stdout); 
459                                 /*RTAprint*/ method_display(rt_method);fflush(stdout); 
460                                 /*RTAprint*/ }
461         /* add call edges */
462         rt_method->xta->calls = add2MethSet(rt_method->xta->calls, mi);
463         rt_method->xta->calls->tail->monoPoly = monoPoly;
464         mi->xta->calledBy     = add2MethSet(mi->xta->calledBy,     rt_method); 
465         if (mi->xta->calledBy     == NULL) panic("mi->xta->calledBy is NULL!!!");
466         if (rt_method->xta->calls == NULL) panic("rt_method->xta->calls is NULL!!!");
467 }
468
469
470 /*--------------------------------------------------------------*/
471 bool xtaSubUsed(classinfo *class, methodinfo *meth, classSetNode *subtypesUsedSet) {
472         classinfo *subs;
473
474         for (subs=class->sub; subs != NULL; subs = subs->nextsub) {
475                 /* if class used */
476                 if (inSet(subtypesUsedSet,subs)) {
477                         if (class_findmethod(class, meth->name, meth->descriptor) == NULL) 
478                                 return false;
479                         else    {
480                                 if (class_findmethod(subs, meth->name, meth->descriptor) == NULL) 
481                                         return true;
482                                 }
483                 }
484                 if (xtaSubUsed(subs, meth,  subtypesUsedSet)) 
485                         return false;
486         }
487         return false;
488 }
489
490
491 /*-------------------------------------------------------------------------------*/
492 void xtaMarkMethod(classinfo *class, methodinfo *topmethod, classSetNode *subtypesUsedSet)
493 {
494         methodinfo *submeth;
495
496         utf *name = topmethod -> name;
497         utf *descriptor = topmethod -> descriptor;
498         /****/
499                  printf("xtaMarkMethod for:"); utf_display(class->name);fflush(stdout); 
500                  method_display(topmethod);
501         /**/
502
503         submeth = class_resolvemethod(class, name, descriptor);
504
505         /***/
506                 printf(" def: "); utf_display(submeth->class->name);fflush(stdout);
507                 method_display(submeth);
508         /****/
509
510         /* Basic checks */
511         if (submeth == NULL)
512         panic("parse XTA: Method not found in class hierarchy");
513         if (submeth->xta == NULL) 
514                 submeth->xta = xtainfoInit(submeth);
515
516         if (rt_method->xta->calls != NULL) {
517                 if (inMethSet(rt_method->xta->calls->head,submeth)) return;
518         }
519         /*----*/
520         if (submeth->class == class) {
521
522         /*--- Method defined in class -----------------------------*/
523                 if (inSet(subtypesUsedSet,submeth->class)) {
524 printf("in set submeth->class:"); utf_display(submeth->class->name);
525                         xtaAddCallEdges(submeth,POLY);  
526                 }
527                 else    {
528                         if (subtypesUsedSet != NULL) {  
529                                 if (xtaSubUsed (class,submeth,subtypesUsedSet)) {
530 printf("xtaSubUsed "); 
531                                         xtaAddCallEdges(submeth,POLY);
532                                 }
533                         }
534                         else    {
535                                 rt_method->xta->marked = add2MethSet(rt_method->xta->marked, submeth);
536                         }
537                 }
538         }
539         else  {
540         /*--- Method NOT defined in class -----------------------------*/
541                 if (!(inSet(subtypesUsedSet,submeth->class) )){  /* class with method def     is not used */
542                         if (!(inSet(subtypesUsedSet,class) )) { /* class currently resolving is not used */ 
543                                 rt_method->xta->marked = add2MethSet(rt_method->xta->marked, submeth);
544                                 /*printf("Added to marked Set: "); fflush(stdout);printMethodSet(rt_method->xta->marked);*/
545                         }
546                 }
547                 if ( (inSet(subtypesUsedSet,submeth->class))  /* class with method def     is used */
548                          || (inSet(subtypesUsedSet,class)) ) {       /* class currently resolving is used */ 
549                         xtaAddCallEdges(submeth,POLY);
550                 }
551
552         } /* end defined in class */
553
554 }
555 /*-------------------------------------------------------------------------------*/
556 void xtaMarkSubs(classinfo *class, methodinfo *topmethod, classSetNode *subtypesUsedSet) {
557         /* xtaPRINTmarkSubs1*/
558         xtaMarkMethod(class, topmethod,subtypesUsedSet);   /* Mark method in class where it was found */
559         if (class->sub != NULL) {
560                 classinfo *subs;
561
562                 if (!(topmethod->flags & ACC_FINAL )) {
563                         for (subs = class->sub; subs != NULL; subs = subs->nextsub) {
564                                 /* xtaPRINTmarkSubs1 */
565                                 xtaMarkSubs(subs, topmethod, subtypesUsedSet);
566                                 }
567                         }
568                 }
569 }
570
571 /*-------------------------------------------------------------------------------*/
572 /* Both RTA and XTA */
573 /*-------------------------------------------------------------------------------*/
574
575 int addClassInit(classinfo *ci) {
576         /* CHANGE to a kind of table look-up for a list of class/methods (currently 3)
577          */
578
579         utf* utf_java_lang_system = utf_new_char("java/lang/System"); 
580         utf* utf_initializeSystemClass = utf_new_char("initializeSystemClass"); 
581         utf* utf_java_lang_Object = utf_new_char("java/lang/Object"); 
582
583         int m, m1=-1, m2=-1, mf=-1;
584         methodinfo *mi;
585
586         for  (m=0; m < ci->methodscount; m++) {
587                 /*<clnit> class init method */
588                 if (ci->methods[m].name == CLINIT) {
589                         m1=m;
590                 }
591                 /* Special case: System class has an extra initializer method */
592                 if        ((utf_java_lang_system == ci->name) 
593                            && (utf_initializeSystemClass == ci->methods[m].name)) {
594                         m2=m;  
595         }
596
597                 /* Finalize methods */
598                 if    ((ci->methods[m].name == FINALIZE) 
599                            && (ci->name != utf_java_lang_Object)) {
600                         mf=m;  
601         }
602
603     }
604
605         if (m1 >= 0) { /* No <clinit>  available - ignore */  
606
607                 /* Get clinit methodinfo ptr */
608                 mi = class_findmethod (ci,ci->methods[m1].name , NULL); 
609
610                 /*--- RTA ---*/
611                 if ( mi->methodUsed != USED) {
612                         mi->class->classUsed = PARTUSED;  
613                         ADDTOCALLGRAPH(mi)  
614                                 }
615
616                 /*--- XTA ---*/
617                 if ((XTAOPTbypass) || (opt_xta)) {
618                         xtaAddCallEdges(mi,MONO); 
619                 }
620
621         }
622
623         if (mf >= 0) {   
624
625                 /* Get finalize methodinfo ptr */
626                 mi = class_findmethod (ci,ci->methods[mf].name , NULL); 
627
628                 /*--- RTA ---*/
629                 if ( mi->methodUsed != USED) {
630                         mi->class->classUsed = PARTUSED;  
631                         ADDTOCALLGRAPH(mi)  
632                                 }
633
634                 /*--- XTA ---*/
635                 if ((XTAOPTbypass) || (opt_xta)) {
636                         xtaAddCallEdges(mi,MONO); 
637                 }
638         }
639
640         /*Special Case for System class init:  
641         add java/lang/initializeSystemClass to callgraph */
642         if (m2 >= 0) {
643                 /* Get clinit methodinfo ptr */
644                 mi = class_findmethod (ci,ci->methods[m2].name , NULL); 
645
646                 /*--- RTA ---*/
647                 if ( mi->methodUsed != USED) {
648                         mi->class->classUsed = PARTUSED;
649                         ADDTOCALLGRAPH(mi)  
650                                 }
651
652                 /*--- XTA ---*/
653                 if ((XTAOPTbypass) || (opt_xta)) {
654                         xtaAddCallEdges(mi,MONO);
655                 }
656         }
657
658         /* add marked methods to callgraph */ 
659         addMarkedMethods(ci); 
660                 
661         return m;
662
663
664
665 #define rt_code_get_u1(p)  rt_jcode[p]
666 #define rt_code_get_s1(p)  ((s1)rt_jcode[p])
667 #define rt_code_get_u2(p)  ((((u2)rt_jcode[p])<<8)+rt_jcode[p+1])
668 #define rt_code_get_s2(p)  ((s2)((((u2)rt_jcode[p])<<8)+rt_jcode[p+1]))
669 #define rt_code_get_u4(p)  ((((u4)rt_jcode[p])<<24)+(((u4)rt_jcode[p+1])<<16)\
670                            +(((u4)rt_jcode[p+2])<<8)+rt_jcode[p+3])
671 #define rt_code_get_s4(p)  ((s4)((((u4)rt_jcode[p])<<24)+(((u4)rt_jcode[p+1])<<16)\
672                            +(((u4)rt_jcode[p+2])<<8)+rt_jcode[p+3]))
673
674
675
676 /*-------------------------------------------------------------------------------*/
677 void rtaAddUsedInterfaceMethods(classinfo *ci) {
678         int jj,mm;
679
680         /* add used interfaces methods to callgraph */
681         for (jj=0; jj < ci -> interfacescount; jj++) {
682                 classinfo *ici = ci -> interfaces [jj];
683         
684                 if (pWhenMarked >= 1) { 
685                         printf("BInterface used: ");fflush(stdout); 
686                         utf_display(ici->name);
687                         printf("<%i>\t",ici -> classUsed ); fflush(stdout); 
688                         if (ici -> classUsed == NOTUSED) printf("\t classUsed=NOTUSED\n" );
689                         if (ici -> classUsed == USED) printf("\t classUsed=USED\n");
690                         if (ici -> classUsed == PARTUSED) printf("\t classUsed=PARTUSED\n");
691                         fflush(stdout);
692                 }
693                 /* add class to interfaces list of classes that implement it */
694                 ici -> impldBy =  addElement(ici -> impldBy,  ci);
695
696                 /* if interface class is used */
697         if (ici -> classUsed != NOTUSED) {
698
699                         /* for each interface method implementation that has already been used */
700                         for (mm=0; mm< ici->methodscount; mm++) {
701                                 methodinfo *imi = &(ici->methods[mm]);
702                                 if (pWhenMarked >= 1) { 
703                                         if  (imi->methodUsed != USED) {
704                                                 if (imi->methodUsed == NOTUSED) printf("Interface Method notused: "); 
705                                                 if (imi->methodUsed == MARKED) printf("Interface Method marked: "); 
706                                                 utf_display(ici->name);printf(".");method_display(imi);fflush(stdout);
707                                         }
708                                 } 
709                                 if  (imi->methodUsed == USED) {
710                                         if (pWhenMarked >= 1) { 
711                                                 printf("Interface Method used: "); utf_display(ici->name);printf(".");method_display(imi);fflush(stdout);
712
713                                                 /* Mark this method used in the (used) implementing class and its subclasses */
714                                                 printf("rMAY ADD methods that was used by an interface\n");
715                                         }
716                                         rtaMarkSubs(ci,imi);
717                                 }
718                         }
719                 }
720         }
721
722 }
723 /*-------------------------------------------------------------------------------*/
724 void rtaMarkInterfaceSubs(methodinfo *mi) {                             
725         classSetNode *subs;
726         if (mi->class->classUsed == NOTUSED) {
727                 mi->class->classUsed = USED; 
728                 class_java_lang_Object->impldBy =  addElement(class_java_lang_Object -> impldBy,  mi->class);
729                 }
730
731         /* add interface class to list kept in Object */
732         mi->methodUsed = USED;
733         mi->monoPoly   = POLY;
734
735         subs =  mi->class->impldBy; 
736                                                 RTAPRINT08invokeInterface1
737         while (subs != NULL) {                  
738                 classinfo * isubs = subs->classType;
739                                                         RTAPRINT09invokeInterface2
740                 /* Mark method (mark/used) in classes that implement the method */
741                 if (isubs->classUsed != NOTUSED) {
742                         methodinfo *submeth;
743                                                 
744                         submeth = class_findmethod(isubs,mi->name, mi->descriptor); 
745                         if (submeth != NULL)
746                                 submeth->monoPoly = POLY; /*  poly even if nosubs */
747                         rtaMarkSubs(isubs, mi);  
748                         }
749                                 
750                 subs = subs->nextClass;
751                 } /* end while */
752
753
754 /*-------------------------------------------------------------------------------*/
755 /*-------------------------------------------------------------------------------*/
756
757
758
759 /*-------------------------------------------------------------------------------*/
760 void xtaAddUsedInterfaceMethods(classinfo *ci) {
761         int jj,mm;
762
763 /* add used interfaces methods to callgraph */
764 for (jj=0; jj < ci -> interfacescount; jj++) {
765         classinfo *ici = ci -> interfaces [jj];
766         
767         if (pWhenMarked >= 1) { 
768                         printf("XInterface used: ");fflush(stdout); 
769                         utf_display(ici->name);
770                         printf("<%i>\t",ici -> classUsed ); fflush(stdout); 
771                         if (ici -> classUsed == NOTUSED) printf("\t classUsed=NOTUSED\n" );
772                         if (ici -> classUsed == USED) printf("\t classUsed=USED\n");
773                         if (ici -> classUsed == PARTUSED) printf("\t classUsed=PARTUSED\n");
774                         fflush(stdout);
775                         }
776         /* add class to interfaces list of classes that implement it */
777         ici -> impldBy =  addElement(ici -> impldBy,  ci);
778
779         /* if interface class is used */
780         if (ici -> classUsed != NOTUSED) {
781
782                 /* for each interface method implementation that has already been used */
783                 for (mm=0; mm< ici->methodscount; mm++) {
784                         methodinfo *imi = &(ici->methods[mm]);  /*interface method */
785 printf("==%i==%i\n",ici->methodscount,mm);
786                         if (imi->xta == NULL)
787                                 xtainfoInit (imi); 
788                                         /*RTAprint*/if (pWhenMarked >= 1) { 
789                                         /*RTAprint*/  if  (imi->xta->XTAmethodUsed != USED) {
790                                         /*RTAprint*/    if (imi->xta->XTAmethodUsed==NOTUSED) 
791                                                                 printf("Interface Method notused: "); 
792                                         /*RTAprint*/    if (imi->xta->XTAmethodUsed==MARKED) 
793                                                                 printf("Interface Method marked: "); 
794                                         /*RTAprint*/    utf_display(ici->name);printf(".");
795                                         /*RTAprint*/    method_display(imi);fflush(stdout);
796                                         /*RTAprint*/    }
797                                         /*RTAprint*/  } 
798                         if  (imi->xta->XTAmethodUsed == USED) {
799                                 methSetNode *mCalledBy = NULL;
800                                         if (pWhenMarked >= 1) { 
801                                                 printf("Interface Method used: "); utf_display(ici->name);printf(".");
802                                                 method_display(imi);fflush(stdout);
803
804                                                 /* Mark this method used in the (used) implementing class &its subclasses */
805                                                 printf("xMAY ADD methods that was used by an interface\n"); fflush(stdout);
806                                                 }
807 printf("calledBy set ="); fflush(stdout);
808 printMethodSet(imi->xta->calledBy);
809                                 if (imi->xta->calledBy != NULL) { 
810                                         /* for each calledBy method */
811                                         for (   mCalledBy = imi->xta->calledBy->head; 
812                                                 mCalledBy != NULL; 
813                                                 mCalledBy = mCalledBy->nextmethRef) {
814                                                                 printf("xtaMarkSubs(");
815                                                                 utf_display(ci->name); printf("."); fflush(stdout);
816                                                                 method_display(imi);
817                                                                 printf("mCalledBy method class set BEFORE\n"); fflush(stdout);
818                                                                 printSet(mCalledBy->methRef->xta->XTAclassSet->head);
819                                                 xtaMarkSubs(ci,imi,mCalledBy->methRef->xta->XTAclassSet->head);
820                                                                 printf("mCalledBy method class set AFTER \n"); fflush(stdout);
821                                                                 printSet(mCalledBy->methRef->xta->XTAclassSet->head);
822                                                 }
823                                         }
824                                 }
825                         } 
826                 }
827         } /* end for */
828 }
829
830 /*-------------------------------------------------------------------------------*/
831
832 /*-------------------------------------------------------------------------------*/
833 void xtaMarkInterfaceSubs(methodinfo *mi) {
834         classSetNode *subs;
835         classSetNode * Si;
836
837         if (mi->xta == NULL)
838                 xtainfoInit (mi); 
839                                         
840         if (mi->class->classUsed != USED) {
841                 mi->class->classUsed = USED; 
842                 class_java_lang_Object->impldBy =  addElement(class_java_lang_Object -> impldBy,  mi->class);
843                 }
844
845         /* add interface class to list kept in Object */
846 printf("Marking Interface Method: "); fflush(stdout);
847         xtaAddCallEdges(mi,POLY);       
848
849         subs =  mi->class->impldBy; 
850                                                 RTAPRINT08invokeInterface1
851         while (subs != NULL) { 
852                 classinfo * isubs = subs->classType;
853                                                         RTAPRINT09invokeInterface2
854                 /* Mark method (mark/used) in classes that implement the method */
855                 if (isubs->classUsed != NOTUSED) {
856                         methodinfo *submeth;
857                                                 
858                         submeth = class_resolvemethod(isubs,mi->name, mi->descriptor); 
859                         if (submeth != NULL)    ///+1
860                                 {
861                                 classSetNode *subtypesUsedSet = NULL;
862                                 submeth->monoPoly = POLY; /*  poly even if nosubs */
863                                                         
864                                 mi->xta->XTAmethodUsed = USED;
865                                 if (rt_method->xta->XTAclassSet != NULL)
866                                         subtypesUsedSet =
867                                                 intersectSubtypesWithSet
868                                                         (subs->classType, rt_method->xta->XTAclassSet->head);
869
870                                                                 /*RTAprint*/ printf(" \nXTA subtypesUsedSet: ");
871                                                                 /*RTAprint*/ fflush(stdout);
872                                                                 /*RTAprint*/ printSet(subtypesUsedSet);
873                                 xtaMarkSubs(subs->classType, mi, subtypesUsedSet);
874                                 }
875                         }
876                 subs = subs->nextClass;
877                 }
878 }
879 /*-------------------------------------------------------------------------------*/
880 void xxxtaMarkInterfaceSubs(methodinfo *mCalled) {
881         classSetNode * Si;
882         
883         /* for every class that implements the interface of the method called */
884         for (Si = mCalled->class->impldBy; Si != NULL; Si = Si->nextClass) {
885                 /* add all definitions of this method for this interface */
886                 methodinfo *submeth;
887                 classSetNode *subtypesUsedSet = NULL;
888
889                 submeth = class_findmethod(Si->classType, mCalled->name, mCalled->descriptor); 
890                 if (submeth == NULL) { /* search up the heir - ignore for now!!! */
891                        submeth = class_resolvemethod(Si->classType, mCalled->name, mCalled->descriptor);
892                         }
893
894                 if (rt_method->xta->XTAclassSet != NULL)
895                         subtypesUsedSet = intersectSubtypesWithSet(Si->classType, rt_method->xta->XTAclassSet->head);
896                                 
897                                 printf(" \nXTA subtypesUsedSet: "); fflush(stdout);
898                                 printSet(subtypesUsedSet);
899                         xtaMarkSubs(Si->classType, submeth, subtypesUsedSet);   
900         }
901 }
902
903 /*-------------------------------------------------------------------------------*/
904 bool xtaAddFldClassTypeInfo(fieldinfo *fi) {
905
906         bool rc = false;
907
908         if (fi->xta->fieldChecked) {
909                 if (fi->xta->fldClassType != NULL)
910                         return true;  /* field has a class type */
911                 else
912                         return false;
913         }
914         fi->xta->fieldChecked = true;
915
916         if (fi->type == TYPE_ADDRESS) {
917                 char *utf_ptr = fi->descriptor->text;  /* current position in utf text */
918
919                 if (*utf_ptr != 'L') {
920                         while (*utf_ptr++ =='[') ;
921                 }
922
923                 if (*utf_ptr =='L') {
924                         rc = true;
925                         if  (fi->xta->fldClassType== NULL) {
926                                 char *desc;
927                                 char *cname;
928                                 classinfo * class;
929
930                                 desc = MNEW(char, 256);
931                                 strcpy(desc,++utf_ptr);
932                                 cname = strtok(desc,";");
933                                 if (XTAdebug >= 1) {
934                                         printf("STATIC fields type is: %s\n",cname);
935                                         fflush(stdout);
936                                 }
937                                 class = class_get(utf_new_char(cname));
938                                 fi->xta->fldClassType= class;    /* save field's type class ptr */      
939                         } 
940                 }
941         }
942         return rc;
943 }
944
945 /*-------------------------------------------------------------------------------*/
946 void xtaPassFldPUT(fldSetNode *fN)
947 {
948         /* Field type is a class */
949         classSetNode *c;
950         classSetNode *c1 = NULL;
951         classSetNode *cp = NULL;
952         classSetNode *cprev= NULL;
953
954         fieldinfo *fi;
955         if (fN != NULL)
956                 fi = fN->fldRef;
957         else
958                 return;
959
960 /* Use lastptr  so don't check whole XTA class set each time */
961         cp = fN->lastptrPUT;
962         if (cp != NULL) {
963                 if (cp->nextClass != NULL)
964                         c1 = cp -> nextClass;
965         } 
966         else    {
967                 if (rt_method->xta->XTAclassSet != NULL)
968                         c1  = rt_method->xta->XTAclassSet->head;
969
970                 if (XTAfld >=1 ) {
971                         printf("rt XTA class set =");fflush(stdout);
972                         printClassSet(rt_method->xta->XTAclassSet);
973                         printf("\t\tField class type = ");fflush(stdout);
974                         utf_display(fi->xta->fldClassType->name); printf("\n");
975                 }
976         }
977
978         /*--- PUTSTATIC specific ---*/
979         /* Sx = intersection of type+subtypes(field x)   */
980         /*   and Sm (where putstatic code is)            */
981         for (c=c1; c != NULL; c=c->nextClass) {
982                 vftbl *f_cl_vt = fi->xta->fldClassType->vftbl;
983                 vftbl *c_cl_vt =  c->   classType->vftbl;
984                 if (XTAfld >=2 ) {
985                         printf("\tXTA class = ");fflush(stdout);
986                         utf_display(c->classType->name);
987                         printf("<b=%i> ",c_cl_vt->baseval); fflush(stdout);
988                         if (c->nextClass == NULL) {
989                                 printf("next=NULL ");fflush(stdout);
990                         }
991                         else    {
992                                 printf("next="); fflush(stdout);
993                                 utf_display(c->nextClass->classType->name);
994                                 printf("\n"); fflush(stdout);
995                         }
996
997                         printf("\t\tField class type = ");fflush(stdout);
998                         utf_display(fi->xta->fldClassType->name);
999                         printf("<b=%i/+d=%i> \n",f_cl_vt->baseval,(f_cl_vt->baseval+f_cl_vt->diffval)); fflush(stdout);
1000                 }
1001
1002                 if ((f_cl_vt->baseval <= c_cl_vt->baseval)
1003                         && (c_cl_vt->baseval <= (f_cl_vt->baseval+f_cl_vt->diffval)) ) {
1004                         fi->xta->XTAclassSet = add2ClassSet(fi->xta->XTAclassSet,c->classType);
1005                 }
1006                 cprev = c;
1007         }
1008         fN->lastptrPUT = cprev;
1009 }
1010 /*-------------------------------------------------------------------------------*/
1011 void xtaPassFldGET(fldSetNode *fN)
1012 {
1013         /* Field type is a class */
1014         classSetNode *c;
1015         classSetNode *c1 = NULL;
1016         classSetNode *cp = NULL;
1017         classSetNode *cprev= NULL;
1018
1019         fieldinfo *fi;
1020         if (fN != NULL)
1021                 fi = fN->fldRef;
1022         else
1023                 return;
1024
1025 /* Use lastptr  so don't check whole XTA class set each time */
1026         cp = fN->lastptrGET;
1027         if (cp != NULL) {
1028                 if (cp->nextClass != NULL)
1029                         c1 = cp -> nextClass;
1030         } 
1031         else    {
1032                 if (fi->xta->XTAclassSet != NULL)
1033                         c1  = fi->xta->XTAclassSet->head;
1034
1035                 if (XTAfld >=1 ) {
1036                         printf("fld XTA class set =");fflush(stdout);
1037                         printClassSet(fi->xta->XTAclassSet);
1038                         printf("\t\tField class type = ");fflush(stdout);
1039                         utf_display(fi->xta->fldClassType->name); printf("\n");
1040                 }
1041         }
1042
1043         /*--- GETSTATIC specific ---*/
1044         /* Sm = union of Sm and Sx */
1045         for (c=c1; c != NULL; c=c->nextClass) {
1046                 bool addFlg = false;
1047                 if (rt_method->xta->XTAclassSet ==NULL) 
1048                         addFlg = true;
1049                 else    {
1050                         if (!(inSet (rt_method->xta->XTAclassSet->head, c->classType) )) 
1051                                 addFlg = true;
1052                         }
1053                 if (addFlg) {
1054                         rt_method->xta->XTAclassSet 
1055                                 = add2ClassSet(rt_method->xta->XTAclassSet,c->classType);
1056                 }
1057                 cprev = c;
1058         }
1059
1060         fN->lastptrGET = cprev;
1061
1062 }
1063
1064 /*-------------------------------------------------------------------------------*/
1065 void xtaPassAllCalledByParams () {
1066         methSetNode *SmCalled;
1067         methSetNode *s1;
1068         if (XTAdebug >= 1) {
1069                 printf("xta->calledBy method set: "); fflush(stdout);
1070                 
1071                 if (rt_method->xta == NULL) panic ("rt_method->xta == NULL!!!!\n");
1072                 printMethodSet(rt_method->xta->calledBy); fflush(stdout);
1073                 }
1074         if (rt_method->xta->calledBy == NULL)
1075                 s1 = NULL;
1076         else
1077                 s1 = rt_method->xta->calledBy->head;
1078         for (SmCalled=s1; SmCalled != NULL; SmCalled = SmCalled->nextmethRef) {
1079                 if (XTAdebug >= 1) {
1080                         printf("SmCalled = "); fflush(stdout);
1081                         utf_display(SmCalled->methRef->class->name); fflush(stdout);
1082                         printf(".");fflush(stdout); method_display(SmCalled->methRef);
1083                 }
1084                                 
1085                 rt_method->xta->chgdSinceLastParse = false;             
1086                 xtaPassParams(rt_method, SmCalled->methRef,SmCalled);   /* chg flag output ignored for 1st regular parse */
1087         }
1088 }
1089
1090 /*-------------------------------------------------------------------------------*/
1091 void xtaAllFldsUsed ( ){
1092         fldSetNode  *f;
1093         fldSetNode *f1=NULL; 
1094         /*      bool chgd = false */
1095
1096         if (rt_method->xta->fldsUsed == NULL) return;
1097
1098         /* for each field that this method uses */
1099         f1 = rt_method->xta->fldsUsed->head;
1100
1101         for (f=f1; f != NULL; f = f->nextfldRef) {
1102
1103                 if (f->writePUT)
1104                         xtaPassFldPUT(f);
1105                 if (f->readGET)
1106                         xtaPassFldGET(f);
1107         }
1108 }
1109 /*-------------------------------------------------------------------------------*/
1110 void  xtaMethodCalls_and_sendReturnType() 
1111 {
1112         methSetNode *SmCalled;  /* for return type       */
1113         methSetNode *SmCalls;   /* for calls param types */
1114         methSetNode *s1=NULL; 
1115         bool chgd = false;
1116         if (XTAdebug >= 1) {
1117                 printf("calls method set Return type: ");
1118                 printMethodSet(rt_method->xta->calls);
1119         }
1120         xtaAllFldsUsed ( );
1121
1122         /* for each method that this method calls */
1123         if (rt_method->xta->calls == NULL)
1124                 s1 = NULL;
1125         else
1126                 s1 = SmCalls=rt_method->xta->calls->head;
1127
1128         for (SmCalls=s1; SmCalls != NULL; SmCalls = SmCalls->nextmethRef) {
1129                 /*    pass param types  */
1130                 bool chgd = false;
1131                 chgd = xtaPassParams (SmCalls->methRef, rt_method, SmCalls);  
1132                 /* if true chgd after its own parse */
1133                 if (!(SmCalls->methRef->xta->chgdSinceLastParse)) {
1134                         SmCalls->methRef->xta->chgdSinceLastParse = true;
1135                 }
1136         }
1137
1138         /* for each calledBy method */
1139         /*    send return type */
1140         if (rt_method->xta->calledBy == NULL)
1141                 s1 = NULL;
1142         else
1143                 s1 = rt_method->xta->calledBy->head;
1144         for (SmCalled=s1; SmCalled != NULL; SmCalled = SmCalled->nextmethRef) {
1145
1146                 if (XTAdebug >= 1) {
1147                         printf("\tSmCalled = ");fflush(stdout); utf_display(SmCalled->methRef->class->name);
1148                         printf("."); method_display(SmCalled->methRef);
1149                 }
1150                                 
1151                 chgd = xtaPassReturnType(rt_method, SmCalled->methRef); 
1152                 if (!(SmCalled->methRef->xta->chgdSinceLastParse)) {
1153                         SmCalled->methRef->xta->chgdSinceLastParse = chgd;              
1154                 }
1155         }
1156 }
1157
1158
1159 /*-------------------------------------------------------------------------------*/
1160 static void parseRT()
1161 {
1162         int  p;                     /* java instruction counter                   */
1163         int  nextp;                 /* start of next java instruction             */
1164         int  opcode;                /* java opcode                                */
1165         int  i;                     /* temporary for different uses (counters)    */
1166         bool iswide = false;        /* true if last instruction was a wide        */
1167
1168         RTAPRINT01method
1169
1170                 if ( ((XTAOPTbypass) || (opt_xta)) && (rt_method->name != utf_MAIN)) {
1171                                         printf("XTA parseRT():"); fflush(stdout);
1172                                         method_display(rt_method);
1173                         if (rt_method->xta == NULL)
1174                                 xtainfoInit (rt_method);
1175                         xtaPassAllCalledByParams ();
1176                                         printf("XTA parseRT() after xtaPassAll...\n");fflush(stdout);
1177    
1178                 }
1179
1180         /* scan all java instructions */
1181
1182         for (p = 0; p < rt_jcodelength; p = nextp) {
1183                 opcode = rt_code_get_u1 (p);           /* fetch op code                  */
1184                 RTAPRINT02opcode
1185                         fflush(stdout); 
1186                 nextp = p + jcommandsize[opcode];   /* compute next instruction start */
1187                 switch (opcode) {
1188
1189                         /*--------------------------------*/
1190                         /* Code just to get the correct  next instruction */
1191                         /* 21- 25 */
1192                 case JAVA_ILOAD:
1193                 case JAVA_LLOAD:
1194                 case JAVA_FLOAD:
1195                 case JAVA_DLOAD:
1196
1197                 case JAVA_ALOAD:
1198                         if (iswide)
1199                                 {
1200                                         nextp = p+3;
1201                                         iswide = false;
1202                                 }
1203                         break;
1204
1205                         /* 54 -58 */
1206                 case JAVA_ISTORE:
1207                 case JAVA_LSTORE:
1208                 case JAVA_FSTORE:
1209                 case JAVA_DSTORE:
1210
1211                 case JAVA_ASTORE:
1212                         if (iswide)
1213                                 {
1214                                         iswide=false;
1215                                         nextp = p+3;
1216                                 }
1217                         break;
1218
1219                         /* 132 */
1220                 case JAVA_IINC:
1221                         {
1222                                 if (iswide) {
1223                                         iswide = false;
1224                                         nextp = p+5;
1225                                 }
1226                         }
1227                         break;
1228
1229                         /* wider index for loading, storing and incrementing */
1230                         /* 196 */
1231                 case JAVA_WIDE:
1232                         iswide = true;
1233                         nextp = p + 1;
1234                         break;
1235                         /* 169 */
1236                 case JAVA_RET:
1237                         if (iswide) {
1238                                 nextp = p+3;
1239                                 iswide = false;
1240                         }
1241                         break;
1242
1243                         /* table jumps ********************************/
1244
1245                 case JAVA_LOOKUPSWITCH:
1246                         {
1247                                 s4 num;
1248                                 nextp = ALIGN((p + 1), 4);
1249                                 num = rt_code_get_u4(nextp + 4);
1250                                 nextp = nextp + 8 + 8 * num;
1251                                 break;
1252                         }
1253
1254
1255                 case JAVA_TABLESWITCH:
1256                         {
1257                                 s4 num;
1258                                 nextp = ALIGN ((p + 1),4);
1259                                 num = rt_code_get_s4(nextp + 4);
1260                                 num = rt_code_get_s4(nextp + 8) - num;
1261                                 nextp = nextp + 16 + 4 * num;
1262                                 break;
1263                         }
1264
1265                         /*-------------------------------*/
1266                 case JAVA_PUTSTATIC:
1267                         i = rt_code_get_u2(p + 1);
1268                         {
1269                                 constant_FMIref *fr;
1270                                 fieldinfo *fi;
1271
1272                                 fr = class_getconstant (rt_class, i, CONSTANT_Fieldref);
1273                                 /* descr has type of field ref'd  */
1274                                 fi = class_findfield (fr->class,fr->name, fr->descriptor);
1275                                 RTAPRINT03putstatic1
1276
1277                                 /*--- RTA ---*/
1278                                 /* class with field - marked in addClassinit */
1279                                 addClassInit(fr->class);
1280
1281                                 /*--- XTA ---*/
1282                                 if   ((XTAOPTbypass) || (opt_xta))
1283                                         {
1284                                                 if (fi->xta == NULL)
1285                                                         fi->xta = xtafldinfoInit(fi);
1286                                                 if (xtaAddFldClassTypeInfo(fi)) {  
1287                                                         rt_method->xta->fldsUsed = add2FldSet(rt_method->xta->fldsUsed, fi, true,false);
1288                                                 }
1289                                         }
1290                         }
1291                         break;
1292
1293                 case JAVA_GETSTATIC:
1294                         i = rt_code_get_u2(p + 1);
1295                         {
1296                                 constant_FMIref *fr;
1297                                 fieldinfo *fi;
1298
1299                                 fr = class_getconstant (rt_class, i, CONSTANT_Fieldref);
1300                                 /* descr has type of field ref'd  */
1301                                 fi = class_findfield (fr->class,fr->name, fr->descriptor);
1302                                 RTAPRINT03putstatic1
1303
1304                                 /*--- RTA ---*/
1305                                 /* class with field - marked in addClassinit */
1306                                 addClassInit(fr->class);
1307
1308                                 /*--- XTA ---*/
1309                                 if  ((XTAOPTbypass) || (opt_xta) ) 
1310                                         {
1311                                                 if (fi->xta == NULL)
1312                                                         fi->xta = xtafldinfoInit(fi);
1313                                                 if (xtaAddFldClassTypeInfo(fi)) {
1314                                                         rt_method->xta->fldsUsed = add2FldSet(rt_method->xta->fldsUsed, fi, false, true);
1315                                                 }
1316                                         }
1317
1318                         }
1319                         break;
1320
1321
1322                         /*--------------------  method invocation ---------------------*/
1323
1324                 case JAVA_INVOKESTATIC:
1325                         i = rt_code_get_u2(p + 1);
1326                         {
1327                                 constant_FMIref *mr;
1328                                 methodinfo *mi;
1329
1330                                 mr = class_getconstant (rt_class, i, CONSTANT_Methodref);
1331                                 mi = class_findmethod (mr->class, mr->name, mr->descriptor);
1332                                 /*-- RTA --*/
1333                                                         RTAPRINT04invokestatic1
1334                                 if (mi->class->classUsed == NOTUSED) {
1335                                         mi->class->classUsed = USED;
1336                                                 RTAPRINT05invokestatic2
1337                                         }
1338                                 addClassInit(mi->class);
1339         
1340                                 if (opt_rt) {
1341                                         ADDTOCALLGRAPH(mi)  
1342                                 } /* end RTA */
1343                                 /*-- XTA --*/
1344                                 if ((XTAOPTbypass) || (opt_xta)) {
1345                                         xtaAddCallEdges(mi,MONO); 
1346                                 } /* end XTA */
1347                         }
1348                         break;
1349
1350                 case JAVA_INVOKESPECIAL:
1351                         i = rt_code_get_u2(p + 1);
1352                         {
1353                         constant_FMIref *mr;
1354                         methodinfo *mi;
1355                         classinfo  *ci;
1356                                 
1357                         mr = class_getconstant (rt_class, i, CONSTANT_Methodref);
1358                         mi = class_findmethod (mr->class, mr->name, mr->descriptor);
1359                         ci = mi->class;
1360                                                 RTAPRINT06invoke_spec_virt1
1361                         /*--- PRIVATE Method -----------------------------------------------------*/ 
1362                         if (mi->name        != INIT) {     /* if method called is PRIVATE */ 
1363                                                         RTAPRINT07invoke_spec_virt2
1364                                                         RTAPRINT04invokestatic1
1365                                 /*-- RTA --*/   /* was just markSubs(mi); */
1366                                 if (opt_rt) {
1367                                         ADDTOCALLGRAPH(mi)  
1368                                         }
1369
1370                                 /*--- XTA ---*/
1371                                 if ((XTAOPTbypass) || (opt_xta)) {
1372                                         xtaAddCallEdges(mi,MONO);
1373                                         } /* end XTA */
1374                                 }
1375
1376                         else    {
1377                                 /*--- Test for super <init> which is: <init> calling its super class <init> -*/
1378
1379                                 /* new class so add marked methods */
1380                                 if (opt_rt) {
1381                                         if (( mi->methodUsed != USED) || (mi->class->classUsed == PARTUSED))  {
1382                                 /*--- process NORMAL <init> method ---------------------------------------------*/
1383                                                 if ( mi->methodUsed != USED) {
1384                                                         /* Normal <init> 
1385                                                         - mark class as USED and <init> to callgraph */
1386                                 
1387                                                         /*-- RTA --*/
1388                                                         ci->classUsed = USED;
1389                                                         addMarkedMethods(ci);  /* add to callgraph marked methods */
1390                                                                                 RTAPRINT06Binvoke_spec_init
1391                                                         rtaAddUsedInterfaceMethods(ci); 
1392                                                         ADDTOCALLGRAPH(mi)  
1393                                                         }
1394                                                 }       
1395                                         }
1396
1397                                 /*-- XTA --*/
1398                                 if ((XTAOPTbypass) || (opt_xta)) { 
1399                                         if (mi->xta == NULL) {
1400                                                 mi->xta = xtainfoInit(mi);
1401                                                 }
1402                                         if ((mi->xta->XTAmethodUsed != USED) || (mi->class->classUsed == PARTUSED)) {
1403                                                 ci->classUsed = USED;
1404                                                 rt_method->xta->XTAclassSet = add2ClassSet(rt_method->xta->XTAclassSet,ci ); 
1405                                                 xtaAddUsedInterfaceMethods(ci); 
1406                                                 xtaAddCallEdges(mi,MONO);
1407                                                         RTAPRINT06CXTAinvoke_spec_init1
1408                                                 } /* end XTA */
1409                                         }
1410                                 }
1411
1412                         }                                                
1413                         break;
1414
1415
1416                 case JAVA_INVOKEVIRTUAL:
1417                         i = rt_code_get_u2(p + 1);
1418                         {
1419                         constant_FMIref *mr;
1420                         methodinfo *mi;
1421                                 
1422                         mr = class_getconstant (rt_class, i, CONSTANT_Methodref);
1423                         mi = class_findmethod (mr->class, mr->name, mr->descriptor);
1424
1425                         /*--- RTA ---*/
1426                                         RTAPRINT07invoke_spec_virt2
1427                         mi->monoPoly = POLY;
1428                         if (opt_rt) { 
1429                                 rtaMarkSubs(mi->class,mi); 
1430                                 }
1431
1432                         /*--- XTA ---*/
1433                         if ((XTAOPTbypass) || (opt_xta)) { 
1434                                 classSetNode *subtypesUsedSet = NULL;
1435                                 if (rt_method->xta->XTAclassSet != NULL)
1436                                         subtypesUsedSet = 
1437                                                 intersectSubtypesWithSet(mi->class, rt_method->xta->XTAclassSet->head);
1438                                 else
1439                                         subtypesUsedSet = addElement(subtypesUsedSet, rt_method->class);
1440                                         /*****/ 
1441                                                         printf(" \nXTA subtypesUsedSet: "); fflush(stdout);
1442                                                         printSet(subtypesUsedSet);
1443                                         /*****/
1444                                         xtaMarkSubs(mi->class, mi, subtypesUsedSet);   
1445                                 } /* end XTA */
1446                         }
1447                         break;
1448
1449                 case JAVA_INVOKEINTERFACE:
1450                         i = rt_code_get_u2(p + 1);
1451                         {
1452                         constant_FMIref *mr;
1453                         methodinfo *mi;
1454
1455                         mr = class_getconstant (rt_class, i, CONSTANT_InterfaceMethodref);
1456                         mi = class_findmethod (mr->class, mr->name, mr->descriptor);
1457                         
1458                                                 /*RTAprint*/ if (pWhenMarked >= 1) {
1459                                                 /*RTAprint*/ printf("\t");fflush(stdout);
1460                                                 /*RTAprint*/ utf_display(mr->class->name); printf(".");fflush(stdout);
1461                                                 /*RTAprint*/ method_display(mi); fflush(stdout); 
1462                                                 /*RTAprint*/ }
1463
1464                         if (mi->flags & ACC_STATIC)
1465                                 panic ("Static/Nonstatic mismatch calling static method");
1466                                                         RTAPRINT08AinvokeInterface0
1467                         /*--- RTA ---*/
1468                         if (opt_rt) {
1469                                 rtaMarkInterfaceSubs(mi);
1470                                 }
1471                         /*--- XTA ---*/
1472                         if ((XTAOPTbypass2) || (opt_xta)) {
1473                                 xtaMarkInterfaceSubs(mi);
1474                                 }
1475                         }
1476                         break;
1477
1478                         /* miscellaneous object operations *******/
1479
1480                 case JAVA_NEW:
1481                         i = rt_code_get_u2 (p+1);
1482                         {
1483                                 classinfo *ci;
1484
1485                                 ci = class_getconstant (rt_class, i, CONSTANT_Class); 
1486                                         if (pWhenMarked >= 1) {
1487                                                 printf("\tclass=");fflush(stdout);
1488                                                 utf_display(ci->name); fflush(stdout);
1489                                                 printf("=\n");fflush(stdout);
1490                                                 }
1491                                 /*--- RTA ---*/
1492                                 if (ci->classUsed != USED) {
1493                                         RTAPRINT10new
1494                                                 ci->classUsed = USED;    /* add to heirarchy    */
1495                                         /* Add this class to the implemented by list of the abstract interface */
1496                                         rtaAddUsedInterfaceMethods(ci);
1497                                         addClassInit(ci);
1498                                         } 
1499                                 /*--- XTA ---*/
1500                                 if ((XTAOPTbypass) || (opt_xta))
1501                                         {
1502                                         xtaAddUsedInterfaceMethods(ci);
1503                                         rt_method->xta->XTAclassSet = add2ClassSet(rt_method->xta->XTAclassSet,ci ); /*XTA*/
1504                                                 RTAPRINT10newXTA
1505                                         }
1506                         }
1507                         break;
1508
1509                 default:
1510                         break;
1511
1512                 } /* end switch */
1513
1514
1515         } /* end for */
1516
1517         if (p != rt_jcodelength)
1518                 panic("Command-sequence crosses code-boundary");
1519
1520         if ((XTAOPTbypass) || (opt_xta))
1521                 xtaMethodCalls_and_sendReturnType();
1522
1523
1524 }
1525
1526 /*-------------------------------------------------------------------------------*/
1527 /* RTA add Native Methods/ Class functions  */
1528 /*-------------------------------------------------------------------------------*/
1529 void   findMarkNativeUsedMeth (utf * c1, utf* m1, utf* d1) {
1530
1531         classinfo  *class;
1532         methodinfo *meth;
1533
1534         class = class_get(c1);
1535         if (class == NULL)  {
1536                 return;    /*Note: Since NativeCalls is for mult programs some may not be loaded - that's ok */
1537         }
1538
1539         if (class->classUsed == NOTUSED) {
1540                 class->classUsed = USED; /* MARK CLASS USED */
1541                 /* add marked methods to callgraph */ 
1542                 addMarkedMethods(class);
1543         }
1544
1545         meth = class_findmethod (class, m1, d1);
1546         if (meth == NULL) {
1547                 utf_display(class->name);printf(".");utf_display(m1);printf(" ");utf_display(d1);
1548                 printf("WARNING from parseRT:  Method given is used by Native method call, but NOT FOUND\n");
1549         }
1550         else
1551                 rtaMarkSubs(class,meth);
1552 }
1553
1554 /*-------------------------------------------------------------------------------*/
1555
1556 void   findMarkNativeUsedClass (utf * c) {
1557         classinfo  *class;
1558
1559         class = class_get(c);
1560         if (class == NULL)  panic("parseRT: Class used by Native method called not loaded!!!");
1561         class->classUsed = USED;
1562
1563         /* add marked methods to callgraph */
1564         addMarkedMethods(class);
1565 }
1566
1567
1568 /*-------------------------------------------------------------------------------*/
1569
1570 void markNativeMethodsRT(utf *rt_class, utf* rt_method, utf* rt_descriptor) {
1571         int i,j,k;
1572         bool found = false;
1573
1574         nativecallcompdone = natcall2utf(nativecallcompdone); 
1575
1576         for (i=0; i<NATIVECALLSSIZE; i++) {
1577                 if (rt_class  == nativeCompCalls[i].classname) {
1578         
1579                         /* find native class.method invoked */
1580                         for (j=0; (!(found) && (j<nativeCompCalls[i].methCnt)); j++) {
1581
1582                                 if ( (rt_method     == nativeCompCalls[i].methods[j].methodname)
1583                                          && (rt_descriptor == nativeCompCalls[i].methods[j].descriptor)) {
1584
1585                                         found=true;
1586
1587                                         /* mark methods and classes used by this native class.method */
1588                                         for (k=0; k < nativeCompCalls[i].callCnt[j]; k++) {
1589                                                 if (nativeCompCalls[i].methods[j].methodCalls[k].methodname != NULL) {
1590                                                         /* mark method used */
1591                                                         findMarkNativeUsedMeth(
1592                                                                                                    nativeCompCalls[i].methods[j].methodCalls[k].classname,
1593                                                                                                    nativeCompCalls[i].methods[j].methodCalls[k].methodname,
1594                                                                                                    nativeCompCalls[i].methods[j].methodCalls[k].descriptor); 
1595
1596                                                         /*RTprint 
1597                                                           printf("\nmark method used: "); fflush(stdout);
1598                                                           utf_display(nativeCompCalls[i].methods[j].methodCalls[k].classname); printf(".");fflush(stdout);
1599                                                           utf_display(nativeCompCalls[i].methods[j].methodCalls[k].methodname); printf("=="); fflush(stdout);
1600                                                           utf_display(nativeCompCalls[i].methods[j].methodCalls[k].descriptor); printf("==\n"); fflush(stdout);
1601                                                         */
1602                                                 }
1603                                                 else {
1604                                                         /* mark class used */
1605                                                         findMarkNativeUsedClass( nativeCompCalls[i].methods[j].methodCalls[k].classname);
1606                                                 } /* if-else k  */ 
1607
1608                                         }  /* for k */ 
1609
1610                                 }  /* if j */
1611                         }  /* for j */
1612
1613                 }  /* if i */  
1614         }  /* for i */
1615
1616 }
1617
1618
1619 /*-------------------------------------------------------------------------------*/
1620 /*-------------------------------------------------------------------------------*/
1621 void mainRTAparseInit (methodinfo *m )
1622 {
1623         /*printf("MAIN_NOT_STARTED \n");*/ 
1624         if (class_java_lang_Object->sub != NULL) { 
1625                 RTAPRINT16stats1;
1626         }
1627
1628         if (firstCall) {
1629                 firstCall=false;
1630
1631                 /* Frequently used utf strings */
1632                 utf_MAIN  = utf_new_char("main");
1633                 INIT      = utf_new_char("<init>");
1634                 CLINIT    = utf_new_char("<clinit>");
1635                 FINALIZE  = utf_new_char("finalize");
1636                 EMPTY_DESC= utf_new_char("()V");
1637
1638                 /* open file for list of methods parsed before main method or missed and parsed after main */
1639                 if ( (rtMissed = fopen("rtMissed", "w")) == NULL) {
1640                         printf("CACAO - rtMissed file: cant open file to write\n");
1641                 }
1642                 else {
1643                         fprintf(rtMissed,"To Help User create a dymLoad file \n");
1644                         fprintf(rtMissed,
1645                 "Not parsed in the static analysis parse of Main: #rt parse / #missed class.method (descriptor) \n");
1646                         fprintf(rtMissed,"\n\tBEFORE MAIN RT PARSE\n");
1647                         fflush(rtMissed);
1648                         fclose(rtMissed);
1649                 }
1650                 /* Allocate callgraph */
1651                 if (opt_rt) {
1652                         callgraph = MNEW (methodinfo*, MAXCALLGRAPH);   /****/
1653                         }
1654                 if ((XTAOPTbypass) || (opt_xta)) {
1655                         printf("XTAXTA  CALLGRAPHS allocated\n");
1656                         XTAcallgraph = MNEW (methodinfo*, MAXCALLGRAPH);
1657                         }
1658                 }
1659
1660         if (m->name == utf_MAIN) {
1661                 rtMissed = fopen("rtMissed","a");
1662                 fprintf(rtMissed,"\n\n\tAFTER MAIN RT PARSE\n");
1663                 fclose(rtMissed);
1664                 AfterMain = true;
1665         }
1666         else {  
1667                 if ( (rtMissed = fopen("rtMissed", "a")) == NULL) {
1668                         printf("CACAO - rtMissed file: cant open file to write\n");
1669                 }
1670                 else {
1671                         fprintf(rtMissed,"#%i/#%i ",methRTlast+1,missedCnt++ );
1672                         utf_fprint(rtMissed,m->class->name);
1673                         fprintf(rtMissed," ");
1674                         fprintflags(rtMissed,m->flags);
1675                         fprintf(rtMissed," ");
1676                         utf_fprint(rtMissed,m->name);
1677                         fprintf(rtMissed," ");
1678                         utf_fprint(rtMissed,m->descriptor);
1679                         fprintf(rtMissed,"\n");
1680                         fflush(rtMissed);
1681                         fclose(rtMissed);
1682                 }
1683                 if (AfterMain) {
1684                         printf("#%i : ",methRT);
1685                         printf("Method missed by static analysis Main parse. See rtMissed file");
1686                         /***    panic ("Method missed by static analysis Main parse. See rtMissed file");**/
1687                 }
1688         }
1689
1690         /* At moment start RTA before main when parsed                      */
1691         /* Will definitely use flag with to know if ok to apply in-lining.  */
1692 }
1693
1694
1695 /*-------------------------------------------------------------------------------*/
1696 /*-------------------------------------------------------------------------------*/
1697 /* still need to look at field sets in 2nd pass and clinit .....  */
1698 void XTA_jit_parse2(methodinfo *m)
1699 {
1700 int methRT; /* local */
1701         if (XTAdebug >= 1) 
1702                 printf("\n\nStarting Round 2 XTA !!!!!!!!!!!!!!\n");
1703
1704         /* for each method in XTA worklist = callgraph (use RTA for now) */
1705         methRT=0;
1706         //while (methRT <= methRTlast) {
1707         while (methRT <= methXTAlast) {
1708                 rt_method      = XTAcallgraph[methRT];
1709                 rt_class       = rt_method->class;
1710                 rt_descriptor  = rt_method->descriptor;
1711                 rt_jcodelength = rt_method->jcodelength;
1712                 rt_jcode       = rt_method->jcode;
1713
1714                 if (! (  (rt_method->flags & ACC_NATIVE  )
1715                                  ||   (rt_method->flags & ACC_ABSTRACT) ) ) {
1716                         if (XTAdebug >= 1) {
1717                                 printf("\n!!!!! XTA Round 2 Parse of #%i:",methRT);fflush(stdout);
1718                                 utf_display(rt_class->name); printf("."); fflush(stdout);
1719                                 method_display(rt_method);
1720                         }
1721                         /*   if XTA type set changed since last parse */
1722                         if (rt_method->xta->chgdSinceLastParse) {
1723
1724                                 /*     get types from methods it is calledBy */
1725                                 xtaPassAllCalledByParams ();
1726
1727                                 /* Pass parameter types to methods it calls and  send the return type those called by  */
1728                                 xtaMethodCalls_and_sendReturnType();
1729                         }
1730                 }
1731                 methRT++;
1732         }
1733         if (XTAdebug >= 1) {
1734
1735                 printf("\n\nEND_OF Round 2 XTA !!!!!!!!!!!!!!\n");
1736                 printXTACallgraph ();
1737         }
1738         
1739         RTAPRINT14CallgraphLast  /*was >=2 */
1740                 RTAPRINT15HeirarchyiLast /*was >= 2 */
1741                 }
1742
1743
1744 /*-------------------------------------------------------------------------------*/
1745
1746 void RT_jit_parse(methodinfo *m)
1747 {
1748
1749 /*-- RTA -- *******************************************************/
1750     if (opt_rt) 
1751        {
1752         if (m->methodUsed == USED) return;
1753         mainRTAparseInit (m);
1754         m->methodUsed = USED;
1755
1756         /* initialise parameter type descriptor */
1757         callgraph[++methRTlast] = m;          /*-- RTA --*/
1758                 RTAPRINT11addedtoCallgraph 
1759         /* <init> then like a new class so add marked methods to callgraph */
1760         if (m->name == INIT)  {  /* need for <init>s parsed efore Main */
1761                 classinfo *ci;
1762                 ci = m->class;
1763                 ci->classUsed = USED;
1764                         if (pWhenMarked >= 1) {
1765                                 printf("Class=");utf_display(ci->name);
1766                         }
1767                         /* add marked methods to callgraph */
1768                         RTAPRINT11addedtoCallgraph2
1769                 addMarkedMethods(ci);
1770                 } /* if */
1771
1772         /*---- RTA call graph worklist -----***/
1773         while (methRT <= methRTlast) {
1774                 rt_method      = callgraph[methRT];
1775                 rt_class       = rt_method->class;
1776                 rt_descriptor  = rt_method->descriptor;
1777                 rt_jcodelength = rt_method->jcodelength;
1778                 rt_jcode       = rt_method->jcode;
1779
1780                 if (! (  (rt_method->flags & ACC_NATIVE  )
1781                                  ||   (rt_method->flags & ACC_ABSTRACT) ) ) {
1782                         parseRT();
1783                         }
1784                 else    {
1785                                 RTAPRINT12bAbstractNative
1786                         if (rt_method->flags & ACC_NATIVE ) {
1787                                         RTAPRINT12aNative
1788                                                 /* mark used and add to callgraph methods and classes used by NATIVE method */
1789                                                 markNativeMethodsRT(rt_class->name,rt_method->name,rt_descriptor);                
1790                                 }
1791                         if (rt_method->flags & ACC_ABSTRACT) {
1792                                 panic("ABSTRACT_SHOULD not ever get into the callgraph!!!!!****!!!****!!!!****!!!!\n"); 
1793                                 }
1794                         }
1795                 methRT++;
1796                                 RTAPRINT12Callgraph 
1797                                 RTAPRINT13Heirarchy 
1798                 } /* while */
1799
1800         if (m->class->classUsed == NOTUSED)
1801                 m->class->classUsed = USED; /* say Main's class has a method used ??*/ 
1802
1803         if (m->name == utf_MAIN) { /*-- MAIN specific -- */
1804
1805                                         /*RTAprint*/ if (pCallgraph >= 1) {
1806                                         /*RTAprint*/    printCallgraph ();}
1807                                         /*RTprint*/ if (pClassHeir >= 1) {
1808                                         /*RTprint*/     printRThierarchyInfo(m);
1809                                         /*RTprint*/     }
1810                                         /*RTprint*/     /**printObjectClassHeirarchyAll( );**/
1811                                                 fflush(stdout);
1812                 MFREE(callgraph,methodinfo*,MAXCALLGRAPH);
1813                 }
1814         } /*  end opt_rt */
1815
1816 /*-- XTA -- *******************************************************/
1817         if ((XTAOPTbypass) || (opt_xta)) {
1818                 if (m->xta != NULL) {
1819                         if (m->xta->XTAmethodUsed == USED) return;
1820                         }
1821                 mainRTAparseInit (m);
1822
1823                 XTAcallgraph[++methXTAlast] = m;
1824                 if (m->xta == NULL) {
1825                         m->xta = xtainfoInit(m);
1826                         }
1827                 m->xta->XTAmethodUsed = USED;
1828                         {methodinfo *mi = m;
1829                         printf("<");fflush(stdout);
1830                         XTAPRINTcallgraph2
1831                         }
1832                 }
1833
1834         /*-- Call graph work list loop -----------------*/
1835         /*---- XTA call graph worklist -----***/
1836                                                         useXTAcallgraph = true;
1837         if ((useXTAcallgraph) && (opt_xta)) {
1838                                                         printf("USING XTA call graph>>>>>>>>>><<\n");
1839
1840           while (methXTA <= methXTAlast) {
1841                 rt_method      = XTAcallgraph[methXTA];
1842                                                         printf("xTA CALLGRAPH #%i:",methXTA); fflush(stdout);
1843                                                         method_display(rt_method);
1844                 rt_class       = rt_method->class;
1845                 rt_descriptor  = rt_method->descriptor;
1846                 rt_jcodelength = rt_method->jcodelength;
1847                 rt_jcode       = rt_method->jcode;
1848
1849                 if (! (  (rt_method->flags & ACC_NATIVE  )
1850                                  ||   (rt_method->flags & ACC_ABSTRACT) ) ) {
1851                         parseRT();
1852                         }
1853                 else    {
1854                                 RTAPRINT12bAbstractNative
1855                         if (rt_method->flags & ACC_NATIVE ) {
1856                                         RTAPRINT12aNative
1857                                 /* mark used and add to callgraph methods and classes used by NATIVE method */
1858                                 markNativeMethodsRT(rt_class->name,rt_method->name,rt_descriptor);
1859                                 }
1860                         if (rt_method->flags & ACC_ABSTRACT) {
1861                                 panic("ABSTRACT_SHOULD not ever get into the callgraph!!!!!****!!!****!!!!****!!!!\n");
1862                                 }
1863                         }
1864                 methXTA++;
1865                                 RTAPRINT12Callgraph
1866                                 RTAPRINT13Heirarchy
1867                 } /* while */
1868         if (m->class->classUsed == NOTUSED)
1869                 m->class->classUsed = USED; /* say Main's class has a method used ??*/ 
1870         printXTACallgraph ();
1871
1872         if (m->name == utf_MAIN) { /*-- MAIN specific -- */
1873                                         /*RTAprint*/ if (pCallgraph >= 1) {
1874                                         /*RTAprint*/    printXTACallgraph (); }
1875                                         /*RTprint*/ if (pClassHeir >= 1) {
1876                                         /*RTprint*/     printf("Last RTA Info -+-+-");
1877                                         /*RTprint*/     printRThierarchyInfo(m);
1878                                         /*RTprint*/     }
1879                                         /*RTprint*/     /**printObjectClassHeirarchyAll( );**/
1880                                                 fflush(stdout);
1881                 /*--- XTA round 2+ "parse" - use info structures only so not a real parse */
1882                 XTA_jit_parse2(m);
1883                 printf("XTAXTA  CALLGRAPHS -SHOULD BE BUT ISNT- returned \n");
1884                 //MFREE(XTAcallgraph,methodinfo*,MAXCALLGRAPH);
1885                 }
1886         } /*  end opt_xta */
1887
1888         RTAPRINT14CallgraphLast  /*  was >=2*/
1889                 /***RTAPRINT15HeirarchyiLast **/ /*was >= 2 */
1890
1891         return;
1892 }
1893
1894
1895 /*
1896  * These are local overrides for various environment variables in Emacs.
1897  * Please do not remove this and leave it at the end of the file, where
1898  * Emacs will automagically detect them.
1899  * ---------------------------------------------------------------------
1900  * Local variables:
1901  * mode: c
1902  * indent-tabs-mode: t
1903  * c-basic-offset: 4
1904  * tab-width: 4
1905  * End:
1906  */
1907