-
Notifications
You must be signed in to change notification settings - Fork 6.4k
8356595: Convert -Xlog:cds to -Xlog:aot (step1) #25136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 23 commits
8ed2bf5
cedc5db
30f2ce6
267fdc8
ad6abfc
4a520a5
ac109c3
c00b2f6
88b7ea0
43bdeac
15a87ce
2c869dc
6adfa95
b772b3d
8b25821
38dbe7e
031cbef
82e5518
ad0c4aa
b7670bf
dbab9a7
e2156fb
dddf591
37d334a
8205506
2abc23b
278ab15
2a4355f
78a79ac
8ce133d
4a2aa74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| /* | ||
| * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| * or visit www.oracle.com if you need additional information or have any | ||
| * questions. | ||
| * | ||
| */ | ||
|
|
||
| #ifndef SHARE_CDS_AOTLOGGING_HPP | ||
| #define SHARE_CDS_AOTLOGGING_HPP | ||
|
|
||
| #include "cds/cds_globals.hpp" | ||
| #include "cds/cdsConfig.hpp" | ||
| #include "logging/log.hpp" | ||
|
|
||
| // UL Logging for AOT | ||
| // ================== | ||
| // | ||
| // The old "CDS" feature is rebranded as "AOT" in JEP 483. Therefore, UL logging | ||
| // related to the AOT features should be using the [aot] tag. | ||
| // | ||
| // However, some old scripts may be using -Xlog:cds for diagnostic purposes. To | ||
| // provide a fair amount of backwards compatibility for such scripts, some AOT | ||
| // logs that are likely to be used by such scripts are printed using the macros | ||
| // in this header file. | ||
| // | ||
| // NOTE: MOST of the AOT logs will be using the usual macros such as log_info(aot)(...). | ||
| // The information below does NOT apply to such logs. | ||
| // | ||
| // CDS Compatibility Logs & Compatibility Macros | ||
| // ============================================= | ||
| // | ||
| // A subset of the original CDS logs (the "CDS Compatibility Logs") have been | ||
| // selected in JDK 25. These logs are guarded using the aot_log_xxx compatibility | ||
| // macros. Before JDK 25, such code looked like this: | ||
| // | ||
| // log_info(cds)("trying to map %s%s", info, _full_path); | ||
| // log_warning(cds)("Unable to read the file header."); | ||
| // | ||
| // New code since JDK 25: | ||
| // | ||
| // aot_log_info(aot)("trying to map %s%s", info, _full_path); | ||
| // aot_log_warning(aot)("Unable to read the file header."); | ||
| // | ||
| // The messages printed with the log_aot_xxx() macros work as if they are | ||
| // using the [cds] tag when running with the "classic" CDS flags such as | ||
| // -XX:SharedArchiveFile: | ||
| // | ||
| // $ java -Xlog:cds -XX:SharedArchiveFile=bad.jsa ... | ||
| // [0.020s][info][cds] trying to map bad.jsa | ||
| // [0.020s][warning][cds] Unable to read the file header | ||
| // | ||
| // However, when running new AOT flags such as-XX:AOTCache, these messages are | ||
| // under the [aot] tag: | ||
| // | ||
| // $ java -Xlog:aot -XX:AOTCache=bad.aot ... | ||
| // [0.020s][info][aot] trying to map bad.aot | ||
| // [0.020s][warning][aot] Unable to read the file header | ||
| // | ||
| // Rules on selection and printing | ||
| // | ||
| // [1] When using AOT cache | ||
| // - These logs can be selected ONLY with -Xlog:aot. They are always printed with [aot] decoration | ||
| // | ||
| // [2] When using CDS archives | ||
| // - These logs can be selected ONLY with -Xlog:cds. They are always printed with [cds] decoration | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, so if I use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, I think we should simplify the comments a bit then. Just 'when using AOT cache, these logs are selected via the aot tag, and not the cds tag. When using CDS, these logs are selected via the cds tag, and not the aot tag.' but with the structure you had. The "ONLY with -Xlog:aot" makes it sound like |
||
| // | ||
| // Deprecation Process | ||
| // =================== | ||
| // | ||
| // This is model after the deprecate/obsolete/removal process of VM options in arguments.cpp | ||
|
iklam marked this conversation as resolved.
Outdated
|
||
| // | ||
| // JDK 25 - When using OLD CDS flags (see the list of flags in CDSConfig::check_new_flag()), the | ||
| // the CDS Compatibility Logs must be selected with -Xlog:cds | ||
| // | ||
| // JDK 26 - Same as above, except that when -Xlog:cds is specified in the command-line, an warning | ||
|
iklam marked this conversation as resolved.
Outdated
|
||
| // message is printed to indicate that -Xlog:cds is deprecated. | ||
| // | ||
| // JDK 27 - When using OLD CDS flags (see the list of flags in CDSConfig::check_new_flag()), the | ||
| // the CDS Compatibility Logs must be selected with -Xlog:aot. | ||
| // | ||
| // When -Xlog:cds is specified in the command-line, an warning message is printed to | ||
|
iklam marked this conversation as resolved.
Outdated
|
||
| // indicate that -Xlog:cds is obsolete. | ||
| // | ||
| // JDK 28 - When -Xlog:cds is specified in the command-line, the VM will exit with an error message: | ||
| // | ||
| // [0.002s][error][logging] Invalid tag 'cds' in log selection. | ||
| // Invalid -Xlog option '-Xlog:cds', see error log for details. | ||
| // | ||
|
|
||
| // The following macros are inspired by the same macros (without the aot_ prefix) in logging/log.hpp | ||
|
|
||
| #define aot_log_is_enabled(level, ...) (AOTLogImpl<LOG_TAGS(__VA_ARGS__)>::is_level(LogLevel::level)) | ||
|
|
||
| #define aot_log_error(...) (!aot_log_is_enabled(Error, __VA_ARGS__)) ? (void)0 : AOTLogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Error> | ||
| #define aot_log_warning(...) (!aot_log_is_enabled(Warning, __VA_ARGS__)) ? (void)0 : AOTLogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Warning> | ||
| #define aot_log_info(...) (!aot_log_is_enabled(Info, __VA_ARGS__)) ? (void)0 : AOTLogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Info> | ||
| #define aot_log_debug(...) (!aot_log_is_enabled(Debug, __VA_ARGS__)) ? (void)0 : AOTLogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Debug> | ||
| #define aot_log_trace(...) (!aot_log_is_enabled(Trace, __VA_ARGS__)) ? (void)0 : AOTLogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Trace> | ||
|
|
||
| template <LogTagType IGNORED, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG, LogTagType T3 = LogTag::__NO_TAG, | ||
| LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG> | ||
| class AOTLogImpl { | ||
| public: | ||
| // Make sure no more than the maximum number of tags have been given. | ||
| // The GuardTag allows this to be detected if/when it happens. If the GuardTag | ||
| // is not __NO_TAG, the number of tags given exceeds the maximum allowed. | ||
| STATIC_ASSERT(GuardTag == LogTag::__NO_TAG); // Number of logging tags exceeds maximum supported! | ||
|
|
||
| // Empty constructor to avoid warnings on MSVC about unused variables | ||
| // when the log instance is only used for static functions. | ||
| AOTLogImpl() { | ||
| } | ||
|
|
||
| static bool is_level(LogLevelType level) { | ||
| if (CDSConfig::new_aot_flags_used()) { | ||
| return LogTagSetMapping<LogTag::_aot, T1, T2, T3, T4>::tagset().is_level(level); | ||
| } else { | ||
| return LogTagSetMapping<LogTag::_cds, T1, T2, T3, T4>::tagset().is_level(level); | ||
| } | ||
| } | ||
|
|
||
| ATTRIBUTE_PRINTF(2, 3) | ||
| static void write(LogLevelType level, const char* fmt, ...) { | ||
| va_list args; | ||
| va_start(args, fmt); | ||
| vwrite(level, fmt, args); | ||
| va_end(args); | ||
| } | ||
|
|
||
| template <LogLevelType Level> | ||
| ATTRIBUTE_PRINTF(1, 2) | ||
| static void write(const char* fmt, ...) { | ||
| va_list args; | ||
| va_start(args, fmt); | ||
| vwrite(Level, fmt, args); | ||
| va_end(args); | ||
| } | ||
|
|
||
| ATTRIBUTE_PRINTF(2, 0) | ||
| static void vwrite(LogLevelType level, const char* fmt, va_list args) { | ||
| if (CDSConfig::new_aot_flags_used()) { | ||
| LogTagSetMapping<LogTag::_aot, T1, T2, T3, T4>::tagset().vwrite(level, fmt, args); | ||
| } else { | ||
| LogTagSetMapping<LogTag::_cds, T1, T2, T3, T4>::tagset().vwrite(level, fmt, args); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you specify no flags and rely on the implicit settings e.g.
-Xshare:auto, will-Xlog:cdscontinue to work as today?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the comments to flip the condition -- if no
-XX:AOTxxxflag are used, we print the[cds]decorations.The new AOT workflow requires the use of at least one flag that starts with
-XX:AOT. There's no implicit use of AOT features.