Mercurial > hg > graal-compiler
annotate src/share/vm/services/memoryManager.hpp @ 1941:79d04223b8a5
Added caching for resolved types and resolved fields.
This is crucial, because the local load elimination will lead to wrong results, if field equality (of two RiField objects with the same object and the same RiType) is not given. The caching makes sure that the default equals implementation is sufficient.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Tue, 28 Dec 2010 18:33:26 +0100 |
parents | f6f3eef8a521 |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1089
diff
changeset
|
2 * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1089
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1089
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1089
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 // A memory manager is responsible for managing one or more memory pools. | |
26 // The garbage collector is one type of memory managers responsible | |
27 // for reclaiming memory occupied by unreachable objects. A Java virtual | |
28 // machine may have one or more memory managers. It may | |
29 // add or remove memory managers during execution. | |
30 // A memory pool can be managed by more than one memory managers. | |
31 | |
32 class MemoryPool; | |
33 class GCMemoryManager; | |
34 class OopClosure; | |
35 | |
36 class MemoryManager : public CHeapObj { | |
37 private: | |
38 enum { | |
39 max_num_pools = 10 | |
40 }; | |
41 | |
42 MemoryPool* _pools[max_num_pools]; | |
43 int _num_pools; | |
44 | |
45 protected: | |
46 volatile instanceOop _memory_mgr_obj; | |
47 | |
48 public: | |
49 enum Name { | |
50 Abstract, | |
51 CodeCache, | |
52 Copy, | |
53 MarkSweepCompact, | |
54 ParNew, | |
55 ConcurrentMarkSweep, | |
56 PSScavenge, | |
1089
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
57 PSMarkSweep, |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
58 G1YoungGen, |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
59 G1OldGen |
0 | 60 }; |
61 | |
62 MemoryManager(); | |
63 | |
64 int num_memory_pools() const { return _num_pools; } | |
65 MemoryPool* get_memory_pool(int index) { | |
66 assert(index >= 0 && index < _num_pools, "Invalid index"); | |
67 return _pools[index]; | |
68 } | |
69 | |
70 void add_pool(MemoryPool* pool); | |
71 | |
72 bool is_manager(instanceHandle mh) { return mh() == _memory_mgr_obj; } | |
73 | |
74 virtual instanceOop get_memory_manager_instance(TRAPS); | |
75 virtual MemoryManager::Name kind() { return MemoryManager::Abstract; } | |
76 virtual bool is_gc_memory_manager() { return false; } | |
77 virtual const char* name() = 0; | |
78 | |
79 // GC support | |
80 void oops_do(OopClosure* f); | |
81 | |
82 // Static factory methods to get a memory manager of a specific type | |
83 static MemoryManager* get_code_cache_memory_manager(); | |
84 static GCMemoryManager* get_copy_memory_manager(); | |
85 static GCMemoryManager* get_msc_memory_manager(); | |
86 static GCMemoryManager* get_parnew_memory_manager(); | |
87 static GCMemoryManager* get_cms_memory_manager(); | |
88 static GCMemoryManager* get_psScavenge_memory_manager(); | |
89 static GCMemoryManager* get_psMarkSweep_memory_manager(); | |
1089
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
90 static GCMemoryManager* get_g1YoungGen_memory_manager(); |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
91 static GCMemoryManager* get_g1OldGen_memory_manager(); |
0 | 92 |
93 }; | |
94 | |
95 class CodeCacheMemoryManager : public MemoryManager { | |
96 private: | |
97 public: | |
98 CodeCacheMemoryManager() : MemoryManager() {} | |
99 | |
100 MemoryManager::Name kind() { return MemoryManager::CodeCache; } | |
101 const char* name() { return "CodeCacheManager"; } | |
102 }; | |
103 | |
104 class GCStatInfo : public CHeapObj { | |
105 private: | |
106 size_t _index; | |
107 jlong _start_time; | |
108 jlong _end_time; | |
109 | |
110 // We keep memory usage of all memory pools | |
111 MemoryUsage* _before_gc_usage_array; | |
112 MemoryUsage* _after_gc_usage_array; | |
113 int _usage_array_size; | |
114 | |
115 void set_gc_usage(int pool_index, MemoryUsage, bool before_gc); | |
116 | |
117 public: | |
118 GCStatInfo(int num_pools); | |
119 ~GCStatInfo(); | |
120 | |
121 size_t gc_index() { return _index; } | |
122 jlong start_time() { return _start_time; } | |
123 jlong end_time() { return _end_time; } | |
124 int usage_array_size() { return _usage_array_size; } | |
125 MemoryUsage before_gc_usage_for_pool(int pool_index) { | |
126 assert(pool_index >= 0 && pool_index < _usage_array_size, "Range checking"); | |
127 return _before_gc_usage_array[pool_index]; | |
128 } | |
129 MemoryUsage after_gc_usage_for_pool(int pool_index) { | |
130 assert(pool_index >= 0 && pool_index < _usage_array_size, "Range checking"); | |
131 return _after_gc_usage_array[pool_index]; | |
132 } | |
133 | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
134 MemoryUsage* before_gc_usage_array() { return _before_gc_usage_array; } |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
135 MemoryUsage* after_gc_usage_array() { return _after_gc_usage_array; } |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
136 |
0 | 137 void set_index(size_t index) { _index = index; } |
138 void set_start_time(jlong time) { _start_time = time; } | |
139 void set_end_time(jlong time) { _end_time = time; } | |
140 void set_before_gc_usage(int pool_index, MemoryUsage usage) { | |
141 assert(pool_index >= 0 && pool_index < _usage_array_size, "Range checking"); | |
142 set_gc_usage(pool_index, usage, true /* before gc */); | |
143 } | |
144 void set_after_gc_usage(int pool_index, MemoryUsage usage) { | |
145 assert(pool_index >= 0 && pool_index < _usage_array_size, "Range checking"); | |
146 set_gc_usage(pool_index, usage, false /* after gc */); | |
147 } | |
148 | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
149 void clear(); |
0 | 150 }; |
151 | |
152 class GCMemoryManager : public MemoryManager { | |
153 private: | |
154 // TODO: We should unify the GCCounter and GCMemoryManager statistic | |
155 size_t _num_collections; | |
156 elapsedTimer _accumulated_timer; | |
157 elapsedTimer _gc_timer; // for measuring every GC duration | |
158 GCStatInfo* _last_gc_stat; | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
159 Mutex* _last_gc_lock; |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
160 GCStatInfo* _current_gc_stat; |
0 | 161 int _num_gc_threads; |
162 public: | |
163 GCMemoryManager(); | |
164 ~GCMemoryManager(); | |
165 | |
166 void initialize_gc_stat_info(); | |
167 | |
168 bool is_gc_memory_manager() { return true; } | |
169 jlong gc_time_ms() { return _accumulated_timer.milliseconds(); } | |
170 size_t gc_count() { return _num_collections; } | |
171 int num_gc_threads() { return _num_gc_threads; } | |
172 void set_num_gc_threads(int count) { _num_gc_threads = count; } | |
173 | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
174 void gc_begin(bool recordGCBeginTime, bool recordPreGCUsage, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
175 bool recordAccumulatedGCTime); |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
176 void gc_end(bool recordPostGCUsage, bool recordAccumulatedGCTime, |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
177 bool recordGCEndTime, bool countCollection); |
0 | 178 |
179 void reset_gc_stat() { _num_collections = 0; _accumulated_timer.reset(); } | |
1703
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
180 |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
181 // Copy out _last_gc_stat to the given destination, returning |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
182 // the collection count. Zero signifies no gc has taken place. |
f6f3eef8a521
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
1552
diff
changeset
|
183 size_t get_last_gc_stat(GCStatInfo* dest); |
0 | 184 |
185 virtual MemoryManager::Name kind() = 0; | |
186 }; | |
187 | |
188 // These subclasses of GCMemoryManager are defined to include | |
189 // GC-specific information. | |
190 // TODO: Add GC-specific information | |
191 class CopyMemoryManager : public GCMemoryManager { | |
192 private: | |
193 public: | |
194 CopyMemoryManager() : GCMemoryManager() {} | |
195 | |
196 MemoryManager::Name kind() { return MemoryManager::Copy; } | |
197 const char* name() { return "Copy"; } | |
198 }; | |
199 | |
200 class MSCMemoryManager : public GCMemoryManager { | |
201 private: | |
202 public: | |
203 MSCMemoryManager() : GCMemoryManager() {} | |
204 | |
205 MemoryManager::Name kind() { return MemoryManager::MarkSweepCompact; } | |
206 const char* name() { return "MarkSweepCompact"; } | |
207 | |
208 }; | |
209 | |
210 class ParNewMemoryManager : public GCMemoryManager { | |
211 private: | |
212 public: | |
213 ParNewMemoryManager() : GCMemoryManager() {} | |
214 | |
215 MemoryManager::Name kind() { return MemoryManager::ParNew; } | |
216 const char* name() { return "ParNew"; } | |
217 | |
218 }; | |
219 | |
220 class CMSMemoryManager : public GCMemoryManager { | |
221 private: | |
222 public: | |
223 CMSMemoryManager() : GCMemoryManager() {} | |
224 | |
225 MemoryManager::Name kind() { return MemoryManager::ConcurrentMarkSweep; } | |
226 const char* name() { return "ConcurrentMarkSweep";} | |
227 | |
228 }; | |
229 | |
230 class PSScavengeMemoryManager : public GCMemoryManager { | |
231 private: | |
232 public: | |
233 PSScavengeMemoryManager() : GCMemoryManager() {} | |
234 | |
235 MemoryManager::Name kind() { return MemoryManager::PSScavenge; } | |
236 const char* name() { return "PS Scavenge"; } | |
237 | |
238 }; | |
239 | |
240 class PSMarkSweepMemoryManager : public GCMemoryManager { | |
241 private: | |
242 public: | |
243 PSMarkSweepMemoryManager() : GCMemoryManager() {} | |
244 | |
245 MemoryManager::Name kind() { return MemoryManager::PSMarkSweep; } | |
246 const char* name() { return "PS MarkSweep"; } | |
247 }; | |
1089
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
248 |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
249 class G1YoungGenMemoryManager : public GCMemoryManager { |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
250 private: |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
251 public: |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
252 G1YoungGenMemoryManager() : GCMemoryManager() {} |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
253 |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
254 MemoryManager::Name kind() { return MemoryManager::G1YoungGen; } |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
255 const char* name() { return "G1 Young Generation"; } |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
256 }; |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
257 |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
258 class G1OldGenMemoryManager : public GCMemoryManager { |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
259 private: |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
260 public: |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
261 G1OldGenMemoryManager() : GCMemoryManager() {} |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
262 |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
263 MemoryManager::Name kind() { return MemoryManager::G1OldGen; } |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
264 const char* name() { return "G1 Old Generation"; } |
db0d5eba9d20
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents:
0
diff
changeset
|
265 }; |