Skip to content

Commit

Permalink
8278826: Print error if Shenandoah flags are empty (instead of crashing)
Browse files Browse the repository at this point in the history
Backport-of: 247ea71d24a251d29d9a5179e5b773df850e7261
  • Loading branch information
shipilev committed Nov 21, 2022
1 parent 112ea1d commit 3f79952
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
25 changes: 12 additions & 13 deletions src/hotspot/share/gc/shenandoah/mode/shenandoahIUMode.cpp
Expand Up @@ -65,19 +65,18 @@ void ShenandoahIUMode::initialize_flags() const {
}

ShenandoahHeuristics* ShenandoahIUMode::initialize_heuristics() const {
if (ShenandoahGCHeuristics != NULL) {
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();
} else {
vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option");
}
if (ShenandoahGCHeuristics == NULL) {
vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option (null)");
}
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;
}
Expand Up @@ -28,6 +28,7 @@
#include "logging/log.hpp"
#include "logging/logTag.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/java.hpp"

void ShenandoahPassiveMode::initialize_flags() const {
// Do not allow concurrent cycles.
Expand Down Expand Up @@ -55,9 +56,8 @@ void ShenandoahPassiveMode::initialize_flags() const {
// No barriers are required to run.
}
ShenandoahHeuristics* ShenandoahPassiveMode::initialize_heuristics() const {
if (ShenandoahGCHeuristics != NULL) {
return new ShenandoahPassiveHeuristics();
if (ShenandoahGCHeuristics == NULL) {
vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option (null)");
}
ShouldNotReachHere();
return NULL;
return new ShenandoahPassiveHeuristics();
}
25 changes: 12 additions & 13 deletions src/hotspot/share/gc/shenandoah/mode/shenandoahSATBMode.cpp
Expand Up @@ -53,19 +53,18 @@ void ShenandoahSATBMode::initialize_flags() const {
}

ShenandoahHeuristics* ShenandoahSATBMode::initialize_heuristics() const {
if (ShenandoahGCHeuristics != NULL) {
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();
} else {
vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option");
}
if (ShenandoahGCHeuristics == NULL) {
vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option (null)");
}
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;
}
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Expand Up @@ -416,7 +416,7 @@ void ShenandoahHeap::initialize_mode() {
vm_exit_during_initialization("Unknown -XX:ShenandoahGCMode option");
}
} else {
ShouldNotReachHere();
vm_exit_during_initialization("Unknown -XX:ShenandoahGCMode option (null)");
}
_gc_mode->initialize_flags();
if (_gc_mode->is_diagnostic() && !UnlockDiagnosticVMOptions) {
Expand Down

1 comment on commit 3f79952

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.