From: Marek P. <ma...@us...> - 2001-11-21 22:31:54
|
Update of /cvsroot/javaprofiler/library/src/shared In directory usw-pr-cvs1:/tmp/cvs-serv12170/src/shared Modified Files: Makefile.rules class.cpp class.h classField.cpp classField.h dir.info groupThread.h method.cpp method.h thread.cpp thread.h trace.cpp trace.h traceFrame.cpp traceFrame.h Added Files: groupThread.cpp traceKey.h Log Message: some parts completely rewritten; changes in communication interface to make it faster; ported to linux --- NEW FILE: groupThread.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 "../shared/groupThread.h" Buffer& GroupThread::infoToBin( Buffer& b) { b += groupName; return b; } --- NEW FILE: traceKey.h --- /* * 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. */ #ifndef _TRACE_KEY_H_ #define _TRACE_KEY_H_ #include "../main/includes.h" #include "../main/const.h" /** Key for Trace class. ** Used for searching in hash tables. ** ** @author Petr Luner */ struct TraceKey { private: /// internally used frames JVMPI_CallFrame _frames[MAX_TRACE]; public: /// number of call frames int numFrames; /// call frames JVMPI_CallFrame* frames; /// Initialization. TraceKey() : frames( _frames) {} }; #endif // _TRACE_KEY_H_ Index: Makefile.rules =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/Makefile.rules,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** Makefile.rules 2001/07/28 04:11:17 1.4 --- Makefile.rules 2001/11/21 22:31:50 1.5 *************** *** 1,23 **** class.o \ ! class.obj: class.cpp ../main/includes.h $(CCC) $(CPPFLAGS) class.cpp classField.o \ ! classField.obj: classField.cpp ../main/includes.h $(CCC) $(CPPFLAGS) classField.cpp method.o \ ! method.obj: method.cpp ../main/includes.h $(CCC) $(CPPFLAGS) method.cpp trace.o \ ! trace.obj: trace.cpp ../main/includes.h $(CCC) $(CPPFLAGS) trace.cpp thread.o \ ! thread.obj: thread.cpp ../main/includes.h $(CCC) $(CPPFLAGS) thread.cpp traceFrame.o \ ! traceFrame.obj: traceFrame.cpp ../main/includes.h $(CCC) $(CPPFLAGS) traceFrame.cpp --- 1,27 ---- class.o \ ! class.obj: class.cpp $(CCC) $(CPPFLAGS) class.cpp classField.o \ ! classField.obj: classField.cpp $(CCC) $(CPPFLAGS) classField.cpp method.o \ ! method.obj: method.cpp $(CCC) $(CPPFLAGS) method.cpp trace.o \ ! trace.obj: trace.cpp $(CCC) $(CPPFLAGS) trace.cpp thread.o \ ! thread.obj: thread.cpp $(CCC) $(CPPFLAGS) thread.cpp traceFrame.o \ ! traceFrame.obj: traceFrame.cpp $(CCC) $(CPPFLAGS) traceFrame.cpp + + groupThread.o \ + groupThread.obj: groupThread.cpp + $(CCC) $(CPPFLAGS) groupThread.cpp Index: class.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/class.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** class.cpp 2001/09/18 22:19:29 1.4 --- class.cpp 2001/11/21 22:31:51 1.5 *************** *** 33,40 **** */ ! #include "../main/includes.h" - Allocator Class::_allocator( sizeof( Class)); - Buffer& Class::infoToBin( Buffer& b) { --- 33,44 ---- */ ! #include "../shared/class.h" ! #include "../prof/prof.h" ! #include "../alloc/allocObject.h" ! ! #ifdef USE_ALLOCATOR ! Allocator Class::_allocator; ! #endif Buffer& Class::infoToBin( Buffer& b) { *************** *** 61,66 **** } } - - - - \ No newline at end of file --- 65,66 ---- Index: class.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/class.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** class.h 2001/09/02 20:14:22 1.15 --- class.h 2001/11/21 22:31:51 1.16 *************** *** 36,39 **** --- 36,50 ---- #define _CLASS_H_ + #include "../main/includes.h" + #include "../list/listItem.h" + #include "../commun2/idObject.h" + #include "../commun/binaryFormat.h" + #include "../string/string.h" + #include "../list/list.h" + #include "../shared/method.h" + #include "../shared/classField.h" + #include "../commun/buffer.h" + #include "../allocator/allocator.h" + /** Java class. This class consists of data aquired ** by receiving a JVMPI_EVENT_CLASS_LOAD event. There *************** *** 47,52 **** ** @author Marek Przeczek, Petr Luner */ ! class Class: public LI1, public LI2, ! public IdObject, public InfoBinaryFormat { public: --- 58,65 ---- ** @author Marek Przeczek, Petr Luner */ ! class Class: public LI1, ! public LI2, ! public IdObject, ! public InfoBinaryFormat { public: *************** *** 103,124 **** allocObject( NULL), allocObjectArray( NULL) ! {}; /** Retrieves object's key. ** ! ** @param key where to store the key ** @return key ** ** @see Hash */ ! const jobjectID& getKey(jobjectID& key) { ! ! return key = classId; ! } /** Compares object with given key. ** ** @param key key ** @return 1 (true); ** 0 (false) --- 116,139 ---- allocObject( NULL), allocObjectArray( NULL) + + {} ! /// Destructor. ! virtual ~Class() {} /** Retrieves object's key. ** ! ** @param key where to store the key ! ** ** @return key ** ** @see Hash */ ! const jobjectID& getKey(jobjectID& key) { return key = classId;} /** Compares object with given key. ** ** @param key key + ** ** @return 1 (true); ** 0 (false) *************** *** 126,143 **** ** @see Hash */ ! int operator==(const jobjectID& key) { ! ! return (classId == key); ! } /** Hash function. ** ! ** @param reference to a key ** @return hash value */ - - static int hashKey(const jobjectID& key) { ! return (int)key; ! } /** Convert info to binary. This method converts information --- 141,153 ---- ** @see Hash */ ! int operator==(const jobjectID& key) { return (classId == key);} /** Hash function. ** ! ** @param key reference to a key ! ** ** @return hash value */ ! static int hashKey(const jobjectID& key) { return (int)key;} /** Convert info to binary. This method converts information *************** *** 155,158 **** --- 165,169 ---- void deactivate(); + #ifdef USE_ALLOCATOR private: *************** *** 164,172 **** /** Overloaded new() operator. */ ! void* operator new( size_t) { return _allocator.get();} /** Overloaded delete() operator. */ void operator delete( void* unit) { _allocator.put( unit);} public: --- 175,184 ---- /** Overloaded new() operator. */ ! void* operator new( size_t sz) { return _allocator.get( sz);} /** Overloaded delete() operator. */ void operator delete( void* unit) { _allocator.put( unit);} + #endif public: *************** *** 174,178 **** /** Class identification. ** ! ** @return unique class type identified */ virtual eClassIdent getClassIdent() { return CLASS;} --- 186,190 ---- /** Class identification. ** ! ** @return unique class type identifier */ virtual eClassIdent getClassIdent() { return CLASS;} Index: classField.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/classField.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** classField.cpp 2001/09/02 20:14:22 1.2 --- classField.cpp 2001/11/21 22:31:51 1.3 *************** *** 33,37 **** */ ! #include "../main/includes.h" ! Allocator ClassField::_allocator( sizeof( ClassField)); --- 33,47 ---- */ ! #include "../shared/classField.h" ! #ifdef USE_ALLOCATOR ! Allocator ClassField::_allocator; ! #endif ! ! Buffer& ClassField::infoToBin( Buffer& b) { ! ! b += fieldName; ! b += fieldSignature; ! ! return b; ! } Index: classField.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/classField.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** classField.h 2001/09/02 20:14:22 1.11 --- classField.h 2001/11/21 22:31:51 1.12 *************** *** 36,39 **** --- 36,47 ---- #define _CLASS_FIELD_H_ + #include "../main/includes.h" + #include "../list/listItem.h" + #include "../commun2/idObject.h" + #include "../commun/binaryFormat.h" + #include "../string/string.h" + #include "../commun/buffer.h" + #include "../allocator/allocator.h" + /** Class field. This class consists of data about ** a field defined in a Java class. This data is gained *************** *** 44,49 **** ** @author Marek Przeczek */ ! class ClassField: public LI1, public IdObject, ! public InfoBinaryFormat { public: --- 52,58 ---- ** @author Marek Przeczek */ ! class ClassField: public LI1, ! public IdObject, ! public InfoBinaryFormat { public: *************** *** 56,59 **** --- 65,74 ---- public: + /// Default constructor. + ClassField() {} + + /// Destructor. + virtual ~ClassField() {} + /** Convert info to binary. This method converts information ** data to binary format in which it is sent thru communication *************** *** 63,75 **** ** ** @return reference to same Buffer object as argument 'b' */ - - virtual Buffer& infoToBin( Buffer& b) { - - b += fieldName; - b += fieldSignature; ! return b; ! } private: --- 78,85 ---- ** ** @return reference to same Buffer object as argument 'b' */ ! virtual Buffer& infoToBin( Buffer& b); + #ifdef USE_ALLOCATOR private: *************** *** 81,89 **** /** Overloaded new() operator. */ ! void* operator new( size_t) { return _allocator.get();} /** Overloaded delete() operator. */ void operator delete( void* unit) { _allocator.put( unit);} public: --- 91,100 ---- /** Overloaded new() operator. */ ! void* operator new( size_t sz) { return _allocator.get( sz);} /** Overloaded delete() operator. */ void operator delete( void* unit) { _allocator.put( unit);} + #endif public: *************** *** 91,95 **** /** Class identification. ** ! ** @return unique class type identified */ virtual eClassIdent getClassIdent() { return CLASS_FIELD;} --- 102,106 ---- /** Class identification. ** ! ** @return unique class type identifier */ virtual eClassIdent getClassIdent() { return CLASS_FIELD;} Index: dir.info =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/dir.info,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** dir.info 2001/07/28 04:11:17 1.5 --- dir.info 2001/11/21 22:31:51 1.6 *************** *** 1,3 **** ! FILES = class classField method thread trace traceFrame ! CLEAN_FILES = *.pdb *.obj *.o --- 1,2 ---- ! FILES = class classField groupThread method thread trace traceFrame CLEAN_FILES = *.pdb *.obj *.o Index: groupThread.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/groupThread.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** groupThread.h 2001/09/02 20:14:22 1.9 --- groupThread.h 2001/11/21 22:31:51 1.10 *************** *** 36,39 **** --- 36,48 ---- #define _GROUP_THREAD_H_ + #include "../main/includes.h" + #include "../list/listItem.h" + #include "../commun2/idObject.h" + #include "../commun/binaryFormat.h" + #include "../string/string.h" + #include "../list/list.h" + #include "../shared/thread.h" + #include "../commun/buffer.h" + /** Group of threads. This class consists of data aquired ** by receiving the JVMPI_EVENT_THREAD_START event. *************** *** 43,48 **** ** @author Marek Przeczek */ ! class GroupThread: public LI1, public IdObject, ! public InfoBinaryFormat { public: --- 52,58 ---- ** @author Marek Przeczek */ ! class GroupThread: public LI1, ! public IdObject, ! public InfoBinaryFormat { public: *************** *** 55,58 **** --- 65,74 ---- public: + /// Default constructor. + GroupThread() {} + + /// Destructor. + virtual ~GroupThread() {} + /** Convert info to binary. This method converts information ** data to binary format in which it is sent thru communication *************** *** 62,72 **** ** ** @return reference to same Buffer object as argument 'b' */ - - virtual Buffer& infoToBin( Buffer& b) { - - b += groupName; ! return b; ! } public: --- 78,83 ---- ** ** @return reference to same Buffer object as argument 'b' */ ! virtual Buffer& infoToBin( Buffer& b); public: *************** *** 74,78 **** /** Class identification. ** ! ** @return unique class type identified */ virtual eClassIdent getClassIdent() { return GROUP_THREAD;} --- 85,89 ---- /** Class identification. ** ! ** @return unique class type identifier */ virtual eClassIdent getClassIdent() { return GROUP_THREAD;} Index: method.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/method.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** method.cpp 2001/09/18 22:19:29 1.13 --- method.cpp 2001/11/21 22:31:51 1.14 *************** *** 33,40 **** */ ! #include "../main/includes.h" - Allocator Method::_allocator( sizeof( Method)); - Buffer& Method::infoToBin( Buffer& b) { --- 33,50 ---- */ ! #include "../shared/method.h" ! #include "../shared/class.h" ! #include "../prof/prof.h" ! #include "../alloc/allocThreadMethod.h" ! #include "../cpu/cpuThreadMethod.h" ! #include "../mon/monThreadMethod.h" ! #include "../alloc/allocTrace.h" ! #include "../cpu/cpuTrace.h" ! #include "../mon/monTrace.h" ! ! #ifdef USE_ALLOCATOR ! Allocator Method::_allocator; ! #endif Buffer& Method::infoToBin( Buffer& b) { *************** *** 69,73 **** mtm = monThreadMethods.next(mtm); } ! AllocTrace* at = allocTraces.first(); while (at) { --- 79,83 ---- mtm = monThreadMethods.next(mtm); } ! AllocTrace* at = allocTraces.first(); while (at) { *************** *** 87,89 **** --- 97,120 ---- mt = monTraces.next(mt); } + } + + int Method::isActive() { + + return (clss) ? clss->isActive() : 1; + } + + int Method::isChanged() { + + return (activeChanged() || + AllocStatData::dataChanged() || + CpuStatData::dataChanged() || + MonStatData::dataChanged()); // order dependent ! + } + + void Method::setUnchanged() { + + IdObject::setUnchanged(); + AllocStatData::clearDataChanged(); + CpuStatData::clearDataChanged(); + MonStatData::clearDataChanged(); } Index: method.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/method.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** method.h 2001/09/02 20:14:22 1.20 --- method.h 2001/11/21 22:31:51 1.21 *************** *** 36,39 **** --- 36,58 ---- #define _METHOD_H_ + #include "../main/includes.h" + #include "../list/listItem.h" + #include "../commun2/idObject.h" + #include "../alloc/allocStatData.h" + #include "../cpu/cpuStatData.h" + #include "../mon/monStatData.h" + #include "../commun/binaryFormat.h" + #include "../string/string.h" + #include "../list/list.h" + #include "../alloc/allocTrace.h" + #include "../alloc/allocObjectMethod.h" + #include "../alloc/allocThreadMethod.h" + #include "../cpu/cpuTrace.h" + #include "../cpu/cpuThreadMethod.h" + #include "../mon/monTrace.h" + #include "../mon/monThreadMethod.h" + #include "../commun/buffer.h" + #include "../allocator/allocator.h" + /** Java method. This class consists of data about ** loaded Java method (gained by receiving *************** *** 44,53 **** ** @author Marek Przeczek, Petr Luner */ ! class Method: public IdObject, ! public LI1, public LI2, ! public AllocStatData, ! public CpuStatData, ! public MonStatData, ! public InfoBinaryFormat { public: --- 63,73 ---- ** @author Marek Przeczek, Petr Luner */ ! class Method: public LI1, ! public LI2, ! public IdObject, ! public AllocStatData, ! public CpuStatData, ! public MonStatData, ! public InfoBinaryFormat { public: *************** *** 103,121 **** {} /** Retrieves object's key. ** ! ** @param key where to store the key ** @return key ** ** @see Hash */ ! const jmethodID& getKey(jmethodID& key) { ! ! return key = methodId; ! } /** Compares object with given key. ** ** @param key key ** @return 1 (true); ** 0 (false) --- 123,143 ---- {} + /// Destructor. + virtual ~Method() {} + /** Retrieves object's key. ** ! ** @param key where to store the key ! ** ** @return key ** ** @see Hash */ ! const jmethodID& getKey(jmethodID& key) { return key = methodId;} /** Compares object with given key. ** ** @param key key + ** ** @return 1 (true); ** 0 (false) *************** *** 123,140 **** ** @see Hash */ ! int operator==(const jmethodID& key) { ! ! return (methodId == key); ! } /** Hash function. ** ! ** @param reference to a key ** @return hash value */ - - static int hashKey(const jmethodID& key) { ! return (int)key; ! } /** Convert info to binary. This method converts information --- 145,157 ---- ** @see Hash */ ! int operator==(const jmethodID& key) { return (methodId == key);} /** Hash function. ** ! ** @param key reference to a key ! ** ** @return hash value */ ! static int hashKey(const jmethodID& key) { return (int)key;} /** Convert info to binary. This method converts information *************** *** 152,155 **** --- 169,173 ---- void deactivate(); + #ifdef USE_ALLOCATOR private: *************** *** 161,169 **** /** Overloaded new() operator. */ ! void* operator new( size_t) { return _allocator.get();} /** Overloaded delete() operator. */ void operator delete( void* unit) { _allocator.put( unit);} public: --- 179,188 ---- /** Overloaded new() operator. */ ! void* operator new( size_t sz) { return _allocator.get( sz);} /** Overloaded delete() operator. */ void operator delete( void* unit) { _allocator.put( unit);} + #endif public: *************** *** 171,175 **** /** Class identification. ** ! ** @return unique class type identified */ virtual eClassIdent getClassIdent() { return METHOD;} --- 190,194 ---- /** Class identification. ** ! ** @return unique class type identifier */ virtual eClassIdent getClassIdent() { return METHOD;} *************** *** 181,185 **** ** 1 (active) */ ! virtual int isActive() { return (clss) ? clss->isActive() : 1;} /** Indication that object has changed its data. --- 200,204 ---- ** 1 (active) */ ! virtual int isActive(); /** Indication that object has changed its data. *************** *** 188,205 **** ** 1 (data changed) */ ! virtual int isChanged() { return (activeChanged() || ! AllocStatData::dataChanged() || ! CpuStatData::dataChanged() || ! MonStatData::dataChanged());} // order dependent ! /** Set the structure is unchanged although it may not be. */ ! virtual void setUnchanged() { ! ! IdObject::setUnchanged(); ! AllocStatData::clearDataChanged(); ! CpuStatData::clearDataChanged(); ! MonStatData::clearDataChanged(); ! } }; --- 207,215 ---- ** 1 (data changed) */ ! virtual int isChanged(); /** Set the structure is unchanged although it may not be. */ ! virtual void setUnchanged(); }; Index: thread.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/thread.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** thread.cpp 2001/09/18 22:19:29 1.9 --- thread.cpp 2001/11/21 22:31:51 1.10 *************** *** 33,40 **** */ ! #include "../main/includes.h" - Allocator Thread::_allocator( sizeof( Thread)); - Buffer& Thread::infoToBin( Buffer& b) { --- 33,48 ---- */ ! #include "../shared/thread.h" ! #include "../shared/groupThread.h" ! #include "../alloc/allocThreadObject.h" ! #include "../alloc/allocThreadMethod.h" ! #include "../cpu/cpuThreadMethod.h" ! #include "../mon/monThreadMethod.h" ! #include "../prof/prof.h" ! ! #ifdef USE_ALLOCATOR ! Allocator Thread::_allocator; ! #endif Buffer& Thread::infoToBin( Buffer& b) { *************** *** 77,79 **** --- 85,93 ---- mtm = monThreadMethods.next(mtm); } + } + + void Thread::setUnchanged() { + + IdObject::setUnchanged(); + clearDataChanged(); } Index: thread.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/thread.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** thread.h 2001/09/02 20:14:22 1.22 --- thread.h 2001/11/21 22:31:51 1.23 *************** *** 36,39 **** --- 36,56 ---- #define _THREAD_H_ + #include "../main/includes.h" + #include "../list/listItem.h" + #include "../alloc/allocStatData.h" + #include "../commun2/idObject.h" + #include "../commun/binaryFormat.h" + #include "../string/string.h" + #include "../list/list.h" + #include "../shared/thread.h" + #include "../alloc/allocThreadObject.h" + #include "../alloc/allocThreadMethod.h" + #include "../cpu/cpuThreadMethod.h" + #include "../mon/monThreadMethod.h" + #include "../cpu/cpuStack.h" + #include "../main/const.h" + #include "../commun/buffer.h" + #include "../allocator/allocator.h" + /** Thread. This class consists of data gained ** by receiving the JVMPI_EVENT_THREAD_START event. *************** *** 46,52 **** ** @author Marek Przeczek, Petr Luner */ ! class Thread: public LI1, public LI2, public LI3, public LI4, ! public LI5, public AllocStatData, public IdObject, ! public InfoBinaryFormat { public: --- 63,74 ---- ** @author Marek Przeczek, Petr Luner */ ! class Thread: public LI1, ! public LI2, ! public LI3, ! public LI4, ! public LI5, ! public AllocStatData, ! public IdObject, ! public InfoBinaryFormat { public: *************** *** 89,92 **** --- 111,115 ---- /** Call trace for general temporary usage. ** There are MAX_TRACE frames. */ + JVMPI_CallTrace callTrace; *************** *** 101,104 **** --- 124,128 ---- ** event occured for this thread. The flag is cleared ** in JVMPI_EVENT_MONITOR_CONTENDED_ENTERED event. */ + int monitorEnter; *************** *** 106,109 **** --- 130,134 ---- ** Holds the object id of the last ** JVMPI_EVENT_MONITOR_CONTENDED_ENTER event. */ + jobjectID monitorEnterObject; *************** *** 111,114 **** --- 136,140 ---- ** Holds the time of the last ** JVMPI_EVENT_MONITOR_CONTENDED_ENTER event. */ + unsigned long monitorEnterTime; *************** *** 130,154 **** monitorEnter(0), monitorEnterObject(0), ! monitorEnterTime(0) - { callTrace.frames = _frames; } /** Retrieves object's key. ** - ** @param key where to store the key ** @return key ** ** @see Hash */ ! JNIEnv* const& getKey(JNIEnv*& key) { ! ! return key = threadEnvId; ! } /** Compares object with given key. ** ** @param key key ** @return 1 (true); ** 0 (false) --- 156,181 ---- monitorEnter(0), monitorEnterObject(0), ! monitorEnterTime(0) { callTrace.frames = _frames; } + /// Destructor. + virtual ~Thread() {} + /** Retrieves object's key. + ** + ** @param key where to store the key ** ** @return key ** ** @see Hash */ ! JNIEnv* const& getKey(JNIEnv*& key) { return key = threadEnvId;} /** Compares object with given key. ** ** @param key key + ** ** @return 1 (true); ** 0 (false) *************** *** 156,174 **** ** @see Hash */ ! int operator==(JNIEnv* const& key) { ! ! return (threadEnvId == key); ! } /** Hash function. ** ! ** @param reference to a key ** @return hash value */ ! static int hashKey(JNIEnv* const& key) { - return (int)key; - } - /** Convert info to binary. This method converts information ** data to binary format in which it is sent thru communication --- 183,196 ---- ** @see Hash */ ! int operator==(JNIEnv* const& key) { return (threadEnvId == key);} /** Hash function. ** ! ** @param key reference to a key ! ** ** @return hash value */ ! static int hashKey(JNIEnv* const& key) { return (int)key;} /** Convert info to binary. This method converts information ** data to binary format in which it is sent thru communication *************** *** 185,188 **** --- 207,211 ---- void deactivate(); + #ifdef USE_ALLOCATOR private: *************** *** 194,202 **** /** Overloaded new() operator. */ ! void* operator new( size_t) { return _allocator.get();} /** Overloaded delete() operator. */ void operator delete( void* unit) { _allocator.put( unit);} public: --- 217,226 ---- /** Overloaded new() operator. */ ! void* operator new( size_t sz) { return _allocator.get( sz);} /** Overloaded delete() operator. */ void operator delete( void* unit) { _allocator.put( unit);} + #endif public: *************** *** 204,208 **** /** Class identification. ** ! ** @return unique class type identified */ virtual eClassIdent getClassIdent() { return THREAD;} --- 228,232 ---- /** Class identification. ** ! ** @return unique class type identifier */ virtual eClassIdent getClassIdent() { return THREAD;} *************** *** 225,233 **** /** Set the structure is unchanged although it may not be. */ ! virtual void setUnchanged() { ! ! IdObject::setUnchanged(); ! clearDataChanged(); ! } }; --- 249,253 ---- /** Set the structure is unchanged although it may not be. */ ! virtual void setUnchanged(); }; Index: trace.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/trace.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** trace.cpp 2001/09/02 20:14:22 1.8 --- trace.cpp 2001/11/21 22:31:51 1.9 *************** *** 33,37 **** */ ! #include "../main/includes.h" Trace::~Trace() { --- 33,39 ---- */ ! #include "../shared/trace.h" ! #include "../shared/traceFrame.h" ! #include "../shared/method.h" Trace::~Trace() { *************** *** 53,55 **** --- 55,97 ---- return b; + } + + const TraceKey& Trace::getKey(TraceKey& key) { + + TraceFrame* tf = frames; + JVMPI_CallFrame* cf = key.frames; + + key.numFrames = numFrames; + for (int i = 0; i < numFrames; i++, tf++, cf++) { + cf->lineno = tf->lineno; + tf->method->getKey(cf->method_id); + } + + return key; + } + + int Trace::operator==(const TraceKey& key) { + + if (key.numFrames != numFrames) return 0; + + const JVMPI_CallFrame* cf = key.frames; + TraceFrame* tf = frames; + + for (int i = 0; i < numFrames; i++, tf++, cf++) + if( (tf->lineno != cf->lineno) || (!(*tf->method == cf->method_id))) return 0; + + return 1; + } + + int Trace::hashKey(const TraceKey& key) { + + const JVMPI_CallFrame* p = key.frames; + int sum = 0; + + for (int i = 0; i < key.numFrames; i++, p++) { + sum += (int)p->lineno; + sum += Method::hashKey(p->method_id); + } + + return sum; } Index: trace.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/trace.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** trace.h 2001/09/02 20:14:22 1.8 --- trace.h 2001/11/21 22:31:51 1.9 *************** *** 36,59 **** #define _TRACE_H_ ! /** Key for Trace class. ! ** Used for searching in hash tables. ! ** ! ** @author Petr Luner */ ! ! struct TraceKey { ! private: ! JVMPI_CallFrame _frames[MAX_TRACE]; ! ! public: ! /// number of call frames ! int numFrames; ! ! /// call frames ! JVMPI_CallFrame* frames; - TraceKey() { frames = _frames; } - }; - - /** Trace. This class consists of data aquired ** by calling a GetCallTrace() function of the JVMPI. --- 36,44 ---- #define _TRACE_H_ ! #include "../main/includes.h" ! #include "../commun/binaryFormat.h" ! #include "../shared/traceKey.h" ! #include "../commun/buffer.h" /** Trace. This class consists of data aquired ** by calling a GetCallTrace() function of the JVMPI. *************** *** 82,86 **** frames( NULL) ! {}; /// Destructor. --- 67,71 ---- frames( NULL) ! {} /// Destructor. *************** *** 88,150 **** /** Retrieves object's key. ** - ** @param key where to store the key ** @return key ** ** @see Hash */ - - const TraceKey& getKey(TraceKey& key) { - - TraceFrame* tf = frames; - JVMPI_CallFrame* cf = key.frames; ! key.numFrames = numFrames; ! for (int i = 0; i < numFrames; i++, tf++, cf++) { ! cf->lineno = tf->lineno; ! tf->method->getKey(cf->method_id); ! } - return key; - } - /** Compares object with given key. ** ** @param key key ** @return 1 (true); ** 0 (false) ** ** @see Hash */ - - int operator==(const TraceKey& key) { - - if (key.numFrames != numFrames) return 0; - - const JVMPI_CallFrame* cf = key.frames; - TraceFrame* tf = frames; - - for (int i = 0; i < numFrames; i++, tf++, cf++) - if( (tf->lineno != cf->lineno) || (!(*tf->method == cf->method_id))) return 0; ! return 1; ! } /** Hash function. ** ! ** @param reference to a key ** @return hash value */ - - static int hashKey(const TraceKey& key) { - - const JVMPI_CallFrame* p = key.frames; - int sum = 0; ! for (int i = 0; i < key.numFrames; i++, p++) { ! sum += (int)p->lineno; ! sum += Method::hashKey(p->method_id); ! } - return sum; - } - /** Convert info to binary. This method converts information ** data to binary format in which it is sent thru communication --- 73,104 ---- /** Retrieves object's key. + ** + ** @param key where to store the key ** ** @return key ** ** @see Hash */ ! const TraceKey& getKey(TraceKey& key); /** Compares object with given key. ** ** @param key key + ** ** @return 1 (true); ** 0 (false) ** ** @see Hash */ ! int operator==(const TraceKey& key); /** Hash function. ** ! ** @param key reference to a key ! ** ** @return hash value */ ! static int hashKey(const TraceKey& key); /** Convert info to binary. This method converts information ** data to binary format in which it is sent thru communication *************** *** 159,161 **** #endif // _TRACE_H_ - --- 113,114 ---- Index: traceFrame.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/traceFrame.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** traceFrame.cpp 2001/09/02 20:14:22 1.3 --- traceFrame.cpp 2001/11/21 22:31:51 1.4 *************** *** 33,37 **** */ ! #include "../main/includes.h" Allocator TraceFrame::_allocators[MAX_TRACE]; --- 33,39 ---- */ ! #include "../shared/traceFrame.h" + #ifdef USE_ALLOCATOR Allocator TraceFrame::_allocators[MAX_TRACE]; + #endif Index: traceFrame.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/shared/traceFrame.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** traceFrame.h 2001/09/02 20:14:22 1.8 --- traceFrame.h 2001/11/21 22:31:51 1.9 *************** *** 36,44 **** #define _TRACE_FRAME_H_ /** Trace frame. This class consists of information ** about one frame of method trace. It is used internally ! ** by AllocTrace and CpuTrace classes (by Trace class). ** ! ** @see AllocTrace, CpuTrace ** ** @author Marek Przeczek, Petr Luner */ --- 36,48 ---- #define _TRACE_FRAME_H_ + #include "../main/includes.h" + #include "../allocator/allocator.h" + #include "../main/const.h" + /** Trace frame. This class consists of information ** about one frame of method trace. It is used internally ! ** by AllocTrace, CpuTrace and MonTrace classes (by Trace class). ** ! ** @see AllocTrace, CpuTrace, MonTrace ** ** @author Marek Przeczek, Petr Luner */ *************** *** 52,59 **** --- 56,65 ---- Method* method; + #ifdef USE_ALLOCATOR private: /// allocators static Allocator _allocators[MAX_TRACE]; + #endif public: *************** *** 61,79 **** /** Allocates a new array of frames. ** ! ** @param size array size */ static TraceFrame* newArray(int size) { ! ! return reinterpret_cast<TraceFrame*>(_allocators[size - 1].get(size * sizeof(TraceFrame))); } /** Frees an array of frames. ** ! ** @param array frames array ! ** @param size array size */ static void deleteArray(TraceFrame* array, int size) { ! _allocators[size - 1].put(reinterpret_cast<void*>(array)); } }; --- 67,93 ---- /** Allocates a new array of frames. ** ! ** @param size array size */ static TraceFrame* newArray(int size) { ! ! #ifdef USE_ALLOCATOR ! return reinterpret_cast<TraceFrame*>(_allocators[size-1].get(size*sizeof(TraceFrame))); ! #else ! return ::new TraceFrame[size]; ! #endif } /** Frees an array of frames. ** ! ** @param array frames array ! ** @param size array size */ static void deleteArray(TraceFrame* array, int size) { ! #ifdef USE_ALLOCATOR ! _allocators[size-1].put( reinterpret_cast<void*>(array)); ! #else ! ::delete[] array; ! #endif } }; |