annotate src/share/vm/services/memoryPool.hpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents d2a62e0f25eb
children db9981fd3124
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_SERVICES_MEMORYPOOL_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_SERVICES_MEMORYPOOL_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "gc_implementation/shared/mutableSpace.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/defNewGeneration.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "memory/heap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "memory/space.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "services/memoryUsage.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #ifndef SERIALGC
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36
0
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // A memory pool represents the memory area that the VM manages.
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // The Java virtual machine has at least one memory pool
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // and it may create or remove memory pools during execution.
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // A memory pool can belong to the heap or the non-heap memory.
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // A Java virtual machine may also have memory pools belonging to
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // both heap and non-heap memory.
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // Forward declaration
a61af66fc99e Initial load
duke
parents:
diff changeset
45 class MemoryManager;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class SensorInfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 class Generation;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 class DefNewGeneration;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 class ThresholdSupport;
a61af66fc99e Initial load
duke
parents:
diff changeset
50
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
51 class MemoryPool : public CHeapObj<mtInternal> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 friend class MemoryManager;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
54 enum PoolType {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 Heap = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
56 NonHeap = 2
a61af66fc99e Initial load
duke
parents:
diff changeset
57 };
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
60 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 max_num_managers = 5
a61af66fc99e Initial load
duke
parents:
diff changeset
62 };
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // We could make some of the following as performance counters
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // for external monitoring.
a61af66fc99e Initial load
duke
parents:
diff changeset
66 const char* _name;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 PoolType _type;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 size_t _initial_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 size_t _max_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 bool _available_for_allocation; // Default is true
a61af66fc99e Initial load
duke
parents:
diff changeset
71 MemoryManager* _managers[max_num_managers];
a61af66fc99e Initial load
duke
parents:
diff changeset
72 int _num_managers;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 MemoryUsage _peak_usage; // Peak memory usage
a61af66fc99e Initial load
duke
parents:
diff changeset
74 MemoryUsage _after_gc_usage; // After GC memory usage
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 ThresholdSupport* _usage_threshold;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 ThresholdSupport* _gc_usage_threshold;
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 SensorInfo* _usage_sensor;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 SensorInfo* _gc_usage_sensor;
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 volatile instanceOop _memory_pool_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 void add_manager(MemoryManager* mgr);
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
87 MemoryPool(const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
88 PoolType type,
a61af66fc99e Initial load
duke
parents:
diff changeset
89 size_t init_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
90 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
91 bool support_usage_threshold,
a61af66fc99e Initial load
duke
parents:
diff changeset
92 bool support_gc_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 const char* name() { return _name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 bool is_heap() { return _type == Heap; }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 bool is_non_heap() { return _type == NonHeap; }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 size_t initial_size() const { return _initial_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 int num_memory_managers() const { return _num_managers; }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // max size could be changed
a61af66fc99e Initial load
duke
parents:
diff changeset
100 virtual size_t max_size() const { return _max_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 bool is_pool(instanceHandle pool) { return (pool() == _memory_pool_obj); }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 bool available_for_allocation() { return _available_for_allocation; }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 bool set_available_for_allocation(bool value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 bool prev = _available_for_allocation;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 _available_for_allocation = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 return prev;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 MemoryManager* get_memory_manager(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 assert(index >= 0 && index < _num_managers, "Invalid index");
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return _managers[index];
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Records current memory usage if it's a peak usage
a61af66fc99e Initial load
duke
parents:
diff changeset
117 void record_peak_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 MemoryUsage get_peak_memory_usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // check current memory usage first and then return peak usage
a61af66fc99e Initial load
duke
parents:
diff changeset
121 record_peak_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return _peak_usage;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 void reset_peak_memory_usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 _peak_usage = get_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 ThresholdSupport* usage_threshold() { return _usage_threshold; }
a61af66fc99e Initial load
duke
parents:
diff changeset
129 ThresholdSupport* gc_usage_threshold() { return _gc_usage_threshold; }
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 SensorInfo* usage_sensor() { return _usage_sensor; }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 SensorInfo* gc_usage_sensor() { return _gc_usage_sensor; }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 void set_usage_sensor_obj(instanceHandle s);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void set_gc_usage_sensor_obj(instanceHandle s);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 void set_last_collection_usage(MemoryUsage u) { _after_gc_usage = u; }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 virtual instanceOop get_memory_pool_instance(TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 virtual MemoryUsage get_memory_usage() = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 virtual size_t used_in_bytes() = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 virtual bool is_collected_pool() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 virtual MemoryUsage get_last_collection_usage() { return _after_gc_usage; }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // GC support
a61af66fc99e Initial load
duke
parents:
diff changeset
145 void oops_do(OopClosure* f);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 };
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 class CollectedMemoryPool : public MemoryPool {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
150 CollectedMemoryPool(const char* name, PoolType type, size_t init_size, size_t max_size, bool support_usage_threshold) :
a61af66fc99e Initial load
duke
parents:
diff changeset
151 MemoryPool(name, type, init_size, max_size, support_usage_threshold, true) {};
a61af66fc99e Initial load
duke
parents:
diff changeset
152 bool is_collected_pool() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 };
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 class ContiguousSpacePool : public CollectedMemoryPool {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
157 ContiguousSpace* _space;
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
160 ContiguousSpacePool(ContiguousSpace* space, const char* name, PoolType type, size_t max_size, bool support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 ContiguousSpace* space() { return _space; }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 MemoryUsage get_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
164 size_t used_in_bytes() { return space()->used(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 };
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 class SurvivorContiguousSpacePool : public CollectedMemoryPool {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
169 DefNewGeneration* _gen;
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
172 SurvivorContiguousSpacePool(DefNewGeneration* gen,
a61af66fc99e Initial load
duke
parents:
diff changeset
173 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
174 PoolType type,
a61af66fc99e Initial load
duke
parents:
diff changeset
175 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
176 bool support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 MemoryUsage get_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 size_t used_in_bytes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 return _gen->from()->used();
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 size_t committed_in_bytes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 return _gen->from()->capacity();
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 };
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
189 class CompactibleFreeListSpacePool : public CollectedMemoryPool {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
191 CompactibleFreeListSpace* _space;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
193 CompactibleFreeListSpacePool(CompactibleFreeListSpace* space,
a61af66fc99e Initial load
duke
parents:
diff changeset
194 const char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
195 PoolType type,
a61af66fc99e Initial load
duke
parents:
diff changeset
196 size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
197 bool support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 MemoryUsage get_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
200 size_t used_in_bytes() { return _space->used(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 };
a61af66fc99e Initial load
duke
parents:
diff changeset
202 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 class GenerationPool : public CollectedMemoryPool {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
207 Generation* _gen;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
209 GenerationPool(Generation* gen, const char* name, PoolType type, bool support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 MemoryUsage get_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
212 size_t used_in_bytes() { return _gen->used(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 };
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 class CodeHeapPool: public MemoryPool {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
217 CodeHeap* _codeHeap;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
219 CodeHeapPool(CodeHeap* codeHeap, const char* name, bool support_usage_threshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 MemoryUsage get_memory_usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
221 size_t used_in_bytes() { return _codeHeap->allocated_capacity(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
223
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
224 #endif // SHARE_VM_SERVICES_MEMORYPOOL_HPP