From 54c2f04ba05ce07e701345bc66d038b7d47a9bed Mon Sep 17 00:00:00 2001 From: Anthony 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. From-SVN: r32866 --- libjava/prims.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'libjava/prims.cc') diff --git a/libjava/prims.cc b/libjava/prims.cc index 81668a8..5b1e62d 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -34,6 +34,10 @@ details. */ #include #include +#ifdef ENABLE_JVMPI +#include +#endif + #ifndef DISABLE_GETENV_PROPERTIES #include #include @@ -83,6 +87,12 @@ property_pair *_Jv_Environment_Properties; // The name of this executable. static char * _Jv_execName; +#ifdef ENABLE_JVMPI +// Pointer to JVMPI notification functions. +void (*_Jv_JVMPI_Notify_OBJECT_ALLOC) (JVMPI_Event *event); +void (*_Jv_JVMPI_Notify_THREAD_START) (JVMPI_Event *event); +void (*_Jv_JVMPI_Notify_THREAD_END) (JVMPI_Event *event); +#endif #ifdef HANDLE_SEGV @@ -326,6 +336,27 @@ _Jv_AllocObject (jclass c, jint size) if (c->vtable->method[1] != ObjectClass.vtable->method[1]) _Jv_RegisterFinalizer (obj, _Jv_FinalizeObject); +#ifdef ENABLE_JVMPI + // Service JVMPI request. + + if (_Jv_JVMPI_Notify_OBJECT_ALLOC) + { + JVMPI_Event event; + + event.event_type = JVMPI_EVENT_OBJECT_ALLOC; + event.env_id = NULL; + event.u.obj_alloc.arena_id = 0; + event.u.obj_alloc.class_id = (jobjectID) c; + event.u.obj_alloc.is_array = 0; + event.u.obj_alloc.size = size; + event.u.obj_alloc.obj_id = (jobjectID) obj; + + _Jv_DisableGC (); + (*_Jv_JVMPI_Notify_OBJECT_ALLOC) (&event); + _Jv_EnableGC (); + } +#endif + return obj; } -- cgit v1.1