From 911888f64e116a8d31b8cc0cef7ec849d186387a Mon Sep 17 00:00:00 2001 From: bdemsky Date: Mon, 11 Apr 2011 09:14:58 +0000 Subject: [PATCH] improve specjbb marks...rework locks a little... --- Robust/src/IR/Flat/BuildCode.java | 11 +++++----- Robust/src/Runtime/garbage.c | 12 ++++++++++- Robust/src/Runtime/object.c | 36 ++++++++++++------------------- Robust/src/Runtime/runtime.c | 4 ---- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 6b625a51..3c73647d 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -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;"); diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index 01e39484..3a121cc3 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -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;iindex;i++) { + struct ___Object___ *orig=lvector->locks[i].object; + ENQUEUE(orig, lvector->locks[i].object); + } + } +#endif listptr=listptr->next; } } diff --git a/Robust/src/Runtime/object.c b/Robust/src/Runtime/object.c index 9192bb40..6cd8da70 100644 --- a/Robust/src/Runtime/object.c +++ b/Robust/src/Runtime/object.c @@ -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; } } diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index 245cda93..b3411862 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -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 -- 2.34.1