Now wondering if there is a memory corruption because XTA seems to finish ok
****/
-/* jit/parseXTA.c - parser and print functions for Rapid Type Analyis
+/* src/vm/jit/inline/parseXTA.c - parser and print functions for
+ Rapid Type Analyis
- Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
- R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
- C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
- Institut f. Computersprachen - TU Wien
+ Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, Institut f. Computersprachen - TU Wien
This file is part of CACAO.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
- Contact: cacao@complang.tuwien.ac.at
+ Contact: cacao@cacaojvm.org
Authors: Carolyn Oates
- $Id: parseXTA.c 2189 2005-04-02 02:05:59Z edwin $
+ Changes: Christian Thalinger
+
+ $Id: parseXTA.c 4357 2006-01-22 23:33:38Z twisti $
*/
****************/
+
+#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "cacao/cacao.h"
#include "mm/memory.h"
#include "toolbox/list.h"
+#include "toolbox/logging.h"
#include "vm/class.h"
#include "vm/linker.h"
#include "vm/loader.h"
#include "vm/resolve.h"
#include "vm/options.h"
#include "vm/statistics.h"
-#include "vm/tables.h"
#include "vm/jit/jit.h"
#include "vm/jit/parse.h"
#include "vm/jit/inline/parseXTA.h"
char *class;
char *desc;
classSetNode *p=NULL;
+ classinfo *clsinfo;
+
if (debugInfo >= 1) {
printf("In descriptor2typesL >>>\t"); fflush(stdout);
utf_display(m->class->name); printf(".");
- method_display(m);fflush(stdout);
+ method_println(m);fflush(stdout);
}
pcount = 0;
class = strtok(desc,";");
desc = strtok(NULL,"\0");
/* get/save classinfo ptr */
- classtypes[pcount-1] = class_get(utf_new_char(class));
- p = addClassCone(p, class_get(utf_new_char(class)));
+ if (!(clsinfo = load_class_bootstrap(utf_new_char(class)))) {
+ log_text("could not load class in descriptor2typesL");
+ assert(0);
+ }
+ classtypes[pcount-1] = clsinfo;
+ p = addClassCone(p, clsinfo);
if (debugInfo >= 1) {
printf("LParam#%i 's class type is: %s\n",pcount-1,class);fflush(stdout);
printf("Lclasstypes[%i]=",pcount-1);fflush(stdout);
class = strtok(desc,";");
desc = strtok(NULL,"\0");
/* get/save classinfo ptr */
- classtypes[pcount-1] = class_get(utf_new_char(class));
- p= addClassCone(p, class_get(utf_new_char(class)));
+ if (!(clsinfo = load_class_bootstrap(utf_new_char(class)))) {
+ log_text("could not load class in descriptor2typesL");
+ assert(0);
+ }
+ classtypes[pcount-1] = clsinfo;
+ p= addClassCone(p, clsinfo);
if (debugInfo >= 1) {
printf("[Param#%i 's class type is: %s\n",pcount-1,class);
printf("[classtypes[%i]=",pcount-1);fflush(stdout);
classtypes[pcount-1] = NULL;
break;
default:
- panic("Ill formed methodtype-descriptor");
+ log_text("Ill formed methodtype-descriptor");
+ assert(0);
}
}
/* get class string */
class = strtok(desc,";");
- m->returnclass = class_get(utf_new_char(class));
+ if (!(clsinfo = load_class_bootstrap(utf_new_char(class)))) {
+ log_text("could not load class in descriptor2typesL");
+ assert(0);
+ }
+ m->returnclass = clsinfo;
if (m->returnclass == NULL) {
printf("class=<%s>\t",class); fflush(stdout);
- panic ("return class not found");
+ log_text("return class not found");
+ assert(0);
}
break;
case 'V': m->returntype = TYPE_VOID;
break;
- default: panic("Ill formed methodtype-descriptor-ReturnType");
+ default:
+ log_text("Ill formed methodtype-descriptor-ReturnType");
+ assert(0);
}
m->paramcount = pcount;
if (m->xta != NULL)
return m->xta; /* already initialized */
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
count_methods_marked_used++;
#endif
mCalled->xta->calledBy = add2MethSet(mCalled->xta->calledBy, mCalls);
/* IS THIS REALLY NEEDED???? */
-if (mCalled->xta->calledBy == NULL) panic("mCalled->xta->calledBy is NULL!!!");
-if (mCalls->xta->calls == NULL) panic("mCalls->xta->calls is NULL!!!");
+if (mCalled->xta->calledBy == NULL) {
+ log_text("mCalled->xta->calledBy is NULL!!!");
+ assert(0);
+}
+if (mCalls->xta->calls == NULL) {
+ log_text("mCalls->xta->calls is NULL!!!");
+ assert(0);
+}
}
classSetNode *cprev;
bool chgd = false;
+ /* prevent compiler warnings */
+
+ c1 = NULL;
+
if (lastptrInto->lastptrIntoClassSet2 == NULL) {
if (Calls->xta->XTAclassSet != NULL)
c1 = Calls->xta->XTAclassSet->head;
xtaAllFldsUsed (m);
- if (m->xta == NULL) panic("m->xta null for return type\n");
+ if (m->xta == NULL) {
+ log_text("m->xta null for return type");
+ assert(0);
+ }
+
/* for each method that this method calls */
if (m->xta->calls == NULL)
s1 = NULL;
desc = MNEW(char, 256);
strcpy(desc,++utf_ptr);
cname = strtok(desc,";");
- class = class_get(utf_new_char(cname));
+ if (!(class = load_class_bootstrap(utf_new_char(cname)))) {
+ log_text("could not load class in xtaAddFldClassTypeInfo");
+ assert(0);
+ }
fi->xta->fldClassType= class; /* save field's type class ptr */
}
}
utf_display(class->name); printf(".");
METHINFOx(topmethod);
printf("parse XTA: Method not found in class hierarchy");fflush(stdout);
- panic("parse XTA: Method not found in class hierarchy");
- }
+ assert(0);
+}
/* if submeth called previously from this method then return */
if (mCalls->xta->calls != NULL) {
methodinfo *imi = &(ici->methods[mm]);
if ( (XTA_DEBUGinf) && (imi->methodUsed != USED)) {
printf("Interface Method %s: ", methFlgs[imi->methodUsed]);
- utf_display(ici->name);printf(".");method_display(imi);fflush(stdout);
+ utf_display(ici->name);printf(".");method_println(imi);fflush(stdout);
}
if (imi->methodUsed == USED) {
if (XTA_DEBUGinf) {
- printf("Interface Method used: "); utf_display(ici->name);printf(".");method_display(imi);fflush(stdout);
+ printf("Interface Method used: "); utf_display(ici->name);printf(".");method_println(imi);fflush(stdout);
/* Mark this method used in the (used) implementing class &its subclasses */
printf("rMAY ADD methods that was used by an interface\n");
}
SHOWOPCODE(XTA_DEBUGopcodes)
nextp = p + jcommandsize[opcode]; /* compute next instr start */
- if (nextp > m->jcodelength)
- panic("Unexpected end of bytecode");
+ if (nextp > m->jcodelength) {
+ log_text("Unexpected end of bytecode");
+ assert(0);
+ }
switch (opcode) {
classinfo *frclass;
fr = class_getconstant(m->class, i, CONSTANT_Fieldref);
- if (!resolve_classref(m,fr->classref,resolveEager,true,&frclass))
- panic("Could not resolve class reference");
+ if (!fr)
+ return 0;
+ if (!resolve_classref(m,fr->classref,resolveEager,true, true,&frclass)) {
+ log_text("Could not resolve class reference");
+ assert(0);
+ }
LAZYLOADING(frclass)
fi = class_resolvefield(frclass,
classinfo *frclass;
fr = class_getconstant(m->class, i, CONSTANT_Fieldref);
- if (!resolve_classref(m,fr->classref,resolveEager,true,&frclass))
- panic("Could not resolve class reference");
+ if (!fr)
+ return 0;
+ if (!resolve_classref(m,fr->classref,resolveEager,true, true,&frclass)) {
+ log_text("Could not resolve class reference");
+ assert(0);
+ }
+
LAZYLOADING(frclass)
fi = class_resolvefield(frclass,
classinfo *mrclass;
mr = class_getconstant(m->class, i, CONSTANT_Methodref);
- if (!resolve_classref(m,mr->classref,resolveEager,true,&mrclass))
- panic("Could not resolve class reference");
+ if (!mr)
+ return 0;
+ if (!resolve_classref(m,mr->classref,resolveEager,true, true,&mrclass)) {
+ log_text("Could not resolve class reference");
+ assert(0);
+ }
+
LAZYLOADING(mrclass)
mi = class_resolveclassmethod( mrclass,
mr->name,
methodinfo *mi;
classinfo *mrclass;
+ /* XXX remove direct access */
mr = m->class->cpinfos[i];
/*mr = class_getconstant(m->class, i, CONSTANT_Methodref)*/
- if (!resolve_classref(m,mr->classref,resolveEager,true,&mrclass))
- panic("Could not resolve class reference");
+ if (!resolve_classref(m,mr->classref,resolveEager,true, true,&mrclass)) {
+ log_text("Could not resolve class reference");
+ assert(0);
+ }
+
LAZYLOADING(mrclass)
mi = class_resolveclassmethod(mrclass,
mr->name,
classinfo *mrclass;
mr = class_getconstant(m->class, i, CONSTANT_InterfaceMethodref);
- if (!resolve_classref(m,mr->classref,resolveEager,true,&mrclass))
- panic("Could not resolve class reference");
+ if (!mr)
+ return 0;
+ if (!resolve_classref(m,mr->classref,resolveEager,true, true,&mrclass)) {
+ log_text("Could not resolve class reference");
+ assert(0);
+ }
+
LAZYLOADING(mrclass)
mi = class_resolveinterfacemethod(mrclass,
i = code_get_u2(p + 1,m);
{
classinfo *cls;
- cls = class_getconstant(m->class, i, CONSTANT_Class);
+ constant_classref *cr;
+ cr = (constant_classref *)class_getconstant(m->class, i, CONSTANT_Class);
+ if (!cr)
+ return 0;
+ resolve_classref(NULL,cr,resolveEager,true, false,&cls);
/*** s_count++; look for s_counts for VTA */
/* add marked methods */
CLASSNAME(cls,"NEW : do nothing",XTA_DEBUGr);
/* class used */
i = code_get_u2(p + 1,m);
{
- classinfo *cls =
- (classinfo *)
- class_getconstant(m->class, i, CONSTANT_Class);
+ constant_classref *cr;
+ classinfo *cls;
+ cr = (constant_classref*) class_getconstant(m->class, i, CONSTANT_Class);
+ if (!cr)
+ return 0;
+ resolve_classref(NULL,cr,resolveEager,true, false,&cls);
LAZYLOADING(cls)
CLASSNAMEop(cls,XTA_DEBUGr);
if (cls->classUsed == NOTUSED){
/*-- Get meth ptr for class.meth desc and add to XTA worklist --*/
#define SYSADD(cls,meth,desc, is_mono_poly, txt) \
- c = class_new(utf_new_char(cls)); \
+ c = load_class_bootstrap(utf_new_char(cls)); \
LAZYLOADING(c) \
callmeth = class_resolveclassmethod(c, \
utf_new_char(meth), \
if ((calls_class == NULL) || (calls_meth == NULL) || (calls_desc == NULL)
|| (class == NULL) || (meth == NULL) || (desc == NULL))
****/
- if ( (class == NULL) || (meth == NULL) || (desc == NULL))
- panic (
- "Error in xtaMissedIn file: Missing a part of calls_class.calls_meth calls calls_desc class.meth desc \n");
+ if ( (class == NULL) || (meth == NULL) || (desc == NULL)) {
+ log_text("Error in xtaMissedIn file: Missing a part of calls_class.calls_meth calls calls_desc class.meth desc");
+ assert(0);
+ }
SYSADD(class,meth,desc, POLY, missedtxt)
}
fclose(xtaMissedIn);
else {
printf("Abstract method in XTA Work List: ");
METHINFOx(xta_method);
- panic("Abstract method in XTA Work List.");
- }
- }
+ log_text("Abstract method in XTA Work List.");
+ assert(0);
+ }
+ }
}
void XTAprintCallgraph (list *xtaWorkList, char * txt);
methodinfo *xta_meth;
printf("\n%s\n",txt);
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
printf("-*-*-*-*- XTA Callgraph Worklist:<%i>\n",count_methods_marked_used);
#endif
xta_meth = xta->method;
printf(" (%i): ",i++);
- method_display_w_class(xta_meth);
+ method_println(xta_meth);
}
printf("\n\n");