* src/native/vm/cldc1.1/java_lang_Object.cpp: Use above getter function.
* src/native/vm/gnuclasspath/java_lang_VMSystem.cpp: Likewise.
* src/native/vm/openjdk/jvm.cpp: Likewise.
#include "threads/lock-common.h"
#include "vm/exceptions.hpp"
+#include "vm/javaobjects.hpp"
// Native functions are exported as C functions.
*/
JNIEXPORT jint JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, jobject _this)
{
-#if defined(ENABLE_GC_CACAO)
- assert(0);
-#else
- return (int32_t) ((uintptr_t) _this);
-#endif
+ java_lang_Object o(_this);
+
+ return o.get_hashcode();
}
#endif
#include "vm/builtin.h"
+#include "vm/javaobjects.hpp"
// Native functions are exported as C functions.
* Method: identityHashCode
* Signature: (Ljava/lang/Object;)I
*/
-JNIEXPORT jint JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, jobject o)
+JNIEXPORT jint JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, jobject obj)
{
- int32_t hashcode;
-
- // XXX This critical section should be inside the heap function.
- LLNI_CRITICAL_START;
-
- hashcode = heap_hashcode(LLNI_UNWRAP((java_handle_t *) o));
-
- LLNI_CRITICAL_END;
-
- return hashcode;
+ java_lang_Object o(obj);
+ return o.get_hashcode();
}
} // extern "C"
{
TRACEJVMCALLS(("JVM_IHashCode(env=%p, jobject=%p)", env, handle));
- return (jint) ((ptrint) handle);
+ java_lang_Object o(handle);
+
+ return o.get_hashcode();
}
virtual ~java_lang_Object() {}
// Getters.
- virtual inline java_handle_t* get_handle() const { return _handle; }
- inline vftbl_t* get_vftbl () const;
- inline classinfo* get_Class () const;
+ virtual inline java_handle_t* get_handle () const { return _handle; }
+ inline vftbl_t* get_vftbl () const;
+ inline classinfo* get_Class () const;
+ inline int32_t get_hashcode() const;
inline bool is_null () const;
inline bool is_non_null() const;
return get_vftbl()->clazz;
}
+inline int32_t java_lang_Object::get_hashcode() const
+{
+#if defined(ENABLE_GC_CACAO)
+ return heap_get_hashcode(_handle);
+#else
+ java_object_t* o;
+ int32_t hashcode;
+
+ GC::critical_enter();
+
+ // XXX This should be h->get_object();
+ o = LLNI_UNWRAP(_handle);
+
+ hashcode = (int32_t)(intptr_t) o;
+
+ GC::critical_leave();
+
+ return hashcode;
+#endif
+}
+
inline bool java_lang_Object::is_null() const
{