GNU header update.
[cacao.git] / src / vm / jit / inline / sets.c
index fe658d55a2328062be55d6bb8877ea578324005e..4967d9b9decd004cb9b0ced13d67a1417a3232c2 100644 (file)
@@ -1,10 +1,9 @@
-/* jit/sets.c -
+/* vm/jit/inline/sets.c -
 
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-   Institut f. Computersprachen, TU Wien
-   R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Probst,
-   S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich,
-   J. Wenninger
+   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
 
    This file is part of CACAO.
 
 
    Authors: Carolyn Oates
 
-   $Id: sets.c 557 2003-11-02 22:51:59Z twisti $
+   $Id: sets.c 1735 2004-12-07 14:33:27Z 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"
 
 
 /*
@@ -64,7 +67,7 @@ fldSetNode *addFldRef(fldSetNode *s, fieldinfo *f)
 {
        fldSetNode *s1 = s;
        if (!inFldSet(s,f)) {
-               s1 = (fldSetNode *)malloc(sizeof(fldSetNode));
+               s1 = NEW(fldSetNode);
                s1->nextfldRef  = s;
                s1->fldRef      = f;
                s1->writePUT     = false;
@@ -93,7 +96,7 @@ fldSet *add2FldSet(fldSet *sf,  fieldinfo *f, bool wput, bool rget)
        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;
@@ -126,7 +129,7 @@ fldSet *add2FldSet(fldSet *sf,  fieldinfo *f, bool wput, bool rget)
 fldSet *createFldSet( )
 {
        fldSet *s;
-       s = (fldSet *)malloc(sizeof(fldSet));
+       s = NEW(fldSet);
        s->head = NULL;
        s->tail = NULL;
        s->pos  = NULL;
@@ -138,10 +141,10 @@ fldSet *createFldSet( )
 /*------------------------------------------------------------*/
 /*-- 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 */
                }
@@ -155,7 +158,7 @@ methSetNode *addMethRef(methSetNode *s,  methodinfo *m)
 {
        methSetNode *s1 = s;
        if (!inMethSet(s,m)) {
-               s1 = (methSetNode *)malloc(sizeof(methSetNode));
+               s1 = NEW(methSetNode);
                s1->nextmethRef= s;
                s1->methRef = m;
                s1->lastptrIntoClassSet2 = NULL;
@@ -181,7 +184,7 @@ methSet *add2MethSet(methSet *sm,  methodinfo *m)
        }
        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;
@@ -206,7 +209,7 @@ methSet *add2MethSet(methSet *sm,  methodinfo *m)
 methSet *createMethSet( )
 {
        methSet *s;
-       s = (methSet *)malloc(sizeof(methSet));
+       s = NEW(methSet);
        s->head = NULL;
        s->tail = NULL;
        s->pos  = NULL;
@@ -218,12 +221,12 @@ methSet *createMethSet( )
 /*------------------------------------------------------------*/
 /*-- 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;
@@ -235,7 +238,7 @@ classSetNode *addElement(classSetNode *s,  classinfo *c)
 {
        classSetNode *s1 = s;
        if (!inSet(s,c)) {
-               s1 = (classSetNode *)malloc(sizeof(classSetNode));
+               s1 = NEW(classSetNode);
                s1->nextClass= s;
                s1->classType = c;
                if (s == NULL)
@@ -259,7 +262,7 @@ classSet *add2ClassSet(classSet *sc,  classinfo *c)
        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;
@@ -279,10 +282,10 @@ classSet *add2ClassSet(classSet *sc,  classinfo *c)
 
 
 /*------------------------------------------------------------*/
-classSet *createClassSet( )
+classSet *createClassSet()
 {
        classSet *s;
-       s = (classSet *)malloc(sizeof(classSet));
+       s = NEW(classSet);
        s->head = NULL;
        s->tail = NULL;
        s->pos  = NULL;
@@ -297,12 +300,12 @@ classSet *createClassSet( )
 /*     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)) {
@@ -331,7 +334,7 @@ classSetNode *addClassCone(classSetNode *s,  classinfo *c)
  
        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)
@@ -344,14 +347,15 @@ classSetNode *addClassCone(classSetNode *s,  classinfo *c)
 
 
 /*------------------------------------------------------------*/
+/* 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)
@@ -384,16 +388,16 @@ int printSet(classSetNode *s)
        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); 
@@ -408,12 +412,13 @@ int printSet(classSetNode *s)
 
 
 /*------------------------------------------------------------*/
-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));
 }
 
@@ -423,11 +428,10 @@ int printMethSet(methSetNode *s)
 {
        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) {
@@ -455,11 +459,18 @@ int printMethSet(methSetNode *s)
 /*------------------------------------------------------------*/
 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));
+               }
 }