Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 1 | /* |
Per Lidén | 4dc240f | 2015-05-13 15:16:06 +0200 | [diff] [blame] | 2 | * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 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 | |
Per Lidén | 4dc240f | 2015-05-13 15:16:06 +0200 | [diff] [blame] | 25 | #ifndef SHARE_VM_GC_SHARED_GCHEAPSUMMARY_HPP |
| 26 | #define SHARE_VM_GC_SHARED_GCHEAPSUMMARY_HPP |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 27 | |
| 28 | #include "memory/allocation.hpp" |
Erik Helin | 853fffb | 2014-03-18 09:03:28 +0100 | [diff] [blame] | 29 | #include "memory/metaspaceChunkFreeListSummary.hpp" |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 30 | |
| 31 | class VirtualSpaceSummary : public StackObj { |
| 32 | HeapWord* _start; |
| 33 | HeapWord* _committed_end; |
| 34 | HeapWord* _reserved_end; |
| 35 | public: |
| 36 | VirtualSpaceSummary() : |
| 37 | _start(NULL), _committed_end(NULL), _reserved_end(NULL) { } |
| 38 | VirtualSpaceSummary(HeapWord* start, HeapWord* committed_end, HeapWord* reserved_end) : |
| 39 | _start(start), _committed_end(committed_end), _reserved_end(reserved_end) { } |
| 40 | |
| 41 | HeapWord* start() const { return _start; } |
| 42 | HeapWord* committed_end() const { return _committed_end; } |
| 43 | HeapWord* reserved_end() const { return _reserved_end; } |
| 44 | size_t committed_size() const { return (uintptr_t)_committed_end - (uintptr_t)_start; } |
| 45 | size_t reserved_size() const { return (uintptr_t)_reserved_end - (uintptr_t)_start; } |
| 46 | }; |
| 47 | |
| 48 | class SpaceSummary : public StackObj { |
| 49 | HeapWord* _start; |
| 50 | HeapWord* _end; |
| 51 | size_t _used; |
| 52 | public: |
| 53 | SpaceSummary() : |
| 54 | _start(NULL), _end(NULL), _used(0) { } |
| 55 | SpaceSummary(HeapWord* start, HeapWord* end, size_t used) : |
| 56 | _start(start), _end(end), _used(used) { } |
| 57 | |
| 58 | HeapWord* start() const { return _start; } |
| 59 | HeapWord* end() const { return _end; } |
| 60 | size_t used() const { return _used; } |
| 61 | size_t size() const { return (uintptr_t)_end - (uintptr_t)_start; } |
| 62 | }; |
| 63 | |
| 64 | class MetaspaceSizes : public StackObj { |
Erik Helin | a00bf70 | 2014-03-26 14:15:02 +0100 | [diff] [blame] | 65 | size_t _committed; |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 66 | size_t _used; |
| 67 | size_t _reserved; |
| 68 | |
| 69 | public: |
Erik Helin | a00bf70 | 2014-03-26 14:15:02 +0100 | [diff] [blame] | 70 | MetaspaceSizes() : _committed(0), _used(0), _reserved(0) {} |
| 71 | MetaspaceSizes(size_t committed, size_t used, size_t reserved) : |
| 72 | _committed(committed), _used(used), _reserved(reserved) {} |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 73 | |
Erik Helin | a00bf70 | 2014-03-26 14:15:02 +0100 | [diff] [blame] | 74 | size_t committed() const { return _committed; } |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 75 | size_t used() const { return _used; } |
| 76 | size_t reserved() const { return _reserved; } |
| 77 | }; |
| 78 | |
| 79 | class GCHeapSummary; |
| 80 | class PSHeapSummary; |
David Lindholm | c3f3f0f | 2015-06-12 12:55:32 +0200 | [diff] [blame] | 81 | class G1HeapSummary; |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 82 | |
| 83 | class GCHeapSummaryVisitor { |
| 84 | public: |
| 85 | virtual void visit(const GCHeapSummary* heap_summary) const = 0; |
| 86 | virtual void visit(const PSHeapSummary* heap_summary) const {} |
David Lindholm | c3f3f0f | 2015-06-12 12:55:32 +0200 | [diff] [blame] | 87 | virtual void visit(const G1HeapSummary* heap_summary) const {} |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | class GCHeapSummary : public StackObj { |
| 91 | VirtualSpaceSummary _heap; |
| 92 | size_t _used; |
| 93 | |
| 94 | public: |
| 95 | GCHeapSummary() : |
| 96 | _heap(), _used(0) { } |
| 97 | GCHeapSummary(VirtualSpaceSummary& heap_space, size_t used) : |
| 98 | _heap(heap_space), _used(used) { } |
| 99 | |
| 100 | const VirtualSpaceSummary& heap() const { return _heap; } |
| 101 | size_t used() const { return _used; } |
| 102 | |
| 103 | virtual void accept(GCHeapSummaryVisitor* visitor) const { |
| 104 | visitor->visit(this); |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | class PSHeapSummary : public GCHeapSummary { |
| 109 | VirtualSpaceSummary _old; |
| 110 | SpaceSummary _old_space; |
| 111 | VirtualSpaceSummary _young; |
| 112 | SpaceSummary _eden; |
| 113 | SpaceSummary _from; |
| 114 | SpaceSummary _to; |
| 115 | public: |
| 116 | PSHeapSummary(VirtualSpaceSummary& heap_space, size_t heap_used, VirtualSpaceSummary old, SpaceSummary old_space, VirtualSpaceSummary young, SpaceSummary eden, SpaceSummary from, SpaceSummary to) : |
| 117 | GCHeapSummary(heap_space, heap_used), _old(old), _old_space(old_space), _young(young), _eden(eden), _from(from), _to(to) { } |
| 118 | const VirtualSpaceSummary& old() const { return _old; } |
| 119 | const SpaceSummary& old_space() const { return _old_space; } |
| 120 | const VirtualSpaceSummary& young() const { return _young; } |
| 121 | const SpaceSummary& eden() const { return _eden; } |
| 122 | const SpaceSummary& from() const { return _from; } |
| 123 | const SpaceSummary& to() const { return _to; } |
| 124 | |
| 125 | virtual void accept(GCHeapSummaryVisitor* visitor) const { |
| 126 | visitor->visit(this); |
| 127 | } |
| 128 | }; |
| 129 | |
David Lindholm | c3f3f0f | 2015-06-12 12:55:32 +0200 | [diff] [blame] | 130 | class G1HeapSummary : public GCHeapSummary { |
| 131 | size_t _edenUsed; |
| 132 | size_t _edenCapacity; |
| 133 | size_t _survivorUsed; |
David Lindholm | 19bc0f3 | 2016-02-11 16:49:12 +0100 | [diff] [blame] | 134 | uint _numberOfRegions; |
David Lindholm | c3f3f0f | 2015-06-12 12:55:32 +0200 | [diff] [blame] | 135 | public: |
David Lindholm | 19bc0f3 | 2016-02-11 16:49:12 +0100 | [diff] [blame] | 136 | G1HeapSummary(VirtualSpaceSummary& heap_space, size_t heap_used, size_t edenUsed, size_t edenCapacity, size_t survivorUsed, uint numberOfRegions) : |
| 137 | GCHeapSummary(heap_space, heap_used), _edenUsed(edenUsed), _edenCapacity(edenCapacity), _survivorUsed(survivorUsed), _numberOfRegions(numberOfRegions) { } |
David Lindholm | c3f3f0f | 2015-06-12 12:55:32 +0200 | [diff] [blame] | 138 | const size_t edenUsed() const { return _edenUsed; } |
| 139 | const size_t edenCapacity() const { return _edenCapacity; } |
| 140 | const size_t survivorUsed() const { return _survivorUsed; } |
David Lindholm | 19bc0f3 | 2016-02-11 16:49:12 +0100 | [diff] [blame] | 141 | const uint numberOfRegions() const { return _numberOfRegions; } |
David Lindholm | c3f3f0f | 2015-06-12 12:55:32 +0200 | [diff] [blame] | 142 | |
| 143 | virtual void accept(GCHeapSummaryVisitor* visitor) const { |
| 144 | visitor->visit(this); |
| 145 | } |
| 146 | }; |
| 147 | |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 148 | class MetaspaceSummary : public StackObj { |
Erik Helin | 1fb0683 | 2014-03-17 17:31:46 +0100 | [diff] [blame] | 149 | size_t _capacity_until_GC; |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 150 | MetaspaceSizes _meta_space; |
| 151 | MetaspaceSizes _data_space; |
| 152 | MetaspaceSizes _class_space; |
Erik Helin | 853fffb | 2014-03-18 09:03:28 +0100 | [diff] [blame] | 153 | MetaspaceChunkFreeListSummary _metaspace_chunk_free_list_summary; |
| 154 | MetaspaceChunkFreeListSummary _class_chunk_free_list_summary; |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 155 | |
| 156 | public: |
Erik Helin | 853fffb | 2014-03-18 09:03:28 +0100 | [diff] [blame] | 157 | MetaspaceSummary() : |
| 158 | _capacity_until_GC(0), |
| 159 | _meta_space(), |
| 160 | _data_space(), |
| 161 | _class_space(), |
| 162 | _metaspace_chunk_free_list_summary(), |
| 163 | _class_chunk_free_list_summary() |
| 164 | {} |
| 165 | MetaspaceSummary(size_t capacity_until_GC, |
| 166 | const MetaspaceSizes& meta_space, |
| 167 | const MetaspaceSizes& data_space, |
| 168 | const MetaspaceSizes& class_space, |
| 169 | const MetaspaceChunkFreeListSummary& metaspace_chunk_free_list_summary, |
| 170 | const MetaspaceChunkFreeListSummary& class_chunk_free_list_summary) : |
| 171 | _capacity_until_GC(capacity_until_GC), |
| 172 | _meta_space(meta_space), |
| 173 | _data_space(data_space), |
| 174 | _class_space(class_space), |
| 175 | _metaspace_chunk_free_list_summary(metaspace_chunk_free_list_summary), |
| 176 | _class_chunk_free_list_summary(class_chunk_free_list_summary) |
| 177 | {} |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 178 | |
Erik Helin | 1fb0683 | 2014-03-17 17:31:46 +0100 | [diff] [blame] | 179 | size_t capacity_until_GC() const { return _capacity_until_GC; } |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 180 | const MetaspaceSizes& meta_space() const { return _meta_space; } |
| 181 | const MetaspaceSizes& data_space() const { return _data_space; } |
| 182 | const MetaspaceSizes& class_space() const { return _class_space; } |
Erik Helin | 853fffb | 2014-03-18 09:03:28 +0100 | [diff] [blame] | 183 | |
| 184 | const MetaspaceChunkFreeListSummary& metaspace_chunk_free_list_summary() const { |
| 185 | return _metaspace_chunk_free_list_summary; |
| 186 | } |
| 187 | |
| 188 | const MetaspaceChunkFreeListSummary& class_chunk_free_list_summary() const { |
| 189 | return _class_chunk_free_list_summary; |
| 190 | } |
| 191 | |
Staffan Larsen | 718f325 | 2013-06-10 11:30:51 +0200 | [diff] [blame] | 192 | }; |
| 193 | |
Thomas Schatzl | 4a849fb | 2015-08-20 15:17:41 +0200 | [diff] [blame] | 194 | class G1EvacSummary : public StackObj { |
| 195 | private: |
| 196 | size_t _allocated; // Total allocated |
| 197 | size_t _wasted; // of which wasted (internal fragmentation) |
| 198 | size_t _undo_wasted; // of which wasted on undo (is not used for calculation of PLAB size) |
| 199 | size_t _unused; // Unused in last buffer |
| 200 | size_t _used; |
| 201 | |
| 202 | size_t _region_end_waste; // Number of words wasted due to skipping to the next region. |
| 203 | uint _regions_filled; // Number of regions filled completely. |
| 204 | size_t _direct_allocated; // Number of words allocated directly into the regions. |
| 205 | |
| 206 | // Number of words in live objects remaining in regions that ultimately suffered an |
| 207 | // evacuation failure. This is used in the regions when the regions are made old regions. |
| 208 | size_t _failure_used; |
| 209 | // Number of words wasted in regions which failed evacuation. This is the sum of space |
| 210 | // for objects successfully copied out of the regions (now dead space) plus waste at the |
| 211 | // end of regions. |
| 212 | size_t _failure_waste; |
| 213 | public: |
| 214 | G1EvacSummary(size_t allocated, size_t wasted, size_t undo_wasted, size_t unused, |
| 215 | size_t used, size_t region_end_waste, uint regions_filled, size_t direct_allocated, |
| 216 | size_t failure_used, size_t failure_waste) : |
| 217 | _allocated(allocated), _wasted(wasted), _undo_wasted(undo_wasted), _unused(unused), |
| 218 | _used(used), _region_end_waste(region_end_waste), _regions_filled(regions_filled), |
| 219 | _direct_allocated(direct_allocated), _failure_used(failure_used), _failure_waste(failure_waste) |
| 220 | { } |
| 221 | |
| 222 | size_t allocated() const { return _allocated; } |
| 223 | size_t wasted() const { return _wasted; } |
| 224 | size_t undo_wasted() const { return _undo_wasted; } |
| 225 | size_t unused() const { return _unused; } |
| 226 | size_t used() const { return _used; } |
| 227 | size_t region_end_waste() const { return _region_end_waste; } |
| 228 | uint regions_filled() const { return _regions_filled; } |
| 229 | size_t direct_allocated() const { return _direct_allocated; } |
| 230 | size_t failure_used() const { return _failure_used; } |
| 231 | size_t failure_waste() const { return _failure_waste; } |
| 232 | }; |
| 233 | |
Per Lidén | 4dc240f | 2015-05-13 15:16:06 +0200 | [diff] [blame] | 234 | #endif // SHARE_VM_GC_SHARED_GCHEAPSUMMARY_HPP |