--- old/src/hotspot/share/gc/z/zHeap.cpp 2020-01-21 12:40:44.279166431 +0100 +++ new/src/hotspot/share/gc/z/zHeap.cpp 2020-01-21 12:40:43.722155130 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -412,13 +412,8 @@ } // Update statistics - ZStatRelocation::set_at_select_relocation_set(selector.stats_small(), - selector.stats_medium(), - selector.stats_large()); - ZStatHeap::set_at_select_relocation_set(selector.stats_small(), - selector.stats_medium(), - selector.stats_large(), - reclaimed()); + ZStatRelocation::set_at_select_relocation_set(selector.stats()); + ZStatHeap::set_at_select_relocation_set(selector.stats(), reclaimed()); } void ZHeap::reset_relocation_set() { --- old/src/hotspot/share/gc/z/zRelocationSetSelector.cpp 2020-01-21 12:40:44.977180594 +0100 +++ new/src/hotspot/share/gc/z/zRelocationSetSelector.cpp 2020-01-21 12:40:44.457170043 +0100 @@ -220,3 +220,11 @@ relocation_set->populate(_medium.selected(), _medium.nselected(), _small.selected(), _small.nselected()); } + +ZRelocationSetSelectorStats ZRelocationSetSelector::stats() const { + ZRelocationSetSelectorStats stats; + stats._small = _small.stats(); + stats._medium = _medium.stats(); + stats._large = _large.stats(); + return stats; +} --- old/src/hotspot/share/gc/z/zRelocationSetSelector.hpp 2020-01-21 12:40:45.661194472 +0100 +++ new/src/hotspot/share/gc/z/zRelocationSetSelector.hpp 2020-01-21 12:40:45.139183881 +0100 @@ -54,6 +54,20 @@ size_t compacting_to() const; }; +class ZRelocationSetSelectorStats { + friend class ZRelocationSetSelector; + +private: + ZRelocationSetSelectorGroupStats _small; + ZRelocationSetSelectorGroupStats _medium; + ZRelocationSetSelectorGroupStats _large; + +public: + const ZRelocationSetSelectorGroupStats& small() const; + const ZRelocationSetSelectorGroupStats& medium() const; + const ZRelocationSetSelectorGroupStats& large() const; +}; + class ZRelocationSetSelectorGroup { private: const char* const _name; @@ -97,9 +111,7 @@ void register_garbage_page(ZPage* page); void select(ZRelocationSet* relocation_set); - const ZRelocationSetSelectorGroupStats& stats_small() const; - const ZRelocationSetSelectorGroupStats& stats_medium() const; - const ZRelocationSetSelectorGroupStats& stats_large() const; + ZRelocationSetSelectorStats stats() const; }; #endif // SHARE_GC_Z_ZRELOCATIONSETSELECTOR_HPP --- old/src/hotspot/share/gc/z/zRelocationSetSelector.inline.hpp 2020-01-21 12:40:46.339208228 +0100 +++ new/src/hotspot/share/gc/z/zRelocationSetSelector.inline.hpp 2020-01-21 12:40:45.820197698 +0100 @@ -54,28 +54,28 @@ return _compacting_to; } -inline ZPage* const* ZRelocationSetSelectorGroup::selected() const { - return _sorted_pages; +inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelectorStats::small() const { + return _small; } -inline size_t ZRelocationSetSelectorGroup::nselected() const { - return _nselected; +inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelectorStats::medium() const { + return _medium; } -inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelectorGroup::stats() const { - return _stats; +inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelectorStats::large() const { + return _large; } -inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelector::stats_small() const { - return _small.stats(); +inline ZPage* const* ZRelocationSetSelectorGroup::selected() const { + return _sorted_pages; } -inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelector::stats_medium() const { - return _medium.stats(); +inline size_t ZRelocationSetSelectorGroup::nselected() const { + return _nselected; } -inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelector::stats_large() const { - return _large.stats(); +inline const ZRelocationSetSelectorGroupStats& ZRelocationSetSelectorGroup::stats() const { + return _stats; } #endif // SHARE_GC_Z_ZRELOCATIONSETSELECTOR_INLINE_HPP --- old/src/hotspot/share/gc/z/zStat.cpp 2020-01-21 12:40:47.071223081 +0100 +++ new/src/hotspot/share/gc/z/zStat.cpp 2020-01-21 12:40:46.504211576 +0100 @@ -1128,53 +1128,33 @@ // // Stat relocation // -ZStatRelocation::Group ZStatRelocation::_small; -ZStatRelocation::Group ZStatRelocation::_medium; -ZStatRelocation::Group ZStatRelocation::_large; -bool ZStatRelocation::_success; - -void ZStatRelocation::set_at_select_relocation_set(const ZRelocationSetSelectorGroupStats& small, - const ZRelocationSetSelectorGroupStats& medium, - const ZRelocationSetSelectorGroupStats& large) { - _small._npages = small.npages(); - _small._total = small.total(); - _small._empty = small.empty(); - _small._compacting_from = small.compacting_from(); - _small._compacting_to = small.compacting_to(); - - _medium._npages = medium.npages(); - _medium._total = medium.total(); - _medium._empty = medium.empty(); - _medium._compacting_from = medium.compacting_from(); - _medium._compacting_to = medium.compacting_to(); - - _large._npages = large.npages(); - _large._total = large.total(); - _large._empty = large.empty(); - _large._compacting_from = large.compacting_from(); - _large._compacting_to = large.compacting_to(); +ZRelocationSetSelectorStats ZStatRelocation::_stats; +bool ZStatRelocation::_success; + +void ZStatRelocation::set_at_select_relocation_set(const ZRelocationSetSelectorStats& stats) { + _stats = stats; } void ZStatRelocation::set_at_relocate_end(bool success) { _success = success; } -void ZStatRelocation::print(const char* name, const ZStatRelocation::Group& group) { - const size_t total = _small._total + _medium._total + _large._total; +void ZStatRelocation::print(const char* name, const ZRelocationSetSelectorGroupStats& group) { + const size_t total = _stats.small().total() + _stats.medium().total() + _stats.large().total(); log_info(gc, reloc)("%s Pages: " SIZE_FORMAT " / " ZSIZE_FMT ", Empty: " ZSIZE_FMT ", Compacting: " ZSIZE_FMT "->" ZSIZE_FMT, name, - group._npages, - ZSIZE_ARGS_WITH_MAX(group._total, total), - ZSIZE_ARGS_WITH_MAX(group._empty, total), - ZSIZE_ARGS_WITH_MAX(group._compacting_from, total), - ZSIZE_ARGS_WITH_MAX(group._compacting_to, total)); + group.npages(), + ZSIZE_ARGS_WITH_MAX(group.total(), total), + ZSIZE_ARGS_WITH_MAX(group.empty(), total), + ZSIZE_ARGS_WITH_MAX(group.compacting_from(), total), + ZSIZE_ARGS_WITH_MAX(group.compacting_to(), total)); } void ZStatRelocation::print() { - print("Small", _small); - print("Medium", _medium); - print("Large", _large); + print("Small", _stats.small()); + print("Medium", _stats.medium()); + print("Large", _stats.large()); log_info(gc, reloc)("Relocation: %s", _success ? "Successful" : "Incomplete"); } @@ -1312,12 +1292,9 @@ _at_mark_end.free = free(used); } -void ZStatHeap::set_at_select_relocation_set(const ZRelocationSetSelectorGroupStats& small, - const ZRelocationSetSelectorGroupStats& medium, - const ZRelocationSetSelectorGroupStats& large, - size_t reclaimed) { - const size_t live = small.live() + medium.live() + large.live(); - const size_t garbage = small.garbage() + medium.garbage() + large.garbage(); +void ZStatHeap::set_at_select_relocation_set(const ZRelocationSetSelectorStats& stats, size_t reclaimed) { + const size_t live = stats.small().live() + stats.medium().live() + stats.large().live(); + const size_t garbage = stats.small().garbage() + stats.medium().garbage() + stats.large().garbage(); _at_mark_end.live = live; _at_mark_end.garbage = garbage; --- old/src/hotspot/share/gc/z/zStat.hpp 2020-01-21 12:40:47.805237973 +0100 +++ new/src/hotspot/share/gc/z/zStat.hpp 2020-01-21 12:40:47.282227362 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ class ZPage; class ZRelocationSetSelectorGroupStats; +class ZRelocationSetSelectorStats; class ZStatSampler; class ZStatSamplerHistory; struct ZStatCounterData; @@ -419,25 +420,13 @@ // class ZStatRelocation : public AllStatic { private: - struct Group { - size_t _npages; - size_t _total; - size_t _empty; - size_t _compacting_from; - size_t _compacting_to; - }; - - static Group _small; - static Group _medium; - static Group _large; - static bool _success; - - static void print(const char* name, const ZStatRelocation::Group& group); - -public: - static void set_at_select_relocation_set(const ZRelocationSetSelectorGroupStats& small, - const ZRelocationSetSelectorGroupStats& medium, - const ZRelocationSetSelectorGroupStats& large); + static ZRelocationSetSelectorStats _stats; + static bool _success; + + static void print(const char* name, const ZRelocationSetSelectorGroupStats& group); + +public: + static void set_at_select_relocation_set(const ZRelocationSetSelectorStats& stats); static void set_at_relocate_end(bool success); static void print(); @@ -555,9 +544,7 @@ static void set_at_mark_end(size_t capacity, size_t allocated, size_t used); - static void set_at_select_relocation_set(const ZRelocationSetSelectorGroupStats& small, - const ZRelocationSetSelectorGroupStats& medium, - const ZRelocationSetSelectorGroupStats& large, + static void set_at_select_relocation_set(const ZRelocationSetSelectorStats& stats, size_t reclaimed); static void set_at_relocate_start(size_t capacity, size_t allocated,