8152896: Convert PrintCompressedOopsMode to Unified Logging
Summary: Converted -XX:+PrintCompressedOopsMode to -Xlog:gc+heap+coops and aliased old option
Reviewed-by: coleenp, sjohanss, kvn, hseigel
--- a/hotspot/src/share/vm/logging/logTag.hpp Thu Apr 07 15:01:56 2016 +0000
+++ b/hotspot/src/share/vm/logging/logTag.hpp Thu Apr 07 13:11:15 2016 -0400
@@ -48,6 +48,7 @@
LOG_TAG(classpath) \
LOG_TAG(compaction) \
LOG_TAG(constraints) \
+ LOG_TAG(coops) \
LOG_TAG(cpu) \
LOG_TAG(cset) \
LOG_TAG(defaultmethods) \
--- a/hotspot/src/share/vm/memory/universe.cpp Thu Apr 07 15:01:56 2016 +0000
+++ b/hotspot/src/share/vm/memory/universe.cpp Thu Apr 07 13:11:15 2016 -0400
@@ -747,8 +747,10 @@
Universe::set_narrow_ptrs_base(Universe::narrow_oop_base());
- if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
- Universe::print_compressed_oops_mode(tty);
+ if (log_is_enabled(Info, gc, heap, coops)) {
+ ResourceMark rm;
+ outputStream* logst = Log(gc, heap, coops)::info_stream();
+ Universe::print_compressed_oops_mode(logst);
}
// Tell tests in which mode we run.
@@ -776,8 +778,8 @@
}
void Universe::print_compressed_oops_mode(outputStream* st) {
- st->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB",
- p2i(Universe::heap()->base()), Universe::heap()->reserved_region().byte_size()/M);
+ st->print("Heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB",
+ p2i(Universe::heap()->base()), Universe::heap()->reserved_region().byte_size()/M);
st->print(", Compressed Oops mode: %s", narrow_oop_mode_to_string(narrow_oop_mode()));
--- a/hotspot/src/share/vm/memory/virtualspace.cpp Thu Apr 07 15:01:56 2016 +0000
+++ b/hotspot/src/share/vm/memory/virtualspace.cpp Thu Apr 07 13:11:15 2016 -0400
@@ -24,6 +24,8 @@
#include "precompiled.hpp"
#include "code/codeCacheExtensions.hpp"
+#include "logging/log.hpp"
+#include "memory/resourceArea.hpp"
#include "memory/virtualspace.hpp"
#include "oops/markOop.hpp"
#include "oops/oop.inline.hpp"
@@ -78,10 +80,7 @@
// Different reserve address may be acceptable in other cases
// but for compressed oops heap should be at requested address.
assert(UseCompressedOops, "currently requested address used only for compressed oops");
- if (PrintCompressedOopsMode) {
- tty->cr();
- tty->print_cr("Reserved memory not at requested address: " PTR_FORMAT " vs " PTR_FORMAT, p2i(base), p2i(requested_address));
- }
+ log_debug(gc, heap, coops)("Reserved memory not at requested address: " PTR_FORMAT " vs " PTR_FORMAT, p2i(base), p2i(requested_address));
// OS ignored requested address. Try different address.
if (special) {
if (!os::release_memory_special(base, size)) {
@@ -143,10 +142,7 @@
// failed; try to reserve regular memory below
if (UseLargePages && (!FLAG_IS_DEFAULT(UseLargePages) ||
!FLAG_IS_DEFAULT(LargePageSizeInBytes))) {
- if (PrintCompressedOopsMode) {
- tty->cr();
- tty->print_cr("Reserve regular memory without large pages.");
- }
+ log_debug(gc, heap, coops)("Reserve regular memory without large pages");
}
}
}
@@ -286,11 +282,10 @@
if (!os::protect_memory(_base, _noaccess_prefix, os::MEM_PROT_NONE, _special)) {
fatal("cannot protect protection page");
}
- if (PrintCompressedOopsMode) {
- tty->cr();
- tty->print_cr("Protected page at the reserved heap base: "
- PTR_FORMAT " / " INTX_FORMAT " bytes", p2i(_base), _noaccess_prefix);
- }
+ log_debug(gc, heap, coops)("Protected page at the reserved heap base: "
+ PTR_FORMAT " / " INTX_FORMAT " bytes",
+ p2i(_base),
+ _noaccess_prefix);
assert(Universe::narrow_oop_use_implicit_null_checks() == true, "not initialized?");
} else {
Universe::set_narrow_oop_use_implicit_null_checks(false);
@@ -321,10 +316,10 @@
bool special = large && !os::can_commit_large_page_memory();
char* base = NULL;
- if (PrintCompressedOopsMode && Verbose) {
- tty->print("Trying to allocate at address " PTR_FORMAT " heap of size " SIZE_FORMAT_HEX ".\n",
- p2i(requested_address), size);
- }
+ log_trace(gc, heap, coops)("Trying to allocate at address " PTR_FORMAT
+ " heap of size " SIZE_FORMAT_HEX,
+ p2i(requested_address),
+ size);
if (special) {
base = os::reserve_memory_special(size, alignment, requested_address, false);
@@ -343,10 +338,7 @@
// Failed; try to reserve regular memory below
if (UseLargePages && (!FLAG_IS_DEFAULT(UseLargePages) ||
!FLAG_IS_DEFAULT(LargePageSizeInBytes))) {
- if (PrintCompressedOopsMode) {
- tty->cr();
- tty->print_cr("Reserve regular memory without large pages.");
- }
+ log_debug(gc, heap, coops)("Reserve regular memory without large pages");
}
// Optimistically assume that the OSes returns an aligned base pointer.
@@ -558,9 +550,7 @@
// Last, desperate try without any placement.
if (_base == NULL) {
- if (PrintCompressedOopsMode && Verbose) {
- tty->print("Trying to allocate at address NULL heap of size " SIZE_FORMAT_HEX ".\n", size + noaccess_prefix);
- }
+ log_trace(gc, heap, coops)("Trying to allocate at address NULL heap of size " SIZE_FORMAT_HEX, size + noaccess_prefix);
initialize(size + noaccess_prefix, alignment, large, NULL, false);
}
}
--- a/hotspot/src/share/vm/runtime/arguments.cpp Thu Apr 07 15:01:56 2016 +0000
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Thu Apr 07 13:11:15 2016 -0400
@@ -407,7 +407,9 @@
{ NULL, NULL}
};
+// 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) },
{ "TraceBiasedLocking", LogLevel::Info, true, LOG_TAGS(biasedlocking) },
{ "TraceClassLoading", LogLevel::Info, true, LOG_TAGS(classload) },
{ "TraceClassLoadingPreorder", LogLevel::Debug, true, LOG_TAGS(classload, preorder) },
@@ -2184,15 +2186,11 @@
if (!FLAG_IS_DEFAULT(HeapBaseMinAddress)) {
if (HeapBaseMinAddress < DefaultHeapBaseMinAddress) {
// matches compressed oops printing flags
- if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
- jio_fprintf(defaultStream::error_stream(),
- "HeapBaseMinAddress must be at least " SIZE_FORMAT
- " (" SIZE_FORMAT "G) which is greater than value given "
- SIZE_FORMAT "\n",
- DefaultHeapBaseMinAddress,
- DefaultHeapBaseMinAddress/G,
- HeapBaseMinAddress);
- }
+ log_debug(gc, heap, coops)("HeapBaseMinAddress must be at least " SIZE_FORMAT
+ " (" SIZE_FORMAT "G) which is greater than value given " SIZE_FORMAT,
+ DefaultHeapBaseMinAddress,
+ DefaultHeapBaseMinAddress/G,
+ HeapBaseMinAddress);
FLAG_SET_ERGO(size_t, HeapBaseMinAddress, DefaultHeapBaseMinAddress);
}
}
--- a/hotspot/src/share/vm/runtime/globals.hpp Thu Apr 07 15:01:56 2016 +0000
+++ b/hotspot/src/share/vm/runtime/globals.hpp Thu Apr 07 13:11:15 2016 -0400
@@ -641,9 +641,6 @@
"region.") \
range(1, max_uintx) \
\
- diagnostic(bool, PrintCompressedOopsMode, false, \
- "Print compressed oops base address and encoding mode") \
- \
lp64_product(intx, ObjectAlignmentInBytes, 8, \
"Default object alignment in bytes, 8 is minimum") \
range(8, 256) \
--- a/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java Thu Apr 07 15:01:56 2016 +0000
+++ b/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java Thu Apr 07 13:11:15 2016 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -85,8 +85,7 @@
public static void heapBaseMinAddressTest() throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:HeapBaseMinAddress=1m",
- "-XX:+UnlockDiagnosticVMOptions",
- "-XX:+PrintCompressedOopsMode",
+ "-Xlog:gc+heap+coops=debug",
"-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("HeapBaseMinAddress must be at least");
--- a/hotspot/test/runtime/CompressedOops/UseCompressedOops.java Thu Apr 07 15:01:56 2016 +0000
+++ b/hotspot/test/runtime/CompressedOops/UseCompressedOops.java Thu Apr 07 13:11:15 2016 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -169,7 +169,6 @@
ArrayList<String> args = new ArrayList<>();
// Always run with these three:
- args.add("-XX:+UnlockDiagnosticVMOptions");
args.add("-XX:+PrintCompressedOopsMode");
args.add("-Xms32m");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/logging/CompressedOopsTest.java Thu Apr 07 13:11:15 2016 -0400
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2016, 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
+ * @bug 8149991
+ * @requires (sun.arch.data.model == "64")
+ * @summary -Xlog:gc+heap+coops=info should have output from the code
+ * @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
+ * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.Platform jdk.test.lib.ProcessTools
+ * @run driver CompressedOopsTest
+ */
+
+import jdk.test.lib.OutputAnalyzer;
+import jdk.test.lib.Platform;
+import jdk.test.lib.ProcessTools;
+
+public class CompressedOopsTest {
+ static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("[gc,heap,coops] Heap address");
+ output.shouldHaveExitValue(0);
+ }
+
+ static void analyzeOutputOff(ProcessBuilder pb) throws Exception {
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldNotContain("[gc,heap,coops]");
+ output.shouldHaveExitValue(0);
+ }
+
+ public static void main(String[] args) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseCompressedOops",
+ "-Xlog:gc+heap+coops=info",
+ InnerClass.class.getName());
+ analyzeOutputOn(pb);
+
+ pb = ProcessTools.createJavaProcessBuilder("-XX:+UseCompressedOops",
+ "-XX:+PrintCompressedOopsMode",
+ InnerClass.class.getName());
+ analyzeOutputOn(pb);
+
+ pb = ProcessTools.createJavaProcessBuilder("-XX:+UseCompressedOops",
+ "-XX:+PrintCompressedOopsMode",
+ "-Xlog:gc+heap+coops=off",
+ InnerClass.class.getName());
+ analyzeOutputOff(pb);
+
+ pb = ProcessTools.createJavaProcessBuilder("-XX:+UseCompressedOops",
+ "-Xlog:gc+heap+coops=info",
+ "-XX:-PrintCompressedOopsMode",
+ InnerClass.class.getName());
+ analyzeOutputOff(pb);
+ }
+
+ public static class InnerClass {
+ public static void main(String[] args) throws Exception {
+ System.out.println("Compressed Oops (gc+heap+coops) test");
+ }
+ }
+}