src/share/vm/memory/heapInspection.hpp

Wed, 02 Jul 2008 12:55:16 -0700

author
xdono
date
Wed, 02 Jul 2008 12:55:16 -0700
changeset 631
d1605aabd0a1
parent 446
3c1dbcaaab1d
child 1050
c6c601a0f2d6
permissions
-rw-r--r--

6719955: Update copyright year
Summary: Update copyright year for files that have been modified in 2008
Reviewed-by: ohair, tbell

duke@435 1 /*
xdono@631 2 * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #ifndef SERVICES_KERNEL
duke@435 26
duke@435 27
duke@435 28 // HeapInspection
duke@435 29
duke@435 30 // KlassInfoTable is a bucket hash table that
duke@435 31 // maps klassOops to extra information:
duke@435 32 // instance count and instance word size.
duke@435 33 //
duke@435 34 // A KlassInfoBucket is the head of a link list
duke@435 35 // of KlassInfoEntry's
duke@435 36 //
duke@435 37 // KlassInfoHisto is a growable array of pointers
duke@435 38 // to KlassInfoEntry's and is used to sort
duke@435 39 // the entries.
duke@435 40
duke@435 41 class KlassInfoEntry: public CHeapObj {
duke@435 42 private:
duke@435 43 KlassInfoEntry* _next;
duke@435 44 klassOop _klass;
duke@435 45 long _instance_count;
duke@435 46 size_t _instance_words;
duke@435 47
duke@435 48 public:
duke@435 49 KlassInfoEntry(klassOop k, KlassInfoEntry* next) :
duke@435 50 _klass(k), _instance_count(0), _instance_words(0), _next(next)
duke@435 51 {}
duke@435 52 KlassInfoEntry* next() { return _next; }
duke@435 53 bool is_equal(klassOop k) { return k == _klass; }
duke@435 54 klassOop klass() { return _klass; }
duke@435 55 long count() { return _instance_count; }
duke@435 56 void set_count(long ct) { _instance_count = ct; }
duke@435 57 size_t words() { return _instance_words; }
duke@435 58 void set_words(size_t wds) { _instance_words = wds; }
duke@435 59 int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
duke@435 60 void print_on(outputStream* st) const;
duke@435 61 };
duke@435 62
duke@435 63 class KlassInfoClosure: public StackObj {
duke@435 64 public:
duke@435 65 // Called for each KlassInfoEntry.
duke@435 66 virtual void do_cinfo(KlassInfoEntry* cie) = 0;
duke@435 67 };
duke@435 68
duke@435 69 class KlassInfoBucket: public CHeapObj {
duke@435 70 private:
duke@435 71 KlassInfoEntry* _list;
duke@435 72 KlassInfoEntry* list() { return _list; }
duke@435 73 void set_list(KlassInfoEntry* l) { _list = l; }
duke@435 74 public:
duke@435 75 KlassInfoEntry* lookup(const klassOop k);
duke@435 76 void initialize() { _list = NULL; }
duke@435 77 void empty();
duke@435 78 void iterate(KlassInfoClosure* cic);
duke@435 79 };
duke@435 80
duke@435 81 class KlassInfoTable: public StackObj {
duke@435 82 private:
duke@435 83 int _size;
duke@435 84
duke@435 85 // An aligned reference address (typically the least
duke@435 86 // address in the perm gen) used for hashing klass
duke@435 87 // objects.
duke@435 88 HeapWord* _ref;
duke@435 89
duke@435 90 KlassInfoBucket* _buckets;
duke@435 91 uint hash(klassOop p);
duke@435 92 KlassInfoEntry* lookup(const klassOop k);
duke@435 93
duke@435 94 public:
duke@435 95 // Table size
duke@435 96 enum {
duke@435 97 cit_size = 20011
duke@435 98 };
duke@435 99 KlassInfoTable(int size, HeapWord* ref);
duke@435 100 ~KlassInfoTable();
ysr@446 101 bool record_instance(const oop obj);
duke@435 102 void iterate(KlassInfoClosure* cic);
ysr@446 103 bool allocation_failed() { return _buckets == NULL; }
duke@435 104 };
duke@435 105
duke@435 106 class KlassInfoHisto : public StackObj {
duke@435 107 private:
duke@435 108 GrowableArray<KlassInfoEntry*>* _elements;
duke@435 109 GrowableArray<KlassInfoEntry*>* elements() const { return _elements; }
duke@435 110 const char* _title;
duke@435 111 const char* title() const { return _title; }
duke@435 112 static int sort_helper(KlassInfoEntry** e1, KlassInfoEntry** e2);
duke@435 113 void print_elements(outputStream* st) const;
duke@435 114 public:
duke@435 115 enum {
duke@435 116 histo_initial_size = 1000
duke@435 117 };
duke@435 118 KlassInfoHisto(const char* title,
duke@435 119 int estimatedCount);
duke@435 120 ~KlassInfoHisto();
duke@435 121 void add(KlassInfoEntry* cie);
duke@435 122 void print_on(outputStream* st) const;
duke@435 123 void sort();
duke@435 124 };
duke@435 125
duke@435 126 #endif // SERVICES_KERNEL
duke@435 127
duke@435 128 class HeapInspection : public AllStatic {
duke@435 129 public:
duke@435 130 static void heap_inspection(outputStream* st) KERNEL_RETURN;
duke@435 131 static void find_instances_at_safepoint(klassOop k, GrowableArray<oop>* result) KERNEL_RETURN;
duke@435 132 };

mercurial