src/share/vm/memory/heapInspection.hpp

Print this page
rev 4873 : 8015972: Refactor the sending of the object count after GC event


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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_VM_MEMORY_HEAPINSPECTION_HPP
  26 #define SHARE_VM_MEMORY_HEAPINSPECTION_HPP
  27 
  28 #include "memory/allocation.inline.hpp"
  29 #include "memory/klassInfoClosure.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "oops/annotations.hpp"
  32 #include "utilities/macros.hpp"
  33 
  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 


 185   long            _instance_count;
 186   size_t          _instance_words;
 187   long            _index;
 188 
 189  public:
 190   KlassInfoEntry(Klass* k, KlassInfoEntry* next) :
 191     _klass(k), _instance_count(0), _instance_words(0), _next(next), _index(-1)
 192   {}
 193   KlassInfoEntry* next() const   { return _next; }
 194   bool is_equal(const Klass* k)  { return k == _klass; }
 195   Klass* klass()  const      { return _klass; }
 196   long count()    const      { return _instance_count; }
 197   void set_count(long ct)    { _instance_count = ct; }
 198   size_t words()  const      { return _instance_words; }
 199   void set_words(size_t wds) { _instance_words = wds; }
 200   void set_index(long index) { _index = index; }
 201   long index()    const      { return _index; }
 202   int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
 203   void print_on(outputStream* st) const;
 204   const char* name() const;






 205 };
 206 
 207 class KlassInfoBucket: public CHeapObj<mtInternal> {
 208  private:
 209   KlassInfoEntry* _list;
 210   KlassInfoEntry* list()           { return _list; }
 211   void set_list(KlassInfoEntry* l) { _list = l; }
 212  public:
 213   KlassInfoEntry* lookup(Klass* k);
 214   void initialize() { _list = NULL; }
 215   void empty();
 216   void iterate(KlassInfoClosure* cic);
 217 };
 218 
 219 class KlassInfoTable: public StackObj {
 220  private:
 221   int _size;
 222   static const int _num_buckets = 20011;
 223   size_t _size_of_instances_in_words;
 224 




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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_VM_MEMORY_HEAPINSPECTION_HPP
  26 #define SHARE_VM_MEMORY_HEAPINSPECTION_HPP
  27 
  28 #include "memory/allocation.inline.hpp"

  29 #include "oops/oop.inline.hpp"
  30 #include "oops/annotations.hpp"
  31 #include "utilities/macros.hpp"
  32 
  33 #if INCLUDE_SERVICES
  34 
  35 
  36 // HeapInspection
  37 
  38 // KlassInfoTable is a bucket hash table that
  39 // maps Klass*s to extra information:
  40 //    instance count and instance word size.
  41 //
  42 // A KlassInfoBucket is the head of a link list
  43 // of KlassInfoEntry's
  44 //
  45 // KlassInfoHisto is a growable array of pointers
  46 // to KlassInfoEntry's and is used to sort
  47 // the entries.
  48 


 184   long            _instance_count;
 185   size_t          _instance_words;
 186   long            _index;
 187 
 188  public:
 189   KlassInfoEntry(Klass* k, KlassInfoEntry* next) :
 190     _klass(k), _instance_count(0), _instance_words(0), _next(next), _index(-1)
 191   {}
 192   KlassInfoEntry* next() const   { return _next; }
 193   bool is_equal(const Klass* k)  { return k == _klass; }
 194   Klass* klass()  const      { return _klass; }
 195   long count()    const      { return _instance_count; }
 196   void set_count(long ct)    { _instance_count = ct; }
 197   size_t words()  const      { return _instance_words; }
 198   void set_words(size_t wds) { _instance_words = wds; }
 199   void set_index(long index) { _index = index; }
 200   long index()    const      { return _index; }
 201   int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
 202   void print_on(outputStream* st) const;
 203   const char* name() const;
 204 };
 205 
 206 class KlassInfoClosure : public StackObj {
 207  public:
 208   // Called for each KlassInfoEntry.
 209   virtual void do_cinfo(KlassInfoEntry* cie) = 0;
 210 };
 211 
 212 class KlassInfoBucket: public CHeapObj<mtInternal> {
 213  private:
 214   KlassInfoEntry* _list;
 215   KlassInfoEntry* list()           { return _list; }
 216   void set_list(KlassInfoEntry* l) { _list = l; }
 217  public:
 218   KlassInfoEntry* lookup(Klass* k);
 219   void initialize() { _list = NULL; }
 220   void empty();
 221   void iterate(KlassInfoClosure* cic);
 222 };
 223 
 224 class KlassInfoTable: public StackObj {
 225  private:
 226   int _size;
 227   static const int _num_buckets = 20011;
 228   size_t _size_of_instances_in_words;
 229