4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #include "gc/shenandoah/shenandoahHeapRegionSet.hpp"
25 #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
26 #include "utilities/quickSort.hpp"
27
28 ShenandoahHeapRegionSet::ShenandoahHeapRegionSet(size_t max_regions):
29 _reserved_end(max_regions),
30 _active_end(0),
31 _regions(NEW_C_HEAP_ARRAY(ShenandoahHeapRegion*, max_regions, mtGC)),
32 _current_index(0)
33 {
34 }
35
36 ShenandoahHeapRegionSet::~ShenandoahHeapRegionSet() {
37 FREE_C_HEAP_ARRAY(ShenandoahHeapRegion*, _regions);
38 }
39
40 class PrintHeapRegionClosure : public ShenandoahHeapRegionClosure {
41 public:
42 bool doHeapRegion(ShenandoahHeapRegion* r) {
43 r->print();
66 void ShenandoahHeapRegionSet::add_region(ShenandoahHeapRegion* r) {
67 if (_active_end < _reserved_end) {
68 _regions[_active_end] = r;
69 _active_end++;
70 }
71 }
72
73 // Apply blk->doHeapRegion() on all committed regions in address order,
74 // terminating the iteration early if doHeapRegion() returns true.
75 void ShenandoahHeapRegionSet::active_heap_region_iterate(ShenandoahHeapRegionClosure* blk,
76 bool skip_dirty_regions,
77 bool skip_humongous_continuation) const {
78 size_t i;
79 for (i = 0; i < _active_end; i++) {
80 ShenandoahHeapRegion* current = _regions[i];
81 assert(current->region_number() <= _reserved_end, "Tautology");
82
83 if (skip_humongous_continuation && current->is_humongous_continuation()) {
84 continue;
85 }
86 if (skip_dirty_regions && current->is_in_collection_set()) {
87 continue;
88 }
89 if (blk->doHeapRegion(current)) {
90 return;
91 }
92 }
93 }
94
95 void ShenandoahHeapRegionSet::unclaimed_heap_region_iterate(ShenandoahHeapRegionClosure* blk,
96 bool skip_dirty_regions,
97 bool skip_humongous_continuation) const {
98 size_t i;
99 for (i = _current_index + 1; i < _active_end; i++) {
100 ShenandoahHeapRegion* current = _regions[i];
101 assert(current->region_number() <= _reserved_end, "Tautology");
102
103 if (skip_humongous_continuation && current->is_humongous_continuation()) {
104 continue;
105 }
106 if (skip_dirty_regions && current->is_in_collection_set()) {
107 continue;
108 }
109 if (blk->doHeapRegion(current)) {
110 return;
111 }
112 }
113 }
114
115 // Iterates over all of the regions.
116 void ShenandoahHeapRegionSet::heap_region_iterate(ShenandoahHeapRegionClosure* blk,
117 bool skip_dirty_regions,
118 bool skip_humongous_continuation) const {
119 active_heap_region_iterate(blk, skip_dirty_regions, skip_humongous_continuation);
120 }
121
122 class PrintHeapRegionsClosure : public
123 ShenandoahHeapRegionClosure {
124 private:
125 outputStream* _st;
126 public:
|
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #include "gc/shenandoah/shenandoahHeap.hpp"
25 #include "gc/shenandoah/shenandoahHeapRegionSet.hpp"
26 #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
27 #include "utilities/quickSort.hpp"
28
29 ShenandoahHeapRegionSet::ShenandoahHeapRegionSet(size_t max_regions):
30 _reserved_end(max_regions),
31 _active_end(0),
32 _regions(NEW_C_HEAP_ARRAY(ShenandoahHeapRegion*, max_regions, mtGC)),
33 _current_index(0)
34 {
35 }
36
37 ShenandoahHeapRegionSet::~ShenandoahHeapRegionSet() {
38 FREE_C_HEAP_ARRAY(ShenandoahHeapRegion*, _regions);
39 }
40
41 class PrintHeapRegionClosure : public ShenandoahHeapRegionClosure {
42 public:
43 bool doHeapRegion(ShenandoahHeapRegion* r) {
44 r->print();
67 void ShenandoahHeapRegionSet::add_region(ShenandoahHeapRegion* r) {
68 if (_active_end < _reserved_end) {
69 _regions[_active_end] = r;
70 _active_end++;
71 }
72 }
73
74 // Apply blk->doHeapRegion() on all committed regions in address order,
75 // terminating the iteration early if doHeapRegion() returns true.
76 void ShenandoahHeapRegionSet::active_heap_region_iterate(ShenandoahHeapRegionClosure* blk,
77 bool skip_dirty_regions,
78 bool skip_humongous_continuation) const {
79 size_t i;
80 for (i = 0; i < _active_end; i++) {
81 ShenandoahHeapRegion* current = _regions[i];
82 assert(current->region_number() <= _reserved_end, "Tautology");
83
84 if (skip_humongous_continuation && current->is_humongous_continuation()) {
85 continue;
86 }
87 if (skip_dirty_regions && current->in_collection_set()) {
88 continue;
89 }
90 if (blk->doHeapRegion(current)) {
91 return;
92 }
93 }
94 }
95
96 void ShenandoahHeapRegionSet::unclaimed_heap_region_iterate(ShenandoahHeapRegionClosure* blk,
97 bool skip_dirty_regions,
98 bool skip_humongous_continuation) const {
99 size_t i;
100 for (i = _current_index + 1; i < _active_end; i++) {
101 ShenandoahHeapRegion* current = _regions[i];
102 assert(current->region_number() <= _reserved_end, "Tautology");
103
104 if (skip_humongous_continuation && current->is_humongous_continuation()) {
105 continue;
106 }
107 if (skip_dirty_regions && current->in_collection_set()) {
108 continue;
109 }
110 if (blk->doHeapRegion(current)) {
111 return;
112 }
113 }
114 }
115
116 // Iterates over all of the regions.
117 void ShenandoahHeapRegionSet::heap_region_iterate(ShenandoahHeapRegionClosure* blk,
118 bool skip_dirty_regions,
119 bool skip_humongous_continuation) const {
120 active_heap_region_iterate(blk, skip_dirty_regions, skip_humongous_continuation);
121 }
122
123 class PrintHeapRegionsClosure : public
124 ShenandoahHeapRegionClosure {
125 private:
126 outputStream* _st;
127 public:
|