104 ErgoHeuristic n = extract_heuristic(tag); 105 return level <= _level && _enabled[n]; 106 } 107 108 // Extract the heuristic id from the tag and return a string with 109 // its name. 110 static const char* to_string(int tag); 111 }; 112 113 // The macros below generate the format string for values of different 114 // types and/or metrics. 115 116 // The reason for the action is optional and is handled specially: the 117 // reason string is concatenated here so it's not necessary to pass it 118 // as a parameter. 119 #define ergo_format_reason(_reason_) ", reason: " _reason_ 120 121 // Single parameter format strings 122 #define ergo_format_str(_name_) ", " _name_ ": %s" 123 #define ergo_format_region(_name_) ", " _name_ ": %u regions" 124 #define ergo_format_byte(_name_) ", " _name_ ": "SIZE_FORMAT" bytes" 125 #define ergo_format_double(_name_) ", " _name_ ": %1.2f" 126 #define ergo_format_perc(_name_) ", " _name_ ": %1.2f %%" 127 #define ergo_format_ms(_name_) ", " _name_ ": %1.2f ms" 128 #define ergo_format_size(_name_) ", " _name_ ": "SIZE_FORMAT 129 130 // Double parameter format strings 131 #define ergo_format_byte_perc(_name_) \ 132 ", " _name_ ": "SIZE_FORMAT" bytes (%1.2f %%)" 133 134 // Generates the format string 135 #define ergo_format(_extra_format_) \ 136 " %1.3f: [G1Ergonomics (%s) %s" _extra_format_ "]" 137 138 // Conditionally, prints an ergonomic decision record. _extra_format_ 139 // is the format string for the optional items we'd like to print 140 // (i.e., the decision's reason and any associated values). This 141 // string should be built up using the ergo_*_format macros (see 142 // above) to ensure consistency. 143 // 144 // Since we cannot rely on the compiler supporting variable argument 145 // macros, this macro accepts a fixed number of arguments and passes 146 // them to the print method. For convenience, we have wrapper macros 147 // below which take a specific number of arguments and set the rest to 148 // a default value. 149 #define ergo_verbose_common(_tag_, _action_, _extra_format_, \ 150 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_) \ 151 do { \ 152 if (G1ErgoVerbose::enabled((_tag_))) { \ | 104 ErgoHeuristic n = extract_heuristic(tag); 105 return level <= _level && _enabled[n]; 106 } 107 108 // Extract the heuristic id from the tag and return a string with 109 // its name. 110 static const char* to_string(int tag); 111 }; 112 113 // The macros below generate the format string for values of different 114 // types and/or metrics. 115 116 // The reason for the action is optional and is handled specially: the 117 // reason string is concatenated here so it's not necessary to pass it 118 // as a parameter. 119 #define ergo_format_reason(_reason_) ", reason: " _reason_ 120 121 // Single parameter format strings 122 #define ergo_format_str(_name_) ", " _name_ ": %s" 123 #define ergo_format_region(_name_) ", " _name_ ": %u regions" 124 #define ergo_format_byte(_name_) ", " _name_ ": " SIZE_FORMAT " bytes" 125 #define ergo_format_double(_name_) ", " _name_ ": %1.2f" 126 #define ergo_format_perc(_name_) ", " _name_ ": %1.2f %%" 127 #define ergo_format_ms(_name_) ", " _name_ ": %1.2f ms" 128 #define ergo_format_size(_name_) ", " _name_ ": " SIZE_FORMAT 129 130 // Double parameter format strings 131 #define ergo_format_byte_perc(_name_) \ 132 ", " _name_ ": " SIZE_FORMAT " bytes (%1.2f %%)" 133 134 // Generates the format string 135 #define ergo_format(_extra_format_) \ 136 " %1.3f: [G1Ergonomics (%s) %s" _extra_format_ "]" 137 138 // Conditionally, prints an ergonomic decision record. _extra_format_ 139 // is the format string for the optional items we'd like to print 140 // (i.e., the decision's reason and any associated values). This 141 // string should be built up using the ergo_*_format macros (see 142 // above) to ensure consistency. 143 // 144 // Since we cannot rely on the compiler supporting variable argument 145 // macros, this macro accepts a fixed number of arguments and passes 146 // them to the print method. For convenience, we have wrapper macros 147 // below which take a specific number of arguments and set the rest to 148 // a default value. 149 #define ergo_verbose_common(_tag_, _action_, _extra_format_, \ 150 _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_) \ 151 do { \ 152 if (G1ErgoVerbose::enabled((_tag_))) { \ |