#include "threads/atomic.hpp"
-#include "mm/memory.h"
+#include "mm/memory.hpp"
#include "native/jni.hpp"
#include "native/llni.h"
#include "vm/jit/builtin.hpp"
#include "vm/exceptions.hpp"
-#include "vm/initialize.h"
+#include "vm/initialize.hpp"
#include "vm/javaobjects.hpp"
#include "vm/os.hpp"
#include "vm/string.hpp"
}
+/*
+ * Class: sun/misc/Unsafe
+ * Method: getDouble
+ * Signature: (J)D
+ */
+JNIEXPORT jdouble JNICALL Java_sun_misc_Unsafe_getDouble__J(JNIEnv *env, jobject _this, jlong address)
+{
+ double *p;
+ double value;
+
+ p = (double*) (intptr_t) address;
+
+ value = *p;
+
+ return value;
+}
+
+
+/*
+ * Class: sun/misc/Unsafe
+ * Method: putDouble
+ * Signature: (JD)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putDouble__JD(JNIEnv *env, jobject _this, jlong address, jdouble value)
+{
+ double* p;
+
+ p = (double*) (intptr_t) address;
+
+ *p = value;
+}
+
+
/*
* Class: sun/misc/Unsafe
* Method: objectFieldOffset
}
+/*
+ * Class: sun/misc/Unsafe
+ * Method: getByteVolatile
+ * Signature: (Ljava/lang/Object;J)B
+ */
+JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByteVolatile(JNIEnv* env, jobject _this, jobject o, jlong offset)
+{
+ return FieldAccess::get_volatile<int32_t>(o, offset);
+}
+
+
/*
* Class: sun/misc/Unsafe
* Method: getIntVolatile
*/
JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, jobject _this, jobject thread)
{
- /* XXX IMPLEMENT ME */
+ java_handle_t *h = (java_handle_t *) thread;
+ threadobject *t;
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+ h = java_lang_Thread(h).get_vmThread();
+#endif
+ t = thread_get_thread(h);
+
+ threads_unpark(t);
}
*/
JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, jobject _this, jboolean isAbsolute, jlong time)
{
- /* XXX IMPLEMENT ME */
+ threads_park(isAbsolute, time);
}
} // extern "C"
{ (char*) "putLong", (char*) "(JJ)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLong__JJ },
{ (char*) "getFloat", (char*) "(J)F", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloat__J },
{ (char*) "putFloat", (char*) "(JF)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putFloat__JF },
+ { (char*) "getDouble", (char*) "(J)D", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getDouble__J },
+ { (char*) "putDouble", (char*) "(JD)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putDouble__JD },
{ (char*) "objectFieldOffset", (char*) "(Ljava/lang/reflect/Field;)J", (void*) (uintptr_t) &Java_sun_misc_Unsafe_objectFieldOffset },
{ (char*) "allocateMemory", (char*) "(J)J", (void*) (uintptr_t) &Java_sun_misc_Unsafe_allocateMemory },
#if 0
{ (char*) "compareAndSwapLong", (char*) "(Ljava/lang/Object;JJJ)Z", (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapLong },
{ (char*) "getObjectVolatile", (char*) "(Ljava/lang/Object;J)Ljava/lang/Object;", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getObjectVolatile },
{ (char*) "putObjectVolatile", (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putObjectVolatile },
+ { (char*) "getByteVolatile", (char*) "(Ljava/lang/Object;J)B", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByteVolatile },
{ (char*) "getIntVolatile", (char*) "(Ljava/lang/Object;J)I", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getIntVolatile },
{ (char*) "putIntVolatile", (char*) "(Ljava/lang/Object;JI)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putIntVolatile },
{ (char*) "getLongVolatile", (char*) "(Ljava/lang/Object;J)J", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLongVolatile },
void _Jv_sun_misc_Unsafe_init(void)
{
- utf *u;
-
- u = utf_new_char("sun/misc/Unsafe");
+ utf* u = utf_new_char("sun/misc/Unsafe");
- native_method_register(u, methods, NATIVE_METHODS_COUNT);
+ NativeMethods& nm = VM::get_current()->get_nativemethods();
+ nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
}