# HG changeset patch # User mlarsson # Date 1518527456 -3600 # Node ID 88ad6c676c878336885b5ecc284d6ea13584939f # Parent 120b61d50f85a4ace7bbd1f563c7c0a02f7d7da6 8194994: Remove redundant string streams used for logging Reviewed-by: rehn, iklam, coleenp diff -r 120b61d50f85 -r 88ad6c676c87 src/hotspot/share/classfile/compactHashtable.cpp --- a/src/hotspot/share/classfile/compactHashtable.cpp Wed Jan 10 22:48:27 2018 +0100 +++ b/src/hotspot/share/classfile/compactHashtable.cpp Tue Feb 13 14:10:56 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, 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 @@ -146,27 +146,23 @@ cht->init(base_address, _num_entries, _num_buckets, _compact_buckets->data(), _compact_entries->data()); - if (log_is_enabled(Info, cds, hashtables)) { - ResourceMark rm; - LogMessage(cds, hashtables) msg; - stringStream info_stream; - + LogMessage(cds, hashtables) msg; + if (msg.is_info()) { double avg_cost = 0.0; if (_num_entries > 0) { avg_cost = double(table_bytes)/double(_num_entries); } - info_stream.print_cr("Shared %s table stats -------- base: " PTR_FORMAT, + msg.info("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()); + msg.info("Number of entries : %9d", _num_entries); + msg.info("Total bytes used : %9d", table_bytes); + msg.info("Average bytes per entry : %9.3f", avg_cost); + msg.info("Average bucket size : %9.3f", summary.avg()); + msg.info("Variance of bucket size : %9.3f", summary.variance()); + msg.info("Std. dev. of bucket size: %9.3f", summary.sd()); + msg.info("Empty buckets : %9d", _num_empty_buckets); + msg.info("Value_Only buckets : %9d", _num_value_only_buckets); + msg.info("Other buckets : %9d", _num_other_buckets); } } diff -r 120b61d50f85 -r 88ad6c676c87 src/hotspot/share/memory/filemap.cpp --- a/src/hotspot/share/memory/filemap.cpp Wed Jan 10 22:48:27 2018 +0100 +++ b/src/hotspot/share/memory/filemap.cpp Tue Feb 13 14:10:56 2018 +0100 @@ -410,14 +410,11 @@ // Write the FileMapInfo information to the file. void FileMapInfo::open_for_write() { - _full_path = Arguments::GetSharedArchivePath(); - 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()); + _full_path = Arguments::GetSharedArchivePath(); + LogMessage(cds) msg; + if (msg.is_info()) { + msg.info("Dumping shared data to file: "); + msg.info(" %s", _full_path); } #ifdef _WINDOWS // On Windows, need WRITE permission to remove the file. diff -r 120b61d50f85 -r 88ad6c676c87 src/hotspot/share/memory/metaspaceShared.cpp --- a/src/hotspot/share/memory/metaspaceShared.cpp Wed Jan 10 22:48:27 2018 +0100 +++ b/src/hotspot/share/memory/metaspaceShared.cpp Tue Feb 13 14:10:56 2018 +0100 @@ -883,13 +883,11 @@ const char *sep = "--------------------+---------------------------+---------------------------+--------------------------"; const char *hdr = " ro_cnt ro_bytes % | rw_cnt rw_bytes % | all_cnt all_bytes %"; - ResourceMark rm; LogMessage(cds) msg; - stringStream info_stream; - info_stream.print_cr("Detailed metadata info (excluding od/st regions; rw stats include md/mc regions):"); - info_stream.print_cr("%s", hdr); - info_stream.print_cr("%s", sep); + msg.info("Detailed metadata info (excluding od/st regions; rw stats include md/mc regions):"); + msg.info("%s", hdr); + msg.info("%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]; @@ -903,7 +901,7 @@ double rw_perc = percent_of(rw_bytes, rw_all); double perc = percent_of(bytes, ro_all + rw_all); - info_stream.print_cr(fmt_stats, name, + msg.info(fmt_stats, name, ro_count, ro_bytes, ro_perc, rw_count, rw_bytes, rw_perc, count, bytes, perc); @@ -921,8 +919,8 @@ double all_rw_perc = percent_of(all_rw_bytes, rw_all); double all_perc = percent_of(all_bytes, ro_all + rw_all); - info_stream.print_cr("%s", sep); - info_stream.print_cr(fmt_stats, "Total", + msg.info("%s", sep); + msg.info(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); @@ -930,7 +928,6 @@ 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 }