Skip to content

Commit bf26a25

Browse files
author
Thomas Schatzl
committed
8264027: Refactor "CLEANUP" region printing
Reviewed-by: kbarrett, ayang
1 parent eb6330e commit bf26a25

File tree

4 files changed

+50
-27
lines changed

4 files changed

+50
-27
lines changed

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4031,7 +4031,6 @@ void G1CollectedHeap::free_region(HeapRegion* hr, FreeRegionList* free_list) {
40314031
void G1CollectedHeap::free_humongous_region(HeapRegion* hr,
40324032
FreeRegionList* free_list) {
40334033
assert(hr->is_humongous(), "this is only for humongous regions");
4034-
assert(free_list != NULL, "pre-condition");
40354034
hr->clear_humongous();
40364035
free_region(hr, free_list);
40374036
}
@@ -4183,6 +4182,7 @@ class G1FreeCollectionSetTask : public AbstractGangTask {
41834182

41844183
// Free the region and and its remembered set.
41854184
_g1h->free_region(r, NULL);
4185+
_g1h->hr_printer()->cleanup(r);
41864186
}
41874187

41884188
void handle_failed_region(HeapRegion* r) {
@@ -4336,16 +4336,14 @@ void G1CollectedHeap::free_collection_set(G1CollectionSet* collection_set, G1Eva
43364336
}
43374337

43384338
class G1FreeHumongousRegionClosure : public HeapRegionClosure {
4339-
private:
4340-
FreeRegionList* _free_region_list;
43414339
HeapRegionSet* _proxy_set;
43424340
uint _humongous_objects_reclaimed;
43434341
uint _humongous_regions_reclaimed;
43444342
size_t _freed_bytes;
43454343
public:
43464344

4347-
G1FreeHumongousRegionClosure(FreeRegionList* free_region_list) :
4348-
_free_region_list(free_region_list), _proxy_set(NULL), _humongous_objects_reclaimed(0), _humongous_regions_reclaimed(0), _freed_bytes(0) {
4345+
G1FreeHumongousRegionClosure() :
4346+
_proxy_set(NULL), _humongous_objects_reclaimed(0), _humongous_regions_reclaimed(0), _freed_bytes(0) {
43494347
}
43504348

43514349
virtual bool do_heap_region(HeapRegion* r) {
@@ -4430,7 +4428,8 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure {
44304428
_freed_bytes += r->used();
44314429
r->set_containing_set(NULL);
44324430
_humongous_regions_reclaimed++;
4433-
g1h->free_humongous_region(r, _free_region_list);
4431+
g1h->free_humongous_region(r, NULL);
4432+
g1h->hr_printer()->cleanup(r);
44344433
r = next;
44354434
} while (r != NULL);
44364435

@@ -4461,22 +4460,11 @@ void G1CollectedHeap::eagerly_reclaim_humongous_regions() {
44614460

44624461
double start_time = os::elapsedTime();
44634462

4464-
FreeRegionList local_cleanup_list("Local Humongous Cleanup List");
4465-
4466-
G1FreeHumongousRegionClosure cl(&local_cleanup_list);
4463+
G1FreeHumongousRegionClosure cl;
44674464
heap_region_iterate(&cl);
44684465

44694466
remove_from_old_gen_sets(0, 0, cl.humongous_regions_reclaimed());
44704467

4471-
G1HRPrinter* hrp = hr_printer();
4472-
if (hrp->is_active()) {
4473-
FreeRegionListIterator iter(&local_cleanup_list);
4474-
while (iter.more_available()) {
4475-
HeapRegion* hr = iter.get_next();
4476-
hrp->cleanup(hr);
4477-
}
4478-
}
4479-
44804468
decrement_summary_bytes(cl.bytes_freed());
44814469

44824470
phase_times()->record_fast_reclaim_humongous_time_ms((os::elapsedTime() - start_time) * 1000.0,

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,14 +1288,7 @@ void G1ConcurrentMark::reclaim_empty_regions() {
12881288
if (!empty_regions_list.is_empty()) {
12891289
log_debug(gc)("Reclaimed %u empty regions", empty_regions_list.length());
12901290
// Now print the empty regions list.
1291-
G1HRPrinter* hrp = _g1h->hr_printer();
1292-
if (hrp->is_active()) {
1293-
FreeRegionListIterator iter(&empty_regions_list);
1294-
while (iter.more_available()) {
1295-
HeapRegion* hr = iter.get_next();
1296-
hrp->cleanup(hr);
1297-
}
1298-
}
1291+
_g1h->hr_printer()->cleanup(&empty_regions_list);
12991292
// And actually make them available.
13001293
_g1h->prepend_to_freelist(&empty_regions_list);
13011294
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
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+
25+
#include "precompiled.hpp"
26+
27+
#include "gc/g1/g1HRPrinter.hpp"
28+
#include "gc/g1/heapRegionSet.hpp"
29+
30+
void G1HRPrinter::cleanup(FreeRegionList* cleanup_list) {
31+
if (is_active()) {
32+
FreeRegionListIterator iter(cleanup_list);
33+
while (iter.more_available()) {
34+
HeapRegion* hr = iter.get_next();
35+
cleanup(hr);
36+
}
37+
}
38+
}

src/hotspot/share/gc/g1/g1HRPrinter.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,8 @@
3030

3131
#define SKIP_RETIRED_FULL_REGIONS 1
3232

33+
class FreeRegionList;
34+
3335
class G1HRPrinter {
3436

3537
private:
@@ -86,6 +88,8 @@ class G1HRPrinter {
8688
}
8789
}
8890

91+
void cleanup(FreeRegionList* free_list);
92+
8993
void post_compaction(HeapRegion* hr) {
9094
if (is_active()) {
9195
print("POST-COMPACTION", hr);

0 commit comments

Comments
 (0)