--- old/src/share/vm/classfile/compactHashtable.cpp 2017-05-31 15:52:03.996225278 -0400 +++ new/src/share/vm/classfile/compactHashtable.cpp 2017-05-31 15:52:03.544225293 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "classfile/compactHashtable.inline.hpp" #include "classfile/javaClasses.hpp" +#include "logging/logMessage.hpp" #include "memory/metadataFactory.hpp" #include "memory/metaspaceShared.hpp" #include "prims/jvm.h" @@ -146,22 +147,27 @@ cht->init(base_address, _num_entries, _num_buckets, _compact_buckets->data(), _compact_entries->data()); - if (PrintSharedSpaces) { + if (log_is_enabled(Info, cds, hashtables)) { + ResourceMark rm; + LogMessage(cds, hashtables) msg; + stringStream info_stream; + double avg_cost = 0.0; if (_num_entries > 0) { avg_cost = double(table_bytes)/double(_num_entries); } - tty->print_cr("Shared %s table stats -------- base: " PTR_FORMAT, - table_name, (intptr_t)base_address); - tty->print_cr("Number of entries : %9d", _num_entries); - tty->print_cr("Total bytes used : %9d", table_bytes); - tty->print_cr("Average bytes per entry : %9.3f", avg_cost); - tty->print_cr("Average bucket size : %9.3f", summary.avg()); - tty->print_cr("Variance of bucket size : %9.3f", summary.variance()); - tty->print_cr("Std. dev. of bucket size: %9.3f", summary.sd()); - tty->print_cr("Empty buckets : %9d", _num_empty_buckets); - tty->print_cr("Value_Only buckets : %9d", _num_value_only_buckets); - tty->print_cr("Other buckets : %9d", _num_other_buckets); + info_stream.print_cr("Shared %s table stats -------- base: " PTR_FORMAT, + table_name, (intptr_t)base_address); + info_stream.print_cr("Number of entries : %9d", _num_entries); + info_stream.print_cr("Total bytes used : %9d", table_bytes); + info_stream.print_cr("Average bytes per entry : %9.3f", avg_cost); + info_stream.print_cr("Average bucket size : %9.3f", summary.avg()); + info_stream.print_cr("Variance of bucket size : %9.3f", summary.variance()); + info_stream.print_cr("Std. dev. of bucket size: %9.3f", summary.sd()); + info_stream.print_cr("Empty buckets : %9d", _num_empty_buckets); + info_stream.print_cr("Value_Only buckets : %9d", _num_value_only_buckets); + info_stream.print_cr("Other buckets : %9d", _num_other_buckets); + msg.info("%s", info_stream.as_string()); } } --- old/src/share/vm/classfile/stringTable.cpp 2017-05-31 15:52:08.516225120 -0400 +++ new/src/share/vm/classfile/stringTable.cpp 2017-05-31 15:52:07.192225166 -0400 @@ -30,6 +30,7 @@ #include "classfile/systemDictionary.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "gc/shared/gcLocker.inline.hpp" +#include "logging/log.hpp" #include "memory/allocation.inline.hpp" #include "memory/filemap.hpp" #include "memory/resourceArea.hpp" @@ -737,14 +738,12 @@ _shared_table.reset(); if (soc->writing()) { if (!(UseG1GC && UseCompressedOops && UseCompressedClassPointers)) { - if (PrintSharedSpaces) { - tty->print_cr( + log_info(cds)( "Shared strings are excluded from the archive as UseG1GC, " "UseCompressedOops and UseCompressedClassPointers are required." "Current settings: UseG1GC=%s, UseCompressedOops=%s, UseCompressedClassPointers=%s.", BOOL_TO_STR(UseG1GC), BOOL_TO_STR(UseCompressedOops), BOOL_TO_STR(UseCompressedClassPointers)); - } } else { int num_buckets = the_table()->number_of_entries() / SharedSymbolTableBucketSize; --- old/src/share/vm/logging/logTag.hpp 2017-05-31 15:52:12.420224984 -0400 +++ new/src/share/vm/logging/logTag.hpp 2017-05-31 15:52:10.592225048 -0400 @@ -44,6 +44,7 @@ LOG_TAG(blocks) \ LOG_TAG(bot) \ LOG_TAG(breakpoint) \ + LOG_TAG(cds) \ LOG_TAG(census) \ LOG_TAG(class) \ LOG_TAG(classhisto) \ --- old/src/share/vm/memory/filemap.cpp 2017-05-31 15:52:13.788224937 -0400 +++ new/src/share/vm/memory/filemap.cpp 2017-05-31 15:52:13.336224952 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -32,6 +32,8 @@ #if INCLUDE_ALL_GCS #include "gc/g1/g1CollectedHeap.hpp" #endif +#include "logging/log.hpp" +#include "logging/logMessage.hpp" #include "memory/filemap.hpp" #include "memory/metadataFactory.hpp" #include "memory/oopFactory.hpp" @@ -98,9 +100,11 @@ if (RequireSharedSpaces) { fail(msg, ap); } else { - if (PrintSharedSpaces) { - tty->print("UseSharedSpaces: "); - tty->vprint_cr(msg, ap); + if (log_is_enabled(Info, cds)) { + ResourceMark rm; + outputStream* logstream = Log(cds)::info_stream(); + logstream->print("UseSharedSpaces: "); + logstream->vprint_cr(msg, ap); } } UseSharedSpaces = false; @@ -418,9 +422,13 @@ void FileMapInfo::open_for_write() { _full_path = Arguments::GetSharedArchivePath(); - if (PrintSharedSpaces) { - tty->print_cr("Dumping shared data to file: "); - tty->print_cr(" %s", _full_path); + if (log_is_enabled(Info, cds)) { + ResourceMark rm; + LogMessage(cds) msg; + stringStream info_stream; + info_stream.print_cr("Dumping shared data to file: "); + info_stream.print_cr(" %s", _full_path); + msg.info("%s", info_stream.as_string()); } #ifdef _WINDOWS // On Windows, need WRITE permission to remove the file. @@ -477,10 +485,9 @@ if (_file_open) { guarantee(si->_file_offset == _file_offset, "file offset mismatch."); - if (PrintSharedSpaces) { - tty->print_cr("Shared file region %d: " SIZE_FORMAT_HEX_W(6) " bytes, addr " INTPTR_FORMAT - " file offset " SIZE_FORMAT_HEX_W(6), region, size, p2i(base), _file_offset); - } + log_info(cds)("Shared file region %d: " SIZE_FORMAT_HEX_W(6) + " bytes, addr " INTPTR_FORMAT " file offset " SIZE_FORMAT_HEX_W(6), + region, size, p2i(base), _file_offset); } else { si->_file_offset = _file_offset; } @@ -691,11 +698,11 @@ narrow_oop_shift() != Universe::narrow_oop_shift() || narrow_klass_base() != Universe::narrow_klass_base() || narrow_klass_shift() != Universe::narrow_klass_shift()) { - if (PrintSharedSpaces && _header->_space[MetaspaceShared::first_string]._used > 0) { - tty->print_cr("Shared string data from the CDS archive is being ignored. " - "The current CompressedOops/CompressedClassPointers encoding differs from " - "that archived due to heap size change. The archive was dumped using max heap " - "size " UINTX_FORMAT "M.", max_heap_size()/M); + if (log_is_enabled(Info, cds) && _header->_space[MetaspaceShared::first_string]._used > 0) { + log_info(cds)("Shared string data from the CDS archive is being ignored. " + "The current CompressedOops/CompressedClassPointers encoding differs from " + "that archived due to heap size change. The archive was dumped using max heap " + "size " UINTX_FORMAT "M.", max_heap_size()/M); } } else { string_ranges = new MemRegion[MetaspaceShared::max_strings]; @@ -761,8 +768,8 @@ return true; } } else { - if (PrintSharedSpaces && _header->_space[MetaspaceShared::first_string]._used > 0) { - tty->print_cr("Shared string data from the CDS archive is being ignored. UseG1GC, " + if (log_is_enabled(Info, cds) && _header->_space[MetaspaceShared::first_string]._used > 0) { + log_info(cds)("Shared string data from the CDS archive is being ignored. UseG1GC, " "UseCompressedOops and UseCompressedClassPointers are required."); } } --- old/src/share/vm/memory/metadataFactory.hpp 2017-05-31 15:52:15.176224888 -0400 +++ new/src/share/vm/memory/metadataFactory.hpp 2017-05-31 15:52:14.724224904 -0400 @@ -80,7 +80,7 @@ template static void free_metadata(ClassLoaderData* loader_data, T md) { if (DumpSharedSpaces) { - // FIXME: the freeing code is buggy, especially when PrintSharedSpaces is enabled. + // FIXME: the freeing code is buggy, especially when -Xlog:cds is enabled. // Disable for now -- this means if you specify bad classes in your classlist you // may have wasted space inside the archive. return; --- old/src/share/vm/memory/metaspace.cpp 2017-05-31 15:52:16.548224840 -0400 +++ new/src/share/vm/memory/metaspace.cpp 2017-05-31 15:52:16.092224856 -0400 @@ -3569,7 +3569,7 @@ assert(!SafepointSynchronize::is_at_safepoint() || Thread::current()->is_VM_thread(), "should be the VM thread"); - if (DumpSharedSpaces && PrintSharedSpaces) { + if (DumpSharedSpaces && log_is_enabled(Info, cds)) { record_deallocation(ptr, vsm()->get_allocation_word_size(word_size)); } @@ -3603,7 +3603,7 @@ if (result == NULL) { report_out_of_shared_space(read_only ? SharedReadOnly : SharedReadWrite); } - if (PrintSharedSpaces) { + if (log_is_enabled(Info, cds)) { space->record_allocation(result, type, space->vsm()->get_allocation_word_size(word_size)); } --- old/src/share/vm/memory/metaspaceShared.cpp 2017-05-31 15:52:17.944224792 -0400 +++ new/src/share/vm/memory/metaspaceShared.cpp 2017-05-31 15:52:17.496224807 -0400 @@ -36,6 +36,8 @@ #include "gc/shared/gcLocker.hpp" #include "interpreter/bytecodeStream.hpp" #include "interpreter/bytecodes.hpp" +#include "logging/log.hpp" +#include "logging/logMessage.hpp" #include "memory/filemap.hpp" #include "memory/metaspace.hpp" #include "memory/metaspaceShared.hpp" @@ -330,9 +332,7 @@ // We already checked (and, if necessary, adjusted n) when the vtables were allocated, so we are // safe to do memcpy. - if (PrintSharedSpaces) { - tty->print_cr("Copying %3d vtable entries for %s", n, name); - } + log_debug(cds, vtables)("Copying %3d vtable entries for %s", n, name); memcpy(dstvtable, srcvtable, sizeof(intptr_t) * n); return dstvtable + n; } @@ -383,9 +383,7 @@ break; } } - if (PrintSharedSpaces) { - tty->print_cr("Found %3d vtable entries for %s", vtable_len, name); - } + log_debug(cds, vtables)("Found %3d vtable entries for %s", vtable_len, name); return vtable_len; } @@ -628,9 +626,13 @@ const char *sep = "--------------------+---------------------------+---------------------------+--------------------------"; const char *hdr = " ro_cnt ro_bytes % | rw_cnt rw_bytes % | all_cnt all_bytes %"; - tty->print_cr("Detailed metadata info (rw includes md and mc):"); - tty->print_cr("%s", hdr); - tty->print_cr("%s", sep); + ResourceMark rm; + LogMessage(cds) msg; + stringStream info_stream; + + info_stream.print_cr("Detailed metadata info (rw includes md and mc):"); + info_stream.print_cr("%s", hdr); + info_stream.print_cr("%s", sep); for (int type = 0; type < int(_number_of_types); type ++) { const char *name = type_name((Type)type); int ro_count = _counts[RO][type]; @@ -644,10 +646,10 @@ double rw_perc = 100.0 * double(rw_bytes) / double(rw_all); double perc = 100.0 * double(bytes) / double(ro_all + rw_all); - tty->print_cr(fmt_stats, name, - ro_count, ro_bytes, ro_perc, - rw_count, rw_bytes, rw_perc, - count, bytes, perc); + info_stream.print_cr(fmt_stats, name, + ro_count, ro_bytes, ro_perc, + rw_count, rw_bytes, rw_perc, + count, bytes, perc); all_ro_count += ro_count; all_ro_bytes += ro_bytes; @@ -662,14 +664,16 @@ double all_rw_perc = 100.0 * double(all_rw_bytes) / double(rw_all); double all_perc = 100.0 * double(all_bytes) / double(ro_all + rw_all); - tty->print_cr("%s", sep); - tty->print_cr(fmt_stats, "Total", - all_ro_count, all_ro_bytes, all_ro_perc, - all_rw_count, all_rw_bytes, all_rw_perc, - all_count, all_bytes, all_perc); + info_stream.print_cr("%s", sep); + info_stream.print_cr(fmt_stats, "Total", + all_ro_count, all_ro_bytes, all_ro_perc, + all_rw_count, all_rw_bytes, all_rw_perc, + all_count, all_bytes, all_perc); assert(all_ro_bytes == ro_all, "everything should have been counted"); assert(all_rw_bytes == rw_all, "everything should have been counted"); + + msg.info("%s", info_stream.as_string()); #undef fmt_stats } @@ -897,7 +901,7 @@ // Restore the vtable in case we invoke any virtual methods. MetaspaceShared::clone_cpp_vtables((intptr_t*)vtbl_list); - if (PrintSharedSpaces) { + if (log_is_enabled(Info, cds)) { DumpAllocClosure dac; dac.iterate_metaspace(_loader_data->ro_metaspace(), DumpAllocClosure::RO); dac.iterate_metaspace(_loader_data->rw_metaspace(), DumpAllocClosure::RW); @@ -1064,9 +1068,7 @@ } tty->print_cr("Loading classes to share: done."); - if (PrintSharedSpaces) { - tty->print_cr("Shared spaces: preloaded %d classes", class_count); - } + log_info(cds)("Shared spaces: preloaded %d classes", class_count); // Rewrite and link classes tty->print_cr("Rewriting and linking classes ..."); @@ -1102,9 +1104,9 @@ CLEAR_PENDING_EXCEPTION; if (klass != NULL) { - if (PrintSharedSpaces && Verbose && WizardMode) { + if (log_is_enabled(Trace, cds)) { ResourceMark rm; - tty->print_cr("Shared spaces preloaded: %s", klass->external_name()); + log_trace(cds)("Shared spaces preloaded: %s", klass->external_name()); } InstanceKlass* ik = InstanceKlass::cast(klass); --- old/src/share/vm/runtime/arguments.cpp 2017-05-31 15:52:19.332224743 -0400 +++ new/src/share/vm/runtime/arguments.cpp 2017-05-31 15:52:18.876224759 -0400 @@ -416,6 +416,7 @@ // NOTE: A compatibility request will be necessary for each alias to be removed. static AliasedLoggingFlag const aliased_logging_flags[] = { { "PrintCompressedOopsMode", LogLevel::Info, true, LOG_TAGS(gc, heap, coops) }, + { "PrintSharedSpaces", LogLevel::Info, true, LOG_TAGS(cds) }, { "TraceBiasedLocking", LogLevel::Info, true, LOG_TAGS(biasedlocking) }, { "TraceClassLoading", LogLevel::Info, true, LOG_TAGS(class, load) }, { "TraceClassLoadingPreorder", LogLevel::Debug, true, LOG_TAGS(class, preorder) }, @@ -1298,7 +1299,7 @@ assert(ARRAY_SIZE(unsupported_properties) == ARRAY_SIZE(unsupported_options), "must be"); // If a vm option is found in the unsupported_options array with index less than the info_idx, // vm will exit with an error message. Otherwise, it will print an informational message if - // PrintSharedSpaces is enabled. + // -Xlog:cds is enabled. uint info_idx = 1; SystemProperty* sp = system_properties(); while (sp != NULL) { @@ -1308,10 +1309,8 @@ vm_exit_during_initialization( "Cannot use the following option when dumping the shared archive", unsupported_options[i]); } else { - if (PrintSharedSpaces) { - tty->print_cr( - "Info: the %s option is ignored when dumping the shared archive", unsupported_options[i]); - } + log_info(cds)("Info: the %s option is ignored when dumping the shared archive", + unsupported_options[i]); } } } @@ -4402,10 +4401,11 @@ "Shared spaces are not supported in this VM\n"); return JNI_ERR; } - if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) { + if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || + log_is_enabled(Info, cds)) { warning("Shared spaces are not supported in this VM"); FLAG_SET_DEFAULT(UseSharedSpaces, false); - FLAG_SET_DEFAULT(PrintSharedSpaces, false); + LogConfiguration::configure_stdout(LogLevel::Off, true, LOG_TAGS(cds)); } no_shared_spaces("CDS Disabled"); #endif // INCLUDE_CDS --- old/src/share/vm/runtime/globals.hpp 2017-05-31 15:52:20.756224694 -0400 +++ new/src/share/vm/runtime/globals.hpp 2017-05-31 15:52:20.288224710 -0400 @@ -3874,9 +3874,6 @@ "shared spaces, and dumps the shared spaces to a file to be " \ "used in future JVM runs") \ \ - product(bool, PrintSharedSpaces, false, \ - "Print usage of shared spaces") \ - \ product(bool, PrintSharedArchiveAndExit, false, \ "Print shared archive file contents") \ \ --- old/test/runtime/CDSCompressedKPtrs/XShareAuto.java 2017-05-31 15:52:22.160224645 -0400 +++ new/test/runtime/CDSCompressedKPtrs/XShareAuto.java 2017-05-31 15:52:21.708224661 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, 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 @@ -62,7 +62,7 @@ pb = ProcessTools.createJavaProcessBuilder( "-server", "-Xshare:auto", "-XX:+UnlockDiagnosticVMOptions", - "-XX:SharedArchiveFile=./XShareAuto.jsa", "-XX:+PrintSharedSpaces", "-version"); + "-XX:SharedArchiveFile=./XShareAuto.jsa", "-Xlog:cds", "-version"); output = new OutputAnalyzer(pb.start()); try { output.shouldContain("sharing"); --- old/test/runtime/SharedArchiveFile/DefaultUseWithClient.java 2017-05-31 15:52:23.524224597 -0400 +++ new/test/runtime/SharedArchiveFile/DefaultUseWithClient.java 2017-05-31 15:52:23.072224613 -0400 @@ -48,6 +48,6 @@ } CDSTestUtils.createArchiveAndCheck(); - CDSTestUtils.runWithArchiveAndCheck("-client", "-XX:+PrintSharedSpaces"); + CDSTestUtils.runWithArchiveAndCheck("-client", "-Xlog:cds"); } } --- old/test/runtime/SharedArchiveFile/SharedStrings.java 2017-05-31 15:52:24.892224550 -0400 +++ new/test/runtime/SharedArchiveFile/SharedStrings.java 2017-05-31 15:52:24.436224566 -0400 @@ -52,7 +52,7 @@ "-XX:SharedArchiveFile=./SharedStrings.jsa", "-XX:+UseG1GC", "-XX:+UseCompressedOops", - "-XX:+PrintSharedSpaces", + "-Xlog:cds,cds+hashtables", // Needed for bootclasspath match, for CDS to work with WhiteBox API "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"), "-Xshare:dump");