* src/native/vm/openjdk/sun_misc_Perf.cpp: Added new file.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 14 Oct 2009 08:56:49 +0000 (10:56 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 14 Oct 2009 08:56:49 +0000 (10:56 +0200)
* src/native/vm/openjdk/Makefile.am (libnativevmcore_la_SOURCES): Added file.
* src/native/vm/nativevm.cpp (nativevm_preinit): Register sun.misc.Perf methods.
* src/native/vm/nativevm.hpp (_Jv_sun_misc_Perf_init): Added.

src/native/vm/nativevm.cpp
src/native/vm/nativevm.hpp
src/native/vm/openjdk/Makefile.am
src/native/vm/openjdk/sun_misc_Perf.cpp [new file with mode: 0644]

index 4b2e9bee4350e9471c98124d5956309f021c7343..1894c9019364c15b27b5876015a5948d5e8b8612 100644 (file)
@@ -124,6 +124,7 @@ void nativevm_preinit(void)
        HPI& hpi = vm->get_hpi();
        hpi.initialize();
 
+       _Jv_sun_misc_Perf_init();
        _Jv_sun_misc_Unsafe_init();
 
 # else
index 9f651a6cec99c0b7de0b6531dc69fbb7882241af..6410cb94e686782c54f61f0a6ee200ed8c842205 100644 (file)
@@ -66,6 +66,7 @@ void _Jv_sun_reflect_ConstantPool_init();
 
 # elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
+void _Jv_sun_misc_Perf_init();
 void _Jv_sun_misc_Unsafe_init();
 
 # else
index 1e5bfd3bd19ff7cab27660b9c572ac09b8e0c953..f917a10ef407f6bb5fb0dfb674ae17d5f85340d7 100644 (file)
@@ -1,6 +1,6 @@
 ## src/native/vm/openjdk/Makefile.am
 ##
-## Copyright (C) 2007, 2008
+## Copyright (C) 2007, 2008, 2009
 ## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 ##
 ## This file is part of CACAO.
@@ -33,7 +33,8 @@ libnativevmcore_la_SOURCES = \
        hpi.hpp \
        jvm.cpp \
        management.cpp \
-       management.hpp
+       management.hpp \
+       sun_misc_Perf.cpp
 
 
 ## Local variables:
diff --git a/src/native/vm/openjdk/sun_misc_Perf.cpp b/src/native/vm/openjdk/sun_misc_Perf.cpp
new file mode 100644 (file)
index 0000000..8fb75bb
--- /dev/null
@@ -0,0 +1,165 @@
+/* src/native/vm/openjdk/sun_misc_Perf.cpp - sun/misc/Perf
+
+   Copyright (C) 2009
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+   Copyright (C) 2009 Theobroma Systems Ltd.
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#include "config.h"
+
+#include "native/jni.hpp"
+#include "native/native.hpp"
+
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
+
+
+// Native functions are exported as C functions.
+extern "C" {
+
+/*
+ * Class:     sun/misc/Perf
+ * Method:    registerNatives
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Perf_registerNatives(JNIEnv *env, jclass clazz)
+{
+       /* The native methods of this function are already registered in
+          _Jv_sun_misc_Perf_init() which is called during VM
+          startup. */
+}
+
+
+/*
+ * Class:     sun/misc/Perf
+ * Method:    attach
+ * Signature: (Ljava/lang/String;II)Ljava/nio/ByteBuffer;
+ */
+JNIEXPORT jobject JNICALL Java_sun_misc_Perf_attach(JNIEnv *env, jobject _this, jstring user, jint lvmid, jint mode)
+{
+       log_println("Java_sun_misc_Perf_attach: Not supported!");
+       return NULL;
+}
+
+
+/*
+ * Class:     sun/misc/Perf
+ * Method:    createByteArray
+ * Signature: (Ljava/lang/String;II[BI)Ljava/nio/ByteBuffer;
+ */
+JNIEXPORT jobject JNICALL Java_sun_misc_Perf_createByteArray(JNIEnv *env, jobject _this, jstring name, jint variability, jint units, jbyteArray value, jint max_length)
+{
+       log_println("Java_sun_misc_Perf_createByteArray: Not supported!");
+       return NULL;
+}
+
+
+/*
+ * Class:     sun/misc/Perf
+ * Method:    createLong
+ * Signature: (Ljava/lang/String;IIJ)Ljava/nio/ByteBuffer;
+ */
+JNIEXPORT jobject JNICALL Java_sun_misc_Perf_createLong(JNIEnv *env, jobject _this, jstring name, jint variability, jint units, jlong value)
+{
+       log_println("Java_sun_misc_Perf_createLong: Not supported!");
+       return NULL;
+}
+
+
+/*
+ * Class:     sun/misc/Perf
+ * Method:    detach
+ * Signature: (Ljava/nio/ByteBuffer;)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Perf_detach(JNIEnv *env, jobject _this, jobject bb)
+{
+       log_println("Java_sun_misc_Perf_detach: Not supported!");
+}
+
+
+/*
+ * Class:     sun/misc/Perf
+ * Method:    highResCounter
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_sun_misc_Perf_highResCounter(JNIEnv *env, jobject _this)
+{
+       log_println("Java_sun_misc_Perf_highResCounter: IMPLEMENT ME!");
+       return 0;
+}
+
+
+/*
+ * Class:     sun/misc/Perf
+ * Method:    highResFrequency
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_sun_misc_Perf_highResFrequency(JNIEnv *env, jobject _this)
+{
+       log_println("Java_sun_misc_Perf_highResFrequency: IMPLEMENT ME!");
+       return 0;
+}
+
+} // extern "C"
+
+
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { (char*) "registerNatives",  (char*) "()V",                                            (void*) (uintptr_t) &Java_sun_misc_Perf_registerNatives  },
+       { (char*) "attach",           (char*) "(Ljava/lang/String;II)Ljava/nio/ByteBuffer;",    (void*) (uintptr_t) &Java_sun_misc_Perf_attach           },
+       { (char*) "createByteArray",  (char*) "(Ljava/lang/String;II[BI)Ljava/nio/ByteBuffer;", (void*) (uintptr_t) &Java_sun_misc_Perf_createByteArray  },
+       { (char*) "createLong",       (char*) "(Ljava/lang/String;IIJ)Ljava/nio/ByteBuffer;",   (void*) (uintptr_t) &Java_sun_misc_Perf_createLong       },
+       { (char*) "detach",           (char*) "(Ljava/nio/ByteBuffer;)V",                       (void*) (uintptr_t) &Java_sun_misc_Perf_detach           },
+       { (char*) "highResCounter",   (char*) "()J",                                            (void*) (uintptr_t) &Java_sun_misc_Perf_highResCounter   },
+       { (char*) "highResFrequency", (char*) "()J",                                            (void*) (uintptr_t) &Java_sun_misc_Perf_highResFrequency },
+};
+
+
+/* _Jv_sun_misc_Perf_init ******************************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_sun_misc_Perf_init(void)
+{
+       utf* u = utf_new_char("sun/misc/Perf");
+
+       NativeMethods& nm = VM::get_current()->get_nativemethods();
+       nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */