move hashcode into header...part of prep to switch class libraries
authorbdemsky <bdemsky>
Thu, 14 Apr 2011 18:53:46 +0000 (18:53 +0000)
committerbdemsky <bdemsky>
Thu, 14 Apr 2011 18:53:46 +0000 (18:53 +0000)
Robust/src/ClassLibrary/Bristlecone/Object.java
Robust/src/ClassLibrary/FastCheck/Object.java
Robust/src/ClassLibrary/Java/Object.java
Robust/src/ClassLibrary/JavaDSM/Object.java
Robust/src/ClassLibrary/JavaSTM/Object.java
Robust/src/ClassLibrary/JavaThread/Object.java
Robust/src/ClassLibrary/MGC/Object.java
Robust/src/Runtime/object.c
Robust/src/Runtime/runtime.c

index 304aa4304a3cd4f8cd9e1140d49e0d70fb71b0d8..a581471644e44cd23705533a3bef5c52ce3d56ba 100644 (file)
@@ -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;
 
index 3a867bb67b5116fa60f578e13f464cdcdd19d3de..dfc1ef477d1eb7cf01890b829f777039702a04de 100644 (file)
@@ -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;
 
index b250cc86955cf04b96eda0e9be38416b637b50e0..e509356bcfe22dbca424aac26d24b7dce677dfc1 100644 (file)
@@ -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 */
index 308e81f3a04c7f17fdd8c6c7716d953e9af14045..e1fb6e5111eb6536ec139541b15ae75963fda850 100644 (file)
@@ -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 */
index 2e85d02fabc75407ce2a7e55f9466dc539aa778f..8eadb36211ac3bba43a09b142c720cd7fbb2f9c3 100644 (file)
@@ -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;
index b48cd258c6a4484b47f11593784b80385ac59bba..f1bcf21f2db7065f547806abaea25783e3157e6f 100644 (file)
@@ -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 */
index a1d7703bfb367c5f1ebb04d0a68e3113ac701a13..41dfb1201b287a9f7dbd4f4ee0dfbcde0cdf7bec 100644 (file)
@@ -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;
 
index 4dbb7f0ba59ef5c97bb1bcf6cc4131b354f7564e..d0f59488dc834eddf563a31a490f6bc6f1ea9624 100644 (file)
@@ -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
 
index f2c81b0fb99616f93c0697c34fb32d86638c789c..2eebeacb16641a8b005a3cc8b41ec1465137ec72 100644 (file)
@@ -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;