From baca7daa32d553b647bdb33bb74a0eb84542deeb Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Fri, 17 Jan 2025 16:24:47 +0000 Subject: [PATCH] 8347733: Replace SIZE_FORMAT in runtime code Reviewed-by: matsaave, sspitsyn, dholmes --- .../share/cds/aotLinkedClassBulkLoader.cpp | 4 +- src/hotspot/share/cds/archiveBuilder.cpp | 18 ++--- src/hotspot/share/cds/archiveHeapLoader.cpp | 2 +- src/hotspot/share/cds/archiveHeapWriter.cpp | 14 ++-- src/hotspot/share/cds/archiveUtils.cpp | 14 ++-- src/hotspot/share/cds/dynamicArchive.cpp | 2 +- src/hotspot/share/cds/filemap.cpp | 52 +++++++------- src/hotspot/share/cds/heapShared.cpp | 14 ++-- src/hotspot/share/cds/metaspaceShared.cpp | 29 ++++---- .../share/classfile/classFileParser.cpp | 2 +- .../share/classfile/classLoaderStats.cpp | 6 +- src/hotspot/share/classfile/dictionary.cpp | 4 +- src/hotspot/share/classfile/javaClasses.cpp | 4 +- src/hotspot/share/classfile/stringTable.cpp | 6 +- src/hotspot/share/classfile/symbolTable.cpp | 30 ++++---- src/hotspot/share/code/codeCache.cpp | 2 +- src/hotspot/share/code/codeHeapState.cpp | 40 +++++------ src/hotspot/share/compiler/compileBroker.cpp | 6 +- src/hotspot/share/logging/logAsyncWriter.cpp | 4 +- .../share/logging/logConfiguration.cpp | 14 ++-- src/hotspot/share/logging/logFileOutput.cpp | 8 +-- src/hotspot/share/logging/logSelection.cpp | 2 +- .../share/logging/logSelectionList.cpp | 2 +- src/hotspot/share/nmt/mallocTracker.cpp | 4 +- src/hotspot/share/nmt/memReporter.cpp | 68 +++++++++---------- src/hotspot/share/nmt/memoryFileTracker.cpp | 4 +- src/hotspot/share/nmt/nmtPreInit.cpp | 4 +- .../share/nmt/virtualMemoryTracker.cpp | 24 +++---- src/hotspot/share/nmt/vmatree.cpp | 4 +- src/hotspot/share/oops/array.hpp | 8 +-- src/hotspot/share/oops/compressedOops.cpp | 4 +- src/hotspot/share/oops/instanceKlass.cpp | 2 +- .../share/oops/instanceMirrorKlass.cpp | 4 +- src/hotspot/share/oops/oop.inline.hpp | 6 +- src/hotspot/share/oops/stackChunkOop.cpp | 6 +- src/hotspot/share/prims/jvmtiEnter.xsl | 4 +- .../share/prims/resolvedMethodTable.cpp | 8 +-- src/hotspot/share/prims/whitebox.cpp | 6 +- src/hotspot/share/runtime/arguments.cpp | 14 ++-- src/hotspot/share/runtime/deoptimization.cpp | 2 +- src/hotspot/share/runtime/flags/jvmFlag.cpp | 4 +- .../share/runtime/flags/jvmFlagAccess.cpp | 8 +-- .../flags/jvmFlagConstraintsCompiler.cpp | 2 +- .../flags/jvmFlagConstraintsRuntime.cpp | 2 +- src/hotspot/share/runtime/java.cpp | 2 +- src/hotspot/share/runtime/jniHandles.cpp | 4 +- src/hotspot/share/runtime/os.cpp | 42 ++++++------ src/hotspot/share/runtime/perfData.cpp | 6 +- src/hotspot/share/runtime/perfMemory.cpp | 12 ++-- src/hotspot/share/runtime/reflection.cpp | 4 +- src/hotspot/share/runtime/stackOverflow.cpp | 2 +- src/hotspot/share/runtime/synchronizer.cpp | 48 ++++++------- src/hotspot/share/runtime/thread.cpp | 4 +- .../share/services/diagnosticCommand.cpp | 4 +- .../share/services/heapDumperCompression.cpp | 4 +- .../share/services/lowMemoryDetector.cpp | 4 +- src/hotspot/share/services/threadIdTable.cpp | 4 +- src/hotspot/share/services/writeableFlags.cpp | 2 +- src/hotspot/share/utilities/bitMap.cpp | 12 ++-- src/hotspot/share/utilities/bitMap.hpp | 4 +- src/hotspot/share/utilities/chunkedList.hpp | 4 +- .../utilities/concurrentHashTable.inline.hpp | 4 +- src/hotspot/share/utilities/copy.cpp | 8 +-- src/hotspot/share/utilities/elfFile.cpp | 4 +- .../share/utilities/globalDefinitions.hpp | 8 +-- src/hotspot/share/utilities/ostream.cpp | 6 +- .../share/utilities/tableStatistics.cpp | 6 +- src/hotspot/share/utilities/vmError.cpp | 8 +-- 68 files changed, 335 insertions(+), 338 deletions(-) diff --git a/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp b/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp index 9bab6042436..4fc8072dcd5 100644 --- a/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp +++ b/src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp @@ -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 @@ -89,7 +89,7 @@ void AOTLinkedClassBulkLoader::exit_on_exception(JavaThread* current) { ResourceMark rm(current); if (current->pending_exception()->is_a(vmClasses::OutOfMemoryError_klass())) { log_error(cds)("Out of memory. Please run with a larger Java heap, current MaxHeapSize = " - SIZE_FORMAT "M", MaxHeapSize/M); + "%zuM", MaxHeapSize/M); } else { log_error(cds)("%s: %s", current->pending_exception()->klass()->external_name(), java_lang_String::as_utf8_string(java_lang_Throwable::message(current->pending_exception()))); diff --git a/src/hotspot/share/cds/archiveBuilder.cpp b/src/hotspot/share/cds/archiveBuilder.cpp index 7a2d0548206..5946fc2c435 100644 --- a/src/hotspot/share/cds/archiveBuilder.cpp +++ b/src/hotspot/share/cds/archiveBuilder.cpp @@ -312,14 +312,14 @@ address ArchiveBuilder::reserve_buffer() { MetaspaceShared::core_region_alignment(), os::vm_page_size()); if (!rs.is_reserved()) { - log_error(cds)("Failed to reserve " SIZE_FORMAT " bytes of output buffer.", buffer_size); + log_error(cds)("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 " [" SIZE_FORMAT " bytes]", + log_info(cds)("Reserved output buffer space at " PTR_FORMAT " [%zu bytes]", p2i(buffer_bottom), buffer_size); _shared_rs = rs; @@ -1184,7 +1184,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic { log_as_hex(last_obj_base, last_obj_end, last_obj_base + buffer_to_runtime_delta()); if (last_obj_end < region_end) { - log_debug(cds, map)(PTR_FORMAT ": @@ Misc data " SIZE_FORMAT " bytes", + log_debug(cds, map)(PTR_FORMAT ": @@ Misc data %zu bytes", p2i(last_obj_end + buffer_to_runtime_delta()), size_t(region_end - last_obj_end)); log_as_hex(last_obj_end, region_end, last_obj_end + buffer_to_runtime_delta()); @@ -1204,7 +1204,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic { size_t size = top - base; base = requested_base; top = requested_base + size; - log_info(cds, map)("[%-18s " PTR_FORMAT " - " PTR_FORMAT " " SIZE_FORMAT_W(9) " bytes]", + log_info(cds, map)("[%-18s " PTR_FORMAT " - " PTR_FORMAT " %9zu bytes]", name, p2i(base), p2i(top), size); } @@ -1245,7 +1245,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic { // We have a filler oop, which also does not exist in BufferOffsetToSourceObjectTable. // Example: // 0x00000007ffc3ffd8: @@ Object filler 40 bytes - st.print_cr("filler " SIZE_FORMAT " bytes", byte_size); + st.print_cr("filler %zu bytes", byte_size); } else { ShouldNotReachHere(); } @@ -1348,7 +1348,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic { print_oop_info_cr(&st, obj); } } else { - st.print_cr(" - fields (" SIZE_FORMAT " words):", source_oop->size()); + st.print_cr(" - fields (%zu words):", source_oop->size()); ArchivedFieldPrinter print_field(heap_info, &st, source_oop, buffered_addr); InstanceKlass::cast(source_klass)->print_nonstatic_fields(&print_field); @@ -1573,12 +1573,12 @@ void ArchiveBuilder::print_region_stats(FileMapInfo *mapinfo, ArchiveHeapInfo* h print_heap_region_stats(heap_info, total_reserved); } - log_debug(cds)("total : " SIZE_FORMAT_W(9) " [100.0%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used]", + log_debug(cds)("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: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [100.0%% used]", + log_debug(cds)("bm space: %9zu [ %4.1f%% of total] out of %9zu bytes [100.0%% used]", size, size/double(total_size)*100.0, size); } @@ -1586,7 +1586,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: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [100.0%% used] at " INTPTR_FORMAT, + log_debug(cds)("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)); } diff --git a/src/hotspot/share/cds/archiveHeapLoader.cpp b/src/hotspot/share/cds/archiveHeapLoader.cpp index 65bff94e71c..e103f83ce33 100644 --- a/src/hotspot/share/cds/archiveHeapLoader.cpp +++ b/src/hotspot/share/cds/archiveHeapLoader.cpp @@ -308,7 +308,7 @@ bool ArchiveHeapLoader::load_heap_region_impl(FileMapInfo* mapinfo, LoadedArchiv } assert(r->mapped_base() == (char*)load_address, "sanity"); log_info(cds)("Loaded heap region #%d at base " INTPTR_FORMAT " top " INTPTR_FORMAT - " size " SIZE_FORMAT_W(6) " delta %zd", + " size %6zu delta %zd", loaded_region->_region_index, load_address, load_address + loaded_region->_region_size, loaded_region->_region_size, loaded_region->_runtime_offset); diff --git a/src/hotspot/share/cds/archiveHeapWriter.cpp b/src/hotspot/share/cds/archiveHeapWriter.cpp index 7c9311fc49a..845ef960e01 100644 --- a/src/hotspot/share/cds/archiveHeapWriter.cpp +++ b/src/hotspot/share/cds/archiveHeapWriter.cpp @@ -218,7 +218,7 @@ void ArchiveHeapWriter::copy_roots_to_buffer(GrowableArrayCHeapat(root_index++)); } - log_info(cds, heap)("archived obj root segment [%d] = " SIZE_FORMAT " bytes, obj = " PTR_FORMAT, + log_info(cds, heap)("archived obj root segment [%d] = %zu bytes, obj = " PTR_FORMAT, size_elems, size_bytes, p2i(seg_oop)); } @@ -330,7 +330,7 @@ void ArchiveHeapWriter::copy_source_objs_to_buffer(GrowableArrayCHeaplength() + 1, roots->length(), _num_native_ptrs); } @@ -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 (" SIZE_FORMAT " bytes total) @ buffer offset " SIZE_FORMAT, + log_info(cds, 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; @@ -627,7 +627,7 @@ static void log_bitmap_usage(const char* which, BitMap* bitmap, size_t total_bit // The whole heap is covered by total_bits, but there are only non-zero bits within [start ... end). size_t start = bitmap->find_first_set_bit(0); size_t end = bitmap->size(); - log_info(cds)("%s = " SIZE_FORMAT_W(7) " ... " SIZE_FORMAT_W(7) " (%3zu%% ... %3zu%% = %3zu%%)", which, + log_info(cds)("%s = %7zu ... %7zu (%3zu%% ... %3zu%% = %3zu%%)", which, start, end, start * 100 / total_bits, end * 100 / total_bits, @@ -754,7 +754,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 (" SIZE_FORMAT " bits)", + log_info(cds, 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/archiveUtils.cpp b/src/hotspot/share/cds/archiveUtils.cpp index 3530fcff2b3..ecc50520558 100644 --- a/src/hotspot/share/cds/archiveUtils.cpp +++ b/src/hotspot/share/cds/archiveUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, 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 @@ -124,7 +124,7 @@ void ArchivePtrMarker::mark_pointer(address* ptr_loc) { } assert(idx < _ptrmap->size(), "must be"); _ptrmap->set_bit(idx); - //tty->print_cr("Marking pointer [" PTR_FORMAT "] -> " PTR_FORMAT " @ " SIZE_FORMAT_W(5), p2i(ptr_loc), p2i(*ptr_loc), idx); + //tty->print_cr("Marking pointer [" PTR_FORMAT "] -> " PTR_FORMAT " @ %5zu", p2i(ptr_loc), p2i(*ptr_loc), idx); } } } @@ -138,7 +138,7 @@ void ArchivePtrMarker::clear_pointer(address* ptr_loc) { size_t idx = ptr_loc - ptr_base(); assert(idx < _ptrmap->size(), "cannot clear pointers that have not been marked"); _ptrmap->clear_bit(idx); - //tty->print_cr("Clearing pointer [" PTR_FORMAT "] -> " PTR_FORMAT " @ " SIZE_FORMAT_W(5), p2i(ptr_loc), p2i(*ptr_loc), idx); + //tty->print_cr("Clearing pointer [" PTR_FORMAT "] -> " PTR_FORMAT " @ %5zu", p2i(ptr_loc), p2i(*ptr_loc), idx); } class ArchivePtrBitmapCleaner: public BitMapClosure { @@ -163,7 +163,7 @@ public: } } else { _ptrmap->clear_bit(offset); - DEBUG_ONLY(log_trace(cds, reloc)("Clearing pointer [" PTR_FORMAT "] -> null @ " SIZE_FORMAT_W(9), p2i(ptr_loc), offset)); + DEBUG_ONLY(log_trace(cds, reloc)("Clearing pointer [" PTR_FORMAT "] -> null @ %9zu", p2i(ptr_loc), offset)); } return true; @@ -228,7 +228,7 @@ void DumpRegion::commit_to(char* newtop) { assert(commit <= uncommitted, "sanity"); if (!_vs->expand_by(commit, false)) { - log_error(cds)("Failed to expand shared space to " SIZE_FORMAT " bytes", + log_error(cds)("Failed to expand shared space to %zu bytes", need_committed_size); MetaspaceShared::unrecoverable_writing_error(); } @@ -239,7 +239,7 @@ void DumpRegion::commit_to(char* newtop) { } else { which = "shared"; } - log_debug(cds)("Expanding %s spaces by " SIZE_FORMAT_W(7) " bytes [total " SIZE_FORMAT_W(9) " bytes ending at %p]", + log_debug(cds)("Expanding %s spaces by %7zu bytes [total %9zu bytes ending at %p]", which, commit, _vs->actual_committed_size(), _vs->high()); } @@ -265,7 +265,7 @@ void DumpRegion::append_intptr_t(intptr_t n, bool need_to_mark) { } void DumpRegion::print(size_t total_bytes) const { - log_debug(cds)("%s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT, + log_debug(cds)("%s space: %9zu [ %4.1f%% of total] out of %9zu bytes [%5.1f%% used] at " INTPTR_FORMAT, _name, used(), percent_of(used(), total_bytes), reserved(), percent_of(used(), reserved()), p2i(ArchiveBuilder::current()->to_requested(_base))); } diff --git a/src/hotspot/share/cds/dynamicArchive.cpp b/src/hotspot/share/cds/dynamicArchive.cpp index 9a570984079..118159eb3bf 100644 --- a/src/hotspot/share/cds/dynamicArchive.cpp +++ b/src/hotspot/share/cds/dynamicArchive.cpp @@ -352,7 +352,7 @@ void DynamicArchiveBuilder::write_archive(char* serialized_data) { size_t file_size = pointer_delta(top, base, sizeof(char)); log_info(cds, dynamic)("Written dynamic archive " PTR_FORMAT " - " PTR_FORMAT - " [" UINT32_FORMAT " bytes header, " SIZE_FORMAT " bytes total]", + " [" UINT32_FORMAT " bytes header, %zu bytes total]", p2i(base), p2i(top), _header->header_size(), file_size); log_info(cds, dynamic)("%d klasses; %d symbols", klasses()->length(), symbols()->length()); diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index d34e190a48b..dba6aeb3e47 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -279,7 +279,7 @@ void FileMapHeader::print(outputStream* st) { } st->print_cr("============ end regions ======== "); - st->print_cr("- core_region_alignment: " SIZE_FORMAT, _core_region_alignment); + st->print_cr("- core_region_alignment: %zu", _core_region_alignment); st->print_cr("- obj_alignment: %d", _obj_alignment); st->print_cr("- narrow_oop_base: " INTPTR_FORMAT, p2i(_narrow_oop_base)); st->print_cr("- narrow_oop_shift %d", _narrow_oop_shift); @@ -291,11 +291,11 @@ void FileMapHeader::print(outputStream* st) { st->print_cr("- compressed_class_ptrs: %d", _compressed_class_ptrs); st->print_cr("- narrow_klass_pointer_bits: %d", _narrow_klass_pointer_bits); st->print_cr("- narrow_klass_shift: %d", _narrow_klass_shift); - st->print_cr("- cloned_vtables_offset: " SIZE_FORMAT_X, _cloned_vtables_offset); - st->print_cr("- early_serialized_data_offset: " SIZE_FORMAT_X, _early_serialized_data_offset); - st->print_cr("- serialized_data_offset: " SIZE_FORMAT_X, _serialized_data_offset); + st->print_cr("- cloned_vtables_offset: 0x%zx", _cloned_vtables_offset); + st->print_cr("- early_serialized_data_offset: 0x%zx", _early_serialized_data_offset); + st->print_cr("- serialized_data_offset: 0x%zx", _serialized_data_offset); st->print_cr("- jvm_ident: %s", _jvm_ident); - st->print_cr("- shared_path_table_offset: " SIZE_FORMAT_X, _shared_path_table_offset); + st->print_cr("- shared_path_table_offset: 0x%zx", _shared_path_table_offset); st->print_cr("- app_class_paths_start_index: %d", _app_class_paths_start_index); st->print_cr("- app_module_paths_start_index: %d", _app_module_paths_start_index); st->print_cr("- num_module_paths: %d", _num_module_paths); @@ -307,14 +307,14 @@ void FileMapHeader::print(outputStream* st) { st->print_cr("- requested_base_address: " INTPTR_FORMAT, p2i(_requested_base_address)); st->print_cr("- mapped_base_address: " INTPTR_FORMAT, p2i(_mapped_base_address)); st->print_cr("- heap_root_segments.roots_count: %d" , _heap_root_segments.roots_count()); - st->print_cr("- heap_root_segments.base_offset: " SIZE_FORMAT_X, _heap_root_segments.base_offset()); - st->print_cr("- heap_root_segments.count: " SIZE_FORMAT, _heap_root_segments.count()); + st->print_cr("- heap_root_segments.base_offset: 0x%zx", _heap_root_segments.base_offset()); + st->print_cr("- heap_root_segments.count: %zu", _heap_root_segments.count()); st->print_cr("- heap_root_segments.max_size_elems: %d", _heap_root_segments.max_size_in_elems()); st->print_cr("- heap_root_segments.max_size_bytes: %d", _heap_root_segments.max_size_in_bytes()); - st->print_cr("- _heap_oopmap_start_pos: " SIZE_FORMAT, _heap_oopmap_start_pos); - st->print_cr("- _heap_ptrmap_start_pos: " SIZE_FORMAT, _heap_ptrmap_start_pos); - st->print_cr("- _rw_ptrmap_start_pos: " SIZE_FORMAT, _rw_ptrmap_start_pos); - st->print_cr("- _ro_ptrmap_start_pos: " SIZE_FORMAT, _ro_ptrmap_start_pos); + st->print_cr("- _heap_oopmap_start_pos: %zu", _heap_oopmap_start_pos); + st->print_cr("- _heap_ptrmap_start_pos: %zu", _heap_ptrmap_start_pos); + st->print_cr("- _rw_ptrmap_start_pos: %zu", _rw_ptrmap_start_pos); + st->print_cr("- _ro_ptrmap_start_pos: %zu", _ro_ptrmap_start_pos); st->print_cr("- allow_archiving_with_java_agent:%d", _allow_archiving_with_java_agent); st->print_cr("- use_optimized_module_handling: %d", _use_optimized_module_handling); st->print_cr("- has_full_module_graph %d", _has_full_module_graph); @@ -1420,7 +1420,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 " SIZE_FORMAT, pos); + log_error(cds)("Unable to seek to position %zu", pos); MetaspaceShared::unrecoverable_loading_error(); } } @@ -1555,7 +1555,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 " (" SIZE_FORMAT " bits)", + log_debug(cds, reloc)("mapped %s relocation %smap @ " INTPTR_FORMAT " (%zu bits)", region_name(region_index), is_oopmap ? "oop" : "ptr", p2i(bitmap_base), size_in_bits); @@ -1578,13 +1578,13 @@ void FileMapRegion::print(outputStream* st, int region_index) { st->print_cr("- is_heap_region: %d", _is_heap_region); st->print_cr("- is_bitmap_region: %d", _is_bitmap_region); st->print_cr("- mapped_from_file: %d", _mapped_from_file); - st->print_cr("- file_offset: " SIZE_FORMAT_X, _file_offset); - st->print_cr("- mapping_offset: " SIZE_FORMAT_X, _mapping_offset); - st->print_cr("- used: " SIZE_FORMAT, _used); - st->print_cr("- oopmap_offset: " SIZE_FORMAT_X, _oopmap_offset); - st->print_cr("- oopmap_size_in_bits: " SIZE_FORMAT, _oopmap_size_in_bits); - st->print_cr("- ptrmap_offset: " SIZE_FORMAT_X, _ptrmap_offset); - st->print_cr("- ptrmap_size_in_bits: " SIZE_FORMAT, _ptrmap_size_in_bits); + st->print_cr("- file_offset: 0x%zx", _file_offset); + st->print_cr("- mapping_offset: 0x%zx", _mapping_offset); + st->print_cr("- used: %zu", _used); + st->print_cr("- oopmap_offset: 0x%zx", _oopmap_offset); + st->print_cr("- oopmap_size_in_bits: %zu", _oopmap_size_in_bits); + st->print_cr("- ptrmap_offset: 0x%zx", _ptrmap_offset); + st->print_cr("- ptrmap_size_in_bits: %zu", _ptrmap_size_in_bits); st->print_cr("- mapped_base: " INTPTR_FORMAT, p2i(_mapped_base)); } @@ -1623,7 +1623,7 @@ 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: " SIZE_FORMAT_W(8) + log_info(cds)("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); @@ -2109,7 +2109,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 "] = " SIZE_FORMAT_W(8) " bytes", + log_info(cds)("Requested heap region [" INTPTR_FORMAT " - " INTPTR_FORMAT "] = %8zu bytes", p2i(start), p2i(end), size); return MemRegion((HeapWord*)start, (HeapWord*)end); @@ -2171,13 +2171,13 @@ 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 = " SIZE_FORMAT "M, and the following configuration:", + log_info(cds)("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", 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", narrow_oop_mode(), p2i(narrow_oop_base()), narrow_oop_shift()); - log_info(cds)("The current max heap size = " SIZE_FORMAT "M, G1HeapRegion::GrainBytes = " SIZE_FORMAT, + log_info(cds)("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", p2i(CompressedKlassPointers::base()), CompressedKlassPointers::narrow_klass_pointer_bits(), CompressedKlassPointers::shift()); @@ -2334,7 +2334,7 @@ bool FileMapInfo::map_heap_region_impl() { if (base == nullptr || base != addr) { dealloc_heap_region(); log_info(cds)("UseSharedSpaces: Unable to map at required address in java heap. " - INTPTR_FORMAT ", size = " SIZE_FORMAT " bytes", + INTPTR_FORMAT ", size = %zu bytes", p2i(addr), _mapped_heap_memregion.byte_size()); return false; } @@ -2371,7 +2371,7 @@ bool FileMapInfo::map_heap_region_impl() { return false; } } - log_info(cds)("Heap data mapped at " INTPTR_FORMAT ", size = " SIZE_FORMAT_W(8) " bytes", + log_info(cds)("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); return true; diff --git a/src/hotspot/share/cds/heapShared.cpp b/src/hotspot/share/cds/heapShared.cpp index be9f2ace64f..eb90bfb77fc 100644 --- a/src/hotspot/share/cds/heapShared.cpp +++ b/src/hotspot/share/cds/heapShared.cpp @@ -302,7 +302,7 @@ bool HeapShared::archive_object(oop obj, KlassSubGraphInfo* subgraph_info) { } if (ArchiveHeapWriter::is_too_large_to_archive(obj->size())) { - log_debug(cds, heap)("Cannot archive, object (" PTR_FORMAT ") is too large: " SIZE_FORMAT, + log_debug(cds, heap)("Cannot archive, object (" PTR_FORMAT ") is too large: %zu", p2i(obj), obj->size()); debug_trace(); return false; @@ -1388,7 +1388,7 @@ class WalkOopAndArchiveClosure: public BasicOopIterateClosure { if (!_record_klasses_only && log_is_enabled(Debug, cds, heap)) { ResourceMark rm; - log_debug(cds, heap)("(%d) %s[" SIZE_FORMAT "] ==> " PTR_FORMAT " size " SIZE_FORMAT " %s", _level, + log_debug(cds, heap)("(%d) %s[%zu] ==> " PTR_FORMAT " size %zu %s", _level, _referencing_obj->klass()->external_name(), field_delta, p2i(obj), obj->size() * HeapWordSize, obj->klass()->external_name()); if (log_is_enabled(Trace, cds, heap)) { @@ -1531,7 +1531,7 @@ bool HeapShared::archive_reachable_objects_from(int level, ResourceMark rm; log_error(cds, heap)( "Cannot archive the sub-graph referenced from %s object (" - PTR_FORMAT ") size " SIZE_FORMAT ", skipped.", + PTR_FORMAT ") size %zu, skipped.", orig_obj->klass()->external_name(), p2i(orig_obj), orig_obj->size() * HeapWordSize); if (level == 1) { // Don't archive a subgraph root that's too big. For archives static fields, that's OK @@ -2119,18 +2119,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)(SIZE_FORMAT_W(8) " objects are <= " SIZE_FORMAT_W(-6) - " bytes (total " SIZE_FORMAT_W(8) " bytes, avg %8.1f bytes)", + log_info(cds, 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)(SIZE_FORMAT_W(8) " huge objects (total " SIZE_FORMAT_W(8) " bytes" + log_info(cds, 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)(SIZE_FORMAT_W(8) " total objects (total " SIZE_FORMAT_W(8) " bytes" + log_info(cds, 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/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp index 422cb3b9bfe..9bf4d15e514 100644 --- a/src/hotspot/share/cds/metaspaceShared.cpp +++ b/src/hotspot/share/cds/metaspaceShared.cpp @@ -265,7 +265,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: " SIZE_FORMAT, core_region_alignment()); + log_info(cds)("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; @@ -286,7 +286,7 @@ void MetaspaceShared::initialize_for_static_dump() { size_t symbol_rs_size = LP64_ONLY(3 * G) NOT_LP64(128 * M); _symbol_rs = MemoryReserver::reserve(symbol_rs_size, mtClassShared); if (!_symbol_rs.is_reserved()) { - log_error(cds)("Unable to reserve memory for symbols: " SIZE_FORMAT " bytes.", symbol_rs_size); + log_error(cds)("Unable to reserve memory for symbols: %zu bytes.", symbol_rs_size); MetaspaceShared::unrecoverable_writing_error(); } _symbol_region.init(&_symbol_rs, &_symbol_vs); @@ -769,7 +769,7 @@ void MetaspaceShared::preload_and_dump(TRAPS) { 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 = " - SIZE_FORMAT "M", MaxHeapSize/M); + "%zuM", MaxHeapSize/M); MetaspaceShared::writing_error(); } else { log_error(cds)("%s: %s", PENDING_EXCEPTION->klass()->external_name(), @@ -798,15 +798,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 = " SIZE_FORMAT "M", MinHeapSize/M); + log_debug(cds)("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 = " SIZE_FORMAT "M", InitialHeapSize/M); + log_debug(cds)("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 = " SIZE_FORMAT "M", MaxHeapSize/M); + log_debug(cds)("Setting MaxHeapSize to 4G for CDS dumping, original size = %zuM", MaxHeapSize/M); FLAG_SET_ERGO(MaxHeapSize, max_heap_size); } } @@ -1082,7 +1082,7 @@ void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() { FileMapInfo* dynamic_mapinfo = nullptr; if (static_mapinfo != nullptr) { - log_info(cds)("Core region alignment: " SIZE_FORMAT, static_mapinfo->core_region_alignment()); + log_info(cds)("Core region alignment: %zu", static_mapinfo->core_region_alignment()); dynamic_mapinfo = open_dynamic_archive(); // First try to map at the requested address @@ -1236,9 +1236,9 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File } #endif // ASSERT - log_info(cds)("Reserved archive_space_rs [" INTPTR_FORMAT " - " INTPTR_FORMAT "] (" SIZE_FORMAT ") bytes", + log_info(cds)("Reserved archive_space_rs [" INTPTR_FORMAT " - " INTPTR_FORMAT "] (%zu) bytes", p2i(archive_space_rs.base()), p2i(archive_space_rs.end()), archive_space_rs.size()); - log_info(cds)("Reserved class_space_rs [" INTPTR_FORMAT " - " INTPTR_FORMAT "] (" SIZE_FORMAT ") bytes", + log_info(cds)("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()) { @@ -1467,8 +1467,7 @@ char* MetaspaceShared::reserve_address_space_for_archives(FileMapInfo* static_ma size_t class_space_size = CompressedClassSpaceSize; assert(CompressedClassSpaceSize > 0 && is_aligned(CompressedClassSpaceSize, class_space_alignment), - "CompressedClassSpaceSize malformed: " - SIZE_FORMAT, CompressedClassSpaceSize); + "CompressedClassSpaceSize malformed: %zu", CompressedClassSpaceSize); const size_t ccs_begin_offset = align_up(archive_space_size, class_space_alignment); const size_t gap_size = ccs_begin_offset - archive_space_size; @@ -1478,7 +1477,7 @@ char* MetaspaceShared::reserve_address_space_for_archives(FileMapInfo* static_ma guarantee(archive_space_size < max_encoding_range_size - class_space_alignment, "Archive too large"); if ((archive_space_size + gap_size + class_space_size) > max_encoding_range_size) { class_space_size = align_down(max_encoding_range_size - archive_space_size - gap_size, class_space_alignment); - log_info(metaspace)("CDS initialization: reducing class space size from " SIZE_FORMAT " to " SIZE_FORMAT, + log_info(metaspace)("CDS initialization: reducing class space size from %zu to %zu", CompressedClassSpaceSize, class_space_size); FLAG_SET_ERGO(CompressedClassSpaceSize, class_space_size); } @@ -1600,8 +1599,8 @@ MapArchiveResult MetaspaceShared::map_archive(FileMapInfo* mapinfo, char* mapped mapinfo->set_is_mapped(false); if (mapinfo->core_region_alignment() != (size_t)core_region_alignment()) { - log_info(cds)("Unable to map CDS archive -- core_region_alignment() expected: " SIZE_FORMAT - " actual: " SIZE_FORMAT, mapinfo->core_region_alignment(), core_region_alignment()); + log_info(cds)("Unable to map CDS archive -- core_region_alignment() expected: %zu" + " actual: %zu", mapinfo->core_region_alignment(), core_region_alignment()); return MAP_ARCHIVE_OTHER_FAILURE; } @@ -1770,7 +1769,7 @@ void MetaspaceShared::print_on(outputStream* st) { address static_top = (address)_shared_metaspace_static_top; address top = (address)MetaspaceObj::shared_metaspace_top(); st->print("[" PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "), ", p2i(base), p2i(static_top), p2i(top)); - st->print("size " SIZE_FORMAT ", ", top - base); + st->print("size %zu, ", top - base); st->print("SharedBaseAddress: " PTR_FORMAT ", ArchiveRelocationMode: %d.", SharedBaseAddress, ArchiveRelocationMode); } else { st->print("CDS archive(s) not mapped"); diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index c552e48c8b8..5724a5fa6ab 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -5663,7 +5663,7 @@ void ClassFileParser::mangle_hidden_class_name(InstanceKlass* const ik) { static volatile size_t counter = 0; Atomic::cmpxchg(&counter, (size_t)0, Arguments::default_SharedBaseAddress()); // initialize it size_t new_id = Atomic::add(&counter, (size_t)1); - jio_snprintf(addr_buf, 20, SIZE_FORMAT_X, new_id); + jio_snprintf(addr_buf, 20, "0x%zx", new_id); } else { jio_snprintf(addr_buf, 20, INTPTR_FORMAT, p2i(ik)); } diff --git a/src/hotspot/share/classfile/classLoaderStats.cpp b/src/hotspot/share/classfile/classLoaderStats.cpp index 1216811aeea..3c54cb44c29 100644 --- a/src/hotspot/share/classfile/classLoaderStats.cpp +++ b/src/hotspot/share/classfile/classLoaderStats.cpp @@ -112,7 +112,7 @@ bool ClassLoaderStatsClosure::do_entry(oop const& key, ClassLoaderStats const& c Klass* class_loader_klass = (cls._class_loader == nullptr ? nullptr : cls._class_loader->klass()); Klass* parent_klass = (cls._parent == nullptr ? nullptr : cls._parent->klass()); - _out->print(INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " %6zu " SIZE_FORMAT_W(8) " " SIZE_FORMAT_W(8) " ", + _out->print(INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " %6zu %8zu %8zu ", p2i(class_loader_klass), p2i(parent_klass), p2i(cls._cld), cls._classes_count, cls._chunk_sz, cls._block_sz); @@ -123,7 +123,7 @@ bool ClassLoaderStatsClosure::do_entry(oop const& key, ClassLoaderStats const& c } _out->cr(); if (cls._hidden_classes_count > 0) { - _out->print_cr(SPACE SPACE SPACE " %6zu " SIZE_FORMAT_W(8) " " SIZE_FORMAT_W(8) " + hidden classes", + _out->print_cr(SPACE SPACE SPACE " %6zu %8zu %8zu + hidden classes", "", "", "", cls._hidden_classes_count, cls._hidden_chunk_sz, cls._hidden_block_sz); @@ -137,7 +137,7 @@ void ClassLoaderStatsClosure::print() { _stats->iterate(this); _out->print("Total = %-6zu", _total_loaders); _out->print(SPACE SPACE SPACE " ", "", "", ""); - _out->print_cr("%6zu " SIZE_FORMAT_W(8) " " SIZE_FORMAT_W(8) " ", + _out->print_cr("%6zu %8zu %8zu ", _total_classes, _total_chunk_sz, _total_block_sz); diff --git a/src/hotspot/share/classfile/dictionary.cpp b/src/hotspot/share/classfile/dictionary.cpp index a6df19ef915..6f853b3f0a3 100644 --- a/src/hotspot/share/classfile/dictionary.cpp +++ b/src/hotspot/share/classfile/dictionary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -46,7 +46,7 @@ Dictionary::Dictionary(ClassLoaderData* loader_data, size_t table_size) size_t start_size_log_2 = MAX2(log2i_ceil(table_size), 2); // 2 is minimum size even though some dictionaries only have one entry size_t current_size = ((size_t)1) << start_size_log_2; - log_info(class, loader, data)("Dictionary start size: " SIZE_FORMAT " (" SIZE_FORMAT ")", + log_info(class, loader, data)("Dictionary start size: %zu (%zu)", current_size, start_size_log_2); _table = new ConcurrentTable(start_size_log_2, END_SIZE, REHASH_LEN); } diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index 650d0a9fa74..700c6da0f90 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -1242,8 +1242,8 @@ void java_lang_Class::fixup_module_field(Klass* k, Handle module) { void java_lang_Class::set_oop_size(HeapWord* java_class, size_t size) { assert(_oop_size_offset != 0, "must be set"); - assert(size > 0, "Oop size must be greater than zero, not " SIZE_FORMAT, size); - assert(size <= INT_MAX, "Lossy conversion: " SIZE_FORMAT, size); + assert(size > 0, "Oop size must be greater than zero, not %zu", size); + assert(size <= INT_MAX, "Lossy conversion: %zu", size); *(int*)(((char*)java_class) + _oop_size_offset) = (int)size; } diff --git a/src/hotspot/share/classfile/stringTable.cpp b/src/hotspot/share/classfile/stringTable.cpp index 2574a3918b1..897b42b12f6 100644 --- a/src/hotspot/share/classfile/stringTable.cpp +++ b/src/hotspot/share/classfile/stringTable.cpp @@ -311,7 +311,7 @@ public: void StringTable::create_table() { size_t start_size_log_2 = log2i_ceil(StringTableSize); _current_size = ((size_t)1) << start_size_log_2; - log_trace(stringtable)("Start size: " SIZE_FORMAT " (" SIZE_FORMAT ")", + log_trace(stringtable)("Start size: %zu (%zu)", _current_size, start_size_log_2); _local_table = new StringTableHash(start_size_log_2, END_SIZE, REHASH_LEN, true); _oop_storage = OopStorageSet::create_weak("StringTable Weak", mtSymbol); @@ -582,7 +582,7 @@ void StringTable::grow(JavaThread* jt) { } gt.done(jt); _current_size = table_size(); - log_debug(stringtable)("Grown to size:" SIZE_FORMAT, _current_size); + log_debug(stringtable)("Grown to size:%zu", _current_size); } struct StringTableDoDelete : StackObj { @@ -631,7 +631,7 @@ void StringTable::clean_dead_entries(JavaThread* jt) { } void StringTable::gc_notification(size_t num_dead) { - log_trace(stringtable)("Uncleaned items:" SIZE_FORMAT, num_dead); + log_trace(stringtable)("Uncleaned items:%zu", num_dead); if (has_work()) { return; diff --git a/src/hotspot/share/classfile/symbolTable.cpp b/src/hotspot/share/classfile/symbolTable.cpp index 040ba4795e4..b08089f13de 100644 --- a/src/hotspot/share/classfile/symbolTable.cpp +++ b/src/hotspot/share/classfile/symbolTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -214,7 +214,7 @@ private: void SymbolTable::create_table () { size_t start_size_log_2 = log2i_ceil(SymbolTableSize); _current_size = ((size_t)1) << start_size_log_2; - log_trace(symboltable)("Start size: " SIZE_FORMAT " (" SIZE_FORMAT ")", + log_trace(symboltable)("Start size: %zu (%zu)", _current_size, start_size_log_2); _local_table = new SymbolTableHash(start_size_log_2, END_SIZE, REHASH_LEN, true); @@ -749,7 +749,7 @@ void SymbolTable::grow(JavaThread* jt) { } gt.done(jt); _current_size = table_size(); - log_debug(symboltable)("Grown to size:" SIZE_FORMAT, _current_size); + log_debug(symboltable)("Grown to size:%zu", _current_size); } struct SymbolTableDoDelete : StackObj { @@ -798,7 +798,7 @@ void SymbolTable::clean_dead_entries(JavaThread* jt) { Atomic::add(&_symbols_counted, stdc._processed); - log_debug(symboltable)("Cleaned " SIZE_FORMAT " of " SIZE_FORMAT, + log_debug(symboltable)("Cleaned %zu of %zu", stdd._deleted, stdc._processed); } @@ -931,29 +931,29 @@ void SymbolTable::print_histogram() { HistogramIterator hi; _local_table->do_scan(Thread::current(), hi); tty->print_cr("Symbol Table Histogram:"); - tty->print_cr(" Total number of symbols " SIZE_FORMAT_W(7), hi.total_count); - tty->print_cr(" Total size in memory " SIZE_FORMAT_W(7) "K", (hi.total_size * wordSize) / K); - tty->print_cr(" Total counted " SIZE_FORMAT_W(7), _symbols_counted); - tty->print_cr(" Total removed " SIZE_FORMAT_W(7), _symbols_removed); + tty->print_cr(" Total number of symbols %7zu", hi.total_count); + tty->print_cr(" Total size in memory %7zuK", (hi.total_size * wordSize) / K); + tty->print_cr(" Total counted %7zu", _symbols_counted); + tty->print_cr(" Total removed %7zu", _symbols_removed); if (_symbols_counted > 0) { tty->print_cr(" Percent removed %3.2f", ((double)_symbols_removed / (double)_symbols_counted) * 100); } - tty->print_cr(" Reference counts " SIZE_FORMAT_W(7), Symbol::_total_count); - tty->print_cr(" Symbol arena used " SIZE_FORMAT_W(7) "K", arena()->used() / K); - tty->print_cr(" Symbol arena size " SIZE_FORMAT_W(7) "K", arena()->size_in_bytes() / K); - tty->print_cr(" Total symbol length " SIZE_FORMAT_W(7), hi.total_length); - tty->print_cr(" Maximum symbol length " SIZE_FORMAT_W(7), hi.max_length); + tty->print_cr(" Reference counts %7zu", Symbol::_total_count); + tty->print_cr(" Symbol arena used %7zuK", arena()->used() / K); + tty->print_cr(" Symbol arena size %7zuK", arena()->size_in_bytes() / K); + tty->print_cr(" Total symbol length %7zu", hi.total_length); + tty->print_cr(" Maximum symbol length %7zu", hi.max_length); tty->print_cr(" Average symbol length %7.2f", ((double)hi.total_length / (double)hi.total_count)); tty->print_cr(" Symbol length histogram:"); tty->print_cr(" %6s %10s %10s", "Length", "#Symbols", "Size"); for (size_t i = 0; i < hi.results_length; i++) { if (hi.counts[i] > 0) { - tty->print_cr(" " SIZE_FORMAT_W(6) " " SIZE_FORMAT_W(10) " " SIZE_FORMAT_W(10) "K", + tty->print_cr(" %6zu %10zu %10zuK", i, hi.counts[i], (hi.sizes[i] * wordSize) / K); } } - tty->print_cr(" >=" SIZE_FORMAT_W(6) " " SIZE_FORMAT_W(10) " " SIZE_FORMAT_W(10) "K\n", + tty->print_cr(" >= %6zu %10zu %10zuK\n", hi.results_length, hi.out_of_range_count, (hi.out_of_range_size*wordSize) / K); } #endif // PRODUCT diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index ed8147a95a8..85725116f35 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -181,7 +181,7 @@ static void check_min_size(const char* codeheap, size_t size, size_t required_si log_debug(codecache)("Code heap (%s) size %zuK below required minimal size %zuK", codeheap, size/K, required_size/K); err_msg title("Not enough space in %s to run VM", codeheap); - err_msg message(SIZE_FORMAT "K < %zuK", size/K, required_size/K); + err_msg message("%zuK < %zuK", size/K, required_size/K); vm_exit_during_initialization(title, message); } } diff --git a/src/hotspot/share/code/codeHeapState.cpp b/src/hotspot/share/code/codeHeapState.cpp index c577f86a3c3..40b778c198d 100644 --- a/src/hotspot/share/code/codeHeapState.cpp +++ b/src/hotspot/share/code/codeHeapState.cpp @@ -1042,19 +1042,19 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular // interspersed with print data from other threads. We take this risk intentionally. // Getting stalled waiting for tty_lock while holding the CodeCache_lock is not desirable. printBox(ast, '-', "Global CodeHeap statistics for segment ", heapName); - ast->print_cr("freeSpace = " SIZE_FORMAT_W(8) "k, nBlocks_free = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", freeSpace/(size_t)K, nBlocks_free, (100.0*freeSpace)/size, (100.0*freeSpace)/res_size); - ast->print_cr("usedSpace = " SIZE_FORMAT_W(8) "k, nBlocks_used = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", usedSpace/(size_t)K, nBlocks_used, (100.0*usedSpace)/size, (100.0*usedSpace)/res_size); - ast->print_cr(" Tier1 Space = " SIZE_FORMAT_W(8) "k, nBlocks_t1 = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", t1Space/(size_t)K, nBlocks_t1, (100.0*t1Space)/size, (100.0*t1Space)/res_size); - ast->print_cr(" Tier2 Space = " SIZE_FORMAT_W(8) "k, nBlocks_t2 = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", t2Space/(size_t)K, nBlocks_t2, (100.0*t2Space)/size, (100.0*t2Space)/res_size); - ast->print_cr(" Alive Space = " SIZE_FORMAT_W(8) "k, nBlocks_alive = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", aliveSpace/(size_t)K, nBlocks_alive, (100.0*aliveSpace)/size, (100.0*aliveSpace)/res_size); - ast->print_cr(" disconnected = " SIZE_FORMAT_W(8) "k, nBlocks_disconn = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", disconnSpace/(size_t)K, nBlocks_disconn, (100.0*disconnSpace)/size, (100.0*disconnSpace)/res_size); - ast->print_cr(" not entrant = " SIZE_FORMAT_W(8) "k, nBlocks_notentr = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", notentrSpace/(size_t)K, nBlocks_notentr, (100.0*notentrSpace)/size, (100.0*notentrSpace)/res_size); - ast->print_cr(" stubSpace = " SIZE_FORMAT_W(8) "k, nBlocks_stub = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", stubSpace/(size_t)K, nBlocks_stub, (100.0*stubSpace)/size, (100.0*stubSpace)/res_size); + ast->print_cr("freeSpace = %8zuk, nBlocks_free = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", freeSpace/(size_t)K, nBlocks_free, (100.0*freeSpace)/size, (100.0*freeSpace)/res_size); + ast->print_cr("usedSpace = %8zuk, nBlocks_used = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", usedSpace/(size_t)K, nBlocks_used, (100.0*usedSpace)/size, (100.0*usedSpace)/res_size); + ast->print_cr(" Tier1 Space = %8zuk, nBlocks_t1 = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", t1Space/(size_t)K, nBlocks_t1, (100.0*t1Space)/size, (100.0*t1Space)/res_size); + ast->print_cr(" Tier2 Space = %8zuk, nBlocks_t2 = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", t2Space/(size_t)K, nBlocks_t2, (100.0*t2Space)/size, (100.0*t2Space)/res_size); + ast->print_cr(" Alive Space = %8zuk, nBlocks_alive = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", aliveSpace/(size_t)K, nBlocks_alive, (100.0*aliveSpace)/size, (100.0*aliveSpace)/res_size); + ast->print_cr(" disconnected = %8zuk, nBlocks_disconn = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", disconnSpace/(size_t)K, nBlocks_disconn, (100.0*disconnSpace)/size, (100.0*disconnSpace)/res_size); + ast->print_cr(" not entrant = %8zuk, nBlocks_notentr = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", notentrSpace/(size_t)K, nBlocks_notentr, (100.0*notentrSpace)/size, (100.0*notentrSpace)/res_size); + ast->print_cr(" stubSpace = %8zuk, nBlocks_stub = %6d, %10.3f%% of capacity, %10.3f%% of max_capacity", stubSpace/(size_t)K, nBlocks_stub, (100.0*stubSpace)/size, (100.0*stubSpace)/res_size); ast->print_cr("ZombieBlocks = %8d. These are HeapBlocks which could not be identified as CodeBlobs.", nBlocks_zomb); ast->cr(); - ast->print_cr("Segment start = " INTPTR_FORMAT ", used space = " SIZE_FORMAT_W(8)"k", p2i(low_bound), size/K); - ast->print_cr("Segment end (used) = " INTPTR_FORMAT ", remaining space = " SIZE_FORMAT_W(8)"k", p2i(low_bound) + size, (res_size - size)/K); - ast->print_cr("Segment end (reserved) = " INTPTR_FORMAT ", reserved space = " SIZE_FORMAT_W(8)"k", p2i(low_bound) + res_size, res_size/K); + ast->print_cr("Segment start = " INTPTR_FORMAT ", used space = %8zuk", p2i(low_bound), size/K); + ast->print_cr("Segment end (used) = " INTPTR_FORMAT ", remaining space = %8zuk", p2i(low_bound) + size, (res_size - size)/K); + ast->print_cr("Segment end (reserved) = " INTPTR_FORMAT ", reserved space = %8zuk", p2i(low_bound) + res_size, res_size/K); ast->cr(); ast->print_cr("latest allocated compilation id = %d", latest_compilation_id); ast->print_cr("highest observed compilation id = %d", highest_compilation_id); @@ -1303,7 +1303,7 @@ void CodeHeapState::print_usedSpace(outputStream* out, CodeHeap* heap) { if (is_nmethod) { //---< nMethod size in hex >--- ast->print(UINT32_FORMAT_X_0, TopSizeArray[i].nm_size); - ast->print("(" SIZE_FORMAT_W(4) "K)", TopSizeArray[i].nm_size/K); + ast->print("(%4zuK)", TopSizeArray[i].nm_size/K); ast->fill_to(51); ast->print(" %c", blobTypeChar[TopSizeArray[i].type]); //---< compiler information >--- @@ -1315,7 +1315,7 @@ void CodeHeapState::print_usedSpace(outputStream* out, CodeHeap* heap) { } else { //---< block size in hex >--- ast->print(UINT32_FORMAT_X_0, (unsigned int)(TopSizeArray[i].len<print("(" SIZE_FORMAT_W(4) "K)", (TopSizeArray[i].len<print("(%4zuK)", (TopSizeArray[i].len<--- ast->fill_to(56); //---< name and signature >--- @@ -1362,17 +1362,17 @@ void CodeHeapState::print_usedSpace(outputStream* out, CodeHeap* heap) { ast->print_cr("[Size Range)------avg.-size-+----count-+"); for (unsigned int i = 0; i < nSizeDistElements; i++) { if (SizeDistributionArray[i].rangeStart<print("[" SIZE_FORMAT_W(5) " .." SIZE_FORMAT_W(5) " ): " + ast->print("[%5zu ..%5zu ): " ,(size_t)(SizeDistributionArray[i].rangeStart<print("[" SIZE_FORMAT_W(5) "K.." SIZE_FORMAT_W(5) "K): " + ast->print("[%5zuK..%5zuK): " ,(SizeDistributionArray[i].rangeStart<print("[" SIZE_FORMAT_W(5) "M.." SIZE_FORMAT_W(5) "M): " + ast->print("[%5zuM..%5zuM): " ,(SizeDistributionArray[i].rangeStart<print_cr("[Size Range)------avg.-size-+----count-+"); for (unsigned int i = 0; i < nSizeDistElements; i++) { if (SizeDistributionArray[i].rangeStart<print("[" SIZE_FORMAT_W(5) " .." SIZE_FORMAT_W(5) " ): " + ast->print("[%5zu ..%5zu ): " ,(size_t)(SizeDistributionArray[i].rangeStart<print("[" SIZE_FORMAT_W(5) "K.." SIZE_FORMAT_W(5) "K): " + ast->print("[%5zuK..%5zuK): " ,(SizeDistributionArray[i].rangeStart<print("[" SIZE_FORMAT_W(5) "M.." SIZE_FORMAT_W(5) "M): " + ast->print("[%5zuM..%5zuM): " ,(SizeDistributionArray[i].rangeStart<--- ast->print(UINT32_FORMAT_X_0, total_size); - ast->print("(" SIZE_FORMAT_W(4) "K)", total_size/K); + ast->print("(%4zuK)", total_size/K); //---< compiler information >--- ast->fill_to(51); ast->print("%5s %3d", compTypeName[StatArray[ix].compiler], StatArray[ix].level); diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index 518a53ca26e..8581fc23554 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -2778,9 +2778,9 @@ void CompileBroker::print_info(outputStream *out) { out->print_cr("CodeCache overview"); out->print_cr("--------------------------------------------------------"); out->cr(); - out->print_cr(" Reserved size : " SIZE_FORMAT_W(7) " KB", CodeCache::max_capacity() / K); - out->print_cr(" Committed size : " SIZE_FORMAT_W(7) " KB", CodeCache::capacity() / K); - out->print_cr(" Unallocated capacity : " SIZE_FORMAT_W(7) " KB", CodeCache::unallocated_capacity() / K); + out->print_cr(" Reserved size : %7zu KB", CodeCache::max_capacity() / K); + out->print_cr(" Committed size : %7zu KB", CodeCache::capacity() / K); + out->print_cr(" Unallocated capacity : %7zu KB", CodeCache::unallocated_capacity() / K); out->cr(); } diff --git a/src/hotspot/share/logging/logAsyncWriter.cpp b/src/hotspot/share/logging/logAsyncWriter.cpp index 3d987d04b8d..a025c857973 100644 --- a/src/hotspot/share/logging/logAsyncWriter.cpp +++ b/src/hotspot/share/logging/logAsyncWriter.cpp @@ -1,6 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. - * Copyright (c) 2023, 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 @@ -108,7 +108,7 @@ AsyncLogWriter::AsyncLogWriter() size_t size = AsyncLogBufferSize / 2; _buffer = new Buffer(size); _buffer_staging = new Buffer(size); - log_info(logging)("AsyncLogBuffer estimates memory use: " SIZE_FORMAT " bytes", size * 2); + log_info(logging)("AsyncLogBuffer estimates memory use: %zu bytes", size * 2); if (os::create_thread(this, os::asynclog_thread)) { _initialized = true; } else { diff --git a/src/hotspot/share/logging/logConfiguration.cpp b/src/hotspot/share/logging/logConfiguration.cpp index dfddfff2f05..88388710946 100644 --- a/src/hotspot/share/logging/logConfiguration.cpp +++ b/src/hotspot/share/logging/logConfiguration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, 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 @@ -214,8 +214,8 @@ size_t LogConfiguration::add_output(LogOutput* output) { void LogConfiguration::delete_output(size_t idx) { assert(idx > 1 && idx < _n_outputs, - "idx must be in range 1 < idx < _n_outputs, but idx = " SIZE_FORMAT - " and _n_outputs = " SIZE_FORMAT, idx, _n_outputs); + "idx must be in range 1 < idx < _n_outputs, but idx = %zu" + " and _n_outputs = %zu", idx, _n_outputs); LogOutput* output = _outputs[idx]; // Swap places with the last output and shrink the array _outputs[idx] = _outputs[--_n_outputs]; @@ -240,7 +240,7 @@ void LogConfiguration::delete_output(size_t idx) { // void LogConfiguration::configure_output(size_t idx, const LogSelectionList& selections, const LogDecorators& decorators) { assert(ConfigurationLock::current_thread_has_lock(), "Must hold configuration lock to call this function."); - assert(idx < _n_outputs, "Invalid index, idx = " SIZE_FORMAT " and _n_outputs = " SIZE_FORMAT, idx, _n_outputs); + assert(idx < _n_outputs, "Invalid index, idx = %zu and _n_outputs = %zu", idx, _n_outputs); LogOutput* output = _outputs[idx]; output->_reconfigured = true; @@ -351,7 +351,7 @@ void LogConfiguration::configure_stdout(LogLevelType level, int exact_match, ... } } assert(i < LogTag::MaxTags || static_cast(va_arg(ap, int)) == LogTag::__NO_TAG, - "Too many tags specified! Can only have up to " SIZE_FORMAT " tags in a tag set.", LogTag::MaxTags); + "Too many tags specified! Can only have up to %zu tags in a tag set.", LogTag::MaxTags); va_end(ap); LogSelection selection(tags, !exact_match, level); @@ -500,7 +500,7 @@ bool LogConfiguration::parse_log_arguments(const char* outputstr, size_t idx; bool added = false; if (outputstr[0] == '#') { // Output specified using index - int ret = sscanf(outputstr + 1, SIZE_FORMAT, &idx); + int ret = sscanf(outputstr + 1, "%zu", &idx); if (ret != 1 || idx >= _n_outputs) { errstream->print_cr("Invalid output index '%s'", outputstr); return false; @@ -566,7 +566,7 @@ void LogConfiguration::describe_available(outputStream* out) { void LogConfiguration::describe_current_configuration(outputStream* out) { out->print_cr("Log output configuration:"); for (size_t i = 0; i < _n_outputs; i++) { - out->print(" #" SIZE_FORMAT ": ", i); + out->print(" #%zu: ", i); _outputs[i]->describe(out); if (_outputs[i]->is_reconfigured()) { out->print(" (reconfigured)"); diff --git a/src/hotspot/share/logging/logFileOutput.cpp b/src/hotspot/share/logging/logFileOutput.cpp index 783be865861..78dee5e3792 100644 --- a/src/hotspot/share/logging/logFileOutput.cpp +++ b/src/hotspot/share/logging/logFileOutput.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, 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 @@ -185,7 +185,7 @@ bool LogFileOutput::set_option(const char* key, const char* value, outputStream* success = Arguments::atojulong(value, &longval); if (!success || (longval > SIZE_MAX)) { errstream->print_cr("Invalid option: %s must be in range [0, " - SIZE_FORMAT "]", FileSizeOptionKey, (size_t)SIZE_MAX); + "%zu]", FileSizeOptionKey, (size_t)SIZE_MAX); success = false; } else { _rotate_size = static_cast(longval); @@ -215,7 +215,7 @@ bool LogFileOutput::initialize(const char* options, outputStream* errstream) { } log_trace(logging)("Initializing logging to file '%s' (filecount: %u" - ", filesize: " SIZE_FORMAT " KiB).", + ", filesize: %zu KiB).", _file_name, _file_count, _rotate_size / K); if (_file_count > 0 && file_exist) { @@ -461,7 +461,7 @@ char* LogFileOutput::make_file_name(const char* file_name, void LogFileOutput::describe(outputStream *out) { LogFileStreamOutput::describe(out); - out->print(",filecount=%u,filesize=" SIZE_FORMAT "%s,async=%s", _file_count, + out->print(",filecount=%u,filesize=%zu%s,async=%s", _file_count, byte_size_in_proper_unit(_rotate_size), proper_unit_for_byte_size(_rotate_size), LogConfiguration::is_async_mode() ? "true" : "false"); diff --git a/src/hotspot/share/logging/logSelection.cpp b/src/hotspot/share/logging/logSelection.cpp index f5a0ab1bf53..1b5251ae266 100644 --- a/src/hotspot/share/logging/logSelection.cpp +++ b/src/hotspot/share/logging/logSelection.cpp @@ -145,7 +145,7 @@ static LogSelection parse_internal(char *str, outputStream* errstream) { } if (ntags == LogTag::MaxTags) { if (errstream != nullptr) { - errstream->print_cr("Too many tags in log selection '%s' (can only have up to " SIZE_FORMAT " tags).", + errstream->print_cr("Too many tags in log selection '%s' (can only have up to %zu tags).", str, LogTag::MaxTags); } return LogSelection::Invalid; diff --git a/src/hotspot/share/logging/logSelectionList.cpp b/src/hotspot/share/logging/logSelectionList.cpp index d7e5981aa00..7fdf5e6778e 100644 --- a/src/hotspot/share/logging/logSelectionList.cpp +++ b/src/hotspot/share/logging/logSelectionList.cpp @@ -72,7 +72,7 @@ bool LogSelectionList::parse(const char* str, outputStream* errstream) { for (char *comma_pos = copy, *cur = copy; success; cur = comma_pos + 1) { if (_nselections == MaxSelections) { if (errstream != nullptr) { - errstream->print_cr("Can not have more than " SIZE_FORMAT " log selections in a single configuration.", + errstream->print_cr("Can not have more than %zu log selections in a single configuration.", MaxSelections); } success = false; diff --git a/src/hotspot/share/nmt/mallocTracker.cpp b/src/hotspot/share/nmt/mallocTracker.cpp index 6829db90b4b..eb23c4dc9c5 100644 --- a/src/hotspot/share/nmt/mallocTracker.cpp +++ b/src/hotspot/share/nmt/mallocTracker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2023 SAP SE. All rights reserved. * Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates. * @@ -292,7 +292,7 @@ bool MallocTracker::print_pointer_information(const void* p, outputStream* st) { } else { where = "just outside of"; } - st->print_cr(PTR_FORMAT " %s %s malloced block starting at " PTR_FORMAT ", size " SIZE_FORMAT ", tag %s", + st->print_cr(PTR_FORMAT " %s %s malloced block starting at " PTR_FORMAT ", size %zu, tag %s", p2i(p), where, (block->is_dead() ? "dead" : "live"), p2i(block + 1), // lets print the payload start, not the header diff --git a/src/hotspot/share/nmt/memReporter.cpp b/src/hotspot/share/nmt/memReporter.cpp index a7575c820c5..e6617223c16 100644 --- a/src/hotspot/share/nmt/memReporter.cpp +++ b/src/hotspot/share/nmt/memReporter.cpp @@ -42,8 +42,8 @@ // Diff two counters, express them as signed, with range checks static ssize_t counter_diff(size_t c1, size_t c2) { - assert(c1 <= SSIZE_MAX, "counter out of range: " SIZE_FORMAT ".", c1); - assert(c2 <= SSIZE_MAX, "counter out of range: " SIZE_FORMAT ".", c2); + assert(c1 <= SSIZE_MAX, "counter out of range: %zu.", c1); + assert(c2 <= SSIZE_MAX, "counter out of range: %zu.", c2); if (c1 > SSIZE_MAX || c2 > SSIZE_MAX) { return 0; } @@ -63,10 +63,10 @@ size_t MemReporterBase::committed_total(const MallocMemory* malloc, const Virtua void MemReporterBase::print_total(size_t reserved, size_t committed, size_t peak) const { const char* scale = current_scale(); - output()->print("reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s", + output()->print("reserved=%zu%s, committed=%zu%s", amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale); if (peak != 0) { - output()->print(", peak=" SIZE_FORMAT "%s", amount_in_current_scale(peak), scale); + output()->print(", peak=%zu%s", amount_in_current_scale(peak), scale); } } @@ -79,16 +79,16 @@ void MemReporterBase::print_malloc(const MemoryCounter* c, MemTag mem_tag) const const size_t count = c->count(); if (mem_tag != mtNone) { - out->print("(%s" SIZE_FORMAT "%s type=%s", alloc_type, + out->print("(%s%zu%s type=%s", alloc_type, amount_in_current_scale(amount), scale, NMTUtil::tag_to_name(mem_tag)); } else { - out->print("(%s" SIZE_FORMAT "%s", alloc_type, + out->print("(%s%zu%s", alloc_type, amount_in_current_scale(amount), scale); } // blends out mtChunk count number if (count > 0) { - out->print(" #" SIZE_FORMAT "", count); + out->print(" #%zu", count); } out->print(")"); @@ -98,7 +98,7 @@ void MemReporterBase::print_malloc(const MemoryCounter* c, MemTag mem_tag) const out->print_raw(" (at peak)"); } else if (pk_amount > amount) { size_t pk_count = c->peak_count(); - out->print(" (peak=" SIZE_FORMAT "%s #" SIZE_FORMAT ")", + out->print(" (peak=%zu%s #%zu)", amount_in_current_scale(pk_amount), scale, pk_count); } } @@ -106,12 +106,12 @@ void MemReporterBase::print_malloc(const MemoryCounter* c, MemTag mem_tag) const void MemReporterBase::print_virtual_memory(size_t reserved, size_t committed, size_t peak) const { outputStream* out = output(); const char* scale = current_scale(); - out->print("(mmap: reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s, ", + out->print("(mmap: reserved=%zu%s, committed=%zu%s, ", amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale); if (peak == committed) { out->print_raw("at peak)"); } else { - out->print("peak=" SIZE_FORMAT "%s)", amount_in_current_scale(peak), scale); + out->print("peak=%zu%s)", amount_in_current_scale(peak), scale); } } @@ -122,7 +122,7 @@ void MemReporterBase::print_arena(const MemoryCounter* c) const { const size_t amount = c->size(); const size_t count = c->count(); - out->print("(arena=" SIZE_FORMAT "%s #" SIZE_FORMAT ")", + out->print("(arena=%zu%s #%zu)", amount_in_current_scale(amount), scale, count); size_t pk_amount = c->peak_size(); @@ -130,14 +130,14 @@ void MemReporterBase::print_arena(const MemoryCounter* c) const { out->print_raw(" (at peak)"); } else if (pk_amount > amount) { size_t pk_count = c->peak_count(); - out->print(" (peak=" SIZE_FORMAT "%s #" SIZE_FORMAT ")", + out->print(" (peak=%zu%s #%zu)", amount_in_current_scale(pk_amount), scale, pk_count); } } void MemReporterBase::print_virtual_memory_region(const char* type, address base, size_t size) const { const char* scale = current_scale(); - output()->print("[" PTR_FORMAT " - " PTR_FORMAT "] %s " SIZE_FORMAT "%s", + output()->print("[" PTR_FORMAT " - " PTR_FORMAT "] %s %zu%s", p2i(base), p2i(base + size), type, amount_in_current_scale(size), scale); } @@ -165,7 +165,7 @@ void MemSummaryReporter::report() { print_total(total_reserved_amount, total_committed_amount); out->cr(); INDENT_BY(7, - out->print_cr("malloc: " SIZE_FORMAT "%s #" SIZE_FORMAT ", peak=" SIZE_FORMAT "%s #" SIZE_FORMAT, + out->print_cr("malloc: %zu%s #%zu, peak=%zu%s #%zu", amount_in_current_scale(total_malloced_bytes), current_scale(), _malloc_snapshot->total_count(), amount_in_current_scale(_malloc_snapshot->total_peak()), @@ -224,7 +224,7 @@ void MemSummaryReporter::report_summary_of_type(MemTag mem_tag, #if INCLUDE_CDS if (mem_tag == mtClassShared) { size_t read_only_bytes = FileMapInfo::readonly_total(); - output()->print(", readonly=" SIZE_FORMAT "%s", + output()->print(", readonly=%zu%s", amount_in_current_scale(read_only_bytes), scale); } #endif @@ -234,14 +234,14 @@ void MemSummaryReporter::report_summary_of_type(MemTag mem_tag, if (mem_tag == mtClass) { // report class count - out->print_cr("(classes #" SIZE_FORMAT ")", (_instance_class_count + _array_class_count)); - out->print_cr("( instance classes #" SIZE_FORMAT ", array classes #" SIZE_FORMAT ")", + out->print_cr("(classes #%zu)", (_instance_class_count + _array_class_count)); + out->print_cr("( instance classes #%zu, array classes #%zu)", _instance_class_count, _array_class_count); } else if (mem_tag == mtThread) { const VirtualMemory* thread_stack_usage = _vm_snapshot->by_type(mtThreadStack); // report thread count - out->print_cr("(threads #" SIZE_FORMAT ")", ThreadStackTracker::thread_count()); + out->print_cr("(threads #%zu)", ThreadStackTracker::thread_count()); out->print("(stack: "); print_total(thread_stack_usage->reserved(), thread_stack_usage->committed(), thread_stack_usage->peak_size()); out->print_cr(")"); @@ -265,7 +265,7 @@ void MemSummaryReporter::report_summary_of_type(MemTag mem_tag, if (mem_tag == mtNMT && amount_in_current_scale(_malloc_snapshot->malloc_overhead()) > 0) { - out->print_cr("(tracking overhead=" SIZE_FORMAT "%s)", + out->print_cr("(tracking overhead=%zu%s)", amount_in_current_scale(_malloc_snapshot->malloc_overhead()), scale); } else if (mem_tag == mtClass) { // Metadata information @@ -301,8 +301,8 @@ void MemSummaryReporter::report_metadata(Metaspace::MetadataType type) const { out->print("( "); print_total(stats.reserved(), stats.committed()); out->print_cr(")"); - out->print_cr("( used=" SIZE_FORMAT "%s)", amount_in_current_scale(stats.used()), scale); - out->print_cr("( waste=" SIZE_FORMAT "%s =%2.2f%%)", amount_in_current_scale(waste), + out->print_cr("( used=%zu%s)", amount_in_current_scale(stats.used()), scale); + out->print_cr("( waste=%zu%s =%2.2f%%)", amount_in_current_scale(waste), scale, waste_percentage); } @@ -540,7 +540,7 @@ void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t cur outputStream* out = output(); const char* alloc_tag = (mem_tag == mtThread) ? "" : "malloc="; - out->print("%s" SIZE_FORMAT "%s", alloc_tag, amount_in_current_scale(current_amount), scale); + out->print("%s%zu%s", alloc_tag, amount_in_current_scale(current_amount), scale); // Report type only if it is valid and not under "thread" category if (mem_tag != mtNone && mem_tag != mtThread) { out->print(" type=%s", NMTUtil::tag_to_name(mem_tag)); @@ -551,7 +551,7 @@ void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t cur out->print(" " INT64_PLUS_FORMAT "%s", amount_diff, scale); } if (current_count > 0) { - out->print(" #" SIZE_FORMAT "", current_count); + out->print(" #%zu", current_count); const ssize_t delta_count = counter_diff(current_count, early_count); if (delta_count != 0) { out->print(" %+zd", delta_count); @@ -563,13 +563,13 @@ void MemSummaryDiffReporter::print_arena_diff(size_t current_amount, size_t curr size_t early_amount, size_t early_count) const { const char* scale = current_scale(); outputStream* out = output(); - out->print("arena=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale); + out->print("arena=%zu%s", amount_in_current_scale(current_amount), scale); int64_t amount_diff = diff_in_current_scale(current_amount, early_amount); if (amount_diff != 0) { out->print(" " INT64_PLUS_FORMAT "%s", amount_diff, scale); } - out->print(" #" SIZE_FORMAT "", current_count); + out->print(" #%zu", current_count); const ssize_t delta_count = counter_diff(current_count, early_count); if (delta_count != 0) { out->print(" %+zd", delta_count); @@ -580,13 +580,13 @@ void MemSummaryDiffReporter::print_virtual_memory_diff(size_t current_reserved, size_t early_reserved, size_t early_committed) const { const char* scale = current_scale(); outputStream* out = output(); - out->print("reserved=" SIZE_FORMAT "%s", amount_in_current_scale(current_reserved), scale); + out->print("reserved=%zu%s", amount_in_current_scale(current_reserved), scale); int64_t reserved_diff = diff_in_current_scale(current_reserved, early_reserved); if (reserved_diff != 0) { out->print(" " INT64_PLUS_FORMAT "%s", reserved_diff, scale); } - out->print(", committed=" SIZE_FORMAT "%s", amount_in_current_scale(current_committed), scale); + out->print(", committed=%zu%s", amount_in_current_scale(current_committed), scale); int64_t committed_diff = diff_in_current_scale(current_committed, early_committed); if (committed_diff != 0) { out->print(" " INT64_PLUS_FORMAT "%s", committed_diff, scale); @@ -646,7 +646,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MemTag mem_tag, // detail lines if (mem_tag == mtClass) { // report class count - out->print("(classes #" SIZE_FORMAT, _current_baseline.class_count()); + out->print("(classes #%zu", _current_baseline.class_count()); const ssize_t class_count_diff = counter_diff(_current_baseline.class_count(), _early_baseline.class_count()); if (class_count_diff != 0) { @@ -654,13 +654,13 @@ void MemSummaryDiffReporter::diff_summary_of_type(MemTag mem_tag, } out->print_cr(")"); - out->print("( instance classes #" SIZE_FORMAT, _current_baseline.instance_class_count()); + out->print("( instance classes #%zu", _current_baseline.instance_class_count()); const ssize_t instance_class_count_diff = counter_diff(_current_baseline.instance_class_count(), _early_baseline.instance_class_count()); if (instance_class_count_diff != 0) { out->print(" %+zd", instance_class_count_diff); } - out->print(", array classes #" SIZE_FORMAT, _current_baseline.array_class_count()); + out->print(", array classes #%zu", _current_baseline.array_class_count()); const ssize_t array_class_count_diff = counter_diff(_current_baseline.array_class_count(), _early_baseline.array_class_count()); if (array_class_count_diff != 0) { @@ -670,7 +670,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MemTag mem_tag, } else if (mem_tag == mtThread) { // report thread count - out->print("(threads #" SIZE_FORMAT, _current_baseline.thread_count()); + out->print("(threads #%zu", _current_baseline.thread_count()); const ssize_t thread_count_diff = counter_diff(_current_baseline.thread_count(), _early_baseline.thread_count()); if (thread_count_diff != 0) { out->print(" %+zd", thread_count_diff); @@ -724,7 +724,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MemTag mem_tag, size_t current_tracking_overhead = amount_in_current_scale(_current_baseline.malloc_tracking_overhead()); size_t early_tracking_overhead = amount_in_current_scale(_early_baseline.malloc_tracking_overhead()); - out->print("(tracking overhead=" SIZE_FORMAT "%s", + out->print("(tracking overhead=%zu%s", amount_in_current_scale(_current_baseline.malloc_tracking_overhead()), scale); int64_t overhead_diff = diff_in_current_scale(_current_baseline.malloc_tracking_overhead(), @@ -770,7 +770,7 @@ void MemSummaryDiffReporter::print_metaspace_diff(const char* header, int64_t diff_waste = diff_in_current_scale(current_waste, early_waste); // Diff used - out->print("( used=" SIZE_FORMAT "%s", + out->print("( used=%zu%s", amount_in_current_scale(current_stats.used()), scale); if (diff_used != 0) { out->print(" " INT64_PLUS_FORMAT "%s", diff_used, scale); @@ -780,7 +780,7 @@ void MemSummaryDiffReporter::print_metaspace_diff(const char* header, // Diff waste const float waste_percentage = current_stats.committed() == 0 ? 0.0f : ((float)current_waste * 100.0f) / (float)current_stats.committed(); - out->print("( waste=" SIZE_FORMAT "%s =%2.2f%%", + out->print("( waste=%zu%s =%2.2f%%", amount_in_current_scale(current_waste), scale, waste_percentage); if (diff_waste != 0) { out->print(" " INT64_PLUS_FORMAT "%s", diff_waste, scale); diff --git a/src/hotspot/share/nmt/memoryFileTracker.cpp b/src/hotspot/share/nmt/memoryFileTracker.cpp index 0777d5aafc3..83e7a1b917f 100644 --- a/src/hotspot/share/nmt/memoryFileTracker.cpp +++ b/src/hotspot/share/nmt/memoryFileTracker.cpp @@ -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 @@ -87,7 +87,7 @@ void MemoryFileTracker::print_report_on(const MemoryFile* file, outputStream* st if (prev->val().out.type() == VMATree::StateType::Committed) { const VMATree::position& start_addr = prev->key(); const VMATree::position& end_addr = current->key(); - stream->print_cr("[" PTR_FORMAT " - " PTR_FORMAT "] allocated " SIZE_FORMAT "%s" " for %s from", + stream->print_cr("[" PTR_FORMAT " - " PTR_FORMAT "] allocated %zu%s" " for %s from", start_addr, end_addr, NMTUtil::amount_in_scale(end_addr - start_addr, scale), NMTUtil::scale_name(scale), diff --git a/src/hotspot/share/nmt/nmtPreInit.cpp b/src/hotspot/share/nmt/nmtPreInit.cpp index 0aa74566f42..a3f58dd8218 100644 --- a/src/hotspot/share/nmt/nmtPreInit.cpp +++ b/src/hotspot/share/nmt/nmtPreInit.cpp @@ -132,7 +132,7 @@ void NMTPreInitAllocationTable::print_state(outputStream* st) const { num_entries += chain_len; longest_chain = MAX2(chain_len, longest_chain); } - st->print("entries: %d (primary: %d, empties: %d), sum bytes: " SIZE_FORMAT + st->print("entries: %d (primary: %d, empties: %d), sum bytes: %zu" ", longest chain length: %d", num_entries, num_primary_entries, table_size - num_primary_entries, sum_bytes, longest_chain); @@ -143,7 +143,7 @@ void NMTPreInitAllocationTable::print_map(outputStream* st) const { for (int i = 0; i < table_size; i++) { st->print("[%d]: ", i); for (NMTPreInitAllocation* a = _entries[i]; a != nullptr; a = a->next) { - st->print( PTR_FORMAT "(" SIZE_FORMAT ") ", p2i(a->payload), a->size); + st->print( PTR_FORMAT "(%zu) ", p2i(a->payload), a->size); } st->cr(); } diff --git a/src/hotspot/share/nmt/virtualMemoryTracker.cpp b/src/hotspot/share/nmt/virtualMemoryTracker.cpp index d298381f103..05db5341174 100644 --- a/src/hotspot/share/nmt/virtualMemoryTracker.cpp +++ b/src/hotspot/share/nmt/virtualMemoryTracker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -341,7 +341,7 @@ bool VirtualMemoryTracker::add_reserved_region(address base_addr, size_t size, ReservedMemoryRegion rgn(base_addr, size, stack, mem_tag); ReservedMemoryRegion* reserved_rgn = _reserved_regions->find(rgn); - log_debug(nmt)("Add reserved region \'%s\' (" INTPTR_FORMAT ", " SIZE_FORMAT ")", + log_debug(nmt)("Add reserved region \'%s\' (" INTPTR_FORMAT ", %zu)", rgn.mem_tag_name(), p2i(rgn.base()), rgn.size()); if (reserved_rgn == nullptr) { VirtualMemorySummary::record_reserved_memory(size, mem_tag); @@ -381,7 +381,7 @@ bool VirtualMemoryTracker::add_reserved_region(address base_addr, size_t size, // CDS reserves the whole region for mapping CDS archive, then maps each section into the region. // NMT reports CDS as a whole. if (reserved_rgn->mem_tag() == mtClassShared) { - log_debug(nmt)("CDS reserved region \'%s\' as a whole (" INTPTR_FORMAT ", " SIZE_FORMAT ")", + log_debug(nmt)("CDS reserved region \'%s\' as a whole (" INTPTR_FORMAT ", %zu)", reserved_rgn->mem_tag_name(), p2i(reserved_rgn->base()), reserved_rgn->size()); assert(reserved_rgn->contain_region(base_addr, size), "Reserved CDS region should contain this mapping region"); return true; @@ -390,7 +390,7 @@ bool VirtualMemoryTracker::add_reserved_region(address base_addr, size_t size, // Mapped CDS string region. // The string region(s) is part of the java heap. if (reserved_rgn->mem_tag() == mtJavaHeap) { - log_debug(nmt)("CDS reserved region \'%s\' as a whole (" INTPTR_FORMAT ", " SIZE_FORMAT ")", + log_debug(nmt)("CDS reserved region \'%s\' as a whole (" INTPTR_FORMAT ", %zu)", reserved_rgn->mem_tag_name(), p2i(reserved_rgn->base()), reserved_rgn->size()); assert(reserved_rgn->contain_region(base_addr, size), "Reserved heap region should contain this mapping region"); return true; @@ -439,13 +439,13 @@ bool VirtualMemoryTracker::add_committed_region(address addr, size_t size, ReservedMemoryRegion* reserved_rgn = _reserved_regions->find(rgn); if (reserved_rgn == nullptr) { - log_debug(nmt)("Add committed region \'%s\', No reserved region found for (" INTPTR_FORMAT ", " SIZE_FORMAT ")", + log_debug(nmt)("Add committed region \'%s\', No reserved region found for (" INTPTR_FORMAT ", %zu)", rgn.mem_tag_name(), p2i(rgn.base()), rgn.size()); } assert(reserved_rgn != nullptr, "Add committed region, No reserved region found"); assert(reserved_rgn->contain_region(addr, size), "Not completely contained"); bool result = reserved_rgn->add_committed_region(addr, size, stack); - log_debug(nmt)("Add committed region \'%s\'(" INTPTR_FORMAT ", " SIZE_FORMAT ") %s", + log_debug(nmt)("Add committed region \'%s\'(" INTPTR_FORMAT ", %zu) %s", reserved_rgn->mem_tag_name(), p2i(rgn.base()), rgn.size(), (result ? "Succeeded" : "Failed")); return result; } @@ -457,11 +457,11 @@ bool VirtualMemoryTracker::remove_uncommitted_region(address addr, size_t size) ReservedMemoryRegion rgn(addr, size); ReservedMemoryRegion* reserved_rgn = _reserved_regions->find(rgn); - assert(reserved_rgn != nullptr, "No reserved region (" INTPTR_FORMAT ", " SIZE_FORMAT ")", p2i(addr), size); + assert(reserved_rgn != nullptr, "No reserved region (" INTPTR_FORMAT ", %zu)", p2i(addr), size); assert(reserved_rgn->contain_region(addr, size), "Not completely contained"); const char* type_name = reserved_rgn->mem_tag_name(); // after remove, info is not complete bool result = reserved_rgn->remove_uncommitted_region(addr, size); - log_debug(nmt)("Removed uncommitted region \'%s\' (" INTPTR_FORMAT ", " SIZE_FORMAT ") %s", + log_debug(nmt)("Removed uncommitted region \'%s\' (" INTPTR_FORMAT ", %zu) %s", type_name, p2i(addr), size, (result ? " Succeeded" : "Failed")); return result; } @@ -473,7 +473,7 @@ bool VirtualMemoryTracker::remove_released_region(ReservedMemoryRegion* rgn) { // uncommit regions within the released region ReservedMemoryRegion backup(*rgn); bool result = rgn->remove_uncommitted_region(rgn->base(), rgn->size()); - log_debug(nmt)("Remove uncommitted region \'%s\' (" INTPTR_FORMAT ", " SIZE_FORMAT ") %s", + log_debug(nmt)("Remove uncommitted region \'%s\' (" INTPTR_FORMAT ", %zu) %s", backup.mem_tag_name(), p2i(backup.base()), backup.size(), (result ? "Succeeded" : "Failed")); if (!result) { return false; @@ -481,7 +481,7 @@ bool VirtualMemoryTracker::remove_released_region(ReservedMemoryRegion* rgn) { VirtualMemorySummary::record_released_memory(rgn->size(), rgn->mem_tag()); result = _reserved_regions->remove(*rgn); - log_debug(nmt)("Removed region \'%s\' (" INTPTR_FORMAT ", " SIZE_FORMAT ") from _reserved_regions %s" , + log_debug(nmt)("Removed region \'%s\' (" INTPTR_FORMAT ", %zu) from _reserved_regions %s" , backup.mem_tag_name(), p2i(backup.base()), backup.size(), (result ? "Succeeded" : "Failed")); return result; } @@ -495,7 +495,7 @@ bool VirtualMemoryTracker::remove_released_region(address addr, size_t size) { ReservedMemoryRegion* reserved_rgn = _reserved_regions->find(rgn); if (reserved_rgn == nullptr) { - log_debug(nmt)("No reserved region found for (" INTPTR_FORMAT ", " SIZE_FORMAT ")!", + log_debug(nmt)("No reserved region found for (" INTPTR_FORMAT ", %zu)!", p2i(rgn.base()), rgn.size()); } assert(reserved_rgn != nullptr, "No reserved region"); @@ -571,7 +571,7 @@ bool VirtualMemoryTracker::split_reserved_region(address addr, size_t size, size const char* name = reserved_rgn->mem_tag_name(); remove_released_region(reserved_rgn); - log_debug(nmt)("Split region \'%s\' (" INTPTR_FORMAT ", " SIZE_FORMAT ") with size " SIZE_FORMAT, + log_debug(nmt)("Split region \'%s\' (" INTPTR_FORMAT ", %zu) with size %zu", name, p2i(rgn.base()), rgn.size(), split); // Now, create two new regions. add_reserved_region(addr, split, original_stack, mem_tag); diff --git a/src/hotspot/share/nmt/vmatree.cpp b/src/hotspot/share/nmt/vmatree.cpp index ec4f405f1c9..4514df6a182 100644 --- a/src/hotspot/share/nmt/vmatree.cpp +++ b/src/hotspot/share/nmt/vmatree.cpp @@ -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. * Copyright (c) 2024, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -220,7 +220,7 @@ VMATree::SummaryDiff VMATree::register_mapping(position A, position B, StateType #ifdef ASSERT void VMATree::print_on(outputStream* out) { visit_in_order([&](TreapNode* current) { - out->print(SIZE_FORMAT " (%s) - %s - ", current->key(), NMTUtil::tag_to_name(out_state(current).mem_tag()), + out->print("%zu (%s) - %s - ", current->key(), NMTUtil::tag_to_name(out_state(current).mem_tag()), statetype_to_string(out_state(current).type())); }); out->cr(); diff --git a/src/hotspot/share/oops/array.hpp b/src/hotspot/share/oops/array.hpp index 25dd8cd6beb..12e23080166 100644 --- a/src/hotspot/share/oops/array.hpp +++ b/src/hotspot/share/oops/array.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -74,12 +74,12 @@ protected: assert(is_aligned(left, sizeof(T)), "Must be"); size_t elements = left / sizeof(T); - assert(elements <= (size_t)INT_MAX, "number of elements " SIZE_FORMAT "doesn't fit into an int.", elements); + assert(elements <= (size_t)INT_MAX, "number of elements %zu doesn't fit into an int.", elements); int length = (int)elements; assert((size_t)size(length) * BytesPerWord == (size_t)bytes, - "Expected: " SIZE_FORMAT " got: " SIZE_FORMAT, + "Expected: %zu got: %zu", bytes, (size_t)size(length) * BytesPerWord); return length; @@ -135,7 +135,7 @@ protected: size_t bytes = align_up(byte_sizeof(length), BytesPerWord); size_t words = bytes / BytesPerWord; - assert(words <= INT_MAX, "Overflow: " SIZE_FORMAT, words); + assert(words <= INT_MAX, "Overflow: %zu", words); return (int)words; } diff --git a/src/hotspot/share/oops/compressedOops.cpp b/src/hotspot/share/oops/compressedOops.cpp index 5532b406b6d..688599170ad 100644 --- a/src/hotspot/share/oops/compressedOops.cpp +++ b/src/hotspot/share/oops/compressedOops.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, 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 @@ -161,7 +161,7 @@ bool CompressedOops::base_overlaps() { } void CompressedOops::print_mode(outputStream* st) { - st->print("Heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB", + st->print("Heap address: " PTR_FORMAT ", size: %zu MB", p2i(_heap_address_range.start()), _heap_address_range.byte_size()/M); st->print(", Compressed Oops mode: %s", mode_to_string(mode())); diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index fb94f4fac8d..b44bcb700c8 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -3806,7 +3806,7 @@ void InstanceKlass::oop_print_on(oop obj, outputStream* st) { } } - st->print_cr(BULLET"---- fields (total size " SIZE_FORMAT " words):", oop_size(obj)); + st->print_cr(BULLET"---- fields (total size %zu words):", oop_size(obj)); FieldPrinter print_field(st, obj); print_nonstatic_fields(&print_field); diff --git a/src/hotspot/share/oops/instanceMirrorKlass.cpp b/src/hotspot/share/oops/instanceMirrorKlass.cpp index a90c9284b1a..0190d25e002 100644 --- a/src/hotspot/share/oops/instanceMirrorKlass.cpp +++ b/src/hotspot/share/oops/instanceMirrorKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -54,7 +54,7 @@ size_t InstanceMirrorKlass::instance_size(Klass* k) { instanceOop InstanceMirrorKlass::allocate_instance(Klass* k, TRAPS) { // Query before forming handle. size_t size = instance_size(k); - assert(size > 0, "total object size must be non-zero: " SIZE_FORMAT, size); + assert(size > 0, "total object size must be non-zero: %zu", size); // Since mirrors can be variable sized because of the static fields, store // the size in the mirror itself. diff --git a/src/hotspot/share/oops/oop.inline.hpp b/src/hotspot/share/oops/oop.inline.hpp index 9ce953380ba..3dad778a73a 100644 --- a/src/hotspot/share/oops/oop.inline.hpp +++ b/src/hotspot/share/oops/oop.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -220,8 +220,8 @@ size_t oopDesc::size_given_klass(Klass* klass) { } } - assert(s > 0, "Oop size must be greater than zero, not " SIZE_FORMAT, s); - assert(is_object_aligned(s), "Oop size is not properly aligned: " SIZE_FORMAT, s); + assert(s > 0, "Oop size must be greater than zero, not %zu", s); + assert(is_object_aligned(s), "Oop size is not properly aligned: %zu", s); return s; } diff --git a/src/hotspot/share/oops/stackChunkOop.cpp b/src/hotspot/share/oops/stackChunkOop.cpp index 7319e93b667..6d2a35d082c 100644 --- a/src/hotspot/share/oops/stackChunkOop.cpp +++ b/src/hotspot/share/oops/stackChunkOop.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, 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 @@ -497,7 +497,7 @@ public: assert(obj == nullptr || dbg_is_good_oop(obj), "p: " PTR_FORMAT " obj: " PTR_FORMAT, p2i(p), p2i(obj)); if (_chunk->has_bitmap()) { BitMap::idx_t index = _chunk->bit_index_for(p); - assert(_chunk->bitmap().at(index), "Bit not set at index " SIZE_FORMAT " corresponding to " PTR_FORMAT, index, p2i(p)); + assert(_chunk->bitmap().at(index), "Bit not set at index %zu corresponding to " PTR_FORMAT, index, p2i(p)); } } @@ -582,7 +582,7 @@ public: oop obj = _chunk->load_oop(p); assert(obj == nullptr || dbg_is_good_oop(obj), - "p: " PTR_FORMAT " obj: " PTR_FORMAT " index: " SIZE_FORMAT, + "p: " PTR_FORMAT " obj: " PTR_FORMAT " index: %zu", p2i(p), p2i((oopDesc*)obj), index); return true; // continue processing diff --git a/src/hotspot/share/prims/jvmtiEnter.xsl b/src/hotspot/share/prims/jvmtiEnter.xsl index 59b70a162eb..4862d0333db 100644 --- a/src/hotspot/share/prims/jvmtiEnter.xsl +++ b/src/hotspot/share/prims/jvmtiEnter.xsl @@ -1,6 +1,6 @@