Skip to content

Commit c32b6f7

Browse files
committed
8355638: Allow -Xlog:aot to be used as an alias for -Xlog:cds
1 parent 88e0b00 commit c32b6f7

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

src/hotspot/share/logging/logSelection.cpp

+31-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ bool LogSelection::superset_of(const LogSelection& other) const {
8585
return true;
8686
}
8787

88+
// quick-and-dirty -- to be refactored properly.
89+
int _cds_tag_specified = 0;
90+
8891
static LogSelection parse_internal(char *str, outputStream* errstream) {
8992
// Parse the level, if specified
9093
LogLevelType level = LogLevel::Unspecified;
@@ -166,7 +169,34 @@ static LogSelection parse_internal(char *str, outputStream* errstream) {
166169
}
167170
}
168171

169-
return LogSelection(tags, wildcard, level);
172+
LogSelection ls = LogSelection(tags, wildcard, level);
173+
if (ls.tag_sets_selected() == 0) {
174+
// Make "aot" an alias for "cds. E.g.,
175+
// -Xlog:aot -> -Xlog:cds
176+
// -Xlog:aot+class -> -Xlog:cds+class
177+
if (tags[0] == LogTag::_aot) {
178+
LogTagType aliased_tags[LogTag::MaxTags];
179+
memcpy(aliased_tags, tags, sizeof(tags));
180+
aliased_tags[0] = LogTag::_cds;
181+
LogSelection aliased_ls = LogSelection(aliased_tags, wildcard, level);
182+
if (aliased_ls.tag_sets_selected() > 0) {
183+
return aliased_ls;
184+
}
185+
}
186+
} else {
187+
if (tags[0] == LogTag::_cds) {
188+
// If the user has specified ONLY -Xlog:aot, then all "cds" logs will be printed with an "aot" decoration.
189+
//
190+
// [0.022s][info][aot] full module graph: enabled
191+
// [2.335s][debug][aot,class] klasses[ 1587] = ...
192+
//
193+
// For backwards compatibility (until we convert all "cds" logs to "aot" logs, if
194+
// the user has specifed at least one log of the "cds" type, then we will
195+
// revert to the "cds" decoration.
196+
_cds_tag_specified ++;
197+
}
198+
}
199+
return ls;
170200
}
171201

172202
LogSelection LogSelection::parse(const char* str, outputStream* error_stream) {

src/hotspot/share/logging/logSelectionList.cpp

+22-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
static const char* DefaultExpressionString = "all";
3030

31+
extern int _cds_tag_specified;
32+
3133
bool LogSelectionList::verify_selections(outputStream* out) const {
3234
bool valid = true;
3335

@@ -67,6 +69,8 @@ bool LogSelectionList::parse(const char* str, outputStream* errstream) {
6769
str = DefaultExpressionString;
6870
}
6971
char* copy = os::strdup_check_oom(str, mtLogging);
72+
char* extra_copy = nullptr;
73+
7074
// Split string on commas
7175
for (char *comma_pos = copy, *cur = copy; success; cur = comma_pos + 1) {
7276
if (_nselections == MaxSelections) {
@@ -83,6 +87,16 @@ bool LogSelectionList::parse(const char* str, outputStream* errstream) {
8387
*comma_pos = '\0';
8488
}
8589

90+
if (strncmp(cur, "aot*", 4) == 0 && extra_copy == nullptr) {
91+
size_t len = strlen(cur);
92+
extra_copy = (char*)os::malloc(len+10, mtLogging);
93+
strcpy(extra_copy + 1, cur);
94+
extra_copy[0] = ',';
95+
extra_copy[1] = 'c';
96+
extra_copy[2] = 'd';
97+
extra_copy[3] = 's';
98+
_cds_tag_specified --;
99+
}
86100
LogSelection selection = LogSelection::parse(cur, errstream);
87101
if (selection == LogSelection::Invalid) {
88102
success = false;
@@ -91,7 +105,14 @@ bool LogSelectionList::parse(const char* str, outputStream* errstream) {
91105
_selections[_nselections++] = selection;
92106

93107
if (comma_pos == nullptr) {
94-
break;
108+
if (extra_copy != nullptr) {
109+
os::free(copy);
110+
copy = extra_copy;
111+
comma_pos = copy;
112+
extra_copy = nullptr;
113+
} else {
114+
break;
115+
}
95116
}
96117
}
97118

src/hotspot/share/logging/logTagSet.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,16 @@ void LogTagSet::log(const LogMessageBuffer& msg) {
9393
}
9494
}
9595

96+
extern int _cds_tag_specified;
97+
9698
void LogTagSet::label(outputStream* st, const char* separator) const {
97-
for (size_t i = 0; i < _ntags; i++) {
99+
size_t i = 0;
100+
if (_ntags > 0 && _tag[0] == LogTag::_cds && _cds_tag_specified == 0) {
101+
st->print("%s", "aot");
102+
i++;
103+
}
104+
105+
for (; i < _ntags; i++) {
98106
st->print("%s%s", (i == 0 ? "" : separator), LogTag::name(_tag[i]));
99107
}
100108
}

0 commit comments

Comments
 (0)