--- old/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp 2019-12-16 22:38:16.567520700 +0900 +++ new/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp 2019-12-16 22:38:16.301083200 +0900 @@ -37,7 +37,11 @@ #include "runtime/os.hpp" #include "utilities/macros.hpp" -static const char* Indents[5] = {"", " ", " ", " ", " "}; +static const char* indent(uint level) { + static const char* Indents[] = {"", " ", " ", " ", " ", " "}; + assert(level < ARRAY_SIZE(Indents), "Too high indent level %u", level); + return Indents[level]; +} G1GCPhaseTimes::G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads) : _max_gc_threads(max_gc_threads), @@ -299,26 +303,26 @@ } template -void G1GCPhaseTimes::details(T* phase, const char* indent) const { +void G1GCPhaseTimes::details(T* phase, const char* indent_str) const { LogTarget(Trace, gc, phases, task) lt; if (lt.is_enabled()) { LogStream ls(lt); - ls.print("%s", indent); + ls.print("%s", indent_str); phase->print_details_on(&ls); } } -void G1GCPhaseTimes::log_phase(WorkerDataArray* phase, uint indent, outputStream* out, bool print_sum) const { - out->print("%s", Indents[indent]); +void G1GCPhaseTimes::log_phase(WorkerDataArray* phase, uint indent_level, outputStream* out, bool print_sum) const { + out->print("%s", indent(indent_level)); phase->print_summary_on(out, print_sum); - details(phase, Indents[indent]); + details(phase, indent(indent_level)); for (uint i = 0; i < phase->MaxThreadWorkItems; i++) { WorkerDataArray* work_items = phase->thread_work_items(i); if (work_items != NULL) { - out->print("%s", Indents[indent + 1]); + out->print("%s", indent(indent_level + 1)); work_items->print_summary_on(out, true); - details(work_items, Indents[indent + 1]); + details(work_items, indent(indent_level + 1)); } } } @@ -343,11 +347,11 @@ #define TIME_FORMAT "%.1lfms" void G1GCPhaseTimes::info_time(const char* name, double value) const { - log_info(gc, phases)("%s%s: " TIME_FORMAT, Indents[1], name, value); + log_info(gc, phases)("%s%s: " TIME_FORMAT, indent(1), name, value); } void G1GCPhaseTimes::debug_time(const char* name, double value) const { - log_debug(gc, phases)("%s%s: " TIME_FORMAT, Indents[2], name, value); + log_debug(gc, phases)("%s%s: " TIME_FORMAT, indent(2), name, value); } void G1GCPhaseTimes::debug_time_for_reference(const char* name, double value) const { @@ -356,19 +360,19 @@ if (lt.is_enabled()) { LogStream ls(lt); - ls.print_cr("%s%s: " TIME_FORMAT, Indents[2], name, value); + ls.print_cr("%s%s: " TIME_FORMAT, indent(2), name, value); } else if (lt2.is_enabled()) { LogStream ls(lt2); - ls.print_cr("%s%s: " TIME_FORMAT, Indents[2], name, value); + ls.print_cr("%s%s: " TIME_FORMAT, indent(2), name, value); } } void G1GCPhaseTimes::trace_time(const char* name, double value) const { - log_trace(gc, phases)("%s%s: " TIME_FORMAT, Indents[3], name, value); + log_trace(gc, phases)("%s%s: " TIME_FORMAT, indent(3), name, value); } void G1GCPhaseTimes::trace_count(const char* name, size_t value) const { - log_trace(gc, phases)("%s%s: " SIZE_FORMAT, Indents[3], name, value); + log_trace(gc, phases)("%s%s: " SIZE_FORMAT, indent(3), name, value); } double G1GCPhaseTimes::print_pre_evacuate_collection_set() const {