public int cachedCode; //first field has to be a primitive
public boolean cachedHash;
- private Object nextlockobject;
- private Object prevlockobject;
-
- // temporary extra unused int filed to align objects for Java
- int wkhqwemnbmwnb;
-
public native int hashCode();
/* DON'T USE THIS METHOD UNLESS NECESSARY */
/* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
public native int getType();
- public native int MonitorEnter();
- public native int MonitorExit();
+ public native void MonitorEnter();
+ public native void MonitorExit();
public String toString() {
return "Object"+hashCode();
public int cachedCode; //first field has to be a primitive
public boolean cachedHash;
- private Object nextlockobject;
- private Object prevlockobject;
-
// temporary extra unused int filed to align objects for Java
//int wkhqwemnbmwnb;
/* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
public native int getType();
- public native int MonitorEnter();
- public native int MonitorExit();
+ public native void MonitorEnter();
+ public native void MonitorExit();
public String toString() {
return "Object"+hashCode();
}
#if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP)
/* Go to next thread */
+#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
#ifndef MAC
//skip over us
if (listptr==&litem) {
// update forward list & memory queue for the current SESE
updateForwardList(&((SESEcommon*)listptr->seseCommon)->forwardList,FALSE);
updateMemoryQueue((SESEcommon*)(listptr->seseCommon));
-#endif
-#ifdef THREADS
- void *orig=pthread_getspecific(threadlocks);
- ENQUEUE(orig, orig);
- pthread_setspecific(threadlocks, orig);
#endif
listptr=listptr->next;
}
{
struct listitem *litem=pthread_getspecific(litemkey);
if (listptr==litem) {
-#ifdef THREADS
- void *orig=pthread_getspecific(threadlocks);
- ENQUEUE(orig, orig);
- pthread_setspecific(threadlocks, orig);
-#endif
listptr=listptr->next;
}
}
#ifdef STM
#include "stmlookup.h"
#endif
+
struct garbagelist {
int size;
struct garbagelist *next;
struct listitem * next;
struct garbagelist * stackptr;
#ifdef THREADS
- struct ___Object___ * locklist;
+ struct lockvector * lvector;
#endif
#ifdef STM
unsigned int tc_size;
#include "mlp_lock.h"
#endif
+#ifndef MAC
+extern __thread struct lockvector lvector;
+#endif
+
#ifdef D___Object______nativehashCode____
int CALL01(___Object______nativehashCode____, struct ___Object___ * ___this___) {
return (int)((INTPTR) VAR(___this___));
#ifdef THREADS
#ifdef D___Object______MonitorEnter____
-int CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) {
-#ifndef NOLOCK
+void CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) {
+#ifdef MAC
+ struct lockvector *lptr=(struct lockvector *)pthread_getspecific(threadlocks);
+#else
+ struct lockvector *lptr=&lvector;
+#endif
+ struct lockpair *lpair=lptr->locks[lptr->index];
pthread_t self=pthread_self();
+ lpair->object=VAR(___this___);
+ lptr->index++;
+
+
if (self==VAR(___this___)->tid) {
- atomic_inc(&VAR(___this___)->lockcount);
+ lpair->islastlock=0;
} else {
+ lpair->islastlock=1;
while(1) {
if (VAR(___this___)->lockcount==0) {
if (CAS32(&VAR(___this___)->lockcount, 0, 1)==0) {
- VAR(___this___)->___prevlockobject___=NULL;
- VAR(___this___)->___nextlockobject___=(struct ___Object___ *)pthread_getspecific(threadlocks);
- if (VAR(___this___)->___nextlockobject___!=NULL)
- VAR(___this___)->___nextlockobject___->___prevlockobject___=VAR(___this___);
- pthread_setspecific(threadlocks, VAR(___this___));
VAR(___this___)->tid=self;
- pthread_mutex_unlock(&objlock);
- BARRIER();
return;
}
}
}
}
}
-#endif
}
#endif
#ifdef D___Object______wait____
void CALL01(___Object______wait____, struct ___Object___ * ___this___) {
pthread_t self=pthread_self();
- int lockcount=VAR(___this___)->lockcount;
- //release lock
- if (VAR(___this___)->___prevlockobject___==NULL) {
- pthread_setspecific(threadlocks, VAR(___this___)->___nextlockobject___);
- } else
- VAR(___this___)->___prevlockobject___->___nextlockobject___=VAR(___this___)->___nextlockobject___;
- if (VAR(___this___)->___nextlockobject___!=NULL)
- VAR(___this___)->___nextlockobject___->___prevlockobject___=VAR(___this___)->___prevlockobject___;
- VAR(___this___)->___nextlockobject___=NULL;
- VAR(___this___)->___prevlockobject___=NULL;
- //VAR(___this___)->lockentry=NULL;
+
VAR(___this___)->tid=0;
- //release lock
BARRIER();
VAR(___this___)->lockcount=0;
while(1) {
if (VAR(___this___)->lockcount==0) {
if (CAS32(&VAR(___this___)->lockcount, 0, lockcount)==0) {
- VAR(___this___)->___prevlockobject___=NULL;
- VAR(___this___)->___nextlockobject___=(struct ___Object___ *)pthread_getspecific(threadlocks);
- if (VAR(___this___)->___nextlockobject___!=NULL)
- VAR(___this___)->___nextlockobject___->___prevlockobject___=VAR(___this___);
- pthread_setspecific(threadlocks, VAR(___this___));
VAR(___this___)->tid=self;
- pthread_mutex_unlock(&objlock);
BARRIER();
return;
}
#endif
#ifdef D___Object______MonitorExit____
-int CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___) {
-#ifndef NOLOCK
- pthread_t self=pthread_self();
- if (self==VAR(___this___)->tid) {
- //release one lock...
- BARRIER();
- if (VAR(___this___)->lockcount==1) {
- if (VAR(___this___)->___prevlockobject___==NULL) {
- pthread_setspecific(threadlocks, VAR(___this___)->___nextlockobject___);
- } else
- VAR(___this___)->___prevlockobject___->___nextlockobject___=VAR(___this___)->___nextlockobject___;
- if (VAR(___this___)->___nextlockobject___!=NULL)
- VAR(___this___)->___nextlockobject___->___prevlockobject___=VAR(___this___)->___prevlockobject___;
- VAR(___this___)->___nextlockobject___=NULL;
- VAR(___this___)->___prevlockobject___=NULL;
- //VAR(___this___)->lockentry=NULL;
- VAR(___this___)->tid=0;
- }
- atomic_dec(&VAR(___this___)->lockcount);
- } else {
-#ifdef MULTICORE
- BAMBOO_EXIT(0xf201);
+void CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___) {
+#ifdef MAC
+ struct lockvector *lptr=(struct lockvector *)pthread_getspecific(threadlocks);
#else
- printf("ERROR...UNLOCKING LOCK WE DON'T HAVE\n");
- exit(-1);
+ 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();
+ lpair->object->lockcount=0;
}
-#endif
}
#endif
#endif
#include "runtime.h"
#include "structdefs.h"
#include "methodheaders.h"
+
+#define MAXLOCKS 256
+
+struct lockpair {
+ struct ___Object___ *object;
+ int islastlock;
+};
+
+struct lockvector {
+ int index;
+ struct lockpair locks[MAXLOCKS];
+};
+
+#ifndef MAC
+extern __thread struct lockvector lvector;
+#endif
+
#ifdef D___Object______nativehashCode____
int CALL01(___Object______nativehashCode____, struct ___Object___ * ___this___);
#endif
#ifdef D___Object______hashCode____
-int CALL01(___Object______hashCode____, struct ___Object___ * ___this___);
+int CALL01(___Object______hashCode____, struct ___Object___ * ___this___);
+#endif
+#ifdef D___Object______MonitorEnter____
+void CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___);
+#endif
+#ifdef D___Object______MonitorExit____
+void CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___);
#endif
-#ifdef THREADS
-int CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___);
-int CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___);
#ifdef D___Object______notify____
void CALL01(___Object______notify____, struct ___Object___ * ___this___);
#endif
void CALL01(___Object______wait____, struct ___Object___ * ___this___);
#endif
#endif
-#endif
void *value;
#ifdef THREADS
- struct ___Object___ *ll=pthread_getspecific(threadlocks);
- while(ll!=NULL) {
- struct ___Object___ *llnext=ll->___nextlockobject___;
- ll->___nextlockobject___=NULL;
- ll->___prevlockobject___=NULL;
- ll->lockcount=0;
- ll->tid=0; //unlock it
- ll=llnext;
+#ifdef MAC
+ struct lockvector *lptr=(struct lockvector *) pthread_getspecific(threadlocks);
+#else
+ struct lockvector *lptr=&lvector;
+#endif
+ for(lptr->index--;lptr->index>=0;lptr->index--) {
+ if (lptr->locks[lptr->index].islastlock) {
+ struct ___Object___ *ll=lptr->locks[lptr->index].object;
+ ll->tid=0;
+ BARRIER();
+ ll->lockcount=0;
+ }
}
+
pthread_mutex_lock(&objlock); //wake everyone up
pthread_cond_broadcast(&objcond);
pthread_mutex_unlock(&objlock);
#endif
pthread_mutex_lock(&gclistlock);
-#ifdef THREADS
- pthread_setspecific(threadlocks, litem.locklist);
-#endif
+
#ifndef MAC
if (litem.prev==NULL) {
list=litem.next;
#ifdef MAC
struct listitem litem;
pthread_setspecific(litemkey, &litem);
+ struct lockvector lvector;
+ pthread_setspecific(threadlocks, &lvector);
#endif
+ litem.lvector=&lvector;
litem.prev=NULL;
pthread_mutex_lock(&gclistlock);
litem.next=list;
list->prev=&litem;
list=&litem;
pthread_mutex_unlock(&gclistlock);
-
#ifdef THREADS
___Thread______staticStart____L___Thread___((struct ___Thread______staticStart____L___Thread____params *)p);
#else
pthread_mutex_unlock(&joinlock);
pthread_mutex_lock(&gclistlock);
-#ifdef THREADS
- pthread_setspecific(threadlocks, litem.locklist);
-#endif
if (litem.prev==NULL) {
list=litem.next;
} else {
void startDSMthread(int oid, int objType);
extern void * virtualtable[];
#endif
-
-struct locklist {
- struct locklist * next;
- struct locklist * prev;
- struct ___Object___ * object;
-};
#endif