Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

prof_jniref.cpp

00001 /*
00002  *                         Sun Public License Notice
00003  *
00004  * The contents of this file are subject to the Sun Public License
00005  * Version 1.0 (the "License"); you may not use this file except
00006  * in compliance with the License. A copy of the License is available
00007  * at http://www.sun.com/
00008  *
00009  * The Original Code is the Java Profiler module.  The Initial Developers
00010  * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner,
00011  * Lukas Petru and Marek Przeczek.
00012  *
00013  * Portions created by Jan Stola are Copyright (C) 2000-2001.
00014  * All Rights Reserved.
00015  *
00016  * Portions created by Pavel Vacha are Copyright (C) 2000-2001.
00017  * All Rights Reserved.
00018  *
00019  * Portions created by Michal Pise are Copyright (C) 2000-2001.
00020  * All Rights Reserved.
00021  *
00022  * Portions created by Petr Luner are Copyright (C) 2000-2001.
00023  * All Rights Reserved.
00024  *
00025  * Portions created by Lukas Petru are Copyright (C) 2000-2001.
00026  * All Rights Reserved.
00027  *
00028  * Portions created by Marek Przeczek are Copyright (C) 2000-2001.
00029  * All Rights Reserved.
00030  *
00031  * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner,
00032  *               Lukas Petru and Marek Przeczek.
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 }

Generated on Mon Jan 28 14:53:27 2002 for Java Profiler Dynamic Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001