Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "gc/shared/workerPolicy.hpp"
#include "gc/shenandoah/shenandoahArguments.hpp"
#include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
#include "gc/shenandoah/shenandoahGenerationalHeap.hpp"
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
#include "gc/shenandoah/shenandoahHeapRegion.hpp"
#include "runtime/globals_extension.hpp"
Expand Down Expand Up @@ -206,5 +207,8 @@ void ShenandoahArguments::initialize_alignments() {
}

CollectedHeap* ShenandoahArguments::create_heap() {
if (strcmp(ShenandoahGCMode, "generational") == 0) {
return new ShenandoahGenerationalHeap(new ShenandoahCollectorPolicy());
}
return new ShenandoahHeap(new ShenandoahCollectorPolicy());
}
74 changes: 74 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright Amazon.com Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

#include "precompiled.hpp"

#include "gc/shenandoah/shenandoahGenerationalHeap.hpp"
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
#include "gc/shenandoah/shenandoahInitLogger.hpp"
#include "gc/shenandoah/shenandoahOldGeneration.hpp"
#include "gc/shenandoah/shenandoahYoungGeneration.hpp"

#include "logging/log.hpp"

class ShenandoahGenerationalInitLogger : public ShenandoahInitLogger {
public:
static void print() {
ShenandoahGenerationalInitLogger logger;
logger.print_all();
}

void print_heap() override {
ShenandoahInitLogger::print_heap();

ShenandoahGenerationalHeap* heap = ShenandoahGenerationalHeap::heap();

ShenandoahYoungGeneration* young = heap->young_generation();
log_info(gc, init)("Young Generation Soft Size: " PROPERFMT, PROPERFMTARGS(young->soft_max_capacity()));
log_info(gc, init)("Young Generation Max: " PROPERFMT, PROPERFMTARGS(young->max_capacity()));

ShenandoahOldGeneration* old = heap->old_generation();
log_info(gc, init)("Old Generation Soft Size: " PROPERFMT, PROPERFMTARGS(old->soft_max_capacity()));
log_info(gc, init)("Old Generation Max: " PROPERFMT, PROPERFMTARGS(old->max_capacity()));
}

protected:
void print_gc_specific() override {
ShenandoahInitLogger::print_gc_specific();

ShenandoahGenerationalHeap* heap = ShenandoahGenerationalHeap::heap();
log_info(gc, init)("Young Heuristics: %s", heap->young_generation()->heuristics()->name());
log_info(gc, init)("Old Heuristics: %s", heap->old_generation()->heuristics()->name());
}
};

ShenandoahGenerationalHeap* ShenandoahGenerationalHeap::heap() {
CollectedHeap* heap = Universe::heap();
return checked_cast<ShenandoahGenerationalHeap*>(heap);
}

void ShenandoahGenerationalHeap::print_init_logger() const {
ShenandoahGenerationalInitLogger logger;
logger.print_all();
}
39 changes: 39 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright Amazon.com Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHGENERATIONALHEAP
#define SHARE_GC_SHENANDOAH_SHENANDOAHGENERATIONALHEAP

#include "gc/shenandoah/shenandoahHeap.hpp"

class ShenandoahGenerationalHeap : public ShenandoahHeap {
public:
explicit ShenandoahGenerationalHeap(ShenandoahCollectorPolicy* policy) : ShenandoahHeap(policy) {}

static ShenandoahGenerationalHeap* heap();

void print_init_logger() const override;
};

#endif //SHARE_GC_SHENANDOAH_SHENANDOAHGENERATIONALHEAP
9 changes: 8 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,15 @@ jint ShenandoahHeap::initialize() {
_control_thread = new ShenandoahControlThread();
_regulator_thread = new ShenandoahRegulatorThread(_control_thread);

ShenandoahInitLogger::print();
print_init_logger();

return JNI_OK;
}

void ShenandoahHeap::print_init_logger() const {
ShenandoahInitLogger::print();
}

size_t ShenandoahHeap::max_size_for(ShenandoahGeneration* generation) const {
switch (generation->type()) {
case YOUNG:
Expand Down Expand Up @@ -726,6 +730,9 @@ void ShenandoahHeap::post_initialize() {
JFR_ONLY(ShenandoahJFRSupport::register_jfr_type_serializers());
}

ShenandoahHeuristics* ShenandoahHeap::heuristics() {
return _global_generation->heuristics();
}

ShenandoahOldHeuristics* ShenandoahHeap::old_heuristics() {
return (ShenandoahOldHeuristics*) _old_generation->heuristics();
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class ShenandoahHeap : public CollectedHeap {
_gc_generation = generation;
}

ShenandoahHeuristics* heuristics();
ShenandoahOldHeuristics* old_heuristics();
ShenandoahYoungHeuristics* young_heuristics();

Expand All @@ -198,7 +199,7 @@ class ShenandoahHeap : public CollectedHeap {
jint initialize() override;
void post_initialize() override;
void initialize_heuristics_generations();

virtual void print_init_logger() const;
void initialize_serviceability() override;

void print_on(outputStream* st) const override;
Expand Down
61 changes: 15 additions & 46 deletions src/hotspot/share/gc/shenandoah/shenandoahInitLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,60 +27,29 @@
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
#include "gc/shenandoah/shenandoahHeapRegion.hpp"
#include "gc/shenandoah/shenandoahInitLogger.hpp"
#include "gc/shenandoah/shenandoahOldGeneration.hpp"
#include "gc/shenandoah/shenandoahYoungGeneration.hpp"
#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp"
#include "gc/shenandoah/mode/shenandoahMode.hpp"
#include "logging/log.hpp"
#include "runtime/globals.hpp"
#include "utilities/globalDefinitions.hpp"

void ShenandoahInitLogger::print() {
ShenandoahInitLogger init_log;
init_log.print_all();
}

void ShenandoahInitLogger::print_heap() {
GCInitLogger::print_heap();

ShenandoahHeap* heap = ShenandoahHeap::heap();

log_info(gc, init)("Mode: %s",
heap->mode()->name());

if (!heap->mode()->is_generational()) {
log_info(gc, init)("Heuristics: %s", heap->global_generation()->heuristics()->name());
} else {
log_info(gc, init)("Young Heuristics: %s", heap->young_generation()->heuristics()->name());
log_info(gc, init)("Young Generation Soft Size: " SIZE_FORMAT "%s",
byte_size_in_proper_unit(heap->young_generation()->soft_max_capacity()),
proper_unit_for_byte_size(heap->young_generation()->soft_max_capacity()));
log_info(gc, init)("Young Generation Max: " SIZE_FORMAT "%s",
byte_size_in_proper_unit(heap->young_generation()->max_capacity()),
proper_unit_for_byte_size(heap->young_generation()->max_capacity()));
log_info(gc, init)("Old Heuristics: %s", heap->old_generation()->heuristics()->name());
log_info(gc, init)("Old Generation Soft Size: " SIZE_FORMAT "%s",
byte_size_in_proper_unit(heap->old_generation()->soft_max_capacity()),
proper_unit_for_byte_size(heap->old_generation()->soft_max_capacity()));
log_info(gc, init)("Old Generation Max: " SIZE_FORMAT "%s",
byte_size_in_proper_unit(heap->old_generation()->max_capacity()),
proper_unit_for_byte_size(heap->old_generation()->max_capacity()));
}



log_info(gc, init)("Heap Region Count: " SIZE_FORMAT,
ShenandoahHeapRegion::region_count());

log_info(gc, init)("Heap Region Size: " SIZE_FORMAT "%s",
byte_size_in_exact_unit(ShenandoahHeapRegion::region_size_bytes()),
exact_unit_for_byte_size(ShenandoahHeapRegion::region_size_bytes()));

log_info(gc, init)("TLAB Size Max: " SIZE_FORMAT "%s",
byte_size_in_exact_unit(ShenandoahHeapRegion::max_tlab_size_bytes()),
exact_unit_for_byte_size(ShenandoahHeapRegion::max_tlab_size_bytes()));

log_info(gc, init)("Humongous Object Threshold: " SIZE_FORMAT "%s",
byte_size_in_exact_unit(ShenandoahHeapRegion::humongous_threshold_bytes()),
exact_unit_for_byte_size(ShenandoahHeapRegion::humongous_threshold_bytes()));
log_info(gc, init)("Heap Region Count: " SIZE_FORMAT, ShenandoahHeapRegion::region_count());
log_info(gc, init)("Heap Region Size: " PROPERFMT, PROPERFMTARGS(ShenandoahHeapRegion::region_size_bytes()));
log_info(gc, init)("TLAB Size Max: " PROPERFMT, PROPERFMTARGS(ShenandoahHeapRegion::max_tlab_size_bytes()));
log_info(gc, init)("Humongous Object Threshold: " PROPERFMT, PROPERFMTARGS(ShenandoahHeapRegion::humongous_threshold_bytes()));
}

void ShenandoahInitLogger::print() {
ShenandoahInitLogger init_log;
init_log.print_all();
void ShenandoahInitLogger::print_gc_specific() {
GCInitLogger::print_gc_specific();

ShenandoahHeap* heap = ShenandoahHeap::heap();
log_info(gc, init)("Mode: %s", heap->mode()->name());
log_info(gc, init)("Heuristics: %s", heap->heuristics()->name());
}
3 changes: 2 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahInitLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

class ShenandoahInitLogger : public GCInitLogger {
protected:
virtual void print_heap();
void print_heap() override;
void print_gc_specific() override;

public:
static void print();
Expand Down