From: Marek P. <ma...@us...> - 2001-11-21 22:32:22
|
Update of /cvsroot/javaprofiler/library/src/prof In directory usw-pr-cvs1:/tmp/cvs-serv12170/src/prof Modified Files: Makefile.rules dir.info lock.h prof.cpp prof.h prof_arena.cpp prof_class.cpp prof_gc.cpp prof_get.cpp prof_jniref.cpp prof_jvm.cpp prof_method.cpp prof_monitor.cpp prof_object.cpp prof_thread.cpp synchronized.h Added Files: lock.cpp Log Message: some parts completely rewritten; changes in communication interface to make it faster; ported to linux --- NEW FILE: lock.cpp --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ #include "../prof/lock.h" #include "../prof/prof.h" Lock::Lock( const String& name, JVMPI_Interface* jvmpi) { #ifdef USE_RAW_MONITORS if( !jvmpi) jvmpi = Prof::prof().jvmpiInterface; _rm = jvmpi->RawMonitorCreate( (char*)(const char*)name); #else #ifdef WIN32 InitializeCriticalSection( &cs); #else pthread_mutex_init( &cs, NULL); #endif #endif } Lock::~Lock() { #ifdef USE_RAW_MONITORS //Prof::prof().jvmpiInterface->RawMonitorDestroy( _rm); #else #ifdef WIN32 //DeleteCriticalSection( &cs); #else //pthread_mutex_destroy( &cs); #endif #endif } void Lock::wait() { #ifdef USE_RAW_MONITORS Prof::prof().jvmpiInterface->RawMonitorEnter( _rm); #else #ifdef WIN32 EnterCriticalSection( &cs); #else pthread_mutex_lock( &cs); #endif #endif } void Lock::release() { #ifdef USE_RAW_MONITORS Prof::prof().jvmpiInterface->RawMonitorExit( _rm); #else #ifdef WIN32 LeaveCriticalSection( &cs); #else pthread_mutex_unlock( &cs); #endif #endif } Index: Makefile.rules =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/Makefile.rules,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Makefile.rules 2001/08/24 17:54:04 1.3 --- Makefile.rules 2001/11/21 22:31:44 1.4 *************** *** 1,43 **** prof.o \ ! prof.obj: prof.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof.cpp prof_gc.o \ ! prof_gc.obj: prof_gc.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof_gc.cpp prof_get.o \ ! prof_get.obj: prof_get.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof_get.cpp prof_jvm.o \ ! prof_jvm.obj: prof_jvm.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof_jvm.cpp prof_jniref.o \ ! prof_jniref.obj: prof_jniref.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof_jniref.cpp prof_thread.o \ ! prof_thread.obj: prof_thread.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof_thread.cpp prof_arena.o \ ! prof_arena.obj: prof_arena.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof_arena.cpp prof_object.o \ ! prof_object.obj: prof_object.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof_object.cpp prof_class.o \ ! prof_class.obj: prof_class.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof_class.cpp prof_method.o \ ! prof_method.obj: prof_method.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof_method.cpp prof_monitor.o \ ! prof_monitor.obj: prof_monitor.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof_monitor.cpp --- 1,47 ---- prof.o \ ! prof.obj: prof.cpp $(CCC) $(CPPFLAGS) prof.cpp prof_gc.o \ ! prof_gc.obj: prof_gc.cpp $(CCC) $(CPPFLAGS) prof_gc.cpp prof_get.o \ ! prof_get.obj: prof_get.cpp $(CCC) $(CPPFLAGS) prof_get.cpp prof_jvm.o \ ! prof_jvm.obj: prof_jvm.cpp $(CCC) $(CPPFLAGS) prof_jvm.cpp prof_jniref.o \ ! prof_jniref.obj: prof_jniref.cpp $(CCC) $(CPPFLAGS) prof_jniref.cpp prof_thread.o \ ! prof_thread.obj: prof_thread.cpp $(CCC) $(CPPFLAGS) prof_thread.cpp prof_arena.o \ ! prof_arena.obj: prof_arena.cpp $(CCC) $(CPPFLAGS) prof_arena.cpp prof_object.o \ ! prof_object.obj: prof_object.cpp $(CCC) $(CPPFLAGS) prof_object.cpp prof_class.o \ ! prof_class.obj: prof_class.cpp $(CCC) $(CPPFLAGS) prof_class.cpp prof_method.o \ ! prof_method.obj: prof_method.cpp $(CCC) $(CPPFLAGS) prof_method.cpp prof_monitor.o \ ! prof_monitor.obj: prof_monitor.cpp $(CCC) $(CPPFLAGS) prof_monitor.cpp + + lock.o \ + lock.obj: lock.cpp + $(CCC) $(CPPFLAGS) lock.cpp Index: dir.info =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/dir.info,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** dir.info 2001/08/24 17:54:04 1.5 --- dir.info 2001/11/21 22:31:44 1.6 *************** *** 1,4 **** FILES = prof prof_arena prof_class prof_gc prof_get prof_jniref prof_jvm \ ! prof_method prof_monitor prof_object prof_thread CLEAN_FILES = *.pdb *.obj *.o --- 1,4 ---- FILES = prof prof_arena prof_class prof_gc prof_get prof_jniref prof_jvm \ ! prof_method prof_monitor prof_object prof_thread lock CLEAN_FILES = *.pdb *.obj *.o Index: lock.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/lock.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** lock.h 2001/09/02 20:14:22 1.13 --- lock.h 2001/11/21 22:31:44 1.14 *************** *** 36,39 **** --- 36,42 ---- #define _LOCK_H_ + #include "../main/includes.h" + #include "../string/string.h" + /** Implementation of locking. This class implements OS dependent 0/1 locks. ** It uses mutexes for it. This implementation can be replaced *************** *** 51,54 **** --- 54,61 ---- class Lock { + #ifdef USE_RAW_MONITORS + /// raw monitor object + JVMPI_RawMonitor _rm; + #else #ifdef WIN32 /// critical section (mutex) object *************** *** 58,61 **** --- 65,69 ---- pthread_mutex_t cs; #endif + #endif public: *************** *** 67,105 **** ** ** @param name name of mutex (used on WIN32 only) ** ** @see WIN32 API, UNIX API, String */ ! Lock( const String& name = NULL) { ! ! #ifdef WIN32 ! InitializeCriticalSection( &cs); ! #else ! pthread_mutex_init( &cs, NULL); ! #endif ! } /// Destructor. It destroys the mutex. ! ~Lock() { - #ifdef WIN32 - DeleteCriticalSection( &cs); - #else - pthread_mutex_destroy( &cs); - #endif - } - /** Locking. This method waits on the mutex till it is used ** by someone else. ** ** @see release() */ - - void wait() { ! #ifdef WIN32 ! EnterCriticalSection( &cs); ! #else ! pthread_mutex_lock( &cs); ! #endif ! } /** Unlocking. This method releases locked mutex so it can be --- 75,93 ---- ** ** @param name name of mutex (used on WIN32 only) + ** @param jvmpi pointer to JVMPI interface ** ** @see WIN32 API, UNIX API, String */ ! Lock( const String& name, JVMPI_Interface* jvmpi = NULL); /// Destructor. It destroys the mutex. ! ~Lock(); /** Locking. This method waits on the mutex till it is used ** by someone else. ** ** @see release() */ ! void wait(); /** Unlocking. This method releases locked mutex so it can be *************** *** 108,119 **** ** @see wait() */ ! void release() { ! ! #ifdef WIN32 ! LeaveCriticalSection( &cs); ! #else ! pthread_mutex_unlock( &cs); ! #endif ! } }; --- 96,100 ---- ** @see wait() */ ! void release(); }; Index: prof.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** prof.cpp 2001/09/18 22:19:28 1.25 --- prof.cpp 2001/11/21 22:31:44 1.26 *************** *** 33,48 **** */ ! #include "../main/includes.h" #define tF( i, a, b) tabFunc[i].event = a; tabFunc[i].func = b ! Prof::Prof( Setup& msetup) : ! setup( msetup), ! IProf( msetup), ! dataLock( "_data_lock"), ! shutdownLock( "_shutdown_lock"), ! gcLock( "_gc_lock"), shuttingDown( 0), --- 33,52 ---- */ ! #include "../prof/prof.h" #define tF( i, a, b) tabFunc[i].event = a; tabFunc[i].func = b ! Prof::Prof( Setup& msetup, JVMPI_Interface* jvmpi) : ! IProf( msetup, jvmpi), ! ! dataLock( "_data_lock", jvmpi), ! shutdownLock( "_shutdown_lock", jvmpi), ! gcLock( "_gc_lock", jvmpi), ! ! jvmpiInterface( jvmpi), ! setup( msetup), ! sampling( jvmpi), shuttingDown( 0), *************** *** 92,95 **** --- 96,104 ---- } + Prof::~Prof() { + + delete &setup; + } + void Prof::runEvent( JVMPI_Event* event) { *************** *** 99,103 **** if( event->event_type == p->event) { ! if( p->func) (this->*(p->func))( event); break; --- 108,112 ---- if( event->event_type == p->event) { ! if( p->func) (this->*(p->func))( event); break; *************** *** 120,141 **** Prof* Prof::_prof = NULL; - - Prof& Prof::prof() { return *_prof;} ! Prof* Prof::create( char* options) { ! return (_prof = new Prof( *(new Setup( options)))); } void Prof::destroy() { ! Prof* p = _prof; ! _prof = NULL; ! if( p) delete p; ! } ! void Prof::notifyEvent( JVMPI_Event* event) { ! ! if( _prof) _prof->runEvent( event); } --- 129,146 ---- Prof* Prof::_prof = NULL; ! Prof* Prof::create( char* options, JVMPI_Interface* jvmpi) { ! return (_prof = new Prof( *(new Setup( options)), jvmpi)); } void Prof::destroy() { ! static int destroying = 0; ! if( destroying) return; ! destroying = 1; ! if( _prof) delete _prof; ! _prof = NULL; } Index: prof.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof.h,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** prof.h 2001/09/18 22:19:29 1.36 --- prof.h 2001/11/21 22:31:44 1.37 *************** *** 36,39 **** --- 36,53 ---- #define _PROF_H_ + #include "../main/includes.h" + #include "../commun/iprof.h" + #include "../hash/hash.h" + #include "../cpu/sampling.h" + #include "../cpu/cpuThreadMethodKey.h" + #include "../shared/class.h" + #include "../shared/method.h" + #include "../shared/thread.h" + #include "../shared/groupThread.h" + #include "../alloc/allocArena.h" + #include "../alloc/allocObject.h" + #include "../alloc/allocGlobalRef.h" + #include "../gc/gc.h" + /** Main profiler library class. It encapsulates all used event handlers, ** implements all necessary methods for proper function of the library. *************** *** 46,50 **** class Prof: public IProf { - private: /// one row of event handlers table --- 60,63 ---- *************** *** 65,68 **** --- 78,83 ---- }; + private: + /// event handlers table sF tabFunc[TAB_FUNC_SIZE]; *************** *** 78,82 **** Setup& setup; ! /** Lock for enabling / disabling GC. ** Following locking order must be obeyed: ** gcLock -> DisableGC -> dataLock --- 93,97 ---- Setup& setup; ! /** Lock for enabling/disabling GC. ** Following locking order must be obeyed: ** gcLock -> DisableGC -> dataLock *************** *** 183,195 **** public: ! /** Default constructor. The constructor initializes event handlers table ** with appropriate values ( {event_type, relative_method_pointer} pairs). ** ! ** @param msetup reference to profiler setup */ ! Prof( Setup& msetup); /// Destructor. ! virtual ~Prof() { delete &setup;} /** Main fork for all received JVMPI events. For each event received by profiler --- 198,211 ---- public: ! /** Constructor. The constructor initializes event handlers table ** with appropriate values ( {event_type, relative_method_pointer} pairs). ** ! ** @param msetup reference to profiler setup ! ** @param jvmpi pointer to JVMPI interface */ ! Prof( Setup& msetup, JVMPI_Interface* jvmpi); /// Destructor. ! virtual ~Prof(); /** Main fork for all received JVMPI events. For each event received by profiler *************** *** 215,220 **** ** ** @return pointer to Class object or NULL */ ! Class* getClass(jobjectID classId, int create = 1); /** Returns corresponding Method object. --- 231,239 ---- ** ** @return pointer to Class object or NULL */ + + Class* getClass( jobjectID classId, int create = 1) { ! return activeClasses.get( classId); ! } /** Returns corresponding Method object. *************** *** 228,233 **** ** @return pointer to Method object or NULL */ ! Method* getMethod(jmethodID methodId, int create = 1); /** Returns corresponding Thread object. ** If none exists and the 'create' flag is set to 1 --- 247,255 ---- ** @return pointer to Method object or NULL */ ! Method* getMethod( jmethodID methodId, int create = 1) { + return activeMethods.get( methodId); + } + /** Returns corresponding Thread object. ** If none exists and the 'create' flag is set to 1 *************** *** 235,244 **** ** If unsuccessful in either case the NULL is returned. ** ! ** @param envId thread ID ** @param create creation flag ** ** @return pointer to Thread object or NULL */ ! Thread* getThread(JNIEnv* envId, int create = 1); /** Returns corresponding AllocTrace object. --- 257,269 ---- ** If unsuccessful in either case the NULL is returned. ** ! ** @param envId thread ID ** @param create creation flag ** ** @return pointer to Thread object or NULL */ + + Thread* getThread( JNIEnv* envId, int create = 1) { ! return activeThreads.get( envId); ! } /** Returns corresponding AllocTrace object. *************** *** 253,257 **** ** @return pointer to AllocTrace object or NULL */ ! AllocTrace* getAllocTrace(int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding AllocObject object. --- 278,282 ---- ** @return pointer to AllocTrace object or NULL */ ! AllocTrace* getAllocTrace( int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding AllocObject object. *************** *** 266,270 **** ** @return pointer to AllocObject object or NULL */ ! AllocObject* getAllocObject(jobjectID classId, jint isArray, int create = 1); /** Returns corresponding AllocObjectMethod object. --- 291,295 ---- ** @return pointer to AllocObject object or NULL */ ! AllocObject* getAllocObject( jobjectID classId, jint isArray, int create = 1); /** Returns corresponding AllocObjectMethod object. *************** *** 280,284 **** ** @return pointer to AllocObjectMethod object or NULL */ ! AllocObjectMethod* getAllocObjectMethod(jobjectID classId, jint isArray, jmethodID methodId, int create = 1); /** Returns corresponding AllocObjectTrace object. --- 305,309 ---- ** @return pointer to AllocObjectMethod object or NULL */ ! AllocObjectMethod* getAllocObjectMethod( jobjectID classId, jint isArray, jmethodID methodId, int create = 1); /** Returns corresponding AllocObjectTrace object. *************** *** 295,299 **** ** @return pointer to AllocObjectTrace object or NULL */ ! AllocObjectTrace* getAllocObjectTrace(jobjectID classId, jint isArray, int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding AllocThreadMethod object. --- 320,324 ---- ** @return pointer to AllocObjectTrace object or NULL */ ! AllocObjectTrace* getAllocObjectTrace( jobjectID classId, jint isArray, int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding AllocThreadMethod object. *************** *** 308,312 **** ** @return pointer to AllocThreadMethod object or NULL */ ! AllocThreadMethod* getAllocThreadMethod(JNIEnv* envId, jmethodID methodId, int create = 1); /** Returns corresponding AllocThreadTrace object. --- 333,337 ---- ** @return pointer to AllocThreadMethod object or NULL */ ! AllocThreadMethod* getAllocThreadMethod( JNIEnv* envId, jmethodID methodId, int create = 1); /** Returns corresponding AllocThreadTrace object. *************** *** 322,326 **** ** @return pointer to AllocThreadTrace object or NULL */ ! AllocThreadTrace* getAllocThreadTrace(JNIEnv* envId, int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding AllocThreadObject object. --- 347,351 ---- ** @return pointer to AllocThreadTrace object or NULL */ ! AllocThreadTrace* getAllocThreadTrace( JNIEnv* envId, int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding AllocThreadObject object. *************** *** 329,333 **** ** If unsuccessful in either case the NULL is returned. ** ! ** @param envId thread ID ** @param classId class ID ** @param isArray is array? --- 354,358 ---- ** If unsuccessful in either case the NULL is returned. ** ! ** @param envId thread ID ** @param classId class ID ** @param isArray is array? *************** *** 336,340 **** ** @return pointer to AllocThreadObject object or NULL */ ! AllocThreadObject* getAllocThreadObject(JNIEnv* envId, jobjectID classId, jint isArray, int create = 1); /** Returns corresponding AllocThreadObjectMethod object. --- 361,365 ---- ** @return pointer to AllocThreadObject object or NULL */ ! AllocThreadObject* getAllocThreadObject( JNIEnv* envId, jobjectID classId, jint isArray, int create = 1); /** Returns corresponding AllocThreadObjectMethod object. *************** *** 343,347 **** ** If unsuccessful in either case the NULL is returned. ** ! ** @param envId thread ID ** @param classId class ID ** @param isArray is array? --- 368,372 ---- ** If unsuccessful in either case the NULL is returned. ** ! ** @param envId thread ID ** @param classId class ID ** @param isArray is array? *************** *** 351,355 **** ** @return pointer to AllocThreadObjectMethod object or NULL */ ! AllocThreadObjectMethod* getAllocThreadObjectMethod(JNIEnv* envId, jobjectID classId, jint isArray, jmethodID methodId, int create = 1); /** Returns corresponding AllocThreadObjectTrace object. --- 376,380 ---- ** @return pointer to AllocThreadObjectMethod object or NULL */ ! AllocThreadObjectMethod* getAllocThreadObjectMethod( JNIEnv* envId, jobjectID classId, jint isArray, jmethodID methodId, int create = 1); /** Returns corresponding AllocThreadObjectTrace object. *************** *** 358,362 **** ** If unsuccessful in either case the NULL is returned. ** ! ** @param envId thread ID ** @param classId class ID ** @param isArray is array? --- 383,387 ---- ** If unsuccessful in either case the NULL is returned. ** ! ** @param envId thread ID ** @param classId class ID ** @param isArray is array? *************** *** 367,371 **** ** @return pointer to AllocThreadObjectTrace object or NULL */ ! AllocThreadObjectTrace* getAllocThreadObjectTrace(JNIEnv* envId, jobjectID classId, jint isArray, int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding CpuTrace object. --- 392,396 ---- ** @return pointer to AllocThreadObjectTrace object or NULL */ ! AllocThreadObjectTrace* getAllocThreadObjectTrace( JNIEnv* envId, jobjectID classId, jint isArray, int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding CpuTrace object. *************** *** 380,384 **** ** @return pointer to CpuTrace object or NULL */ ! CpuTrace* getCpuTrace(int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding CpuThreadMethod object. --- 405,409 ---- ** @return pointer to CpuTrace object or NULL */ ! CpuTrace* getCpuTrace( int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding CpuThreadMethod object. *************** *** 393,397 **** ** @return pointer to CpuThreadMethod object or NULL */ ! CpuThreadMethod* getCpuThreadMethod(JNIEnv* envId, jmethodID methodId, int create = 1); /** Returns corresponding CpuThreadTrace object. --- 418,422 ---- ** @return pointer to CpuThreadMethod object or NULL */ ! CpuThreadMethod* getCpuThreadMethod( JNIEnv* envId, jmethodID methodId, int create = 1); /** Returns corresponding CpuThreadTrace object. *************** *** 407,411 **** ** @return pointer to CpuThreadTrace object or NULL */ ! CpuThreadTrace* getCpuThreadTrace(JNIEnv* envId, int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding MonTrace object. --- 432,436 ---- ** @return pointer to CpuThreadTrace object or NULL */ ! CpuThreadTrace* getCpuThreadTrace( JNIEnv* envId, int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding MonTrace object. *************** *** 420,424 **** ** @return pointer to MonTrace object or NULL */ ! MonTrace* getMonTrace(int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding MonThreadMethod object. --- 445,449 ---- ** @return pointer to MonTrace object or NULL */ ! MonTrace* getMonTrace( int numFrames, JVMPI_CallFrame* frames, int create = 1); /** Returns corresponding MonThreadMethod object. *************** *** 433,437 **** ** @return pointer to MonThreadMethod object or NULL */ ! MonThreadMethod* getMonThreadMethod(JNIEnv* envId, jmethodID methodId, int create = 1); /** Returns corresponding MonThreadTrace object. --- 458,462 ---- ** @return pointer to MonThreadMethod object or NULL */ ! MonThreadMethod* getMonThreadMethod( JNIEnv* envId, jmethodID methodId, int create = 1); /** Returns corresponding MonThreadTrace object. *************** *** 447,451 **** ** @return pointer to MonThreadTrace object or NULL */ ! MonThreadTrace* getMonThreadTrace(JNIEnv* envId, int numFrames, JVMPI_CallFrame* frames, int create = 1); private: --- 472,476 ---- ** @return pointer to MonThreadTrace object or NULL */ ! MonThreadTrace* getMonThreadTrace( JNIEnv* envId, int numFrames, JVMPI_CallFrame* frames, int create = 1); private: *************** *** 807,812 **** ** ** @param infoId identifier of object having an information ! ** @param type type of information ! ** @param info pointer to output structure ** ** @return RC_OK (ok); --- 832,837 ---- ** ** @param infoId identifier of object having an information ! ** @param type type of information ! ** @param info pointer to output structure ** ** @return RC_OK (ok); *************** *** 816,822 **** ** @see getData(), getAll(), getChanged() */ ! virtual jint getInfo( objectID infoId, // in (jint) ! eInfoType type, // in (jint) ! InfoBinaryFormat*& info); // out /** Get statistic data. This method returns statistic data --- 841,847 ---- ** @see getData(), getAll(), getChanged() */ ! virtual jint getInfo( objectID infoId, // in (jint) ! eInfoType type, // in (jint) ! InfoBinaryFormat*& info); // out /** Get statistic data. This method returns statistic data *************** *** 833,839 **** ** @see getInfo(), getAll(), getChanged() */ ! virtual jint getData( objectID objId, // in (jint) ! eDataType type, // in (jint) ! sData& data); // out /** Get all objects with all statistic data. This method returns --- 858,864 ---- ** @see getInfo(), getAll(), getChanged() */ ! virtual jint getData( objectID objId, // in (jint) ! eDataType type, // in (jint) ! sData& data); // out /** Get all objects with all statistic data. This method returns *************** *** 846,852 **** ** of specified method. ** ! ** @param objId identifier of object having a data ! ** @param what specified action ! ** @param seq output sequence ** ** @return >=0 length of output sequence; --- 871,879 ---- ** of specified method. ** ! ** @param objId identifier of object having a data ! ** @param what specified action ! ** @param includeInfo include information about object ! ** @param optionalArg optional argument (depends on type of data) ! ** @param seq output sequence ** ** @return >=0 length of output sequence; *************** *** 856,863 **** ** @see getInfo(), getData(), getChanged() */ ! virtual jint getAll( objectID objId, // in (jint) ! eSeqType what, // in (jint) ! seqID& seq); // out /** Get all objects with changed statistic data. This method returns ** all statistic data of all objects of specified type, which have changed --- 883,895 ---- ** @see getInfo(), getData(), getChanged() */ ! virtual jint getAll( objectID objId, // in (jint) ! eSeqType what, // in (jint) ! jint includeInfo, // in (jint) ! jint optionalArg, // in (jint) ! seqID& seq) { // out + return getAllOrChanged( objId, what, includeInfo, optionalArg, seq, 1); + } + /** Get all objects with changed statistic data. This method returns ** all statistic data of all objects of specified type, which have changed *************** *** 866,872 **** ** If an error occurres, returned value is less than 0. ** ! ** @param objId identifier of object having a data ! ** @param what specified action ! ** @param seq output sequence ** ** @return >=0 length of output sequence; --- 898,906 ---- ** If an error occurres, returned value is less than 0. ** ! ** @param objId identifier of object having a data ! ** @param what specified action ! ** @param includeInfo include information about object ! ** @param optionalArg optional argument (depends on type of data) ! ** @param seq output sequence ** ** @return >=0 length of output sequence; *************** *** 876,883 **** ** @see getInfo(), getData(), getAll() */ ! virtual jint getChanged( objectID objId, // in (jint) ! eSeqType what, // in (jint) ! seqID& seq); // out private: --- 910,922 ---- ** @see getInfo(), getData(), getAll() */ ! virtual jint getChanged( objectID objId, // in (jint) ! eSeqType what, // in (jint) ! jint includeInfo, // in (jint) ! jint optionalArg, // in (jint) ! seqID& seq) { // out + return getAllOrChanged( objId, what, includeInfo, optionalArg, seq, 0); + } + private: *************** *** 887,890 **** --- 926,931 ---- jint getAllOrChanged( objectID objId, eSeqType what, + jint includeInfo, + jint optionalArg, seqID& seq, int all); *************** *** 892,907 **** private: - // internally used by Prof::event_threadStart() - // not documented - - static int findParent( Thread* t, void** inout); - - // internally used by Prof::event_threadStart() - // not documented - - static int findGroup( GroupThread* g, void** inout); - - private: - /** Get infoId of an object. This method returns infoId ** of an object according to seqType value. InfoId is an identifier --- 933,936 ---- *************** *** 910,914 **** ** Don't use it anywhere else. ** ! ** @param o object ** @param seqType sequence type (which an object is part of) ** --- 939,943 ---- ** Don't use it anywhere else. ** ! ** @param o object ** @param seqType sequence type (which an object is part of) ** *************** *** 921,931 **** ** data thru communication interface. ** ! ** @param dest destination ! ** @param src source ! ** @param infoId infoId of object ** ** @return pointer to destination object */ ! sID* copy( sID* dest, IdObject* src, objectID infoId); /** Get data from given list. This function template is used --- 950,961 ---- ** data thru communication interface. ** ! ** @param dest destination ! ** @param src source ! ** @param infoId infoId of object ! ** @param includeInfo include information about object ** ** @return pointer to destination object */ ! sID* copy( sID* dest, IdObject* src, objectID infoId, jint includeInfo); /** Get data from given list. This function template is used *************** *** 934,951 **** ** between library and Java. ** ! ** @param list reference to list of objects (in) ! ** @param seq reference to output sequence (out) ! ** @param all 1 = all objects; 0 = changed objects only ! ** @param st sequence type (see IProf::eSeqType) */ template<class T, class L> ! void getDataFromList( List<T,L>& list, seqID& seq, int all, eSeqType st) { T* a = list.first(); while( a) { ! if( all || a->isChanged()) { ! seq.add( copy( new sID, a, getInfoId( a, st))); a->setUnchanged(); } --- 964,990 ---- ** between library and Java. ** ! ** @param list reference to list of objects (in) ! ** @param seq reference to output sequence (out) ! ** @param all 1 = all objects; 0 = changed objects only ! ** @param st sequence type (see IProf::eSeqType) ! ** @param includeInfo include information about object ! ** @param optionalArg optional argument (depends on type of object) ! ** ! ** @see getDataFromList_filter() */ template<class T, class L> ! void getDataFromList( List<T,L>& list, ! seqID& seq, ! int all, ! eSeqType st, ! jint includeInfo, ! jint optionalArg) { T* a = list.first(); while( a) { ! if( (all || a->isChanged()) && getDataFromList_filter( a, optionalArg)) { ! seq.add( copy( new sID, a, getInfoId( a, st), includeInfo)); a->setUnchanged(); } *************** *** 955,958 **** --- 994,1030 ---- } + /** Filter useless objects. This method is used by getDataFromList() + ** template to filter some useless objects which are unimportant for + ** client's statistics. The client can specify special 'optionalArg' + ** while calling IProf::getChanged() or IProf::getAll() method. This + ** argument is dependent on type of object and its statistic information. + ** Eg. for cpu traces this argument means number of hits, so only traces + ** hitted more than or equal to the optionalArg's value are sent to client. + ** + ** @param o pointer to object + ** @param optionalArg optional argument (depends on type of object) + ** + ** @return 0 (false - filter); + ** 1 (true - do not filter) + ** + ** @see getDataFromList() */ + + int getDataFromList_filter( IdObject* o, jint optionalArg); + + /** Get information about object. This method returns information + ** in binary format (and type of information) about an object with + ** given 'infoId' identifier. + ** + ** @param infoId ID of object where info is stored + ** @param info reference to place where to store pointer to info data + ** @param infoType where to store type of information + ** + ** @return 0 (failed); + ** 1 (ok) */ + + jint getInfoBinaryFormat( objectID infoId, // in (jint) + InfoBinaryFormat*& info, // out (pointer) + jint& infoType); // out (jint) + public: *************** *** 960,971 **** ** ** @param context error context ! ** @param error error description ! ** @param file source file ! ** @param line line number */ ! ! void dumpError( const char* context, ! const char* error, ! const char* file, ! int line); private: --- 1032,1043 ---- ** ** @param context error context ! ** @param error error description ! ** @param file source file ! ** @param line line number */ ! ! static void dumpError( const char* context, ! const char* error, ! const char* file, ! int line); private: *************** *** 980,990 **** ** @return reference to Prof object */ ! static Prof& prof(); /** Creates static instance of Prof class. ** ** @return pointer to newly created object */ ! static Prof* create( char* options); /** Destroys profiler Prof object. It is called --- 1052,1065 ---- ** @return reference to Prof object */ ! static Prof& prof() { return *_prof;} /** Creates static instance of Prof class. ** + ** @param options command-line options + ** @param jvmpi pointer to JVMPI interface + ** ** @return pointer to newly created object */ ! static Prof* create( char* options, JVMPI_Interface* jvmpi); /** Destroys profiler Prof object. It is called *************** *** 1002,1014 **** ** @see JVM_OnLoad(), JVMPI specification */ ! static void notifyEvent( JVMPI_Event* event); ! }; ! #ifdef PROF_ERROR_ON ! #define PROF_ERROR(context, error) prof.dumpError(context, error, __FILE__, __LINE__) ! #else // PROF_ERROR_ON ! #define PROF_ERROR(context, error) ! #endif // PROF_ERROR_ON ! #endif // _PROF_H_ --- 1077,1093 ---- ** @see JVM_OnLoad(), JVMPI specification */ ! static void notifyEvent( JVMPI_Event* event) { ! if( _prof) _prof->runEvent( event); ! } ! private: + // internally used by event_threadStart() method + // not documented + + static int findParent( Thread* t, void** inout); + static int findGroup( GroupThread* g, void** inout); + }; + + #endif // _PROF_H_ Index: prof_arena.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof_arena.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** prof_arena.cpp 2001/09/02 20:14:22 1.9 --- prof_arena.cpp 2001/11/21 22:31:44 1.10 *************** *** 33,37 **** */ ! #include "../main/includes.h" void Prof::event_arenaNew( JVMPI_Event* event) { --- 33,41 ---- */ ! #include "../prof/prof.h" ! #include "../prof/synchronized.h" ! #include "../alloc/allocArena.h" ! #include "../alloc/allocInstance.h" ! #include "../alloc/allocAbstractStatThreadObject.h" void Prof::event_arenaNew( JVMPI_Event* event) { *************** *** 48,52 **** void Prof::event_arenaDelete( JVMPI_Event* event) { ! jint arena_id = event->u.delete_arena.arena_id; --- 52,56 ---- void Prof::event_arenaDelete( JVMPI_Event* event) { ! jint arena_id = event->u.delete_arena.arena_id; Index: prof_class.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof_class.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** prof_class.cpp 2001/09/02 20:14:22 1.10 --- prof_class.cpp 2001/11/21 22:31:44 1.11 *************** *** 33,37 **** */ ! #include "../main/includes.h" void Prof::event_classLoad( JVMPI_Event* event) { --- 33,39 ---- */ ! #include "../prof/prof.h" ! #include "../shared/classField.h" ! #include "../prof/synchronized.h" void Prof::event_classLoad( JVMPI_Event* event) { *************** *** 42,45 **** --- 44,63 ---- if( !event->u.class_load.class_id) return; + static int firstTime = 1; + if( firstTime) { + + jvmpiInterface->EnableEvent( JVMPI_EVENT_CLASS_UNLOAD, NULL); + + if( setup.alloc.turnedOn) jvmpiInterface->EnableEvent( JVMPI_EVENT_OBJECT_ALLOC, NULL); + + if( setup.cpu.turnedOn && !setup.cpu.sampling) + jvmpiInterface->EnableEvent( JVMPI_EVENT_METHOD_ENTRY, NULL); + + if( setup.mon.turnedOn) + jvmpiInterface->EnableEvent( JVMPI_EVENT_MONITOR_CONTENDED_ENTER, NULL); + + firstTime = 0; + } + Class* c = new Class; *************** *** 107,111 **** Synchronized sync( dataLock); ! Class* c = getClass(event->u.class_unload.class_id, 0); if( c) c->deactivate(); --- 125,129 ---- Synchronized sync( dataLock); ! Class* c = getClass(event->u.class_unload.class_id, 0); if( c) c->deactivate(); Index: prof_gc.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof_gc.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** prof_gc.cpp 2001/09/02 20:14:22 1.8 --- prof_gc.cpp 2001/11/21 22:31:44 1.9 *************** *** 33,37 **** */ ! #include "../main/includes.h" void Prof::event_gcStart( JVMPI_Event* event) { --- 33,38 ---- */ ! #include "../prof/prof.h" ! #include "../gc/gc.h" void Prof::event_gcStart( JVMPI_Event* event) { *************** *** 40,43 **** --- 41,57 ---- dataLock.wait(); + static int firstTime = 1; + if( firstTime) { + + jvmpiInterface->EnableEvent( JVMPI_EVENT_GC_FINISH, NULL); + + jvmpiInterface->EnableEvent( JVMPI_EVENT_OBJECT_FREE, NULL); + jvmpiInterface->EnableEvent( JVMPI_EVENT_OBJECT_MOVE, NULL); + + jvmpiInterface->EnableEvent( JVMPI_EVENT_ARENA_DELETE, NULL); + + firstTime = 0; + } + GC* gc = new GC; gc->startTime = time( NULL); *************** *** 47,51 **** void Prof::event_gcFinish( JVMPI_Event* event) { ! GC* gc = gcStat.first(); --- 61,65 ---- void Prof::event_gcFinish( JVMPI_Event* event) { ! GC* gc = gcStat.first(); Index: prof_get.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof_get.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** prof_get.cpp 2001/09/02 20:14:22 1.7 --- prof_get.cpp 2001/11/21 22:31:44 1.8 *************** *** 33,53 **** */ ! #include "../main/includes.h" - Class* Prof::getClass(jobjectID classId, int create) { - - return activeClasses.get(classId); - } - - Method* Prof::getMethod(jmethodID methodId, int create) { - - return activeMethods.get(methodId); - } - - Thread* Prof::getThread(JNIEnv* envId, int create) { - - return activeThreads.get(envId); - } - CpuTrace* Prof::getCpuTrace(int numFrames, JVMPI_CallFrame* frames, int create) { --- 33,54 ---- */ ! #include "../prof/prof.h" ! #include "../cpu/cpuTrace.h" ! #include "../shared/traceFrame.h" ! #include "../cpu/cpuThreadMethod.h" ! #include "../cpu/cpuThreadTrace.h" ! #include "../alloc/allocTrace.h" ! #include "../alloc/allocObject.h" ! #include "../alloc/allocObjectMethod.h" ! #include "../alloc/allocObjectTrace.h" ! #include "../alloc/allocThreadMethod.h" ! #include "../alloc/allocThreadTrace.h" ! #include "../alloc/allocThreadObject.h" ! #include "../alloc/allocThreadObjectMethod.h" ! #include "../alloc/allocThreadObjectTrace.h" ! #include "../mon/monTrace.h" ! #include "../mon/monThreadMethod.h" ! #include "../mon/monThreadTrace.h" CpuTrace* Prof::getCpuTrace(int numFrames, JVMPI_CallFrame* frames, int create) { *************** *** 524,526 **** return threadTrace; } - --- 525,526 ---- Index: prof_jniref.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof_jniref.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** prof_jniref.cpp 2001/09/02 20:14:22 1.6 --- prof_jniref.cpp 2001/11/21 22:31:44 1.7 *************** *** 33,37 **** */ ! #include "../main/includes.h" void Prof::event_jniGlobalrefAlloc( JVMPI_Event* event) { --- 33,40 ---- */ ! #include "../prof/prof.h" ! #include "../prof/synchronized.h" ! #include "../alloc/allocInstance.h" ! #include "../alloc/allocGlobalRef.h" void Prof::event_jniGlobalrefAlloc( JVMPI_Event* event) { *************** *** 42,45 **** --- 45,55 ---- if( !ins) return; + static int firstTime = 1; + if( firstTime) { + + jvmpiInterface->EnableEvent( JVMPI_EVENT_JNI_GLOBALREF_FREE, NULL); + firstTime = 0; + } + AllocGlobalRef* r = new AllocGlobalRef; r->instance = ins; *************** *** 66,69 **** --- 76,86 ---- AllocInstance* ins = instances.get( event->u.jni_globalref_alloc.obj_id); if( !ins) return; + + static int firstTime = 1; + if( firstTime) { + + jvmpiInterface->EnableEvent( JVMPI_EVENT_JNI_WEAK_GLOBALREF_FREE, NULL); + firstTime = 0; + } AllocGlobalRef* r = new AllocGlobalRef; Index: prof_jvm.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof_jvm.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** prof_jvm.cpp 2001/09/18 22:19:29 1.22 --- prof_jvm.cpp 2001/11/21 22:31:44 1.23 *************** *** 33,43 **** */ ! #include "../main/includes.h" #ifdef _DEBUG static int printMethod( Method* m, void**) { cout << m->methodName << " SIGN = " << m->methodSignature << endl; - return 0; } --- 33,60 ---- */ ! #include "../prof/prof.h" ! #include "../delay/delay.h" #ifdef _DEBUG + + #include "../shared/classField.h" + #include "../shared/groupThread.h" + #include "../alloc/allocArena.h" + #include "../alloc/allocObject.h" + #include "../alloc/allocTrace.h" + #include "../shared/traceFrame.h" + #include "../alloc/allocInstance.h" + #include "../gc/gc.h" + #include "../alloc/allocGlobalRef.h" + #include "../alloc/allocObjectMethod.h" + #include "../alloc/allocThreadObject.h" + #include "../alloc/allocThreadObjectMethod.h" + #include "../alloc/allocThreadMethod.h" + #include "../cpu/cpuThreadMethod.h" + #include "../mon/monThreadMethod.h" + static int printMethod( Method* m, void**) { cout << m->methodName << " SIGN = " << m->methodSignature << endl; return 0; } *************** *** 46,50 **** cout << f->fieldName << " SIGN = " << f->fieldSignature << endl; - return 0; } --- 63,66 ---- *************** *** 72,76 **** cout << t->threadName << " : " << (long)(t->threadEnvId) << endl; - return 0; } --- 88,91 ---- *************** *** 88,92 **** cout << "ARENA = " << a->arenaName << endl << endl; - return 0; } --- 103,106 ---- *************** *** 416,440 **** cout << endl; } ! ! #endif void Prof::event_jvmInitDone( JVMPI_Event* event) { if( setup.cpu.turnedOn && setup.cpu.sampling) sampling.startThread( 1); jvmpiInterface->CreateSystemThread( (char*)COMMUN_THREAD, ! JVMPI_NORMAL_PRIORITY, ! Prof::communThreadRoutine); } void Prof::event_jvmShutDown( JVMPI_Event* event) { - Synchronized sync1( communLock, 0); - Synchronized sync2( dataLock, 0); - if( isConnectionEstablished()) { ! sync1.enter(); ! sync2.enter(); } --- 430,460 ---- cout << endl; } ! #endif // _DEBUG void Prof::event_jvmInitDone( JVMPI_Event* event) { + // enable some curious events ;-) + + jvmpiInterface->EnableEvent( JVMPI_EVENT_THREAD_START, NULL); + jvmpiInterface->EnableEvent( JVMPI_EVENT_CLASS_LOAD, NULL); + + if( setup.alloc.turnedOn) jvmpiInterface->EnableEvent( JVMPI_EVENT_ARENA_NEW, NULL); + + jvmpiInterface->EnableEvent ( JVMPI_EVENT_JVM_SHUT_DOWN, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_JVM_INIT_DONE, NULL); + if( setup.cpu.turnedOn && setup.cpu.sampling) sampling.startThread( 1); jvmpiInterface->CreateSystemThread( (char*)COMMUN_THREAD, ! JVMPI_NORMAL_PRIORITY, ! Prof::communThreadRoutine); } void Prof::event_jvmShutDown( JVMPI_Event* event) { if( isConnectionEstablished()) { ! communLock.wait(); ! dataLock.wait(); } *************** *** 444,450 **** if( isConnectionEstablished()) { ! sync1.release(); shutdownLock.wait(); ! sync1.enter(); } else communThreadEnd = 1; --- 464,470 ---- if( isConnectionEstablished()) { ! communLock.release(); shutdownLock.wait(); ! communLock.wait(); } else communThreadEnd = 1; *************** *** 464,468 **** #endif Prof::destroy(); ! exit( 0); } --- 484,528 ---- #endif + // that's amazing ! must be called in reverse order ;-) + + jvmpiInterface->DisableEvent( JVMPI_EVENT_CLASS_UNLOAD, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_CLASS_LOAD, NULL); + + jvmpiInterface->DisableEvent( JVMPI_EVENT_METHOD_EXIT, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_METHOD_ENTRY, NULL); + + jvmpiInterface->DisableEvent( JVMPI_EVENT_THREAD_END, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_THREAD_START, NULL); + + jvmpiInterface->DisableEvent( JVMPI_EVENT_GC_FINISH, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_GC_START, NULL); + + jvmpiInterface->DisableEvent( JVMPI_EVENT_ARENA_DELETE, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_ARENA_NEW, NULL); + + jvmpiInterface->DisableEvent( JVMPI_EVENT_OBJECT_FREE, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_OBJECT_MOVE, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_OBJECT_ALLOC, NULL); + + jvmpiInterface->DisableEvent( JVMPI_EVENT_JNI_GLOBALREF_FREE, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_JNI_GLOBALREF_ALLOC, NULL); + + jvmpiInterface->DisableEvent( JVMPI_EVENT_JNI_WEAK_GLOBALREF_FREE, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_JNI_WEAK_GLOBALREF_ALLOC, NULL); + + jvmpiInterface->DisableEvent( JVMPI_EVENT_MONITOR_WAITED, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_MONITOR_CONTENDED_ENTERED, NULL); + jvmpiInterface->DisableEvent( JVMPI_EVENT_MONITOR_CONTENDED_ENTER, NULL); + + jvmpiInterface->DisableEvent( JVMPI_EVENT_JVM_SHUT_DOWN, NULL); + + dataLock.release(); + + while( !sampling.isTerminated()) Delay::delay( 10); + Delay::delay( 1000); + + dataLock.wait(); + Prof::destroy(); ! exit( 0); // for sure } Index: prof_method.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof_method.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** prof_method.cpp 2001/09/02 20:14:22 1.6 --- prof_method.cpp 2001/11/21 22:31:44 1.7 *************** *** 33,37 **** */ ! #include "../main/includes.h" void Prof::event_methodEntry( JVMPI_Event* event) { --- 33,41 ---- */ ! #include "../prof/prof.h" ! #include "../prof/synchronized.h" ! #include "../cpu/cpuThreadMethod.h" ! #include "../cpu/cpuThreadTrace.h" ! #include "../cpu/cpuTrace.h" void Prof::event_methodEntry( JVMPI_Event* event) { *************** *** 39,44 **** Synchronized sync(dataLock); - // cerr << "METHOD ENTRY: " << (long)(event->env_id) << endl; - jlong entryTime; JVMPI_CallFrame callFrame; --- 43,46 ---- *************** *** 51,54 **** --- 53,57 ---- jvmpiInterface->GetCallTrace(&callTrace, (jint)1); + if (callTrace.num_frames != (jint)1) { PROF_ERROR("METHOD ENTRY", "GetCallTrace failed"); *************** *** 67,70 **** --- 70,80 ---- entryTime = jvmpiInterface->GetCurrentThreadCpuTime(); thread->stack.push(callFrame, entryTime); + + static int firstTime = 1; + if( firstTime) { + + jvmpiInterface->EnableEvent( JVMPI_EVENT_METHOD_EXIT, NULL); + firstTime = 0; + } } *************** *** 72,77 **** Synchronized sync(dataLock); - - // cerr << "METHOD EXIT: " << (long)(event->env_id) << endl; Thread* thread; --- 82,85 ---- Index: prof_monitor.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof_monitor.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** prof_monitor.cpp 2001/09/02 20:14:22 1.3 --- prof_monitor.cpp 2001/11/21 22:31:44 1.4 *************** *** 33,37 **** */ ! #include "../main/includes.h" void Prof::event_monitorContendedEnter( JVMPI_Event* event) { --- 33,42 ---- */ ! #include "../prof/prof.h" ! #include "../prof/synchronized.h" ! #include "../delay/delay.h" ! #include "../mon/monThreadMethod.h" ! #include "../mon/monThreadTrace.h" ! #include "../mon/monTrace.h" void Prof::event_monitorContendedEnter( JVMPI_Event* event) { *************** *** 39,44 **** Synchronized sync(dataLock); - // cerr << "MONITOR CONTENDED ENTER: " << (long)(event->env_id) << endl; - Thread* t; if (!(t = getThread(event->env_id))) { --- 44,47 ---- *************** *** 47,50 **** --- 50,62 ---- } + static int firstTime = 1; + if( firstTime) { + + jvmpiInterface->EnableEvent( JVMPI_EVENT_MONITOR_CONTENDED_ENTERED, NULL); + jvmpiInterface->EnableEvent( JVMPI_EVENT_MONITOR_WAITED, NULL); + + firstTime = 0; + } + t->monitorEnter = 1; t->monitorEnterObject = event->u.monitor.object; *************** *** 56,61 **** Synchronized sync(dataLock); - // cerr << "MONITOR CONTENDED ENTERED: " << (long)(event->env_id) << endl; - Thread* t; if (!(t = getThread(event->env_id))) { --- 68,71 ---- *************** *** 134,139 **** Synchronized sync(dataLock); - - // cerr << "MONITOR WAITED: " << (long)(event->env_id) << endl; Thread* t; --- 144,147 ---- Index: prof_object.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof_object.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** prof_object.cpp 2001/09/02 20:14:22 1.15 --- prof_object.cpp 2001/11/21 22:31:45 1.16 *************** *** 33,37 **** */ ! #include "../main/includes.h" void Prof::event_objectAlloc( JVMPI_Event* event) { --- 33,46 ---- */ ! #include "../prof/prof.h" ! #include "../prof/synchronized.h" ! #include "../alloc/allocThreadObject.h" ! #include "../alloc/allocObject.h" ! #include "../alloc/allocThreadObjectMethod.h" ! #include "../alloc/allocObjectMethod.h" ! #include "../alloc/allocThreadObjectTrace.h" ! #include "../alloc/allocObjectTrace.h" ! #include "../alloc/allocInstance.h" ! #include "../alloc/allocArena.h" void Prof::event_objectAlloc( JVMPI_Event* event) { *************** *** 102,106 **** } else { - JVMPI_CallTrace trace; JVMPI_CallFrame frames[MAX_TRACE]; --- 111,114 ---- *************** *** 134,137 **** --- 142,156 ---- } + static int firstTime = 1; + if( firstTime) { + + jvmpiInterface->EnableEvent( JVMPI_EVENT_GC_START, NULL); + + jvmpiInterface->EnableEvent( JVMPI_EVENT_JNI_GLOBALREF_ALLOC, NULL); + jvmpiInterface->EnableEvent( JVMPI_EVENT_JNI_WEAK_GLOBALREF_ALLOC, NULL); + + firstTime = 0; + } + AllocInstance* instance = unusedInstances.first(); if (instance) unusedInstances.remove(instance); *************** *** 170,174 **** void Prof::event_objectMove( JVMPI_Event* event) { ! jobjectID obj_id = event->u.obj_move.obj_id; AllocInstance* ins = instances.get( obj_id); --- 189,193 ---- void Prof::event_objectMove( JVMPI_Event* event) { ! jobjectID obj_id = event->u.obj_move.obj_id; AllocInstance* ins = instances.get( obj_id); *************** *** 200,204 **** } ! instances.removeNoRehash(ins); if( ins->arena) ins->arena->instances.remove( ins); --- 219,223 ---- } ! instances.removeNoRehash(ins); if( ins->arena) ins->arena->instances.remove( ins); Index: prof_thread.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/prof_thread.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** prof_thread.cpp 2001/09/02 20:14:22 1.13 --- prof_thread.cpp 2001/11/21 22:31:46 1.14 *************** *** 33,37 **** */ ! #include "../main/includes.h" int Prof::findParent( Thread* t, void** inout) { --- 33,39 ---- */ ! #include "../prof/prof.h" ! #include "../shared/groupThread.h" ! #include "../prof/synchronized.h" int Prof::findParent( Thread* t, void** inout) { *************** *** 62,67 **** if( !(event->event_type & JVMPI_REQUESTED_EVENT)) sync.enter(); - // cerr << "THREAD START: " << (long)(event->u.thread_start.thread_env_id) << " " << event->u.thread_start.thread_name << endl; - JNIEnv* envId = event->u.thread_start.thread_env_id; char* name = event->u.thread_start.thread_name; --- 64,67 ---- *************** *** 71,74 **** --- 71,81 ---- if (strcmp(name, SAMPLING_THREAD) == 0) return; + static int firstTime = 1; + if( firstTime) { + + jvmpiInterface->EnableEvent( JVMPI_EVENT_THREAD_END, NULL); + firstTime = 0; + } + Thread* t = new Thread; *************** *** 109,114 **** Synchronized sync( dataLock); - - // cerr << "THREAD END: " << (long)(event->env_id) << endl; Thread* t = getThread(event->env_id, 0); --- 116,119 ---- Index: synchronized.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/prof/synchronized.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** synchronized.h 2001/09/02 20:14:22 1.5 --- synchronized.h 2001/11/21 22:31:49 1.6 *************** *** 36,39 **** --- 36,42 ---- #define _SYNCHRONIZED_H_ + #include "../main/includes.h" + #include "../prof/lock.h" + /** Implementation of easy-to-use synchronization. This class gave its name ** after JTCSynchronized class used in JTC (OOC JavaThreads for C++) library, *************** *** 106,108 **** #endif // _SYNCHRONIZED_H_ - --- 109,110 ---- |