Mercurial > hg > truffle
annotate src/share/vm/services/memTrackWorker.hpp @ 8733:9def4075da6d
8008079: G1: Add nextObject routine to CMBitMapRO and replace nextWord
Summary: Update the task local finger to the start of the next object when marking aborts, in order to avoid the redundant scanning of all 0's when the marking task restarts, if otherwise updating to the next word. In addition, reuse the routine nextObject() in routine iterate().
Reviewed-by: johnc, ysr
Contributed-by: tamao <tao.mao@oracle.com>
author | tamao |
---|---|
date | Tue, 05 Mar 2013 15:36:56 -0800 |
parents | 4102b59539ce |
children | 35f8765422b9 |
rev | line source |
---|---|
6197 | 1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
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_SERVICES_MEM_TRACK_WORKER_HPP | |
26 #define SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP | |
27 | |
28 #include "memory/allocation.hpp" | |
29 #include "runtime/thread.hpp" | |
30 #include "services/memRecorder.hpp" | |
31 | |
32 // Maximum MAX_GENERATIONS generation data can be tracked. | |
33 #define MAX_GENERATIONS 512 | |
34 | |
7464
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
35 class GenerationData : public _ValueObj { |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
36 private: |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
37 int _number_of_classes; |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
38 MemRecorder* _recorder_list; |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
39 |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
40 public: |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
41 GenerationData(): _number_of_classes(0), _recorder_list(NULL) { } |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
42 |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
43 inline int number_of_classes() const { return _number_of_classes; } |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
44 inline void set_number_of_classes(long num) { _number_of_classes = num; } |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
45 |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
46 inline MemRecorder* next_recorder() { |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
47 if (_recorder_list == NULL) { |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
48 return NULL; |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
49 } else { |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
50 MemRecorder* tmp = _recorder_list; |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
51 _recorder_list = _recorder_list->next(); |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
52 return tmp; |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
53 } |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
54 } |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
55 |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
56 inline bool has_more_recorder() const { |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
57 return (_recorder_list != NULL); |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
58 } |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
59 |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
60 // add recorders to this generation |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
61 void add_recorders(MemRecorder* head) { |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
62 if (head != NULL) { |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
63 if (_recorder_list == NULL) { |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
64 _recorder_list = head; |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
65 } else { |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
66 MemRecorder* tmp = _recorder_list; |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
67 for (; tmp->next() != NULL; tmp = tmp->next()); |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
68 tmp->set_next(head); |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
69 } |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
70 } |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
71 } |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
72 |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
73 void reset(); |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
74 |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
75 NOT_PRODUCT(MemRecorder* peek() const { return _recorder_list; }) |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
76 }; |
6197 | 77 |
78 class MemTrackWorker : public NamedThread { | |
79 private: | |
7464
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
80 // circular buffer. This buffer contains generation data to be merged into global |
6197 | 81 // snaphsot. |
7464
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
82 // Each slot holds a generation |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
83 GenerationData _gen[MAX_GENERATIONS]; |
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
84 int _head, _tail; // head and tail pointers to above circular buffer |
6197 | 85 |
7464
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
86 bool _has_error; |
6197 | 87 |
88 public: | |
89 MemTrackWorker(); | |
90 ~MemTrackWorker(); | |
91 _NOINLINE_ void* operator new(size_t size); | |
92 _NOINLINE_ void* operator new(size_t size, const std::nothrow_t& nothrow_constant); | |
93 | |
94 void start(); | |
95 void run(); | |
96 | |
97 inline bool has_error() const { return _has_error; } | |
98 | |
99 // task at synchronization point | |
7464
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
6231
diff
changeset
|
100 void at_sync_point(MemRecorder* pending_recorders, int number_of_classes); |
6197 | 101 |
102 // for debugging purpose, they are not thread safe. | |
103 NOT_PRODUCT(static int count_recorder(const MemRecorder* head);) | |
104 NOT_PRODUCT(int count_pending_recorders() const;) | |
105 | |
106 NOT_PRODUCT(int _sync_point_count;) | |
107 NOT_PRODUCT(int _merge_count;) | |
108 NOT_PRODUCT(int _last_gen_in_use;) | |
109 | |
7971
4102b59539ce
8005012: Add WB APIs to better support NMT testing
ctornqvi
parents:
7464
diff
changeset
|
110 // how many generations are queued |
6197 | 111 inline int generations_in_use() const { |
6231 | 112 return (_tail >= _head ? (_tail - _head + 1) : (MAX_GENERATIONS - (_head - _tail) + 1)); |
6197 | 113 } |
114 }; | |
115 | |
116 #endif // SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP |