101 // calculate used / committed bytes for these three pools is related |
101 // calculate used / committed bytes for these three pools is related |
102 // (see comment above), we put the calculations in this class so that |
102 // (see comment above), we put the calculations in this class so that |
103 // we can easily share them among the subclasses. |
103 // we can easily share them among the subclasses. |
104 class G1MemoryPoolSuper : public CollectedMemoryPool { |
104 class G1MemoryPoolSuper : public CollectedMemoryPool { |
105 private: |
105 private: |
106 G1CollectedHeap* _g1h; |
|
107 |
|
108 // It returns x - y if x > y, 0 otherwise. |
106 // It returns x - y if x > y, 0 otherwise. |
109 // As described in the comment above, some of the inputs to the |
107 // As described in the comment above, some of the inputs to the |
110 // calculations we have to do are obtained concurrently and hence |
108 // calculations we have to do are obtained concurrently and hence |
111 // may be inconsistent with each other. So, this provides a |
109 // may be inconsistent with each other. So, this provides a |
112 // defensive way of performing the subtraction and avoids the value |
110 // defensive way of performing the subtraction and avoids the value |
150 static size_t survivor_space_max(G1CollectedHeap* g1h); |
150 static size_t survivor_space_max(G1CollectedHeap* g1h); |
151 |
151 |
152 static size_t old_space_committed(G1CollectedHeap* g1h); |
152 static size_t old_space_committed(G1CollectedHeap* g1h); |
153 static size_t old_space_used(G1CollectedHeap* g1h); |
153 static size_t old_space_used(G1CollectedHeap* g1h); |
154 static size_t old_space_max(G1CollectedHeap* g1h); |
154 static size_t old_space_max(G1CollectedHeap* g1h); |
155 |
|
156 // The non-static versions are included for convenience. |
|
157 |
|
158 size_t eden_space_committed() { |
|
159 return eden_space_committed(_g1h); |
|
160 } |
|
161 size_t eden_space_used() { |
|
162 return eden_space_used(_g1h); |
|
163 } |
|
164 size_t eden_space_max() { |
|
165 return eden_space_max(_g1h); |
|
166 } |
|
167 |
|
168 size_t survivor_space_committed() { |
|
169 return survivor_space_committed(_g1h); |
|
170 } |
|
171 size_t survivor_space_used() { |
|
172 return survivor_space_used(_g1h); |
|
173 } |
|
174 size_t survivor_space_max() { |
|
175 return survivor_space_max(_g1h); |
|
176 } |
|
177 |
|
178 size_t old_space_committed() { |
|
179 return old_space_committed(_g1h); |
|
180 } |
|
181 size_t old_space_used() { |
|
182 return old_space_used(_g1h); |
|
183 } |
|
184 size_t old_space_max() { |
|
185 return old_space_max(_g1h); |
|
186 } |
|
187 }; |
155 }; |
188 |
156 |
189 // Memory pool that represents the G1 eden. |
157 // Memory pool that represents the G1 eden. |
190 class G1EdenPool : public G1MemoryPoolSuper { |
158 class G1EdenPool : public G1MemoryPoolSuper { |
191 public: |
159 public: |
192 G1EdenPool(G1CollectedHeap* g1h); |
160 G1EdenPool(G1CollectedHeap* g1h); |
193 |
161 |
194 size_t used_in_bytes() { |
162 size_t used_in_bytes() { |
195 return eden_space_used(); |
163 return eden_space_used(_g1h); |
196 } |
164 } |
197 size_t max_size() { |
165 size_t max_size() const { |
198 return eden_space_max(); |
166 return eden_space_max(_g1h); |
199 } |
167 } |
200 MemoryUsage get_memory_usage(); |
168 MemoryUsage get_memory_usage(); |
201 }; |
169 }; |
202 |
170 |
203 // Memory pool that represents the G1 survivor. |
171 // Memory pool that represents the G1 survivor. |
204 class G1SurvivorPool : public G1MemoryPoolSuper { |
172 class G1SurvivorPool : public G1MemoryPoolSuper { |
205 public: |
173 public: |
206 G1SurvivorPool(G1CollectedHeap* g1h); |
174 G1SurvivorPool(G1CollectedHeap* g1h); |
207 |
175 |
208 size_t used_in_bytes() { |
176 size_t used_in_bytes() { |
209 return survivor_space_used(); |
177 return survivor_space_used(_g1h); |
210 } |
178 } |
211 size_t max_size() { |
179 size_t max_size() const { |
212 return survivor_space_max(); |
180 return survivor_space_max(_g1h); |
213 } |
181 } |
214 MemoryUsage get_memory_usage(); |
182 MemoryUsage get_memory_usage(); |
215 }; |
183 }; |
216 |
184 |
217 // Memory pool that represents the G1 old gen. |
185 // Memory pool that represents the G1 old gen. |
218 class G1OldGenPool : public G1MemoryPoolSuper { |
186 class G1OldGenPool : public G1MemoryPoolSuper { |
219 public: |
187 public: |
220 G1OldGenPool(G1CollectedHeap* g1h); |
188 G1OldGenPool(G1CollectedHeap* g1h); |
221 |
189 |
222 size_t used_in_bytes() { |
190 size_t used_in_bytes() { |
223 return old_space_used(); |
191 return old_space_used(_g1h); |
224 } |
192 } |
225 size_t max_size() { |
193 size_t max_size() const { |
226 return old_space_max(); |
194 return old_space_max(_g1h); |
227 } |
195 } |
228 MemoryUsage get_memory_usage(); |
196 MemoryUsage get_memory_usage(); |
229 }; |
197 }; |