2 #include "structdefs.h"
9 #include "methodheaders.h"
11 #if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP)
17 #include "DSTM/interface_recovery/dstm.h"
18 #include "DSTM/interface_recovery/altprelookup.h"
21 extern int numRecovery;
22 extern unsigned int deadMachine[8];
23 extern unsigned int sizeOfRedupedData[8];
24 extern double elapsedTime[8];
28 #include "DSTM/interface/dstm.h"
29 #include "DSTM/interface/altprelookup.h"
30 #include "DSTM/interface/prefetch.h"
38 #define ARRAY_LENGTH 700003
40 __thread int event[ARRAY_LENGTH];
41 __thread unsigned long long clkticks[ARRAY_LENGTH];
42 unsigned long long beginClock=0;
43 #define FILENAME "log"
47 __thread int objcount=0;
48 #define ASSIGNUID(x) { \
49 int number=((objcount++)<<EVTHREADSHIFT)|threadnum; \
56 #if defined(THREADS)||defined(STM)
58 /* Global barrier for STM */
59 pthread_barrier_t barrier;
60 pthread_barrierattr_t attr;
69 #define GCPOINT(x) ((INTPTR)((x)*0.99))
72 extern int classsize[];
73 extern int typearray[];
74 extern int typearray2[];
75 jmp_buf error_handler;
80 float failurechance=0;
83 int injectinstructionfailures;
85 float instfailurechance=0;
88 typedef unsigned long long ticks;
93 int instanceof(ObjectPtr ptr, int type) {
105 i=typearray2[i-NUMCLASSES];
111 void exithandler(int sig, siginfo_t *info, void * uap) {
115 void initializeexithandler() {
116 struct sigaction sig;
117 sig.sa_sigaction=&exithandler;
118 sig.sa_flags=SA_SIGINFO;
119 sigemptyset(&sig.sa_mask);
120 sigaction(SIGUSR2, &sig, 0);
124 /* This function inject failures */
126 void injectinstructionfailure() {
128 if (injectinstructionfailures) {
131 instructioncount=failurecount;
132 instaccum+=failurecount;
133 if ((((double)random())/RAND_MAX)<instfailurechance) {
136 printf("FAILURE!!! %d\n",numfailures);
137 longjmp(error_handler,11);
142 if (injectinstructionfailures) {
145 instaccum+=failurecount;
146 if ((((double)random())/RAND_MAX)<instfailurechance) {
149 printf("FAILURE!!! %d\n",numfailures);
157 #ifdef D___Double______nativeparsedouble____L___String___
158 double CALL01(___Double______nativeparsedouble____L___String___,struct ___String___ * ___str___) {
159 int length=VAR(___str___)->___count___;
160 int maxlength=(length>60) ? 60 : length;
161 char str[maxlength+1];
162 struct ArrayObject * chararray=VAR(___str___)->___value___;
164 int offset=VAR(___str___)->___offset___;
165 for(i=0; i<maxlength; i++) {
166 str[i]=((short *)(((char *)&chararray->___length___)+sizeof(int)))[i+offset];
174 #ifdef D___Double______nativeparsedouble_____AR_B_I_I
175 double CALL23(___Double______nativeparsedouble_____AR_B_I_I, int start, int length,int start,int length,struct ArrayObject * ___str___) {
176 int maxlength=(length>60) ? 60 : length;
177 char str[maxlength+1];
178 struct ArrayObject * bytearray=VAR(___str___);
180 for(i=0; i<maxlength; i++) {
181 str[i]=(((char *)&bytearray->___length___)+sizeof(int))[i+start];
189 #ifdef D___Double______doubleToRawLongBits____D
190 typedef union jvalue {
200 long long CALL11(___Double______doubleToRawLongBits____D, double dval, double dval) {
204 #if defined(__IEEE_BYTES_LITTLE_ENDIAN)
205 /* On little endian ARM processors when using FPA, word order of
206 doubles is still big endian. So take that into account here. When
207 using VFP, word order of doubles follows byte order. */
209 #define SWAP_DOUBLE(a) (((a) << 32) | (((a) >> 32) & 0x00000000ffffffff))
211 val.j = SWAP_DOUBLE(val.j);
218 #ifdef D___Double______longBitsToDouble____J
219 double CALL11(___Double______longBitsToDouble____J, long long lval, long long lval) {
223 #if defined(__IEEE_BYTES_LITTLE_ENDIAN)
225 #define SWAP_DOUBLE(a) (((a) << 32) | (((a) >> 32) & 0x00000000ffffffff))
227 val.j = SWAP_DOUBLE(val.j);
234 #ifdef D___String______convertdoubletochar____D__AR_C
235 int CALL12(___String______convertdoubletochar____D__AR_C, double ___val___, double ___val___, struct ArrayObject ___chararray___) {
236 int length=VAR(___chararray___)->___length___;
239 int num=snprintf(str, length, "%f",___val___);
242 for(i=0; i<length; i++) {
243 ((short *)(((char *)&VAR(___chararray___)->___length___)+sizeof(int)))[i]=(short)str[i];
248 #ifdef D___System______deepArrayCopy____L___Object____L___Object___
249 void deepArrayCopy(struct ___Object___ * dst, struct ___Object___ * src) {
250 int dsttype=((int *)dst)[0];
251 int srctype=((int *)src)[0];
253 src=src->___objlocation___;
255 if (dsttype<NUMCLASSES||srctype<NUMCLASSES||srctype!=dsttype)
257 struct ArrayObject *aodst=(struct ArrayObject *)dst;
258 struct ArrayObject *aosrc=(struct ArrayObject *)src;
259 int dstlength=aodst->___length___;
260 int srclength=aosrc->___length___;
261 if (dstlength!=srclength)
263 unsigned INTPTR *pointer=pointerarray[srctype];
265 int elementsize=classsize[srctype];
266 int size=srclength*elementsize;
268 memcpy(((char *)&aodst->___length___)+sizeof(int), ((char *)&aosrc->___length___)+sizeof(int), size);
272 for(i=0; i<srclength; i++) {
273 struct ___Object___ * ptr=((struct ___Object___**)(((char*) &aosrc->___length___)+sizeof(int)))[i];
274 int ptrtype=((int *)ptr)[0];
275 if (ptrtype>=NUMCLASSES) {
276 struct ___Object___ * dstptr=((struct ___Object___**)(((char*) &aodst->___length___)+sizeof(int)))[i];
277 deepArrayCopy(dstptr,ptr);
280 ((struct ___Object___ **)(((char*) &aodst->___length___)+sizeof(int)))[i]=ptr;
286 void CALL02(___System______deepArrayCopy____L___Object____L___Object___, struct ___Object___ * ___dst___, struct ___Object___ * ___src___) {
287 deepArrayCopy(VAR(___dst___), VAR(___src___));
291 #ifdef D___System______arraycopy____L___Object____I_L___Object____I_I
292 void arraycopy(struct ___Object___ *src, int srcPos, struct ___Object___ *dst, int destPos, int length) {
293 int dsttype=((int *)dst)[0];
294 int srctype=((int *)src)[0];
296 //not an array or type mismatch
297 if (dsttype<NUMCLASSES||srctype<NUMCLASSES)
299 if (srctype!=dsttype)
300 printf("Potential type mismatch in arraycopy\n");
302 struct ArrayObject *aodst=(struct ArrayObject *)dst;
303 struct ArrayObject *aosrc=(struct ArrayObject *)src;
304 int dstlength=aodst->___length___;
305 int srclength=aosrc->___length___;
309 if (srcPos+length>srclength)
311 if (destPos+length>dstlength)
314 unsigned INTPTR *pointer=pointerarray[srctype];
316 int elementsize=classsize[srctype];
317 int size=length*elementsize;
319 memcpy(((char *)&aodst->___length___)+sizeof(int)+destPos*elementsize, ((char *)&aosrc->___length___)+sizeof(int)+srcPos*elementsize, size);
323 for(i=0; i<length; i++) {
324 struct ___Object___ * ptr=((struct ___Object___**)(((char*) &aosrc->___length___)+sizeof(int)))[i+srcPos];
326 ((struct ___Object___ **)(((char*) &aodst->___length___)+sizeof(int)))[i+destPos]=ptr;
331 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___) {
332 arraycopy(VAR(___src___), ___srcPos___, VAR(___dst___), ___destPos___, ___length___);
336 #ifdef D___Runtime______availableProcessors____
337 int CALL01(___Runtime______availableProcessors____, struct ___Runtime___ * ___this___) {
338 printf("Unimplemented Runtime.availableProcessors\n");
343 #ifdef D___Runtime______freeMemory____
344 long long CALL01(___Runtime______freeMemory____, struct ___Runtime___ * ___this___) {
345 printf("Unimplemented Runtime.freeMemory\n");
346 return 1024*1024*1024;
350 #ifdef D___Runtime______totalMemory____
351 long long CALL01(___Runtime______totalMemory____, struct ___Runtime___ * ___this___) {
352 printf("Unimplemented Runtime.totalMemory\n");
353 return 1024*1024*1024;
357 #ifdef D___Runtime______maxMemory____
358 long long CALL01(___Runtime______maxMemory____, struct ___Runtime___ * ___this___) {
359 printf("Unimplemented Runtime.maxMemory\n");
360 return 1024*1024*1024;
363 #ifdef D___System______exit____I
364 void CALL11(___System______exit____I,int ___status___, int ___status___) {
367 printf("numTransCommit = %d\n", numTransCommit);
368 printf("numTransAbort = %d\n", numTransAbort);
369 printf("nSoftAbort = %d\n", nSoftAbort);
372 printf("nSoftAbortCommit = %d\n", nSoftAbortCommit);
373 printf("nSoftAbortAbort = %d\n", nSoftAbortAbort);
376 for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {
377 printf("typesCausingAbort[%2d] numaccess= %5d numabort= %3d\n", i, typesCausingAbort[i].numaccess, typesCausingAbort[i].numabort);
389 #ifdef D___System______logevent____I
390 void CALL11(___System______logevent____I,int ___event___, int ___event___) {
392 event[counter] = ___event___;
393 clkticks[counter] = rdtsc();
400 #ifdef ___System______logevent____
401 void CALL00(___System______logevent____) {
409 #ifdef ___System______flushToFile____I
410 void CALL11(___System______flushToFile____I, int ___threadid___, int ___threadid___) {
415 memset(filename, 0, 20);
416 sprintf(filename, "%s_%d", FILENAME, ___threadid___);
417 if ((fp = fopen(filename, "w+")) == NULL) {
422 for (i = 0; i < counter-1; i++) {
423 fprintf(fp, "%d %lld %lld\n", event[i], clkticks[i]-beginClock, clkticks[i+1]-beginClock);
425 fprintf(fp, "%d %lld\n", event[i], clkticks[i]-beginClock);
433 #ifdef D___System______initLog____
434 void CALL00(___System______initLog____) {
438 for(i=0; i<ARRAY_LENGTH; i++) {
448 #ifdef D___Vector______removeElement_____AR_L___Object____I_I
449 void CALL23(___Vector______removeElement_____AR_L___Object____I_I, int ___index___, int ___size___, struct ArrayObject * ___array___, int ___index___, int ___size___) {
450 char* offset=((char *)(&VAR(___array___)->___length___))+sizeof(unsigned int)+sizeof(void *)*___index___;
451 memmove(offset, offset+sizeof(void *),(___size___-___index___-1)*sizeof(void *));
455 #ifdef D___System______printI____I
456 void CALL11(___System______printI____I,int ___status___, int ___status___) {
457 printf("%d\n",___status___);
461 #ifdef D___System______currentTimeMillis____
462 long long CALL00(___System______currentTimeMillis____) {
463 struct timeval tv; long long retval;
464 gettimeofday(&tv, NULL);
465 retval = tv.tv_sec; /* seconds */
466 retval*=1000; /* milliseconds */
467 retval+= (tv.tv_usec/1000); /* adjust milliseconds & add them in */
472 #ifdef D___System______gc____
473 void CALL00(___System______gc____) {
474 #if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP)
475 while (pthread_mutex_trylock(&gclock)!=0) {
476 stopforgc((struct garbagelist *)___params___);
481 /* Grow the to heap if necessary */
483 INTPTR curr_heapsize=curr_heaptop-curr_heapbase;
484 INTPTR to_heapsize=to_heaptop-to_heapbase;
486 if (curr_heapsize>to_heapsize) {
488 to_heapbase=malloc(curr_heapsize);
489 if (to_heapbase==NULL) {
490 printf("Error Allocating enough memory\n");
493 to_heaptop=to_heapbase+curr_heapsize;
494 to_heapptr=to_heapbase;
499 collect((struct garbagelist *)___params___);
502 void * tmp=to_heapbase;
503 to_heapbase=curr_heapbase;
507 to_heaptop=curr_heaptop;
511 curr_heapptr=to_heapptr;
512 curr_heapgcpoint=((char *) curr_heapbase)+GCPOINT(curr_heaptop-curr_heapbase);
513 to_heapptr=to_heapbase;
514 bzero(tmp, curr_heaptop-tmp);
518 #if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP)
519 pthread_mutex_unlock(&gclock);
524 #ifdef D___System______microTimes____
525 long long CALL00(___System______microTimes____) {
528 gettimeofday(&tv, NULL);
529 retval = tv.tv_sec; /* seconds */
530 retval*=1000000; /* microsecs */
531 retval+= (tv.tv_usec); /* adjust microseconds & add them in */
536 #ifdef D___System______getticks____
537 long long CALL00(___System______getticks____) {
540 asm volatile ("rdtsc" : "=a" (a), "=d" (d));
541 return (((ticks)a) | (((ticks)d) << 32));
545 #ifdef D___System______printString____L___String___
546 void CALL01(___System______printString____L___String___,struct ___String___ * ___s___) {
547 struct ArrayObject * chararray=VAR(___s___)->___value___;
549 int offset=VAR(___s___)->___offset___;
550 for(i=0; i<VAR(___s___)->___count___; i++) {
551 short sc=((short *)(((char *)&chararray->___length___)+sizeof(int)))[i+offset];
561 #ifdef D___RecoveryStat______printRecoveryStat____
563 void CALL00(___RecoveryStat______printRecoveryStat____) {
567 void CALL00(___RecoveryStat______printRecoveryStat____) {
575 #ifdef D___System______clearPrefetchCache____
576 void CALL00(___System______clearPrefetchCache____) {
582 #ifdef D___System______rangePrefetch____L___Object_____AR_S
583 void CALL02(___System______rangePrefetch____L___Object_____AR_S, struct ___Object___ * ___o___, struct ArrayObject * ___offsets___) {
584 /* Manual Prefetches to be inserted */
585 //printf("DEBUG-> %s() ___Object___ * ___o___ = %x\n", __func__, VAR(___o___));
586 //printf("DEBUG-> %s() ArrayObject * = %x\n", __func__, VAR(___offsets___));
587 int numoffset=VAR(___offsets___)->___length___;
589 short offArry[numoffset+2];
592 for(i = 2; i<(numoffset+2); i++) {
593 offArry[i] = *((short *)(((char *)&VAR(___offsets___)->___length___) + sizeof(int) + (i-2) * sizeof(short)));
594 //printf("DEBUG-> offArry[%d] = %d\n", i, offArry[i]);
597 if(((unsigned int)(VAR(___o___)) & 1) != 0) { //odd
598 oid = (unsigned int) VAR(___o___); //outside transaction therefore just an oid
600 oid = (unsigned int) COMPOID(VAR(___o___)); //inside transaction therefore a pointer to oid
602 rangePrefetch(oid, (short)(numoffset+2), offArry);
605 void CALL02(___System______rangePrefetch____L___Object_____AR_S, struct ___Object___ * ___o___, struct ArrayObject * ___offsets___) {
611 #ifdef D___Task______execution____
612 extern void* virtualtable[];
613 // associated with Task.execution(). finds proper execute method and call it
614 void CALL01(___Task______execution____,struct ___Task___ * ___this___) {
616 oid = (unsigned int) VAR(___this___); // object id
617 int type = getObjType(oid); // object type
620 int p[] = {1,0, oid};
621 ((void (*)(void *))virtualtable[type*MAXCOUNT + EXECUTEMETHOD])(p);
623 // call the proper execute method
624 ((void (*)(void *))virtualtable[type*MAXCOUNT + EXECUTEMETHOD])(oid);
631 /* STM Barrier constructs */
632 #ifdef D___Barrier______setBarrier____I
633 void CALL11(___Barrier______setBarrier____I, int nthreads, int nthreads) {
634 // Barrier initialization
636 if((ret = pthread_barrier_init(&barrier, NULL, nthreads)) != 0) {
637 printf("%s() Could not create a barrier: numthreads = 0 in %s\n", __func__, __FILE__);
643 #ifdef D___Barrier______enterBarrier____
644 void CALL00(___Barrier______enterBarrier____) {
645 // Synchronization point
648 EVLOGEVENT(EV_ENTERBARRIER);
651 stopforgc((struct garbagelist *)___params___);
653 ret = pthread_barrier_wait(&barrier);
657 if(ret != 0 && ret != PTHREAD_BARRIER_SERIAL_THREAD) {
658 printf("%s() Could not wait on barrier: error %d in %s\n", __func__, errno, __FILE__);
662 EVLOGEVENT(EV_EXITBARRIER);
667 /* Object allocation function */
670 __attribute__((malloc)) void * allocate_newglobal(int type) {
671 struct ___Object___ * v=(struct ___Object___ *) transCreateObj(classsize[type]);
673 v->hashcode=(int)(INTPTR)v;
674 //printf("DEBUG %s(), type= %x\n", __func__, type);
681 /* Array allocation function */
683 __attribute__((malloc)) struct ArrayObject * allocate_newarrayglobal(int type, int length) {
684 struct ArrayObject * v=(struct ArrayObject *)transCreateObj(sizeof(struct ArrayObject)+length*classsize[type]);
686 printf("ERROR: negative array\n");
690 v->hashcode=(int)(INTPTR)v;
691 v->___length___=length;
701 // STM Versions of allocation functions
703 /* Object allocation function */
704 __attribute__((malloc)) void * allocate_newtrans(void * ptr, int type) {
706 struct ___Object___ * v=(struct ___Object___ *) transCreateObj(ptr, classsize[type], 0);
708 struct ___Object___ * v=(struct ___Object___ *) transCreateObj(ptr, classsize[type]);
712 v->hashcode=(int)(INTPTR)v;
713 v->___objlocation___=v;
717 /* Array allocation function */
718 __attribute__((malloc)) struct ArrayObject * allocate_newarraytrans(void * ptr, int type, int length) {
720 int basesize=length*classsize[type];
721 //round the base size up
722 basesize=(basesize+LOWMASK)&HIGHMASK;
723 int numlocks=basesize>>INDEXSHIFT;
724 int bookkeepsize=numlocks*2*sizeof(int);
725 struct ArrayObject * v=(struct ArrayObject *)transCreateObj(ptr, sizeof(struct ArrayObject)+basesize+bookkeepsize, bookkeepsize);
726 unsigned int *intptr=(unsigned int *)(((char *)v)-sizeof(objheader_t));
727 for(; numlocks>0; numlocks--) {
732 v->lowindex=MAXARRAYSIZE;
734 struct ArrayObject * v=(struct ArrayObject *)transCreateObj(ptr, sizeof(struct ArrayObject)+length*classsize[type]);
738 printf("ERROR: negative array\n");
741 v->___objlocation___=(struct ___Object___*)v;
743 v->hashcode=(int)(INTPTR)v;
744 v->___length___=length;
748 __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
749 objheader_t *tmp=mygcmalloc((struct garbagelist *) ptr, classsize[type]+sizeof(objheader_t));
750 struct ___Object___ * v=(struct ___Object___ *) &tmp[1];
752 initdsmlocks(&tmp->lock);
754 v->___objlocation___=v;
756 v->hashcode=(int)(INTPTR)v;
760 /* Array allocation function */
762 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
764 int basesize=length*classsize[type];
765 //round the base size up
766 basesize=(basesize+LOWMASK)&HIGHMASK;
767 int numlocks=basesize>>INDEXSHIFT;
768 int bookkeepsize=(numlocks)*2*sizeof(int);
769 int *tmpint=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+basesize+sizeof(objheader_t)+bookkeepsize);
770 for(; numlocks>0; numlocks--) {
774 objheader_t *tmp=(objheader_t *)tmpint;
775 struct ArrayObject * v=(struct ArrayObject *) &tmp[1];
777 v->lowindex=MAXARRAYSIZE;
779 objheader_t *tmp=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+length*classsize[type]+sizeof(objheader_t));
780 struct ArrayObject * v=(struct ArrayObject *) &tmp[1];
783 tmp->lock=RW_LOCK_BIAS;
785 initdsmlocks(&tmp->lock);
790 v->hashcode=(int)(INTPTR)v;
792 printf("ERROR: negative array %d\n", length);
795 v->___objlocation___=(struct ___Object___ *)v;
796 v->___length___=length;
802 #if defined(PRECISE_GC)
804 __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
805 return allocate_new_mlp(ptr, type, 0, 0);
807 __attribute__((malloc)) void * allocate_new_mlp(void * ptr, int type, int oid, int allocsite) {
809 __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
811 ObjectPtr v=(ObjectPtr) mygcmalloc((struct garbagelist *) ptr, classsize[type]);
813 v->hashcode=(int)(INTPTR)v;
822 // v->allocsite=allocsite;
827 /* Array allocation function */
829 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
830 return allocate_newarray_mlp(ptr, type, length, 0, 0);
832 __attribute__((malloc)) struct ArrayObject * allocate_newarray_mlp(void * ptr, int type, int length, int oid, int allocsite) {
834 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
836 struct ArrayObject * v=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+length*classsize[type]);
838 v->hashcode=(int)(INTPTR)v;
840 printf("ERROR: negative array\n");
843 v->___length___=length;
852 v->allocsite=allocsite;
858 __attribute__((malloc)) void * allocate_new(int type) {
859 ObjectPtr v=FREEMALLOC(classsize[type]);
861 v->hashcode=(int)(INTPTR)v;
868 /* Array allocation function */
870 __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int length) {
871 __attribute__((malloc)) struct ArrayObject * v=FREEMALLOC(sizeof(struct ArrayObject)+length*classsize[type]);
873 v->hashcode=(int)(INTPTR)v;
874 v->___length___=length;
883 /* Converts C character arrays into Java strings */
885 __attribute__((malloc)) StringPtr NewStringShort(void * ptr, const short *str,int length) {
887 __attribute__((malloc)) StringPtr NewStringShort(const short *str,int length) {
891 struct ArrayObject * chararray=allocate_newarray((struct garbagelist *)ptr, CHARARRAYTYPE, length);
892 INTPTR ptrarray[]={1, (INTPTR) ptr, (INTPTR) chararray};
893 StringPtr strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE);
894 chararray=(struct ArrayObject *) ptrarray[2];
896 struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length);
897 StringPtr strobj=allocate_new(STRINGTYPE);
899 strobj->___value___=chararray;
900 strobj->___count___=length;
901 strobj->___offset___=0;
903 for(i=0; i<length; i++) {
904 ((short *)(((char *)&chararray->___length___)+sizeof(int)))[i]=str[i];
909 /* Converts C character arrays into Java strings */
911 __attribute__((malloc)) StringPtr NewString(void * ptr, const char *str,int length) {
913 __attribute__((malloc)) StringPtr NewString(const char *str,int length) {
917 struct ArrayObject * chararray=allocate_newarray((struct garbagelist *)ptr, CHARARRAYTYPE, length);
918 INTPTR ptrarray[]={1, (INTPTR) ptr, (INTPTR) chararray};
919 StringPtr strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE);
920 chararray=(struct ArrayObject *) ptrarray[2];
922 struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length);
923 StringPtr strobj=allocate_new(STRINGTYPE);
925 strobj->___value___=chararray;
926 strobj->___count___=length;
927 strobj->___offset___=0;
929 for(i=0; i<length; i++) {
930 ((short *)(((char *)&chararray->___length___)+sizeof(int)))[i]=(short)str[i];
935 /* Generated code calls this if we fail a bounds check */
937 void failedboundschk(int num) {
939 printf("Array out of bounds\n");
946 longjmp(error_handler,2);
950 /* Abort task call */
953 longjmp(error_handler,4);
955 printf("Aborting\n");
961 #ifdef D___System______Assert____Z
962 void CALL11(___System______Assert____Z, int ___status___, int ___status___) {
964 printf("Assertion violation\n");
965 *((int *)(NULL)); //force stack trace error