comparison src/share/vm/memory/heapInspection.hpp @ 10405:f2110083203d

8005849: JEP 167: Event-Based JVM Tracing Reviewed-by: acorn, coleenp, sla Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
author sla
date Mon, 10 Jun 2013 11:30:51 +0200
parents 92ef81e2f571
children 2cbc8f3011a0
comparison
equal deleted inserted replaced
10404:d0add7016434 10405:f2110083203d
24 24
25 #ifndef SHARE_VM_MEMORY_HEAPINSPECTION_HPP 25 #ifndef SHARE_VM_MEMORY_HEAPINSPECTION_HPP
26 #define SHARE_VM_MEMORY_HEAPINSPECTION_HPP 26 #define SHARE_VM_MEMORY_HEAPINSPECTION_HPP
27 27
28 #include "memory/allocation.inline.hpp" 28 #include "memory/allocation.inline.hpp"
29 #include "memory/klassInfoClosure.hpp"
29 #include "oops/oop.inline.hpp" 30 #include "oops/oop.inline.hpp"
30 #include "oops/annotations.hpp" 31 #include "oops/annotations.hpp"
31 #include "utilities/macros.hpp" 32 #include "utilities/macros.hpp"
32 33
33 #if INCLUDE_SERVICES 34 #if INCLUDE_SERVICES
201 int compare(KlassInfoEntry* e1, KlassInfoEntry* e2); 202 int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
202 void print_on(outputStream* st) const; 203 void print_on(outputStream* st) const;
203 const char* name() const; 204 const char* name() const;
204 }; 205 };
205 206
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> { 207 class KlassInfoBucket: public CHeapObj<mtInternal> {
213 private: 208 private:
214 KlassInfoEntry* _list; 209 KlassInfoEntry* _list;
215 KlassInfoEntry* list() { return _list; } 210 KlassInfoEntry* list() { return _list; }
216 void set_list(KlassInfoEntry* l) { _list = l; } 211 void set_list(KlassInfoEntry* l) { _list = l; }
222 }; 217 };
223 218
224 class KlassInfoTable: public StackObj { 219 class KlassInfoTable: public StackObj {
225 private: 220 private:
226 int _size; 221 int _size;
222 static const int _num_buckets = 20011;
223 size_t _size_of_instances_in_words;
227 224
228 // An aligned reference address (typically the least 225 // An aligned reference address (typically the least
229 // address in the perm gen) used for hashing klass 226 // address in the perm gen) used for hashing klass
230 // objects. 227 // objects.
231 HeapWord* _ref; 228 HeapWord* _ref;
240 AllClassesFinder(KlassInfoTable* table) : _table(table) {} 237 AllClassesFinder(KlassInfoTable* table) : _table(table) {}
241 virtual void do_klass(Klass* k); 238 virtual void do_klass(Klass* k);
242 }; 239 };
243 240
244 public: 241 public:
245 // Table size 242 KlassInfoTable(bool need_class_stats);
246 enum {
247 cit_size = 20011
248 };
249 KlassInfoTable(int size, HeapWord* ref, bool need_class_stats);
250 ~KlassInfoTable(); 243 ~KlassInfoTable();
251 bool record_instance(const oop obj); 244 bool record_instance(const oop obj);
252 void iterate(KlassInfoClosure* cic); 245 void iterate(KlassInfoClosure* cic);
253 bool allocation_failed() { return _buckets == NULL; } 246 bool allocation_failed() { return _buckets == NULL; }
247 size_t size_of_instances_in_words() const;
254 248
255 friend class KlassInfoHisto; 249 friend class KlassInfoHisto;
256 }; 250 };
257 251
258 class KlassInfoHisto : public StackObj { 252 class KlassInfoHisto : public StackObj {
259 private: 253 private:
254 static const int _histo_initial_size = 1000;
260 KlassInfoTable *_cit; 255 KlassInfoTable *_cit;
261 GrowableArray<KlassInfoEntry*>* _elements; 256 GrowableArray<KlassInfoEntry*>* _elements;
262 GrowableArray<KlassInfoEntry*>* elements() const { return _elements; } 257 GrowableArray<KlassInfoEntry*>* elements() const { return _elements; }
263 const char* _title; 258 const char* _title;
264 const char* title() const { return _title; } 259 const char* title() const { return _title; }
332 // add a leading space for separation. 327 // add a leading space for separation.
333 return w + 1; 328 return w + 1;
334 } 329 }
335 330
336 public: 331 public:
337 enum { 332 KlassInfoHisto(KlassInfoTable* cit, const char* title);
338 histo_initial_size = 1000
339 };
340 KlassInfoHisto(KlassInfoTable* cit, const char* title,
341 int estimatedCount);
342 ~KlassInfoHisto(); 333 ~KlassInfoHisto();
343 void add(KlassInfoEntry* cie); 334 void add(KlassInfoEntry* cie);
344 void print_histo_on(outputStream* st, bool print_class_stats, bool csv_format, const char *columns); 335 void print_histo_on(outputStream* st, bool print_class_stats, bool csv_format, const char *columns);
345 void sort(); 336 void sort();
346 }; 337 };
347 338
348 #endif // INCLUDE_SERVICES 339 #endif // INCLUDE_SERVICES
340
341 // These declarations are needed since teh declaration of KlassInfoTable and
342 // KlassInfoClosure are guarded by #if INLCUDE_SERVICES
343 class KlassInfoTable;
344 class KlassInfoClosure;
349 345
350 class HeapInspection : public StackObj { 346 class HeapInspection : public StackObj {
351 bool _csv_format; // "comma separated values" format for spreadsheet. 347 bool _csv_format; // "comma separated values" format for spreadsheet.
352 bool _print_help; 348 bool _print_help;
353 bool _print_class_stats; 349 bool _print_class_stats;
355 public: 351 public:
356 HeapInspection(bool csv_format, bool print_help, 352 HeapInspection(bool csv_format, bool print_help,
357 bool print_class_stats, const char *columns) : 353 bool print_class_stats, const char *columns) :
358 _csv_format(csv_format), _print_help(print_help), 354 _csv_format(csv_format), _print_help(print_help),
359 _print_class_stats(print_class_stats), _columns(columns) {} 355 _print_class_stats(print_class_stats), _columns(columns) {}
360 void heap_inspection(outputStream* st, bool need_prologue) NOT_SERVICES_RETURN; 356 void heap_inspection(outputStream* st) NOT_SERVICES_RETURN;
357 size_t populate_table(KlassInfoTable* cit, BoolObjectClosure* filter = NULL) NOT_SERVICES_RETURN;
361 static void find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) NOT_SERVICES_RETURN; 358 static void find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) NOT_SERVICES_RETURN;
359 private:
360 void iterate_over_heap(KlassInfoTable* cit, BoolObjectClosure* filter = NULL);
362 }; 361 };
363 362
364 #endif // SHARE_VM_MEMORY_HEAPINSPECTION_HPP 363 #endif // SHARE_VM_MEMORY_HEAPINSPECTION_HPP