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 #ifndef SHARE_GC_Z_ZRELOCATIONSETSELECTOR_HPP 25 #define SHARE_GC_Z_ZRELOCATIONSETSELECTOR_HPP 26 27 #include "gc/z/zArray.hpp" 28 #include "memory/allocation.hpp" 29 30 class ZPage; 31 class ZRelocationSet; 32 33 class ZRelocationSetSelectorGroup { 34 private: 35 const char* const _name; 36 const size_t _page_size; 37 const size_t _object_size_limit; 38 const size_t _fragmentation_limit; 39 40 ZArray<ZPage*> _registered_pages; 41 ZPage** _sorted_pages; 42 size_t _nselected; 43 size_t _relocating; 44 45 void semi_sort(); 46 47 public: 48 ZRelocationSetSelectorGroup(const char* name, 49 size_t page_size, 50 size_t object_size_limit); 51 ~ZRelocationSetSelectorGroup(); 52 53 void register_live_page(ZPage* page, size_t garbage); 54 void select(); 55 56 ZPage* const* selected() const; 57 size_t nselected() const; 58 size_t relocating() const; 59 }; 60 61 class ZRelocationSetSelector : public StackObj { 62 private: 63 ZRelocationSetSelectorGroup _small; 64 ZRelocationSetSelectorGroup _medium; 65 size_t _live; 66 size_t _garbage; 67 68 public: 69 ZRelocationSetSelector(); 70 71 void register_live_page(ZPage* page); 72 void register_garbage_page(ZPage* page); 73 void select(ZRelocationSet* relocation_set); 74 75 size_t live() const; 76 size_t garbage() const; 77 size_t relocating() const; 78 }; 79 80 #endif // SHARE_GC_Z_ZRELOCATIONSETSELECTOR_HPP | 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 #ifndef SHARE_GC_Z_ZRELOCATIONSETSELECTOR_HPP 25 #define SHARE_GC_Z_ZRELOCATIONSETSELECTOR_HPP 26 27 #include "gc/z/zArray.hpp" 28 #include "memory/allocation.hpp" 29 30 class ZPage; 31 class ZRelocationSet; 32 33 class ZRelocationSetSelectorGroupStats { 34 friend class ZRelocationSetSelectorGroup; 35 36 private: 37 size_t _npages; 38 size_t _total; 39 size_t _live; 40 size_t _garbage; 41 size_t _empty; 42 size_t _compacting_from; 43 size_t _compacting_to; 44 45 public: 46 ZRelocationSetSelectorGroupStats(); 47 48 size_t npages() const; 49 size_t total() const; 50 size_t live() const; 51 size_t garbage() const; 52 size_t empty() const; 53 size_t compacting_from() const; 54 size_t compacting_to() const; 55 }; 56 57 class ZRelocationSetSelectorStats { 58 friend class ZRelocationSetSelector; 59 60 private: 61 ZRelocationSetSelectorGroupStats _small; 62 ZRelocationSetSelectorGroupStats _medium; 63 ZRelocationSetSelectorGroupStats _large; 64 65 public: 66 const ZRelocationSetSelectorGroupStats& small() const; 67 const ZRelocationSetSelectorGroupStats& medium() const; 68 const ZRelocationSetSelectorGroupStats& large() const; 69 }; 70 71 class ZRelocationSetSelectorGroup { 72 private: 73 const char* const _name; 74 const size_t _page_size; 75 const size_t _object_size_limit; 76 const size_t _fragmentation_limit; 77 78 ZArray<ZPage*> _registered_pages; 79 ZPage** _sorted_pages; 80 size_t _nselected; 81 ZRelocationSetSelectorGroupStats _stats; 82 83 void semi_sort(); 84 85 public: 86 ZRelocationSetSelectorGroup(const char* name, 87 size_t page_size, 88 size_t object_size_limit); 89 ~ZRelocationSetSelectorGroup(); 90 91 void register_live_page(ZPage* page); 92 void register_garbage_page(ZPage* page); 93 void select(); 94 95 ZPage* const* selected() const; 96 size_t nselected() const; 97 98 const ZRelocationSetSelectorGroupStats& stats() const; 99 }; 100 101 class ZRelocationSetSelector : public StackObj { 102 private: 103 ZRelocationSetSelectorGroup _small; 104 ZRelocationSetSelectorGroup _medium; 105 ZRelocationSetSelectorGroup _large; 106 107 public: 108 ZRelocationSetSelector(); 109 110 void register_live_page(ZPage* page); 111 void register_garbage_page(ZPage* page); 112 void select(ZRelocationSet* relocation_set); 113 114 ZRelocationSetSelectorStats stats() const; 115 }; 116 117 #endif // SHARE_GC_Z_ZRELOCATIONSETSELECTOR_HPP |