8176132: -XX:+PrintSharedSpaces should be converted to use Unified Logging

Converted -XX:+PrintSharedSpaces to -Xlog:cds=info

Reviewed-by: iklam, jiangli, mseledtsov
This commit is contained in:
Rachel Protacio 2017-06-05 13:13:38 -04:00
parent 3312fc717b
commit 451b8b5d32
12 changed files with 87 additions and 75 deletions

View file

@ -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 @@ void FileMapInfo::fail_continue(const char *msg, ...) {
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 @@ bool FileMapInfo::open_for_read() {
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 @@ void FileMapInfo::write_region(int region, char* base, size_t size,
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 @@ bool FileMapInfo::map_string_regions() {
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 @@ bool FileMapInfo::map_string_regions() {
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.");
}
}