Update of /cvsroot/javaprofiler/library/src/commun2 In directory usw-pr-cvs1:/tmp/cvs-serv12170/src/commun2 Modified Files: Makefile.rules counter.h dir.info idObject.h objectTable.cpp objectTable.h prof_interface.cpp Added Files: counter.cpp idObject.cpp Log Message: some parts completely rewritten; changes in communication interface to make it faster; ported to linux --- NEW FILE: counter.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 "../commun2/counter.h" Counter* Counter::getCounter() { static Counter c; return &c; } --- NEW FILE: idObject.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 "../commun2/idObject.h" #include "../commun2/counter.h" IdObject::IdObject() : _active( 0) { Counter* p = Counter::getCounter(); profId = p->getValue(); p->table.add( new ObjectTable( profId, this)); } int IdObject::activeChanged() { if( _active != isActive()) { _active = isActive(); return 1; } return 0; } Index: Makefile.rules =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun2/Makefile.rules,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Makefile.rules 2001/07/28 04:11:17 1.3 --- Makefile.rules 2001/11/21 22:31:42 1.4 *************** *** 1,11 **** ! communThread.o \ ! communThread.obj: communThread.cpp ../main/includes.h ! $(CCC) $(CPPFLAGS) communThread.cpp objectTable.o \ ! objectTable.obj: objectTable.cpp ../main/includes.h $(CCC) $(CPPFLAGS) objectTable.cpp prof_interface.o \ ! prof_interface.obj: prof_interface.cpp ../main/includes.h $(CCC) $(CPPFLAGS) prof_interface.cpp --- 1,15 ---- ! counter.o \ ! counter.obj: counter.cpp ! $(CCC) $(CPPFLAGS) counter.cpp + idObject.o \ + idObject.obj: idObject.cpp + $(CCC) $(CPPFLAGS) idObject.cpp + objectTable.o \ ! objectTable.obj: objectTable.cpp $(CCC) $(CPPFLAGS) objectTable.cpp prof_interface.o \ ! prof_interface.obj: prof_interface.cpp $(CCC) $(CPPFLAGS) prof_interface.cpp Index: counter.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun2/counter.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** counter.h 2001/09/02 20:14:21 1.3 --- counter.h 2001/11/21 22:31:42 1.4 *************** *** 36,39 **** --- 36,44 ---- #define _COUNTER_H_ + #include "../main/includes.h" + #include "../hash/hash.h" + #include "../list/listItem.h" + #include "../commun2/objectTable.h" + /** Internal counter. This class implements counter. ** Each call to getValue() method increments stored *************** *** 65,69 **** _value( 1) ! {}; /** Get current value. This method returns current value --- 70,74 ---- _value( 1) ! {} /** Get current value. This method returns current value *************** *** 80,90 **** ** @return pointer to object */ ! static Counter* getCounter() { ! ! static Counter c; ! return &c; ! } }; #endif // _COUNTER_H_ - --- 85,90 ---- ** @return pointer to object */ ! static Counter* getCounter(); }; #endif // _COUNTER_H_ Index: dir.info =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun2/dir.info,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** dir.info 2001/08/05 01:37:10 1.4 --- dir.info 2001/11/21 22:31:42 1.5 *************** *** 1,3 **** ! FILES = objectTable prof_interface ! CLEAN_FILES = *.pdb *.obj *.o --- 1,2 ---- ! FILES = counter idObject objectTable prof_interface CLEAN_FILES = *.pdb *.obj *.o Index: idObject.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun2/idObject.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** idObject.h 2001/09/02 20:14:21 1.8 --- idObject.h 2001/11/21 22:31:42 1.9 *************** *** 36,39 **** --- 36,41 ---- #define _ID_OBJECT_H_ + #include "../main/includes.h" + /** Unique ID of object. Each class inherited from this ** class contains special private unique ID. Each instance *************** *** 57,63 **** enum eClassIdent { ! ALLOC = 1, // 001b ! CPU = 2, // 010b ! MON = 4, // 100b ALLOC_ARENA = ( 1 << 8), --- 59,65 ---- enum eClassIdent { ! ALLOC = 1, // 0001b ! CPU = 2, // 0010b ! MON = 4, // 0100b ALLOC_ARENA = ( 1 << 8), *************** *** 74,78 **** CPU_THREAD_TRACE = (12 << 8) | CPU, CPU_TRACE = (13 << 8) | CPU, ! GARBAGE_C = (14 << 8), // don't use GC !!! CLASS = (15 << 8), CLASS_FIELD = (16 << 8), --- 76,80 ---- CPU_THREAD_TRACE = (12 << 8) | CPU, CPU_TRACE = (13 << 8) | CPU, ! GARBAGE_C = (14 << 8), // don't use GC as a name of type !!! CLASS = (15 << 8), CLASS_FIELD = (16 << 8), *************** *** 91,101 **** ** to special ObjectTable hashtable. */ ! IdObject() : ! ! _active( 0) { ! ! profId = Counter::getCounter()->getValue(); ! Counter::getCounter()->table.add( new ObjectTable( profId, this)); ! } /** Get object ID. This method returns ID --- 93,100 ---- ** to special ObjectTable hashtable. */ ! IdObject(); ! ! /// Destructor. ! virtual ~IdObject() {} /** Get object ID. This method returns ID *************** *** 120,124 **** /** Class identification. ** ! ** @return unique class type identified */ virtual eClassIdent getClassIdent() = 0; --- 119,123 ---- /** Class identification. ** ! ** @return unique class type identifier */ virtual eClassIdent getClassIdent() = 0; *************** *** 137,150 **** ** 1 (changed) */ ! int activeChanged() { ! ! if( _active != isActive()) { ! ! _active = isActive(); ! return 1; ! } ! ! return 0; ! } /** Indication that object has changed its data. --- 136,140 ---- ** 1 (changed) */ ! int activeChanged(); /** Indication that object has changed its data. *************** *** 161,163 **** #endif // _ID_OBJECT_H_ - --- 151,152 ---- Index: objectTable.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun2/objectTable.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** objectTable.cpp 2001/09/02 20:14:21 1.2 --- objectTable.cpp 2001/11/21 22:31:42 1.3 *************** *** 33,37 **** */ ! #include "../main/includes.h" ! Allocator ObjectTable::_allocator( sizeof( ObjectTable)); --- 33,39 ---- */ ! #include "../commun2/objectTable.h" ! #ifdef USE_ALLOCATOR ! Allocator ObjectTable::_allocator; ! #endif Index: objectTable.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun2/objectTable.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** objectTable.h 2001/09/02 20:14:21 1.5 --- objectTable.h 2001/11/21 22:31:42 1.6 *************** *** 36,44 **** #define _OBJECT_TABLE_H_ /** Couple (object_id, pointer_to_object). This class consists ** of two items: unique ID of the object in profiler library's memory ** (having information about corresponding Java object) and ** pointer to this object. ID is used during the communication ! ** between Java and C++ parts of Java profiler, ID uniquely ** identifies the object - pointers to objects cannot be transfered ** between Java and C++ - profiled JVM can be run on various platforms --- 36,48 ---- #define _OBJECT_TABLE_H_ + #include "../main/includes.h" + #include "../list/listItem.h" + #include "../allocator/allocator.h" + /** Couple (object_id, pointer_to_object). This class consists ** of two items: unique ID of the object in profiler library's memory ** (having information about corresponding Java object) and ** pointer to this object. ID is used during the communication ! ** between Java and C++ part of Java profiler, ID uniquely ** identifies the object - pointers to objects cannot be transfered ** between Java and C++ - profiled JVM can be run on various platforms *************** *** 71,92 **** id( i), obj( o) ! {}; /** Retrieves object's key. ** ! ** @param key where to store the key ! ** @return key ** ** @see Hash */ ! const jint& getKey(jint& key) { ! ! return key = id; ! } /** Compares object with given key. ** ** @param key key ** @return 1 (true); ** 0 (false) --- 75,98 ---- id( i), obj( o) + + {} ! /// Destructor. ! virtual ~ObjectTable() {} /** Retrieves object's key. + ** + ** @param key where to store the key ** ! ** @return key ** ** @see Hash */ ! const jint& getKey( jint& key) { return key = id;} /** Compares object with given key. ** ** @param key key + ** ** @return 1 (true); ** 0 (false) *************** *** 94,112 **** ** @see Hash */ ! int operator==(const jint& key) { ! ! return (id == key); ! } /** Hash function. ** ! ** @param reference to a key ** @return hash value */ - - static int hashKey(const jint& key) { ! return (int)key; ! } private: --- 100,114 ---- ** @see Hash */ ! int operator==( const jint& key) { return (id == key);} /** Hash function. ** ! ** @param key reference to a key ! ** ** @return hash value */ ! static int hashKey( const jint& key) { return (int)key;} + #ifdef USE_ALLOCATOR private: *************** *** 118,126 **** /** Overloaded new() operator. */ ! void* operator new( size_t) { return _allocator.get();} /** Overloaded delete() operator. */ void operator delete( void* unit) { _allocator.put( unit);} }; --- 120,129 ---- /** 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 }; Index: prof_interface.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun2/prof_interface.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** prof_interface.cpp 2001/09/02 20:14:21 1.12 --- prof_interface.cpp 2001/11/21 22:31:42 1.13 *************** *** 33,37 **** */ ! #include "../main/includes.h" void Prof::shutdown() { --- 33,60 ---- */ ! #include "../prof/prof.h" ! #include "../prof/synchronized.h" [...1197 lines suppressed...] + break; + } + case IdObject::CPU_TRACE: { // optionalArg ... number of hits + + CpuStatData* cpu = static_cast<CpuTrace*>( o); + if( cpu->hits < optionalArg) return 0; + + break; + } + case IdObject::MON_TRACE: { // optionalArg ... number of hits + + MonStatData* mon = static_cast<MonTrace*>( o); + if( mon->hits < optionalArg) return 0; + + break; + } + } + + return 1; } |