Fix: need to keep the number of allocation site for the heap examiner. Somehow the...
[IRC.git] / Robust / src / Runtime / runtime.c
index 1df3a6bda624c1621d9b97a63ecf60c5f1b89214..585cb73c8d9df5905b3abe12a480965574d3d4f8 100644 (file)
@@ -90,7 +90,7 @@ typedef unsigned long long ticks;
 #include "dmalloc.h"
 #endif
 
-int instanceof(ObjectPtr *ptr, int type) {
+int instanceof(ObjectPtr ptr, int type) {
   int i=ptr->type;
   do {
     if (i==type)
@@ -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 ObjectPtr * v=(struct ObjectPtr *) 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 ObjectPtr * 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