From 89d1c15834957f4bc62db37dbf77b1f955f84b66 Mon Sep 17 00:00:00 2001 From: green Date: Sun, 2 Apr 2000 15:34:17 +0000 Subject: JVMPI changes... Sun Apr 2 08:27:18 2000 Anthony Green * configure: Rebuilt. * configure.in: Add --disable-jvmpi. * include/config.h.in: Rebuilt. * acconfig.h: Add ENABLE_JVMPI. * include/jvm.h: Declare _Jv_DisableGC and _Jv_EnableGC. (_Jv_JVMPI_Notify_OBJECT_ALLOC): New define. (_Jv_JVMPI_Notify_THREAD_END): New define. (_Jv_JVMPI_Notify_THREAD_END): New define. * prims.cc (_Jv_JVMPI_Notify_OBJECT_ALLOC): Declare. (_Jv_JVMPI_Notify_THREAD_END): Declare. (_Jv_JVMPI_Notify_THREAD_END): Declare. * prims.cc (_Jv_AllocObject): Generate JVMPI object allocation events. * java/lang/natThread.cc: Include JVMPI headers if necessary. (finish_): Generate JVMPI thread end events. (run_): Generate JVMPI thread start events. * gnu/gcj/runtime/natFirstThread.cc (run): Call JNI_OnLoad for any preloaded JNI library. Include JVMPI headers if necessary. (run): Generate JVMPI thread start events. * boehm.cc: Define GC_disable and GC_enable. (_Jv_DisableGC): New function. (_Jv_EnableGC): New function. (disable_gc_mutex): Declare. * nogc.cc (_Jv_DisableGC): New function. (_Jv_EnableGC): New function. * jni.cc (_Jv_JNI_GetEnv): Handle JVMPI interface requests. (_Jv_JVMPI_Interface): Define. (jvmpiEnableEvent): New function. (_Jv_JNI_Init): Initialize _Jv_JVMPI_Interface. * include/jvmpi.h: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@32866 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/jni.cc | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'libjava/jni.cc') diff --git a/libjava/jni.cc b/libjava/jni.cc index da9a84860ee..ea2f03974f3 100644 --- a/libjava/jni.cc +++ b/libjava/jni.cc @@ -20,6 +20,9 @@ details. */ #include #include #include +#ifdef ENABLE_JVMPI +#include +#endif #include #include @@ -105,12 +108,66 @@ static java::util::Hashtable *ref_table; // The only VM. static JavaVM *the_vm; +#ifdef ENABLE_JVMPI +// The only JVMPI interface description. +static JVMPI_Interface _Jv_JVMPI_Interface; + +static jint +jvmpiEnableEvent (jint event_type, void *) +{ + switch (event_type) + { + case JVMPI_EVENT_OBJECT_ALLOC: + _Jv_JVMPI_Notify_OBJECT_ALLOC = _Jv_JVMPI_Interface.NotifyEvent; + break; + + case JVMPI_EVENT_THREAD_START: + _Jv_JVMPI_Notify_THREAD_START = _Jv_JVMPI_Interface.NotifyEvent; + break; + + case JVMPI_EVENT_THREAD_END: + _Jv_JVMPI_Notify_THREAD_END = _Jv_JVMPI_Interface.NotifyEvent; + break; + + default: + return JVMPI_NOT_AVAILABLE; + } + + return JVMPI_SUCCESS; +} + +static jint +jvmpiDisableEvent (jint event_type, void *) +{ + switch (event_type) + { + case JVMPI_EVENT_OBJECT_ALLOC: + _Jv_JVMPI_Notify_OBJECT_ALLOC = NULL; + break; + + default: + return JVMPI_NOT_AVAILABLE; + } + + return JVMPI_SUCCESS; +} +#endif + void _Jv_JNI_Init (void) { ref_table = new java::util::Hashtable; + +#ifdef ENABLE_JVMPI + _Jv_JVMPI_Interface.version = 1; + _Jv_JVMPI_Interface.EnableEvent = &jvmpiEnableEvent; + _Jv_JVMPI_Interface.DisableEvent = &jvmpiDisableEvent; + _Jv_JVMPI_Interface.EnableGC = &_Jv_EnableGC; + _Jv_JVMPI_Interface.DisableGC = &_Jv_DisableGC; + _Jv_JVMPI_Interface.RunGC = &_Jv_RunGC; +#endif } // Tell the GC that a certain pointer is live. @@ -1868,6 +1925,15 @@ _Jv_JNI_GetEnv (JavaVM *, void **penv, jint version) return JNI_EDETACHED; } +#ifdef ENABLE_JVMPI + // Handle JVMPI requests. + if (version == JVMPI_VERSION_1) + { + *penv = (void *) &_Jv_JVMPI_Interface; + return 0; + } +#endif + // FIXME: do we really want to support 1.1? if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_1) { -- cgit v1.2.3