helpful progress reporting
[IRC.git] / Robust / src / Runtime / runtime.c
index f9f7e2a58b60889fb42b34b02da5f9607a452895..ead07d04e46893c9e19aaeeb303429b31803c8c5 100644 (file)
@@ -2,13 +2,13 @@
 #include "structdefs.h"
 #include <signal.h>
 #include "mem.h"
-#include<fcntl.h>
-#include<errno.h>
-#include<signal.h>
-#include<stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
 #include "option.h"
 #ifdef DSTM
 #include "dstm.h"
+#include "prelookup.h"
 #endif
 
 extern int classsize[];
@@ -28,9 +28,6 @@ int instaccum=0;
 #include "dmalloc.h"
 #endif
 
-
-
-
 void exithandler(int sig, siginfo_t *info, void * uap) {
   exit(0);
 }
@@ -51,7 +48,7 @@ void injectinstructionfailure() {
   if (injectinstructionfailures) {
     if (numfailures==0)
       return;
-    instructioncount=failurecount;    
+    instructioncount=failurecount;
     instaccum+=failurecount;
     if ((((double)random())/RAND_MAX)<instfailurechance) {
       if (numfailures>0)
@@ -77,21 +74,44 @@ void injectinstructionfailure() {
 #endif
 }
 
+void CALL11(___System______exit____I,int ___status___, int ___status___) {
+  exit(___status___);
+}
+
+void CALL11(___System______printI____I,int ___status___, int ___status___) {
+  printf("%d\n",___status___);
+}
+
+long CALL00(___System______currentTimeMillis____) {
+  struct timeval tv; long long retval;
+  gettimeofday(&tv, NULL);
+  retval = tv.tv_sec; /* seconds */
+  retval*=1000; /* milliseconds */
+  retval+= (tv.tv_usec/1000); /* adjust milliseconds & add them in */
+  return retval;
+}
+
 void CALL01(___System______printString____L___String___,struct ___String___ * ___s___) {
-    struct ArrayObject * chararray=VAR(___s___)->___value___;
-    int i;
-    int offset=VAR(___s___)->___offset___;
-    for(i=0;i<VAR(___s___)->___count___;i++) {
-       short sc=((short *)(((char *)& chararray->___length___)+sizeof(int)))[i+offset];
-       putchar(sc);
-    }
+  struct ArrayObject * chararray=VAR(___s___)->___value___;
+  int i;
+  int offset=VAR(___s___)->___offset___;
+  for(i=0; i<VAR(___s___)->___count___; i++) {
+    short sc=((short *)(((char *)&chararray->___length___)+sizeof(int)))[i+offset];
+    putchar(sc);
+  }
 }
 
+#ifdef DSTM
+void CALL00(___System______clearPrefetchCache____) {
+  prehashClear();
+}
+#endif
+
 /* Object allocation function */
 
 #ifdef DSTM
 void * allocate_newglobal(transrecord_t *trans, int type) {
-  struct ___Object___ * v=(struct ___Object___ *) dstmalloc(trans, classsize[type]);
+  struct ___Object___ * v=(struct ___Object___ *) transCreateObj(trans, classsize[type]);
   v->type=type;
 #ifdef THREADS
   v->tid=0;
@@ -104,12 +124,12 @@ void * allocate_newglobal(transrecord_t *trans, int type) {
 /* Array allocation function */
 
 struct ArrayObject * allocate_newarrayglobal(transrecord_t *trans, int type, int length) {
-  struct ArrayObject * v=(struct ArrayObject *)dstmalloc(trans, classsize[type]);
-  v->type=type;
+  struct ArrayObject * v=(struct ArrayObject *)transCreateObj(trans, sizeof(struct ArrayObject)+length*classsize[type]);
   if (length<0) {
     printf("ERROR: negative array\n");
     return NULL;
   }
+  v->type=type;
   v->___length___=length;
 #ifdef THREADS
   v->tid=0;
@@ -129,6 +149,9 @@ void * allocate_new(void * ptr, int type) {
   v->tid=0;
   v->lockentry=0;
   v->lockcount=0;
+#endif
+#ifdef OPTIONAL
+  v->fses=0;
 #endif
   return v;
 }
@@ -147,14 +170,20 @@ struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
   v->tid=0;
   v->lockentry=0;
   v->lockcount=0;
+#endif
+#ifdef OPTIONAL
+  v->fses=0;
 #endif
   return v;
 }
 
 #else
 void * allocate_new(int type) {
-  void * v=FREEMALLOC(classsize[type]);
-  *((int *)v)=type;
+  struct ___Object___ * v=FREEMALLOC(classsize[type]);
+  v->type=type;
+#ifdef OPTIONAL
+  v->fses=0;
+#endif
   return v;
 }
 
@@ -164,6 +193,9 @@ struct ArrayObject * allocate_newarray(int type, int length) {
   struct ArrayObject * v=FREEMALLOC(sizeof(struct ArrayObject)+length*classsize[type]);
   v->type=type;
   v->___length___=length;
+#ifdef OPTIONAL
+  v->fses=0;
+#endif
   return v;
 }
 #endif
@@ -189,8 +221,9 @@ struct ___String___ * NewString(const char *str,int length) {
   strobj->___count___=length;
   strobj->___offset___=0;
 
-  for(i=0;i<length;i++) {
-    ((short *)(((char *)& chararray->___length___)+sizeof(int)))[i]=(short)str[i];  }
+  for(i=0; i<length; i++) {
+    ((short *)(((char *)&chararray->___length___)+sizeof(int)))[i]=(short)str[i];
+  }
   return strobj;
 }