Skip to content

Commit 69aa971

Browse files
author
William Kemper
committed
8315875: GenShen: Remove heap mode check from ShenandoahInitLogger
Reviewed-by: kdnilsen, shade, ysr
1 parent 496addb commit 69aa971

File tree

7 files changed

+144
-49
lines changed

7 files changed

+144
-49
lines changed

src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "gc/shared/workerPolicy.hpp"
3030
#include "gc/shenandoah/shenandoahArguments.hpp"
3131
#include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
32+
#include "gc/shenandoah/shenandoahGenerationalHeap.hpp"
3233
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
3334
#include "gc/shenandoah/shenandoahHeapRegion.hpp"
3435
#include "runtime/globals_extension.hpp"
@@ -206,5 +207,8 @@ void ShenandoahArguments::initialize_alignments() {
206207
}
207208

208209
CollectedHeap* ShenandoahArguments::create_heap() {
210+
if (strcmp(ShenandoahGCMode, "generational") == 0) {
211+
return new ShenandoahGenerationalHeap(new ShenandoahCollectorPolicy());
212+
}
209213
return new ShenandoahHeap(new ShenandoahCollectorPolicy());
210214
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright Amazon.com Inc. 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/shenandoah/shenandoahGenerationalHeap.hpp"
28+
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
29+
#include "gc/shenandoah/shenandoahInitLogger.hpp"
30+
#include "gc/shenandoah/shenandoahOldGeneration.hpp"
31+
#include "gc/shenandoah/shenandoahYoungGeneration.hpp"
32+
33+
#include "logging/log.hpp"
34+
35+
class ShenandoahGenerationalInitLogger : public ShenandoahInitLogger {
36+
public:
37+
static void print() {
38+
ShenandoahGenerationalInitLogger logger;
39+
logger.print_all();
40+
}
41+
42+
void print_heap() override {
43+
ShenandoahInitLogger::print_heap();
44+
45+
ShenandoahGenerationalHeap* heap = ShenandoahGenerationalHeap::heap();
46+
47+
ShenandoahYoungGeneration* young = heap->young_generation();
48+
log_info(gc, init)("Young Generation Soft Size: " PROPERFMT, PROPERFMTARGS(young->soft_max_capacity()));
49+
log_info(gc, init)("Young Generation Max: " PROPERFMT, PROPERFMTARGS(young->max_capacity()));
50+
51+
ShenandoahOldGeneration* old = heap->old_generation();
52+
log_info(gc, init)("Old Generation Soft Size: " PROPERFMT, PROPERFMTARGS(old->soft_max_capacity()));
53+
log_info(gc, init)("Old Generation Max: " PROPERFMT, PROPERFMTARGS(old->max_capacity()));
54+
}
55+
56+
protected:
57+
void print_gc_specific() override {
58+
ShenandoahInitLogger::print_gc_specific();
59+
60+
ShenandoahGenerationalHeap* heap = ShenandoahGenerationalHeap::heap();
61+
log_info(gc, init)("Young Heuristics: %s", heap->young_generation()->heuristics()->name());
62+
log_info(gc, init)("Old Heuristics: %s", heap->old_generation()->heuristics()->name());
63+
}
64+
};
65+
66+
ShenandoahGenerationalHeap* ShenandoahGenerationalHeap::heap() {
67+
CollectedHeap* heap = Universe::heap();
68+
return checked_cast<ShenandoahGenerationalHeap*>(heap);
69+
}
70+
71+
void ShenandoahGenerationalHeap::print_init_logger() const {
72+
ShenandoahGenerationalInitLogger logger;
73+
logger.print_all();
74+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright Amazon.com Inc. 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+
#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHGENERATIONALHEAP
26+
#define SHARE_GC_SHENANDOAH_SHENANDOAHGENERATIONALHEAP
27+
28+
#include "gc/shenandoah/shenandoahHeap.hpp"
29+
30+
class ShenandoahGenerationalHeap : public ShenandoahHeap {
31+
public:
32+
explicit ShenandoahGenerationalHeap(ShenandoahCollectorPolicy* policy) : ShenandoahHeap(policy) {}
33+
34+
static ShenandoahGenerationalHeap* heap();
35+
36+
void print_init_logger() const override;
37+
};
38+
39+
#endif //SHARE_GC_SHENANDOAH_SHENANDOAHGENERATIONALHEAP

src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,15 @@ jint ShenandoahHeap::initialize() {
487487
_control_thread = new ShenandoahControlThread();
488488
_regulator_thread = new ShenandoahRegulatorThread(_control_thread);
489489

490-
ShenandoahInitLogger::print();
490+
print_init_logger();
491491

492492
return JNI_OK;
493493
}
494494

495+
void ShenandoahHeap::print_init_logger() const {
496+
ShenandoahInitLogger::print();
497+
}
498+
495499
size_t ShenandoahHeap::max_size_for(ShenandoahGeneration* generation) const {
496500
switch (generation->type()) {
497501
case YOUNG:
@@ -726,6 +730,9 @@ void ShenandoahHeap::post_initialize() {
726730
JFR_ONLY(ShenandoahJFRSupport::register_jfr_type_serializers());
727731
}
728732

733+
ShenandoahHeuristics* ShenandoahHeap::heuristics() {
734+
return _global_generation->heuristics();
735+
}
729736

730737
ShenandoahOldHeuristics* ShenandoahHeap::old_heuristics() {
731738
return (ShenandoahOldHeuristics*) _old_generation->heuristics();

src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ class ShenandoahHeap : public CollectedHeap {
179179
_gc_generation = generation;
180180
}
181181

182+
ShenandoahHeuristics* heuristics();
182183
ShenandoahOldHeuristics* old_heuristics();
183184
ShenandoahYoungHeuristics* young_heuristics();
184185

@@ -198,7 +199,7 @@ class ShenandoahHeap : public CollectedHeap {
198199
jint initialize() override;
199200
void post_initialize() override;
200201
void initialize_heuristics_generations();
201-
202+
virtual void print_init_logger() const;
202203
void initialize_serviceability() override;
203204

204205
void print_on(outputStream* st) const override;

src/hotspot/share/gc/shenandoah/shenandoahInitLogger.cpp

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,60 +27,29 @@
2727
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
2828
#include "gc/shenandoah/shenandoahHeapRegion.hpp"
2929
#include "gc/shenandoah/shenandoahInitLogger.hpp"
30-
#include "gc/shenandoah/shenandoahOldGeneration.hpp"
31-
#include "gc/shenandoah/shenandoahYoungGeneration.hpp"
3230
#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp"
3331
#include "gc/shenandoah/mode/shenandoahMode.hpp"
3432
#include "logging/log.hpp"
35-
#include "runtime/globals.hpp"
3633
#include "utilities/globalDefinitions.hpp"
3734

35+
void ShenandoahInitLogger::print() {
36+
ShenandoahInitLogger init_log;
37+
init_log.print_all();
38+
}
39+
3840
void ShenandoahInitLogger::print_heap() {
3941
GCInitLogger::print_heap();
4042

41-
ShenandoahHeap* heap = ShenandoahHeap::heap();
42-
43-
log_info(gc, init)("Mode: %s",
44-
heap->mode()->name());
45-
46-
if (!heap->mode()->is_generational()) {
47-
log_info(gc, init)("Heuristics: %s", heap->global_generation()->heuristics()->name());
48-
} else {
49-
log_info(gc, init)("Young Heuristics: %s", heap->young_generation()->heuristics()->name());
50-
log_info(gc, init)("Young Generation Soft Size: " SIZE_FORMAT "%s",
51-
byte_size_in_proper_unit(heap->young_generation()->soft_max_capacity()),
52-
proper_unit_for_byte_size(heap->young_generation()->soft_max_capacity()));
53-
log_info(gc, init)("Young Generation Max: " SIZE_FORMAT "%s",
54-
byte_size_in_proper_unit(heap->young_generation()->max_capacity()),
55-
proper_unit_for_byte_size(heap->young_generation()->max_capacity()));
56-
log_info(gc, init)("Old Heuristics: %s", heap->old_generation()->heuristics()->name());
57-
log_info(gc, init)("Old Generation Soft Size: " SIZE_FORMAT "%s",
58-
byte_size_in_proper_unit(heap->old_generation()->soft_max_capacity()),
59-
proper_unit_for_byte_size(heap->old_generation()->soft_max_capacity()));
60-
log_info(gc, init)("Old Generation Max: " SIZE_FORMAT "%s",
61-
byte_size_in_proper_unit(heap->old_generation()->max_capacity()),
62-
proper_unit_for_byte_size(heap->old_generation()->max_capacity()));
63-
}
64-
65-
66-
67-
log_info(gc, init)("Heap Region Count: " SIZE_FORMAT,
68-
ShenandoahHeapRegion::region_count());
69-
70-
log_info(gc, init)("Heap Region Size: " SIZE_FORMAT "%s",
71-
byte_size_in_exact_unit(ShenandoahHeapRegion::region_size_bytes()),
72-
exact_unit_for_byte_size(ShenandoahHeapRegion::region_size_bytes()));
73-
74-
log_info(gc, init)("TLAB Size Max: " SIZE_FORMAT "%s",
75-
byte_size_in_exact_unit(ShenandoahHeapRegion::max_tlab_size_bytes()),
76-
exact_unit_for_byte_size(ShenandoahHeapRegion::max_tlab_size_bytes()));
77-
78-
log_info(gc, init)("Humongous Object Threshold: " SIZE_FORMAT "%s",
79-
byte_size_in_exact_unit(ShenandoahHeapRegion::humongous_threshold_bytes()),
80-
exact_unit_for_byte_size(ShenandoahHeapRegion::humongous_threshold_bytes()));
43+
log_info(gc, init)("Heap Region Count: " SIZE_FORMAT, ShenandoahHeapRegion::region_count());
44+
log_info(gc, init)("Heap Region Size: " PROPERFMT, PROPERFMTARGS(ShenandoahHeapRegion::region_size_bytes()));
45+
log_info(gc, init)("TLAB Size Max: " PROPERFMT, PROPERFMTARGS(ShenandoahHeapRegion::max_tlab_size_bytes()));
46+
log_info(gc, init)("Humongous Object Threshold: " PROPERFMT, PROPERFMTARGS(ShenandoahHeapRegion::humongous_threshold_bytes()));
8147
}
8248

83-
void ShenandoahInitLogger::print() {
84-
ShenandoahInitLogger init_log;
85-
init_log.print_all();
49+
void ShenandoahInitLogger::print_gc_specific() {
50+
GCInitLogger::print_gc_specific();
51+
52+
ShenandoahHeap* heap = ShenandoahHeap::heap();
53+
log_info(gc, init)("Mode: %s", heap->mode()->name());
54+
log_info(gc, init)("Heuristics: %s", heap->heuristics()->name());
8655
}

src/hotspot/share/gc/shenandoah/shenandoahInitLogger.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
class ShenandoahInitLogger : public GCInitLogger {
3131
protected:
32-
virtual void print_heap();
32+
void print_heap() override;
33+
void print_gc_specific() override;
3334

3435
public:
3536
static void print();

0 commit comments

Comments
 (0)