8202366: Add macro for common loop in GCConfig
Reviewed-by: eosterlund, shade
This commit is contained in:
parent
8c235a30e7
commit
b9490e5760
@ -63,6 +63,9 @@ static const SupportedGC SupportedGCs[] = {
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
};
|
||||
|
||||
#define FOR_EACH_SUPPORTED_GC(var) \
|
||||
for (const SupportedGC* var = &SupportedGCs[0]; var < &SupportedGCs[ARRAY_SIZE(SupportedGCs)]; var++)
|
||||
|
||||
GCArguments* GCConfig::_arguments = NULL;
|
||||
bool GCConfig::_gc_selected_ergonomically = false;
|
||||
|
||||
@ -83,8 +86,8 @@ void GCConfig::select_gc_ergonomically() {
|
||||
}
|
||||
|
||||
bool GCConfig::is_no_gc_selected() {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
||||
if (SupportedGCs[i]._flag) {
|
||||
FOR_EACH_SUPPORTED_GC(gc) {
|
||||
if (gc->_flag) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -95,11 +98,11 @@ bool GCConfig::is_no_gc_selected() {
|
||||
bool GCConfig::is_exactly_one_gc_selected() {
|
||||
CollectedHeap::Name selected = CollectedHeap::None;
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
||||
if (SupportedGCs[i]._flag) {
|
||||
if (SupportedGCs[i]._name == selected || selected == CollectedHeap::None) {
|
||||
FOR_EACH_SUPPORTED_GC(gc) {
|
||||
if (gc->_flag) {
|
||||
if (gc->_name == selected || selected == CollectedHeap::None) {
|
||||
// Selected
|
||||
selected = SupportedGCs[i]._name;
|
||||
selected = gc->_name;
|
||||
} else {
|
||||
// More than one selected
|
||||
return false;
|
||||
@ -127,9 +130,9 @@ GCArguments* GCConfig::select_gc() {
|
||||
|
||||
if (is_exactly_one_gc_selected()) {
|
||||
// Exacly one GC selected
|
||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
||||
if (SupportedGCs[i]._flag) {
|
||||
return &SupportedGCs[i]._arguments;
|
||||
FOR_EACH_SUPPORTED_GC(gc) {
|
||||
if (gc->_flag) {
|
||||
return &gc->_arguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,8 +149,8 @@ void GCConfig::initialize() {
|
||||
}
|
||||
|
||||
bool GCConfig::is_gc_supported(CollectedHeap::Name name) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
||||
if (SupportedGCs[i]._name == name) {
|
||||
FOR_EACH_SUPPORTED_GC(gc) {
|
||||
if (gc->_name == name) {
|
||||
// Supported
|
||||
return true;
|
||||
}
|
||||
@ -158,8 +161,8 @@ bool GCConfig::is_gc_supported(CollectedHeap::Name name) {
|
||||
}
|
||||
|
||||
bool GCConfig::is_gc_selected(CollectedHeap::Name name) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
||||
if (SupportedGCs[i]._name == name && SupportedGCs[i]._flag) {
|
||||
FOR_EACH_SUPPORTED_GC(gc) {
|
||||
if (gc->_name == name && gc->_flag) {
|
||||
// Selected
|
||||
return true;
|
||||
}
|
||||
@ -176,9 +179,9 @@ bool GCConfig::is_gc_selected_ergonomically() {
|
||||
const char* GCConfig::hs_err_name() {
|
||||
if (is_exactly_one_gc_selected()) {
|
||||
// Exacly one GC selected
|
||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
||||
if (SupportedGCs[i]._flag) {
|
||||
return SupportedGCs[i]._hs_err_name;
|
||||
FOR_EACH_SUPPORTED_GC(gc) {
|
||||
if (gc->_flag) {
|
||||
return gc->_hs_err_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user