adds 'nativeavailable()' and 'read(buf,offset,len)' methods into FileInputStream...
[IRC.git] / Robust / src / Runtime / runtime.c
index 7adccfe40c50614920c37a353f01556aa53fc92f..01d4555594a4e9e48564038735b572c3eb59a6dd 100644 (file)
 #include "DSTM/interface_recovery/altprelookup.h"
 
 #ifdef RECOVERYSTATS
-  extern int numRecovery;
-  extern unsigned int deadMachine[8];
-  extern unsigned int sizeOfRedupedData[8];
-  extern double elapsedTime[8];
+extern int numRecovery;
+extern unsigned int deadMachine[8];
+extern unsigned int sizeOfRedupedData[8];
+extern double elapsedTime[8];
 #endif
-  
+
 #else
 #include "DSTM/interface/dstm.h"
 #include "DSTM/interface/altprelookup.h"
@@ -45,19 +45,21 @@ unsigned long long beginClock=0;
 #ifdef EVENTMONITOR
 #include "monitor.h"
 __thread int objcount=0;
-#define ASSIGNUID(x) {                                 \
-    int number=((objcount++)<<EVTHREADSHIFT)|threadnum;        \
-    x->objuid=number;                                  \
-  }
+#define ASSIGNUID(x) {                                  \
+    int number=((objcount++)<<EVTHREADSHIFT)|threadnum; \
+    x->objuid=number;                                   \
+}
 #else
 #define ASSIGNUID(x)
 #endif
 
 #if defined(THREADS)||defined(STM)
+#ifndef MAC
 /* Global barrier for STM */
 pthread_barrier_t barrier;
 pthread_barrierattr_t attr;
 #endif
+#endif
 
 #include <string.h>
 
@@ -88,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)
@@ -99,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);
   }
@@ -130,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);
     }
@@ -143,7 +145,7 @@ void injectinstructionfailure() {
     instaccum+=failurecount;
     if ((((double)random())/RAND_MAX)<instfailurechance) {
       if (numfailures>0)
-       numfailures--;
+        numfailures--;
       printf("FAILURE!!! %d\n",numfailures);
       threadexit();
     }
@@ -155,7 +157,7 @@ void injectinstructionfailure() {
 #ifdef D___Double______nativeparsedouble____L___String___
 double CALL01(___Double______nativeparsedouble____L___String___,struct ___String___ * ___str___) {
   int length=VAR(___str___)->___count___;
-  int maxlength=(length>60)?60:length;
+  int maxlength=(length>60) ? 60 : length;
   char str[maxlength+1];
   struct ArrayObject * chararray=VAR(___str___)->___value___;
   int i;
@@ -169,9 +171,9 @@ double CALL01(___Double______nativeparsedouble____L___String___,struct ___String
 }
 #endif
 
-#ifdef D___Double______nativeparsedouble_____AR_B_I_I 
+#ifdef D___Double______nativeparsedouble_____AR_B_I_I
 double CALL23(___Double______nativeparsedouble_____AR_B_I_I, int start, int length,int start,int length,struct ArrayObject * ___str___) {
-  int maxlength=(length>60)?60:length;
+  int maxlength=(length>60) ? 60 : length;
   char str[maxlength+1];
   struct ArrayObject * bytearray=VAR(___str___);
   int i;
@@ -184,16 +186,15 @@ double CALL23(___Double______nativeparsedouble_____AR_B_I_I, int start, int leng
 }
 #endif
 
-#ifdef D___Double______doubleToRawLongBits____D 
-typedef union jvalue
-{
+#ifdef D___Double______doubleToRawLongBits____D
+typedef union jvalue {
   bool z;
-  char    c;
-  short   s;
-  int     i;
-  long long    j;
-  float   f;
-  double  d;
+  char c;
+  short s;
+  int i;
+  long long j;
+  float f;
+  double d;
 } jvalue;
 
 long long CALL11(___Double______doubleToRawLongBits____D, double dval, double dval) {
@@ -214,7 +215,7 @@ long long CALL11(___Double______doubleToRawLongBits____D, double dval, double dv
 }
 #endif
 
-#ifdef D___Double______longBitsToDouble____J 
+#ifdef D___Double______longBitsToDouble____J
 double CALL11(___Double______longBitsToDouble____J, long long lval, long long lval) {
   jvalue val;
   val.j = lval;
@@ -264,19 +265,19 @@ void deepArrayCopy(struct ___Object___ * dst, struct ___Object___ * src) {
     int elementsize=classsize[srctype];
     int size=srclength*elementsize;
     //primitives
-    memcpy(((char *)&aodst->___length___)+sizeof(int) , ((char *)&aosrc->___length___)+sizeof(int), size);
+    memcpy(((char *)&aodst->___length___)+sizeof(int), ((char *)&aosrc->___length___)+sizeof(int), size);
   } else {
     //objects
     int i;
-    for(i=0;i<srclength;i++) {
+    for(i=0; i<srclength; i++) {
       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;
       }
     }
   }
@@ -319,7 +320,7 @@ void arraycopy(struct ___Object___ *src, int srcPos, struct ___Object___ *dst, i
   } else {
     //objects
     int i;
-    for(i=0;i<length;i++) {
+    for(i=0; i<length; i++) {
       struct ___Object___ * ptr=((struct ___Object___**)(((char*) &aosrc->___length___)+sizeof(int)))[i+srcPos];
       //hit an object
       ((struct ___Object___ **)(((char*) &aodst->___length___)+sizeof(int)))[i+destPos]=ptr;
@@ -327,7 +328,7 @@ void arraycopy(struct ___Object___ *src, int srcPos, struct ___Object___ *dst, i
   }
 }
 
-void CALL35(___System______arraycopy____L___Object____I_L___Object____I_I, int ___srcPos___, int ___destPos___, int ___length___, struct ___Object___ * ___src___, int ___srcPos___, struct ___Object___ * ___dst___, int  ___destPos___, int ___length___) {
+void CALL35(___System______arraycopy____L___Object____I_L___Object____I_I, int ___srcPos___, int ___destPos___, int ___length___, struct ___Object___ * ___src___, int ___srcPos___, struct ___Object___ * ___dst___, int ___destPos___, int ___length___) {
   arraycopy(VAR(___src___), ___srcPos___, VAR(___dst___), ___destPos___, ___length___);
 }
 #endif
@@ -335,7 +336,7 @@ void CALL35(___System______arraycopy____L___Object____I_L___Object____I_I, int _
 #ifdef D___Runtime______availableProcessors____
 int CALL01(___Runtime______availableProcessors____, struct ___Runtime___ * ___this___) {
   printf("Unimplemented Runtime.availableProcessors\n");
-  return 2;
+  return 24;
 }
 #endif
 
@@ -359,7 +360,7 @@ long long CALL01(___Runtime______maxMemory____, struct ___Runtime___ * ___this__
   return 1024*1024*1024;
 }
 #endif
-
+#ifdef D___System______exit____I
 void CALL11(___System______exit____I,int ___status___, int ___status___) {
 #ifdef TRANSSTATS
 #ifndef RECOVERY
@@ -383,7 +384,9 @@ void CALL11(___System______exit____I,int ___status___, int ___status___) {
 #endif
   exit(___status___);
 }
+#endif
 
+#ifdef D___System______logevent____I
 void CALL11(___System______logevent____I,int ___event___, int ___event___) {
 #ifdef STMLOG
   event[counter] = ___event___;
@@ -392,14 +395,18 @@ void CALL11(___System______logevent____I,int ___event___, int ___event___) {
 #endif
   return;
 }
+#endif
 
+#ifdef ___System______logevent____
 void CALL00(___System______logevent____) {
 #ifdef STMLOG
   beginClock= rdtsc();
 #endif
   return;
 }
+#endif
 
+#ifdef ___System______flushToFile____I
 void CALL11(___System______flushToFile____I, int ___threadid___, int ___threadid___) {
 #ifdef STMLOG
   FILE *fp;
@@ -421,7 +428,9 @@ void CALL11(___System______flushToFile____I, int ___threadid___, int ___threadid
 #endif
   return;
 }
+#endif
 
+#ifdef D___System______initLog____
 void CALL00(___System______initLog____) {
 #ifdef STMLOG
   counter=0;
@@ -434,6 +443,7 @@ void CALL00(___System______initLog____) {
 #endif
   return;
 }
+#endif
 
 #ifdef D___Vector______removeElement_____AR_L___Object____I_I
 void CALL23(___Vector______removeElement_____AR_L___Object____I_I, int ___index___, int ___size___, struct ArrayObject * ___array___, int ___index___, int ___size___) {
@@ -442,10 +452,13 @@ void CALL23(___Vector______removeElement_____AR_L___Object____I_I, int ___index_
 }
 #endif
 
+#ifdef D___System______printI____I
 void CALL11(___System______printI____I,int ___status___, int ___status___) {
   printf("%d\n",___status___);
 }
+#endif
 
+#ifdef D___System______currentTimeMillis____
 long long CALL00(___System______currentTimeMillis____) {
   struct timeval tv; long long retval;
   gettimeofday(&tv, NULL);
@@ -454,6 +467,7 @@ long long CALL00(___System______currentTimeMillis____) {
   retval+= (tv.tv_usec/1000); /* adjust milliseconds & add them in */
   return retval;
 }
+#endif
 
 #ifdef D___System______gc____
 void CALL00(___System______gc____) {
@@ -473,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;
@@ -485,19 +499,19 @@ void CALL00(___System______gc____) {
   collect((struct garbagelist *)___params___);
 
   {
-  void * tmp=to_heapbase;
-  to_heapbase=curr_heapbase;
-  curr_heapbase=tmp;
+    void * tmp=to_heapbase;
+    to_heapbase=curr_heapbase;
+    curr_heapbase=tmp;
 
-  tmp=to_heaptop;
-  to_heaptop=curr_heaptop;
-  curr_heaptop=tmp;
+    tmp=to_heaptop;
+    to_heaptop=curr_heaptop;
+    curr_heaptop=tmp;
 
-  tmp=to_heapptr;
-  curr_heapptr=to_heapptr;
-  curr_heapgcpoint=((char *) curr_heapbase)+GCPOINT(curr_heaptop-curr_heapbase);
-  to_heapptr=to_heapbase;
-  bzero(tmp, curr_heaptop-tmp);
+    tmp=to_heapptr;
+    curr_heapptr=to_heapptr;
+    curr_heapgcpoint=((char *) curr_heapbase)+GCPOINT(curr_heaptop-curr_heapbase);
+    to_heapptr=to_heapbase;
+    bzero(tmp, curr_heaptop-tmp);
 
   }
 
@@ -507,8 +521,9 @@ void CALL00(___System______gc____) {
 }
 #endif
 
+#ifdef D___System______microTimes____
 long long CALL00(___System______microTimes____) {
-  struct timeval tv; 
+  struct timeval tv;
   long long retval;
   gettimeofday(&tv, NULL);
   retval = tv.tv_sec; /* seconds */
@@ -516,14 +531,18 @@ long long CALL00(___System______microTimes____) {
   retval+= (tv.tv_usec); /* adjust microseconds & add them in */
   return retval;
 }
+#endif
 
+#ifdef D___System______getticks____
 long long CALL00(___System______getticks____) {
   unsigned a, d;
-  asm("cpuid");
-  asm volatile("rdtsc" : "=a" (a), "=d" (d));
+  asm ("cpuid");
+  asm volatile ("rdtsc" : "=a" (a), "=d" (d));
   return (((ticks)a) | (((ticks)d) << 32));
 }
+#endif
 
+#ifdef D___System______printString____L___String___
 void CALL01(___System______printString____L___String___,struct ___String___ * ___s___) {
   struct ArrayObject * chararray=VAR(___s___)->___value___;
   int i;
@@ -537,8 +556,9 @@ void CALL01(___System______printString____L___String___,struct ___String___ * __
   fflush(stdout);
 #endif
 }
+#endif
 
-#ifdef D___RecoveryStat______printRecoveryStat____ 
+#ifdef D___RecoveryStat______printRecoveryStat____
 #ifdef RECOVERYSTATS
 void CALL00(___RecoveryStat______printRecoveryStat____) {
   printRecoveryStat();
@@ -552,11 +572,14 @@ void CALL00(___RecoveryStat______printRecoveryStat____) {
 #endif
 
 #ifdef DSTM
+#ifdef D___System______clearPrefetchCache____
 void CALL00(___System______clearPrefetchCache____) {
   prehashClear();
 }
+#endif
 
 #ifdef RANGEPREFETCH
+#ifdef D___System______rangePrefetch____L___Object_____AR_S
 void CALL02(___System______rangePrefetch____L___Object_____AR_S, struct ___Object___ * ___o___, struct ArrayObject * ___offsets___) {
   /* Manual Prefetches to be inserted */
   //printf("DEBUG-> %s() ___Object___ * ___o___ = %x\n", __func__, VAR(___o___));
@@ -583,22 +606,22 @@ void CALL02(___System______rangePrefetch____L___Object_____AR_S, struct ___Objec
   return;
 }
 #endif
+#endif
 
-#ifdef D___Task______execution____ 
+#ifdef D___Task______execution____
 extern void* virtualtable[];
 // associated with Task.execution(). finds proper execute method and call it
-void CALL01(___Task______execution____,struct ___Task___ * ___this___)
-{
+void CALL01(___Task______execution____,struct ___Task___ * ___this___) {
   unsigned int oid;
   oid = (unsigned int) VAR(___this___);   // object id
   int type = getObjType(oid);             // object type
 
 #ifdef PRECISE_GC
-  int p[] = {1,0 , oid};
-  ((void(*) (void *))virtualtable[type*MAXCOUNT + EXECUTEMETHOD])(p);
+  int p[] = {1,0, oid};
+  ((void (*)(void *))virtualtable[type*MAXCOUNT + EXECUTEMETHOD])(p);
 #else
   // call the proper execute method
-  ((void(*) (void *))virtualtable[type*MAXCOUNT + EXECUTEMETHOD])(oid);
+  ((void (*)(void *))virtualtable[type*MAXCOUNT + EXECUTEMETHOD])(oid);
 #endif
 }
 #endif
@@ -647,11 +670,10 @@ void CALL00(___Barrier______enterBarrier____) {
 __attribute__((malloc)) void * allocate_newglobal(int type) {
   struct ___Object___ * v=(struct ___Object___ *) transCreateObj(classsize[type]);
   v->type=type;
+  v->hashcode=(int)(INTPTR)v;
   //printf("DEBUG %s(), type= %x\n", __func__, type);
 #ifdef THREADS
   v->tid=0;
-  v->lockentry=0;
-  v->lockcount=0;
 #endif
   return v;
 }
@@ -665,11 +687,10 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarrayglobal(int type, i
     return NULL;
   }
   v->type=type;
+  v->hashcode=(int)(INTPTR)v;
   v->___length___=length;
 #ifdef THREADS
   v->tid=0;
-  v->lockentry=0;
-  v->lockcount=0;
 #endif
   return v;
 }
@@ -688,6 +709,7 @@ __attribute__((malloc)) void * allocate_newtrans(void * ptr, int type) {
 #endif
   ASSIGNUID(v);
   v->type=type;
+  v->hashcode=(int)(INTPTR)v;
   v->___objlocation___=v;
   return v;
 }
@@ -702,7 +724,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarraytrans(void * ptr,
   int bookkeepsize=numlocks*2*sizeof(int);
   struct ArrayObject * v=(struct ArrayObject *)transCreateObj(ptr, sizeof(struct ArrayObject)+basesize+bookkeepsize, bookkeepsize);
   unsigned int *intptr=(unsigned int *)(((char *)v)-sizeof(objheader_t));
-  for(;numlocks>0;numlocks--) {
+  for(; numlocks>0; numlocks--) {
     intptr-=2;
     intptr[0]=1;
   }
@@ -718,6 +740,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarraytrans(void * ptr,
   }
   v->___objlocation___=(struct ___Object___*)v;
   v->type=type;
+  v->hashcode=(int)(INTPTR)v;
   v->___length___=length;
   return v;
 }
@@ -730,6 +753,7 @@ __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
   tmp->version = 1;
   v->___objlocation___=v;
   v->type = type;
+  v->hashcode=(int)(INTPTR)v;
   return v;
 }
 
@@ -743,7 +767,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t
   int numlocks=basesize>>INDEXSHIFT;
   int bookkeepsize=(numlocks)*2*sizeof(int);
   int *tmpint=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+basesize+sizeof(objheader_t)+bookkeepsize);
-  for(;numlocks>0;numlocks--) {
+  for(; numlocks>0; numlocks--) {
     tmpint[0]=1;
     tmpint+=2;
   }
@@ -763,6 +787,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t
   tmp->version=1;
   ASSIGNUID(v);
   v->type=type;
+  v->hashcode=(int)(INTPTR)v;
   if (length<0) {
     printf("ERROR: negative array %d\n", length);
     return NULL;
@@ -783,19 +808,18 @@ __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
   v->tid=0;
-  v->lockentry=0;
-  v->lockcount=0;
 #endif
 #ifdef OPTIONAL
   v->fses=0;
 #endif
 #ifdef MLP
   v->oid=oid;
-  v->allocsite=allocsite;
+  //  v->allocsite=allocsite;
 #endif
   return v;
 }
@@ -805,12 +829,13 @@ __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
   return allocate_newarray_mlp(ptr, type, length, 0, 0);
 }
- __attribute__((malloc)) struct ArrayObject * allocate_newarray_mlp(void * ptr, int type, int length, int oid, int allocsite) {
+__attribute__((malloc)) struct ArrayObject * allocate_newarray_mlp(void * ptr, int type, int length, int oid, int allocsite) {
 #else
 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
 #endif
   struct ArrayObject * v=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+length*classsize[type]);
   v->type=type;
+  v->hashcode=(int)(INTPTR)v;
   if (length<0) {
     printf("ERROR: negative array\n");
     return NULL;
@@ -818,8 +843,6 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t
   v->___length___=length;
 #ifdef THREADS
   v->tid=0;
-  v->lockentry=0;
-  v->lockcount=0;
 #endif
 #ifdef OPTIONAL
   v->fses=0;
@@ -833,8 +856,9 @@ __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
   v->fses=0;
 #endif
@@ -846,6 +870,7 @@ __attribute__((malloc)) void * allocate_new(int type) {
 __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int length) {
   __attribute__((malloc))  struct ArrayObject * v=FREEMALLOC(sizeof(struct ArrayObject)+length*classsize[type]);
   v->type=type;
+  v->hashcode=(int)(INTPTR)v;
   v->___length___=length;
 #ifdef OPTIONAL
   v->fses=0;
@@ -857,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;
@@ -883,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;
@@ -909,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
@@ -934,11 +959,11 @@ void abort_task() {
 
 #ifndef SANDBOX
 #ifdef D___System______Assert____Z
- void CALL11(___System______Assert____Z, int ___status___, int ___status___) {
-   if (!___status___) {
-     printf("Assertion violation\n");
-     *((int *)(NULL)); //force stack trace error
-   }
- }
+void CALL11(___System______Assert____Z, int ___status___, int ___status___) {
+  if (!___status___) {
+    printf("Assertion violation\n");
+    *((int *)(NULL));  //force stack trace error
+  }
+}
 #endif
 #endif