8278826: Print error if Shenandoah flags are empty (instead of crashing)

Reviewed-by: rkennke, mli
This commit is contained in:
Dmitry Chuyko 2021-12-17 09:19:00 +00:00
parent 8c73ec155d
commit 247ea71d24
4 changed files with 29 additions and 31 deletions

View File

@ -65,19 +65,18 @@ void ShenandoahIUMode::initialize_flags() const {
} }
ShenandoahHeuristics* ShenandoahIUMode::initialize_heuristics() const { ShenandoahHeuristics* ShenandoahIUMode::initialize_heuristics() const {
if (ShenandoahGCHeuristics != NULL) { if (ShenandoahGCHeuristics == NULL) {
if (strcmp(ShenandoahGCHeuristics, "aggressive") == 0) { vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option (null)");
return new ShenandoahAggressiveHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "static") == 0) {
return new ShenandoahStaticHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "adaptive") == 0) {
return new ShenandoahAdaptiveHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "compact") == 0) {
return new ShenandoahCompactHeuristics();
} else {
vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option");
}
} }
ShouldNotReachHere(); if (strcmp(ShenandoahGCHeuristics, "aggressive") == 0) {
return new ShenandoahAggressiveHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "static") == 0) {
return new ShenandoahStaticHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "adaptive") == 0) {
return new ShenandoahAdaptiveHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "compact") == 0) {
return new ShenandoahCompactHeuristics();
}
vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option");
return NULL; return NULL;
} }

View File

@ -28,6 +28,7 @@
#include "logging/log.hpp" #include "logging/log.hpp"
#include "logging/logTag.hpp" #include "logging/logTag.hpp"
#include "runtime/globals_extension.hpp" #include "runtime/globals_extension.hpp"
#include "runtime/java.hpp"
void ShenandoahPassiveMode::initialize_flags() const { void ShenandoahPassiveMode::initialize_flags() const {
// Do not allow concurrent cycles. // Do not allow concurrent cycles.
@ -55,9 +56,8 @@ void ShenandoahPassiveMode::initialize_flags() const {
// No barriers are required to run. // No barriers are required to run.
} }
ShenandoahHeuristics* ShenandoahPassiveMode::initialize_heuristics() const { ShenandoahHeuristics* ShenandoahPassiveMode::initialize_heuristics() const {
if (ShenandoahGCHeuristics != NULL) { if (ShenandoahGCHeuristics == NULL) {
return new ShenandoahPassiveHeuristics(); vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option (null)");
} }
ShouldNotReachHere(); return new ShenandoahPassiveHeuristics();
return NULL;
} }

View File

@ -53,19 +53,18 @@ void ShenandoahSATBMode::initialize_flags() const {
} }
ShenandoahHeuristics* ShenandoahSATBMode::initialize_heuristics() const { ShenandoahHeuristics* ShenandoahSATBMode::initialize_heuristics() const {
if (ShenandoahGCHeuristics != NULL) { if (ShenandoahGCHeuristics == NULL) {
if (strcmp(ShenandoahGCHeuristics, "aggressive") == 0) { vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option (null)");
return new ShenandoahAggressiveHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "static") == 0) {
return new ShenandoahStaticHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "adaptive") == 0) {
return new ShenandoahAdaptiveHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "compact") == 0) {
return new ShenandoahCompactHeuristics();
} else {
vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option");
}
} }
ShouldNotReachHere(); if (strcmp(ShenandoahGCHeuristics, "aggressive") == 0) {
return new ShenandoahAggressiveHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "static") == 0) {
return new ShenandoahStaticHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "adaptive") == 0) {
return new ShenandoahAdaptiveHeuristics();
} else if (strcmp(ShenandoahGCHeuristics, "compact") == 0) {
return new ShenandoahCompactHeuristics();
}
vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option");
return NULL; return NULL;
} }

View File

@ -416,7 +416,7 @@ void ShenandoahHeap::initialize_mode() {
vm_exit_during_initialization("Unknown -XX:ShenandoahGCMode option"); vm_exit_during_initialization("Unknown -XX:ShenandoahGCMode option");
} }
} else { } else {
ShouldNotReachHere(); vm_exit_during_initialization("Unknown -XX:ShenandoahGCMode option (null)");
} }
_gc_mode->initialize_flags(); _gc_mode->initialize_flags();
if (_gc_mode->is_diagnostic() && !UnlockDiagnosticVMOptions) { if (_gc_mode->is_diagnostic() && !UnlockDiagnosticVMOptions) {