From 7077535c0b0a6ea0a2a167f9135b1504a3d71fb3 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Tue, 20 May 2025 03:44:25 +0000 Subject: [PATCH] 8356595: Convert -Xlog:cds to -Xlog:aot (step1) Reviewed-by: ccheung, dholmes, jsjolen, matsaave --- make/GenerateLinkOptData.gmk | 4 + make/RunTests.gmk | 4 +- src/hotspot/share/cds/aotArtifactFinder.cpp | 2 +- src/hotspot/share/cds/aotClassLinker.cpp | 8 +- src/hotspot/share/cds/aotClassLocation.cpp | 3 +- .../share/cds/aotLinkedClassBulkLoader.cpp | 14 +- src/hotspot/share/cds/aotLogging.hpp | 167 +++++++++++++++ .../share/cds/aotReferenceObjSupport.cpp | 12 +- src/hotspot/share/cds/archiveBuilder.cpp | 81 +++---- src/hotspot/share/cds/archiveHeapLoader.cpp | 4 +- src/hotspot/share/cds/archiveHeapWriter.cpp | 8 +- src/hotspot/share/cds/cdsConfig.cpp | 2 +- src/hotspot/share/cds/cdsEnumKlass.cpp | 6 +- src/hotspot/share/cds/cdsHeapVerifier.cpp | 6 +- src/hotspot/share/cds/dumpAllocStats.cpp | 2 +- src/hotspot/share/cds/filemap.cpp | 201 +++++++++--------- src/hotspot/share/cds/finalImageRecipes.cpp | 10 +- src/hotspot/share/cds/heapShared.cpp | 125 +++++------ src/hotspot/share/cds/lambdaFormInvokers.cpp | 16 +- src/hotspot/share/cds/metaspaceShared.cpp | 134 ++++++------ src/hotspot/share/cds/metaspaceShared.hpp | 2 +- src/hotspot/share/classfile/javaClasses.cpp | 6 +- src/hotspot/share/oops/klass.cpp | 18 +- src/hotspot/share/prims/jvmtiTagMap.cpp | 4 +- src/hotspot/share/runtime/arguments.cpp | 7 +- src/hotspot/share/services/heapDumper.cpp | 8 +- .../jtreg/runtime/cds/appcds/AOTFlags.java | 26 +-- .../cds/appcds/ArchiveRelocationTest.java | 2 +- .../cds/appcds/ClassListFormatBase.java | 6 +- .../cds/appcds/DumpingWithNoCoops.java | 4 +- .../cds/appcds/LambdaWithJavaAgent.java | 4 +- .../AOTCacheSupportForCustomLoaders.java | 10 +- .../cds/appcds/aotCache/AOTLoggingTag.java | 114 ++++++++++ .../cds/appcds/aotCache/VerifierFailOver.java | 2 +- .../aotClassLinking/AOTCacheWithZGC.java | 2 +- .../AOTClassLinkingVMOptions.java | 9 +- .../aotClassLinking/BulkLoaderTest.java | 4 +- .../aotClassLinking/FakeCodeLocation.java | 8 +- .../aotCode/AOTCodeCompressedOopsTest.java | 4 +- .../cacheObject/ArchiveHeapTestClass.java | 12 +- .../appcds/dynamicArchive/ArrayKlasses.java | 4 +- .../dynamicArchive/DynamicLotsOfClasses.java | 4 +- .../cds/appcds/jigsaw/ExactOptionMatch.java | 10 +- .../appcds/jigsaw/addmods/AddmodsOption.java | 4 +- .../jigsaw/addopens/AddopensOption.java | 2 +- .../appcds/jigsaw/module/ModuleOption.java | 4 +- .../jvmti/CFLH/ClassFileLoadHookTest.java | 3 +- .../ReplaceCriticalClasses.java | 5 +- test/lib/jdk/test/lib/cds/CDSAppTester.java | 17 +- 49 files changed, 710 insertions(+), 404 deletions(-) create mode 100644 src/hotspot/share/cds/aotLogging.hpp create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTLoggingTag.java diff --git a/make/GenerateLinkOptData.gmk b/make/GenerateLinkOptData.gmk index 1f52b88e1ef..6f6e1f29b4c 100644 --- a/make/GenerateLinkOptData.gmk +++ b/make/GenerateLinkOptData.gmk @@ -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) @@ -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 \ @@ -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 > $@ diff --git a/make/RunTests.gmk b/make/RunTests.gmk index 3c0280353a9..95d3dee7013 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -754,7 +754,7 @@ 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) \ )) @@ -762,7 +762,7 @@ define SetupAOTBody $$(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) \ )) diff --git a/src/hotspot/share/cds/aotArtifactFinder.cpp b/src/hotspot/share/cds/aotArtifactFinder.cpp index d87b501150b..f16e0d9e908 100644 --- a/src/hotspot/share/cds/aotArtifactFinder.cpp +++ b/src/hotspot/share/cds/aotArtifactFinder.cpp @@ -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)); diff --git a/src/hotspot/share/cds/aotClassLinker.cpp b/src/hotspot/share/cds/aotClassLinker.cpp index cd3712f0c65..319c94f553d 100644 --- a/src/hotspot/share/cds/aotClassLinker.cpp +++ b/src/hotspot/share/cds/aotClassLinker.cpp @@ -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); } } @@ -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; } } @@ -228,7 +228,7 @@ Array* 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); } } diff --git a/src/hotspot/share/cds/aotClassLocation.cpp b/src/hotspot/share/cds/aotClassLocation.cpp index a2a707e2608..ae7dcd7ffd4 100644 --- a/src/hotspot/share/cds/aotClassLocation.cpp +++ b/src/hotspot/share/cds/aotClassLocation.cpp @@ -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; diff --git a/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp b/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp index 31d95024e3b..0c4e07d3328 100644 --- a/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp +++ b/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp @@ -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()) { @@ -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); } diff --git a/src/hotspot/share/cds/aotLogging.hpp b/src/hotspot/share/cds/aotLogging.hpp new file mode 100644 index 00000000000..f9515341d72 --- /dev/null +++ b/src/hotspot/share/cds/aotLogging.hpp @@ -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::is_level(LogLevel::level)) + +#define aot_log_error(...) (!aot_log_is_enabled(Error, __VA_ARGS__)) ? (void)0 : AOTLogImpl::write +#define aot_log_warning(...) (!aot_log_is_enabled(Warning, __VA_ARGS__)) ? (void)0 : AOTLogImpl::write +#define aot_log_info(...) (!aot_log_is_enabled(Info, __VA_ARGS__)) ? (void)0 : AOTLogImpl::write +#define aot_log_debug(...) (!aot_log_is_enabled(Debug, __VA_ARGS__)) ? (void)0 : AOTLogImpl::write +#define aot_log_trace(...) (!aot_log_is_enabled(Trace, __VA_ARGS__)) ? (void)0 : AOTLogImpl::write + +template +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::tagset().is_level(level); + } else { + return LogTagSetMapping::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 + 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::tagset().vwrite(level, fmt, args); + } else { + LogTagSetMapping::tagset().vwrite(level, fmt, args); + } + } +}; + +#endif diff --git a/src/hotspot/share/cds/aotReferenceObjSupport.cpp b/src/hotspot/share/cds/aotReferenceObjSupport.cpp index e948a6cefa3..a62e9c7735a 100644 --- a/src/hotspot/share/cds/aotReferenceObjSupport.cpp +++ b/src/hotspot/share/cds/aotReferenceObjSupport.cpp @@ -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 diff --git a/src/hotspot/share/cds/archiveBuilder.cpp b/src/hotspot/share/cds/archiveBuilder.cpp index a544b4921d4..aaebf8bef88 100644 --- a/src/hotspot/share/cds/archiveBuilder.cpp +++ b/src/hotspot/share/cds/archiveBuilder.cpp @@ -25,6 +25,7 @@ #include "cds/aotArtifactFinder.hpp" #include "cds/aotClassLinker.hpp" #include "cds/aotLinkedClassBulkLoader.hpp" +#include "cds/aotLogging.hpp" #include "cds/archiveBuilder.hpp" #include "cds/archiveHeapWriter.hpp" #include "cds/archiveUtils.hpp" @@ -133,7 +134,7 @@ public: address old_p = *ptr_loc; address new_p = _builder->get_buffered_addr(old_p); - log_trace(cds)("Ref: [" PTR_FORMAT "] -> " PTR_FORMAT " => " PTR_FORMAT, + log_trace(aot)("Ref: [" PTR_FORMAT "] -> " PTR_FORMAT " => " PTR_FORMAT, p2i(ptr_loc), p2i(old_p), p2i(new_p)); ArchivePtrMarker::set_and_mark_pointer(ptr_loc, new_p); @@ -251,7 +252,7 @@ void ArchiveBuilder::gather_klasses_and_symbols() { AOTArtifactFinder::initialize(); AOTArtifactFinder::find_artifacts(); - log_info(cds)("Gathering classes and symbols ... "); + aot_log_info(aot)("Gathering classes and symbols ... "); GatherKlassesAndSymbols doit(this); iterate_roots(&doit); #if INCLUDE_CDS_JAVA_HEAP @@ -281,7 +282,7 @@ void ArchiveBuilder::gather_klasses_and_symbols() { // TODO: in the future, if we want to produce deterministic contents in the // dynamic archive, we might need to sort the symbols alphabetically (also see // DynamicArchiveBuilder::sort_methods()). - log_info(cds)("Sorting symbols ... "); + aot_log_info(aot)("Sorting symbols ... "); _symbols->sort(compare_symbols_by_address); sort_klasses(); } @@ -303,7 +304,7 @@ int ArchiveBuilder::compare_klass_by_name(Klass** a, Klass** b) { } void ArchiveBuilder::sort_klasses() { - log_info(cds)("Sorting classes ... "); + aot_log_info(aot)("Sorting classes ... "); _klasses->sort(compare_klass_by_name); } @@ -315,14 +316,14 @@ address ArchiveBuilder::reserve_buffer() { os::vm_page_size(), mtNone); if (!rs.is_reserved()) { - log_error(cds)("Failed to reserve %zu bytes of output buffer.", buffer_size); + aot_log_error(aot)("Failed to reserve %zu bytes of output buffer.", buffer_size); MetaspaceShared::unrecoverable_writing_error(); } // buffer_bottom is the lowest address of the 2 core regions (rw, ro) when // we are copying the class metadata into the buffer. address buffer_bottom = (address)rs.base(); - log_info(cds)("Reserved output buffer space at " PTR_FORMAT " [%zu bytes]", + aot_log_info(aot)("Reserved output buffer space at " PTR_FORMAT " [%zu bytes]", p2i(buffer_bottom), buffer_size); _shared_rs = rs; @@ -364,9 +365,9 @@ address ArchiveBuilder::reserve_buffer() { if (my_archive_requested_bottom < _requested_static_archive_bottom || my_archive_requested_top <= _requested_static_archive_bottom) { // Size overflow. - log_error(cds)("my_archive_requested_bottom = " INTPTR_FORMAT, p2i(my_archive_requested_bottom)); - log_error(cds)("my_archive_requested_top = " INTPTR_FORMAT, p2i(my_archive_requested_top)); - log_error(cds)("SharedBaseAddress (" INTPTR_FORMAT ") is too high. " + aot_log_error(aot)("my_archive_requested_bottom = " INTPTR_FORMAT, p2i(my_archive_requested_bottom)); + aot_log_error(aot)("my_archive_requested_top = " INTPTR_FORMAT, p2i(my_archive_requested_top)); + aot_log_error(aot)("SharedBaseAddress (" INTPTR_FORMAT ") is too high. " "Please rerun java -Xshare:dump with a lower value", p2i(_requested_static_archive_bottom)); MetaspaceShared::unrecoverable_writing_error(); } @@ -424,7 +425,7 @@ bool ArchiveBuilder::gather_one_source_obj(MetaspaceClosure::Ref* ref, bool read SourceObjInfo* p = _src_obj_table.put_if_absent(src_obj, src_info, &created); if (created) { if (_src_obj_table.maybe_grow()) { - log_info(cds, hashtables)("Expanded _src_obj_table table to %d", _src_obj_table.table_size()); + log_info(aot, hashtables)("Expanded _src_obj_table table to %d", _src_obj_table.table_size()); } } @@ -503,7 +504,7 @@ void ArchiveBuilder::remember_embedded_pointer_in_enclosing_obj(MetaspaceClosure void ArchiveBuilder::gather_source_objs() { ResourceMark rm; - log_info(cds)("Gathering all archivable objects ... "); + aot_log_info(aot)("Gathering all archivable objects ... "); gather_klasses_and_symbols(); GatherSortedSourceObjs doit(this); iterate_sorted_roots(&doit); @@ -590,7 +591,7 @@ void ArchiveBuilder::sort_metadata_objs() { void ArchiveBuilder::dump_rw_metadata() { ResourceMark rm; - log_info(cds)("Allocating RW objects ... "); + aot_log_info(aot)("Allocating RW objects ... "); make_shallow_copies(&_rw_region, &_rw_src_objs); #if INCLUDE_CDS_JAVA_HEAP @@ -605,7 +606,7 @@ void ArchiveBuilder::dump_rw_metadata() { void ArchiveBuilder::dump_ro_metadata() { ResourceMark rm; - log_info(cds)("Allocating RO objects ... "); + aot_log_info(aot)("Allocating RO objects ... "); start_dump_region(&_ro_region); make_shallow_copies(&_ro_region, &_ro_src_objs); @@ -626,7 +627,7 @@ void ArchiveBuilder::make_shallow_copies(DumpRegion *dump_region, for (int i = 0; i < src_objs->objs()->length(); i++) { make_shallow_copy(dump_region, src_objs->objs()->at(i)); } - log_info(cds)("done (%d objects)", src_objs->objs()->length()); + aot_log_info(aot)("done (%d objects)", src_objs->objs()->length()); } void ArchiveBuilder::make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* src_info) { @@ -676,7 +677,7 @@ void ArchiveBuilder::make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* s _buffered_to_src_table.put_if_absent((address)dest, src, &created); assert(created, "must be"); if (_buffered_to_src_table.maybe_grow()) { - log_info(cds, hashtables)("Expanded _buffered_to_src_table table to %d", _buffered_to_src_table.table_size()); + log_info(aot, hashtables)("Expanded _buffered_to_src_table table to %d", _buffered_to_src_table.table_size()); } } @@ -686,7 +687,7 @@ void ArchiveBuilder::make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* s ArchivePtrMarker::mark_pointer((address*)dest); } - log_trace(cds)("Copy: " PTR_FORMAT " ==> " PTR_FORMAT " %d", p2i(src), p2i(dest), bytes); + log_trace(aot)("Copy: " PTR_FORMAT " ==> " PTR_FORMAT " %d", p2i(src), p2i(dest), bytes); src_info->set_buffered_addr((address)dest); _alloc_stats.record(src_info->msotype(), int(newtop - oldtop), src_info->read_only()); @@ -752,7 +753,7 @@ void ArchiveBuilder::relocate_embedded_pointers(ArchiveBuilder::SourceObjList* s } void ArchiveBuilder::relocate_metaspaceobj_embedded_pointers() { - log_info(cds)("Relocating embedded pointers in core regions ... "); + aot_log_info(aot)("Relocating embedded pointers in core regions ... "); relocate_embedded_pointers(&_rw_src_objs); relocate_embedded_pointers(&_ro_src_objs); } @@ -923,9 +924,9 @@ void ArchiveBuilder::make_klasses_shareable() { ik->remove_unshareable_info(); } - if (log_is_enabled(Debug, cds, class)) { + if (aot_log_is_enabled(Debug, aot, class)) { ResourceMark rm; - log_debug(cds, class)("klasses[%5d] = " PTR_FORMAT " %-5s %s%s%s%s%s%s%s%s", i, + aot_log_debug(aot, class)("klasses[%5d] = " PTR_FORMAT " %-5s %s%s%s%s%s%s%s%s", i, p2i(to_requested(k)), type, k->external_name(), kind, hidden, old, unlinked, generated, aotlinked_msg, inited_msg); } @@ -934,21 +935,21 @@ void ArchiveBuilder::make_klasses_shareable() { #define STATS_FORMAT "= %5d, aot-linked = %5d, inited = %5d" #define STATS_PARAMS(x) num_ ## x, num_ ## x ## _a, num_ ## x ## _i - log_info(cds)("Number of classes %d", num_instance_klasses + num_obj_array_klasses + num_type_array_klasses); - log_info(cds)(" instance classes " STATS_FORMAT, STATS_PARAMS(instance_klasses)); - log_info(cds)(" boot " STATS_FORMAT, STATS_PARAMS(boot_klasses)); - log_info(cds)(" vm " STATS_FORMAT, STATS_PARAMS(vm_klasses)); - log_info(cds)(" platform " STATS_FORMAT, STATS_PARAMS(platform_klasses)); - log_info(cds)(" app " STATS_FORMAT, STATS_PARAMS(app_klasses)); - log_info(cds)(" unregistered " STATS_FORMAT, STATS_PARAMS(unregistered_klasses)); - log_info(cds)(" (enum) " STATS_FORMAT, STATS_PARAMS(enum_klasses)); - log_info(cds)(" (hidden) " STATS_FORMAT, STATS_PARAMS(hidden_klasses)); - log_info(cds)(" (old) " STATS_FORMAT, STATS_PARAMS(old_klasses)); - log_info(cds)(" (unlinked) = %5d, boot = %d, plat = %d, app = %d, unreg = %d", + aot_log_info(aot)("Number of classes %d", num_instance_klasses + num_obj_array_klasses + num_type_array_klasses); + aot_log_info(aot)(" instance classes " STATS_FORMAT, STATS_PARAMS(instance_klasses)); + aot_log_info(aot)(" boot " STATS_FORMAT, STATS_PARAMS(boot_klasses)); + aot_log_info(aot)(" vm " STATS_FORMAT, STATS_PARAMS(vm_klasses)); + aot_log_info(aot)(" platform " STATS_FORMAT, STATS_PARAMS(platform_klasses)); + aot_log_info(aot)(" app " STATS_FORMAT, STATS_PARAMS(app_klasses)); + aot_log_info(aot)(" unregistered " STATS_FORMAT, STATS_PARAMS(unregistered_klasses)); + aot_log_info(aot)(" (enum) " STATS_FORMAT, STATS_PARAMS(enum_klasses)); + aot_log_info(aot)(" (hidden) " STATS_FORMAT, STATS_PARAMS(hidden_klasses)); + aot_log_info(aot)(" (old) " STATS_FORMAT, STATS_PARAMS(old_klasses)); + aot_log_info(aot)(" (unlinked) = %5d, boot = %d, plat = %d, app = %d, unreg = %d", num_unlinked_klasses, boot_unlinked, platform_unlinked, app_unlinked, unreg_unlinked); - log_info(cds)(" obj array classes = %5d", num_obj_array_klasses); - log_info(cds)(" type array classes = %5d", num_type_array_klasses); - log_info(cds)(" symbols = %5d", _symbols->length()); + aot_log_info(aot)(" obj array classes = %5d", num_obj_array_klasses); + aot_log_info(aot)(" type array classes = %5d", num_type_array_klasses); + aot_log_info(aot)(" symbols = %5d", _symbols->length()); #undef STATS_FORMAT #undef STATS_PARAMS @@ -1050,7 +1051,7 @@ class RelocateBufferToRequested : public BitMapClosure { address top = _builder->buffer_top(); address new_bottom = bottom + _buffer_to_requested_delta; address new_top = top + _buffer_to_requested_delta; - log_debug(cds)("Relocating archive from [" INTPTR_FORMAT " - " INTPTR_FORMAT "] to " + aot_log_debug(aot)("Relocating archive from [" INTPTR_FORMAT " - " INTPTR_FORMAT "] to " "[" INTPTR_FORMAT " - " INTPTR_FORMAT "]", p2i(bottom), p2i(top), p2i(new_bottom), p2i(new_top)); @@ -1574,8 +1575,8 @@ void ArchiveBuilder::write_archive(FileMapInfo* mapinfo, ArchiveHeapInfo* heap_i mapinfo->write_header(); mapinfo->close(); - if (log_is_enabled(Info, cds)) { - log_info(cds)("Full module graph = %s", CDSConfig::is_dumping_full_module_graph() ? "enabled" : "disabled"); + if (log_is_enabled(Info, aot)) { + log_info(aot)("Full module graph = %s", CDSConfig::is_dumping_full_module_graph() ? "enabled" : "disabled"); print_stats(); } @@ -1613,12 +1614,12 @@ void ArchiveBuilder::print_region_stats(FileMapInfo *mapinfo, ArchiveHeapInfo* h print_heap_region_stats(heap_info, total_reserved); } - log_debug(cds)("total : %9zu [100.0%% of total] out of %9zu bytes [%5.1f%% used]", + aot_log_debug(aot)("total : %9zu [100.0%% of total] out of %9zu bytes [%5.1f%% used]", total_bytes, total_reserved, total_u_perc); } void ArchiveBuilder::print_bitmap_region_stats(size_t size, size_t total_size) { - log_debug(cds)("bm space: %9zu [ %4.1f%% of total] out of %9zu bytes [100.0%% used]", + aot_log_debug(aot)("bm space: %9zu [ %4.1f%% of total] out of %9zu bytes [100.0%% used]", size, size/double(total_size)*100.0, size); } @@ -1626,7 +1627,7 @@ void ArchiveBuilder::print_heap_region_stats(ArchiveHeapInfo *info, size_t total char* start = info->buffer_start(); size_t size = info->buffer_byte_size(); char* top = start + size; - log_debug(cds)("hp space: %9zu [ %4.1f%% of total] out of %9zu bytes [100.0%% used] at " INTPTR_FORMAT, + aot_log_debug(aot)("hp space: %9zu [ %4.1f%% of total] out of %9zu bytes [100.0%% used] at " INTPTR_FORMAT, size, size/double(total_size)*100.0, size, p2i(start)); } @@ -1637,6 +1638,6 @@ void ArchiveBuilder::report_out_of_space(const char* name, size_t needed_bytes) _rw_region.print_out_of_space_msg(name, needed_bytes); _ro_region.print_out_of_space_msg(name, needed_bytes); - log_error(cds)("Unable to allocate from '%s' region: Please reduce the number of shared classes.", name); + log_error(aot)("Unable to allocate from '%s' region: Please reduce the number of shared classes.", name); MetaspaceShared::unrecoverable_writing_error(); } diff --git a/src/hotspot/share/cds/archiveHeapLoader.cpp b/src/hotspot/share/cds/archiveHeapLoader.cpp index 68015e319c3..f604dadf980 100644 --- a/src/hotspot/share/cds/archiveHeapLoader.cpp +++ b/src/hotspot/share/cds/archiveHeapLoader.cpp @@ -408,7 +408,7 @@ void ArchiveHeapLoader::finish_loaded_heap() { } void ArchiveHeapLoader::verify_loaded_heap() { - log_info(cds, heap)("Verify all oops and pointers in loaded heap"); + log_info(aot, heap)("Verify all oops and pointers in loaded heap"); ResourceMark rm; ResourceHashtable table; @@ -459,7 +459,7 @@ void ArchiveHeapLoader::patch_native_pointers() { FileMapRegion* r = FileMapInfo::current_info()->region_at(MetaspaceShared::hp); if (r->mapped_base() != nullptr && r->has_ptrmap()) { - log_info(cds, heap)("Patching native pointers in heap region"); + log_info(aot, heap)("Patching native pointers in heap region"); BitMapView bm = FileMapInfo::current_info()->ptrmap_view(MetaspaceShared::hp); PatchNativePointers patcher((Metadata**)r->mapped_base() + FileMapInfo::current_info()->heap_ptrmap_start_pos()); bm.iterate(&patcher); diff --git a/src/hotspot/share/cds/archiveHeapWriter.cpp b/src/hotspot/share/cds/archiveHeapWriter.cpp index 2b6d403d835..1a6b8b1e488 100644 --- a/src/hotspot/share/cds/archiveHeapWriter.cpp +++ b/src/hotspot/share/cds/archiveHeapWriter.cpp @@ -247,7 +247,7 @@ void ArchiveHeapWriter::copy_roots_to_buffer(GrowableArrayCHeapat(root_index++)); } - log_info(cds, heap)("archived obj root segment [%d] = %zu bytes, obj = " PTR_FORMAT, + log_info(aot, heap)("archived obj root segment [%d] = %zu bytes, obj = " PTR_FORMAT, size_elems, size_bytes, p2i(seg_oop)); } @@ -396,7 +396,7 @@ void ArchiveHeapWriter::maybe_fill_gc_region_gap(size_t required_byte_size) { ensure_buffer_space(filler_end); int array_length = filler_array_length(fill_bytes); - log_info(cds, heap)("Inserting filler obj array of %d elements (%zu bytes total) @ buffer offset %zu", + log_info(aot, heap)("Inserting filler obj array of %d elements (%zu bytes total) @ buffer offset %zu", array_length, fill_bytes, _buffer_used); HeapWord* filler = init_filler_array_at_buffer_top(array_length, fill_bytes); _buffer_used = filler_end; @@ -474,7 +474,7 @@ void ArchiveHeapWriter::set_requested_address(ArchiveHeapInfo* info) { if (UseCompressedOops) { if (UseG1GC) { address heap_end = (address)G1CollectedHeap::heap()->reserved().end(); - log_info(cds, heap)("Heap end = %p", heap_end); + log_info(aot, heap)("Heap end = %p", heap_end); _requested_bottom = align_down(heap_end - heap_region_byte_size, G1HeapRegion::GrainBytes); _requested_bottom = align_down(_requested_bottom, MIN_GC_REGION_ALIGNMENT); assert(is_aligned(_requested_bottom, G1HeapRegion::GrainBytes), "sanity"); @@ -763,7 +763,7 @@ void ArchiveHeapWriter::compute_ptrmap(ArchiveHeapInfo* heap_info) { } heap_info->ptrmap()->resize(max_idx + 1); - log_info(cds, heap)("calculate_ptrmap: marked %d non-null native pointers for heap region (%zu bits)", + log_info(aot, heap)("calculate_ptrmap: marked %d non-null native pointers for heap region (%zu bits)", num_non_null_ptrs, size_t(heap_info->ptrmap()->size())); } diff --git a/src/hotspot/share/cds/cdsConfig.cpp b/src/hotspot/share/cds/cdsConfig.cpp index 29376e71a93..52db54e7049 100644 --- a/src/hotspot/share/cds/cdsConfig.cpp +++ b/src/hotspot/share/cds/cdsConfig.cpp @@ -411,7 +411,7 @@ void CDSConfig::check_aot_flags() { } if (FLAG_IS_DEFAULT(AOTCache) && FLAG_IS_DEFAULT(AOTConfiguration) && FLAG_IS_DEFAULT(AOTMode)) { - // AOTCache/AOTConfiguration/AOTMode not used. + // AOTCache/AOTConfiguration/AOTMode not used -> using the "classic CDS" workflow. return; } else { _new_aot_flags_used = true; diff --git a/src/hotspot/share/cds/cdsEnumKlass.cpp b/src/hotspot/share/cds/cdsEnumKlass.cpp index ffce9fb269a..fe55c904312 100644 --- a/src/hotspot/share/cds/cdsEnumKlass.cpp +++ b/src/hotspot/share/cds/cdsEnumKlass.cpp @@ -99,7 +99,7 @@ void CDSEnumKlass::archive_static_field(int level, KlassSubGraphInfo* subgraph_i bool success = HeapShared::archive_reachable_objects_from(level, subgraph_info, oop_field); assert(success, "VM should have exited with unarchivable objects for _level > 1"); int root_index = HeapShared::append_root(oop_field); - log_info(cds, heap)("Archived enum obj @%d %s::%s (" INTPTR_FORMAT ")", + log_info(aot, heap)("Archived enum obj @%d %s::%s (" INTPTR_FORMAT ")", root_index, ik->external_name(), fd.name()->as_C_string(), p2i((oopDesc*)oop_field)); SystemDictionaryShared::add_enum_klass_static_field(ik, root_index); @@ -113,9 +113,9 @@ bool CDSEnumKlass::initialize_enum_klass(InstanceKlass* k, TRAPS) { RunTimeClassInfo* info = RunTimeClassInfo::get_for(k); assert(info != nullptr, "sanity"); - if (log_is_enabled(Info, cds, heap)) { + if (log_is_enabled(Info, aot, heap)) { ResourceMark rm; - log_info(cds, heap)("Initializing Enum class: %s", k->external_name()); + log_info(aot, heap)("Initializing Enum class: %s", k->external_name()); } oop mirror = k->java_mirror(); diff --git a/src/hotspot/share/cds/cdsHeapVerifier.cpp b/src/hotspot/share/cds/cdsHeapVerifier.cpp index 2e96f818c14..2f3c2521b22 100644 --- a/src/hotspot/share/cds/cdsHeapVerifier.cpp +++ b/src/hotspot/share/cds/cdsHeapVerifier.cpp @@ -151,10 +151,10 @@ CDSHeapVerifier::CDSHeapVerifier() : _archived_objs(0), _problems(0) CDSHeapVerifier::~CDSHeapVerifier() { if (_problems > 0) { - log_error(cds, heap)("Scanned %d objects. Found %d case(s) where " + log_error(aot, heap)("Scanned %d objects. Found %d case(s) where " "an object points to a static field that " "may hold a different value at runtime.", _archived_objs, _problems); - log_error(cds, heap)("Please see cdsHeapVerifier.cpp and aotClassInitializer.cpp for details"); + log_error(aot, heap)("Please see cdsHeapVerifier.cpp and aotClassInitializer.cpp for details"); MetaspaceShared::unrecoverable_writing_error(); } } @@ -285,7 +285,7 @@ inline bool CDSHeapVerifier::do_entry(oop& orig_obj, HeapShared::CachedOopInfo& ResourceMark rm; char* class_name = info->_holder->name()->as_C_string(); char* field_name = info->_name->as_C_string(); - LogStream ls(Log(cds, heap)::warning()); + LogStream ls(Log(aot, heap)::warning()); ls.print_cr("Archive heap points to a static field that may hold a different value at runtime:"); ls.print_cr("Field: %s::%s", class_name, field_name); ls.print("Value: "); diff --git a/src/hotspot/share/cds/dumpAllocStats.cpp b/src/hotspot/share/cds/dumpAllocStats.cpp index 5587ac2fac8..671612ec6b3 100644 --- a/src/hotspot/share/cds/dumpAllocStats.cpp +++ b/src/hotspot/share/cds/dumpAllocStats.cpp @@ -52,7 +52,7 @@ void DumpAllocStats::print_stats(int ro_all, int rw_all) { const char *sep = "--------------------+---------------------------+---------------------------+--------------------------"; const char *hdr = " ro_cnt ro_bytes % | rw_cnt rw_bytes % | all_cnt all_bytes %"; - LogMessage(cds) msg; + LogMessage(aot) msg; msg.debug("Detailed metadata info (excluding heap region):"); msg.debug("%s", hdr); diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index 7414a553a74..1458aee412f 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -23,6 +23,7 @@ */ #include "cds/aotClassLocation.hpp" +#include "cds/aotLogging.hpp" #include "cds/archiveBuilder.hpp" #include "cds/archiveHeapLoader.inline.hpp" #include "cds/archiveHeapWriter.hpp" @@ -336,13 +337,13 @@ bool FileMapInfo::validate_class_location() { // the runtime image and the -cp, dynamic dumping is disabled. if (config->num_boot_classpaths() > 0) { CDSConfig::disable_dumping_dynamic_archive(); - log_warning(cds)( + aot_log_warning(aot)( "Dynamic archiving is disabled because base layer archive has appended boot classpath"); } if (config->num_module_paths() > 0) { if (has_extra_module_paths) { CDSConfig::disable_dumping_dynamic_archive(); - log_warning(cds)( + aot_log_warning(aot)( "Dynamic archiving is disabled because base layer archive has a different module path"); } } @@ -397,7 +398,7 @@ public: assert(_archive_name != nullptr, "Archive name is null"); _fd = os::open(_archive_name, O_RDONLY | O_BINARY, 0); if (_fd < 0) { - log_info(cds)("Specified %s not found (%s)", CDSConfig::type_of_archive_being_loaded(), _archive_name); + aot_log_info(aot)("Specified %s not found (%s)", CDSConfig::type_of_archive_being_loaded(), _archive_name); return false; } return initialize(_fd); @@ -414,31 +415,31 @@ public: os::lseek(fd, 0, SEEK_SET); size_t n = ::read(fd, (void*)&gen_header, (unsigned int)size); if (n != size) { - log_warning(cds)("Unable to read generic CDS file map header from %s", file_type); + aot_log_warning(aot)("Unable to read generic CDS file map header from %s", file_type); return false; } if (gen_header._magic != CDS_ARCHIVE_MAGIC && gen_header._magic != CDS_DYNAMIC_ARCHIVE_MAGIC && gen_header._magic != CDS_PREIMAGE_ARCHIVE_MAGIC) { - log_warning(cds)("The %s has a bad magic number: %#x", file_type, gen_header._magic); + aot_log_warning(aot)("The %s has a bad magic number: %#x", file_type, gen_header._magic); return false; } if (gen_header._version < CDS_GENERIC_HEADER_SUPPORTED_MIN_VERSION) { - log_warning(cds)("Cannot handle %s version 0x%x. Must be at least 0x%x.", + aot_log_warning(aot)("Cannot handle %s version 0x%x. Must be at least 0x%x.", file_type, gen_header._version, CDS_GENERIC_HEADER_SUPPORTED_MIN_VERSION); return false; } if (gen_header._version != CURRENT_CDS_ARCHIVE_VERSION) { - log_warning(cds)("The %s version 0x%x does not match the required version 0x%x.", + aot_log_warning(aot)("The %s version 0x%x does not match the required version 0x%x.", file_type, gen_header._version, CURRENT_CDS_ARCHIVE_VERSION); } size_t filelen = os::lseek(fd, 0, SEEK_END); if (gen_header._header_size >= filelen) { - log_warning(cds)("Archive file header larger than archive file"); + aot_log_warning(aot)("Archive file header larger than archive file"); return false; } @@ -448,7 +449,7 @@ public: os::lseek(fd, 0, SEEK_SET); n = ::read(fd, (void*)_header, (unsigned int)size); if (n != size) { - log_warning(cds)("Unable to read file map header from %s", file_type); + aot_log_warning(aot)("Unable to read file map header from %s", file_type); return false; } @@ -493,9 +494,9 @@ public: FileMapHeader* header = (FileMapHeader*)_header; int actual_crc = header->compute_crc(); if (actual_crc != header->crc()) { - log_info(cds)("_crc expected: %d", header->crc()); - log_info(cds)(" actual: %d", actual_crc); - log_warning(cds)("Header checksum verification failed."); + aot_log_info(aot)("_crc expected: %d", header->crc()); + aot_log_info(aot)(" actual: %d", actual_crc); + aot_log_warning(aot)("Header checksum verification failed."); return false; } } @@ -508,18 +509,18 @@ public: unsigned int header_size = _header->_header_size; if (name_offset + name_size < name_offset) { - log_warning(cds)("base_archive_name offset/size overflow: " UINT32_FORMAT "/" UINT32_FORMAT, + aot_log_warning(aot)("base_archive_name offset/size overflow: " UINT32_FORMAT "/" UINT32_FORMAT, name_offset, name_size); return false; } if (is_static_archive() || is_preimage_static_archive()) { if (name_offset != 0) { - log_warning(cds)("static shared archive must have zero _base_archive_name_offset"); + aot_log_warning(aot)("static shared archive must have zero _base_archive_name_offset"); return false; } if (name_size != 0) { - log_warning(cds)("static shared archive must have zero _base_archive_name_size"); + aot_log_warning(aot)("static shared archive must have zero _base_archive_name_size"); return false; } } else { @@ -527,24 +528,24 @@ public: if ((name_size == 0 && name_offset != 0) || (name_size != 0 && name_offset == 0)) { // If either is zero, both must be zero. This indicates that we are using the default base archive. - log_warning(cds)("Invalid base_archive_name offset/size: " UINT32_FORMAT "/" UINT32_FORMAT, + aot_log_warning(aot)("Invalid base_archive_name offset/size: " UINT32_FORMAT "/" UINT32_FORMAT, name_offset, name_size); return false; } if (name_size > 0) { if (name_offset + name_size > header_size) { - log_warning(cds)("Invalid base_archive_name offset/size (out of range): " + aot_log_warning(aot)("Invalid base_archive_name offset/size (out of range): " UINT32_FORMAT " + " UINT32_FORMAT " > " UINT32_FORMAT , name_offset, name_size, header_size); return false; } const char* name = ((const char*)_header) + _header->_base_archive_name_offset; if (name[name_size - 1] != '\0' || strlen(name) != name_size - 1) { - log_warning(cds)("Base archive name is damaged"); + aot_log_warning(aot)("Base archive name is damaged"); return false; } if (!os::file_exists(name)) { - log_warning(cds)("Base archive %s does not exist", name); + aot_log_warning(aot)("Base archive %s does not exist", name); return false; } _base_archive_name = name; @@ -579,7 +580,7 @@ bool FileMapInfo::get_base_archive_name_from_header(const char* archive_name, default: assert(header->_magic == CDS_ARCHIVE_MAGIC, "must be"); if (AutoCreateSharedArchive) { - log_warning(cds)("AutoCreateSharedArchive is ignored because %s is a static archive", archive_name); + aot_log_warning(aot)("AutoCreateSharedArchive is ignored because %s is a static archive", archive_name); } return true; } @@ -607,7 +608,7 @@ bool FileMapInfo::is_preimage_static_archive(const char* file) { bool FileMapInfo::init_from_file(int fd) { FileHeaderHelper file_helper(_full_path, _is_static); if (!file_helper.initialize(fd)) { - log_warning(cds)("Unable to read the file header."); + aot_log_warning(aot)("Unable to read the file header."); return false; } GenericCDSFileMapHeader* gen_header = file_helper.get_generic_file_header(); @@ -619,15 +620,15 @@ bool FileMapInfo::init_from_file(int fd) { // Good } else { if (CDSConfig::new_aot_flags_used()) { - log_warning(cds)("Not a valid %s (%s)", file_type, _full_path); + aot_log_warning(aot)("Not a valid %s (%s)", file_type, _full_path); } else { - log_warning(cds)("Not a base shared archive: %s", _full_path); + aot_log_warning(aot)("Not a base shared archive: %s", _full_path); } return false; } } else { if (gen_header->_magic != CDS_DYNAMIC_ARCHIVE_MAGIC) { - log_warning(cds)("Not a top shared archive: %s", _full_path); + aot_log_warning(aot)("Not a top shared archive: %s", _full_path); return false; } } @@ -637,14 +638,14 @@ bool FileMapInfo::init_from_file(int fd) { size_t size = gen_header->_header_size; size_t n = ::read(fd, (void*)_header, (unsigned int)size); if (n != size) { - log_warning(cds)("Failed to read file header from the top archive file\n"); + aot_log_warning(aot)("Failed to read file header from the top archive file\n"); return false; } if (header()->version() != CURRENT_CDS_ARCHIVE_VERSION) { - log_info(cds)("_version expected: 0x%x", CURRENT_CDS_ARCHIVE_VERSION); - log_info(cds)(" actual: 0x%x", header()->version()); - log_warning(cds)("The %s has the wrong version.", file_type); + aot_log_info(aot)("_version expected: 0x%x", CURRENT_CDS_ARCHIVE_VERSION); + aot_log_info(aot)(" actual: 0x%x", header()->version()); + aot_log_warning(aot)("The %s has the wrong version.", file_type); return false; } @@ -653,10 +654,10 @@ bool FileMapInfo::init_from_file(int fd) { unsigned int header_size = header()->header_size(); if (base_offset != 0 && name_size != 0) { if (header_size != base_offset + name_size) { - log_info(cds)("_header_size: " UINT32_FORMAT, header_size); - log_info(cds)("base_archive_name_size: " UINT32_FORMAT, header()->base_archive_name_size()); - log_info(cds)("base_archive_name_offset: " UINT32_FORMAT, header()->base_archive_name_offset()); - log_warning(cds)("The %s has an incorrect header size.", file_type); + aot_log_info(aot)("_header_size: " UINT32_FORMAT, header_size); + aot_log_info(aot)("base_archive_name_size: " UINT32_FORMAT, header()->base_archive_name_size()); + aot_log_info(aot)("base_archive_name_offset: " UINT32_FORMAT, header()->base_archive_name_offset()); + aot_log_warning(aot)("The %s has an incorrect header size.", file_type); return false; } } @@ -664,16 +665,16 @@ bool FileMapInfo::init_from_file(int fd) { const char* actual_ident = header()->jvm_ident(); if (actual_ident[JVM_IDENT_MAX-1] != 0) { - log_warning(cds)("JVM version identifier is corrupted."); + aot_log_warning(aot)("JVM version identifier is corrupted."); return false; } char expected_ident[JVM_IDENT_MAX]; get_header_version(expected_ident); if (strncmp(actual_ident, expected_ident, JVM_IDENT_MAX-1) != 0) { - log_info(cds)("_jvm_ident expected: %s", expected_ident); - log_info(cds)(" actual: %s", actual_ident); - log_warning(cds)("The %s was created by a different" + aot_log_info(aot)("_jvm_ident expected: %s", expected_ident); + aot_log_info(aot)(" actual: %s", actual_ident); + aot_log_warning(aot)("The %s was created by a different" " version or build of HotSpot", file_type); return false; } @@ -685,7 +686,7 @@ bool FileMapInfo::init_from_file(int fd) { for (int i = 0; i < MetaspaceShared::n_regions; i++) { FileMapRegion* r = region_at(i); if (r->file_offset() > len || len - r->file_offset() < r->used()) { - log_warning(cds)("The %s has been truncated.", file_type); + aot_log_warning(aot)("The %s has been truncated.", file_type); return false; } } @@ -695,7 +696,7 @@ bool FileMapInfo::init_from_file(int fd) { void FileMapInfo::seek_to_position(size_t pos) { if (os::lseek(_fd, (long)pos, SEEK_SET) < 0) { - log_error(cds)("Unable to seek to position %zu", pos); + aot_log_error(aot)("Unable to seek to position %zu", pos); MetaspaceShared::unrecoverable_loading_error(); } } @@ -708,18 +709,18 @@ bool FileMapInfo::open_for_read() { const char* file_type = CDSConfig::type_of_archive_being_loaded(); const char* info = CDSConfig::is_dumping_final_static_archive() ? "AOTConfiguration file " : ""; - log_info(cds)("trying to map %s%s", info, _full_path); + aot_log_info(aot)("trying to map %s%s", info, _full_path); int fd = os::open(_full_path, O_RDONLY | O_BINARY, 0); if (fd < 0) { if (errno == ENOENT) { - log_info(cds)("Specified %s not found (%s)", file_type, _full_path); + aot_log_info(aot)("Specified %s not found (%s)", file_type, _full_path); } else { - log_warning(cds)("Failed to open %s (%s)", file_type, + aot_log_warning(aot)("Failed to open %s (%s)", file_type, os::strerror(errno)); } return false; } else { - log_info(cds)("Opened %s %s.", file_type, _full_path); + aot_log_info(aot)("Opened %s %s.", file_type, _full_path); } _fd = fd; @@ -730,14 +731,14 @@ bool FileMapInfo::open_for_read() { // Write the FileMapInfo information to the file. void FileMapInfo::open_as_output() { - LogMessage(cds) msg; - if (msg.is_info()) { + if (CDSConfig::new_aot_flags_used()) { if (CDSConfig::is_dumping_preimage_static_archive()) { - msg.info("Writing binary AOTConfiguration file: "); + log_info(aot)("Writing binary AOTConfiguration file: %s", _full_path); } else { - msg.info("Dumping shared data to file: "); + log_info(aot)("Writing binary AOTConfiguration file: %s", _full_path); } - msg.info(" %s", _full_path); + } else { + log_info(cds)("Dumping shared data to file: %s", _full_path); } #ifdef _WINDOWS // On Windows, need WRITE permission to remove the file. @@ -749,7 +750,7 @@ void FileMapInfo::open_as_output() { remove(_full_path); int fd = os::open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0666); if (fd < 0) { - log_error(cds)("Unable to create %s %s: (%s).", CDSConfig::type_of_archive_being_written(), _full_path, + aot_log_error(aot)("Unable to create %s %s: (%s).", CDSConfig::type_of_archive_being_written(), _full_path, os::strerror(errno)); MetaspaceShared::writing_error(); return; @@ -815,7 +816,7 @@ bool FileMapRegion::check_region_crc(char* base) const { assert(base != nullptr, "must be initialized"); int crc = ClassLoader::crc32(0, base, (jint)sz); if (crc != this->crc()) { - log_warning(cds)("Checksum verification failed."); + aot_log_warning(aot)("Checksum verification failed."); return false; } return true; @@ -837,7 +838,7 @@ BitMapView FileMapInfo::bitmap_view(int region_index, bool is_oopmap) { bitmap_base += is_oopmap ? r->oopmap_offset() : r->ptrmap_offset(); size_t size_in_bits = is_oopmap ? r->oopmap_size_in_bits() : r->ptrmap_size_in_bits(); - log_debug(cds, reloc)("mapped %s relocation %smap @ " INTPTR_FORMAT " (%zu bits)", + aot_log_debug(aot, reloc)("mapped %s relocation %smap @ " INTPTR_FORMAT " (%zu bits)", region_name(region_index), is_oopmap ? "oop" : "ptr", p2i(bitmap_base), size_in_bits); @@ -905,12 +906,12 @@ void FileMapInfo::write_region(int region, char* base, size_t size, r->set_file_offset(_file_offset); int crc = ClassLoader::crc32(0, base, (jint)size); if (size > 0) { - log_info(cds)("Shared file region (%s) %d: %8zu" + aot_log_info(aot)("Shared file region (%s) %d: %8zu" " bytes, addr " INTPTR_FORMAT " file offset 0x%08" PRIxPTR " crc 0x%08x", region_name(region), region, size, p2i(requested_base), _file_offset, crc); } else { - log_info(cds)("Shared file region (%s) %d: %8zu" + aot_log_info(aot)("Shared file region (%s) %d: %8zu" " bytes", region_name(region), region, size); } @@ -1101,11 +1102,11 @@ bool FileMapInfo::remap_shared_readonly_as_readwrite() { close(); // These have to be errors because the shared region is now unmapped. if (base == nullptr) { - log_error(cds)("Unable to remap shared readonly space (errno=%d).", errno); + aot_log_error(aot)("Unable to remap shared readonly space (errno=%d).", errno); vm_exit(1); } if (base != addr) { - log_error(cds)("Unable to remap shared readonly space (errno=%d).", errno); + aot_log_error(aot)("Unable to remap shared readonly space (errno=%d).", errno); vm_exit(1); } r->set_read_only(false); @@ -1136,7 +1137,7 @@ MapArchiveResult FileMapInfo::map_regions(int regions[], int num_regions, char* assert(r->mapped_base() == last_region->mapped_end(), "must have no gaps"); } last_region = r;) - log_info(cds)("Mapped %s region #%d at base " INTPTR_FORMAT " top " INTPTR_FORMAT " (%s)", is_static() ? "static " : "dynamic", + aot_log_info(aot)("Mapped %s region #%d at base " INTPTR_FORMAT " top " INTPTR_FORMAT " (%s)", is_static() ? "static " : "dynamic", idx, p2i(r->mapped_base()), p2i(r->mapped_end()), shared_region_name[idx]); @@ -1153,11 +1154,11 @@ MapArchiveResult FileMapInfo::map_regions(int regions[], int num_regions, char* bool FileMapInfo::read_region(int i, char* base, size_t size, bool do_commit) { FileMapRegion* r = region_at(i); if (do_commit) { - log_info(cds)("Commit %s region #%d at base " INTPTR_FORMAT " top " INTPTR_FORMAT " (%s)%s", + aot_log_info(aot)("Commit %s region #%d at base " INTPTR_FORMAT " top " INTPTR_FORMAT " (%s)%s", is_static() ? "static " : "dynamic", i, p2i(base), p2i(base + size), shared_region_name[i], r->allow_exec() ? " exec" : ""); if (!os::commit_memory(base, size, r->allow_exec())) { - log_error(cds)("Failed to commit %s region #%d (%s)", is_static() ? "static " : "dynamic", + aot_log_error(aot)("Failed to commit %s region #%d (%s)", is_static() ? "static " : "dynamic", i, shared_region_name[i]); return false; } @@ -1206,7 +1207,7 @@ MapArchiveResult FileMapInfo::map_region(int i, intx addr_delta, char* mapped_ba // can't mmap into a ReservedSpace, so we just ::read() the data. We're going to patch all the // regions anyway, so there's no benefit for mmap anyway. if (!read_region(i, requested_addr, size, /* do_commit = */ true)) { - log_info(cds)("Failed to read %s shared space into reserved space at " INTPTR_FORMAT, + aot_log_info(aot)("Failed to read %s shared space into reserved space at " INTPTR_FORMAT, shared_region_name[i], p2i(requested_addr)); return MAP_ARCHIVE_OTHER_FAILURE; // oom or I/O error. } else { @@ -1220,7 +1221,7 @@ MapArchiveResult FileMapInfo::map_region(int i, intx addr_delta, char* mapped_ba requested_addr, size, r->read_only(), r->allow_exec(), mtClassShared); if (base != requested_addr) { - log_info(cds)("Unable to map %s shared space at " INTPTR_FORMAT, + aot_log_info(aot)("Unable to map %s shared space at " INTPTR_FORMAT, shared_region_name[i], p2i(requested_addr)); _memory_mapping_failed = true; return MAP_ARCHIVE_MMAP_FAILURE; @@ -1260,7 +1261,7 @@ char* FileMapInfo::map_bitmap_region() { } if (VerifySharedSpaces && !r->check_region_crc(bitmap_base)) { - log_error(cds)("relocation bitmap CRC error"); + aot_log_error(aot)("relocation bitmap CRC error"); if (!os::unmap_memory(bitmap_base, r->used_aligned())) { fatal("os::unmap_memory of relocation bitmap failed"); } @@ -1269,7 +1270,7 @@ char* FileMapInfo::map_bitmap_region() { r->set_mapped_from_file(true); r->set_mapped_base(bitmap_base); - log_info(cds)("Mapped %s region #%d at base " INTPTR_FORMAT " top " INTPTR_FORMAT " (%s)", + aot_log_info(aot)("Mapped %s region #%d at base " INTPTR_FORMAT " top " INTPTR_FORMAT " (%s)", is_static() ? "static " : "dynamic", MetaspaceShared::bm, p2i(r->mapped_base()), p2i(r->mapped_end()), shared_region_name[MetaspaceShared::bm]); @@ -1286,7 +1287,7 @@ bool FileMapInfo::map_aot_code_region(ReservedSpace rs) { char* mapped_base; if (MetaspaceShared::use_windows_memory_mapping()) { if (!read_region(MetaspaceShared::ac, requested_base, r->used_aligned(), /* do_commit = */ true)) { - log_info(cds)("Failed to read aot code shared space into reserved space at " INTPTR_FORMAT, + aot_log_info(aot)("Failed to read aot code shared space into reserved space at " INTPTR_FORMAT, p2i(requested_base)); return false; } @@ -1299,13 +1300,13 @@ bool FileMapInfo::map_aot_code_region(ReservedSpace rs) { requested_base, r->used_aligned(), read_only, allow_exec, mtClassShared); } if (mapped_base == nullptr) { - log_info(cds)("failed to map aot code region"); + aot_log_info(aot)("failed to map aot code region"); return false; } else { assert(mapped_base == requested_base, "must be"); r->set_mapped_from_file(true); r->set_mapped_base(mapped_base); - log_info(cds)("Mapped static region #%d at base " INTPTR_FORMAT " top " INTPTR_FORMAT " (%s)", + aot_log_info(aot)("Mapped static region #%d at base " INTPTR_FORMAT " top " INTPTR_FORMAT " (%s)", MetaspaceShared::ac, p2i(r->mapped_base()), p2i(r->mapped_end()), shared_region_name[MetaspaceShared::ac]); return true; @@ -1341,7 +1342,7 @@ public: // This is called when we cannot map the archive at the requested[ base address (usually 0x800000000). // We relocate all pointers in the 2 core regions (ro, rw). bool FileMapInfo::relocate_pointers_in_core_regions(intx addr_delta) { - log_debug(cds, reloc)("runtime archive relocation start"); + aot_log_debug(aot, reloc)("runtime archive relocation start"); char* bitmap_base = map_bitmap_region(); if (bitmap_base == nullptr) { @@ -1388,7 +1389,7 @@ bool FileMapInfo::relocate_pointers_in_core_regions(intx addr_delta) { // The MetaspaceShared::bm region will be unmapped in MetaspaceShared::initialize_shared_spaces(). - log_debug(cds, reloc)("runtime archive relocation done"); + aot_log_debug(aot, reloc)("runtime archive relocation done"); return true; } } @@ -1437,7 +1438,7 @@ MemRegion FileMapInfo::get_heap_region_requested_range() { address start = heap_region_requested_address(); address end = start + size; - log_info(cds)("Requested heap region [" INTPTR_FORMAT " - " INTPTR_FORMAT "] = %8zu bytes", + aot_log_info(aot)("Requested heap region [" INTPTR_FORMAT " - " INTPTR_FORMAT "] = %8zu bytes", p2i(start), p2i(end), size); return MemRegion((HeapWord*)start, (HeapWord*)end); @@ -1467,7 +1468,7 @@ void FileMapInfo::map_or_load_heap_region() { // all AOT-linked classes are visible. // // We get here because the heap is too small. The app will fail anyway. So let's quit. - log_error(cds)("%s has aot-linked classes but the archived " + aot_log_error(aot)("%s has aot-linked classes but the archived " "heap objects cannot be loaded. Try increasing your heap size.", CDSConfig::type_of_archive_being_loaded()); MetaspaceShared::unrecoverable_loading_error(); @@ -1501,19 +1502,19 @@ bool FileMapInfo::can_use_heap_region() { const int archive_narrow_klass_pointer_bits = header()->narrow_klass_pointer_bits(); const int archive_narrow_klass_shift = header()->narrow_klass_shift(); - log_info(cds)("CDS archive was created with max heap size = %zuM, and the following configuration:", + aot_log_info(aot)("CDS archive was created with max heap size = %zuM, and the following configuration:", max_heap_size()/M); - log_info(cds)(" narrow_klass_base at mapping start address, narrow_klass_pointer_bits = %d, narrow_klass_shift = %d", + aot_log_info(aot)(" narrow_klass_base at mapping start address, narrow_klass_pointer_bits = %d, narrow_klass_shift = %d", archive_narrow_klass_pointer_bits, archive_narrow_klass_shift); - log_info(cds)(" narrow_oop_mode = %d, narrow_oop_base = " PTR_FORMAT ", narrow_oop_shift = %d", + aot_log_info(aot)(" narrow_oop_mode = %d, narrow_oop_base = " PTR_FORMAT ", narrow_oop_shift = %d", narrow_oop_mode(), p2i(narrow_oop_base()), narrow_oop_shift()); - log_info(cds)("The current max heap size = %zuM, G1HeapRegion::GrainBytes = %zu", + aot_log_info(aot)("The current max heap size = %zuM, G1HeapRegion::GrainBytes = %zu", MaxHeapSize/M, G1HeapRegion::GrainBytes); - log_info(cds)(" narrow_klass_base = " PTR_FORMAT ", arrow_klass_pointer_bits = %d, narrow_klass_shift = %d", + aot_log_info(aot)(" narrow_klass_base = " PTR_FORMAT ", arrow_klass_pointer_bits = %d, narrow_klass_shift = %d", p2i(CompressedKlassPointers::base()), CompressedKlassPointers::narrow_klass_pointer_bits(), CompressedKlassPointers::shift()); - log_info(cds)(" narrow_oop_mode = %d, narrow_oop_base = " PTR_FORMAT ", narrow_oop_shift = %d", + aot_log_info(aot)(" narrow_oop_mode = %d, narrow_oop_base = " PTR_FORMAT ", narrow_oop_shift = %d", CompressedOops::mode(), p2i(CompressedOops::base()), CompressedOops::shift()); - log_info(cds)(" heap range = [" PTR_FORMAT " - " PTR_FORMAT "]", + aot_log_info(aot)(" heap range = [" PTR_FORMAT " - " PTR_FORMAT "]", UseCompressedOops ? p2i(CompressedOops::begin()) : UseG1GC ? p2i((address)G1CollectedHeap::heap()->reserved().start()) : 0L, UseCompressedOops ? p2i(CompressedOops::end()) : @@ -1631,7 +1632,7 @@ bool FileMapInfo::map_heap_region_impl() { size_t word_size = size / HeapWordSize; address requested_start = heap_region_requested_address(); - log_info(cds)("Preferred address to map heap data (to avoid relocation) is " INTPTR_FORMAT, p2i(requested_start)); + aot_log_info(aot)("Preferred address to map heap data (to avoid relocation) is " INTPTR_FORMAT, p2i(requested_start)); // allocate from java heap HeapWord* start = G1CollectedHeap::heap()->alloc_archive_region(word_size, (HeapWord*)requested_start); @@ -1652,7 +1653,7 @@ bool FileMapInfo::map_heap_region_impl() { align_up(_mapped_heap_memregion.byte_size(), os::vm_page_size()), /* do_commit = */ true)) { dealloc_heap_region(); - log_error(cds)("Failed to read archived heap region into " INTPTR_FORMAT, p2i(addr)); + aot_log_error(aot)("Failed to read archived heap region into " INTPTR_FORMAT, p2i(addr)); return false; } // Checks for VerifySharedSpaces is already done inside read_region() @@ -1663,7 +1664,7 @@ bool FileMapInfo::map_heap_region_impl() { r->allow_exec(), mtJavaHeap); if (base == nullptr || base != addr) { dealloc_heap_region(); - log_info(cds)("UseSharedSpaces: Unable to map at required address in java heap. " + aot_log_info(aot)("UseSharedSpaces: Unable to map at required address in java heap. " INTPTR_FORMAT ", size = %zu bytes", p2i(addr), _mapped_heap_memregion.byte_size()); return false; @@ -1701,9 +1702,9 @@ bool FileMapInfo::map_heap_region_impl() { return false; } } - log_info(cds)("Heap data mapped at " INTPTR_FORMAT ", size = %8zu bytes", + aot_log_info(aot)("Heap data mapped at " INTPTR_FORMAT ", size = %8zu bytes", p2i(mapped_start), _mapped_heap_memregion.byte_size()); - log_info(cds)("CDS heap data relocation delta = %zd bytes", delta); + aot_log_info(aot)("CDS heap data relocation delta = %zd bytes", delta); return true; } @@ -1763,12 +1764,12 @@ void FileMapInfo::unmap_region(int i) { if (mapped_base != nullptr) { if (size > 0 && r->mapped_from_file()) { - log_info(cds)("Unmapping region #%d at base " INTPTR_FORMAT " (%s)", i, p2i(mapped_base), + aot_log_info(aot)("Unmapping region #%d at base " INTPTR_FORMAT " (%s)", i, p2i(mapped_base), shared_region_name[i]); if (r->in_reserved_space()) { // This region was mapped inside a ReservedSpace. Its memory will be freed when the ReservedSpace // is released. Zero it so that we don't accidentally read its content. - log_info(cds)("Region #%d (%s) is in a reserved space, it will be freed when the space is released", i, shared_region_name[i]); + aot_log_info(aot)("Region #%d (%s) is in a reserved space, it will be freed when the space is released", i, shared_region_name[i]); } else { if (!os::unmap_memory(mapped_base, size)) { fatal("os::unmap_memory failed"); @@ -1835,31 +1836,31 @@ bool FileMapInfo::validate_aot_class_linking() { const char* archive_type = CDSConfig::type_of_archive_being_loaded(); CDSConfig::set_has_aot_linked_classes(true); if (JvmtiExport::should_post_class_file_load_hook()) { - log_error(cds)("%s has aot-linked classes. It cannot be used when JVMTI ClassFileLoadHook is in use.", + aot_log_error(aot)("%s has aot-linked classes. It cannot be used when JVMTI ClassFileLoadHook is in use.", archive_type); return false; } if (JvmtiExport::has_early_vmstart_env()) { - log_error(cds)("%s has aot-linked classes. It cannot be used when JVMTI early vm start is in use.", + aot_log_error(aot)("%s has aot-linked classes. It cannot be used when JVMTI early vm start is in use.", archive_type); return false; } if (!CDSConfig::is_using_full_module_graph()) { - log_error(cds)("%s has aot-linked classes. It cannot be used when archived full module graph is not used.", + aot_log_error(aot)("%s has aot-linked classes. It cannot be used when archived full module graph is not used.", archive_type); return false; } const char* prop = Arguments::get_property("java.security.manager"); if (prop != nullptr && strcmp(prop, "disallow") != 0) { - log_error(cds)("%s has aot-linked classes. It cannot be used with -Djava.security.manager=%s.", + aot_log_error(aot)("%s has aot-linked classes. It cannot be used with -Djava.security.manager=%s.", archive_type, prop); return false; } #if INCLUDE_JVMTI if (Arguments::has_jdwp_agent()) { - log_error(cds)("%s has aot-linked classes. It cannot be used with JDWP agent", archive_type); + aot_log_error(aot)("%s has aot-linked classes. It cannot be used with JDWP agent", archive_type); return false; } #endif @@ -1901,13 +1902,13 @@ int FileMapHeader::compute_crc() { bool FileMapHeader::validate() { const char* file_type = CDSConfig::type_of_archive_being_loaded(); if (_obj_alignment != ObjectAlignmentInBytes) { - log_info(cds)("The %s's ObjectAlignmentInBytes of %d" + aot_log_info(aot)("The %s's ObjectAlignmentInBytes of %d" " does not equal the current ObjectAlignmentInBytes of %d.", file_type, _obj_alignment, ObjectAlignmentInBytes); return false; } if (_compact_strings != CompactStrings) { - log_info(cds)("The %s's CompactStrings setting (%s)" + aot_log_info(aot)("The %s's CompactStrings setting (%s)" " does not equal the current CompactStrings setting (%s).", file_type, _compact_strings ? "enabled" : "disabled", CompactStrings ? "enabled" : "disabled"); @@ -1919,11 +1920,11 @@ bool FileMapHeader::validate() { const char* prop = Arguments::get_property("java.system.class.loader"); if (prop != nullptr) { if (has_aot_linked_classes()) { - log_error(cds)("%s has aot-linked classes. It cannot be used when the " + aot_log_error(aot)("%s has aot-linked classes. It cannot be used when the " "java.system.class.loader property is specified.", CDSConfig::type_of_archive_being_loaded()); return false; } - log_warning(cds)("Archived non-system classes are disabled because the " + aot_log_warning(aot)("Archived non-system classes are disabled because the " "java.system.class.loader property is specified (value = \"%s\"). " "To use archived non-system classes, this property must not be set", prop); _has_platform_or_app_classes = false; @@ -1932,7 +1933,7 @@ bool FileMapHeader::validate() { if (!_verify_local && BytecodeVerificationLocal) { // we cannot load boot classes, so there's no point of using the CDS archive - log_info(cds)("The %s's BytecodeVerificationLocal setting (%s)" + aot_log_info(aot)("The %s's BytecodeVerificationLocal setting (%s)" " does not equal the current BytecodeVerificationLocal setting (%s).", file_type, _verify_local ? "enabled" : "disabled", BytecodeVerificationLocal ? "enabled" : "disabled"); @@ -1944,7 +1945,7 @@ bool FileMapHeader::validate() { if (_has_platform_or_app_classes && !_verify_remote // we didn't verify the archived platform/app classes && BytecodeVerificationRemote) { // but we want to verify all loaded platform/app classes - log_info(cds)("The %s was created with less restrictive " + aot_log_info(aot)("The %s was created with less restrictive " "verification setting than the current setting.", file_type); // Pretend that we didn't have any archived platform/app classes, so they won't be loaded // by SystemDictionaryShared. @@ -1956,26 +1957,26 @@ bool FileMapHeader::validate() { // Note: _allow_archiving_with_java_agent is set in the shared archive during dump time // while AllowArchivingWithJavaAgent is set during the current run. if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) { - log_warning(cds)("The setting of the AllowArchivingWithJavaAgent is different " + aot_log_warning(aot)("The setting of the AllowArchivingWithJavaAgent is different " "from the setting in the %s.", file_type); return false; } if (_allow_archiving_with_java_agent) { - log_warning(cds)("This %s was created with AllowArchivingWithJavaAgent. It should be used " + aot_log_warning(aot)("This %s was created with AllowArchivingWithJavaAgent. It should be used " "for testing purposes only and should not be used in a production environment", file_type); } - log_info(cds)("The %s was created with UseCompressedOops = %d, UseCompressedClassPointers = %d, UseCompactObjectHeaders = %d", + aot_log_info(aot)("The %s was created with UseCompressedOops = %d, UseCompressedClassPointers = %d, UseCompactObjectHeaders = %d", file_type, compressed_oops(), compressed_class_pointers(), compact_headers()); if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) { - log_warning(cds)("Unable to use %s.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is " + aot_log_warning(aot)("Unable to use %s.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is " "different from runtime, CDS will be disabled.", file_type); return false; } if (compact_headers() != UseCompactObjectHeaders) { - log_warning(cds)("Unable to use %s.\nThe %s's UseCompactObjectHeaders setting (%s)" + aot_log_warning(aot)("Unable to use %s.\nThe %s's UseCompactObjectHeaders setting (%s)" " does not equal the current UseCompactObjectHeaders setting (%s).", file_type, file_type, _compact_headers ? "enabled" : "disabled", UseCompactObjectHeaders ? "enabled" : "disabled"); @@ -1984,7 +1985,7 @@ bool FileMapHeader::validate() { if (!_use_optimized_module_handling && !CDSConfig::is_dumping_final_static_archive()) { CDSConfig::stop_using_optimized_module_handling(); - log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling"); + aot_log_info(aot)("optimized module handling: disabled because archive was created without optimized module handling"); } if (is_static()) { @@ -2072,7 +2073,7 @@ ClassFileStream* FileMapInfo::open_stream_for_jvmti(InstanceKlass* ik, Handle cl cfs = cpe->open_stream_for_loader(THREAD, file_name, loader_data); } assert(cfs != nullptr, "must be able to read the classfile data of shared classes for built-in loaders."); - log_debug(cds, jvmti)("classfile data for %s [%d: %s] = %d bytes", class_name, path_index, + log_debug(aot, jvmti)("classfile data for %s [%d: %s] = %d bytes", class_name, path_index, cfs->source(), cfs->length()); return cfs; } diff --git a/src/hotspot/share/cds/finalImageRecipes.cpp b/src/hotspot/share/cds/finalImageRecipes.cpp index f0ce8ceb020..a19adda87fa 100644 --- a/src/hotspot/share/cds/finalImageRecipes.cpp +++ b/src/hotspot/share/cds/finalImageRecipes.cpp @@ -181,9 +181,9 @@ void FinalImageRecipes::load_all_classes(TRAPS) { Klass* actual = SystemDictionary::resolve_or_fail(ik->name(), class_loader, true, CHECK); if (actual != ik) { ResourceMark rm(THREAD); - log_error(cds)("Unable to resolve class from CDS archive: %s", ik->external_name()); - log_error(cds)("Expected: " INTPTR_FORMAT ", actual: " INTPTR_FORMAT, p2i(ik), p2i(actual)); - log_error(cds)("Please check if your VM command-line is the same as in the training run"); + log_error(aot)("Unable to resolve class from CDS archive: %s", ik->external_name()); + log_error(aot)("Expected: " INTPTR_FORMAT ", actual: " INTPTR_FORMAT, p2i(ik), p2i(actual)); + log_error(aot)("Please check if your VM command-line is the same as in the training run"); MetaspaceShared::unrecoverable_writing_error(); } assert(ik->is_loaded(), "must be"); @@ -205,9 +205,9 @@ void FinalImageRecipes::apply_recipes(TRAPS) { if (_final_image_recipes != nullptr) { _final_image_recipes->apply_recipes_impl(THREAD); if (HAS_PENDING_EXCEPTION) { - log_error(cds)("%s: %s", PENDING_EXCEPTION->klass()->external_name(), + log_error(aot)("%s: %s", PENDING_EXCEPTION->klass()->external_name(), java_lang_String::as_utf8_string(java_lang_Throwable::message(PENDING_EXCEPTION))); - log_error(cds)("Please check if your VM command-line is the same as in the training run"); + log_error(aot)("Please check if your VM command-line is the same as in the training run"); MetaspaceShared::unrecoverable_writing_error("Unexpected exception, use -Xlog:cds,exceptions=trace for detail"); } } diff --git a/src/hotspot/share/cds/heapShared.cpp b/src/hotspot/share/cds/heapShared.cpp index 32b4e9e13ed..1bc86248d42 100644 --- a/src/hotspot/share/cds/heapShared.cpp +++ b/src/hotspot/share/cds/heapShared.cpp @@ -25,6 +25,7 @@ #include "cds/aotArtifactFinder.hpp" #include "cds/aotClassInitializer.hpp" #include "cds/aotClassLocation.hpp" +#include "cds/aotLogging.hpp" #include "cds/aotReferenceObjSupport.hpp" #include "cds/archiveBuilder.hpp" #include "cds/archiveHeapLoader.hpp" @@ -174,9 +175,9 @@ static void reset_states(oop obj, TRAPS) { Method* method = klass->find_method(method_name, method_sig); if (method != nullptr) { assert(method->is_private(), "must be"); - if (log_is_enabled(Debug, cds)) { + if (log_is_enabled(Debug, aot)) { ResourceMark rm(THREAD); - log_debug(cds)(" calling %s", method->name_and_sig_as_C_string()); + log_debug(aot)(" calling %s", method->name_and_sig_as_C_string()); } JavaValue result(T_VOID); JavaCalls::call_special(&result, h_obj, klass, @@ -188,9 +189,9 @@ static void reset_states(oop obj, TRAPS) { void HeapShared::reset_archived_object_states(TRAPS) { assert(CDSConfig::is_dumping_heap(), "dump-time only"); - log_debug(cds)("Resetting platform loader"); + log_debug(aot)("Resetting platform loader"); reset_states(SystemDictionary::java_platform_loader(), CHECK); - log_debug(cds)("Resetting system loader"); + log_debug(aot)("Resetting system loader"); reset_states(SystemDictionary::java_system_loader(), CHECK); // Clean up jdk.internal.loader.ClassLoaders::bootLoader(), which is not @@ -200,7 +201,7 @@ void HeapShared::reset_archived_object_states(TRAPS) { // Note, this object is non-null, and is not the same as // ClassLoaderData::the_null_class_loader_data()->class_loader(), // which is null. - log_debug(cds)("Resetting boot loader"); + log_debug(aot)("Resetting boot loader"); JavaValue result(T_OBJECT); JavaCalls::call_static(&result, vmClasses::jdk_internal_loader_ClassLoaders_klass(), @@ -277,9 +278,9 @@ void HeapShared::clear_root(int index) { if (ArchiveHeapLoader::is_in_use()) { int seg_idx, int_idx; get_segment_indexes(index, seg_idx, int_idx); - if (log_is_enabled(Debug, cds, heap)) { + if (log_is_enabled(Debug, aot, heap)) { oop old = root_segment(seg_idx)->obj_at(int_idx); - log_debug(cds, heap)("Clearing root %d: was " PTR_FORMAT, index, p2i(old)); + log_debug(aot, heap)("Clearing root %d: was " PTR_FORMAT, index, p2i(old)); } root_segment(seg_idx)->obj_at_put(int_idx, nullptr); } @@ -294,7 +295,7 @@ bool HeapShared::archive_object(oop obj, oop referrer, KlassSubGraphInfo* subgra } if (ArchiveHeapWriter::is_too_large_to_archive(obj->size())) { - log_debug(cds, heap)("Cannot archive, object (" PTR_FORMAT ") is too large: %zu", + log_debug(aot, heap)("Cannot archive, object (" PTR_FORMAT ") is too large: %zu", p2i(obj), obj->size()); debug_trace(); return false; @@ -342,9 +343,9 @@ bool HeapShared::archive_object(oop obj, oop referrer, KlassSubGraphInfo* subgra } } - if (log_is_enabled(Debug, cds, heap)) { + if (log_is_enabled(Debug, aot, heap)) { ResourceMark rm; - LogTarget(Debug, cds, heap) log; + LogTarget(Debug, aot, heap) log; LogStream out(log); out.print("Archived heap object " PTR_FORMAT " : %s ", p2i(obj), obj->klass()->external_name()); @@ -569,9 +570,9 @@ void HeapShared::copy_and_rescan_aot_inited_mirror(InstanceKlass* ik) { assert(success, "sanity"); } - if (log_is_enabled(Debug, cds, init)) { + if (log_is_enabled(Debug, aot, init)) { ResourceMark rm; - log_debug(cds, init)("copied %3d field(s) in aot-initialized mirror %s%s%s", nfields, ik->external_name(), + log_debug(aot, init)("copied %3d field(s) in aot-initialized mirror %s%s%s", nfields, ik->external_name(), ik->is_hidden() ? " (hidden)" : "", ik->is_enum_subclass() ? " (enum)" : ""); } @@ -654,7 +655,7 @@ void HeapShared::start_scanning_for_oops() { create_archived_object_cache(); if (UseCompressedOops || UseG1GC) { - log_info(cds)("Heap range = [" PTR_FORMAT " - " PTR_FORMAT "]", + aot_log_info(aot)("Heap range = [" PTR_FORMAT " - " PTR_FORMAT "]", UseCompressedOops ? p2i(CompressedOops::begin()) : p2i((address)G1CollectedHeap::heap()->reserved().start()), UseCompressedOops ? p2i(CompressedOops::end()) : @@ -817,10 +818,10 @@ void KlassSubGraphInfo::add_subgraph_object_klass(Klass* orig_k) { return; } - if (log_is_enabled(Debug, cds, heap)) { + if (log_is_enabled(Debug, aot, heap)) { if (!_subgraph_object_klasses->contains(orig_k)) { ResourceMark rm; - log_debug(cds, heap)("Adding klass %s", orig_k->external_name()); + log_debug(aot, heap)("Adding klass %s", orig_k->external_name()); } } @@ -863,7 +864,7 @@ void KlassSubGraphInfo::check_allowed_klass(InstanceKlass* ik) { #endif ResourceMark rm; - log_error(cds, heap)("Class %s not allowed in archive heap. Must be in java.base%s%s", + log_error(aot, heap)("Class %s not allowed in archive heap. Must be in java.base%s%s", ik->external_name(), lambda_msg, testcls_msg); MetaspaceShared::unrecoverable_writing_error(); } @@ -875,7 +876,7 @@ bool KlassSubGraphInfo::is_non_early_klass(Klass* k) { if (k->is_instance_klass()) { if (!SystemDictionaryShared::is_early_klass(InstanceKlass::cast(k))) { ResourceMark rm; - log_info(cds, heap)("non-early: %s", k->external_name()); + log_info(aot, heap)("non-early: %s", k->external_name()); return true; } else { return false; @@ -903,7 +904,7 @@ void ArchivedKlassSubGraphInfoRecord::init(KlassSubGraphInfo* info) { if (_has_non_early_klasses) { ResourceMark rm; - log_info(cds, heap)( + log_info(aot, heap)( "Subgraph of klass %s has non-early klasses and cannot be used when JVMTI ClassFileLoadHook is enabled", _k->external_name()); } @@ -942,13 +943,13 @@ void ArchivedKlassSubGraphInfoRecord::init(KlassSubGraphInfo* info) { if (subgraph_k->has_aot_initialized_mirror()) { continue; } - if (log_is_enabled(Info, cds, heap)) { + if (log_is_enabled(Info, aot, heap)) { ResourceMark rm; const char* owner_name = is_special ? "" : _k->external_name(); if (subgraph_k->is_instance_klass()) { InstanceKlass* src_ik = InstanceKlass::cast(ArchiveBuilder::current()->get_source_addr(subgraph_k)); } - log_info(cds, heap)( + log_info(aot, heap)( "Archived object klass %s (%2d) => %s", owner_name, n, subgraph_k->external_name()); } @@ -1017,7 +1018,7 @@ void HeapShared::write_subgraph_info_table() { _archived_ArchiveHeapTestClass = array; } #endif - if (log_is_enabled(Info, cds, heap)) { + if (log_is_enabled(Info, aot, heap)) { print_stats(); } } @@ -1052,7 +1053,7 @@ void HeapShared::serialize_tables(SerializeClosure* soc) { static void verify_the_heap(Klass* k, const char* which) { if (VerifyArchivedFields > 0) { ResourceMark rm; - log_info(cds, heap)("Verify heap %s initializing static field(s) in %s", + log_info(aot, heap)("Verify heap %s initializing static field(s) in %s", which, k->external_name()); VM_Verify verify_op; @@ -1066,7 +1067,7 @@ static void verify_the_heap(Klass* k, const char* which) { // // -XX:VerifyArchivedFields=2 force a GC to happen in such an early stage // to check for GC safety. - log_info(cds, heap)("Trigger GC %s initializing static field(s) in %s", + log_info(aot, heap)("Trigger GC %s initializing static field(s) in %s", which, k->external_name()); FlagSetting fs1(VerifyBeforeGC, true); FlagSetting fs2(VerifyDuringGC, true); @@ -1185,7 +1186,7 @@ void HeapShared::initialize_from_archived_subgraph(JavaThread* current, Klass* k AOTClassLocationConfig::runtime()->num_module_paths() > 0) { // ArchivedModuleGraph was created with a --module-path that's different than the runtime --module-path. // Thus, it might contain references to modules that do not exist at runtime. We cannot use it. - log_info(cds, heap)("Skip initializing ArchivedModuleGraph subgraph: is_using_optimized_module_handling=%s num_module_paths=%d", + log_info(aot, heap)("Skip initializing ArchivedModuleGraph subgraph: is_using_optimized_module_handling=%s num_module_paths=%d", BOOL_TO_STR(CDSConfig::is_using_optimized_module_handling()), AOTClassLocationConfig::runtime()->num_module_paths()); return; @@ -1228,34 +1229,34 @@ HeapShared::resolve_or_init_classes_for_subgraph_of(Klass* k, bool do_init, TRAP // Initialize from archived data. Currently this is done only // during VM initialization time. No lock is needed. if (record == nullptr) { - if (log_is_enabled(Info, cds, heap)) { + if (log_is_enabled(Info, aot, heap)) { ResourceMark rm(THREAD); - log_info(cds, heap)("subgraph %s is not recorded", + log_info(aot, heap)("subgraph %s is not recorded", k->external_name()); } return nullptr; } else { if (record->is_full_module_graph() && !CDSConfig::is_using_full_module_graph()) { - if (log_is_enabled(Info, cds, heap)) { + if (log_is_enabled(Info, aot, heap)) { ResourceMark rm(THREAD); - log_info(cds, heap)("subgraph %s cannot be used because full module graph is disabled", + log_info(aot, heap)("subgraph %s cannot be used because full module graph is disabled", k->external_name()); } return nullptr; } if (record->has_non_early_klasses() && JvmtiExport::should_post_class_file_load_hook()) { - if (log_is_enabled(Info, cds, heap)) { + if (log_is_enabled(Info, aot, heap)) { ResourceMark rm(THREAD); - log_info(cds, heap)("subgraph %s cannot be used because JVMTI ClassFileLoadHook is enabled", + log_info(aot, heap)("subgraph %s cannot be used because JVMTI ClassFileLoadHook is enabled", k->external_name()); } return nullptr; } - if (log_is_enabled(Info, cds, heap)) { + if (log_is_enabled(Info, aot, heap)) { ResourceMark rm; - log_info(cds, heap)("%s subgraph %s ", do_init ? "init" : "resolve", k->external_name()); + log_info(aot, heap)("%s subgraph %s ", do_init ? "init" : "resolve", k->external_name()); } resolve_or_init(k, do_init, CHECK_NULL); @@ -1327,14 +1328,14 @@ void HeapShared::init_archived_fields_for(Klass* k, const ArchivedKlassSubGraphI } else { m->obj_field_put(field_offset, v); } - log_debug(cds, heap)(" " PTR_FORMAT " init field @ %2d = " PTR_FORMAT, p2i(k), field_offset, p2i(v)); + log_debug(aot, heap)(" " PTR_FORMAT " init field @ %2d = " PTR_FORMAT, p2i(k), field_offset, p2i(v)); } // Done. Java code can see the archived sub-graphs referenced from k's // mirror after this point. - if (log_is_enabled(Info, cds, heap)) { + if (log_is_enabled(Info, aot, heap)) { ResourceMark rm; - log_info(cds, heap)("initialize_from_archived_subgraph %s " PTR_FORMAT "%s%s", + log_info(aot, heap)("initialize_from_archived_subgraph %s " PTR_FORMAT "%s%s", k->external_name(), p2i(k), JvmtiExport::is_early_phase() ? " (early)" : "", k->has_aot_initialized_mirror() ? " (aot-inited)" : ""); } @@ -1406,13 +1407,13 @@ class HeapShared::OopFieldPusher: public BasicOopIterateClosure { return; } - if (!_record_klasses_only && log_is_enabled(Debug, cds, heap)) { + if (!_record_klasses_only && log_is_enabled(Debug, aot, heap)) { ResourceMark rm; - log_debug(cds, heap)("(%d) %s[%d] ==> " PTR_FORMAT " size %zu %s", _level, + log_debug(aot, heap)("(%d) %s[%d] ==> " PTR_FORMAT " size %zu %s", _level, _referencing_obj->klass()->external_name(), field_offset, p2i(obj), obj->size() * HeapWordSize, obj->klass()->external_name()); - if (log_is_enabled(Trace, cds, heap)) { - LogTarget(Trace, cds, heap) log; + if (log_is_enabled(Trace, aot, heap)) { + LogTarget(Trace, aot, heap) log; LogStream out(log); obj->print_on(&out); } @@ -1499,14 +1500,14 @@ bool HeapShared::walk_one_object(PendingOopStack* stack, int level, KlassSubGrap // If you get an error here, you probably made a change in the JDK library that has added // these objects that are referenced (directly or indirectly) by static fields. ResourceMark rm; - log_error(cds, heap)("Cannot archive object " PTR_FORMAT " of class %s", p2i(orig_obj), orig_obj->klass()->external_name()); + log_error(aot, heap)("Cannot archive object " PTR_FORMAT " of class %s", p2i(orig_obj), orig_obj->klass()->external_name()); debug_trace(); MetaspaceShared::unrecoverable_writing_error(); } - if (log_is_enabled(Debug, cds, heap) && java_lang_Class::is_instance(orig_obj)) { + if (log_is_enabled(Debug, aot, heap) && java_lang_Class::is_instance(orig_obj)) { ResourceMark rm; - LogTarget(Debug, cds, heap) log; + LogTarget(Debug, aot, heap) log; LogStream out(log); out.print("Found java mirror " PTR_FORMAT " ", p2i(orig_obj)); Klass* k = java_lang_Class::as_Klass(orig_obj); @@ -1545,7 +1546,7 @@ bool HeapShared::walk_one_object(PendingOopStack* stack, int level, KlassSubGrap // If you get an error here, you probably made a change in the JDK library that has added a Class // object that is referenced (directly or indirectly) by an ArchivableStaticFieldInfo // defined at the top of this file. - log_error(cds, heap)("(%d) Unknown java.lang.Class object is in the archived sub-graph", level); + log_error(aot, heap)("(%d) Unknown java.lang.Class object is in the archived sub-graph", level); debug_trace(); MetaspaceShared::unrecoverable_writing_error(); } @@ -1565,7 +1566,7 @@ bool HeapShared::walk_one_object(PendingOopStack* stack, int level, KlassSubGrap if (!archive_object(orig_obj, referrer, subgraph_info)) { // Skip archiving the sub-graph referenced from the current entry field. ResourceMark rm; - log_error(cds, heap)( + log_error(aot, heap)( "Cannot archive the sub-graph referenced from %s object (" PTR_FORMAT ") size %zu, skipped.", orig_obj->klass()->external_name(), p2i(orig_obj), orig_obj->size() * HeapWordSize); @@ -1650,25 +1651,25 @@ void HeapShared::archive_reachable_objects_from_static_field(InstanceKlass *k, KlassSubGraphInfo* subgraph_info = get_subgraph_info(k); oop f = m->obj_field(field_offset); - log_debug(cds, heap)("Start archiving from: %s::%s (" PTR_FORMAT ")", klass_name, field_name, p2i(f)); + log_debug(aot, heap)("Start archiving from: %s::%s (" PTR_FORMAT ")", klass_name, field_name, p2i(f)); if (!CompressedOops::is_null(f)) { - if (log_is_enabled(Trace, cds, heap)) { - LogTarget(Trace, cds, heap) log; + if (log_is_enabled(Trace, aot, heap)) { + LogTarget(Trace, aot, heap) log; LogStream out(log); f->print_on(&out); } bool success = archive_reachable_objects_from(1, subgraph_info, f); if (!success) { - log_error(cds, heap)("Archiving failed %s::%s (some reachable objects cannot be archived)", + log_error(aot, heap)("Archiving failed %s::%s (some reachable objects cannot be archived)", klass_name, field_name); } else { // Note: the field value is not preserved in the archived mirror. // Record the field as a new subGraph entry point. The recorded // information is restored from the archive at runtime. subgraph_info->add_subgraph_entry_field(field_offset, f); - log_info(cds, heap)("Archived field %s::%s => " PTR_FORMAT, klass_name, field_name, p2i(f)); + log_info(aot, heap)("Archived field %s::%s => " PTR_FORMAT, klass_name, field_name, p2i(f)); } } else { // The field contains null, we still need to record the entry point, @@ -1787,7 +1788,7 @@ void HeapShared::set_has_been_seen_during_subgraph_recording(oop obj) { } void HeapShared::start_recording_subgraph(InstanceKlass *k, const char* class_name, bool is_full_module_graph) { - log_info(cds, heap)("Start recording subgraph(s) for archived fields in %s", class_name); + log_info(aot, heap)("Start recording subgraph(s) for archived fields in %s", class_name); init_subgraph_info(k, is_full_module_graph); init_seen_objects_table(); _num_new_walked_objs = 0; @@ -1798,7 +1799,7 @@ void HeapShared::start_recording_subgraph(InstanceKlass *k, const char* class_na void HeapShared::done_recording_subgraph(InstanceKlass *k, const char* class_name) { int num_new_recorded_klasses = get_subgraph_info(k)->num_subgraph_object_klasses() - _num_old_recorded_klasses; - log_info(cds, heap)("Done recording subgraph(s) for archived fields in %s: " + log_info(aot, heap)("Done recording subgraph(s) for archived fields in %s: " "walked %d objs, archived %d new objs, recorded %d classes", class_name, _num_new_walked_objs, _num_new_archived_objs, num_new_recorded_klasses); @@ -1850,7 +1851,7 @@ void HeapShared::init_subgraph_entry_fields(ArchivableStaticFieldInfo fields[], #endif if (is_test_class) { - log_warning(cds)("Loading ArchiveHeapTestClass %s ...", test_class_name); + log_warning(aot)("Loading ArchiveHeapTestClass %s ...", test_class_name); } Klass* k = SystemDictionary::resolve_or_fail(klass_name, true, THREAD); @@ -1898,7 +1899,7 @@ void HeapShared::init_subgraph_entry_fields(ArchivableStaticFieldInfo fields[], } if (is_test_class) { - log_warning(cds)("Initializing ArchiveHeapTestClass %s ...", test_class_name); + log_warning(aot)("Initializing ArchiveHeapTestClass %s ...", test_class_name); } ik->initialize(CHECK); @@ -2047,18 +2048,18 @@ void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[], done_recording_subgraph(info->klass, klass_name); } - log_info(cds, heap)("Archived subgraph records = %d", + log_info(aot, heap)("Archived subgraph records = %d", _num_total_subgraph_recordings); - log_info(cds, heap)(" Walked %d objects", _num_total_walked_objs); - log_info(cds, heap)(" Archived %d objects", _num_total_archived_objs); - log_info(cds, heap)(" Recorded %d klasses", _num_total_recorded_klasses); + log_info(aot, heap)(" Walked %d objects", _num_total_walked_objs); + log_info(aot, heap)(" Archived %d objects", _num_total_archived_objs); + log_info(aot, heap)(" Recorded %d klasses", _num_total_recorded_klasses); #ifndef PRODUCT for (int i = 0; fields[i].valid(); i++) { ArchivableStaticFieldInfo* f = &fields[i]; verify_subgraph_from_static_field(f->klass, f->offset); } - log_info(cds, heap)(" Verified %d references", _num_total_verifications); + log_info(aot, heap)(" Verified %d references", _num_total_verifications); #endif } @@ -2085,7 +2086,7 @@ void HeapShared::debug_trace() { ResourceMark rm; oop referrer = _object_being_archived.referrer(); if (referrer != nullptr) { - LogStream ls(Log(cds, heap)::error()); + LogStream ls(Log(aot, heap)::error()); ls.print_cr("Reference trace"); CDSHeapVerifier::trace_to_root(&ls, referrer); } @@ -2158,18 +2159,18 @@ void HeapShared::print_stats() { size_t byte_size_limit = (size_t(1) << i) * HeapWordSize; size_t count = _alloc_count[i]; size_t size = _alloc_size[i]; - log_info(cds, heap)("%8zu objects are <= %-6zu" + log_info(aot, heap)("%8zu objects are <= %-6zu" " bytes (total %8zu bytes, avg %8.1f bytes)", count, byte_size_limit, size * HeapWordSize, avg_size(size, count)); huge_count -= count; huge_size -= size; } - log_info(cds, heap)("%8zu huge objects (total %8zu bytes" + log_info(aot, heap)("%8zu huge objects (total %8zu bytes" ", avg %8.1f bytes)", huge_count, huge_size * HeapWordSize, avg_size(huge_size, huge_count)); - log_info(cds, heap)("%8zu total objects (total %8zu bytes" + log_info(aot, heap)("%8zu total objects (total %8zu bytes" ", avg %8.1f bytes)", _total_obj_count, _total_obj_size * HeapWordSize, avg_size(_total_obj_size, _total_obj_count)); diff --git a/src/hotspot/share/cds/lambdaFormInvokers.cpp b/src/hotspot/share/cds/lambdaFormInvokers.cpp index 7832de8c6cc..3ed0daf2c4c 100644 --- a/src/hotspot/share/cds/lambdaFormInvokers.cpp +++ b/src/hotspot/share/cds/lambdaFormInvokers.cpp @@ -83,10 +83,10 @@ void LambdaFormInvokers::append(char* line) { class PrintLambdaFormMessage { public: PrintLambdaFormMessage() { - log_info(cds)("Regenerate MethodHandle Holder classes..."); + log_info(aot)("Regenerate MethodHandle Holder classes..."); } ~PrintLambdaFormMessage() { - log_info(cds)("Regenerate MethodHandle Holder classes...done"); + log_info(aot)("Regenerate MethodHandle Holder classes...done"); } }; @@ -114,7 +114,7 @@ void LambdaFormInvokers::regenerate_holder_classes(TRAPS) { PrintLambdaFormMessage plm; if (_lambdaform_lines == nullptr || _lambdaform_lines->length() == 0) { - log_info(cds)("Nothing to regenerate for holder classes"); + log_info(aot)("Nothing to regenerate for holder classes"); return; } @@ -153,9 +153,9 @@ void LambdaFormInvokers::regenerate_holder_classes(TRAPS) { log_error(cds)("%s: %s", PENDING_EXCEPTION->klass()->external_name(), java_lang_String::as_utf8_string(java_lang_Throwable::message(PENDING_EXCEPTION))); if (CDSConfig::is_dumping_static_archive()) { - log_error(cds)("Failed to generate LambdaForm holder classes. Is your classlist out of date?"); + log_error(aot)("Failed to generate LambdaForm holder classes. Is your classlist out of date?"); } else { - log_error(cds)("Failed to generate LambdaForm holder classes. Was the base archive generated with an outdated classlist?"); + log_error(aot)("Failed to generate LambdaForm holder classes. Was the base archive generated with an outdated classlist?"); } CLEAR_PENDING_EXCEPTION; } @@ -226,7 +226,7 @@ void LambdaFormInvokers::regenerate_class(char* class_name, ClassFileStream& st, if (!klass->is_shared()) { SystemDictionaryShared::set_excluded(InstanceKlass::cast(klass)); // exclude the existing class from dump } - log_info(cds, lambda)("Regenerated class %s, old: " INTPTR_FORMAT " new: " INTPTR_FORMAT, + log_info(aot, lambda)("Regenerated class %s, old: " INTPTR_FORMAT " new: " INTPTR_FORMAT, class_name, p2i(klass), p2i(result)); } @@ -256,7 +256,7 @@ void LambdaFormInvokers::dump_static_archive_invokers() { } assert(index == count, "Should match"); } - log_debug(cds)("Total LF lines stored into %s: %d", CDSConfig::type_of_archive_being_written(), count); + log_debug(aot)("Total LF lines stored into %s: %d", CDSConfig::type_of_archive_being_written(), count); } } @@ -268,7 +268,7 @@ void LambdaFormInvokers::read_static_archive_invokers() { char* str = line->adr_at(0); append(str); } - log_debug(cds)("Total LF lines read from %s: %d", CDSConfig::type_of_archive_being_loaded(), _static_archive_invokers->length()); + log_debug(aot)("Total LF lines read from %s: %d", CDSConfig::type_of_archive_being_loaded(), _static_archive_invokers->length()); } } diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp index 45a41e9f679..53d75a3d7ec 100644 --- a/src/hotspot/share/cds/metaspaceShared.cpp +++ b/src/hotspot/share/cds/metaspaceShared.cpp @@ -28,6 +28,7 @@ #include "cds/aotClassLocation.hpp" #include "cds/aotConstantPoolResolver.hpp" #include "cds/aotLinkedClassBulkLoader.hpp" +#include "cds/aotLogging.hpp" #include "cds/aotReferenceObjSupport.hpp" #include "cds/archiveBuilder.hpp" #include "cds/archiveHeapLoader.hpp" @@ -186,7 +187,7 @@ class DumpClassListCLDClosure : public CLDClosure { return; } if (_dumped_classes.maybe_grow()) { - log_info(cds, hashtables)("Expanded _dumped_classes table to %d", _dumped_classes.table_size()); + log_info(aot, hashtables)("Expanded _dumped_classes table to %d", _dumped_classes.table_size()); } if (ik->java_super()) { dump(ik->java_super()); @@ -257,7 +258,7 @@ static char* compute_shared_base(size_t cds_max) { : nullptr; if (aligned_base != specified_base) { - log_info(cds)("SharedBaseAddress (" INTPTR_FORMAT ") aligned up to " INTPTR_FORMAT, + aot_log_info(aot)("SharedBaseAddress (" INTPTR_FORMAT ") aligned up to " INTPTR_FORMAT, p2i(specified_base), p2i(aligned_base)); } @@ -275,7 +276,7 @@ static char* compute_shared_base(size_t cds_max) { // Arguments::default_SharedBaseAddress() is hard-coded in cds_globals.hpp. It must be carefully // picked that (a) the align_up() below will always return a valid value; (b) none of // the following asserts will fail. - log_warning(cds)("SharedBaseAddress (" INTPTR_FORMAT ") is %s. Reverted to " INTPTR_FORMAT, + aot_log_warning(aot)("SharedBaseAddress (" INTPTR_FORMAT ") is %s. Reverted to " INTPTR_FORMAT, p2i((void*)SharedBaseAddress), err, p2i((void*)Arguments::default_SharedBaseAddress())); @@ -290,7 +291,7 @@ static char* compute_shared_base(size_t cds_max) { void MetaspaceShared::initialize_for_static_dump() { assert(CDSConfig::is_dumping_static_archive(), "sanity"); - log_info(cds)("Core region alignment: %zu", core_region_alignment()); + aot_log_info(aot)("Core region alignment: %zu", core_region_alignment()); // The max allowed size for CDS archive. We use this to limit SharedBaseAddress // to avoid address space wrap around. size_t cds_max; @@ -314,7 +315,7 @@ void MetaspaceShared::initialize_for_static_dump() { os::vm_page_size(), mtClassShared); if (!_symbol_rs.is_reserved()) { - log_error(cds)("Unable to reserve memory for symbols: %zu bytes.", symbol_rs_size); + aot_log_error(aot)("Unable to reserve memory for symbols: %zu bytes.", symbol_rs_size); MetaspaceShared::unrecoverable_writing_error(); } _symbol_region.init(&_symbol_rs, &_symbol_vs); @@ -350,7 +351,7 @@ void MetaspaceShared::read_extra_data(JavaThread* current, const char* filename) ResourceMark rm(current); if (utf8_length == 0x7fffffff) { // buf_len will overflown 32-bit value. - log_error(cds)("string length too large: %d", utf8_length); + aot_log_error(aot)("string length too large: %d", utf8_length); MetaspaceShared::unrecoverable_loading_error(); } int buf_len = utf8_length+1; @@ -367,13 +368,13 @@ void MetaspaceShared::read_extra_data(JavaThread* current, const char* filename) oop str = StringTable::intern(utf8_buffer, THREAD); if (HAS_PENDING_EXCEPTION) { - log_warning(cds, heap)("[line %d] extra interned string allocation failed; size too large: %d", + log_warning(aot, heap)("[line %d] extra interned string allocation failed; size too large: %d", reader.last_line_no(), utf8_length); CLEAR_PENDING_EXCEPTION; } else { #if INCLUDE_CDS_JAVA_HEAP if (ArchiveHeapWriter::is_string_too_large_to_archive(str)) { - log_warning(cds, heap)("[line %d] extra interned string ignored; size too large: %d", + log_warning(aot, heap)("[line %d] extra interned string ignored; size too large: %d", reader.last_line_no(), utf8_length); continue; } @@ -407,7 +408,7 @@ void MetaspaceShared::write_method_handle_intrinsics() { word_size += m->constants()->cache()->size(); } } - log_info(cds)("Archived %d method handle intrinsics (%d bytes)", len, word_size * BytesPerWord); + log_info(aot)("Archived %d method handle intrinsics (%d bytes)", len, word_size * BytesPerWord); } // About "serialize" -- @@ -539,7 +540,7 @@ private: void dump_java_heap_objects(); void dump_shared_symbol_table(GrowableArray* symbols) { - log_info(cds)("Dumping symbol table ..."); + log_info(aot)("Dumping symbol table ..."); SymbolTable::write_to_archive(symbols); } char* dump_early_read_only_tables(); @@ -656,7 +657,7 @@ void VM_PopulateDumpSharedSpace::doit() { _builder.dump_ro_metadata(); _builder.relocate_metaspaceobj_embedded_pointers(); - log_info(cds)("Make classes shareable"); + log_info(aot)("Make classes shareable"); _builder.make_klasses_shareable(); MetaspaceShared::make_method_handle_intrinsics_shareable(); @@ -668,7 +669,7 @@ void VM_PopulateDumpSharedSpace::doit() { char* serialized_data = dump_read_only_tables(cl_config); if (CDSConfig::is_dumping_lambdas_in_legacy_mode()) { - log_info(cds)("Adjust lambda proxy class dictionary"); + log_info(aot)("Adjust lambda proxy class dictionary"); LambdaProxyClassDictionary::adjust_dumptime_table(); } @@ -794,11 +795,11 @@ void MetaspaceShared::preload_and_dump(TRAPS) { preload_and_dump_impl(builder, THREAD); if (HAS_PENDING_EXCEPTION) { if (PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())) { - log_error(cds)("Out of memory. Please run with a larger Java heap, current MaxHeapSize = " + aot_log_error(aot)("Out of memory. Please run with a larger Java heap, current MaxHeapSize = " "%zuM", MaxHeapSize/M); MetaspaceShared::writing_error(); } else { - log_error(cds)("%s: %s", PENDING_EXCEPTION->klass()->external_name(), + aot_log_error(aot)("%s: %s", PENDING_EXCEPTION->klass()->external_name(), java_lang_String::as_utf8_string(java_lang_Throwable::message(PENDING_EXCEPTION))); MetaspaceShared::writing_error("Unexpected exception, use -Xlog:cds,exceptions=trace for detail"); } @@ -837,15 +838,15 @@ void MetaspaceShared::adjust_heap_sizes_for_dumping() { julong max_heap_size = (julong)(4 * G); if (MinHeapSize > max_heap_size) { - log_debug(cds)("Setting MinHeapSize to 4G for CDS dumping, original size = %zuM", MinHeapSize/M); + log_debug(aot)("Setting MinHeapSize to 4G for CDS dumping, original size = %zuM", MinHeapSize/M); FLAG_SET_ERGO(MinHeapSize, max_heap_size); } if (InitialHeapSize > max_heap_size) { - log_debug(cds)("Setting InitialHeapSize to 4G for CDS dumping, original size = %zuM", InitialHeapSize/M); + log_debug(aot)("Setting InitialHeapSize to 4G for CDS dumping, original size = %zuM", InitialHeapSize/M); FLAG_SET_ERGO(InitialHeapSize, max_heap_size); } if (MaxHeapSize > max_heap_size) { - log_debug(cds)("Setting MaxHeapSize to 4G for CDS dumping, original size = %zuM", MaxHeapSize/M); + log_debug(aot)("Setting MaxHeapSize to 4G for CDS dumping, original size = %zuM", MaxHeapSize/M); FLAG_SET_ERGO(MaxHeapSize, max_heap_size); } } @@ -868,7 +869,7 @@ void MetaspaceShared::preload_classes(TRAPS) { classlist_path = SharedClassListFile; } - log_info(cds)("Loading classes to share ..."); + aot_log_info(aot)("Loading classes to share ..."); ClassListParser::parse_classlist(classlist_path, ClassListParser::_parse_all, CHECK); if (ExtraSharedClassListFile) { @@ -889,7 +890,7 @@ void MetaspaceShared::preload_classes(TRAPS) { // are archived. exercise_runtime_cds_code(CHECK); - log_info(cds)("Loading classes to share: done."); + aot_log_info(aot)("Loading classes to share: done."); } void MetaspaceShared::exercise_runtime_cds_code(TRAPS) { @@ -907,14 +908,14 @@ void MetaspaceShared::preload_and_dump_impl(StaticArchiveBuilder& builder, TRAPS preload_classes(CHECK); if (SharedArchiveConfigFile) { - log_info(cds)("Reading extra data from %s ...", SharedArchiveConfigFile); + log_info(aot)("Reading extra data from %s ...", SharedArchiveConfigFile); read_extra_data(THREAD, SharedArchiveConfigFile); - log_info(cds)("Reading extra data: done."); + log_info(aot)("Reading extra data: done."); } } if (CDSConfig::is_dumping_preimage_static_archive()) { - log_info(cds)("Reading lambda form invokers from JDK default classlist ..."); + log_info(aot)("Reading lambda form invokers from JDK default classlist ..."); char default_classlist[JVM_MAXPATHLEN]; get_default_classlist(default_classlist, JVM_MAXPATHLEN); struct stat statbuf; @@ -938,21 +939,21 @@ void MetaspaceShared::preload_and_dump_impl(StaticArchiveBuilder& builder, TRAPS if (CDSConfig::is_dumping_final_static_archive()) { if (ExtraSharedClassListFile) { - log_info(cds)("Loading extra classes from %s ...", ExtraSharedClassListFile); + log_info(aot)("Loading extra classes from %s ...", ExtraSharedClassListFile); ClassListParser::parse_classlist(ExtraSharedClassListFile, ClassListParser::_parse_all, CHECK); } } // Rewrite and link classes - log_info(cds)("Rewriting and linking classes ..."); + log_info(aot)("Rewriting and linking classes ..."); // Link any classes which got missed. This would happen if we have loaded classes that // were not explicitly specified in the classlist. E.g., if an interface implemented by class K // fails verification, all other interfaces that were not specified in the classlist but // are implemented by K are not verified. link_shared_classes(CHECK); - log_info(cds)("Rewriting and linking classes: done"); + log_info(aot)("Rewriting and linking classes: done"); if (CDSConfig::is_dumping_regenerated_lambdaform_invokers()) { LambdaFormInvokers::regenerate_holder_classes(CHECK); @@ -973,7 +974,7 @@ void MetaspaceShared::preload_and_dump_impl(StaticArchiveBuilder& builder, TRAPS if (CDSConfig::is_initing_classes_at_dump_time()) { // java.lang.Class::reflectionFactory cannot be archived yet. We set this field // to null, and it will be initialized again at runtime. - log_debug(cds)("Resetting Class::reflectionFactory"); + log_debug(aot)("Resetting Class::reflectionFactory"); TempNewSymbol method_name = SymbolTable::new_symbol("resetArchivedStates"); Symbol* method_sig = vmSymbols::void_method_signature(); JavaValue result(T_VOID); @@ -988,7 +989,7 @@ void MetaspaceShared::preload_and_dump_impl(StaticArchiveBuilder& builder, TRAPS // some new strings may be added to the intern table. StringTable::allocate_shared_strings_array(CHECK); } else { - log_info(cds)("Not dumping heap, reset CDSConfig::_is_using_optimized_module_handling"); + log_info(aot)("Not dumping heap, reset CDSConfig::_is_using_optimized_module_handling"); CDSConfig::stop_using_optimized_module_handling(); } #endif @@ -1024,7 +1025,7 @@ bool MetaspaceShared::write_static_archive(ArchiveBuilder* builder, FileMapInfo* builder->write_archive(map_info, heap_info); if (AllowArchivingWithJavaAgent) { - log_warning(cds)("This %s was created with AllowArchivingWithJavaAgent. It should be used " + aot_log_warning(aot)("This %s was created with AllowArchivingWithJavaAgent. It should be used " "for testing purposes only and should not be used in a production environment", CDSConfig::type_of_archive_being_loaded()); } return true; @@ -1057,7 +1058,7 @@ bool MetaspaceShared::try_link_class(JavaThread* current, InstanceKlass* ik) { ik->link_class(THREAD); if (HAS_PENDING_EXCEPTION) { ResourceMark rm(THREAD); - log_warning(cds)("Preload Warning: Verification failed for %s", + aot_log_warning(aot)("Preload Warning: Verification failed for %s", ik->external_name()); CLEAR_PENDING_EXCEPTION; SystemDictionaryShared::set_class_has_failed_verification(ik); @@ -1109,7 +1110,7 @@ bool MetaspaceShared::is_shared_static(void* p) { // - When -XX:+RequireSharedSpaces is specified, AND the JVM cannot load the archive(s) due // to version or classpath mismatch. void MetaspaceShared::unrecoverable_loading_error(const char* message) { - report_loading_error(message); + report_loading_error("%s", message); if (CDSConfig::is_dumping_final_static_archive()) { vm_exit_during_initialization("Must be a valid AOT configuration generated by the current JVM", AOTConfiguration); @@ -1121,27 +1122,30 @@ void MetaspaceShared::unrecoverable_loading_error(const char* message) { } void MetaspaceShared::report_loading_error(const char* format, ...) { - // If the user doesn't specify any CDS options, we will try to load the default CDS archive, which - // may fail due to incompatible VM options. Print at the info level to avoid excessive verbosity. + // When using AOT cache, errors messages are always printed on the error channel. + LogStream ls_aot(LogLevel::Error, LogTagSetMapping::tagset()); + + // If we are loading load the default CDS archive, it may fail due to incompatible VM options. + // Print at the info level to avoid excessive verbosity. // However, if the user has specified a CDS archive (or AOT cache), they would be interested in // knowing that the loading fails, so we print at the error level. - Log(cds) log; - LogStream ls_error(log.error()); - LogStream ls_info(log.info()); - LogStream& ls = (!CDSConfig::is_using_archive()) || CDSConfig::is_using_only_default_archive() ? ls_info : ls_error; + LogLevelType level = (!CDSConfig::is_using_archive() || CDSConfig::is_using_only_default_archive()) ? + LogLevel::Info : LogLevel::Error; + LogStream ls_cds(level, LogTagSetMapping::tagset()); + + LogStream& ls = CDSConfig::new_aot_flags_used() ? ls_aot : ls_cds; + va_list ap; + va_start(ap, format); static bool printed_error = false; if (!printed_error) { // No need for locks. Loading error checks happen only in main thread. - ls.print_cr("An error has occurred while processing the %s. Run with -Xlog:cds for details.", CDSConfig::type_of_archive_being_loaded()); + ls.print_cr("An error has occurred while processing the %s. Run with -Xlog:%s for details.", + CDSConfig::type_of_archive_being_loaded(), CDSConfig::new_aot_flags_used() ? "aot" : "aot,cds"); printed_error = true; } + ls.vprint_cr(format, ap); - if (format != nullptr) { - va_list ap; - va_start(ap, format); - ls.vprint_cr(format, ap); - va_end(ap); - } + va_end(ap); } // This function is called when the JVM is unable to write the specified CDS archive due to an @@ -1154,9 +1158,9 @@ void MetaspaceShared::unrecoverable_writing_error(const char* message) { // This function is called when the JVM is unable to write the specified CDS archive due to a // an error. The error will be propagated void MetaspaceShared::writing_error(const char* message) { - log_error(cds)("An error has occurred while writing the shared archive file."); + aot_log_error(aot)("An error has occurred while writing the shared archive file."); if (message != nullptr) { - log_error(cds)("%s", message); + aot_log_error(aot)("%s", message); } } @@ -1168,17 +1172,17 @@ void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() { FileMapInfo* dynamic_mapinfo = nullptr; if (static_mapinfo != nullptr) { - log_info(cds)("Core region alignment: %zu", static_mapinfo->core_region_alignment()); + aot_log_info(aot)("Core region alignment: %zu", static_mapinfo->core_region_alignment()); dynamic_mapinfo = open_dynamic_archive(); - log_info(cds)("ArchiveRelocationMode: %d", ArchiveRelocationMode); + aot_log_info(aot)("ArchiveRelocationMode: %d", ArchiveRelocationMode); // First try to map at the requested address result = map_archives(static_mapinfo, dynamic_mapinfo, true); if (result == MAP_ARCHIVE_MMAP_FAILURE) { // Mapping has failed (probably due to ASLR). Let's map at an address chosen // by the OS. - log_info(cds)("Try to map archive(s) at an alternative address"); + aot_log_info(aot)("Try to map archive(s) at an alternative address"); result = map_archives(static_mapinfo, dynamic_mapinfo, false); } } @@ -1199,7 +1203,7 @@ void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() { } else { set_shared_metaspace_range(nullptr, nullptr, nullptr); if (CDSConfig::is_dumping_dynamic_archive()) { - log_warning(cds)("-XX:ArchiveClassesAtExit is unsupported when base CDS archive is not loaded. Run with -Xlog:cds for more info."); + aot_log_warning(aot)("-XX:ArchiveClassesAtExit is unsupported when base CDS archive is not loaded. Run with -Xlog:cds for more info."); } UseSharedSpaces = false; // The base archive cannot be mapped. We cannot dump the dynamic shared archive. @@ -1268,7 +1272,7 @@ FileMapInfo* MetaspaceShared::open_dynamic_archive() { MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, FileMapInfo* dynamic_mapinfo, bool use_requested_addr) { if (use_requested_addr && static_mapinfo->requested_base_address() == nullptr) { - log_info(cds)("Archive(s) were created with -XX:SharedBaseAddress=0. Always map at os-selected address."); + aot_log_info(aot)("Archive(s) were created with -XX:SharedBaseAddress=0. Always map at os-selected address."); return MAP_ARCHIVE_MMAP_FAILURE; } @@ -1276,12 +1280,12 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File // For product build only -- this is for benchmarking the cost of doing relocation. // For debug builds, the check is done below, after reserving the space, for better test coverage // (see comment below). - log_info(cds)("ArchiveRelocationMode == 1: always map archive(s) at an alternative address"); + aot_log_info(aot)("ArchiveRelocationMode == 1: always map archive(s) at an alternative address"); return MAP_ARCHIVE_MMAP_FAILURE; }); if (ArchiveRelocationMode == 2 && !use_requested_addr) { - log_info(cds)("ArchiveRelocationMode == 2: never map archive(s) at an alternative address"); + aot_log_info(aot)("ArchiveRelocationMode == 2: never map archive(s) at an alternative address"); return MAP_ARCHIVE_MMAP_FAILURE; }; @@ -1302,7 +1306,7 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File class_space_rs); if (mapped_base_address == nullptr) { result = MAP_ARCHIVE_MMAP_FAILURE; - log_debug(cds)("Failed to reserve spaces (use_requested_addr=%u)", (unsigned)use_requested_addr); + aot_log_debug(aot)("Failed to reserve spaces (use_requested_addr=%u)", (unsigned)use_requested_addr); } else { if (Metaspace::using_class_space()) { @@ -1332,10 +1336,10 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File } #endif // ASSERT - log_info(cds)("Reserved archive_space_rs [" INTPTR_FORMAT " - " INTPTR_FORMAT "] (%zu) bytes%s", + aot_log_info(aot)("Reserved archive_space_rs [" INTPTR_FORMAT " - " INTPTR_FORMAT "] (%zu) bytes%s", p2i(archive_space_rs.base()), p2i(archive_space_rs.end()), archive_space_rs.size(), (prot_zone_size > 0 ? " (includes protection zone)" : "")); - log_info(cds)("Reserved class_space_rs [" INTPTR_FORMAT " - " INTPTR_FORMAT "] (%zu) bytes", + aot_log_info(aot)("Reserved class_space_rs [" INTPTR_FORMAT " - " INTPTR_FORMAT "] (%zu) bytes", p2i(class_space_rs.base()), p2i(class_space_rs.end()), class_space_rs.size()); if (MetaspaceShared::use_windows_memory_mapping()) { @@ -1357,7 +1361,7 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File // pointers anyway so there's no benefit to mmap. if (use_requested_addr) { assert(!total_space_rs.is_reserved(), "Should not be reserved for Windows"); - log_info(cds)("Windows mmap workaround: releasing archive space."); + aot_log_info(aot)("Windows mmap workaround: releasing archive space."); MemoryReserver::release(archive_space_rs); // Mark as not reserved archive_space_rs = {}; @@ -1374,7 +1378,7 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File mtClassShared); assert(p == mapped_base_address || p == nullptr, "must be"); if (p == nullptr) { - log_debug(cds)("Failed to re-reserve protection zone"); + aot_log_debug(aot)("Failed to re-reserve protection zone"); return MAP_ARCHIVE_MMAP_FAILURE; } } @@ -1399,7 +1403,7 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File // debug builds, we do it here (after all archives have possibly been // mapped), so we can thoroughly test the code for failure handling // (releasing all allocated resource, etc). - log_info(cds)("ArchiveRelocationMode == 1: always map archive(s) at an alternative address"); + aot_log_info(aot)("ArchiveRelocationMode == 1: always map archive(s) at an alternative address"); if (static_result == MAP_ARCHIVE_SUCCESS) { static_result = MAP_ARCHIVE_MMAP_FAILURE; } @@ -1468,8 +1472,8 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File static_mapinfo->map_or_load_heap_region(); } #endif // _LP64 - log_info(cds)("initial optimized module handling: %s", CDSConfig::is_using_optimized_module_handling() ? "enabled" : "disabled"); - log_info(cds)("initial full module graph: %s", CDSConfig::is_using_full_module_graph() ? "enabled" : "disabled"); + log_info(aot)("initial optimized module handling: %s", CDSConfig::is_using_optimized_module_handling() ? "enabled" : "disabled"); + log_info(aot)("initial full module graph: %s", CDSConfig::is_using_full_module_graph() ? "enabled" : "disabled"); } else { unmap_archive(static_mapinfo); unmap_archive(dynamic_mapinfo); @@ -1615,7 +1619,7 @@ char* MetaspaceShared::reserve_address_space_for_archives(FileMapInfo* static_ma const int precomputed_narrow_klass_shift = ArchiveBuilder::precomputed_narrow_klass_shift(); if (!CompressedKlassPointers::check_klass_decode_mode(base_address, precomputed_narrow_klass_shift, total_range_size)) { - log_info(cds)("CDS initialization: Cannot use SharedBaseAddress " PTR_FORMAT " with precomputed shift %d.", + aot_log_info(aot)("CDS initialization: Cannot use SharedBaseAddress " PTR_FORMAT " with precomputed shift %d.", p2i(base_address), precomputed_narrow_klass_shift); use_archive_base_addr = false; } @@ -1699,17 +1703,17 @@ void MetaspaceShared::release_reserved_spaces(ReservedSpace& total_space_rs, ReservedSpace& archive_space_rs, ReservedSpace& class_space_rs) { if (total_space_rs.is_reserved()) { - log_debug(cds)("Released shared space (archive + class) " INTPTR_FORMAT, p2i(total_space_rs.base())); + aot_log_debug(aot)("Released shared space (archive + class) " INTPTR_FORMAT, p2i(total_space_rs.base())); MemoryReserver::release(total_space_rs); total_space_rs = {}; } else { if (archive_space_rs.is_reserved()) { - log_debug(cds)("Released shared space (archive) " INTPTR_FORMAT, p2i(archive_space_rs.base())); + aot_log_debug(aot)("Released shared space (archive) " INTPTR_FORMAT, p2i(archive_space_rs.base())); MemoryReserver::release(archive_space_rs); archive_space_rs = {}; } if (class_space_rs.is_reserved()) { - log_debug(cds)("Released shared space (classes) " INTPTR_FORMAT, p2i(class_space_rs.base())); + aot_log_debug(aot)("Released shared space (classes) " INTPTR_FORMAT, p2i(class_space_rs.base())); MemoryReserver::release(class_space_rs); class_space_rs = {}; } @@ -1819,7 +1823,7 @@ void MetaspaceShared::initialize_shared_spaces() { dynamic_mapinfo->unmap_region(MetaspaceShared::bm); } - LogStreamHandle(Info, cds) lsh; + LogStreamHandle(Info, aot) lsh; if (lsh.is_enabled()) { lsh.print("Using AOT-linked classes: %s (static archive: %s aot-linked classes", BOOL_TO_STR(CDSConfig::is_using_aot_linked_classes()), diff --git a/src/hotspot/share/cds/metaspaceShared.hpp b/src/hotspot/share/cds/metaspaceShared.hpp index 8fb92196acc..2423141b8fa 100644 --- a/src/hotspot/share/cds/metaspaceShared.hpp +++ b/src/hotspot/share/cds/metaspaceShared.hpp @@ -110,7 +110,7 @@ public: static bool is_shared_dynamic(void* p) NOT_CDS_RETURN_(false); static bool is_shared_static(void* p) NOT_CDS_RETURN_(false); - static void unrecoverable_loading_error(const char* message = nullptr) ATTRIBUTE_PRINTF(1, 0); + static void unrecoverable_loading_error(const char* message = "unrecoverable error"); static void report_loading_error(const char* format, ...) ATTRIBUTE_PRINTF(1, 0); static void unrecoverable_writing_error(const char* message = nullptr); static void writing_error(const char* message = nullptr); diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index c7cca9682fe..3b34edf416e 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -1206,7 +1206,7 @@ bool java_lang_Class::restore_archived_mirror(Klass *k, k->clear_archived_mirror_index(); // mirror is archived, restore - log_debug(cds, mirror)("Archived mirror is: " PTR_FORMAT, p2i(m)); + log_debug(aot, mirror)("Archived mirror is: " PTR_FORMAT, p2i(m)); assert(as_Klass(m) == k, "must be"); Handle mirror(THREAD, m); @@ -1231,9 +1231,9 @@ bool java_lang_Class::restore_archived_mirror(Klass *k, set_mirror_module_field(THREAD, k, mirror, module); - if (log_is_enabled(Trace, cds, heap, mirror)) { + if (log_is_enabled(Trace, aot, heap, mirror)) { ResourceMark rm(THREAD); - log_trace(cds, heap, mirror)( + log_trace(aot, heap, mirror)( "Restored %s archived mirror " PTR_FORMAT, k->external_name(), p2i(mirror())); } diff --git a/src/hotspot/share/oops/klass.cpp b/src/hotspot/share/oops/klass.cpp index b0d2e84335e..71f31cef580 100644 --- a/src/hotspot/share/oops/klass.cpp +++ b/src/hotspot/share/oops/klass.cpp @@ -792,9 +792,9 @@ void Klass::remove_unshareable_info() { assert(CDSConfig::is_dumping_archive(), "only called during CDS dump time"); JFR_ONLY(REMOVE_ID(this);) - if (log_is_enabled(Trace, cds, unshareable)) { + if (log_is_enabled(Trace, aot, unshareable)) { ResourceMark rm; - log_trace(cds, unshareable)("remove: %s", external_name()); + log_trace(aot, unshareable)("remove: %s", external_name()); } // _secondary_super_cache may be updated by an is_subtype_of() call @@ -818,9 +818,9 @@ void Klass::remove_unshareable_info() { void Klass::remove_java_mirror() { assert(CDSConfig::is_dumping_archive(), "sanity"); - if (log_is_enabled(Trace, cds, unshareable)) { + if (log_is_enabled(Trace, aot, unshareable)) { ResourceMark rm; - log_trace(cds, unshareable)("remove java_mirror: %s", external_name()); + log_trace(aot, unshareable)("remove java_mirror: %s", external_name()); } #if INCLUDE_CDS_JAVA_HEAP @@ -856,10 +856,10 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec assert(is_shared(), "must be set"); assert(secondary_supers()->length() >= (int)population_count(_secondary_supers_bitmap), "must be"); JFR_ONLY(RESTORE_ID(this);) - if (log_is_enabled(Trace, cds, unshareable)) { + if (log_is_enabled(Trace, aot, unshareable)) { ResourceMark rm(THREAD); oop class_loader = loader_data->class_loader(); - log_trace(cds, unshareable)("restore: %s with class loader: %s", external_name(), + log_trace(aot, unshareable)("restore: %s with class loader: %s", external_name(), class_loader != nullptr ? class_loader->klass()->external_name() : "boot"); } @@ -892,7 +892,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec if (this->has_archived_mirror_index()) { ResourceMark rm(THREAD); - log_debug(cds, mirror)("%s has raw archived mirror", external_name()); + log_debug(aot, mirror)("%s has raw archived mirror", external_name()); if (ArchiveHeapLoader::is_in_use()) { bool present = java_lang_Class::restore_archived_mirror(this, loader, module_handle, protection_domain, @@ -903,7 +903,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec } // No archived mirror data - log_debug(cds, mirror)("No archived mirror data for %s", external_name()); + log_debug(aot, mirror)("No archived mirror data for %s", external_name()); clear_java_mirror_handle(); this->clear_archived_mirror_index(); } @@ -912,7 +912,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec // gotten an OOM later but keep the mirror if it was created. if (java_mirror() == nullptr) { ResourceMark rm(THREAD); - log_trace(cds, mirror)("Recreate mirror for %s", external_name()); + log_trace(aot, mirror)("Recreate mirror for %s", external_name()); java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, Handle(), CHECK); } } diff --git a/src/hotspot/share/prims/jvmtiTagMap.cpp b/src/hotspot/share/prims/jvmtiTagMap.cpp index f6f0e30db34..d3bf8862d37 100644 --- a/src/hotspot/share/prims/jvmtiTagMap.cpp +++ b/src/hotspot/share/prims/jvmtiTagMap.cpp @@ -954,7 +954,7 @@ void IterateOverHeapObjectClosure::do_object(oop o) { // skip if object is a dormant shared object whose mirror hasn't been loaded if (o != nullptr && o->klass()->java_mirror() == nullptr) { - log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)", p2i(o), + log_debug(aot, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)", p2i(o), o->klass()->external_name()); return; } @@ -1040,7 +1040,7 @@ void IterateThroughHeapObjectClosure::do_object(oop obj) { // skip if object is a dormant shared object whose mirror hasn't been loaded if (obj != nullptr && obj->klass()->java_mirror() == nullptr) { - log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)", p2i(obj), + log_debug(aot, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)", p2i(obj), obj->klass()->external_name()); return; } diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 1461f893f4a..2fa519c5ea5 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -22,6 +22,7 @@ * */ +#include "cds/aotLogging.hpp" #include "cds/cds_globals.hpp" #include "cds/cdsConfig.hpp" #include "classfile/classLoader.hpp" @@ -1362,7 +1363,7 @@ void Arguments::set_mode_flags(Mode mode) { // incompatible command line options were chosen. void Arguments::no_shared_spaces(const char* message) { if (RequireSharedSpaces) { - log_error(cds)("%s is incompatible with other specified options.", + aot_log_error(aot)("%s is incompatible with other specified options.", CDSConfig::new_aot_flags_used() ? "AOT cache" : "CDS"); if (CDSConfig::new_aot_flags_used()) { vm_exit_during_initialization("Unable to use AOT cache", message); @@ -1371,7 +1372,7 @@ void Arguments::no_shared_spaces(const char* message) { } } else { if (CDSConfig::new_aot_flags_used()) { - log_warning(cds)("Unable to use AOT cache: %s", message); + log_warning(aot)("Unable to use AOT cache: %s", message); } else { log_info(cds)("Unable to use shared archive: %s", message); } @@ -1562,7 +1563,7 @@ void Arguments::set_heap_size() { // was not specified. if (reasonable_max > max_coop_heap) { if (FLAG_IS_ERGO(UseCompressedOops) && override_coop_limit) { - log_info(cds)("UseCompressedOops and UseCompressedClassPointers have been disabled due to" + aot_log_info(aot)("UseCompressedOops and UseCompressedClassPointers have been disabled due to" " max heap %zu > compressed oop heap %zu. " "Please check the setting of MaxRAMPercentage %5.2f." ,(size_t)reasonable_max, (size_t)max_coop_heap, MaxRAMPercentage); diff --git a/src/hotspot/share/services/heapDumper.cpp b/src/hotspot/share/services/heapDumper.cpp index a042a390925..7c91bb000aa 100644 --- a/src/hotspot/share/services/heapDumper.cpp +++ b/src/hotspot/share/services/heapDumper.cpp @@ -794,14 +794,14 @@ class DumperSupport : AllStatic { } static void report_dormant_archived_object(oop o, oop ref_obj) { - if (log_is_enabled(Trace, cds, heap)) { + if (log_is_enabled(Trace, aot, heap)) { ResourceMark rm; if (ref_obj != nullptr) { - log_trace(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s) referenced by " INTPTR_FORMAT " (%s)", + log_trace(aot, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s) referenced by " INTPTR_FORMAT " (%s)", p2i(o), o->klass()->external_name(), p2i(ref_obj), ref_obj->klass()->external_name()); } else { - log_trace(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)", + log_trace(aot, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)", p2i(o), o->klass()->external_name()); } } @@ -2677,7 +2677,7 @@ int HeapDumper::dump(const char* path, outputStream* out, int compression, bool event.set_compression(compression); event.commit(); } else { - log_debug(cds, heap)("Error %s while dumping heap", error()); + log_debug(aot, heap)("Error %s while dumping heap", error()); } // print message in interactive case diff --git a/test/hotspot/jtreg/runtime/cds/appcds/AOTFlags.java b/test/hotspot/jtreg/runtime/cds/appcds/AOTFlags.java index 53036071fe3..71f72d6b4e8 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/AOTFlags.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/AOTFlags.java @@ -56,7 +56,7 @@ public class AOTFlags { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:AOTMode=record", "-XX:AOTConfiguration=" + aotConfigFile, - "-Xlog:cds=debug", + "-Xlog:aot=debug", "-cp", appJar, helloClass); OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "train"); @@ -70,18 +70,18 @@ public class AOTFlags { "-XX:AOTMode=create", "-XX:AOTConfiguration=" + aotConfigFile, "-XX:AOTCache=" + aotCacheFile, - "-Xlog:cds", + "-Xlog:aot", "-cp", appJar); out = CDSTestUtils.executeAndLog(pb, "asm"); - out.shouldContain("Dumping shared data to file:"); - out.shouldMatch("cds.*hello[.]aot"); + out.shouldContain("AOTCache creation is complete"); + out.shouldMatch("hello[.]aot"); out.shouldHaveExitValue(0); //---------------------------------------------------------------------- printTestCase("Production Run with AOTCache"); pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:AOTCache=" + aotCacheFile, - "-Xlog:cds", + "-Xlog:aot", "-cp", appJar, helloClass); out = CDSTestUtils.executeAndLog(pb, "prod"); out.shouldContain("Using AOT-linked classes: true (static archive: has aot-linked classes)"); @@ -94,7 +94,7 @@ public class AOTFlags { pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:AOTCache=" + aotCacheFile, "--show-version", - "-Xlog:cds", + "-Xlog:aot", "-XX:AOTMode=off", "-cp", appJar, helloClass); out = CDSTestUtils.executeAndLog(pb, "prod"); @@ -108,7 +108,7 @@ public class AOTFlags { pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:AOTCache=" + aotCacheFile, "--show-version", - "-Xlog:cds", + "-Xlog:aot", "-XX:AOTMode=auto", "-cp", appJar, helloClass); out = CDSTestUtils.executeAndLog(pb, "prod"); @@ -122,7 +122,7 @@ public class AOTFlags { pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:AOTCache=" + aotCacheFile, "--show-version", - "-Xlog:cds", + "-Xlog:aot", "-XX:AOTMode=on", "-cp", appJar, helloClass); out = CDSTestUtils.executeAndLog(pb, "prod"); @@ -138,18 +138,18 @@ public class AOTFlags { "-XX:-AOTClassLinking", "-XX:AOTConfiguration=" + aotConfigFile, "-XX:AOTCache=" + aotCacheFile, - "-Xlog:cds", + "-Xlog:aot", "-cp", appJar); out = CDSTestUtils.executeAndLog(pb, "asm"); - out.shouldContain("Dumping shared data to file:"); - out.shouldMatch("cds.*hello[.]aot"); + out.shouldContain("AOTCache creation is complete"); + out.shouldMatch("hello[.]aot"); out.shouldHaveExitValue(0); //---------------------------------------------------------------------- printTestCase("Production Run with AOTCache, which was created with -XX:-AOTClassLinking"); pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:AOTCache=" + aotCacheFile, - "-Xlog:cds", + "-Xlog:aot", "-cp", appJar, helloClass); out = CDSTestUtils.executeAndLog(pb, "prod"); out.shouldContain("Using AOT-linked classes: false (static archive: no aot-linked classes)"); @@ -345,7 +345,7 @@ public class AOTFlags { out.shouldHaveExitValue(0); pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-Xlog:cds", + "-Xlog:aot", "-XX:AOTMode=on", "-XX:AOTCache=" + dynamicArchive, "--version"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/ArchiveRelocationTest.java b/test/hotspot/jtreg/runtime/cds/appcds/ArchiveRelocationTest.java index 985fe23fab2..21a43fcf9cb 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/ArchiveRelocationTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/ArchiveRelocationTest.java @@ -64,7 +64,7 @@ public class ArchiveRelocationTest { String maybeRelocation = "-XX:ArchiveRelocationMode=0"; String alwaysRelocation = "-XX:ArchiveRelocationMode=1"; String runRelocArg = run_reloc ? alwaysRelocation : maybeRelocation; - String logArg = "-Xlog:cds=debug,cds+reloc=debug,cds+heap"; + String logArg = "-Xlog:cds=debug,cds+reloc=debug,aot+heap"; String unlockArg = "-XX:+UnlockDiagnosticVMOptions"; String nmtArg = "-XX:NativeMemoryTracking=detail"; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/ClassListFormatBase.java b/test/hotspot/jtreg/runtime/cds/appcds/ClassListFormatBase.java index 0fd55b4a4a0..1d224a7765d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/ClassListFormatBase.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/ClassListFormatBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -41,7 +41,7 @@ public class ClassListFormatBase { System.out.println("------------------------------"); try { - OutputAnalyzer output = TestCommon.dump(appJar, appClasses, "-Xlog:cds+lambda=debug"); + OutputAnalyzer output = TestCommon.dump(appJar, appClasses, "-Xlog:aot+lambda=debug"); output.shouldHaveExitValue(1); for (String s : expected_errors) { output.shouldContain(s); @@ -63,7 +63,7 @@ public class ClassListFormatBase { System.out.println("------------------------------"); try { - OutputAnalyzer output = TestCommon.dump(appJar, appClasses, "-Xlog:cds", "-Xlog:cds+lambda=debug"); + OutputAnalyzer output = TestCommon.dump(appJar, appClasses, "-Xlog:cds", "-Xlog:aot", "-Xlog:aot+lambda=debug"); output.shouldHaveExitValue(0); output.shouldContain("Dumping"); for (String s : expected_msgs) { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/DumpingWithNoCoops.java b/test/hotspot/jtreg/runtime/cds/appcds/DumpingWithNoCoops.java index 479643f8efc..b5fc35ad149 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/DumpingWithNoCoops.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/DumpingWithNoCoops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -94,7 +94,7 @@ public class DumpingWithNoCoops { public static void main(String[] args) throws Exception { final String noCoops = "-XX:-UseCompressedOops"; - final String logArg = "-Xlog:gc+heap=trace,cds=debug"; + final String logArg = "-Xlog:gc+heap=trace,cds=debug,aot=debug"; JarBuilder.getOrCreateHelloJar(); String appJar = TestCommon.getTestJar("hello.jar"); String appClasses[] = TestCommon.list("Hello"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithJavaAgent.java b/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithJavaAgent.java index 955c07ac7a6..f92acda4397 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithJavaAgent.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithJavaAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -81,7 +81,7 @@ public class LambdaWithJavaAgent { // run with archive CDSOptions runOpts = (new CDSOptions()) - .addPrefix("-cp", appJar, "-Xlog:class+load,cds=debug", + .addPrefix("-cp", appJar, "-Xlog:class+load=debug,cds=debug,class+path=debug", "-XX:+UnlockDiagnosticVMOptions", "-XX:+AllowArchivingWithJavaAgent", useJavaAgent) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTCacheSupportForCustomLoaders.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTCacheSupportForCustomLoaders.java index 1fec4dc3e23..ae00477e67b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTCacheSupportForCustomLoaders.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTCacheSupportForCustomLoaders.java @@ -60,15 +60,15 @@ public class AOTCacheSupportForCustomLoaders { SimpleCDSAppTester.of("AOTCacheSupportForCustomLoaders") .classpath("app.jar") - .addVmArgs("-Xlog:cds+class=debug", "-Xlog:cds", + .addVmArgs("-Xlog:aot+class=debug", "-Xlog:aot", "-Xlog:cds", "--module-path=" + modulePath, "--add-modules=com.test") .appCommandLine("AppWithCustomLoaders", modulePath) .setAssemblyChecker((OutputAnalyzer out) -> { - out.shouldMatch("cds,class.*unreg AppWithCustomLoaders[$]MyLoadeeA") - .shouldMatch("cds,class.*unreg com.test.Foo") - .shouldMatch("cds,class.*array \\[LAppWithCustomLoaders[$]MyLoadeeA;") - .shouldNotMatch("cds,class.* ReturnIntegerAsString"); + out.shouldMatch(",class.*unreg AppWithCustomLoaders[$]MyLoadeeA") + .shouldMatch(",class.*unreg com.test.Foo") + .shouldMatch(",class.*array \\[LAppWithCustomLoaders[$]MyLoadeeA;") + .shouldNotMatch(",class.* ReturnIntegerAsString"); }) .setProductionChecker((OutputAnalyzer out) -> { out.shouldContain("Using AOT-linked classes: true"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTLoggingTag.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTLoggingTag.java new file mode 100644 index 00000000000..5499063ebbd --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/AOTLoggingTag.java @@ -0,0 +1,114 @@ +/* + * 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. + * + */ + + +/* + * @test + * @summary when AOT cache options are used, old "cds" logs should be aliased to "aot". + * @requires vm.cds + * @requires vm.flagless + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds/test-classes + * @build Hello + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar hello.jar Hello + * @run driver AOTLoggingTag + */ + +import java.io.File; +import jdk.test.lib.cds.CDSTestUtils; +import jdk.test.lib.helpers.ClassFileInstaller; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class AOTLoggingTag { + static String appJar = ClassFileInstaller.getJarPath("hello.jar"); + static String aotConfigFile = "hello.aotconfig"; + static String aotCacheFile = "hello.aot"; + static String helloClass = "Hello"; + + public static void main(String[] args) throws Exception { + ProcessBuilder pb; + OutputAnalyzer out; + + //---------------------------------------------------------------------- + printTestCase("Training Run"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:AOTMode=record", + "-XX:AOTConfiguration=" + aotConfigFile, + "-Xlog:aot", + "-cp", appJar, helloClass); + + out = CDSTestUtils.executeAndLog(pb, "train"); + out.shouldContain("[info][aot] Writing binary AOTConfiguration file:"); + out.shouldHaveExitValue(0); + + //---------------------------------------------------------------------- + printTestCase("Assembly Phase"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:AOTMode=create", + "-XX:AOTConfiguration=" + aotConfigFile, + "-XX:AOTCache=" + aotCacheFile, + "-Xlog:aot", + "-cp", appJar); + out = CDSTestUtils.executeAndLog(pb, "asm"); + out.shouldContain("[info][aot] Opened AOT configuration file hello.aotconfig"); + out.shouldHaveExitValue(0); + + //---------------------------------------------------------------------- + printTestCase("Production Run with AOTCache"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:AOTCache=" + aotCacheFile, + "-Xlog:aot", + "-cp", appJar, helloClass); + out = CDSTestUtils.executeAndLog(pb, "prod"); + out.shouldContain("[info][aot] Opened AOT cache hello.aot"); + out.shouldHaveExitValue(0); + + //---------------------------------------------------------------------- + printTestCase("All old -Xlog:cds+heap logs have been changed to -Xlog:aot+heap should alias to -Xlog:cds+heap"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:AOTCache=" + aotCacheFile, + "-Xlog:aot+heap", + "-cp", appJar, helloClass); + out = CDSTestUtils.executeAndLog(pb, "prod"); + out.shouldNotContain("No tag set matches selection: aot+heap"); + out.shouldContain("[info][aot,heap] resolve subgraph java.lang.Integer$IntegerCache"); + out.shouldHaveExitValue(0); + + //---------------------------------------------------------------------- + printTestCase("Production Run: errors should be printed with [aot] decoration"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:AOTCache=nosuchfile.aot", + "-XX:AOTMode=on", + "-cp", appJar, helloClass); + out = CDSTestUtils.executeAndLog(pb, "prod"); + out.shouldContain("[error][aot] An error has occurred while processing the AOT cache. Run with -Xlog:aot for details."); + out.shouldNotHaveExitValue(0); + } + + static int testNum = 0; + static void printTestCase(String s) { + System.out.println("vvvvvvv TEST CASE " + testNum + ": " + s + " starts here vvvvvvv"); + testNum++; + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/VerifierFailOver.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/VerifierFailOver.java index e53775a2041..18caa08c117 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotCache/VerifierFailOver.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCache/VerifierFailOver.java @@ -41,7 +41,7 @@ import jdk.test.lib.process.OutputAnalyzer; public class VerifierFailOver { public static void main(String... args) throws Exception { SimpleCDSAppTester.of("VerifierFailOver") - .addVmArgs("-Xlog:cds+class=debug") + .addVmArgs("-Xlog:aot+class=debug") .classpath("app.jar") .appCommandLine("VerifierFailOverApp") .setTrainingChecker((OutputAnalyzer out) -> { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java index 5db41236a67..96f08004fb2 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTCacheWithZGC.java @@ -42,7 +42,7 @@ import jdk.test.lib.process.OutputAnalyzer; public class AOTCacheWithZGC { public static void main(String... args) throws Exception { SimpleCDSAppTester.of("AOTCacheWithZGC") - .addVmArgs("-XX:+UseZGC", "-Xlog:cds") + .addVmArgs("-XX:+UseZGC", "-Xlog:cds", "-Xlog:aot") .classpath("app.jar") .appCommandLine("AOTCacheWithZGCApp") .setProductionChecker((OutputAnalyzer out) -> { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTClassLinkingVMOptions.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTClassLinkingVMOptions.java index 7aef13abac7..bee0fa60f49 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTClassLinkingVMOptions.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTClassLinkingVMOptions.java @@ -124,12 +124,14 @@ public class AOTClassLinkingVMOptions { "--module-path", modulePath, "-XX:+AOTClassLinking", "-m", MAIN_MODULE); - TestCommon.run("-Xlog:cds", + TestCommon.run("-Xlog:aot", + "-Xlog:cds", "--module-path", modulePath, "-m", MAIN_MODULE) .assertNormalExit("Using AOT-linked classes: true"); - TestCommon.run("-Xlog:cds", + TestCommon.run("-Xlog:aot", + "-Xlog:cds", "--module-path", modulePath + "/bad", "-m", MAIN_MODULE) .assertAbnormalExit("shared archive file has aot-linked classes. It cannot be used when archived full module graph is not used."); @@ -139,7 +141,8 @@ public class AOTClassLinkingVMOptions { "--module-path", modulePath, "-XX:+AOTClassLinking", "--add-modules", MAIN_MODULE); - TestCommon.run("-Xlog:cds", + TestCommon.run("-Xlog:aot", + "-Xlog:cds", "--module-path", modulePath, "--add-modules", MAIN_MODULE, MAIN_CLASS) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java index aa34f479936..90fd0f33bab 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java @@ -137,7 +137,7 @@ public class BulkLoaderTest { @Override public String[] vmArgs(RunMode runMode) { return new String[] { - "-Xlog:cds,cds+aot+load,cds+class=debug", + "-Xlog:cds,aot+load,cds+class=debug,aot+class=debug", "-XX:+AOTClassLinking", }; } @@ -158,7 +158,7 @@ public class BulkLoaderTest { if (isDumping(runMode)) { // Check that we are archiving classes for custom class loaders. - out.shouldMatch("cds,class.* SimpleCusty"); + out.shouldMatch(",class.* SimpleCusty"); } } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/FakeCodeLocation.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/FakeCodeLocation.java index 5bec6623a08..1ffc904963a 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/FakeCodeLocation.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/FakeCodeLocation.java @@ -73,7 +73,9 @@ public class FakeCodeLocation { @Override public String[] vmArgs(RunMode runMode) { String[] args = new String[] { + "-Xlog:aot", "-Xlog:cds", + "-Xlog:aot+class=debug", "-Xlog:cds+class=debug", "-Xlog:class+load", }; @@ -94,9 +96,9 @@ public class FakeCodeLocation { @Override public void checkExecution(OutputAnalyzer out, RunMode runMode) throws Exception { if (isDumping(runMode)) { - out.shouldMatch("cds,class.* FakeCodeLocationApp"); - out.shouldNotMatch("cds,class.* ClassNotInJar1"); - out.shouldNotMatch("cds,class.* ClassNotInJar2"); + out.shouldMatch(",class.* FakeCodeLocationApp"); + out.shouldNotMatch(",class.* ClassNotInJar1"); + out.shouldNotMatch(",class.* ClassNotInJar2"); } if (runMode.isProductionRun()) { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCompressedOopsTest.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCompressedOopsTest.java index 40bd8ee1a88..524b613b5c3 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCompressedOopsTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCompressedOopsTest.java @@ -125,7 +125,7 @@ public class AOTCodeCompressedOopsTest { case RunMode.ASSEMBLY: { List args = getVMArgsForHeapConfig(zeroBaseInAsmPhase, zeroShiftInAsmPhase); args.addAll(List.of("-XX:+UnlockDiagnosticVMOptions", - "-Xlog:cds=info", + "-Xlog:aot=info", "-Xlog:aot+codecache+init=debug", "-Xlog:aot+codecache+exit=debug")); return args.toArray(new String[0]); @@ -133,7 +133,7 @@ public class AOTCodeCompressedOopsTest { case RunMode.PRODUCTION: { List args = getVMArgsForHeapConfig(zeroBaseInProdPhase, zeroShiftInProdPhase); args.addAll(List.of("-XX:+UnlockDiagnosticVMOptions", - "-Xlog:cds=info", // we need this to parse CompressedOops settings + "-Xlog:aot=info", // we need this to parse CompressedOops settings "-Xlog:aot+codecache+init=debug", "-Xlog:aot+codecache+exit=debug")); return args.toArray(new String[0]); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java index ca5a08d20af..819db99a549 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -77,7 +77,7 @@ public class ArchiveHeapTestClass { extraOpts = TestCommon.concat(extraOpts, "-Xbootclasspath/a:" + bootJar, "-XX:ArchiveHeapTestClass=" + bootClass, - "-Xlog:cds+heap"); + "-Xlog:aot+heap"); return TestCommon.dump(appJar, classlist, extraOpts); } @@ -109,13 +109,13 @@ public class ArchiveHeapTestClass { testCase("Simple positive case"); output = dumpBootAndHello(CDSTestClassA_name); mustSucceed(output, CDSTestClassA.getOutput()); // make sure is executed - output.shouldMatch("warning.*cds.*Loading ArchiveHeapTestClass " + CDSTestClassA_name); - output.shouldMatch("warning.*cds.*Initializing ArchiveHeapTestClass " + CDSTestClassA_name); + output.shouldMatch("warning.*aot.*Loading ArchiveHeapTestClass " + CDSTestClassA_name); + output.shouldMatch("warning.*aot.*Initializing ArchiveHeapTestClass " + CDSTestClassA_name); output.shouldContain("Archived field " + CDSTestClassA_name + "::" + ARCHIVE_TEST_FIELD_NAME); output.shouldMatch("Archived object klass CDSTestClassA .*\\[LCDSTestClassA;"); output.shouldMatch("Archived object klass CDSTestClassA .*CDSTestClassA\\$YY"); - TestCommon.run("-Xbootclasspath/a:" + bootJar, "-cp", appJar, "-Xlog:cds+heap", CDSTestClassA_name) + TestCommon.run("-Xbootclasspath/a:" + bootJar, "-cp", appJar, "-Xlog:aot+heap", CDSTestClassA_name) .assertNormalExit(CDSTestClassA.getOutput(), "resolve subgraph " + CDSTestClassA_name); @@ -169,7 +169,7 @@ public class ArchiveHeapTestClass { output = dumpBootAndHello(CDSTestClassG_name, "-XX:+AOTClassLinking", "-Xlog:cds+class=debug"); mustSucceed(output); - TestCommon.run("-Xbootclasspath/a:" + bootJar, "-cp", appJar, "-Xlog:cds+heap,cds+init", + TestCommon.run("-Xbootclasspath/a:" + bootJar, "-cp", appJar, "-Xlog:aot+heap,cds+init", CDSTestClassG_name) .assertNormalExit("init subgraph " + CDSTestClassG_name, "Initialized from CDS"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java index db2b4718fd2..e476382c8c9 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -47,7 +47,7 @@ public class ArrayKlasses extends DynamicArchiveTestBase { final String appJar = ClassFileInstaller.getJarPath("ArrayKlasses.jar"); final String mainClass = "ArrayKlassesApp"; final String runtimeLogOptions = - "-Xlog:class+load,class+load+array=debug,cds+dynamic=debug,cds=debug,cds+unshareable=trace"; + "-Xlog:class+load,class+load+array=debug,cds+dynamic=debug,cds=debug,aot+unshareable=trace"; // Case 1 // Create a dynamic archive with the ArrayKlassesApp app class and its diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicLotsOfClasses.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicLotsOfClasses.java index e7f45766189..f2bff62a812 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicLotsOfClasses.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicLotsOfClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -77,7 +77,7 @@ public class DynamicLotsOfClasses extends DynamicArchiveTestBase { "ALL-SYSTEM", "-Xlog:hashtables", "-Xmx500m", - "-Xlog:cds=debug", // test detailed metadata info printing + "-Xlog:cds=debug,aot=debug", // test detailed metadata info printing "-Xlog:cds+dynamic=info", bootClassPath, "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/ExactOptionMatch.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/ExactOptionMatch.java index dd8f186af80..7e4efc70a4e 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/ExactOptionMatch.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/ExactOptionMatch.java @@ -71,7 +71,7 @@ public class ExactOptionMatch { TestCommon.dumpBaseArchive(archiveName, o.cmdLine(), o.valueA()) .shouldHaveExitValue(0); - TestCommon.execCommon("-Xlog:cds", "--version") + TestCommon.execCommon("-Xlog:aot", "-Xlog:cds", "--version") .shouldMatch("Mismatched values for property " + o.property() + ": j.*specified during dump time but not during runtime") .shouldContain(FMG_DISABLED); @@ -79,7 +79,7 @@ public class ExactOptionMatch { TestCommon.dumpBaseArchive(archiveName) .shouldHaveExitValue(0); - TestCommon.execCommon("-Xlog:cds", o.cmdLine(), o.valueA(), "--version") + TestCommon.execCommon("-Xlog:aot", "-Xlog:cds", o.cmdLine(), o.valueA(), "--version") .shouldMatch("Mismatched values for property " + o.property() + ": j.*specified during runtime but not during dump time") .shouldContain(FMG_DISABLED); @@ -88,18 +88,18 @@ public class ExactOptionMatch { .shouldHaveExitValue(0); // (3.1) Run = specified once - TestCommon.execCommon("-Xlog:cds", o.cmdLine(), o.valueA(), "--version") + TestCommon.execCommon("-Xlog:aot", "-Xlog:cds", o.cmdLine(), o.valueA(), "--version") .shouldMatch("Mismatched values for property " + o.property() + ": runtime.*dump time") .shouldContain(FMG_DISABLED); // (3.2) Run = specified twice (same order) // Should still be able to use FMG. - TestCommon.execCommon("-Xlog:cds", o.cmdLine(), o.valueA(), o.cmdLine(), o.valueB(), "--version") + TestCommon.execCommon("-Xlog:aot", "-Xlog:cds", o.cmdLine(), o.valueA(), o.cmdLine(), o.valueB(), "--version") .shouldContain(FMG_ENABLED); // (3.3) Run = specified twice (but in different order) // Should still be able to use FMG (values are sorted by CDS). - TestCommon.execCommon("-Xlog:cds", o.cmdLine(), o.valueB(), o.cmdLine(), o.valueA(), "--version") + TestCommon.execCommon("-Xlog:aot", "-Xlog:cds", o.cmdLine(), o.valueB(), o.cmdLine(), o.valueA(), "--version") .shouldContain(FMG_ENABLED); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java index 7ce3e37cc8a..d1022fc7956 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 @@ -45,7 +45,7 @@ public class AddmodsOption { final String multiModules = ",,jdk.jconsole,jdk.compiler,,"; final String allSystem = "ALL-SYSTEM"; final String allModulePath = "ALL-MODULE-PATH"; - final String loggingOption = "-Xlog:cds=debug,cds+module=debug,cds+heap=info,module=trace"; + final String loggingOption = "-Xlog:aot=debug,cds+module=debug,aot+heap=info,cds=debug,module=trace"; final String versionPattern = "java.[0-9][0-9].*"; final String subgraphCannotBeUsed = "subgraph jdk.internal.module.ArchivedBootLayer cannot be used because full module graph is disabled"; final String warningIncubator = "WARNING: Using incubator modules: jdk.incubator.vector"; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addopens/AddopensOption.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addopens/AddopensOption.java index 81b24d15f9e..ec41c4ed28b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addopens/AddopensOption.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addopens/AddopensOption.java @@ -41,7 +41,7 @@ public class AddopensOption { final String moduleOption = "jdk.httpserver/sun.net.httpserver.simpleserver.Main"; final String addOpensNio = "java.base/java.nio=ALL-UNNAMED"; final String addOpensTimeFormat = "java.base/java.time.format=ALL-UNNAMED"; - final String loggingOption = "-Xlog:cds=debug,cds+module=debug,cds+heap=info,module=trace"; + final String loggingOption = "-Xlog:aot=debug,cds+module=debug,aot+heap=info,cds=debug,module=trace"; final String versionPattern = "java.[0-9][0-9].*"; final String subgraphCannotBeUsed = "subgraph jdk.internal.module.ArchivedBootLayer cannot be used because full module graph is disabled"; final String warningIncubator = "WARNING: Using incubator modules: jdk.incubator.vector"; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java index d9dcd593430..861efbf5690 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 @@ -37,7 +37,7 @@ public class ModuleOption { public static void main(String[] args) throws Exception { final String moduleOption = "jdk.httpserver/sun.net.httpserver.simpleserver.Main"; final String incubatorModule = "jdk.incubator.vector"; - final String loggingOption = "-Xlog:cds=debug,cds+module=debug,cds+heap=info,module=trace"; + final String loggingOption = "-Xlog:aot=debug,cds+module=debug,aot+heap=info,cds=debug,module=trace"; // Pattern of a module version string. // e.g. JDK 22: "java 22" // JDK 22.0.1: "java 22.0.1" diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/CFLH/ClassFileLoadHookTest.java b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/CFLH/ClassFileLoadHookTest.java index a49054d10a1..2674793c04a 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/CFLH/ClassFileLoadHookTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/CFLH/ClassFileLoadHookTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -103,6 +103,7 @@ public class ClassFileLoadHookTest { "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", useWb, "-agentlib:SimpleClassFileLoadHook=LoadMe,beforeHook,after_Hook", + "-Xlog:aot", "-Xlog:cds", "ClassFileLoadHook", "" + ClassFileLoadHook.TestCaseId.SHARING_ON_CFLH_ON); diff --git a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClasses.java b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClasses.java index 25763e59b1c..5e561ed8b31 100644 --- a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClasses.java +++ b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -166,6 +166,7 @@ public class ReplaceCriticalClasses { .setArchiveName(ReplaceCriticalClasses.class.getName() + ".jsa") .setUseVersion(false) .addSuffix("-showversion", + "-Xlog:aot", "-Xlog:cds", "-XX:+UnlockDiagnosticVMOptions", agent); @@ -173,7 +174,7 @@ public class ReplaceCriticalClasses { opts.addSuffix("-XX:+WhiteBoxAPI", "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar")); } - opts.addSuffix("-Xlog:cds,cds+heap"); + opts.addSuffix("-Xlog:aot,aot+heap,cds"); opts.addSuffix("ReplaceCriticalClasses", "child", shared, diff --git a/test/lib/jdk/test/lib/cds/CDSAppTester.java b/test/lib/jdk/test/lib/cds/CDSAppTester.java index 0a21e340cc6..edda9d45efa 100644 --- a/test/lib/jdk/test/lib/cds/CDSAppTester.java +++ b/test/lib/jdk/test/lib/cds/CDSAppTester.java @@ -242,6 +242,7 @@ abstract public class CDSAppTester { "-XX:AOTConfiguration=" + aotConfigurationFile, logToFile(aotConfigurationFileLog, "class+load=debug", + "aot=debug", "cds=debug", "cds+class=debug")); cmdLine = addCommonVMArgs(runMode, cmdLine); @@ -264,15 +265,17 @@ abstract public class CDSAppTester { private OutputAnalyzer dumpStaticArchive() throws Exception { RunMode runMode = RunMode.DUMP_STATIC; String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode), + "-Xlog:aot", + "-Xlog:aot+heap=error", "-Xlog:cds", - "-Xlog:cds+heap=error", "-Xshare:dump", "-XX:SharedArchiveFile=" + staticArchiveFile, "-XX:SharedClassListFile=" + classListFile, logToFile(staticArchiveFileLog, + "aot=debug", "cds=debug", "cds+class=debug", - "cds+heap=warning", + "aot+heap=warning", "cds+resolve=debug")); cmdLine = addCommonVMArgs(runMode, cmdLine); cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode)); @@ -282,15 +285,17 @@ abstract public class CDSAppTester { private OutputAnalyzer createAOTCache() throws Exception { RunMode runMode = RunMode.ASSEMBLY; String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode), + "-Xlog:aot", + "-Xlog:aot+heap=error", "-Xlog:cds", - "-Xlog:cds+heap=error", "-XX:AOTMode=create", "-XX:AOTConfiguration=" + aotConfigurationFile, "-XX:AOTCache=" + aotCacheFile, logToFile(aotCacheFileLog, + "aot=debug", "cds=debug", "cds+class=debug", - "cds+heap=warning", + "aot+heap=warning", "cds+resolve=debug")); cmdLine = addCommonVMArgs(runMode, cmdLine); cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode)); @@ -331,9 +336,11 @@ abstract public class CDSAppTester { if (isDynamicWorkflow()) { // "classic" dynamic archive cmdLine = StringArrayUtils.concat(vmArgs(runMode), + "-Xlog:aot", "-Xlog:cds", "-XX:ArchiveClassesAtExit=" + dynamicArchiveFile, logToFile(dynamicArchiveFileLog, + "aot=debug", "cds=debug", "cds+class=debug", "cds+resolve=debug", @@ -362,7 +369,7 @@ abstract public class CDSAppTester { String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode), "-XX:+UnlockDiagnosticVMOptions", "-XX:VerifyArchivedFields=2", // make sure archived heap objects are good. - logToFile(productionRunLog(), "cds")); + logToFile(productionRunLog(), "aot", "cds")); cmdLine = addCommonVMArgs(runMode, cmdLine); if (isStaticWorkflow()) {