00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "../prof/prof.h"
00036 #include "../prof/synchronized.h"
00037 #include "../alloc/allocInstance.h"
00038 #include "../alloc/allocGlobalRef.h"
00039
00040 void Prof::event_jniGlobalrefAlloc( JVMPI_Event* event) {
00041
00042 Synchronized sync( dataLock);
00043
00044 AllocInstance* ins = instances.get( event->u.jni_globalref_alloc.obj_id);
00045 if( !ins) return;
00046
00047 static int firstTime = 1;
00048 if( firstTime) {
00049
00050 jvmpiInterface->EnableEvent( JVMPI_EVENT_JNI_GLOBALREF_FREE, NULL);
00051 firstTime = 0;
00052 }
00053
00054 AllocGlobalRef* r = new AllocGlobalRef;
00055 r->instance = ins;
00056 r->refId = event->u.jni_globalref_alloc.ref_id;
00057
00058 jniGlobalRefs.add( r);
00059 }
00060
00061 void Prof::event_jniGlobalrefFree( JVMPI_Event* event) {
00062
00063 Synchronized sync( dataLock);
00064
00065 AllocGlobalRef* r = jniGlobalRefs.get(event->u.jni_globalref_free.ref_id);
00066 if (r) {
00067 jniGlobalRefs.remove(r);
00068 delete r;
00069 }
00070 }
00071
00072 void Prof::event_jniWeakGlobalrefAlloc( JVMPI_Event* event) {
00073
00074 Synchronized sync( dataLock);
00075
00076 AllocInstance* ins = instances.get( event->u.jni_globalref_alloc.obj_id);
00077 if( !ins) return;
00078
00079 static int firstTime = 1;
00080 if( firstTime) {
00081
00082 jvmpiInterface->EnableEvent( JVMPI_EVENT_JNI_WEAK_GLOBALREF_FREE, NULL);
00083 firstTime = 0;
00084 }
00085
00086 AllocGlobalRef* r = new AllocGlobalRef;
00087 r->instance = ins;
00088 r->refId = event->u.jni_globalref_alloc.ref_id;
00089
00090 jniWeakGlobalRefs.add( r);
00091 }
00092
00093 void Prof::event_jniWeakGlobalrefFree( JVMPI_Event* event) {
00094
00095 Synchronized sync( dataLock);
00096
00097 AllocGlobalRef* r = jniWeakGlobalRefs.get(event->u.jni_globalref_free.ref_id);
00098 if (r) {
00099 jniWeakGlobalRefs.remove(r);
00100 delete r;
00101 }
00102 }