-/* jit/sets.c -
+/* vm/jit/inline/sets.c -
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Institut f. Computersprachen, TU Wien
Authors: Carolyn Oates
- $Id: sets.c 557 2003-11-02 22:51:59Z twisti $
+ $Id: sets.c 1621 2004-11-30 13:06:55Z twisti $
*/
#include <stdio.h>
-#include "sets.h"
+
#include "types.h"
-#include "global.h"
+#include "mm/memory.h"
+#include "vm/global.h"
+#include "vm/loader.h"
+#include "vm/tables.h"
+#include "vm/jit/inline/sets.h"
/*
{
fldSetNode *s1 = s;
if (!inFldSet(s,f)) {
- s1 = (fldSetNode *)malloc(sizeof(fldSetNode));
+ s1 = NEW(fldSetNode);
s1->nextfldRef = s;
s1->fldRef = f;
s1->writePUT = false;
s = sf->head;
s1 = inFldSet(s,f);
if (s1 == NULL) {
- s1 = (fldSetNode *)malloc(sizeof(fldSetNode));
+ s1 = NEW(fldSetNode);
if (sf->head == NULL) {
sf->head = s1;
sf->pos = s1;
fldSet *createFldSet( )
{
fldSet *s;
- s = (fldSet *)malloc(sizeof(fldSet));
+ s = NEW(fldSet);
s->head = NULL;
s->tail = NULL;
s->pos = NULL;
/*------------------------------------------------------------*/
/*-- methodinfo call set fns */
/*------------------------------------------------------------*/
-int inMethSet (methSetNode *s, methodinfo *m)
+int inMethSet(methSetNode *s, methodinfo *m)
{
methSetNode* i;
- for (i=s; i != NULL; i = i->nextmethRef) {
+ for (i = s; i != NULL; i = i->nextmethRef) {
if (i->methRef == m) {
return (int)1; /* true = found */
}
{
methSetNode *s1 = s;
if (!inMethSet(s,m)) {
- s1 = (methSetNode *)malloc(sizeof(methSetNode));
+ s1 = NEW(methSetNode);
s1->nextmethRef= s;
s1->methRef = m;
s1->lastptrIntoClassSet2 = NULL;
}
s = sm->head;
if (!inMethSet(s,m)) {
- s1 = (methSetNode *)malloc(sizeof(methSetNode));
+ s1 = NEW(methSetNode);
if (sm->head == NULL) {
sm->head = s1;
sm->pos = s1;
methSet *createMethSet( )
{
methSet *s;
- s = (methSet *)malloc(sizeof(methSet));
+ s = NEW(methSet);
s->head = NULL;
s->tail = NULL;
s->pos = NULL;
/*------------------------------------------------------------*/
/*-- classinfo XTA set fns */
/*------------------------------------------------------------*/
-int inSet (classSetNode *s, classinfo *c)
+int inSet(classSetNode *s, classinfo *c)
{
classSetNode* i;
- for (i=s; i != NULL; i = i->nextClass) {
+ for (i = s; i != NULL; i = i->nextClass) {
if (i->classType == c) {
- return ((i->index)+1); /* true = found */
+ return ((i->index) + 1); /* true = found */
}
}
return (int)0;
{
classSetNode *s1 = s;
if (!inSet(s,c)) {
- s1 = (classSetNode *)malloc(sizeof(classSetNode));
+ s1 = NEW(classSetNode);
s1->nextClass= s;
s1->classType = c;
if (s == NULL)
s = sc->head;
if (!inSet(s,c)) {
- s1 = (classSetNode *)malloc(sizeof(classSetNode));
+ s1 = NEW(classSetNode);
if (sc->head == NULL) {
sc->head = s1;
sc->pos = s1;
/*------------------------------------------------------------*/
-classSet *createClassSet( )
+classSet *createClassSet()
{
classSet *s;
- s = (classSet *)malloc(sizeof(classSet));
+ s = NEW(classSet);
s->head = NULL;
s->tail = NULL;
s->pos = NULL;
/* 0 c class type cone does not overlap any set element */
/* 1 c is a superclass of an existing set element */
-int inRange (classSetNode *s, classinfo *c)
+int inRange(classSetNode *s, classinfo *c)
{
classSetNode* i;
- int rc=0;
+ int rc = 0;
- for (i=s; i != NULL; i = i->nextClass) {
+ for (i = s; i != NULL; i = i->nextClass) {
classinfo *cs = i->classType;
if (cs->vftbl->baseval <= c->vftbl->baseval) {
if (c->vftbl->baseval <= (cs->vftbl->baseval+cs->vftbl->diffval)) {
if (inRange(s,c) == 0) {
/* not in set nor cone of an existing element so add */
- s1 = (classSetNode *)malloc(sizeof(classSetNode));
+ s1 = NEW(classSetNode);
s1->nextClass= s;
s1->classType = c;
if (s == NULL)
/*------------------------------------------------------------*/
+/* intersect the subtypes of class t with class set s */
classSetNode * intersectSubtypesWithSet(classinfo *t, classSetNode *s) {
classSetNode *s1 = NULL;
classSetNode *c;
/* for each s class */
for (c=s; c != NULL; c = c->nextClass) {
- vftbl *t_cl_vt = t->vftbl;
- vftbl *c_cl_vt = c->classType->vftbl;
+ vftbl_t *t_cl_vt = t->vftbl;
+ vftbl_t *c_cl_vt = c->classType->vftbl;
/* if s class is in the t Class range */
if ( (t_cl_vt->baseval <= c_cl_vt->baseval)
if (s == NULL) {
printf("Set of types: <");
printf("\t\tEmpty Set\n");
- }
- else {
+
+ } else {
printf("<%i>Set of types: ",s->index);
- for (i=s; i != NULL; i = i->nextClass) {
+ for (i = s; i != NULL; i = i->nextClass) {
printf("\t#%i: ",cnt);
if (i->classType == NULL) {
printf("NULL CLASS");
fflush(stdout);
- }
- else {
+
+ } else {
utf_display(i->classType->name);
fflush(stdout);
printf("<b%i/d%i> ",i->classType->vftbl->baseval,i->classType->vftbl->diffval);
/*------------------------------------------------------------*/
-int printClassSet(classSet *sc) {
+int printClassSet(classSet *sc)
+{
if (sc == NULL) {
printf("Class Set not yet created\n");
return 0;
- }
- else
+
+ } else
return (printSet(sc->head));
}
{
methSetNode* i;
int cnt=0;
-
if (s == NULL) {
printf("Set of Methods: "); fflush(stdout);
- printf("\t\tEmpty Set\n"); fflush(stdout);
- }
+ printf("\t\tEmpty Set\n"); fflush(stdout);
+ }
else {
printf("<%i>Set of Methods: ",s->index);fflush(stdout);
for (i=s; i != NULL; i = i->nextmethRef) {
/*------------------------------------------------------------*/
int printMethodSet(methSet *sm) {
if (sm == NULL) {
- printf("Method Set not yet created\n");
+ printf("Method Set not yet created\n");fflush(stdout);
return 0;
}
- else
- return (printMethSet(sm->head));
+ else {
+ if (sm->head == NULL) {
+ printf("Set of Methods: "); fflush(stdout);
+ printf("\t\tEmpty Set\n"); fflush(stdout);
+ return 0;
+ }
+ else
+ return (printMethSet(sm->head));
+ }
}