From 244bde43f59db937f2eed4a5f33effe6175ed167 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Sun, 5 Jun 2011 08:07:45 +0000 Subject: [PATCH] more changes towards jni --- Robust/src/Runtime/garbage.c | 7 ++++--- Robust/src/Runtime/runtime.c | 22 +++++++++++----------- Robust/src/Runtime/runtime.h | 27 ++++++++++----------------- Robust/src/Runtime/thread.c | 26 +++++++++++++------------- Robust/src/Runtime/thread.h | 3 ++- 5 files changed, 40 insertions(+), 45 deletions(-) diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index 3fd65c39..75cb0ff2 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -29,6 +29,7 @@ #ifdef DELAYCOMP #include "delaycomp.h" #endif +#include "objtypes.h" #ifndef INITIALHEAPSIZE_MB @@ -329,7 +330,7 @@ void searchjnitable(struct jnireferences *jniptr) { int i; //update table for(i=0; iindex; i++) { - ENQUEUE((struct ___Object___ *)jniptr->array[i].ref, *((struct ___Object___**)&jniptr->array[i].ref)); + ENQUEUE((ObjectPtr)jniptr->array[i].ref, *((ObjectPtr *)&jniptr->array[i].ref)); } //go to next table jniptr=jniptr->next; @@ -354,7 +355,7 @@ void searchthreadroots(struct garbagelist * stackptr) { struct lockvector * lvector=listptr->lvector; int i; for(i=0; iindex; i++) { - struct ___Object___ *orig=lvector->locks[i].object; + ObjectPtr orig=lvector->locks[i].object; ENQUEUE(orig, lvector->locks[i].object); } #endif @@ -501,7 +502,7 @@ void checkcollect2(void * ptr) { int ptrarray[]={1, (int)ptr, (int) revertlist}; stopforgc((struct garbagelist *)ptrarray); restartaftergc(); - revertlist=(struct ___Object___*)ptrarray[2]; + revertlist=(ObjectPtr)ptrarray[2]; } #endif diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index 1df3a6bd..11cac3e3 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -90,7 +90,7 @@ typedef unsigned long long ticks; #include "dmalloc.h" #endif -int instanceof(ObjectPtr *ptr, int type) { +int instanceof(ObjectPtr ptr, int type) { int i=ptr->type; do { if (i==type) @@ -808,7 +808,7 @@ __attribute__((malloc)) void * allocate_new_mlp(void * ptr, int type, int oid, i #else __attribute__((malloc)) void * allocate_new(void * ptr, int type) { #endif - struct ObjectPtr * v=(struct ObjectPtr *) mygcmalloc((struct garbagelist *) ptr, classsize[type]); + ObjectPtr v=(ObjectPtr) mygcmalloc((struct garbagelist *) ptr, classsize[type]); v->type=type; v->hashcode=(int)(INTPTR)v; #ifdef THREADS @@ -856,7 +856,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t #else __attribute__((malloc)) void * allocate_new(int type) { - struct ObjectPtr * v=FREEMALLOC(classsize[type]); + ObjectPtr v=FREEMALLOC(classsize[type]); v->type=type; v->hashcode=(int)(INTPTR)v; #ifdef OPTIONAL @@ -882,19 +882,19 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int len /* Converts C character arrays into Java strings */ #ifdef PRECISE_GC -__attribute__((malloc)) struct ___String___ * NewStringShort(void * ptr, const short *str,int length) { +__attribute__((malloc)) StringPtr NewStringShort(void * ptr, const short *str,int length) { #else -__attribute__((malloc)) struct ___String___ * NewStringShort(const short *str,int length) { +__attribute__((malloc)) StringPtr NewStringShort(const short *str,int length) { #endif int i; #ifdef PRECISE_GC struct ArrayObject * chararray=allocate_newarray((struct garbagelist *)ptr, CHARARRAYTYPE, length); INTPTR ptrarray[]={1, (INTPTR) ptr, (INTPTR) chararray}; - struct ___String___ * strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE); + StringPtr strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE); chararray=(struct ArrayObject *) ptrarray[2]; #else struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length); - struct ___String___ * strobj=allocate_new(STRINGTYPE); + StringPtr strobj=allocate_new(STRINGTYPE); #endif strobj->___value___=chararray; strobj->___count___=length; @@ -908,19 +908,19 @@ __attribute__((malloc)) struct ___String___ * NewStringShort(const short *str,in /* Converts C character arrays into Java strings */ #ifdef PRECISE_GC -__attribute__((malloc)) struct ___String___ * NewString(void * ptr, const char *str,int length) { +__attribute__((malloc)) StringPtr NewString(void * ptr, const char *str,int length) { #else -__attribute__((malloc)) struct ___String___ * NewString(const char *str,int length) { +__attribute__((malloc)) StringPtr NewString(const char *str,int length) { #endif int i; #ifdef PRECISE_GC struct ArrayObject * chararray=allocate_newarray((struct garbagelist *)ptr, CHARARRAYTYPE, length); INTPTR ptrarray[]={1, (INTPTR) ptr, (INTPTR) chararray}; - struct ___String___ * strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE); + StringPtr strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE); chararray=(struct ArrayObject *) ptrarray[2]; #else struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length); - struct ___String___ * strobj=allocate_new(STRINGTYPE); + StringPtr strobj=allocate_new(STRINGTYPE); #endif strobj->___value___=chararray; strobj->___count___=length; diff --git a/Robust/src/Runtime/runtime.h b/Robust/src/Runtime/runtime.h index 9c00112e..8c2a010d 100644 --- a/Robust/src/Runtime/runtime.h +++ b/Robust/src/Runtime/runtime.h @@ -1,6 +1,7 @@ #ifndef RUNTIME #define RUNTIME #include +#include "objtypes.h" #ifndef MULTICORE #include extern jmp_buf error_handler; @@ -79,20 +80,20 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t __attribute__((malloc)) void * allocate_new(void *, int type); __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length); #endif -__attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length); -__attribute__((malloc)) struct ___String___ * NewStringShort(void *, const short *str,int length); +__attribute__((malloc)) StringPtr NewString(void *, const char *str,int length); +__attribute__((malloc)) StringPtr NewStringShort(void *, const short *str,int length); __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index); #elif defined MULTICORE_GC __attribute__((malloc)) void * allocate_new(void *, int type); __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length); -__attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length); -__attribute__((malloc)) struct ___String___ * NewStringShort(void *, const short *str,int length); +__attribute__((malloc)) StringPtr NewString(void *, const char *str,int length); +__attribute__((malloc)) StringPtr NewStringShort(void *, const short *str,int length); __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index); #else __attribute__((malloc)) void * allocate_new(int type); __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int length); -__attribute__((malloc)) struct ___String___ * NewString(const char *str,int length); -__attribute__((malloc)) struct ___String___ * NewStringShort(const short *str,int length); +__attribute__((malloc)) StringPtr NewString(const char *str,int length); +__attribute__((malloc)) StringPtr NewStringShort(const short *str,int length); __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(int index); #endif @@ -161,7 +162,7 @@ inline void setupsmemmode(void); #define MAXLOCKS 256 struct lockpair { - struct ___Object___ *object; + ObjectPtr object; int islastlock; }; @@ -208,7 +209,7 @@ struct transObjInfo { #endif #ifdef FASTCHECK -extern struct ___Object___ * ___fcrevert___; +extern ObjectPtr ___fcrevert___; #endif #ifdef MULTICORE @@ -278,7 +279,7 @@ void toiNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * fail void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams); void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams); void builditerators(struct taskdescriptor * task, int index, struct parameterwrapper * parameter); -int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags); +int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, ObjectPtr ptr, int * enterflags, int numenterflags); #endif @@ -295,12 +296,4 @@ static __inline__ unsigned long long rdtsc(void) { return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); } #endif - -#ifdef JNI -typedef struct ___java___________lang___________Object___ * ObjectPtr -#else -typedef struct ___Object___ * ObjectPtr -#endif - - #endif diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index 3a7ae8c8..99439b6d 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -77,7 +77,7 @@ void threadexit() { #endif for(lptr->index--; lptr->index>=0; lptr->index--) { if (lptr->locks[lptr->index].islastlock) { - struct ___Object___ *ll=lptr->locks[lptr->index].object; + ObjectPtr ll=lptr->locks[lptr->index].object; ll->tid=0; } } @@ -122,9 +122,9 @@ transstart: { transStart(); ptr = transRead(oidvalue); - struct ___Thread___ *p = (struct ___Thread___ *) ptr; + ThreadPtr p = (ThreadPtr) ptr; p->___threadDone___ = 1; - *((unsigned int *)&((struct ___Object___ *) p)->___localcopy___) |=DIRTY; + *((unsigned int *)&((ObjectPtr) p)->___localcopy___) |=DIRTY; if(transCommit() != 0) { goto transstart; } @@ -304,7 +304,7 @@ void initializethreads() { int threadcounter=0; #ifdef D___Thread______nativeCreate____ -void initthread(struct ___Thread___ * ___this___) { +void initthread(ThreadPtr ___this___) { #ifdef AFFINITY set_affinity(); #endif @@ -401,7 +401,7 @@ void initthread(struct ___Thread___ * ___this___) { free(lockedobjs); #endif #endif - ___this___=(struct ___Thread___ *) p[2]; + ___this___=(ThreadPtr) p[2]; #else ___Thread______staticStart____L___Thread___(___this___); #endif @@ -460,13 +460,13 @@ void CALL00(___Thread______abort____) { #ifdef RECOVERY // return if the machine is dead #ifdef D___Thread______nativeGetStatus____I -int CALL12(___Thread______nativeGetStatus____I, int ___mid___, struct ___Thread___ * ___this___, int ___mid___) { +int CALL12(___Thread______nativeGetStatus____I, int ___mid___, ThreadPtr ___this___, int ___mid___) { return getStatus(___mid___); } #endif #else #ifdef D___Thread______nativeGetStatus____I -int CALL12(___Thread______nativeGetStatus____I, int ___mid___, struct ___Thread___ * ___this___, int ___mid___) { +int CALL12(___Thread______nativeGetStatus____I, int ___mid___, ThreadPtr ___this___, int ___mid___) { return 0; } #endif @@ -475,7 +475,7 @@ int CALL12(___Thread______nativeGetStatus____I, int ___mid___, struct ___Thread_ #ifdef DSTM /* Add thread join capability */ #ifdef D___Thread______join____ -void CALL01(___Thread______join____, struct ___Thread___ * ___this___) { +void CALL01(___Thread______join____, ThreadPtr ___this___) { unsigned int *oidarray; unsigned short *versionarray, version; objheader_t *ptr; @@ -483,7 +483,7 @@ void CALL01(___Thread______join____, struct ___Thread___ * ___this___) { transstart: transStart(); ptr = transRead((unsigned int) VAR(___this___)); - struct ___Thread___ *p = (struct ___Thread___ *) ptr; + ThreadPtr p = (ThreadPtr) ptr; #ifdef THREADJOINDEBUG printf("Start join process for Oid = %x\n", (unsigned int) VAR(___this___)); #endif @@ -541,7 +541,7 @@ transstart: #if defined(THREADS)||defined(STM) #ifdef D___Thread______nativeJoin____ -void CALL01(___Thread______nativeJoin____, struct ___Thread___ * ___this___) { +void CALL01(___Thread______nativeJoin____, ThreadPtr ___this___) { pthread_mutex_lock(&joinlock); while(!VAR(___this___)->___finished___) { #ifdef PRECISE_GC @@ -557,7 +557,7 @@ void CALL01(___Thread______nativeJoin____, struct ___Thread___ * ___this___) { #endif #ifdef D___Thread______nativeCreate____ -void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) { +void CALL01(___Thread______nativeCreate____, ThreadPtr ___this___) { pthread_t thread; int retval; pthread_attr_t nattr; @@ -583,7 +583,7 @@ void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) { #ifdef DSTM #ifdef D___Thread______start____I -void CALL12(___Thread______start____I, int ___mid___, struct ___Thread___ * ___this___, int ___mid___) { +void CALL12(___Thread______start____I, int ___mid___, ThreadPtr ___this___, int ___mid___) { startRemoteThread((unsigned int)VAR(___this___), ___mid___); } #endif @@ -646,7 +646,7 @@ transstart: { transStart(); tmp = transRead((unsigned int) oid); - ((struct ___Thread___ *)tmp)->___threadDone___ = 1; + ((ThreadPtr)tmp)->___threadDone___ = 1; *((unsigned int *)&((struct ___Object___ *) tmp)->___localcopy___) |=DIRTY; if(transCommit()!= 0) { goto transstart; diff --git a/Robust/src/Runtime/thread.h b/Robust/src/Runtime/thread.h index abcc5590..773325d1 100644 --- a/Robust/src/Runtime/thread.h +++ b/Robust/src/Runtime/thread.h @@ -2,6 +2,7 @@ #define THREAD_H #include "methodheaders.h" #include +#include "objtypes.h" extern int threadcount; extern pthread_mutex_t gclock; @@ -32,7 +33,7 @@ extern pthread_key_t memorytopkey; #endif #if defined(THREADS)||defined(STM) -void initthread(struct ___Thread___ * ___this___); +void initthread(ThreadPtr ___this___); #endif #ifdef DSTM void initDSMthread(int *ptr); -- 2.34.1