hotspot/src/share/vm/memory/heapInspection.hpp
changeset 29071 73f45d04ad7a
parent 27677 b1997f2f1b56
child 29085 7b01b134b727
equal deleted inserted replaced
29069:938c1c97ad3b 29071:73f45d04ad7a
     1 /*
     1 /*
     2  * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   186   KlassInfoEntry* _next;
   186   KlassInfoEntry* _next;
   187   Klass*          _klass;
   187   Klass*          _klass;
   188   long            _instance_count;
   188   long            _instance_count;
   189   size_t          _instance_words;
   189   size_t          _instance_words;
   190   long            _index;
   190   long            _index;
       
   191   bool            _do_print; // True if we should print this class when printing the class hierarchy.
       
   192   GrowableArray<KlassInfoEntry*>* _subclasses;
   191 
   193 
   192  public:
   194  public:
   193   KlassInfoEntry(Klass* k, KlassInfoEntry* next) :
   195   KlassInfoEntry(Klass* k, KlassInfoEntry* next) :
   194     _klass(k), _instance_count(0), _instance_words(0), _next(next), _index(-1)
   196     _klass(k), _instance_count(0), _instance_words(0), _next(next), _index(-1),
       
   197     _do_print(false), _subclasses(NULL)
   195   {}
   198   {}
       
   199   ~KlassInfoEntry();
   196   KlassInfoEntry* next() const   { return _next; }
   200   KlassInfoEntry* next() const   { return _next; }
   197   bool is_equal(const Klass* k)  { return k == _klass; }
   201   bool is_equal(const Klass* k)  { return k == _klass; }
   198   Klass* klass()  const      { return _klass; }
   202   Klass* klass()  const      { return _klass; }
   199   long count()    const      { return _instance_count; }
   203   long count()    const      { return _instance_count; }
   200   void set_count(long ct)    { _instance_count = ct; }
   204   void set_count(long ct)    { _instance_count = ct; }
   201   size_t words()  const      { return _instance_words; }
   205   size_t words()  const      { return _instance_words; }
   202   void set_words(size_t wds) { _instance_words = wds; }
   206   void set_words(size_t wds) { _instance_words = wds; }
   203   void set_index(long index) { _index = index; }
   207   void set_index(long index) { _index = index; }
   204   long index()    const      { return _index; }
   208   long index()    const      { return _index; }
       
   209   GrowableArray<KlassInfoEntry*>* subclasses() const { return _subclasses; }
       
   210   void add_subclass(KlassInfoEntry* cie);
       
   211   void set_do_print(bool do_print) { _do_print = do_print; }
       
   212   bool do_print() const      { return _do_print; }
   205   int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
   213   int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
   206   void print_on(outputStream* st) const;
   214   void print_on(outputStream* st) const;
   207   const char* name() const;
   215   const char* name() const;
   208 };
   216 };
   209 
   217 
   246     AllClassesFinder(KlassInfoTable* table) : _table(table) {}
   254     AllClassesFinder(KlassInfoTable* table) : _table(table) {}
   247     virtual void do_klass(Klass* k);
   255     virtual void do_klass(Klass* k);
   248   };
   256   };
   249 
   257 
   250  public:
   258  public:
   251   KlassInfoTable(bool need_class_stats);
   259   KlassInfoTable(bool add_all_classes);
   252   ~KlassInfoTable();
   260   ~KlassInfoTable();
   253   bool record_instance(const oop obj);
   261   bool record_instance(const oop obj);
   254   void iterate(KlassInfoClosure* cic);
   262   void iterate(KlassInfoClosure* cic);
   255   bool allocation_failed() { return _buckets == NULL; }
   263   bool allocation_failed() { return _buckets == NULL; }
   256   size_t size_of_instances_in_words() const;
   264   size_t size_of_instances_in_words() const;
   257 
   265 
   258   friend class KlassInfoHisto;
   266   friend class KlassInfoHisto;
       
   267   friend class KlassHierarchy;
       
   268 };
       
   269 
       
   270 class KlassHierarchy : AllStatic {
       
   271  public:
       
   272   static void print_class_hierarchy(outputStream* st, bool print_interfaces,  bool print_subclasses,
       
   273                                     char* classname);
       
   274 
       
   275  private:
       
   276   static void set_do_print_for_class_hierarchy(KlassInfoEntry* cie, KlassInfoTable* cit,
       
   277                                                bool print_subclasse);
       
   278   static void print_class(outputStream* st, KlassInfoEntry* cie, bool print_subclasses);
   259 };
   279 };
   260 
   280 
   261 class KlassInfoHisto : public StackObj {
   281 class KlassInfoHisto : public StackObj {
   262  private:
   282  private:
   263   static const int _histo_initial_size = 1000;
   283   static const int _histo_initial_size = 1000;