< prev index next >

src/hotspot/share/memory/heapInspection.hpp

Print this page




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_MEMORY_HEAPINSPECTION_HPP
  26 #define SHARE_MEMORY_HEAPINSPECTION_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "oops/objArrayOop.hpp"
  30 #include "oops/oop.hpp"
  31 #include "oops/annotations.hpp"
  32 #include "utilities/macros.hpp"
  33 #include "gc/shared/workgroup.hpp"



  34 #if INCLUDE_SERVICES
  35 
  36 
  37 // HeapInspection
  38 
  39 // KlassInfoTable is a bucket hash table that
  40 // maps Klass*s to extra information:
  41 //    instance count and instance word size.
  42 //
  43 // A KlassInfoBucket is the head of a link list
  44 // of KlassInfoEntry's
  45 //
  46 // KlassInfoHisto is a growable array of pointers
  47 // to KlassInfoEntry's and is used to sort
  48 // the entries.
  49 
  50 class KlassInfoEntry: public CHeapObj<mtInternal> {
  51  private:
  52   KlassInfoEntry* _next;
  53   Klass*          _klass;


 205 };
 206 
 207 #endif // INCLUDE_SERVICES
 208 
 209 // These declarations are needed since the declaration of KlassInfoTable and
 210 // KlassInfoClosure are guarded by #if INLCUDE_SERVICES
 211 class KlassInfoTable;
 212 class KlassInfoClosure;
 213 
 214 class HeapInspection : public StackObj {
 215  public:
 216   void heap_inspection(outputStream* st, size_t parallel_thread_num = 1) NOT_SERVICES_RETURN;
 217   size_t populate_table(KlassInfoTable* cit, BoolObjectClosure* filter = NULL, size_t parallel_thread_num = 1) NOT_SERVICES_RETURN_(0);
 218   static void find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) NOT_SERVICES_RETURN;
 219  private:
 220   void iterate_over_heap(KlassInfoTable* cit, BoolObjectClosure* filter = NULL);
 221 };
 222 
 223 class ParHeapInspectTask : public AbstractGangTask {
 224  private:
 225   CollectedHeap* _heap;
 226   KlassInfoTable* _shared_cit;
 227   BoolObjectClosure* _filter;
 228   size_t* _shared_missed_count;
 229   bool _success;
 230   Mutex _mutex;
 231   size_t _par_thread_num;
 232 
 233  public:
 234   ParHeapInspectTask(CollectedHeap* heap, KlassInfoTable* shared_cit,
 235                      BoolObjectClosure* filter, size_t* shared_missed_count,
 236                      size_t parallel_thread_num) :
 237       AbstractGangTask("Iterating heap"),
 238       _heap(heap),
 239       _shared_cit(shared_cit),
 240       _filter(filter),
 241       _shared_missed_count(shared_missed_count),
 242       _success(true),
 243       _mutex(Mutex::leaf, "Parallel heap iteration data merge lock"),
 244       _par_thread_num(parallel_thread_num) { }
 245 
 246   bool is_success() {
 247     return _success;
 248   }
 249 
 250   CollectedHeap* getHeap() {
 251     return _heap;
 252   }
 253   virtual void work(uint worker_id);
 254   virtual void do_object_iterate_parallel(ObjectClosure* closure, uint worker_id) = 0;
 255 };
 256 
 257 
 258 
 259 #endif // SHARE_MEMORY_HEAPINSPECTION_HPP


  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_MEMORY_HEAPINSPECTION_HPP
  26 #define SHARE_MEMORY_HEAPINSPECTION_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "oops/objArrayOop.hpp"
  30 #include "oops/oop.hpp"
  31 #include "oops/annotations.hpp"
  32 #include "utilities/macros.hpp"
  33 #include "gc/shared/workgroup.hpp"
  34 
  35 class ParallelObjectIterator;
  36 
  37 #if INCLUDE_SERVICES
  38 
  39 
  40 // HeapInspection
  41 
  42 // KlassInfoTable is a bucket hash table that
  43 // maps Klass*s to extra information:
  44 //    instance count and instance word size.
  45 //
  46 // A KlassInfoBucket is the head of a link list
  47 // of KlassInfoEntry's
  48 //
  49 // KlassInfoHisto is a growable array of pointers
  50 // to KlassInfoEntry's and is used to sort
  51 // the entries.
  52 
  53 class KlassInfoEntry: public CHeapObj<mtInternal> {
  54  private:
  55   KlassInfoEntry* _next;
  56   Klass*          _klass;


 208 };
 209 
 210 #endif // INCLUDE_SERVICES
 211 
 212 // These declarations are needed since the declaration of KlassInfoTable and
 213 // KlassInfoClosure are guarded by #if INLCUDE_SERVICES
 214 class KlassInfoTable;
 215 class KlassInfoClosure;
 216 
 217 class HeapInspection : public StackObj {
 218  public:
 219   void heap_inspection(outputStream* st, size_t parallel_thread_num = 1) NOT_SERVICES_RETURN;
 220   size_t populate_table(KlassInfoTable* cit, BoolObjectClosure* filter = NULL, size_t parallel_thread_num = 1) NOT_SERVICES_RETURN_(0);
 221   static void find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) NOT_SERVICES_RETURN;
 222  private:
 223   void iterate_over_heap(KlassInfoTable* cit, BoolObjectClosure* filter = NULL);
 224 };
 225 
 226 class ParHeapInspectTask : public AbstractGangTask {
 227  private:
 228   ParallelObjectIterator* _poi;
 229   KlassInfoTable* _shared_cit;
 230   BoolObjectClosure* _filter;
 231   size_t _shared_missed_count;
 232   bool _success;
 233   Mutex _mutex;

 234 
 235  public:
 236   ParHeapInspectTask(ParallelObjectIterator* poi,
 237                      KlassInfoTable* shared_cit,
 238                      BoolObjectClosure* filter) :
 239       AbstractGangTask("Iterating heap"),
 240       _poi(poi),
 241       _shared_cit(shared_cit),
 242       _filter(filter),
 243       _shared_missed_count(0),
 244       _success(true),
 245       _mutex(Mutex::leaf, "Parallel heap iteration data merge lock") {}

 246 
 247   uint missed_count() const {
 248     return _shared_missed_count;
 249   }
 250 



 251   virtual void work(uint worker_id);

 252 };
 253 
 254 
 255 
 256 #endif // SHARE_MEMORY_HEAPINSPECTION_HPP
< prev index next >