improve specjbb marks...rework locks a little...
authorbdemsky <bdemsky>
Mon, 11 Apr 2011 09:14:58 +0000 (09:14 +0000)
committerbdemsky <bdemsky>
Mon, 11 Apr 2011 09:14:58 +0000 (09:14 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/garbage.c
Robust/src/Runtime/object.c
Robust/src/Runtime/runtime.c

index 6b625a519ceae206ba7533cb15f8cafb94480522..3c73647dd44658dd08ecbaa1ef3f8b477986db55 100644 (file)
@@ -613,8 +613,8 @@ public class BuildCode {
     }
     if (state.THREAD) {
       outclassdefs.println("  pthread_t tid;");
-      outclassdefs.println("  void * lockentry;");
-      outclassdefs.println("  int lockcount;");
+      outclassdefs.println("  volatile int lockcount;");
+      outclassdefs.println("  volatile int notifycount;");
     }
     if(state.MGC) {
       outclassdefs.println("  int mutex;");
@@ -632,7 +632,8 @@ public class BuildCode {
        outclassdefs.println("  int version;");
        outclassdefs.println("  int * lock;");  // lock entry for this obj
        outclassdefs.println("  int mutex;");
-       outclassdefs.println("  int lockcount;");
+       outclassdefs.println("  volatile int lockcount;");
+       outclassdefs.println("  volatile int notifycount;");
        if(state.MULTICOREGC) {
          outclassdefs.println("  int marked;");
        }
@@ -1550,8 +1551,8 @@ public class BuildCode {
     }
     if (state.THREAD) {
       classdefout.println("  pthread_t tid;");
-      classdefout.println("  void * lockentry;");
-      classdefout.println("  int lockcount;");
+      classdefout.println("  volatile int lockcount;");
+      classdefout.println("  volatile int notifycount;");
     }
     if (state.MGC) {
       classdefout.println("  int mutex;");
index 01e394846701d6b139164c18b2af997d4c14392f..3a121cc3dfe6d3b137405285a03207a850e9844c 100644 (file)
@@ -405,6 +405,7 @@ void collect(struct garbagelist * stackptr) {
     // update forward list & memory queue for the current SESE
     updateForwardList(&((SESEcommon*)listptr->seseCommon)->forwardList,FALSE);
     updateMemoryQueue((SESEcommon*)(listptr->seseCommon));
+#endif
 #ifdef THREADS
   {
     struct lockvector * lvector=listptr->lvector;
@@ -414,7 +415,6 @@ void collect(struct garbagelist * stackptr) {
       ENQUEUE(orig, lvector->locks[i].object);
     }
   }
-#endif
 #endif
     listptr=listptr->next;
   }
@@ -422,6 +422,16 @@ void collect(struct garbagelist * stackptr) {
  {
   struct listitem *litem=pthread_getspecific(litemkey);
   if (listptr==litem) {
+#ifdef THREADS
+  {
+    struct lockvector * lvector=listptr->lvector;
+    int i;
+    for(i=0;i<lvector->index;i++) {
+      struct ___Object___ *orig=lvector->locks[i].object;
+      ENQUEUE(orig, lvector->locks[i].object);
+    }
+  }
+#endif
     listptr=listptr->next;
   }
  }
index 9192bb405bf8f3e87ccf672a57bcc8f69098c323..6cd8da7094e4bf912f08f8d89b2db32333a3a72e 100644 (file)
@@ -47,12 +47,10 @@ void CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) {
 #else
   struct lockvector *lptr=&lvector;
 #endif
-  struct lockpair *lpair=&lptr->locks[lptr->index];
+  struct lockpair *lpair=&lptr->locks[lptr->index++];
   pthread_t self=pthread_self();
   lpair->object=VAR(___this___);
-  lptr->index++;
 
-  
   if (self==VAR(___this___)->tid) {
     lpair->islastlock=0;
   } else {
@@ -66,10 +64,8 @@ void CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) {
       }
       {
 #ifdef PRECISE_GC
-       stopforgc((struct garbagelist *)___params___);
-#endif
-#ifdef PRECISE_GC
-       restartaftergc();
+       if (unlikely(needtocollect))
+         checkcollect((struct garbagelist *)___params___);
 #endif
       }
     }
@@ -80,30 +76,31 @@ void CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) {
 
 #ifdef D___Object______notify____
 void CALL01(___Object______notify____, struct ___Object___ * ___this___) {
+  VAR(___this___)->notifycount++;
 }
 #endif
 
 #ifdef D___Object______notifyAll____
 void CALL01(___Object______notifyAll____, struct ___Object___ * ___this___) {
+  VAR(___this___)->notifycount++;
 }
 #endif
 
 #ifdef D___Object______wait____
 void CALL01(___Object______wait____, struct ___Object___ * ___this___) {
   pthread_t self=pthread_self();
-
+  int notifycount=VAR(___this___)->notifycount;
+  BARRIER();
   VAR(___this___)->tid=0;
   BARRIER();
   VAR(___this___)->lockcount=0;
   
-  //allow gc
-#ifdef PRECISE_GC
-  stopforgc((struct garbagelist *)___params___);
-#endif
-  sched_yield();
+  while(notifycount==VAR(___this___)->notifycount) {
 #ifdef PRECISE_GC
-  restartaftergc();
+    if (unlikely(needtocollect))
+      checkcollect((struct garbagelist *)___params___);
 #endif
+  }
 
   while(1) {
     if (VAR(___this___)->lockcount==0) {
@@ -113,14 +110,10 @@ void CALL01(___Object______wait____, struct ___Object___ * ___this___) {
        return;
       }
     }
-    {
-#ifdef PRECISE_GC
-      stopforgc((struct garbagelist *)___params___);
-#endif
 #ifdef PRECISE_GC
-      restartaftergc();
+    if (unlikely(needtocollect))
+      checkcollect((struct garbagelist *)___params___);
 #endif
-    }
   }
 }
 #endif
@@ -133,11 +126,10 @@ void CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___) {
   struct lockvector *lptr=&lvector;
 #endif
   struct lockpair *lpair=&lptr->locks[--lptr->index];
-  pthread_t self=pthread_self();
   
   if (lpair->islastlock) {
     lpair->object->tid=0;
-    BARRIER();
+    MBARRIER();
     lpair->object->lockcount=0;
   }
 }
index 245cda9354f4a2f7efecf4defed831f85edd92d9..b3411862b06b1a1e48aaeb1379be0622c651cee3 100644 (file)
@@ -674,7 +674,6 @@ __attribute__((malloc)) void * allocate_newglobal(int type) {
   //printf("DEBUG %s(), type= %x\n", __func__, type);
 #ifdef THREADS
   v->tid=0;
-  v->lockentry=0;
   v->lockcount=0;
 #endif
   return v;
@@ -692,7 +691,6 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarrayglobal(int type, i
   v->___length___=length;
 #ifdef THREADS
   v->tid=0;
-  v->lockentry=0;
   v->lockcount=0;
 #endif
   return v;
@@ -811,7 +809,6 @@ __attribute__((malloc)) void * allocate_new(void * ptr, int type) {
   v->type=type;
 #ifdef THREADS
   v->tid=0;
-  v->lockentry=0;
   v->lockcount=0;
 #endif
 #ifdef OPTIONAL
@@ -842,7 +839,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