From 929fa62c50d2b835470836378912bb879b656202 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 14 Apr 2011 18:53:46 +0000 Subject: [PATCH] move hashcode into header...part of prep to switch class libraries --- Robust/src/ClassLibrary/Bristlecone/Object.java | 3 --- Robust/src/ClassLibrary/FastCheck/Object.java | 2 -- Robust/src/ClassLibrary/Java/Object.java | 3 --- Robust/src/ClassLibrary/JavaDSM/Object.java | 12 +----------- Robust/src/ClassLibrary/JavaSTM/Object.java | 2 -- Robust/src/ClassLibrary/JavaThread/Object.java | 3 --- Robust/src/ClassLibrary/MGC/Object.java | 3 --- Robust/src/Runtime/object.c | 12 +----------- Robust/src/Runtime/runtime.c | 10 ++++++++++ 9 files changed, 12 insertions(+), 38 deletions(-) diff --git a/Robust/src/ClassLibrary/Bristlecone/Object.java b/Robust/src/ClassLibrary/Bristlecone/Object.java index 304aa430..a5814716 100644 --- a/Robust/src/ClassLibrary/Bristlecone/Object.java +++ b/Robust/src/ClassLibrary/Bristlecone/Object.java @@ -1,7 +1,4 @@ public class Object { - private int cachedCode; //first field has to be a primitive - private boolean cachedHash; - /* DO NOT USE ANY OF THESE - THEY ARE FOR IMPLEMENTING TAGS */ private Object tags; diff --git a/Robust/src/ClassLibrary/FastCheck/Object.java b/Robust/src/ClassLibrary/FastCheck/Object.java index 3a867bb6..dfc1ef47 100644 --- a/Robust/src/ClassLibrary/FastCheck/Object.java +++ b/Robust/src/ClassLibrary/FastCheck/Object.java @@ -1,6 +1,4 @@ public class Object { - public int cachedCode; //first field has to be a primitive - public boolean cachedHash; public Object nextobject; /* Oid */ public Object localcopy; diff --git a/Robust/src/ClassLibrary/Java/Object.java b/Robust/src/ClassLibrary/Java/Object.java index b250cc86..e509356b 100644 --- a/Robust/src/ClassLibrary/Java/Object.java +++ b/Robust/src/ClassLibrary/Java/Object.java @@ -1,7 +1,4 @@ public class Object { - public int cachedCode; //first field has to be a primitive - public boolean cachedHash; - public native int hashCode(); /* DON'T USE THIS METHOD UNLESS NECESSARY */ diff --git a/Robust/src/ClassLibrary/JavaDSM/Object.java b/Robust/src/ClassLibrary/JavaDSM/Object.java index 308e81f3..e1fb6e51 100644 --- a/Robust/src/ClassLibrary/JavaDSM/Object.java +++ b/Robust/src/ClassLibrary/JavaDSM/Object.java @@ -1,18 +1,8 @@ public class Object { - public int cachedCode; //first field has to be a primitive - public boolean cachedHash; public Object nextobject; /* Oid */ public Object localcopy; - public native int nativehashCode(); - - public int hashCode() { - if (!cachedHash) { - cachedCode=nativehashCode(); - cachedHash=true; - } - return cachedCode; - } + public native int hashCode(); /* DON'T USE THIS METHOD UNLESS NECESSARY */ /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */ diff --git a/Robust/src/ClassLibrary/JavaSTM/Object.java b/Robust/src/ClassLibrary/JavaSTM/Object.java index 2e85d02f..8eadb362 100644 --- a/Robust/src/ClassLibrary/JavaSTM/Object.java +++ b/Robust/src/ClassLibrary/JavaSTM/Object.java @@ -1,6 +1,4 @@ public class Object { - public int cachedCode; //first field has to be a primitive - public boolean cachedHash; public native int nativehashCode(); private int objstatus; private Object objlocation; diff --git a/Robust/src/ClassLibrary/JavaThread/Object.java b/Robust/src/ClassLibrary/JavaThread/Object.java index b48cd258..f1bcf21f 100644 --- a/Robust/src/ClassLibrary/JavaThread/Object.java +++ b/Robust/src/ClassLibrary/JavaThread/Object.java @@ -1,7 +1,4 @@ public class Object { - public int cachedCode; //first field has to be a primitive - public boolean cachedHash; - public native int hashCode(); /* DON'T USE THIS METHOD UNLESS NECESSARY */ diff --git a/Robust/src/ClassLibrary/MGC/Object.java b/Robust/src/ClassLibrary/MGC/Object.java index a1d7703b..41dfb120 100644 --- a/Robust/src/ClassLibrary/MGC/Object.java +++ b/Robust/src/ClassLibrary/MGC/Object.java @@ -1,7 +1,4 @@ public class Object { - public int cachedCode; //first field has to be a primitive - public boolean cachedHash; - // temporary extra unused int filed to align objects for Java //int wkhqwemnbmwnb; diff --git a/Robust/src/Runtime/object.c b/Robust/src/Runtime/object.c index 4dbb7f0b..d0f59488 100644 --- a/Robust/src/Runtime/object.c +++ b/Robust/src/Runtime/object.c @@ -20,19 +20,9 @@ __thread int mythreadid; #endif -#ifdef D___Object______nativehashCode____ -int CALL01(___Object______nativehashCode____, struct ___Object___ * ___this___) { - return (int)((INTPTR) VAR(___this___)); -} -#endif - #ifdef D___Object______hashCode____ int CALL01(___Object______hashCode____, struct ___Object___ * ___this___) { - if (!VAR(___this___)->___cachedHash___) { - VAR(___this___)->___cachedHash___=1; - VAR(___this___)->___cachedCode___=(int)((INTPTR)VAR(___this___)); - } - return VAR(___this___)->___cachedCode___; + return VAR(___this___)->hashcode; } #endif diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index f2c81b0f..2eebeacb 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -672,6 +672,7 @@ void CALL00(___Barrier______enterBarrier____) { __attribute__((malloc)) void * allocate_newglobal(int type) { struct ___Object___ * v=(struct ___Object___ *) transCreateObj(classsize[type]); v->type=type; + v->hashcode=(int)(INTPTR)v; //printf("DEBUG %s(), type= %x\n", __func__, type); #ifdef THREADS v->tid=0; @@ -688,6 +689,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarrayglobal(int type, i return NULL; } v->type=type; + v->hashcode=(int)(INTPTR)v; v->___length___=length; #ifdef THREADS v->tid=0; @@ -709,6 +711,7 @@ __attribute__((malloc)) void * allocate_newtrans(void * ptr, int type) { #endif ASSIGNUID(v); v->type=type; + v->hashcode=(int)(INTPTR)v; v->___objlocation___=v; return v; } @@ -739,6 +742,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarraytrans(void * ptr, } v->___objlocation___=(struct ___Object___*)v; v->type=type; + v->hashcode=(int)(INTPTR)v; v->___length___=length; return v; } @@ -751,6 +755,7 @@ __attribute__((malloc)) void * allocate_new(void * ptr, int type) { tmp->version = 1; v->___objlocation___=v; v->type = type; + v->hashcode=(int)(INTPTR)v; return v; } @@ -784,6 +789,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t tmp->version=1; ASSIGNUID(v); v->type=type; + v->hashcode=(int)(INTPTR)v; if (length<0) { printf("ERROR: negative array %d\n", length); return NULL; @@ -806,6 +812,7 @@ __attribute__((malloc)) void * allocate_new(void * ptr, int type) { #endif struct ___Object___ * v=(struct ___Object___ *) mygcmalloc((struct garbagelist *) ptr, classsize[type]); v->type=type; + v->hashcode=(int)(INTPTR)v; #ifdef THREADS v->tid=0; #endif @@ -830,6 +837,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t #endif struct ArrayObject * v=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+length*classsize[type]); v->type=type; + v->hashcode=(int)(INTPTR)v; if (length<0) { printf("ERROR: negative array\n"); return NULL; @@ -852,6 +860,7 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int t __attribute__((malloc)) void * allocate_new(int type) { struct ___Object___ * v=FREEMALLOC(classsize[type]); v->type=type; + v->hashcode=(int)(INTPTR)v; #ifdef OPTIONAL v->fses=0; #endif @@ -863,6 +872,7 @@ __attribute__((malloc)) void * allocate_new(int type) { __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int length) { __attribute__((malloc)) struct ArrayObject * v=FREEMALLOC(sizeof(struct ArrayObject)+length*classsize[type]); v->type=type; + v->hashcode=(int)(INTPTR)v; v->___length___=length; #ifdef OPTIONAL v->fses=0; -- 2.34.1