Mercurial > hg > truffle
comparison src/share/vm/services/memTrackWorker.hpp @ 7464:ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
Summary: Count number of instance classes so that it matches class metadata size
Reviewed-by: coleenp, acorn
author | zgu |
---|---|
date | Tue, 08 Jan 2013 14:04:25 -0500 |
parents | 7e5976e66c62 |
children | 4102b59539ce |
comparison
equal
deleted
inserted
replaced
7396:4a2ed49abd51 | 7464:ecd24264898b |
---|---|
30 #include "services/memRecorder.hpp" | 30 #include "services/memRecorder.hpp" |
31 | 31 |
32 // Maximum MAX_GENERATIONS generation data can be tracked. | 32 // Maximum MAX_GENERATIONS generation data can be tracked. |
33 #define MAX_GENERATIONS 512 | 33 #define MAX_GENERATIONS 512 |
34 | 34 |
35 class GenerationData : public _ValueObj { | |
36 private: | |
37 int _number_of_classes; | |
38 MemRecorder* _recorder_list; | |
39 | |
40 public: | |
41 GenerationData(): _number_of_classes(0), _recorder_list(NULL) { } | |
42 | |
43 inline int number_of_classes() const { return _number_of_classes; } | |
44 inline void set_number_of_classes(long num) { _number_of_classes = num; } | |
45 | |
46 inline MemRecorder* next_recorder() { | |
47 if (_recorder_list == NULL) { | |
48 return NULL; | |
49 } else { | |
50 MemRecorder* tmp = _recorder_list; | |
51 _recorder_list = _recorder_list->next(); | |
52 return tmp; | |
53 } | |
54 } | |
55 | |
56 inline bool has_more_recorder() const { | |
57 return (_recorder_list != NULL); | |
58 } | |
59 | |
60 // add recorders to this generation | |
61 void add_recorders(MemRecorder* head) { | |
62 if (head != NULL) { | |
63 if (_recorder_list == NULL) { | |
64 _recorder_list = head; | |
65 } else { | |
66 MemRecorder* tmp = _recorder_list; | |
67 for (; tmp->next() != NULL; tmp = tmp->next()); | |
68 tmp->set_next(head); | |
69 } | |
70 } | |
71 } | |
72 | |
73 void reset(); | |
74 | |
75 NOT_PRODUCT(MemRecorder* peek() const { return _recorder_list; }) | |
76 }; | |
35 | 77 |
36 class MemTrackWorker : public NamedThread { | 78 class MemTrackWorker : public NamedThread { |
37 private: | 79 private: |
38 // circular buffer. This buffer contains recorders to be merged into global | 80 // circular buffer. This buffer contains generation data to be merged into global |
39 // snaphsot. | 81 // snaphsot. |
40 // Each slot holds a linked list of memory recorders, that contains one | 82 // Each slot holds a generation |
41 // generation of memory data. | 83 GenerationData _gen[MAX_GENERATIONS]; |
42 MemRecorder* _gen[MAX_GENERATIONS]; | 84 int _head, _tail; // head and tail pointers to above circular buffer |
43 int _head, _tail; // head and tail pointers to above circular buffer | |
44 | 85 |
45 bool _has_error; | 86 bool _has_error; |
46 | 87 |
47 public: | 88 public: |
48 MemTrackWorker(); | 89 MemTrackWorker(); |
49 ~MemTrackWorker(); | 90 ~MemTrackWorker(); |
50 _NOINLINE_ void* operator new(size_t size); | 91 _NOINLINE_ void* operator new(size_t size); |
54 void run(); | 95 void run(); |
55 | 96 |
56 inline bool has_error() const { return _has_error; } | 97 inline bool has_error() const { return _has_error; } |
57 | 98 |
58 // task at synchronization point | 99 // task at synchronization point |
59 void at_sync_point(MemRecorder* pending_recorders); | 100 void at_sync_point(MemRecorder* pending_recorders, int number_of_classes); |
60 | 101 |
61 // for debugging purpose, they are not thread safe. | 102 // for debugging purpose, they are not thread safe. |
62 NOT_PRODUCT(static int count_recorder(const MemRecorder* head);) | 103 NOT_PRODUCT(static int count_recorder(const MemRecorder* head);) |
63 NOT_PRODUCT(int count_pending_recorders() const;) | 104 NOT_PRODUCT(int count_pending_recorders() const;) |
64 | 105 |