Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8ed2bf5
8355638: Allow -Xlog:aot to be used as an alias for -Xlog:cds
iklam Apr 26, 2025
cedc5db
update
iklam Apr 26, 2025
30f2ce6
Simplified design/implementation: aliasing will always happen with ne…
iklam May 6, 2025
267fdc8
Added LogTagSet::verify_for_aot_aliases()
iklam May 6, 2025
ad6abfc
More tightening .... but this may be the wrong approach
iklam May 6, 2025
4a520a5
Much simplified
iklam May 6, 2025
ac109c3
Much more simplification
iklam May 6, 2025
c00b2f6
Merge branch 'master' into 8355638-xlog-aot-as-alias-for-xlog-cds
iklam May 6, 2025
88b7ea0
Fixed test cases
iklam May 6, 2025
43bdeac
clean up of existing UL logs for cds
iklam May 6, 2025
15a87ce
Fixed comment
iklam May 7, 2025
2c869dc
@jdksjolen comment
iklam May 7, 2025
6adfa95
Merge branch 'master' into 8355638-xlog-aot-as-alias-for-xlog-cds
iklam May 7, 2025
b772b3d
cds+aot+load -> aot+load
iklam May 7, 2025
8b25821
Merge branch 'master' into 8355638-xlog-aot-as-alias-for-xlog-cds
iklam May 8, 2025
38dbe7e
@vnkozlov and @dholmes-ora comments
iklam May 8, 2025
031cbef
Reverted unrelated changes in filemap.cpp
iklam May 8, 2025
82e5518
Removed checks for error message that got removed from the PR
iklam May 8, 2025
ad0c4aa
Merge remote-tracking branch '8355638-xlog-aot-as-alias-for-xlog-cds'…
iklam May 8, 2025
b7670bf
@stefank suggestions
iklam May 9, 2025
dbab9a7
Fixed macos build
iklam May 9, 2025
e2156fb
More conversion; clean up; bug fixes
iklam May 9, 2025
dddf591
Removed PrintAOTLogsAsCDSLogs and improved comments
iklam May 14, 2025
37d334a
@dholmes-ora review - fixed typos
iklam May 14, 2025
8205506
Improved comments: [cds] logs will be printed if no -XX:AOTxxx flags …
iklam May 14, 2025
2abc23b
Merge branch 'master' into 8356595-convert-cds-log-to-aot-log
iklam May 14, 2025
278ab15
Fixed makefile; Fixed copyright
iklam May 14, 2025
2a4355f
Merge master
iklam May 15, 2025
78a79ac
@jdksjolen review comments
iklam May 16, 2025
8ce133d
Merge branch 'master' into 8356595-convert-cds-log-to-aot-log
iklam May 19, 2025
4a2aa74
Fixed merge
iklam May 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions make/GenerateLinkOptData.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXECUTABLE_SUFFIX) $(CLASSLIST
$(call LogInfo, Generating $(patsubst $(OUTPUTDIR)/%, %, $(JLI_TRACE_FILE)))
$(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@.raw \
$(CLASSLIST_FILE_VM_OPTS) \
-Xlog:aot=off \
-Xlog:cds=off \
-cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
build.tools.classlist.HelloClasslist $(LOG_DEBUG)
$(GREP) -v HelloClasslist $@.raw > $@.interim
$(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -Xshare:dump \
-Xlog:aot=off \
-Xlog:cds=off \
-XX:SharedClassListFile=$@.interim -XX:SharedArchiveFile=$@.jsa \
-Xmx128M -Xms128M $(LOG_INFO)
Expand All @@ -89,6 +91,7 @@ $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXECUTABLE_SUFFIX) $(CLASSLIST
-Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \
$(CLASSLIST_FILE_VM_OPTS) \
--module-path $(SUPPORT_OUTPUTDIR)/classlist.jar \
-Xlog:aot=off \
-Xlog:cds=off \
-cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
build.tools.classlist.HelloClasslist \
Expand All @@ -103,6 +106,7 @@ $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXECUTABLE_SUFFIX) $(CLASSLIST
$(GREP) -v HelloClasslist $@.raw.2 > $@.raw.3
$(GREP) -v @cp $@.raw.3 > $@.raw.4
$(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java \
-Xlog:aot=off \
-Xlog:cds=off \
-cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
build.tools.classlist.SortClasslist $@.raw.4 > $@
Expand Down
4 changes: 2 additions & 2 deletions make/RunTests.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -754,15 +754,15 @@ define SetupAOTBody
cd $$($1_AOT_JDK_OUTPUT_DIR); \
$(JAR) --extract --file $(TEST_IMAGE_DIR)/setup_aot/TestSetupAOT.jar; \
$$(FIXPATH) $(JDK_UNDER_TEST)/bin/java $$($1_VM_OPTIONS) \
-Xlog:class+load,cds,cds+class=debug:file=$$($1_AOT_JDK_CONF).log -Xlog:cds*=error \
-Xlog:class+load,aot,aot+class=debug:file=$$($1_AOT_JDK_CONF).log -Xlog:cds*=error -Xlog:aot*=error \
-XX:AOTMode=record -XX:AOTConfiguration=$$($1_AOT_JDK_CONF) \
TestSetupAOT $$($1_AOT_JDK_OUTPUT_DIR) > $$($1_AOT_JDK_LOG) \
))

$$(call LogWarn, AOT: Generate AOT cache $$($1_AOT_JDK_CACHE) with flags: $$($1_VM_OPTIONS))
$$(call ExecuteWithLog, $$($1_AOT_JDK_OUTPUT_DIR), ( \
$$(FIXPATH) $(JDK_UNDER_TEST)/bin/java \
$$($1_VM_OPTIONS) -Xlog:cds,cds+class=debug:file=$$($1_AOT_JDK_CACHE).log -Xlog:cds*=error \
$$($1_VM_OPTIONS) -Xlog:aot,aot+class=debug:file=$$($1_AOT_JDK_CACHE).log -Xlog:cds*=error -Xlog:aot*=error \
-XX:ExtraSharedClassListFile=$(JDK_UNDER_TEST)/lib/classlist \
-XX:AOTMode=create -XX:AOTConfiguration=$$($1_AOT_JDK_CONF) -XX:AOTCache=$$($1_AOT_JDK_CACHE) \
))
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/cds/aotArtifactFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void AOTArtifactFinder::find_artifacts() {
oop orig_mirror = Universe::java_mirror(bt);
oop scratch_mirror = HeapShared::scratch_java_mirror(bt);
HeapShared::scan_java_mirror(orig_mirror);
log_trace(cds, heap, mirror)(
log_trace(aot, heap, mirror)(
"Archived %s mirror object from " PTR_FORMAT,
type2name(bt), p2i(scratch_mirror));
Universe::set_archived_basic_type_mirror_index(bt, HeapShared::append_root(scratch_mirror));
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/cds/aotClassLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ void AOTClassLinker::add_new_candidate(InstanceKlass* ik) {
_candidates->put_when_absent(ik, true);
_sorted_candidates->append(ik);

if (log_is_enabled(Info, cds, aot, link)) {
if (log_is_enabled(Info, aot, link)) {
ResourceMark rm;
log_info(cds, aot, link)("%s %s %p", class_category_name(ik), ik->external_name(), ik);
log_info(aot, link)("%s %s %p", class_category_name(ik), ik->external_name(), ik);
}
}

Expand Down Expand Up @@ -145,7 +145,7 @@ bool AOTClassLinker::try_add_candidate(InstanceKlass* ik) {
InstanceKlass* nest_host = ik->nest_host_not_null();
if (!try_add_candidate(nest_host)) {
ResourceMark rm;
log_warning(cds, aot, link)("%s cannot be aot-linked because it nest host is not aot-linked", ik->external_name());
log_warning(aot, link)("%s cannot be aot-linked because it nest host is not aot-linked", ik->external_name());
return false;
}
}
Expand Down Expand Up @@ -228,7 +228,7 @@ Array<InstanceKlass*>* AOTClassLinker::write_classes(oop class_loader, bool is_j
return nullptr;
} else {
const char* category = class_category_name(list.at(0));
log_info(cds, aot, link)("wrote %d class(es) for category %s", list.length(), category);
log_info(aot, link)("wrote %d class(es) for category %s", list.length(), category);
return ArchiveUtils::archive_array(&list);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/cds/aotClassLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,8 +1029,7 @@ bool AOTClassLocationConfig::validate(bool has_aot_linked_classes, bool* has_ext
MetaspaceShared::unrecoverable_loading_error();
}
} else {
log_warning(cds)("%s%s", mismatch_msg, hint_msg);
MetaspaceShared::report_loading_error(nullptr);
MetaspaceShared::report_loading_error("%s%s", mismatch_msg, hint_msg);
}
}
return success;
Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ void AOTLinkedClassBulkLoader::load_classes_impl(AOTLinkedClassCategory class_ca

for (int i = 0; i < classes->length(); i++) {
InstanceKlass* ik = classes->at(i);
if (log_is_enabled(Info, cds, aot, load)) {
if (log_is_enabled(Info, aot, load)) {
ResourceMark rm(THREAD);
log_info(cds, aot, load)("%-5s %s%s%s", category_name, ik->external_name(),
ik->is_loaded() ? " (already loaded)" : "",
ik->is_hidden() ? " (hidden)" : "");
log_info(aot, load)("%-5s %s%s%s", category_name, ik->external_name(),
ik->is_loaded() ? " (already loaded)" : "",
ik->is_hidden() ? " (hidden)" : "");
}

if (!ik->is_loaded()) {
Expand Down Expand Up @@ -236,11 +236,11 @@ void AOTLinkedClassBulkLoader::initiate_loading(JavaThread* current, const char*
assert(ik->class_loader() == nullptr ||
ik->class_loader() == SystemDictionary::java_platform_loader(), "must be");
if (ik->is_public() && !ik->is_hidden()) {
if (log_is_enabled(Info, cds, aot, load)) {
if (log_is_enabled(Info, aot, load)) {
ResourceMark rm(current);
const char* defining_loader = (ik->class_loader() == nullptr ? "boot" : "plat");
log_info(cds, aot, load)("%s %s (initiated, defined by %s)", category_name, ik->external_name(),
defining_loader);
log_info(aot, load)("%s %s (initiated, defined by %s)", category_name, ik->external_name(),
defining_loader);
}
SystemDictionary::add_to_initiating_loader(current, ik, loader_data);
}
Expand Down
167 changes: 167 additions & 0 deletions src/hotspot/share/cds/aotLogging.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*
* 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
// chosen 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 workflow (i.e.,
// new -XX:AOTxxx flags are not used).
//
// $ 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 are selected via the aot tag, and not the cds tag.
// They are always printed with [aot] decoration
//
// [2] When using CDS archives
// - These logs are selected via the cds tag, and not the aot tag.
// They are always printed with [cds] decoration
//
// Deprecation Process
// ===================
//
// This is modeled after the deprecate/obsolete/expire process of VM options in arguments.cpp
//
// JDK 25 - When no -XX:AOTxxx flags are used, 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, a warning
// message is printed to indicate that -Xlog:cds is deprecated.
//
// JDK 27 - The CDS Compatibility Logs must be selected with -Xlog:aot.
//
// When -Xlog:cds is specified in the command-line, a warning message is printed to
// 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
12 changes: 6 additions & 6 deletions src/hotspot/share/cds/aotReferenceObjSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,24 +197,24 @@ bool AOTReferenceObjSupport::check_if_ref_obj(oop obj) {
if (needs_special_cleanup && (referent == nullptr || !_keep_alive_objs_table->contains(referent))) {
ResourceMark rm;

log_error(cds, heap)("Cannot archive reference object " PTR_FORMAT " of class %s",
log_error(aot, heap)("Cannot archive reference object " PTR_FORMAT " of class %s",
p2i(obj), obj->klass()->external_name());
log_error(cds, heap)("referent = " PTR_FORMAT
log_error(aot, heap)("referent = " PTR_FORMAT
", queue = " PTR_FORMAT
", next = " PTR_FORMAT
", discovered = " PTR_FORMAT,
p2i(referent), p2i(queue), p2i(next), p2i(discovered));
log_error(cds, heap)("This object requires special clean up as its queue is not ReferenceQueue::N" "ULL ("
log_error(aot, heap)("This object requires special clean up as its queue is not ReferenceQueue::N" "ULL ("
PTR_FORMAT ")", p2i(_null_queue.resolve()));
log_error(cds, heap)("%s", (referent == nullptr) ?
log_error(aot, heap)("%s", (referent == nullptr) ?
"referent cannot be null" : "referent is not registered with CDS.keepAlive()");
HeapShared::debug_trace();
MetaspaceShared::unrecoverable_writing_error();
}

if (log_is_enabled(Info, cds, ref)) {
if (log_is_enabled(Info, aot, ref)) {
ResourceMark rm;
log_info(cds, ref)("Reference obj:"
log_info(aot, ref)("Reference obj:"
" r=" PTR_FORMAT
" q=" PTR_FORMAT
" n=" PTR_FORMAT
Expand Down
Loading