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
Reviewed-by: rkennke, mli
  • Loading branch information
Dmitry Chuyko committed Dec 17, 2021
1 parent 8c73ec1 commit 247ea71
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
Original file line number Diff line number Diff line change
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;
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 247ea71

@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.