make hashCode a native method for java lang Object...
authorbdemsky <bdemsky>
Fri, 1 Apr 2011 02:10:17 +0000 (02:10 +0000)
committerbdemsky <bdemsky>
Fri, 1 Apr 2011 02:10:17 +0000 (02:10 +0000)
Robust/src/Runtime/object.c
Robust/src/Runtime/object.h

index 98183c2e5cb1a6ba74f7ee89b3f90fb7a40ca0ea..4c3c7a03865c7516303c9d603bb5610eb28cbe7e 100644 (file)
 #include "thread.h"
 #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___;
+}
+#endif
 
 int CALL01(___Object______getType____, struct ___Object___ * ___this___) {
   return ((int *)VAR(___this___))[0];
index 7f4cdb1557b8c27025c154576afbd13c36770359..8c177340246dd97f23a7189e9e51394e29786b58 100644 (file)
@@ -2,8 +2,14 @@
 #define OBJECT_H
 #include "runtime.h"
 #include "structdefs.h"
-
-int CALL01(___Object______nativehashCode____, struct ___Object___ * ___this___); int CALL01(___Object______getType____, struct ___Object___ * ___this___);
+#include "methodheaders.h"
+#ifdef D___Object______nativehashCode____
+int CALL01(___Object______nativehashCode____, struct ___Object___ * ___this___);
+#endif 
+#ifdef D___Object______hashCode____
+int CALL01(___Object______hashCode____, struct ___Object___ * ___this___); 
+#endif
+int CALL01(___Object______getType____, struct ___Object___ * ___this___);
 #ifdef THREADS
 int CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___);
 int CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___);