From: bdemsky Date: Mon, 11 Apr 2011 21:17:37 +0000 (+0000) Subject: remove lockcount X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=842143364178f59293f4d57914657c3b0b442ead;p=IRC.git remove lockcount --- diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 3c73647d..965fbed2 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -613,7 +613,6 @@ public class BuildCode { } if (state.THREAD) { outclassdefs.println(" pthread_t tid;"); - outclassdefs.println(" volatile int lockcount;"); outclassdefs.println(" volatile int notifycount;"); } if(state.MGC) { @@ -1551,7 +1550,6 @@ public class BuildCode { } if (state.THREAD) { classdefout.println(" pthread_t tid;"); - classdefout.println(" volatile int lockcount;"); classdefout.println(" volatile int notifycount;"); } if (state.MGC) { diff --git a/Robust/src/Runtime/object.c b/Robust/src/Runtime/object.c index 091b1218..61159ecd 100644 --- a/Robust/src/Runtime/object.c +++ b/Robust/src/Runtime/object.c @@ -56,9 +56,8 @@ void CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) { } else { lpair->islastlock=1; while(1) { - if (VAR(___this___)->lockcount==0) { - if (LOCKXCHG32(&VAR(___this___)->lockcount, 1)==0) { - VAR(___this___)->tid=self; + if (VAR(___this___)->tid==0) { + if (CAS32(&VAR(___this___)->tid, 0, self)==0) { return; } } @@ -93,7 +92,6 @@ void CALL01(___Object______wait____, struct ___Object___ * ___this___) { BARRIER(); VAR(___this___)->tid=0; BARRIER(); - VAR(___this___)->lockcount=0; while(notifycount==VAR(___this___)->notifycount) { #ifdef PRECISE_GC @@ -103,9 +101,8 @@ void CALL01(___Object______wait____, struct ___Object___ * ___this___) { } while(1) { - if (VAR(___this___)->lockcount==0) { - if (LOCKXCHG32(&VAR(___this___)->lockcount, 1)==0) { - VAR(___this___)->tid=self; + if (VAR(___this___)->tid==0) { + if (CAS32(&VAR(___this___)->tid, 0, self)==0) { BARRIER(); return; } @@ -128,9 +125,8 @@ void CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___) { struct lockpair *lpair=&lptr->locks[--lptr->index]; if (lpair->islastlock) { - lpair->object->tid=0; MBARRIER(); - lpair->object->lockcount=0; + lpair->object->tid=0; } } #endif diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index b3411862..403fa797 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->lockcount=0; #endif return v; } @@ -691,7 +690,6 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarrayglobal(int type, i v->___length___=length; #ifdef THREADS v->tid=0; - v->lockcount=0; #endif return v; } @@ -809,7 +807,6 @@ __attribute__((malloc)) void * allocate_new(void * ptr, int type) { v->type=type; #ifdef THREADS v->tid=0; - v->lockcount=0; #endif #ifdef OPTIONAL v->fses=0; @@ -839,7 +836,6 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t v->___length___=length; #ifdef THREADS v->tid=0; - v->lockcount=0; #endif #ifdef OPTIONAL v->fses=0; diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index 30a97db6..c048e85e 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -76,8 +76,6 @@ void threadexit() { if (lptr->locks[lptr->index].islastlock) { struct ___Object___ *ll=lptr->locks[lptr->index].object; ll->tid=0; - BARRIER(); - ll->lockcount=0; } }