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
|
#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;
|
GCArguments* GCConfig::_arguments = NULL;
|
||||||
bool GCConfig::_gc_selected_ergonomically = false;
|
bool GCConfig::_gc_selected_ergonomically = false;
|
||||||
|
|
||||||
@ -83,8 +86,8 @@ void GCConfig::select_gc_ergonomically() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GCConfig::is_no_gc_selected() {
|
bool GCConfig::is_no_gc_selected() {
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
FOR_EACH_SUPPORTED_GC(gc) {
|
||||||
if (SupportedGCs[i]._flag) {
|
if (gc->_flag) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,11 +98,11 @@ bool GCConfig::is_no_gc_selected() {
|
|||||||
bool GCConfig::is_exactly_one_gc_selected() {
|
bool GCConfig::is_exactly_one_gc_selected() {
|
||||||
CollectedHeap::Name selected = CollectedHeap::None;
|
CollectedHeap::Name selected = CollectedHeap::None;
|
||||||
|
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
FOR_EACH_SUPPORTED_GC(gc) {
|
||||||
if (SupportedGCs[i]._flag) {
|
if (gc->_flag) {
|
||||||
if (SupportedGCs[i]._name == selected || selected == CollectedHeap::None) {
|
if (gc->_name == selected || selected == CollectedHeap::None) {
|
||||||
// Selected
|
// Selected
|
||||||
selected = SupportedGCs[i]._name;
|
selected = gc->_name;
|
||||||
} else {
|
} else {
|
||||||
// More than one selected
|
// More than one selected
|
||||||
return false;
|
return false;
|
||||||
@ -127,9 +130,9 @@ GCArguments* GCConfig::select_gc() {
|
|||||||
|
|
||||||
if (is_exactly_one_gc_selected()) {
|
if (is_exactly_one_gc_selected()) {
|
||||||
// Exacly one GC selected
|
// Exacly one GC selected
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
FOR_EACH_SUPPORTED_GC(gc) {
|
||||||
if (SupportedGCs[i]._flag) {
|
if (gc->_flag) {
|
||||||
return &SupportedGCs[i]._arguments;
|
return &gc->_arguments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,8 +149,8 @@ void GCConfig::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GCConfig::is_gc_supported(CollectedHeap::Name name) {
|
bool GCConfig::is_gc_supported(CollectedHeap::Name name) {
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
FOR_EACH_SUPPORTED_GC(gc) {
|
||||||
if (SupportedGCs[i]._name == name) {
|
if (gc->_name == name) {
|
||||||
// Supported
|
// Supported
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -158,8 +161,8 @@ bool GCConfig::is_gc_supported(CollectedHeap::Name name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GCConfig::is_gc_selected(CollectedHeap::Name name) {
|
bool GCConfig::is_gc_selected(CollectedHeap::Name name) {
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
FOR_EACH_SUPPORTED_GC(gc) {
|
||||||
if (SupportedGCs[i]._name == name && SupportedGCs[i]._flag) {
|
if (gc->_name == name && gc->_flag) {
|
||||||
// Selected
|
// Selected
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -176,9 +179,9 @@ bool GCConfig::is_gc_selected_ergonomically() {
|
|||||||
const char* GCConfig::hs_err_name() {
|
const char* GCConfig::hs_err_name() {
|
||||||
if (is_exactly_one_gc_selected()) {
|
if (is_exactly_one_gc_selected()) {
|
||||||
// Exacly one GC selected
|
// Exacly one GC selected
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(SupportedGCs); i++) {
|
FOR_EACH_SUPPORTED_GC(gc) {
|
||||||
if (SupportedGCs[i]._flag) {
|
if (gc->_flag) {
|
||||||
return SupportedGCs[i]._hs_err_name;
|
return gc->_hs_err_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user