adds 'nativeavailable()' and 'read(buf,offset,len)' methods into FileInputStream...
[IRC.git] / Robust / src / Runtime / runtime.c
index 9223e230ecc084724b6a8a5f4b47660cc24a71ac..01d4555594a4e9e48564038735b572c3eb59a6dd 100644 (file)
@@ -90,7 +90,7 @@ typedef unsigned long long ticks;
 #include "dmalloc.h"
 #endif
 
-int instanceof(struct ___Object___ *ptr, int type) {
+int instanceof(ObjectPtr ptr, int type) {
   int i=ptr->type;
   do {
     if (i==type)
@@ -101,7 +101,7 @@ int instanceof(struct ___Object___ *ptr, int type) {
   if (i>NUMCLASSES) {
     do {
       if (i==type)
-       return 1;
+        return 1;
       i=typearray2[i-NUMCLASSES];
     } while(i!=-1);
   }
@@ -132,7 +132,7 @@ void injectinstructionfailure() {
     instaccum+=failurecount;
     if ((((double)random())/RAND_MAX)<instfailurechance) {
       if (numfailures>0)
-       numfailures--;
+        numfailures--;
       printf("FAILURE!!! %d\n",numfailures);
       longjmp(error_handler,11);
     }
@@ -145,7 +145,7 @@ void injectinstructionfailure() {
     instaccum+=failurecount;
     if ((((double)random())/RAND_MAX)<instfailurechance) {
       if (numfailures>0)
-       numfailures--;
+        numfailures--;
       printf("FAILURE!!! %d\n",numfailures);
       threadexit();
     }
@@ -273,11 +273,11 @@ void deepArrayCopy(struct ___Object___ * dst, struct ___Object___ * src) {
       struct ___Object___ * ptr=((struct ___Object___**)(((char*) &aosrc->___length___)+sizeof(int)))[i];
       int ptrtype=((int *)ptr)[0];
       if (ptrtype>=NUMCLASSES) {
-       struct ___Object___ * dstptr=((struct ___Object___**)(((char*) &aodst->___length___)+sizeof(int)))[i];
-       deepArrayCopy(dstptr,ptr);
+        struct ___Object___ * dstptr=((struct ___Object___**)(((char*) &aodst->___length___)+sizeof(int)))[i];
+        deepArrayCopy(dstptr,ptr);
       } else {
-       //hit an object
-       ((struct ___Object___ **)(((char*) &aodst->___length___)+sizeof(int)))[i]=ptr;
+        //hit an object
+        ((struct ___Object___ **)(((char*) &aodst->___length___)+sizeof(int)))[i]=ptr;
       }
     }
   }
@@ -487,8 +487,8 @@ void CALL00(___System______gc____) {
       free(to_heapbase);
       to_heapbase=malloc(curr_heapsize);
       if (to_heapbase==NULL) {
-       printf("Error Allocating enough memory\n");
-       exit(-1);
+        printf("Error Allocating enough memory\n");
+        exit(-1);
       }
       to_heaptop=to_heapbase+curr_heapsize;
       to_heapptr=to_heapbase;
@@ -808,7 +808,7 @@ __attribute__((malloc)) void * allocate_new_mlp(void * ptr, int type, int oid, i
 #else
 __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
 #endif
-  struct ___Object___ * v=(struct ___Object___ *) mygcmalloc((struct garbagelist *) ptr, classsize[type]);
+  ObjectPtr v=(ObjectPtr) mygcmalloc((struct garbagelist *) ptr, classsize[type]);
   v->type=type;
   v->hashcode=(int)(INTPTR)v;
 #ifdef THREADS
@@ -819,7 +819,7 @@ __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
 #endif
 #ifdef MLP
   v->oid=oid;
-  v->allocsite=allocsite;
+  //  v->allocsite=allocsite;
 #endif
   return v;
 }
@@ -856,7 +856,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t
 
 #else
 __attribute__((malloc)) void * allocate_new(int type) {
-  struct ___Object___ * v=FREEMALLOC(classsize[type]);
+  ObjectPtr v=FREEMALLOC(classsize[type]);
   v->type=type;
   v->hashcode=(int)(INTPTR)v;
 #ifdef OPTIONAL
@@ -882,19 +882,19 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int len
 
 /* Converts C character arrays into Java strings */
 #ifdef PRECISE_GC
-__attribute__((malloc)) struct ___String___ * NewStringShort(void * ptr, const short *str,int length) {
+__attribute__((malloc)) StringPtr NewStringShort(void * ptr, const short *str,int length) {
 #else
-__attribute__((malloc)) struct ___String___ * NewStringShort(const short *str,int length) {
+__attribute__((malloc)) StringPtr NewStringShort(const short *str,int length) {
 #endif
   int i;
 #ifdef PRECISE_GC
   struct ArrayObject * chararray=allocate_newarray((struct garbagelist *)ptr, CHARARRAYTYPE, length);
   INTPTR ptrarray[]={1, (INTPTR) ptr, (INTPTR) chararray};
-  struct ___String___ * strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE);
+  StringPtr strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE);
   chararray=(struct ArrayObject *) ptrarray[2];
 #else
   struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length);
-  struct ___String___ * strobj=allocate_new(STRINGTYPE);
+  StringPtr strobj=allocate_new(STRINGTYPE);
 #endif
   strobj->___value___=chararray;
   strobj->___count___=length;
@@ -908,19 +908,19 @@ __attribute__((malloc)) struct ___String___ * NewStringShort(const short *str,in
 
 /* Converts C character arrays into Java strings */
 #ifdef PRECISE_GC
-__attribute__((malloc)) struct ___String___ * NewString(void * ptr, const char *str,int length) {
+__attribute__((malloc)) StringPtr NewString(void * ptr, const char *str,int length) {
 #else
-__attribute__((malloc)) struct ___String___ * NewString(const char *str,int length) {
+__attribute__((malloc)) StringPtr NewString(const char *str,int length) {
 #endif
   int i;
 #ifdef PRECISE_GC
   struct ArrayObject * chararray=allocate_newarray((struct garbagelist *)ptr, CHARARRAYTYPE, length);
   INTPTR ptrarray[]={1, (INTPTR) ptr, (INTPTR) chararray};
-  struct ___String___ * strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE);
+  StringPtr strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE);
   chararray=(struct ArrayObject *) ptrarray[2];
 #else
   struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length);
-  struct ___String___ * strobj=allocate_new(STRINGTYPE);
+  StringPtr strobj=allocate_new(STRINGTYPE);
 #endif
   strobj->___value___=chararray;
   strobj->___count___=length;
@@ -934,9 +934,9 @@ __attribute__((malloc)) struct ___String___ * NewString(const char *str,int leng
 
 /* Generated code calls this if we fail a bounds check */
 
-void failedboundschk(int num) {
+ void failedboundschk(int num, int index, struct ArrayObject * ao ) {
 #ifndef TASK
-  printf("Array out of bounds\n");
+   printf("Array out of bounds at line %u with index %u of object %x with length %u\n", num, index, ao, ao->___length___);
 #ifdef THREADS
   threadexit();
 #else