From af3f5d852e5dd0191548bdc477546b5b343d1276 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 15 Jan 2025 10:54:03 +0000 Subject: [PATCH 01/47] 8347039: ThreadPerTaskExecutor terminates if cancelled tasks still running Reviewed-by: vklang --- .../concurrent/ThreadPerTaskExecutor.java | 10 ++- .../ThreadPerTaskExecutorTest.java | 66 ++++++++++++++++--- 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/src/java.base/share/classes/java/util/concurrent/ThreadPerTaskExecutor.java b/src/java.base/share/classes/java/util/concurrent/ThreadPerTaskExecutor.java index f37ef6c956e58..fff60cec15fb9 100644 --- a/src/java.base/share/classes/java/util/concurrent/ThreadPerTaskExecutor.java +++ b/src/java.base/share/classes/java/util/concurrent/ThreadPerTaskExecutor.java @@ -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 @@ -318,8 +318,12 @@ Thread thread() { } @Override - protected void done() { - executor.taskComplete(thread); + public void run() { + try { + super.run(); + } finally { + executor.taskComplete(thread); + } } } diff --git a/test/jdk/java/util/concurrent/ThreadPerTaskExecutor/ThreadPerTaskExecutorTest.java b/test/jdk/java/util/concurrent/ThreadPerTaskExecutor/ThreadPerTaskExecutorTest.java index a599ef234dd7b..ff3b9566f5e8f 100644 --- a/test/jdk/java/util/concurrent/ThreadPerTaskExecutor/ThreadPerTaskExecutorTest.java +++ b/test/jdk/java/util/concurrent/ThreadPerTaskExecutor/ThreadPerTaskExecutorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, 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 @@ -23,6 +23,7 @@ /* * @test id=platform + * @bug 8284161 8347039 * @summary Basic tests for new thread-per-task executors * @run junit/othervm -DthreadFactory=platform ThreadPerTaskExecutorTest */ @@ -157,6 +158,7 @@ void testShutdown(ExecutorService executor) throws Exception { assertTrue(executor.isShutdown()); assertFalse(executor.isTerminated()); assertFalse(executor.awaitTermination(500, TimeUnit.MILLISECONDS)); + assertFalse(future.isDone()); } finally { future.cancel(true); // interrupt task } @@ -280,13 +282,13 @@ void testClose5(ExecutorService executor) throws Exception { } /** - * Test awaitTermination when not shutdown. + * Test awaitTermination with no tasks running. */ @ParameterizedTest @MethodSource("executors") void testAwaitTermination1(ExecutorService executor) throws Exception { assertFalse(executor.awaitTermination(100, TimeUnit.MILLISECONDS)); - executor.close(); + executor.shutdown(); assertTrue(executor.awaitTermination(100, TimeUnit.MILLISECONDS)); } @@ -296,16 +298,62 @@ void testAwaitTermination1(ExecutorService executor) throws Exception { @ParameterizedTest @MethodSource("executors") void testAwaitTermination2(ExecutorService executor) throws Exception { - Phaser barrier = new Phaser(2); - Future future = executor.submit(barrier::arriveAndAwaitAdvance); + var started = new CountDownLatch(1); + var stop = new CountDownLatch(1); + Future future = executor.submit(() -> { + started.countDown(); + stop.await(); + return null; + }); + started.await(); + try { + executor.shutdown(); + assertFalse(executor.awaitTermination(1, TimeUnit.SECONDS)); + assertFalse(future.isDone()); + } finally { + stop.countDown(); + } + assertTrue(executor.awaitTermination(1, TimeUnit.MINUTES)); + assertTrue(future.isDone()); + } + + /** + * Test awaitTermination with cancelled task still running. + */ + @ParameterizedTest + @MethodSource("executors") + void testAwaitTermination3(ExecutorService executor) throws Exception { + var started = new CountDownLatch(1); + var stop = new CountDownLatch(1); + Future future = executor.submit(() -> { + started.countDown(); + stop.await(); + return null; + }); + started.await(); try { + future.cancel(false); executor.shutdown(); - assertFalse(executor.awaitTermination(100, TimeUnit.MILLISECONDS)); - barrier.arriveAndAwaitAdvance(); - assertTrue(executor.awaitTermination(10, TimeUnit.SECONDS)); + assertFalse(executor.awaitTermination(1, TimeUnit.SECONDS)); } finally { - future.cancel(true); + stop.countDown(); } + assertTrue(executor.awaitTermination(1, TimeUnit.MINUTES)); + } + + /** + * Test awaitTermination with cancelled task that may not have started execution. + */ + @ParameterizedTest + @MethodSource("executors") + void testAwaitTermination4(ExecutorService executor) throws Exception { + Future future = executor.submit(() -> { + Thread.sleep(Duration.ofMillis(50)); + return null; + }); + future.cancel(false); + executor.shutdown(); + assertTrue(executor.awaitTermination(1, TimeUnit.MINUTES)); } /** From c36200b09801d8a96a3d3239c15fef91010c3bbf Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 15 Jan 2025 12:16:58 +0000 Subject: [PATCH 02/47] 8347721: Replace SIZE_FORMAT in compiler directories Reviewed-by: kvn, dlong --- src/hotspot/share/code/codeCache.cpp | 32 ++++++++++++------------ src/hotspot/share/code/codeHeapState.cpp | 20 +++++++-------- src/hotspot/share/code/nmethod.cpp | 2 +- src/hotspot/share/code/vtableStubs.cpp | 2 +- src/hotspot/share/opto/parse1.cpp | 4 +-- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index 7407caf741a4a..ed8147a95a809 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -178,10 +178,10 @@ GrowableArray* CodeCache::_allocable_heaps = new(mtCode) GrowableArra static void check_min_size(const char* codeheap, size_t size, size_t required_size) { if (size < required_size) { - log_debug(codecache)("Code heap (%s) size " SIZE_FORMAT "K below required minimal size " SIZE_FORMAT "K", + 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 < " SIZE_FORMAT "K", size/K, required_size/K); + err_msg message(SIZE_FORMAT "K < %zuK", size/K, required_size/K); vm_exit_during_initialization(title, message); } } @@ -256,15 +256,15 @@ void CodeCache::initialize_heaps() { size_t total = non_nmethod.size + profiled.size + non_profiled.size; if (total != cache_size && !cache_size_set) { - log_info(codecache)("ReservedCodeCache size " SIZE_FORMAT "K changed to total segments size NonNMethod " - SIZE_FORMAT "K NonProfiled " SIZE_FORMAT "K Profiled " SIZE_FORMAT "K = " SIZE_FORMAT "K", + log_info(codecache)("ReservedCodeCache size %zuK changed to total segments size NonNMethod " + "%zuK NonProfiled %zuK Profiled %zuK = %zuK", cache_size/K, non_nmethod.size/K, non_profiled.size/K, profiled.size/K, total/K); // Adjust ReservedCodeCacheSize as necessary because it was not set explicitly cache_size = total; } - log_debug(codecache)("Initializing code heaps ReservedCodeCache " SIZE_FORMAT "K NonNMethod " SIZE_FORMAT "K" - " NonProfiled " SIZE_FORMAT "K Profiled " SIZE_FORMAT "K", + log_debug(codecache)("Initializing code heaps ReservedCodeCache %zuK NonNMethod %zuK" + " NonProfiled %zuK Profiled %zuK", cache_size/K, non_nmethod.size/K, non_profiled.size/K, profiled.size/K); // Validation @@ -282,16 +282,16 @@ void CodeCache::initialize_heaps() { // ReservedCodeCacheSize was set explicitly, so report an error and abort if it doesn't match the segment sizes if (total != cache_size && cache_size_set) { - err_msg message("NonNMethodCodeHeapSize (" SIZE_FORMAT "K)", non_nmethod.size/K); + err_msg message("NonNMethodCodeHeapSize (%zuK)", non_nmethod.size/K); if (profiled.enabled) { - message.append(" + ProfiledCodeHeapSize (" SIZE_FORMAT "K)", profiled.size/K); + message.append(" + ProfiledCodeHeapSize (%zuK)", profiled.size/K); } if (non_profiled.enabled) { - message.append(" + NonProfiledCodeHeapSize (" SIZE_FORMAT "K)", non_profiled.size/K); + message.append(" + NonProfiledCodeHeapSize (%zuK)", non_profiled.size/K); } - message.append(" = " SIZE_FORMAT "K", total/K); + message.append(" = %zuK", total/K); message.append((total > cache_size) ? " is greater than " : " is less than "); - message.append("ReservedCodeCacheSize (" SIZE_FORMAT "K).", cache_size/K); + message.append("ReservedCodeCacheSize (%zuK).", cache_size/K); vm_exit_during_initialization("Invalid code heap sizes", message); } @@ -356,7 +356,7 @@ ReservedSpace CodeCache::reserve_heap_memory(size_t size, size_t rs_ps) { ReservedSpace rs = CodeMemoryReserver::reserve(rs_size, rs_align, rs_ps); if (!rs.is_reserved()) { - vm_exit_during_initialization(err_msg("Could not reserve enough space for code cache (" SIZE_FORMAT "K)", + vm_exit_during_initialization(err_msg("Could not reserve enough space for code cache (%zuK)", rs_size/K)); } @@ -437,7 +437,7 @@ void CodeCache::add_heap(ReservedSpace rs, const char* name, CodeBlobType code_b size_t size_initial = MIN2((size_t)InitialCodeCacheSize, rs.size()); size_initial = align_up(size_initial, rs.page_size()); if (!heap->reserve(rs, size_initial, CodeCacheSegmentSize)) { - vm_exit_during_initialization(err_msg("Could not reserve enough space in %s (" SIZE_FORMAT "K)", + vm_exit_during_initialization(err_msg("Could not reserve enough space in %s (%zuK)", heap->name(), size_initial/K)); } @@ -1727,8 +1727,8 @@ void CodeCache::print_summary(outputStream* st, bool detailed) { total_used += used; total_max_used += max_used; total_free += free; - st->print_cr(" size=" SIZE_FORMAT "Kb used=" SIZE_FORMAT - "Kb max_used=" SIZE_FORMAT "Kb free=" SIZE_FORMAT "Kb", + st->print_cr(" size=%zuKb used=%zu" + "Kb max_used=%zuKb free=%zuKb", size, used, max_used, free); if (detailed) { @@ -1788,7 +1788,7 @@ void CodeCache::print_layout(outputStream* st) { void CodeCache::log_state(outputStream* st) { st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'" - " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'", + " adapters='" UINT32_FORMAT "' free_code_cache='%zu'", blob_count(), nmethod_count(), adapter_count(), unallocated_capacity()); } diff --git a/src/hotspot/share/code/codeHeapState.cpp b/src/hotspot/share/code/codeHeapState.cpp index 0fa7c7386c7ee..c577f86a3c37d 100644 --- a/src/hotspot/share/code/codeHeapState.cpp +++ b/src/hotspot/share/code/codeHeapState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -370,7 +370,7 @@ void CodeHeapState::prepare_StatArray(outputStream* out, size_t nElem, size_t gr if (StatArray == nullptr) { //---< just do nothing if allocation failed >--- out->print_cr("Statistics could not be collected for %s, probably out of memory.", heapName); - out->print_cr("Current granularity is " SIZE_FORMAT " bytes. Try a coarser granularity.", granularity); + out->print_cr("Current granularity is %zu bytes. Try a coarser granularity.", granularity); alloc_granules = 0; granule_size = 0; } else { @@ -621,11 +621,11 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular " collected data to be consistent. Only the method names and signatures\n" " are retrieved at print time. That may lead to rare cases where the\n" " name of a method is no longer available, e.g. because it was unloaded.\n"); - ast->print_cr(" CodeHeap committed size " SIZE_FORMAT "K (" SIZE_FORMAT "M), reserved size " SIZE_FORMAT "K (" SIZE_FORMAT "M), %d%% occupied.", + ast->print_cr(" CodeHeap committed size %zuK (%zuM), reserved size %zuK (%zuM), %d%% occupied.", size/(size_t)K, size/(size_t)M, res_size/(size_t)K, res_size/(size_t)M, (unsigned int)(100.0*size/res_size)); - ast->print_cr(" CodeHeap allocation segment size is " SIZE_FORMAT " bytes. This is the smallest possible granularity.", seg_size); - ast->print_cr(" CodeHeap (committed part) is mapped to " SIZE_FORMAT " granules of size " SIZE_FORMAT " bytes.", granules, granularity); - ast->print_cr(" Each granule takes " SIZE_FORMAT " bytes of C heap, that is " SIZE_FORMAT "K in total for statistics data.", sizeof(StatElement), (sizeof(StatElement)*granules)/(size_t)K); + ast->print_cr(" CodeHeap allocation segment size is %zu bytes. This is the smallest possible granularity.", seg_size); + ast->print_cr(" CodeHeap (committed part) is mapped to %zu granules of size %zu bytes.", granules, granularity); + ast->print_cr(" Each granule takes %zu bytes of C heap, that is %zuK in total for statistics data.", sizeof(StatElement), (sizeof(StatElement)*granules)/(size_t)K); ast->print_cr(" The number of granules is limited to %dk, requiring a granules size of at least %d bytes for a 1GB heap.", (unsigned int)(max_granules/K), (unsigned int)(G/max_granules)); BUFFEREDSTREAM_FLUSH("\n") @@ -697,10 +697,10 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular insane = true; ast->print_cr("Sanity check: HeapBlock @%p outside used range (%p)", (char*)h, low_bound + size); } if (ix_end >= granules) { - insane = true; ast->print_cr("Sanity check: end index (%d) out of bounds (" SIZE_FORMAT ")", ix_end, granules); + insane = true; ast->print_cr("Sanity check: end index (%d) out of bounds (%zu)", ix_end, granules); } if (size != heap->capacity()) { - insane = true; ast->print_cr("Sanity check: code heap capacity has changed (" SIZE_FORMAT "K to " SIZE_FORMAT "K)", size/(size_t)K, heap->capacity()/(size_t)K); + insane = true; ast->print_cr("Sanity check: code heap capacity has changed (%zuK to %zuK)", size/(size_t)K, heap->capacity()/(size_t)K); } if (ix_beg > ix_end) { insane = true; ast->print_cr("Sanity check: end index (%d) lower than begin index (%d)", ix_end, ix_beg); @@ -1134,7 +1134,7 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular ast->print_cr(" The aggregate step collects information about all free blocks in CodeHeap.\n" " Subsequent print functions create their output based on this snapshot.\n"); ast->print_cr(" Free space in %s is distributed over %d free blocks.", heapName, nBlocks_free); - ast->print_cr(" Each free block takes " SIZE_FORMAT " bytes of C heap for statistics data, that is " SIZE_FORMAT "K in total.", sizeof(FreeBlk), (sizeof(FreeBlk)*nBlocks_free)/K); + ast->print_cr(" Each free block takes %zu bytes of C heap for statistics data, that is %zuK in total.", sizeof(FreeBlk), (sizeof(FreeBlk)*nBlocks_free)/K); BUFFEREDSTREAM_FLUSH("\n") //---------------------------------------- @@ -2101,7 +2101,7 @@ void CodeHeapState::print_names(outputStream* out, CodeHeap* heap) { size_t end_ix = (ix+granules_per_line <= alloc_granules) ? ix+granules_per_line : alloc_granules; ast->cr(); ast->print_cr("--------------------------------------------------------------------"); - ast->print_cr("Address range [" INTPTR_FORMAT "," INTPTR_FORMAT "), " SIZE_FORMAT "k", p2i(low_bound+ix*granule_size), p2i(low_bound + end_ix*granule_size), (end_ix - ix)*granule_size/(size_t)K); + ast->print_cr("Address range [" INTPTR_FORMAT "," INTPTR_FORMAT "), %zuk", p2i(low_bound+ix*granule_size), p2i(low_bound + end_ix*granule_size), (end_ix - ix)*granule_size/(size_t)K); ast->print_cr("--------------------------------------------------------------------"); BUFFEREDSTREAM_FLUSH_AUTO("") } diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index 0d44c4f2e6d9f..1686090c634ae 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -2110,7 +2110,7 @@ void nmethod::purge(bool unregister_nmethod) { // completely deallocate this method Events::log_nmethod_flush(Thread::current(), "flushing %s nmethod " INTPTR_FORMAT, is_osr_method() ? "osr" : "", p2i(this)); log_debug(codecache)("*flushing %s nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT - "/Free CodeCache:" SIZE_FORMAT "Kb", + "/Free CodeCache:%zuKb", is_osr_method() ? "osr" : "",_compile_id, p2i(this), CodeCache::blob_count(), CodeCache::unallocated_capacity(CodeCache::get_code_blob_type(this))/1024); diff --git a/src/hotspot/share/code/vtableStubs.cpp b/src/hotspot/share/code/vtableStubs.cpp index 8f7ad91ddc900..379605fed537c 100644 --- a/src/hotspot/share/code/vtableStubs.cpp +++ b/src/hotspot/share/code/vtableStubs.cpp @@ -226,7 +226,7 @@ address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) { enter(is_vtable_stub, vtable_index, s); if (PrintAdapterHandlers) { - tty->print_cr("Decoding VtableStub %s[%d]@" PTR_FORMAT " [" PTR_FORMAT ", " PTR_FORMAT "] (" SIZE_FORMAT " bytes)", + tty->print_cr("Decoding VtableStub %s[%d]@" PTR_FORMAT " [" PTR_FORMAT ", " PTR_FORMAT "] (%zu bytes)", is_vtable_stub? "vtbl": "itbl", vtable_index, p2i(VtableStub::receiver_location()), p2i(s->code_begin()), p2i(s->code_end()), pointer_delta(s->code_end(), s->code_begin(), 1)); Disassembler::decode(s->code_begin(), s->code_end()); diff --git a/src/hotspot/share/opto/parse1.cpp b/src/hotspot/share/opto/parse1.cpp index 68b87d858a5bc..5bd7c41daf07f 100644 --- a/src/hotspot/share/opto/parse1.cpp +++ b/src/hotspot/share/opto/parse1.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 @@ -642,7 +642,7 @@ Parse::Parse(JVMState* caller, ciMethod* parse_method, float expected_uses) // for exiting control flow still refers to the inlined method. C->set_default_node_notes(caller_nn); - if (log) log->done("parse nodes='%d' live='%d' memory='" SIZE_FORMAT "'", + if (log) log->done("parse nodes='%d' live='%d' memory='%zu'", C->unique(), C->live_nodes(), C->node_arena()->used()); } From d4e5ec274673c1ee883e8d5c3785f0b03e39445c Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Wed, 15 Jan 2025 12:19:27 +0000 Subject: [PATCH 03/47] 8346610: Make all imports consistent in the FFM API Reviewed-by: mcimadamore --- .../java/lang/foreign/FunctionDescriptor.java | 8 ++--- .../classes/java/lang/foreign/Linker.java | 4 +-- .../java/lang/foreign/MemoryLayout.java | 14 ++++---- .../java/lang/foreign/MemorySegment.java | 17 +++++----- .../java/lang/foreign/SegmentAllocator.java | 11 +++--- .../java/lang/foreign/ValueLayout.java | 5 +-- .../foreign/AbstractMemorySegmentImpl.java | 34 ++++++++++++------- .../jdk/internal/foreign/ArenaImpl.java | 5 +-- .../classes/jdk/internal/foreign/CABI.java | 4 +-- .../jdk/internal/foreign/ConfinedSession.java | 8 ++--- .../jdk/internal/foreign/GlobalSession.java | 6 +--- .../foreign/HeapMemorySegmentImpl.java | 10 +++--- .../jdk/internal/foreign/LayoutPath.java | 3 +- .../foreign/MappedMemorySegmentImpl.java | 5 +-- .../internal/foreign/MemorySessionImpl.java | 16 ++++----- .../foreign/NativeMemorySegmentImpl.java | 8 ++--- .../jdk/internal/foreign/SharedSession.java | 9 ++--- .../jdk/internal/foreign/SystemLookup.java | 16 +++++---- .../classes/jdk/internal/foreign/Utils.java | 14 ++++---- .../internal/foreign/abi/AbstractLinker.java | 6 ++-- .../jdk/internal/foreign/abi/Binding.java | 11 +++--- .../foreign/abi/BindingSpecializer.java | 27 +++++++++------ .../internal/foreign/abi/CallingSequence.java | 3 +- .../foreign/abi/CallingSequenceBuilder.java | 4 +-- .../internal/foreign/abi/DowncallLinker.java | 12 +++---- .../jdk/internal/foreign/abi/SharedUtils.java | 4 +-- .../internal/foreign/abi/UpcallLinker.java | 6 ++-- .../jdk/internal/foreign/abi/UpcallStubs.java | 8 ++--- .../foreign/abi/aarch64/CallArranger.java | 17 +++++----- .../foreign/abi/aarch64/TypeClass.java | 5 +-- .../linux/LinuxAArch64CallArranger.java | 5 +-- .../abi/aarch64/linux/LinuxAArch64Linker.java | 4 +-- .../macos/MacOsAArch64CallArranger.java | 5 +-- .../abi/aarch64/macos/MacOsAArch64Linker.java | 4 +-- .../windows/WindowsAArch64CallArranger.java | 9 ++--- .../aarch64/windows/WindowsAArch64Linker.java | 4 +-- .../foreign/abi/fallback/FFIType.java | 9 ++--- .../foreign/abi/fallback/FallbackLinker.java | 29 +++++++--------- .../foreign/abi/ppc64/CallArranger.java | 6 ++-- .../internal/foreign/abi/ppc64/TypeClass.java | 5 +-- .../abi/ppc64/linux/LinuxPPC64Linker.java | 4 +-- .../abi/ppc64/linux/LinuxPPC64leLinker.java | 4 +-- .../linux/LinuxRISCV64CallArranger.java | 18 +++++----- .../abi/riscv64/linux/LinuxRISCV64Linker.java | 3 +- .../abi/s390/linux/LinuxS390CallArranger.java | 15 ++++---- .../abi/s390/linux/LinuxS390Linker.java | 4 +-- .../foreign/abi/s390/linux/TypeClass.java | 5 +-- .../foreign/abi/x64/sysv/CallArranger.java | 5 +-- .../foreign/abi/x64/sysv/SysVx64Linker.java | 5 ++- .../foreign/abi/x64/sysv/TypeClass.java | 7 ++-- .../foreign/abi/x64/windows/CallArranger.java | 6 ++-- .../abi/x64/windows/Windowsx64Linker.java | 4 +-- 52 files changed, 235 insertions(+), 225 deletions(-) diff --git a/src/java.base/share/classes/java/lang/foreign/FunctionDescriptor.java b/src/java.base/share/classes/java/lang/foreign/FunctionDescriptor.java index dd1ec8e1660e6..b199882ac18af 100644 --- a/src/java.base/share/classes/java/lang/foreign/FunctionDescriptor.java +++ b/src/java.base/share/classes/java/lang/foreign/FunctionDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -25,13 +25,13 @@ package java.lang.foreign; +import jdk.internal.foreign.FunctionDescriptorImpl; + import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; +import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.List; - -import jdk.internal.foreign.FunctionDescriptorImpl; /** * A function descriptor models the signature of a foreign function. A function diff --git a/src/java.base/share/classes/java/lang/foreign/Linker.java b/src/java.base/share/classes/java/lang/foreign/Linker.java index 2f7013803143b..6e7aae9f72b0c 100644 --- a/src/java.base/share/classes/java/lang/foreign/Linker.java +++ b/src/java.base/share/classes/java/lang/foreign/Linker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -26,8 +26,8 @@ package java.lang.foreign; import jdk.internal.foreign.abi.AbstractLinker; -import jdk.internal.foreign.abi.LinkerOptions; import jdk.internal.foreign.abi.CapturableState; +import jdk.internal.foreign.abi.LinkerOptions; import jdk.internal.foreign.abi.SharedUtils; import jdk.internal.javac.Restricted; import jdk.internal.reflect.CallerSensitive; diff --git a/src/java.base/share/classes/java/lang/foreign/MemoryLayout.java b/src/java.base/share/classes/java/lang/foreign/MemoryLayout.java index 2cf0a5e4443cb..cb51bbaf795b0 100644 --- a/src/java.base/share/classes/java/lang/foreign/MemoryLayout.java +++ b/src/java.base/share/classes/java/lang/foreign/MemoryLayout.java @@ -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 @@ -25,12 +25,6 @@ package java.lang.foreign; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.VarHandle; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Stream; - import jdk.internal.foreign.LayoutPath; import jdk.internal.foreign.Utils; import jdk.internal.foreign.layout.MemoryLayoutUtil; @@ -39,6 +33,12 @@ import jdk.internal.foreign.layout.StructLayoutImpl; import jdk.internal.foreign.layout.UnionLayoutImpl; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.VarHandle; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Stream; + /** * A memory layout describes the contents of a memory segment. *

diff --git a/src/java.base/share/classes/java/lang/foreign/MemorySegment.java b/src/java.base/share/classes/java/lang/foreign/MemorySegment.java index 024dfacb71b7e..70af8e7e0419c 100644 --- a/src/java.base/share/classes/java/lang/foreign/MemorySegment.java +++ b/src/java.base/share/classes/java/lang/foreign/MemorySegment.java @@ -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 @@ -25,6 +25,14 @@ package java.lang.foreign; +import jdk.internal.foreign.AbstractMemorySegmentImpl; +import jdk.internal.foreign.MemorySessionImpl; +import jdk.internal.foreign.SegmentBulkOperations; +import jdk.internal.foreign.SegmentFactories; +import jdk.internal.javac.Restricted; +import jdk.internal.reflect.CallerSensitive; +import jdk.internal.vm.annotation.ForceInline; + import java.io.UncheckedIOException; import java.lang.foreign.ValueLayout.OfInt; import java.nio.Buffer; @@ -41,13 +49,6 @@ import java.util.Spliterator; import java.util.function.Consumer; import java.util.stream.Stream; -import jdk.internal.foreign.AbstractMemorySegmentImpl; -import jdk.internal.foreign.MemorySessionImpl; -import jdk.internal.foreign.SegmentBulkOperations; -import jdk.internal.foreign.SegmentFactories; -import jdk.internal.javac.Restricted; -import jdk.internal.reflect.CallerSensitive; -import jdk.internal.vm.annotation.ForceInline; /** * A memory segment provides access to a contiguous region of memory. diff --git a/src/java.base/share/classes/java/lang/foreign/SegmentAllocator.java b/src/java.base/share/classes/java/lang/foreign/SegmentAllocator.java index 6e8cd789a36e2..1297406dcf194 100644 --- a/src/java.base/share/classes/java/lang/foreign/SegmentAllocator.java +++ b/src/java.base/share/classes/java/lang/foreign/SegmentAllocator.java @@ -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 @@ -25,17 +25,16 @@ package java.lang.foreign; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.Objects; - import jdk.internal.foreign.AbstractMemorySegmentImpl; import jdk.internal.foreign.ArenaImpl; import jdk.internal.foreign.SlicingAllocator; import jdk.internal.foreign.StringSupport; -import jdk.internal.foreign.Utils; import jdk.internal.vm.annotation.ForceInline; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.Objects; + /** * An object that may be used to allocate {@linkplain MemorySegment memory segments}. * Clients implementing this interface must implement the {@link #allocate(long, long)} diff --git a/src/java.base/share/classes/java/lang/foreign/ValueLayout.java b/src/java.base/share/classes/java/lang/foreign/ValueLayout.java index d4e396534911e..d81a624e59830 100644 --- a/src/java.base/share/classes/java/lang/foreign/ValueLayout.java +++ b/src/java.base/share/classes/java/lang/foreign/ValueLayout.java @@ -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 @@ -25,9 +25,10 @@ package java.lang.foreign; +import jdk.internal.foreign.layout.ValueLayouts; + import java.lang.invoke.VarHandle; import java.nio.ByteOrder; -import jdk.internal.foreign.layout.ValueLayouts; /** * A layout that models values of basic data types. Examples of values modeled by diff --git a/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java b/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java index 9ccaf92b8d6be..35396665ac69e 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java @@ -25,13 +25,32 @@ package jdk.internal.foreign; -import java.lang.foreign.*; +import jdk.internal.access.JavaNioAccess; +import jdk.internal.access.SharedSecrets; +import jdk.internal.access.foreign.UnmapperProxy; +import jdk.internal.misc.ScopedMemoryAccess; +import jdk.internal.reflect.CallerSensitive; +import jdk.internal.reflect.Reflection; +import jdk.internal.util.ArraysSupport; +import jdk.internal.util.Preconditions; +import jdk.internal.vm.annotation.ForceInline; +import sun.nio.ch.DirectBuffer; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout; import java.lang.reflect.Array; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; -import java.util.*; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Spliterator; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Function; @@ -39,17 +58,6 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; -import jdk.internal.access.JavaNioAccess; -import jdk.internal.access.SharedSecrets; -import jdk.internal.access.foreign.UnmapperProxy; -import jdk.internal.misc.ScopedMemoryAccess; -import jdk.internal.reflect.CallerSensitive; -import jdk.internal.reflect.Reflection; -import jdk.internal.util.ArraysSupport; -import jdk.internal.util.Preconditions; -import jdk.internal.vm.annotation.ForceInline; -import sun.nio.ch.DirectBuffer; - /** * This abstract class provides an immutable implementation for the {@code MemorySegment} interface. This class contains information * about the segment's spatial and temporal bounds; each memory segment implementation is associated with an owner thread which is set at creation time. diff --git a/src/java.base/share/classes/jdk/internal/foreign/ArenaImpl.java b/src/java.base/share/classes/jdk/internal/foreign/ArenaImpl.java index 948cc7c2acf68..da8a6c2666637 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/ArenaImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/ArenaImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, 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 @@ -26,10 +26,7 @@ package jdk.internal.foreign; import java.lang.foreign.Arena; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; import java.lang.foreign.MemorySegment.Scope; -import java.util.Objects; public final class ArenaImpl implements Arena { diff --git a/src/java.base/share/classes/jdk/internal/foreign/CABI.java b/src/java.base/share/classes/jdk/internal/foreign/CABI.java index 216a9fd874c2f..631d8482dd8b1 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/CABI.java +++ b/src/java.base/share/classes/jdk/internal/foreign/CABI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -27,9 +27,9 @@ package jdk.internal.foreign; import jdk.internal.foreign.abi.fallback.FallbackLinker; -import jdk.internal.vm.ForeignLinkerSupport; import jdk.internal.util.OperatingSystem; import jdk.internal.util.StaticProperty; +import jdk.internal.vm.ForeignLinkerSupport; import static java.lang.foreign.ValueLayout.ADDRESS; diff --git a/src/java.base/share/classes/jdk/internal/foreign/ConfinedSession.java b/src/java.base/share/classes/jdk/internal/foreign/ConfinedSession.java index 9b98bf82b5eee..ec1e8fa7b155b 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/ConfinedSession.java +++ b/src/java.base/share/classes/jdk/internal/foreign/ConfinedSession.java @@ -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 @@ -25,12 +25,12 @@ package jdk.internal.foreign; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.VarHandle; - import jdk.internal.invoke.MhUtil; import jdk.internal.vm.annotation.ForceInline; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + /** * A confined session, which features an owner thread. The liveness check features an additional * confinement check - that is, calling any operation on this session from a thread other than the diff --git a/src/java.base/share/classes/jdk/internal/foreign/GlobalSession.java b/src/java.base/share/classes/jdk/internal/foreign/GlobalSession.java index 9f57b2a36ddab..8d834b23eb2e7 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/GlobalSession.java +++ b/src/java.base/share/classes/jdk/internal/foreign/GlobalSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -25,12 +25,8 @@ package jdk.internal.foreign; -import jdk.internal.access.JavaNioAccess; -import jdk.internal.access.SharedSecrets; import jdk.internal.vm.annotation.ForceInline; -import sun.nio.ch.DirectBuffer; -import java.nio.Buffer; import java.util.Objects; /** diff --git a/src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java b/src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java index 2512b9e54a47d..bd7834af7d4fb 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -26,15 +26,15 @@ package jdk.internal.foreign; +import jdk.internal.access.JavaNioAccess; +import jdk.internal.access.SharedSecrets; +import jdk.internal.vm.annotation.ForceInline; + import java.lang.foreign.ValueLayout; import java.nio.ByteBuffer; import java.util.Objects; import java.util.Optional; -import jdk.internal.access.JavaNioAccess; -import jdk.internal.access.SharedSecrets; -import jdk.internal.vm.annotation.ForceInline; - /** * Implementation for heap memory segments. A heap memory segment is composed by an offset and * a base object (typically an array). To enhance performances, the access to the base object needs to feature diff --git a/src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java b/src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java index dc995589472b1..58552d44ea472 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java +++ b/src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java @@ -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 @@ -39,7 +39,6 @@ import java.lang.invoke.MethodType; import java.lang.invoke.VarHandle; import java.util.Arrays; -import java.util.List; import java.util.Objects; import java.util.function.UnaryOperator; import java.util.stream.IntStream; diff --git a/src/java.base/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java b/src/java.base/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java index f0ae76829ffbd..efa6cf398829e 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -25,10 +25,11 @@ package jdk.internal.foreign; -import java.nio.ByteBuffer; import jdk.internal.access.foreign.UnmapperProxy; import jdk.internal.misc.ScopedMemoryAccess; +import java.nio.ByteBuffer; + /** * Implementation for a mapped memory segments. A mapped memory segment is a native memory segment, which * additionally features an {@link UnmapperProxy} object. This object provides detailed information about the diff --git a/src/java.base/share/classes/jdk/internal/foreign/MemorySessionImpl.java b/src/java.base/share/classes/jdk/internal/foreign/MemorySessionImpl.java index 8f576625500c1..cc2e746ce4da9 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/MemorySessionImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/MemorySessionImpl.java @@ -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 @@ -26,20 +26,20 @@ package jdk.internal.foreign; -import java.lang.foreign.MemorySegment; +import jdk.internal.foreign.GlobalSession.HeapSession; +import jdk.internal.invoke.MhUtil; +import jdk.internal.misc.ScopedMemoryAccess; +import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.vm.annotation.Stable; + import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; import java.lang.foreign.MemorySegment.Scope; import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.lang.ref.Cleaner; import java.util.Objects; -import jdk.internal.foreign.GlobalSession.HeapSession; -import jdk.internal.misc.ScopedMemoryAccess; -import jdk.internal.invoke.MhUtil; -import jdk.internal.vm.annotation.ForceInline; -import jdk.internal.vm.annotation.Stable; - /** * This class manages the temporal bounds associated with a memory segment as well * as thread confinement. A session has a liveness bit, which is updated when the session is closed diff --git a/src/java.base/share/classes/jdk/internal/foreign/NativeMemorySegmentImpl.java b/src/java.base/share/classes/jdk/internal/foreign/NativeMemorySegmentImpl.java index 1c726acd2e10a..d0313adc88491 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/NativeMemorySegmentImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/NativeMemorySegmentImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -26,12 +26,12 @@ package jdk.internal.foreign; -import java.nio.ByteBuffer; -import java.util.Optional; - import jdk.internal.misc.Unsafe; import jdk.internal.vm.annotation.ForceInline; +import java.nio.ByteBuffer; +import java.util.Optional; + /** * Implementation for native memory segments. A native memory segment is essentially a wrapper around * a native long address. diff --git a/src/java.base/share/classes/jdk/internal/foreign/SharedSession.java b/src/java.base/share/classes/jdk/internal/foreign/SharedSession.java index b4415ad49590f..b86bb7daee3e9 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/SharedSession.java +++ b/src/java.base/share/classes/jdk/internal/foreign/SharedSession.java @@ -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 @@ -25,12 +25,13 @@ package jdk.internal.foreign; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.VarHandle; -import jdk.internal.misc.ScopedMemoryAccess; import jdk.internal.invoke.MhUtil; +import jdk.internal.misc.ScopedMemoryAccess; import jdk.internal.vm.annotation.ForceInline; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; + /** * A shared session, which can be shared across multiple threads. Closing a shared session has to ensure that * (i) only one thread can successfully close a session (e.g. in a close vs. close race) and that diff --git a/src/java.base/share/classes/jdk/internal/foreign/SystemLookup.java b/src/java.base/share/classes/jdk/internal/foreign/SystemLookup.java index 8adf51ef6fda0..bf5371d43a067 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/SystemLookup.java +++ b/src/java.base/share/classes/jdk/internal/foreign/SystemLookup.java @@ -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 @@ -25,17 +25,21 @@ package jdk.internal.foreign; -import java.lang.foreign.*; +import jdk.internal.loader.NativeLibrary; +import jdk.internal.loader.RawNativeLibraries; +import jdk.internal.util.OperatingSystem; +import jdk.internal.util.StaticProperty; + +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SequenceLayout; +import java.lang.foreign.SymbolLookup; import java.lang.invoke.MethodHandles; import java.nio.file.Files; import java.nio.file.Path; import java.util.Objects; import java.util.Optional; import java.util.function.Function; -import jdk.internal.loader.NativeLibrary; -import jdk.internal.loader.RawNativeLibraries; -import jdk.internal.util.OperatingSystem; -import jdk.internal.util.StaticProperty; import static java.lang.foreign.ValueLayout.ADDRESS; diff --git a/src/java.base/share/classes/jdk/internal/foreign/Utils.java b/src/java.base/share/classes/jdk/internal/foreign/Utils.java index 3d252dcf233ae..9ff1da4ff2405 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/Utils.java +++ b/src/java.base/share/classes/jdk/internal/foreign/Utils.java @@ -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 @@ -26,6 +26,12 @@ package jdk.internal.foreign; +import jdk.internal.access.SharedSecrets; +import jdk.internal.foreign.abi.SharedUtils; +import jdk.internal.misc.Unsafe; +import jdk.internal.vm.annotation.ForceInline; +import sun.invoke.util.Wrapper; + import java.lang.foreign.AddressLayout; import java.lang.foreign.MemoryLayout; import java.lang.foreign.MemoryLayout.PathElement; @@ -42,12 +48,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Supplier; -import jdk.internal.access.SharedSecrets; -import jdk.internal.foreign.abi.SharedUtils; -import jdk.internal.misc.Unsafe; -import jdk.internal.vm.annotation.ForceInline; -import sun.invoke.util.Wrapper; - /** * This class contains misc helper functions to support creation of memory segments. */ diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java index 5b40ac1775007..19b235963a37f 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -42,11 +42,11 @@ import jdk.internal.reflect.Reflection; import java.lang.foreign.AddressLayout; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; import java.lang.foreign.Arena; import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; import java.lang.foreign.Linker; +import java.lang.foreign.MemoryLayout; import java.lang.foreign.MemorySegment; import java.lang.foreign.PaddingLayout; import java.lang.foreign.SequenceLayout; diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/Binding.java b/src/java.base/share/classes/jdk/internal/foreign/abi/Binding.java index 1f7f3327fe566..3e81a4515227d 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/Binding.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/Binding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -29,7 +29,10 @@ import jdk.internal.foreign.abi.BindingInterpreter.LoadFunc; import jdk.internal.foreign.abi.BindingInterpreter.StoreFunc; -import java.lang.foreign.*; +import java.lang.foreign.Arena; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -37,9 +40,7 @@ import java.util.Deque; import java.util.List; -import static java.lang.foreign.ValueLayout.JAVA_BYTE; -import static java.lang.foreign.ValueLayout.JAVA_INT_UNALIGNED; -import static java.lang.foreign.ValueLayout.JAVA_SHORT_UNALIGNED; +import static java.lang.foreign.ValueLayout.*; /** * The binding operators defined in the Binding class can be combined into argument and return value processing 'recipes'. diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java b/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java index 144af9dac793d..a1323e16945aa 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -25,13 +25,6 @@ package jdk.internal.foreign.abi; -import java.lang.classfile.Annotation; -import java.lang.classfile.ClassFile; -import java.lang.classfile.CodeBuilder; -import java.lang.classfile.Label; -import java.lang.classfile.Opcode; -import java.lang.classfile.TypeKind; - import jdk.internal.foreign.AbstractMemorySegmentImpl; import jdk.internal.foreign.MemorySessionImpl; import jdk.internal.foreign.Utils; @@ -51,12 +44,23 @@ import jdk.internal.vm.annotation.ForceInline; import java.io.IOException; +import java.lang.classfile.Annotation; +import java.lang.classfile.ClassFile; +import java.lang.classfile.CodeBuilder; +import java.lang.classfile.Label; +import java.lang.classfile.Opcode; +import java.lang.classfile.TypeKind; import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import java.lang.constant.ClassDesc; import java.lang.constant.ConstantDesc; import java.lang.constant.DynamicConstantDesc; import java.lang.constant.MethodTypeDesc; -import java.lang.foreign.*; +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SegmentAllocator; +import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -69,9 +73,10 @@ import java.util.Deque; import java.util.List; -import static java.lang.constant.ConstantDescs.*; import static java.lang.classfile.ClassFile.*; -import static java.lang.classfile.TypeKind.*; +import static java.lang.classfile.TypeKind.LONG; +import static java.lang.classfile.TypeKind.REFERENCE; +import static java.lang.constant.ConstantDescs.*; import static jdk.internal.constant.ConstantUtils.*; public class BindingSpecializer { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java index 5aad4ccc890dc..4f7a049fd6d1b 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -25,7 +25,6 @@ package jdk.internal.foreign.abi; import java.lang.foreign.FunctionDescriptor; - import java.lang.invoke.MethodType; import java.util.List; import java.util.stream.Stream; diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java index a03c20d317349..272e3eeb6c37d 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -26,7 +26,7 @@ package jdk.internal.foreign.abi; import jdk.internal.foreign.Utils; -import jdk.internal.foreign.abi.Binding.*; +import jdk.internal.foreign.abi.Binding.Allocate; import jdk.internal.foreign.abi.Binding.BoxAddress; import jdk.internal.foreign.abi.Binding.BufferLoad; import jdk.internal.foreign.abi.Binding.BufferStore; diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java index 2df30edb32626..acdbef5822d59 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -27,6 +27,8 @@ import jdk.internal.access.JavaLangInvokeAccess; import jdk.internal.access.SharedSecrets; +import jdk.internal.foreign.AbstractMemorySegmentImpl; +import jdk.internal.foreign.MemorySessionImpl; import jdk.internal.invoke.MhUtil; import java.lang.foreign.AddressLayout; @@ -41,13 +43,7 @@ import java.util.List; import java.util.stream.Stream; -import jdk.internal.foreign.AbstractMemorySegmentImpl; -import jdk.internal.foreign.MemorySessionImpl; - -import static java.lang.invoke.MethodHandles.collectArguments; -import static java.lang.invoke.MethodHandles.foldArguments; -import static java.lang.invoke.MethodHandles.identity; -import static java.lang.invoke.MethodHandles.insertArguments; +import static java.lang.invoke.MethodHandles.*; import static java.lang.invoke.MethodType.methodType; public class DowncallLinker { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java b/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java index 83698398edaa0..9078920f677f6 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -44,9 +44,9 @@ import java.lang.foreign.AddressLayout; import java.lang.foreign.Arena; -import java.lang.foreign.Linker; import java.lang.foreign.FunctionDescriptor; import java.lang.foreign.GroupLayout; +import java.lang.foreign.Linker; import java.lang.foreign.MemoryLayout; import java.lang.foreign.MemorySegment; import java.lang.foreign.MemorySegment.Scope; diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/UpcallLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/UpcallLinker.java index 486ee8b57c53a..64cffa0cf7a5d 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/UpcallLinker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/UpcallLinker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -38,9 +38,7 @@ import java.util.function.UnaryOperator; import java.util.stream.Stream; -import static java.lang.invoke.MethodHandles.exactInvoker; -import static java.lang.invoke.MethodHandles.insertArguments; -import static java.lang.invoke.MethodHandles.lookup; +import static java.lang.invoke.MethodHandles.*; import static java.lang.invoke.MethodType.methodType; public class UpcallLinker { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/UpcallStubs.java b/src/java.base/share/classes/jdk/internal/foreign/abi/UpcallStubs.java index 2d4ccfe39bcdf..61c336bf2fbc2 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/UpcallStubs.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/UpcallStubs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -24,12 +24,12 @@ */ package jdk.internal.foreign.abi; -import java.lang.foreign.MemorySegment; -import java.lang.foreign.Arena; - import jdk.internal.foreign.MemorySessionImpl; import jdk.internal.foreign.Utils; +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; + public final class UpcallStubs { private UpcallStubs() { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java index 9eb4910e5805a..2ad5ffa902eca 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, 2022, Arm Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -25,11 +25,7 @@ */ package jdk.internal.foreign.abi.aarch64; -import java.lang.foreign.AddressLayout; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; +import jdk.internal.foreign.Utils; import jdk.internal.foreign.abi.ABIDescriptor; import jdk.internal.foreign.abi.AbstractLinker.UpcallStubFactory; import jdk.internal.foreign.abi.Binding; @@ -42,16 +38,21 @@ import jdk.internal.foreign.abi.aarch64.linux.LinuxAArch64CallArranger; import jdk.internal.foreign.abi.aarch64.macos.MacOsAArch64CallArranger; import jdk.internal.foreign.abi.aarch64.windows.WindowsAArch64CallArranger; -import jdk.internal.foreign.Utils; +import java.lang.foreign.AddressLayout; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; import java.util.List; import java.util.Optional; -import static jdk.internal.foreign.abi.aarch64.AArch64Architecture.*; import static jdk.internal.foreign.abi.aarch64.AArch64Architecture.Regs.*; +import static jdk.internal.foreign.abi.aarch64.AArch64Architecture.StorageType; +import static jdk.internal.foreign.abi.aarch64.AArch64Architecture.abiFor; /** * For the AArch64 C ABI specifically, this class uses CallingSequenceBuilder diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/TypeClass.java b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/TypeClass.java index 4c655de4b2035..de1b600b54a5e 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/TypeClass.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/TypeClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2021, Arm Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,6 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.aarch64; import java.lang.foreign.GroupLayout; @@ -30,8 +31,8 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; import java.lang.foreign.ValueLayout; -import java.util.List; import java.util.ArrayList; +import java.util.List; public enum TypeClass { STRUCT_REGISTER, diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/linux/LinuxAArch64CallArranger.java b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/linux/LinuxAArch64CallArranger.java index d79b3337f6e00..5f4829ac5d30c 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/linux/LinuxAArch64CallArranger.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/linux/LinuxAArch64CallArranger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, Arm Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,10 +23,11 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.aarch64.linux; -import jdk.internal.foreign.abi.aarch64.CallArranger; import jdk.internal.foreign.abi.ABIDescriptor; +import jdk.internal.foreign.abi.aarch64.CallArranger; /** * AArch64 CallArranger specialized for Linux ABI. diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/linux/LinuxAArch64Linker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/linux/LinuxAArch64Linker.java index 4ffd15aefa0ad..d89717c8320a5 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/linux/LinuxAArch64Linker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/linux/LinuxAArch64Linker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, 2021, Arm Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,6 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.aarch64.linux; import jdk.internal.foreign.abi.AbstractLinker; @@ -35,7 +36,6 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; -import java.nio.ByteOrder; import java.util.Map; /** diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/macos/MacOsAArch64CallArranger.java b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/macos/MacOsAArch64CallArranger.java index e099d8cd93f89..a7c37ab1ec83a 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/macos/MacOsAArch64CallArranger.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/macos/MacOsAArch64CallArranger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, Arm Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,10 +23,11 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.aarch64.macos; -import jdk.internal.foreign.abi.aarch64.CallArranger; import jdk.internal.foreign.abi.ABIDescriptor; +import jdk.internal.foreign.abi.aarch64.CallArranger; /** * AArch64 CallArranger specialized for macOS ABI. diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/macos/MacOsAArch64Linker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/macos/MacOsAArch64Linker.java index c60f01524df42..a63af4c98df45 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/macos/MacOsAArch64Linker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/macos/MacOsAArch64Linker.java @@ -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. * Copyright (c) 2021, Arm Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,6 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.aarch64.macos; import jdk.internal.foreign.abi.AbstractLinker; @@ -35,7 +36,6 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; -import java.nio.ByteOrder; import java.util.Map; /** diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/windows/WindowsAArch64CallArranger.java b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/windows/WindowsAArch64CallArranger.java index 18df73870758a..4570bc75a7793 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/windows/WindowsAArch64CallArranger.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/windows/WindowsAArch64CallArranger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, Arm Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,17 +23,18 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.aarch64.windows; -import jdk.internal.foreign.abi.aarch64.CallArranger; -import jdk.internal.foreign.abi.aarch64.TypeClass; import jdk.internal.foreign.abi.ABIDescriptor; import jdk.internal.foreign.abi.VMStorage; +import jdk.internal.foreign.abi.aarch64.CallArranger; +import jdk.internal.foreign.abi.aarch64.TypeClass; import java.lang.foreign.MemoryLayout; -import static jdk.internal.foreign.abi.aarch64.AArch64Architecture.*; import static jdk.internal.foreign.abi.aarch64.AArch64Architecture.Regs.*; +import static jdk.internal.foreign.abi.aarch64.AArch64Architecture.abiFor; /** * AArch64 CallArranger specialized for Windows ABI. diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/windows/WindowsAArch64Linker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/windows/WindowsAArch64Linker.java index 23fb046aeb1da..df859435f631d 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/windows/WindowsAArch64Linker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/windows/WindowsAArch64Linker.java @@ -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. * Copyright (c) 2021, Arm Limited. All rights reserved. * Copyright (c) 2021, 2022, Microsoft. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -24,6 +24,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.aarch64.windows; import jdk.internal.foreign.abi.AbstractLinker; @@ -36,7 +37,6 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; -import java.nio.ByteOrder; import java.util.Map; /** diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FFIType.java b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FFIType.java index c8fa729711abf..64c364e6ad2e0 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FFIType.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FFIType.java @@ -1,5 +1,5 @@ /* - * 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.fallback; import jdk.internal.foreign.Utils; @@ -42,11 +43,7 @@ import java.util.Objects; import java.util.function.Predicate; -import static java.lang.foreign.ValueLayout.ADDRESS; -import static java.lang.foreign.ValueLayout.JAVA_BYTE; -import static java.lang.foreign.ValueLayout.JAVA_INT; -import static java.lang.foreign.ValueLayout.JAVA_LONG; -import static java.lang.foreign.ValueLayout.JAVA_SHORT; +import static java.lang.foreign.ValueLayout.*; /** * typedef struct _ffi_type diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java index 54906d9fef2ed..9be958e7689f6 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, 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 @@ -22,8 +22,16 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.fallback; +import jdk.internal.foreign.AbstractMemorySegmentImpl; +import jdk.internal.foreign.MemorySessionImpl; +import jdk.internal.foreign.abi.AbstractLinker; +import jdk.internal.foreign.abi.CapturableState; +import jdk.internal.foreign.abi.LinkerOptions; +import jdk.internal.foreign.abi.SharedUtils; + import java.lang.foreign.AddressLayout; import java.lang.foreign.Arena; import java.lang.foreign.FunctionDescriptor; @@ -33,29 +41,16 @@ import java.lang.foreign.SegmentAllocator; import java.lang.foreign.SequenceLayout; import java.lang.foreign.ValueLayout; -import static java.lang.foreign.ValueLayout.ADDRESS; -import static java.lang.foreign.ValueLayout.JAVA_BOOLEAN; -import static java.lang.foreign.ValueLayout.JAVA_BYTE; -import static java.lang.foreign.ValueLayout.JAVA_CHAR; -import static java.lang.foreign.ValueLayout.JAVA_DOUBLE; -import static java.lang.foreign.ValueLayout.JAVA_FLOAT; -import static java.lang.foreign.ValueLayout.JAVA_INT; -import static java.lang.foreign.ValueLayout.JAVA_LONG; -import static java.lang.foreign.ValueLayout.JAVA_SHORT; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; -import static java.lang.invoke.MethodHandles.foldArguments; import java.lang.invoke.MethodType; import java.lang.ref.Reference; import java.util.ArrayList; import java.util.List; import java.util.Map; -import jdk.internal.foreign.AbstractMemorySegmentImpl; -import jdk.internal.foreign.MemorySessionImpl; -import jdk.internal.foreign.abi.AbstractLinker; -import jdk.internal.foreign.abi.CapturableState; -import jdk.internal.foreign.abi.LinkerOptions; -import jdk.internal.foreign.abi.SharedUtils; + +import static java.lang.foreign.ValueLayout.*; +import static java.lang.invoke.MethodHandles.foldArguments; public final class FallbackLinker extends AbstractLinker { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/CallArranger.java b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/CallArranger.java index d07cd79e54813..0fd90ef6f73a6 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/CallArranger.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/CallArranger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,6 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.ppc64; import jdk.internal.foreign.Utils; @@ -50,8 +51,9 @@ import java.util.List; import java.util.Optional; -import static jdk.internal.foreign.abi.ppc64.PPC64Architecture.*; import static jdk.internal.foreign.abi.ppc64.PPC64Architecture.Regs.*; +import static jdk.internal.foreign.abi.ppc64.PPC64Architecture.StorageType; +import static jdk.internal.foreign.abi.ppc64.PPC64Architecture.abiFor; /** * For the PPC64 C ABI specifically, this class uses CallingSequenceBuilder diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/TypeClass.java b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/TypeClass.java index b04d4abf8a4bb..a3e473b6a8d17 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/TypeClass.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/TypeClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,6 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.ppc64; import java.lang.foreign.GroupLayout; @@ -30,8 +31,8 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; import java.lang.foreign.ValueLayout; -import java.util.List; import java.util.ArrayList; +import java.util.List; public enum TypeClass { STRUCT_REGISTER, diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/linux/LinuxPPC64Linker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/linux/LinuxPPC64Linker.java index a9f5bb4d60045..72d1ed704e780 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/linux/LinuxPPC64Linker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/linux/LinuxPPC64Linker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,6 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.ppc64.linux; import jdk.internal.foreign.abi.AbstractLinker; @@ -35,7 +36,6 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; -import java.nio.ByteOrder; import java.util.Map; public final class LinuxPPC64Linker extends AbstractLinker { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/linux/LinuxPPC64leLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/linux/LinuxPPC64leLinker.java index e8305669ba035..22acc6ea6835c 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/linux/LinuxPPC64leLinker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/linux/LinuxPPC64leLinker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,6 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.ppc64.linux; import jdk.internal.foreign.abi.AbstractLinker; @@ -35,7 +36,6 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; -import java.nio.ByteOrder; import java.util.Map; public final class LinuxPPC64leLinker extends AbstractLinker { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/riscv64/linux/LinuxRISCV64CallArranger.java b/src/java.base/share/classes/jdk/internal/foreign/abi/riscv64/linux/LinuxRISCV64CallArranger.java index e8ac33054d20e..eb4192fdfe7c6 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/riscv64/linux/LinuxRISCV64CallArranger.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/riscv64/linux/LinuxRISCV64CallArranger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, Institute of Software, Chinese Academy of Sciences. * All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,11 +28,7 @@ package jdk.internal.foreign.abi.riscv64.linux; -import java.lang.foreign.AddressLayout; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; +import jdk.internal.foreign.Utils; import jdk.internal.foreign.abi.ABIDescriptor; import jdk.internal.foreign.abi.AbstractLinker.UpcallStubFactory; import jdk.internal.foreign.abi.Binding; @@ -42,17 +38,21 @@ import jdk.internal.foreign.abi.LinkerOptions; import jdk.internal.foreign.abi.SharedUtils; import jdk.internal.foreign.abi.VMStorage; -import jdk.internal.foreign.Utils; +import java.lang.foreign.AddressLayout; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; import java.util.List; import java.util.Map; import java.util.Optional; -import static jdk.internal.foreign.abi.riscv64.linux.TypeClass.*; -import static jdk.internal.foreign.abi.riscv64.RISCV64Architecture.*; import static jdk.internal.foreign.abi.riscv64.RISCV64Architecture.Regs.*; +import static jdk.internal.foreign.abi.riscv64.RISCV64Architecture.*; +import static jdk.internal.foreign.abi.riscv64.linux.TypeClass.*; /** * For the RISCV64 C ABI specifically, this class uses CallingSequenceBuilder diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/riscv64/linux/LinuxRISCV64Linker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/riscv64/linux/LinuxRISCV64Linker.java index 706fdacf60875..cc948b884bca9 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/riscv64/linux/LinuxRISCV64Linker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/riscv64/linux/LinuxRISCV64Linker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, Institute of Software, Chinese Academy of Sciences. * All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -37,7 +37,6 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; -import java.nio.ByteOrder; import java.util.Map; public final class LinuxRISCV64Linker extends AbstractLinker { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/LinuxS390CallArranger.java b/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/LinuxS390CallArranger.java index 7e6c254079ac7..bafa5652c3048 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/LinuxS390CallArranger.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/LinuxS390CallArranger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023 IBM Corp. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,13 +23,10 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.s390.linux; -import java.lang.foreign.AddressLayout; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.GroupLayout; -import java.lang.foreign.MemoryLayout; -import java.lang.foreign.MemorySegment; +import jdk.internal.foreign.Utils; import jdk.internal.foreign.abi.ABIDescriptor; import jdk.internal.foreign.abi.AbstractLinker.UpcallStubFactory; import jdk.internal.foreign.abi.Binding; @@ -39,8 +36,12 @@ import jdk.internal.foreign.abi.LinkerOptions; import jdk.internal.foreign.abi.SharedUtils; import jdk.internal.foreign.abi.VMStorage; -import jdk.internal.foreign.Utils; +import java.lang.foreign.AddressLayout; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.GroupLayout; +import java.lang.foreign.MemoryLayout; +import java.lang.foreign.MemorySegment; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; import java.util.List; diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/LinuxS390Linker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/LinuxS390Linker.java index 9810fbf169579..558d19d772c29 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/LinuxS390Linker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/LinuxS390Linker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023 IBM Corp. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,6 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.s390.linux; import jdk.internal.foreign.abi.AbstractLinker; @@ -34,7 +35,6 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; -import java.nio.ByteOrder; import java.util.Map; public final class LinuxS390Linker extends AbstractLinker { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/TypeClass.java b/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/TypeClass.java index 1f96fa4bf79df..316f462472383 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/TypeClass.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/s390/linux/TypeClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023 IBM Corp. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -23,6 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.s390.linux; import java.lang.foreign.GroupLayout; @@ -30,8 +31,8 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.SequenceLayout; import java.lang.foreign.ValueLayout; -import java.util.List; import java.util.ArrayList; +import java.util.List; public enum TypeClass { STRUCT_REGISTER, diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/CallArranger.java b/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/CallArranger.java index 78db1ca89e676..70b4c9f69f247 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/CallArranger.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/CallArranger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -23,6 +23,7 @@ * questions. * */ + package jdk.internal.foreign.abi.x64.sysv; import jdk.internal.foreign.Utils; @@ -50,8 +51,8 @@ import java.util.Optional; import static jdk.internal.foreign.abi.Binding.vmStore; -import static jdk.internal.foreign.abi.x64.X86_64Architecture.*; import static jdk.internal.foreign.abi.x64.X86_64Architecture.Regs.*; +import static jdk.internal.foreign.abi.x64.X86_64Architecture.StorageType; /** * For the SysV x64 C ABI specifically, this class uses namely CallingSequenceBuilder diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVx64Linker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVx64Linker.java index b1fce35af8375..1b4237ec7fa62 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVx64Linker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVx64Linker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -22,8 +22,8 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.foreign.abi.x64.sysv; +package jdk.internal.foreign.abi.x64.sysv; import jdk.internal.foreign.abi.AbstractLinker; import jdk.internal.foreign.abi.LinkerOptions; @@ -34,7 +34,6 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; -import java.nio.ByteOrder; import java.util.Map; /** diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/TypeClass.java b/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/TypeClass.java index 429b29e7fd1d4..af5550ca1db00 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/TypeClass.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/TypeClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -22,8 +22,11 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.x64.sysv; +import jdk.internal.foreign.Utils; + import java.lang.foreign.GroupLayout; import java.lang.foreign.MemoryLayout; import java.lang.foreign.MemorySegment; @@ -31,8 +34,6 @@ import java.lang.foreign.SequenceLayout; import java.lang.foreign.StructLayout; import java.lang.foreign.ValueLayout; -import jdk.internal.foreign.Utils; - import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/x64/windows/CallArranger.java b/src/java.base/share/classes/jdk/internal/foreign/abi/x64/windows/CallArranger.java index cc69e79a09210..1c15d5b069858 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/x64/windows/CallArranger.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/x64/windows/CallArranger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.x64.windows; import jdk.internal.foreign.Utils; @@ -46,8 +47,9 @@ import java.util.List; import java.util.Optional; -import static jdk.internal.foreign.abi.x64.X86_64Architecture.*; +import static jdk.internal.foreign.abi.x64.X86_64Architecture.INSTANCE; import static jdk.internal.foreign.abi.x64.X86_64Architecture.Regs.*; +import static jdk.internal.foreign.abi.x64.X86_64Architecture.StorageType; /** * For the Windowx x64 C ABI specifically, this class uses CallingSequenceBuilder diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/x64/windows/Windowsx64Linker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/x64/windows/Windowsx64Linker.java index 30e4a5bdaf495..c14616f190b39 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/x64/windows/Windowsx64Linker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/x64/windows/Windowsx64Linker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package jdk.internal.foreign.abi.x64.windows; import jdk.internal.foreign.abi.AbstractLinker; @@ -33,7 +34,6 @@ import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; -import java.nio.ByteOrder; import java.util.Map; /** From b0e2be6f6b668ec4e3cfa525c660193dfbff77bf Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 15 Jan 2025 12:25:59 +0000 Subject: [PATCH 04/47] 8347729: Replace SIZE_FORMAT in parallel and serial gc Reviewed-by: dholmes, tschatzl --- .../share/gc/epsilon/epsilonArguments.cpp | 2 +- src/hotspot/share/gc/epsilon/epsilonHeap.cpp | 26 +++---- .../share/gc/epsilon/epsilonInitLogger.cpp | 4 +- .../share/gc/parallel/mutableNUMASpace.cpp | 8 +-- .../share/gc/parallel/mutableSpace.cpp | 4 +- .../share/gc/parallel/parallelInitLogger.cpp | 8 +-- .../gc/parallel/parallelScavengeHeap.cpp | 4 +- .../gc/parallel/psAdaptiveSizePolicy.cpp | 68 +++++++++---------- .../share/gc/parallel/psClosure.inline.hpp | 4 +- src/hotspot/share/gc/parallel/psOldGen.cpp | 16 ++--- .../share/gc/parallel/psParallelCompact.cpp | 16 ++--- src/hotspot/share/gc/parallel/psScavenge.cpp | 6 +- src/hotspot/share/gc/parallel/psYoungGen.cpp | 38 +++++------ .../share/gc/serial/defNewGeneration.cpp | 10 +-- src/hotspot/share/gc/serial/serialFullGC.cpp | 6 +- src/hotspot/share/gc/serial/serialHeap.cpp | 7 +- .../share/gc/serial/tenuredGeneration.cpp | 16 ++--- 17 files changed, 121 insertions(+), 122 deletions(-) diff --git a/src/hotspot/share/gc/epsilon/epsilonArguments.cpp b/src/hotspot/share/gc/epsilon/epsilonArguments.cpp index ba023e8799bc5..21ee348294706 100644 --- a/src/hotspot/share/gc/epsilon/epsilonArguments.cpp +++ b/src/hotspot/share/gc/epsilon/epsilonArguments.cpp @@ -46,7 +46,7 @@ void EpsilonArguments::initialize() { } if (EpsilonMaxTLABSize < MinTLABSize) { - log_warning(gc)("EpsilonMaxTLABSize < MinTLABSize, adjusting it to " SIZE_FORMAT, MinTLABSize); + log_warning(gc)("EpsilonMaxTLABSize < MinTLABSize, adjusting it to %zu", MinTLABSize); EpsilonMaxTLABSize = MinTLABSize; } diff --git a/src/hotspot/share/gc/epsilon/epsilonHeap.cpp b/src/hotspot/share/gc/epsilon/epsilonHeap.cpp index 3cd5665e04534..5c1ef19a3761e 100644 --- a/src/hotspot/share/gc/epsilon/epsilonHeap.cpp +++ b/src/hotspot/share/gc/epsilon/epsilonHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2022, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -103,7 +103,7 @@ EpsilonHeap* EpsilonHeap::heap() { } HeapWord* EpsilonHeap::allocate_work(size_t size, bool verbose) { - assert(is_object_aligned(size), "Allocation size should be aligned: " SIZE_FORMAT, size); + assert(is_object_aligned(size), "Allocation size should be aligned: %zu", size); HeapWord* res = nullptr; while (true) { @@ -129,7 +129,7 @@ HeapWord* EpsilonHeap::allocate_work(size_t size, bool verbose) { size_t unused_space = max_capacity() - used(); size_t want_space = MAX2(size_in_bytes, EpsilonMinHeapExpand); assert(unused_space >= uncommitted_space, - "Unused (" SIZE_FORMAT ") >= uncommitted (" SIZE_FORMAT ")", + "Unused (%zu) >= uncommitted (%zu)", unused_space, uncommitted_space); if (want_space < uncommitted_space) { @@ -218,18 +218,18 @@ HeapWord* EpsilonHeap::allocate_new_tlab(size_t min_size, // Check that adjustments did not break local and global invariants assert(is_object_aligned(size), - "Size honors object alignment: " SIZE_FORMAT, size); + "Size honors object alignment: %zu", size); assert(min_size <= size, - "Size honors min size: " SIZE_FORMAT " <= " SIZE_FORMAT, min_size, size); + "Size honors min size: %zu <= %zu", min_size, size); assert(size <= _max_tlab_size, - "Size honors max size: " SIZE_FORMAT " <= " SIZE_FORMAT, size, _max_tlab_size); + "Size honors max size: %zu <= %zu", size, _max_tlab_size); assert(size <= CollectedHeap::max_tlab_size(), - "Size honors global max size: " SIZE_FORMAT " <= " SIZE_FORMAT, size, CollectedHeap::max_tlab_size()); + "Size honors global max size: %zu <= %zu", size, CollectedHeap::max_tlab_size()); if (log_is_enabled(Trace, gc)) { ResourceMark rm; - log_trace(gc)("TLAB size for \"%s\" (Requested: " SIZE_FORMAT "K, Min: " SIZE_FORMAT - "K, Max: " SIZE_FORMAT "K, Ergo: " SIZE_FORMAT "K) -> " SIZE_FORMAT "K", + log_trace(gc)("TLAB size for \"%s\" (Requested: %zuK, Min: %zu" + "K, Max: %zuK, Ergo: %zuK) -> %zuK", thread->name(), requested_size * HeapWordSize / K, min_size * HeapWordSize / K, @@ -325,8 +325,8 @@ void EpsilonHeap::print_heap_info(size_t used) const { size_t committed = capacity(); if (reserved != 0) { - log_info(gc)("Heap: " SIZE_FORMAT "%s reserved, " SIZE_FORMAT "%s (%.2f%%) committed, " - SIZE_FORMAT "%s (%.2f%%) used", + log_info(gc)("Heap: %zu%s reserved, %zu%s (%.2f%%) committed, " + "%zu%s (%.2f%%) used", byte_size_in_proper_unit(reserved), proper_unit_for_byte_size(reserved), byte_size_in_proper_unit(committed), proper_unit_for_byte_size(committed), committed * 100.0 / reserved, @@ -344,8 +344,8 @@ void EpsilonHeap::print_metaspace_info() const { size_t used = stats.used(); if (reserved != 0) { - log_info(gc, metaspace)("Metaspace: " SIZE_FORMAT "%s reserved, " SIZE_FORMAT "%s (%.2f%%) committed, " - SIZE_FORMAT "%s (%.2f%%) used", + log_info(gc, metaspace)("Metaspace: %zu%s reserved, %zu%s (%.2f%%) committed, " + "%zu%s (%.2f%%) used", byte_size_in_proper_unit(reserved), proper_unit_for_byte_size(reserved), byte_size_in_proper_unit(committed), proper_unit_for_byte_size(committed), committed * 100.0 / reserved, diff --git a/src/hotspot/share/gc/epsilon/epsilonInitLogger.cpp b/src/hotspot/share/gc/epsilon/epsilonInitLogger.cpp index bc35eddeba5c6..61564dff7a1d7 100644 --- a/src/hotspot/share/gc/epsilon/epsilonInitLogger.cpp +++ b/src/hotspot/share/gc/epsilon/epsilonInitLogger.cpp @@ -34,13 +34,13 @@ void EpsilonInitLogger::print_gc_specific() { if (UseTLAB) { size_t max_tlab = EpsilonHeap::heap()->max_tlab_size() * HeapWordSize; - log_info(gc, init)("TLAB Size Max: " SIZE_FORMAT "%s", + log_info(gc, init)("TLAB Size Max: %zu%s", byte_size_in_exact_unit(max_tlab), exact_unit_for_byte_size(max_tlab)); if (EpsilonElasticTLAB) { log_info(gc, init)("TLAB Size Elasticity: %.2fx", EpsilonTLABElasticity); } if (EpsilonElasticTLABDecay) { - log_info(gc, init)("TLAB Size Decay Time: " SIZE_FORMAT "ms", EpsilonTLABDecayTime); + log_info(gc, init)("TLAB Size Decay Time: %zums", EpsilonTLABDecayTime); } } else { log_info(gc, init)("TLAB: Disabled"); diff --git a/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp b/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp index 06aa3d5fc72b2..3371577280dce 100644 --- a/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp +++ b/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -99,7 +99,7 @@ void MutableNUMASpace::ensure_parsability() { while (words_left_to_fill > 0) { size_t words_to_fill = MIN2(words_left_to_fill, CollectedHeap::filler_array_max_size()); assert(words_to_fill >= CollectedHeap::min_fill_size(), - "Remaining size (" SIZE_FORMAT ") is too small to fill (based on " SIZE_FORMAT " and " SIZE_FORMAT ")", + "Remaining size (%zu) is too small to fill (based on %zu and %zu)", words_to_fill, words_left_to_fill, CollectedHeap::filler_array_max_size()); CollectedHeap::fill_with_object(cur_top, words_to_fill); cur_top += words_to_fill; @@ -619,8 +619,8 @@ void MutableNUMASpace::print_on(outputStream* st) const { for (int i = 0; i < lgrp_spaces()->length(); i++) { lgrp_spaces()->at(i)->accumulate_statistics(page_size()); } - st->print(" local/remote/unbiased/uncommitted: " SIZE_FORMAT "K/" - SIZE_FORMAT "K/" SIZE_FORMAT "K/" SIZE_FORMAT "K\n", + st->print(" local/remote/unbiased/uncommitted: %zuK/" + "%zuK/%zuK/%zuK\n", ls->space_stats()->_local_space / K, ls->space_stats()->_remote_space / K, ls->space_stats()->_unbiased_space / K, diff --git a/src/hotspot/share/gc/parallel/mutableSpace.cpp b/src/hotspot/share/gc/parallel/mutableSpace.cpp index 74801f4870b24..5dac82677b598 100644 --- a/src/hotspot/share/gc/parallel/mutableSpace.cpp +++ b/src/hotspot/share/gc/parallel/mutableSpace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -233,7 +233,7 @@ void MutableSpace::object_iterate(ObjectClosure* cl) { void MutableSpace::print_short() const { print_short_on(tty); } void MutableSpace::print_short_on( outputStream* st) const { - st->print(" space " SIZE_FORMAT "K, %d%% used", capacity_in_bytes() / K, + st->print(" space %zuK, %d%% used", capacity_in_bytes() / K, (int) ((double) used_in_bytes() * 100 / capacity_in_bytes())); } diff --git a/src/hotspot/share/gc/parallel/parallelInitLogger.cpp b/src/hotspot/share/gc/parallel/parallelInitLogger.cpp index 555b96e26319b..af7ecf5ac8ca4 100644 --- a/src/hotspot/share/gc/parallel/parallelInitLogger.cpp +++ b/src/hotspot/share/gc/parallel/parallelInitLogger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -29,9 +29,9 @@ void ParallelInitLogger::print_heap() { log_info_p(gc, init)("Alignments:" - " Space " SIZE_FORMAT "%s," - " Generation " SIZE_FORMAT "%s," - " Heap " SIZE_FORMAT "%s", + " Space %zu%s," + " Generation %zu%s," + " Heap %zu%s", byte_size_in_exact_unit(SpaceAlignment), exact_unit_for_byte_size(SpaceAlignment), byte_size_in_exact_unit(GenAlignment), exact_unit_for_byte_size(GenAlignment), byte_size_in_exact_unit(HeapAlignment), exact_unit_for_byte_size(HeapAlignment)); diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp index 6b1b25dd6aae3..a6e476bff6b38 100644 --- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp +++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -400,7 +400,7 @@ HeapWord* ParallelScavengeHeap::mem_allocate_work(size_t size, if ((result == nullptr) && (QueuedAllocationWarningCount > 0) && (loop_count % QueuedAllocationWarningCount == 0)) { log_warning(gc)("ParallelScavengeHeap::mem_allocate retries %d times", loop_count); - log_warning(gc)("\tsize=" SIZE_FORMAT, size); + log_warning(gc)("\tsize=%zu", size); } } diff --git a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp index 288a21fd35d05..98ffc6a103f57 100644 --- a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp +++ b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -315,12 +315,12 @@ void PSAdaptiveSizePolicy::compute_eden_space_size( if (desired_eden_size > eden_limit) { log_debug(gc, ergo)( "PSAdaptiveSizePolicy::compute_eden_space_size limits:" - " desired_eden_size: " SIZE_FORMAT - " old_eden_size: " SIZE_FORMAT - " eden_limit: " SIZE_FORMAT - " cur_eden: " SIZE_FORMAT - " max_eden_size: " SIZE_FORMAT - " avg_young_live: " SIZE_FORMAT, + " desired_eden_size: %zu" + " old_eden_size: %zu" + " eden_limit: %zu" + " cur_eden: %zu" + " max_eden_size: %zu" + " avg_young_live: %zu", desired_eden_size, _eden_size, eden_limit, cur_eden, max_eden_size, (size_t)avg_young_live()->average()); } @@ -358,14 +358,14 @@ void PSAdaptiveSizePolicy::compute_eden_space_size( _avg_major_interval->average(), gc_pause_goal_sec()); - log_debug(gc, ergo)("Live_space: " SIZE_FORMAT " free_space: " SIZE_FORMAT, + log_debug(gc, ergo)("Live_space: %zu free_space: %zu", live_space(), free_space()); - log_trace(gc, ergo)("avg_young_live: " SIZE_FORMAT " avg_old_live: " SIZE_FORMAT, + log_trace(gc, ergo)("avg_young_live: %zu avg_old_live: %zu", (size_t)avg_young_live()->average(), (size_t)avg_old_live()->average()); - log_debug(gc, ergo)("Old eden_size: " SIZE_FORMAT " desired_eden_size: " SIZE_FORMAT, + log_debug(gc, ergo)("Old eden_size: %zu desired_eden_size: %zu", _eden_size, desired_eden_size); set_eden_size(desired_eden_size); @@ -492,11 +492,11 @@ void PSAdaptiveSizePolicy::compute_old_gen_free_space( size_t free_in_old_gen = (size_t)(max_old_gen_size - avg_old_live()->average()); log_debug(gc, ergo)( "PSAdaptiveSizePolicy::compute_old_gen_free_space limits:" - " desired_promo_size: " SIZE_FORMAT - " promo_limit: " SIZE_FORMAT - " free_in_old_gen: " SIZE_FORMAT - " max_old_gen_size: " SIZE_FORMAT - " avg_old_live: " SIZE_FORMAT, + " desired_promo_size: %zu" + " promo_limit: %zu" + " free_in_old_gen: %zu" + " max_old_gen_size: %zu" + " avg_old_live: %zu", desired_promo_size, promo_limit, free_in_old_gen, max_old_gen_size, (size_t) avg_old_live()->average()); } @@ -529,14 +529,14 @@ void PSAdaptiveSizePolicy::compute_old_gen_free_space( gc_pause_goal_sec()); // Footprint stats - log_debug(gc, ergo)("Live_space: " SIZE_FORMAT " free_space: " SIZE_FORMAT, + log_debug(gc, ergo)("Live_space: %zu free_space: %zu", live_space(), free_space()); - log_trace(gc, ergo)("avg_young_live: " SIZE_FORMAT " avg_old_live: " SIZE_FORMAT, + log_trace(gc, ergo)("avg_young_live: %zu avg_old_live: %zu", (size_t)avg_young_live()->average(), (size_t)avg_old_live()->average()); - log_debug(gc, ergo)("Old promo_size: " SIZE_FORMAT " desired_promo_size: " SIZE_FORMAT, + log_debug(gc, ergo)("Old promo_size: %zu desired_promo_size: %zu", _promo_size, desired_promo_size); set_promo_size(desired_promo_size); @@ -603,7 +603,7 @@ void PSAdaptiveSizePolicy::adjust_promo_for_pause_time(size_t* desired_promo_siz log_trace(gc, ergo)( "PSAdaptiveSizePolicy::adjust_promo_for_pause_time " "adjusting gen sizes for major pause (avg %f goal %f). " - "desired_promo_size " SIZE_FORMAT " promo delta " SIZE_FORMAT, + "desired_promo_size %zu promo delta %zu", _avg_major_pause->average(), gc_pause_goal_sec(), *desired_promo_size_ptr, promo_heap_delta); } @@ -620,7 +620,7 @@ void PSAdaptiveSizePolicy::adjust_eden_for_pause_time(size_t* desired_eden_size_ log_trace(gc, ergo)( "PSAdaptiveSizePolicy::adjust_eden_for_pause_time " "adjusting gen sizes for major pause (avg %f goal %f). " - "desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT, + "desired_eden_size %zu eden delta %zu", _avg_major_pause->average(), gc_pause_goal_sec(), *desired_eden_size_ptr, eden_heap_delta); } @@ -636,7 +636,7 @@ void PSAdaptiveSizePolicy::adjust_promo_for_throughput(bool is_full_gc, return; } - log_trace(gc, ergo)("PSAdaptiveSizePolicy::adjust_promo_for_throughput(is_full: %d, promo: " SIZE_FORMAT "): mutator_cost %f major_gc_cost %f minor_gc_cost %f", + log_trace(gc, ergo)("PSAdaptiveSizePolicy::adjust_promo_for_throughput(is_full: %d, promo: %zu): mutator_cost %f major_gc_cost %f minor_gc_cost %f", is_full_gc, *desired_promo_size_ptr, mutator_cost(), major_gc_cost(), minor_gc_cost()); // Tenured generation @@ -650,7 +650,7 @@ void PSAdaptiveSizePolicy::adjust_promo_for_throughput(bool is_full_gc, double scale_by_ratio = major_gc_cost() / gc_cost(); scaled_promo_heap_delta = (size_t) (scale_by_ratio * (double) promo_heap_delta); - log_trace(gc, ergo)("Scaled tenured increment: " SIZE_FORMAT " by %f down to " SIZE_FORMAT, + log_trace(gc, ergo)("Scaled tenured increment: %zu by %f down to %zu", promo_heap_delta, scale_by_ratio, scaled_promo_heap_delta); } else if (major_gc_cost() >= 0.0) { // Scaling is not going to work. If the major gc time is the @@ -697,7 +697,7 @@ void PSAdaptiveSizePolicy::adjust_promo_for_throughput(bool is_full_gc, _old_gen_change_for_major_throughput++; } - log_trace(gc, ergo)("Adjusting tenured gen for throughput (avg %f goal %f). desired_promo_size " SIZE_FORMAT " promo_delta " SIZE_FORMAT , + log_trace(gc, ergo)("Adjusting tenured gen for throughput (avg %f goal %f). desired_promo_size %zu promo_delta %zu", mutator_cost(), _throughput_goal, *desired_promo_size_ptr, scaled_promo_heap_delta); @@ -715,7 +715,7 @@ void PSAdaptiveSizePolicy::adjust_eden_for_throughput(bool is_full_gc, return; } - log_trace(gc, ergo)("PSAdaptiveSizePolicy::adjust_eden_for_throughput(is_full: %d, cur_eden: " SIZE_FORMAT "): mutator_cost %f major_gc_cost %f minor_gc_cost %f", + log_trace(gc, ergo)("PSAdaptiveSizePolicy::adjust_eden_for_throughput(is_full: %d, cur_eden: %zu): mutator_cost %f major_gc_cost %f minor_gc_cost %f", is_full_gc, *desired_eden_size_ptr, mutator_cost(), major_gc_cost(), minor_gc_cost()); // Young generation @@ -728,7 +728,7 @@ void PSAdaptiveSizePolicy::adjust_eden_for_throughput(bool is_full_gc, assert(scale_by_ratio <= 1.0 && scale_by_ratio >= 0.0, "Scaling is wrong"); scaled_eden_heap_delta = (size_t) (scale_by_ratio * (double) eden_heap_delta); - log_trace(gc, ergo)("Scaled eden increment: " SIZE_FORMAT " by %f down to " SIZE_FORMAT, + log_trace(gc, ergo)("Scaled eden increment: %zu by %f down to %zu", eden_heap_delta, scale_by_ratio, scaled_eden_heap_delta); } else if (minor_gc_cost() >= 0.0) { // Scaling is not going to work. If the minor gc time is the @@ -774,7 +774,7 @@ void PSAdaptiveSizePolicy::adjust_eden_for_throughput(bool is_full_gc, _young_gen_change_for_minor_throughput++; } - log_trace(gc, ergo)("Adjusting eden for throughput (avg %f goal %f). desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT, + log_trace(gc, ergo)("Adjusting eden for throughput (avg %f goal %f). desired_eden_size %zu eden delta %zu", mutator_cost(), _throughput_goal, *desired_eden_size_ptr, scaled_eden_heap_delta); } @@ -791,9 +791,9 @@ size_t PSAdaptiveSizePolicy::adjust_promo_for_footprint( log_trace(gc, ergo)( "AdaptiveSizePolicy::adjust_promo_for_footprint " "adjusting tenured gen for footprint. " - "starting promo size " SIZE_FORMAT - " reduced promo size " SIZE_FORMAT - " promo delta " SIZE_FORMAT, + "starting promo size %zu" + " reduced promo size %zu" + " promo delta %zu", desired_promo_size, reduced_size, change ); assert(reduced_size <= desired_promo_size, "Inconsistent result"); @@ -813,9 +813,9 @@ size_t PSAdaptiveSizePolicy::adjust_eden_for_footprint( log_trace(gc, ergo)( "AdaptiveSizePolicy::adjust_eden_for_footprint " "adjusting eden for footprint. " - " starting eden size " SIZE_FORMAT - " reduced eden size " SIZE_FORMAT - " eden delta " SIZE_FORMAT, + " starting eden size %zu" + " reduced eden size %zu" + " eden delta %zu", desired_eden_size, reduced_size, change); assert(reduced_size <= desired_eden_size, "Inconsistent result"); @@ -966,7 +966,7 @@ uint PSAdaptiveSizePolicy::compute_survivor_space_size_and_threshold( log_debug(gc, ergo)("avg_survived_padded_avg: %f", _avg_survived->padded_average()); log_trace(gc, ergo)("avg_promoted_avg: %f avg_promoted_dev: %f", avg_promoted()->average(), avg_promoted()->deviation()); - log_debug(gc, ergo)("avg_promoted_padded_avg: %f avg_pretenured_padded_avg: %f tenuring_thresh: %d target_size: " SIZE_FORMAT, + log_debug(gc, ergo)("avg_promoted_padded_avg: %f avg_pretenured_padded_avg: %f tenuring_thresh: %d target_size: %zu", avg_promoted()->padded_average(), _avg_pretenured->padded_average(), tenuring_threshold, target_size); @@ -989,7 +989,7 @@ void PSAdaptiveSizePolicy::update_averages(bool is_survivor_overflow, } avg_promoted()->sample(promoted); - log_trace(gc, ergo)("AdaptiveSizePolicy::update_averages: survived: " SIZE_FORMAT " promoted: " SIZE_FORMAT " overflow: %s", + log_trace(gc, ergo)("AdaptiveSizePolicy::update_averages: survived: %zu promoted: %zu overflow: %s", survived, promoted, is_survivor_overflow ? "true" : "false"); } diff --git a/src/hotspot/share/gc/parallel/psClosure.inline.hpp b/src/hotspot/share/gc/parallel/psClosure.inline.hpp index 7425b65739d16..5cc059a09f50d 100644 --- a/src/hotspot/share/gc/parallel/psClosure.inline.hpp +++ b/src/hotspot/share/gc/parallel/psClosure.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -45,7 +45,7 @@ class PSAdjustWeakRootsClosure final: public OopClosure { oop new_obj = o->forwardee(); if (log_develop_is_enabled(Trace, gc, scavenge)) { ResourceMark rm; // required by internal_name() - log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (" SIZE_FORMAT ")}", + log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%zu)}", "forwarding", new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); } diff --git a/src/hotspot/share/gc/parallel/psOldGen.cpp b/src/hotspot/share/gc/parallel/psOldGen.cpp index 52ea4dc042cbb..6ab25ef635a0b 100644 --- a/src/hotspot/share/gc/parallel/psOldGen.cpp +++ b/src/hotspot/share/gc/parallel/psOldGen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -251,7 +251,7 @@ bool PSOldGen::expand_by(size_t bytes) { if (result) { size_t new_mem_size = virtual_space()->committed_size(); size_t old_mem_size = new_mem_size - bytes; - log_debug(gc)("Expanding %s from " SIZE_FORMAT "K by " SIZE_FORMAT "K to " SIZE_FORMAT "K", + log_debug(gc)("Expanding %s from %zuK by %zuK to %zuK", name(), old_mem_size/K, bytes/K, new_mem_size/K); } @@ -279,7 +279,7 @@ void PSOldGen::shrink(size_t bytes) { size_t new_mem_size = virtual_space()->committed_size(); size_t old_mem_size = new_mem_size + bytes; - log_debug(gc)("Shrinking %s from " SIZE_FORMAT "K by " SIZE_FORMAT "K to " SIZE_FORMAT "K", + log_debug(gc)("Shrinking %s from %zuK by %zuK to %zuK", name(), old_mem_size/K, bytes/K, new_mem_size/K); } } @@ -309,9 +309,9 @@ void PSOldGen::resize(size_t desired_free_space) { const size_t current_size = capacity_in_bytes(); log_trace(gc, ergo)("AdaptiveSizePolicy::old generation size: " - "desired free: " SIZE_FORMAT " used: " SIZE_FORMAT - " new size: " SIZE_FORMAT " current size " SIZE_FORMAT - " gen limits: " SIZE_FORMAT " / " SIZE_FORMAT, + "desired free: %zu used: %zu" + " new size: %zu current size %zu" + " gen limits: %zu / %zu", desired_free_space, used_in_bytes(), new_size, current_size, max_gen_size(), min_gen_size()); @@ -329,7 +329,7 @@ void PSOldGen::resize(size_t desired_free_space) { shrink(change_bytes); } - log_trace(gc, ergo)("AdaptiveSizePolicy::old generation size: collection: %d (" SIZE_FORMAT ") -> (" SIZE_FORMAT ") ", + log_trace(gc, ergo)("AdaptiveSizePolicy::old generation size: collection: %d (%zu) -> (%zu) ", ParallelScavengeHeap::heap()->total_collections(), size_before, virtual_space()->committed_size()); @@ -367,7 +367,7 @@ void PSOldGen::post_resize() { void PSOldGen::print() const { print_on(tty);} void PSOldGen::print_on(outputStream* st) const { st->print(" %-15s", name()); - st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", + st->print(" total %zuK, used %zuK", capacity_in_bytes()/K, used_in_bytes()/K); st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ")", p2i(virtual_space()->low_boundary()), diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp index 1aadcbeba3316..72fad6935388a 100644 --- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp +++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -584,16 +584,16 @@ bool PSParallelCompact::initialize_aux_data() { if (!_mark_bitmap.initialize(mr)) { vm_shutdown_during_initialization( - err_msg("Unable to allocate " SIZE_FORMAT "KB bitmaps for parallel " - "garbage collection for the requested " SIZE_FORMAT "KB heap.", + err_msg("Unable to allocate %zuKB bitmaps for parallel " + "garbage collection for the requested %zuKB heap.", _mark_bitmap.reserved_byte_size()/K, mr.byte_size()/K)); return false; } if (!_summary_data.initialize(mr)) { vm_shutdown_during_initialization( - err_msg("Unable to allocate " SIZE_FORMAT "KB card tables for parallel " - "garbage collection for the requested " SIZE_FORMAT "KB heap.", + err_msg("Unable to allocate %zuKB card tables for parallel " + "garbage collection for the requested %zuKB heap.", _summary_data.reserved_byte_size()/K, mr.byte_size()/K)); return false; } @@ -1075,7 +1075,7 @@ bool PSParallelCompact::invoke_no_policy(bool clear_all_soft_refs) { if (UseAdaptiveSizePolicy) { log_debug(gc, ergo)("AdaptiveSizeStart: collection: %d ", heap->total_collections()); - log_trace(gc, ergo)("old_gen_capacity: " SIZE_FORMAT " young_gen_capacity: " SIZE_FORMAT, + log_trace(gc, ergo)("old_gen_capacity: %zu young_gen_capacity: %zu", old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes()); // Don't check if the size_policy is ready here. Let @@ -1688,7 +1688,7 @@ class FillableRegionLogger : public StackObj { public: FillableRegionLogger() : _next_index(0), _enabled(log_develop_is_enabled(Trace, gc, compaction)), _total_regions(0) { } ~FillableRegionLogger() { - log.trace(SIZE_FORMAT " initially fillable regions", _total_regions); + log.trace("%zu initially fillable regions", _total_regions); } void print_line() { @@ -1697,7 +1697,7 @@ class FillableRegionLogger : public StackObj { } FormatBuffer<> line("Fillable: "); for (int i = 0; i < _next_index; i++) { - line.append(" " SIZE_FORMAT_W(7), _regions[i]); + line.append(" %7zu", _regions[i]); } log.trace("%s", line.buffer()); _next_index = 0; diff --git a/src/hotspot/share/gc/parallel/psScavenge.cpp b/src/hotspot/share/gc/parallel/psScavenge.cpp index 101f06b8fe0b7..8fbbc85851a77 100644 --- a/src/hotspot/share/gc/parallel/psScavenge.cpp +++ b/src/hotspot/share/gc/parallel/psScavenge.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -460,7 +460,7 @@ bool PSScavenge::invoke(bool clear_soft_refs) { // Calculate the new survivor size and tenuring threshold log_debug(gc, ergo)("AdaptiveSizeStart: collection: %d ", heap->total_collections()); - log_trace(gc, ergo)("old_gen_capacity: " SIZE_FORMAT " young_gen_capacity: " SIZE_FORMAT, + log_trace(gc, ergo)("old_gen_capacity: %zu young_gen_capacity: %zu", old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes()); if (UsePerfData) { @@ -628,7 +628,7 @@ bool PSScavenge::should_attempt_scavenge() { size_t free_in_old_gen = old_gen->max_gen_size() - old_gen->used_in_bytes(); bool result = promotion_estimate < free_in_old_gen; - log_trace(ergo)("%s scavenge: average_promoted " SIZE_FORMAT " padded_average_promoted " SIZE_FORMAT " free in old gen " SIZE_FORMAT, + log_trace(ergo)("%s scavenge: average_promoted %zu padded_average_promoted %zu free in old gen %zu", result ? "Do" : "Skip", (size_t) policy->average_promoted_in_bytes(), (size_t) policy->padded_average_promoted_in_bytes(), free_in_old_gen); diff --git a/src/hotspot/share/gc/parallel/psYoungGen.cpp b/src/hotspot/share/gc/parallel/psYoungGen.cpp index dd9619e454656..da56c9a21566f 100644 --- a/src/hotspot/share/gc/parallel/psYoungGen.cpp +++ b/src/hotspot/share/gc/parallel/psYoungGen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -256,9 +256,9 @@ void PSYoungGen::resize(size_t eden_size, size_t survivor_size) { space_invariants(); log_trace(gc, ergo)("Young generation size: " - "desired eden: " SIZE_FORMAT " survivor: " SIZE_FORMAT - " used: " SIZE_FORMAT " capacity: " SIZE_FORMAT - " gen limits: " SIZE_FORMAT " / " SIZE_FORMAT, + "desired eden: %zu survivor: %zu" + " used: %zu capacity: %zu" + " gen limits: %zu / %zu", eden_size, survivor_size, used_in_bytes(), capacity_in_bytes(), max_gen_size(), min_gen_size()); } @@ -315,15 +315,15 @@ bool PSYoungGen::resize_generation(size_t eden_size, size_t survivor_size) { } } else { if (orig_size == max_gen_size()) { - log_trace(gc)("PSYoung generation size at maximum: " SIZE_FORMAT "K", orig_size/K); + log_trace(gc)("PSYoung generation size at maximum: %zuK", orig_size/K); } else if (orig_size == min_gen_size()) { - log_trace(gc)("PSYoung generation size at minimum: " SIZE_FORMAT "K", orig_size/K); + log_trace(gc)("PSYoung generation size at minimum: %zuK", orig_size/K); } } if (size_changed) { post_resize(); - log_trace(gc)("PSYoung generation size changed: " SIZE_FORMAT "K->" SIZE_FORMAT "K", + log_trace(gc)("PSYoung generation size changed: %zuK->%zuK", orig_size/K, virtual_space()->committed_size()/K); } @@ -420,21 +420,21 @@ void PSYoungGen::resize_spaces(size_t requested_eden_size, return; } - log_trace(gc, ergo)("PSYoungGen::resize_spaces(requested_eden_size: " SIZE_FORMAT ", requested_survivor_size: " SIZE_FORMAT ")", + log_trace(gc, ergo)("PSYoungGen::resize_spaces(requested_eden_size: %zu, requested_survivor_size: %zu)", requested_eden_size, requested_survivor_size); - log_trace(gc, ergo)(" eden: [" PTR_FORMAT ".." PTR_FORMAT ") " SIZE_FORMAT, + log_trace(gc, ergo)(" eden: [" PTR_FORMAT ".." PTR_FORMAT ") %zu", p2i(eden_space()->bottom()), p2i(eden_space()->end()), pointer_delta(eden_space()->end(), eden_space()->bottom(), sizeof(char))); - log_trace(gc, ergo)(" from: [" PTR_FORMAT ".." PTR_FORMAT ") " SIZE_FORMAT, + log_trace(gc, ergo)(" from: [" PTR_FORMAT ".." PTR_FORMAT ") %zu", p2i(from_space()->bottom()), p2i(from_space()->end()), pointer_delta(from_space()->end(), from_space()->bottom(), sizeof(char))); - log_trace(gc, ergo)(" to: [" PTR_FORMAT ".." PTR_FORMAT ") " SIZE_FORMAT, + log_trace(gc, ergo)(" to: [" PTR_FORMAT ".." PTR_FORMAT ") %zu", p2i(to_space()->bottom()), p2i(to_space()->end()), pointer_delta( to_space()->end(), @@ -525,15 +525,15 @@ void PSYoungGen::resize_spaces(size_t requested_eden_size, guarantee(to_start != to_end, "to space is zero sized"); - log_trace(gc, ergo)(" [eden_start .. eden_end): [" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, + log_trace(gc, ergo)(" [eden_start .. eden_end): [" PTR_FORMAT " .. " PTR_FORMAT ") %zu", p2i(eden_start), p2i(eden_end), pointer_delta(eden_end, eden_start, sizeof(char))); - log_trace(gc, ergo)(" [from_start .. from_end): [" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, + log_trace(gc, ergo)(" [from_start .. from_end): [" PTR_FORMAT " .. " PTR_FORMAT ") %zu", p2i(from_start), p2i(from_end), pointer_delta(from_end, from_start, sizeof(char))); - log_trace(gc, ergo)(" [ to_start .. to_end): [" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, + log_trace(gc, ergo)(" [ to_start .. to_end): [" PTR_FORMAT " .. " PTR_FORMAT ") %zu", p2i(to_start), p2i(to_end), pointer_delta( to_end, to_start, sizeof(char))); @@ -575,15 +575,15 @@ void PSYoungGen::resize_spaces(size_t requested_eden_size, eden_end = MAX2(eden_end, eden_start + SpaceAlignment); to_start = MAX2(to_start, eden_end); - log_trace(gc, ergo)(" [eden_start .. eden_end): [" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, + log_trace(gc, ergo)(" [eden_start .. eden_end): [" PTR_FORMAT " .. " PTR_FORMAT ") %zu", p2i(eden_start), p2i(eden_end), pointer_delta(eden_end, eden_start, sizeof(char))); - log_trace(gc, ergo)(" [ to_start .. to_end): [" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, + log_trace(gc, ergo)(" [ to_start .. to_end): [" PTR_FORMAT " .. " PTR_FORMAT ") %zu", p2i(to_start), p2i(to_end), pointer_delta( to_end, to_start, sizeof(char))); - log_trace(gc, ergo)(" [from_start .. from_end): [" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, + log_trace(gc, ergo)(" [from_start .. from_end): [" PTR_FORMAT " .. " PTR_FORMAT ") %zu", p2i(from_start), p2i(from_end), pointer_delta(from_end, from_start, sizeof(char))); @@ -646,7 +646,7 @@ void PSYoungGen::resize_spaces(size_t requested_eden_size, assert(from_space()->top() == old_from_top, "from top changed!"); - log_trace(gc, ergo)("AdaptiveSizePolicy::survivor space sizes: collection: %d (" SIZE_FORMAT ", " SIZE_FORMAT ") -> (" SIZE_FORMAT ", " SIZE_FORMAT ") ", + log_trace(gc, ergo)("AdaptiveSizePolicy::survivor space sizes: collection: %d (%zu, %zu) -> (%zu, %zu) ", ParallelScavengeHeap::heap()->total_collections(), old_from, old_to, from_space()->capacity_in_bytes(), @@ -702,7 +702,7 @@ void PSYoungGen::object_iterate(ObjectClosure* blk) { void PSYoungGen::print() const { print_on(tty); } void PSYoungGen::print_on(outputStream* st) const { st->print(" %-15s", "PSYoungGen"); - st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", + st->print(" total %zuK, used %zuK", capacity_in_bytes()/K, used_in_bytes()/K); virtual_space()->print_space_boundaries_on(st); st->print(" eden"); eden_space()->print_on(st); diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp index f78a766c4c3b8..c77aa6f692abe 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.cpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -480,11 +480,11 @@ void DefNewGeneration::compute_new_size() { gch->rem_set()->resize_covered_region(cmr); log_debug(gc, ergo, heap)( - "New generation size " SIZE_FORMAT "K->" SIZE_FORMAT "K [eden=" SIZE_FORMAT "K,survivor=" SIZE_FORMAT "K]", + "New generation size %zuK->%zuK [eden=%zuK,survivor=%zuK]", new_size_before/K, _virtual_space.committed_size()/K, eden()->capacity()/K, from()->capacity()/K); log_trace(gc, ergo, heap)( - " [allowed " SIZE_FORMAT "K extra for %d threads]", + " [allowed %zuK extra for %d threads]", thread_increase_size/K, threads_count); } } @@ -715,7 +715,7 @@ void DefNewGeneration::remove_forwarding_pointers() { } void DefNewGeneration::handle_promotion_failure(oop old) { - log_debug(gc, promotion)("Promotion failure size = " SIZE_FORMAT ") ", old->size()); + log_debug(gc, promotion)("Promotion failure size = %zu) ", old->size()); _promotion_failed = true; _promotion_failed_info.register_copy_failure(old->size()); @@ -840,7 +840,7 @@ void DefNewGeneration::verify() { void DefNewGeneration::print_on(outputStream* st) const { st->print(" %-10s", name()); - st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", + st->print(" total %zuK, used %zuK", capacity()/K, used()/K); st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ")", p2i(_virtual_space.low_boundary()), diff --git a/src/hotspot/share/gc/serial/serialFullGC.cpp b/src/hotspot/share/gc/serial/serialFullGC.cpp index 0df28fa7bd5d2..d7ccb5b626a79 100644 --- a/src/hotspot/share/gc/serial/serialFullGC.cpp +++ b/src/hotspot/share/gc/serial/serialFullGC.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 @@ -133,7 +133,7 @@ class DeadSpacer : StackObj { // obj->set_mark(obj->mark().set_marked()); assert(dead_length == obj->size(), "bad filler object size"); - log_develop_trace(gc, compaction)("Inserting object to dead space: " PTR_FORMAT ", " PTR_FORMAT ", " SIZE_FORMAT "b", + log_develop_trace(gc, compaction)("Inserting object to dead space: " PTR_FORMAT ", " PTR_FORMAT ", %zub", p2i(dead_start), p2i(dead_end), dead_length * HeapWordSize); return true; @@ -651,7 +651,7 @@ void SerialFullGC::adjust_marks() { } void SerialFullGC::restore_marks() { - log_trace(gc)("Restoring " SIZE_FORMAT " marks", _preserved_count + _preserved_overflow_stack_set.get()->size()); + log_trace(gc)("Restoring %zu marks", _preserved_count + _preserved_overflow_stack_set.get()->size()); // restore the marks we saved earlier for (size_t i = 0; i < _preserved_count; i++) { diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp index 23f1df6fc66db..9efa207ca97d1 100644 --- a/src/hotspot/share/gc/serial/serialHeap.cpp +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -219,8 +219,7 @@ ReservedHeapSpace SerialHeap::allocate(size_t alignment) { "the maximum representable size"); } assert(total_reserved % alignment == 0, - "Gen size; total_reserved=" SIZE_FORMAT ", alignment=" - SIZE_FORMAT, total_reserved, alignment); + "Gen size; total_reserved=%zu, alignment=%zu", total_reserved, alignment); ReservedHeapSpace heap_rs = Universe::reserve_heap(total_reserved, alignment); size_t used_page_size = heap_rs.page_size(); @@ -400,7 +399,7 @@ HeapWord* SerialHeap::mem_allocate_work(size_t size, if ((QueuedAllocationWarningCount > 0) && (try_count % QueuedAllocationWarningCount == 0)) { log_warning(gc, ergo)("SerialHeap::mem_allocate_work retries %d times," - " size=" SIZE_FORMAT " %s", try_count, size, is_tlab ? "(TLAB)" : ""); + " size=%zu %s", try_count, size, is_tlab ? "(TLAB)" : ""); } } } diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.cpp b/src/hotspot/share/gc/serial/tenuredGeneration.cpp index 2b7711e9b0a9e..56bf8925042d1 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.cpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -69,7 +69,7 @@ bool TenuredGeneration::grow_by(size_t bytes) { size_t new_mem_size = _virtual_space.committed_size(); size_t old_mem_size = new_mem_size - bytes; - log_trace(gc, heap)("Expanding %s from " SIZE_FORMAT "K by " SIZE_FORMAT "K to " SIZE_FORMAT "K", + log_trace(gc, heap)("Expanding %s from %zuK by %zuK to %zuK", name(), old_mem_size/K, bytes/K, new_mem_size/K); } return result; @@ -140,7 +140,7 @@ void TenuredGeneration::shrink(size_t bytes) { size_t new_mem_size = _virtual_space.committed_size(); size_t old_mem_size = new_mem_size + size; - log_trace(gc, heap)("Shrinking %s from " SIZE_FORMAT "K to " SIZE_FORMAT "K", + log_trace(gc, heap)("Shrinking %s from %zuK to %zuK", name(), old_mem_size/K, new_mem_size/K); } @@ -236,7 +236,7 @@ void TenuredGeneration::compute_new_size_inner() { assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size"); log_trace(gc, heap)(" shrinking: initSize: %.1fK maximum_desired_capacity: %.1fK", OldSize / (double) K, maximum_desired_capacity / (double) K); - log_trace(gc, heap)(" shrink_bytes: %.1fK current_shrink_factor: " SIZE_FORMAT " new shrink factor: " SIZE_FORMAT " _min_heap_delta_bytes: %.1fK", + log_trace(gc, heap)(" shrink_bytes: %.1fK current_shrink_factor: %zu new shrink factor: %zu _min_heap_delta_bytes: %.1fK", shrink_bytes / (double) K, current_shrink_factor, _shrink_factor, @@ -354,8 +354,8 @@ void TenuredGeneration::compute_new_size() { compute_new_size_inner(); assert(used() == used_after_gc && used_after_gc <= capacity(), - "used: " SIZE_FORMAT " used_after_gc: " SIZE_FORMAT - " capacity: " SIZE_FORMAT, used(), used_after_gc, capacity()); + "used: %zu used_after_gc: %zu" + " capacity: %zu", used(), used_after_gc, capacity()); } void TenuredGeneration::update_promote_stats() { @@ -384,7 +384,7 @@ bool TenuredGeneration::promotion_attempt_is_safe(size_t max_promotion_in_bytes) bool res = (promotion_estimate <= available); - log_trace(gc)("Tenured: promo attempt is%s safe: available(" SIZE_FORMAT ") %s av_promo(" SIZE_FORMAT "), max_promo(" SIZE_FORMAT ")", + log_trace(gc)("Tenured: promo attempt is%s safe: available(%zu) %s av_promo(%zu), max_promo(%zu)", res? "":" not", available, res? ">=":"<", avg_promoted, max_promotion_in_bytes); return res; @@ -445,7 +445,7 @@ void TenuredGeneration::verify() { void TenuredGeneration::print_on(outputStream* st) const { st->print(" %-10s", name()); - st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", + st->print(" total %zuK, used %zuK", capacity()/K, used()/K); st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ")", p2i(_virtual_space.low_boundary()), From 7df21a8f09ab606f38a44d84d841d4bba9f09adf Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Wed, 15 Jan 2025 12:40:38 +0000 Subject: [PATCH 05/47] 8347597: HttpClient: improve exception reporting when closing connection Reviewed-by: jpai --- .../internal/net/http/AsyncSSLConnection.java | 4 +- .../net/http/AsyncSSLTunnelConnection.java | 4 +- .../jdk/internal/net/http/Exchange.java | 75 +++++++++++-------- .../internal/net/http/Http1AsyncReceiver.java | 14 ++-- .../jdk/internal/net/http/Http1Exchange.java | 34 ++++----- .../jdk/internal/net/http/Http1Response.java | 10 +-- .../internal/net/http/Http2Connection.java | 13 ++-- .../net/http/PlainHttpConnection.java | 40 +++++++--- .../classes/jdk/internal/net/http/Stream.java | 7 +- .../jdk/internal/net/http/common/SSLTube.java | 19 +++-- .../jdk/internal/net/http/common/Utils.java | 28 +++++++ .../AbstractThrowingPublishers.java | 18 ++--- .../httpclient/FlowAdapterPublisherTest.java | 10 ++- .../net/httpclient/RedirectMethodChange.java | 14 ++-- .../java/net/httpclient/ShortRequestBody.java | 30 +++++--- .../http2/ExpectContinueResetTest.java | 23 ++++-- 16 files changed, 217 insertions(+), 126 deletions(-) diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLConnection.java b/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLConnection.java index 875923029cfda..598af68e37a72 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLConnection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, 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 @@ -72,7 +72,7 @@ public CompletableFuture finishConnect() { if (ex == null) { return plainConnection.finishConnect(); } else { - plainConnection.close(); + plainConnection.close(ex); return MinimalFuture.failedFuture(ex); } }) .thenCompose(Function.identity()); diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLTunnelConnection.java b/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLTunnelConnection.java index dc9e1bfb795b8..862013cbf938b 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLTunnelConnection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLTunnelConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, 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 @@ -81,7 +81,7 @@ public CompletableFuture finishConnect() { if (ex == null) { return plainConnection.finishConnect(); } else { - plainConnection.close(); + plainConnection.close(ex); return MinimalFuture.failedFuture(ex); } }) .thenCompose(Function.identity()); diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Exchange.java b/src/java.net.http/share/classes/jdk/internal/net/http/Exchange.java index 71e4e05d2c56f..1ee54ed2bef25 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/Exchange.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Exchange.java @@ -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 @@ -33,11 +33,13 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; import java.net.http.HttpClient; import java.net.http.HttpResponse; import java.net.http.HttpTimeoutException; +import jdk.internal.net.http.HttpClientImpl.DelegatingExecutor; import jdk.internal.net.http.common.Logger; import jdk.internal.net.http.common.MinimalFuture; import jdk.internal.net.http.common.Utils; @@ -63,9 +65,9 @@ final class Exchange { // used to record possible cancellation raised before the exchImpl // has been established. - private volatile IOException failed; + private final AtomicReference failed = new AtomicReference<>(); final MultiExchange multi; - final Executor parentExecutor; + final DelegatingExecutor parentExecutor; volatile boolean upgrading; // to HTTP/2 volatile boolean upgraded; // to HTTP/2 final PushGroup pushGroup; @@ -91,7 +93,7 @@ PushGroup getPushGroup() { return pushGroup; } - Executor executor() { + DelegatingExecutor executor() { return parentExecutor; } @@ -236,26 +238,26 @@ public void cancel(IOException cause) { // If the impl is non null, propagate the exception right away. // Otherwise record it so that it can be propagated once the // exchange impl has been established. - ExchangeImpl impl = exchImpl; + ExchangeImpl impl; + IOException closeReason = null; + synchronized (this) { + impl = exchImpl; + if (impl == null) { + // no impl yet. record the exception + failed.compareAndSet(null, cause); + } + } if (impl != null) { // propagate the exception to the impl if (debug.on()) debug.log("Cancelling exchImpl: %s", exchImpl); impl.cancel(cause); } else { - // no impl yet. record the exception - IOException failed = this.failed; - if (failed == null) { - synchronized (this) { - failed = this.failed; - if (failed == null) { - failed = this.failed = cause; - } - } - } - - // abort/close the connection if setting up the exchange. This can + // abort/close the connection if setting up the exchange. This can // be important when setting up HTTP/2 - connectionAborter.closeConnection(failed); + closeReason = failed.get(); + if (closeReason != null) { + connectionAborter.closeConnection(closeReason); + } // now call checkCancelled to recheck the impl. // if the failed state is set and the impl is not null, reset @@ -274,9 +276,9 @@ private void checkCancelled() { ExchangeImpl impl = null; IOException cause = null; CompletableFuture> cf = null; - if (failed != null) { + if (failed.get() != null) { synchronized (this) { - cause = failed; + cause = failed.get(); impl = exchImpl; cf = exchangeCF; } @@ -286,7 +288,11 @@ private void checkCancelled() { // The exception is raised by propagating it to the impl. if (debug.on()) debug.log("Cancelling exchImpl: %s", impl); impl.cancel(cause); - failed = null; + synchronized (this) { + if (impl == exchImpl) { + failed.compareAndSet(cause, null); + } + } } else { Log.logTrace("Exchange: request [{0}/timeout={1}ms] no impl is set." + "\n\tCan''t cancel yet with {2}", @@ -313,7 +319,7 @@ CompletableFuture checkCancelled(CompletableFuture cf, HttpConnection if (t == null) t = new IOException("Request cancelled"); if (debug.on()) debug.log("exchange cancelled during connect: " + t); try { - connection.close(); + connection.close(t); } catch (Throwable x) { if (debug.on()) debug.log("Failed to close connection", x); } @@ -330,8 +336,13 @@ public void h2Upgrade() { request.setH2Upgrade(this); } + synchronized IOException failed(IOException io) { + IOException cause = failed.compareAndExchange(null, io); + return cause == null ? io : cause; + } + synchronized IOException getCancelCause() { - return failed; + return failed.get(); } // get/set the exchange impl, solving race condition issues with @@ -409,6 +420,11 @@ private CompletableFuture checkFor407(ExchangeImpl ex, Throwable t, } } + private CompletableFuture startSendingBody(DelegatingExecutor executor) { + return exchImpl.sendBodyAsync() + .thenCompose(exIm -> exIm.getResponseAsync(executor)); + } + // After sending the request headers, if no ProxyAuthorizationRequired // was raised and the expectContinue flag is on, we need to wait // for the 100-Continue response @@ -430,9 +446,7 @@ private CompletableFuture expectContinue(ExchangeImpl ex) { if (debug.on()) debug.log("Setting ExpectTimeoutRaised and sending request body"); exchImpl.setExpectTimeoutRaised(); - CompletableFuture cf = - exchImpl.sendBodyAsync() - .thenCompose(exIm -> exIm.getResponseAsync(parentExecutor)); + CompletableFuture cf = startSendingBody(parentExecutor); cf = wrapForUpgrade(cf); cf = wrapForLog(cf); return cf; @@ -444,9 +458,7 @@ private CompletableFuture expectContinue(ExchangeImpl ex) { nonFinalResponses.incrementAndGet(); Log.logTrace("Received 100-Continue: sending body"); if (debug.on()) debug.log("Received 100-Continue for %s", r1); - CompletableFuture cf = - exchImpl.sendBodyAsync() - .thenCompose(exIm -> exIm.getResponseAsync(parentExecutor)); + CompletableFuture cf = startSendingBody(parentExecutor); cf = wrapForUpgrade(cf); cf = wrapForLog(cf); return cf; @@ -471,8 +483,7 @@ private CompletableFuture expectContinue(ExchangeImpl ex) { private CompletableFuture sendRequestBody(ExchangeImpl ex) { assert !request.expectContinue(); if (debug.on()) debug.log("sendRequestBody"); - CompletableFuture cf = ex.sendBodyAsync() - .thenCompose(exIm -> exIm.getResponseAsync(parentExecutor)); + CompletableFuture cf = startSendingBody(parentExecutor); cf = wrapForUpgrade(cf); // after 101 is handled we check for other 1xx responses cf = cf.thenCompose(this::ignore1xxResponse); @@ -669,7 +680,7 @@ HttpResponse.BodySubscriber ignoreBody(HttpResponse.ResponseInfo hdrs) { // Either way, we need to relay it to s. synchronized (this) { exchImpl = s; - t = failed; + t = failed.get(); } // Check whether the HTTP/1.1 was cancelled. if (t == null) t = e.getCancelCause(); diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http1AsyncReceiver.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http1AsyncReceiver.java index 1e3861b7ff1a6..3bc4608b41aad 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/Http1AsyncReceiver.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http1AsyncReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -259,8 +259,10 @@ private void flush() { checkRequestMore(); } catch (Throwable t) { - Throwable x = error; - if (x == null) error = t; // will be handled in the finally block + synchronized (this) { + Throwable x = error; + if (x == null) error = t; // will be handled in the finally block + } if (debug.on()) debug.log("Unexpected error caught in flush()", t); } finally { // Handles any pending error. @@ -312,7 +314,7 @@ private void checkForErrors() { // close the upstream connection. Http1Exchange exchg = owner; stop(); - if (exchg != null) exchg.connection().close(); + if (exchg != null) exchg.connection().close(x); } } } @@ -346,7 +348,7 @@ private boolean hasDemand(Http1AsyncDelegate delegate) { AbstractSubscription subscription = delegate.subscription(); long demand = subscription.demand().get(); if (debug.on()) - debug.log("downstream subscription demand is %s", demand); + debug.log("downstream subscription demand is %s for %s", demand, delegate); return demand > 0; } @@ -573,7 +575,7 @@ void requestMore() { if (canRequestMore.compareAndSet(true, false)) { if (!completed && !dropped) { if (debug.on()) - debug.log("Http1TubeSubscriber: requesting one more from upstream"); + debug.log("Http1TubeSubscriber: requesting one more from upstream: " + s); s.request(1); return; } diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java index 11ab5dd7d5449..ecc4a63c9d085 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, 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 @@ -42,6 +42,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.ReentrantLock; +import jdk.internal.net.http.HttpClientImpl.DelegatingExecutor; import jdk.internal.net.http.common.Demand; import jdk.internal.net.http.common.HttpBodySubscriberWrapper; import jdk.internal.net.http.common.Log; @@ -63,14 +64,15 @@ class Http1Exchange extends ExchangeImpl { private volatile Http1Response response; final HttpConnection connection; final HttpClientImpl client; - final Executor executor; + final DelegatingExecutor executor; private final Http1AsyncReceiver asyncReceiver; private volatile boolean upgraded; /** Records a possible cancellation raised before any operation * has been initiated, or an error received while sending the request. */ private final AtomicReference failedRef = new AtomicReference<>(); - private final List> operations; // used for cancel + private final ConcurrentLinkedDeque> operations = + new ConcurrentLinkedDeque<>(); // used for cancel /** Must be held when operating on any internal state or data. */ private final ReentrantLock lock = new ReentrantLock(); @@ -236,7 +238,6 @@ HttpRequestImpl request() { this.request = exchange.request(); this.client = exchange.client(); this.executor = exchange.executor(); - this.operations = new LinkedList<>(); operations.add(headersSentCF); operations.add(bodySentCF); if (connection != null) { @@ -256,7 +257,7 @@ HttpConnection connection() { private void connectFlows(HttpConnection connection) { FlowTube tube = connection.getConnectionFlow(); - if (debug.on()) debug.log("%s connecting flows", tube); + if (debug.on()) debug.log("%s connecting flows %s", tube, writePublisher); // Connect the flow to our Http1TubeSubscriber: // asyncReceiver.subscriber(). @@ -359,7 +360,7 @@ CompletableFuture> sendHeadersAsync() { if (debug.on()) debug.log("Failed to send headers: %s", t); headersSentCF.completeExceptionally(t); bodySentCF.completeExceptionally(t); - connection.close(); + connection.close(t); cf.completeExceptionally(t); return cf; } }) @@ -418,7 +419,7 @@ CompletableFuture getResponseAsync(Executor executor) { lock.lock(); try { operations.add(cf); - cause = failedRef.compareAndExchange(failedRef.get(), null); + cause = failedRef.get(); } finally { lock.unlock(); } @@ -526,7 +527,7 @@ void onProtocolError(final IOException cause) { private void cancelImpl(Throwable cause) { LinkedList> toComplete = null; int count = 0; - Throwable error = null; + Throwable error; BodySubscriber subscriber; lock.lock(); try { @@ -598,7 +599,7 @@ private void cancelImpl(Throwable cause) { } } finally { if (!upgraded) - connection.close(); + connection.close(error); } } @@ -655,10 +656,9 @@ private void requestMoreBody() { } private void cancelUpstreamSubscription() { - final Executor exec = client.theExecutor(); if (debug.on()) debug.log("cancelling upstream publisher"); if (bodySubscriber != null) { - exec.execute(bodySubscriber::cancelSubscription); + executor.execute(bodySubscriber::cancelSubscription); } else if (debug.on()) { debug.log("bodySubscriber is null"); } @@ -668,7 +668,7 @@ private void cancelUpstreamSubscription() { // ALL tasks should execute off the Selector-Manager thread /** Returns the next portion of the HTTP request, or the error. */ private DataPair getOutgoing() { - final Executor exec = client.theExecutor(); + final Executor exec = executor; final DataPair dp = outgoing.pollFirst(); if (writePublisher.cancelled) { @@ -686,7 +686,7 @@ private DataPair getOutgoing() { exec.execute(() -> { headersSentCF.completeExceptionally(dp.throwable); bodySentCF.completeExceptionally(dp.throwable); - connection.close(); + connection.close(dp.throwable); }); return dp; } @@ -799,7 +799,7 @@ final class WriteTask implements Runnable { @Override public void run() { assert state != State.COMPLETED : "Unexpected state:" + state; - if (debug.on()) debug.log("WriteTask"); + if (debug.on()) debug.log("WriteTask for " + request); if (cancelled) { if (debug.on()) debug.log("handling cancellation"); @@ -859,16 +859,16 @@ public void request(long n) { demand.increase(n); if (debug.on()) debug.log("subscription request(%d), demand=%s", n, demand); - writeScheduler.runOrSchedule(client.theExecutor()); + writeScheduler.runOrSchedule(executor); } @Override public void cancel() { - if (debug.on()) debug.log("subscription cancelled"); + if (debug.on()) debug.log("subscription cancelled for " + request); if (cancelled) return; //no-op cancelled = true; - writeScheduler.runOrSchedule(client.theExecutor()); + writeScheduler.runOrSchedule(executor); } } } diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http1Response.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http1Response.java index 6d4e9f7ac2832..d7222067f7ee8 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/Http1Response.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http1Response.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, 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 @@ -285,7 +285,7 @@ public CompletableFuture ignoreBody(Executor executor) { // Used for those response codes that have no body associated public void nullBody(HttpResponse resp, Throwable t) { - if (t != null) connection.close(); + if (t != null) connection.close(t); else { return2Cache = !request.isWebSocket(); onFinished(); @@ -331,7 +331,7 @@ public CompletableFuture readBody(HttpResponse.BodySubscriber p, ); if (cf.isCompletedExceptionally()) { // if an error occurs during subscription - connection.close(); + connection.close(Utils.exceptionNow(cf)); return; } // increment the reference count on the HttpClientImpl @@ -352,7 +352,7 @@ public CompletableFuture readBody(HttpResponse.BodySubscriber p, } finally { bodyReader.onComplete(t); if (t != null) { - connection.close(); + connection.close(t); } } }); @@ -471,7 +471,7 @@ void onReadError(Throwable t) { debug.log(Level.DEBUG, "onReadError", t); } debug.log(Level.DEBUG, () -> "closing connection: cause is " + t); - connection.close(); + connection.close(t); } // ======================================================================== diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java index 2e6b42049840e..9d3517ddde43b 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java @@ -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 @@ -691,7 +691,7 @@ private static CompletableFuture checkSSLConfig(AbstractAsyncSSLConnection ac if (t != null && t instanceof SSLException) { // something went wrong during the initial handshake // close the connection - aconn.close(); + aconn.close(t); } }) .thenCompose(checkAlpnCF); @@ -910,7 +910,7 @@ void shutdown(Throwable t) { Log.logError("Failed to close stream {0}: {1}", s.streamid, e); } } - connection.close(); + connection.close(cause.get()); } /** @@ -971,7 +971,8 @@ void processFrame(Http2Frame frame) throws IOException { protocolError(ResetFrame.PROTOCOL_ERROR, protocolError); return; } - if (stream == null && pushContinuationState == null) { + PushContinuationState pcs = pushContinuationState; + if (stream == null && pcs == null) { // Should never receive a frame with unknown stream id if (frame instanceof HeaderFrame hf) { @@ -1016,7 +1017,6 @@ void processFrame(Http2Frame frame) throws IOException { // While push frame is not null, the only acceptable frame on this // stream is a Continuation frame - PushContinuationState pcs = pushContinuationState; if (pcs != null) { if (frame instanceof ContinuationFrame cf) { if (stream == null) { @@ -1960,7 +1960,8 @@ protected boolean windowSizeExceeded(long received) { if (connection.isOpen()) { try { connection.protocolError(ErrorFrame.FLOW_CONTROL_ERROR, - "connection window exceeded"); + "connection window exceeded (%s > %s)" + .formatted(received, windowSize)); } catch (IOException io) { connection.shutdown(io); } diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java b/src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java index 747945701f8d8..76fbebe6cd01d 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java @@ -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 @@ -34,6 +34,7 @@ import java.nio.channels.SocketChannel; import java.time.Duration; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Function; @@ -58,6 +59,7 @@ class PlainHttpConnection extends HttpConnection { private volatile ConnectTimerEvent connectTimerEvent; // may be null private volatile int unsuccessfulAttempts; private final ReentrantLock stateLock = new ReentrantLock(); + private final AtomicReference errorRef = new AtomicReference<>(); // Indicates whether a connection attempt has succeeded or should be retried. // If the attempt failed, and shouldn't be retried, there will be an exception @@ -107,6 +109,11 @@ public String toString() { } } + Throwable getError(Throwable cause) { + if (errorRef.compareAndSet(null, cause)) return cause; + return errorRef.get(); + } + final class ConnectEvent extends AsyncEvent { private final CompletableFuture cf; private final Exchange exchange; @@ -149,18 +156,19 @@ public void handle() { cf.completeAsync(() -> ConnectState.RETRY, client().theExecutor()); return; } - Throwable t = Utils.toConnectException(e); + Throwable t = getError(Utils.toConnectException(e)); // complete async since the event runs on the SelectorManager thread client().theExecutor().execute( () -> cf.completeExceptionally(t)); - close(); + close(t); } } @Override public void abort(IOException ioe) { + Throwable cause = getError(ioe); // complete async since the event runs on the SelectorManager thread - client().theExecutor().execute( () -> cf.completeExceptionally(ioe)); - close(); + client().theExecutor().execute( () -> cf.completeExceptionally(cause)); + close(cause); } } @@ -205,25 +213,26 @@ public CompletableFuture connectAsync(Exchange exchange) { if (debug.on()) debug.log("connect finished without blocking"); if (connectionOpened()) { cf.complete(ConnectState.SUCCESS); - } else throw new ConnectException("connection closed"); + } else throw getError(new ConnectException("connection closed")); } else { if (debug.on()) debug.log("registering connect event"); client().registerEvent(new ConnectEvent(cf, exchange)); } cf = exchange.checkCancelled(cf, this); } catch (Throwable throwable) { - cf.completeExceptionally(Utils.toConnectException(throwable)); + var cause = getError(Utils.toConnectException(throwable)); + cf.completeExceptionally(cause); try { if (Log.channel()) { Log.logChannel("Closing connection: connect failed due to: " + throwable); } - close(); + close(cause); } catch (Exception x) { if (debug.on()) debug.log("Failed to close channel after unsuccessful connect"); } } - return cf.handle((r,t) -> checkRetryConnect(r, t,exchange)) + return cf.handle((r,t) -> checkRetryConnect(r, t, exchange)) .thenCompose(Function.identity()); } @@ -402,9 +411,16 @@ void close(Throwable cause) { try { if (closed = this.closed) return; closed = this.closed = true; + Throwable reason = getError(cause); Log.logTrace("Closing: " + toString()); - if (debug.on()) - debug.log("Closing channel: " + client().debugInterestOps(chan)); + if (debug.on()) { + String interestOps = client().debugInterestOps(chan); + if (reason == null) { + debug.log("Closing channel: " + interestOps); + } else { + debug.log("Closing channel: %s due to %s", interestOps, reason); + } + } var connectTimerEvent = this.connectTimerEvent; if (connectTimerEvent != null) client().cancelTimer(connectTimerEvent); @@ -412,8 +428,8 @@ void close(Throwable cause) { Log.logChannel("Closing channel: " + chan); } try { + tube.signalClosed(errorRef.get()); chan.close(); - tube.signalClosed(cause); } finally { client().connectionClosed(this); } diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java b/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java index f3eedf8fe6e78..042d6c0ebfeab 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java @@ -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 @@ -725,7 +725,10 @@ void incompleteRequestBodyReset(ResetFrame frame, Flow.Subscriber subscriber) debug.log("completing requestBodyCF exceptionally due to received" + " RESET(%s) (stream=%s)", frame.getErrorCode(), streamid); } - requestBodyCF.completeExceptionally(new IOException("RST_STREAM received")); + var exception = new IOException("RST_STREAM received " + + ResetFrame.stringForCode(frame.getErrorCode())); + requestBodyCF.completeExceptionally(exception); + cancelImpl(exception, frame.getErrorCode()); } else { if (debug.on()) { debug.log("completing requestBodyCF normally due to received" + diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/common/SSLTube.java b/src/java.net.http/share/classes/jdk/internal/net/http/common/SSLTube.java index 1d7d856e8a5a0..c35a6f62a1b18 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/common/SSLTube.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/common/SSLTube.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -76,6 +76,8 @@ public class SSLTube implements FlowTube { private final SSLFlowDelegate sslDelegate; private final SSLEngine engine; private volatile boolean finished; + private final AtomicReference errorRef + = new AtomicReference<>(); public SSLTube(SSLEngine engine, Executor executor, FlowTube tube) { this(engine, executor, null, tube); @@ -157,6 +159,13 @@ protected Throwable checkForHandshake(Throwable t) { } } + private Throwable error(Throwable error) { + if (errorRef.compareAndSet(null, error)) { + return error; + } + return errorRef.get(); + } + public CompletableFuture getALPN() { return sslDelegate.alpn(); } @@ -297,8 +306,6 @@ final class SSLSubscriberWrapper implements FlowTube.TubeSubscriber { new AtomicReference<>(); private volatile DelegateWrapper subscribed; private volatile boolean onCompleteReceived; - private final AtomicReference errorRef - = new AtomicReference<>(); @Override public String toString() { @@ -335,7 +342,7 @@ void setDelegate(Flow.Subscriber> delegate) { synchronized (this) { previous = pendingDelegate.getAndSet(delegateWrapper); subscription = readSubscription; - handleNow = this.errorRef.get() != null || onCompleteReceived; + handleNow = errorRef.get() != null || onCompleteReceived; } if (previous != null) { previous.dropSubscription(); @@ -468,7 +475,7 @@ private void onNewSubscription(DelegateWrapper subscriberImpl, // onError before onSubscribe. It also prevents race conditions // if onError is invoked concurrently with setDelegate. synchronized (this) { - failed = this.errorRef.get(); + failed = errorRef.get(); completed = onCompleteReceived; subscribed = subscriberImpl; } @@ -665,7 +672,7 @@ public void onNext(List item) { @Override public void onError(Throwable throwable) { Objects.requireNonNull(throwable); - sslDelegate.upstreamWriter().onError(throwable); + sslDelegate.upstreamWriter().onError(error(throwable)); } @Override diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java b/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java index 511b17d7813cb..d035a8c8da1cf 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java @@ -57,6 +57,7 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; +import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.concurrent.ConcurrentHashMap; @@ -1133,4 +1134,31 @@ public static String encode(String s) { } return sb.toString(); } + + /** + * {@return the exception the given {@code cf} was completed with, + * or a {@link CancellationException} if the given {@code cf} was + * cancelled} + * + * @param cf a {@code CompletableFuture} exceptionally completed + * @throws IllegalArgumentException if the given cf was not + * {@linkplain CompletableFuture#isCompletedExceptionally() + * completed exceptionally} + */ + public static Throwable exceptionNow(CompletableFuture cf) { + if (cf.isCompletedExceptionally()) { + if (cf.isCancelled()) { + try { + cf.join(); + } catch (CancellationException x) { + return x; + } catch (CompletionException x) { + return x.getCause(); + } + } else { + return cf.exceptionNow(); + } + } + throw new IllegalArgumentException("cf is not completed exceptionally"); + } } diff --git a/test/jdk/java/net/httpclient/AbstractThrowingPublishers.java b/test/jdk/java/net/httpclient/AbstractThrowingPublishers.java index 4079bd81e3e19..859169dcaae83 100644 --- a/test/jdk/java/net/httpclient/AbstractThrowingPublishers.java +++ b/test/jdk/java/net/httpclient/AbstractThrowingPublishers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -21,9 +21,6 @@ * questions. */ -import com.sun.net.httpserver.HttpServer; -import com.sun.net.httpserver.HttpsConfigurator; -import com.sun.net.httpserver.HttpsServer; import jdk.test.lib.net.SimpleSSLContext; import org.testng.ITestContext; import org.testng.ITestResult; @@ -40,8 +37,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.UncheckedIOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; @@ -73,7 +68,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import jdk.httpclient.test.lib.common.HttpServerAdapters; -import jdk.httpclient.test.lib.http2.Http2TestServer; import static java.lang.String.format; import static java.lang.System.out; @@ -479,10 +473,12 @@ private void testThrowing(String uri, boolean sameClient, // synchronous send will rethrow exceptions Throwable throwable = t.getCause(); assert throwable != null; - - if (thrower.test(where, throwable)) { - System.out.println(now() + "Got expected exception: " + throwable); - } else throw causeNotFound(where, t); + Throwable cause = findCause(where, throwable, thrower); + if (cause == null) { + throw causeNotFound(where, t); + } else { + System.out.println(now() + "Got expected exception: " + cause); + } } } if (response != null) { diff --git a/test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java b/test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java index 3676eb7236be3..5d0935d721631 100644 --- a/test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java +++ b/test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -233,8 +233,12 @@ void testPublishTooMany(String uri) throws InterruptedException { } private void assertMessage(Throwable t, String contains) { - if (!t.getMessage().contains(contains)) { - String error = "Exception message:[" + t.toString() + "] doesn't contain [" + contains + "]"; + Throwable cause = t; + do { + if (cause.getMessage().contains(contains)) break; + } while ((cause = cause.getCause()) != null); + if (cause == null) { + String error = "Exception message:[" + t + "] doesn't contain [" + contains + "]"; throw new AssertionError(error, t); } } diff --git a/test/jdk/java/net/httpclient/RedirectMethodChange.java b/test/jdk/java/net/httpclient/RedirectMethodChange.java index 7e5971c40022e..ed1afb384e10b 100644 --- a/test/jdk/java/net/httpclient/RedirectMethodChange.java +++ b/test/jdk/java/net/httpclient/RedirectMethodChange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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,6 +220,7 @@ public void setup() throws Exception { @AfterTest public void teardown() throws Exception { + client.close(); httpTestServer.stop(); httpsTestServer.stop(); http2TestServer.stop(); @@ -240,8 +241,8 @@ public void teardown() throws Exception { */ static class RedirMethodChgeHandler implements HttpTestHandler { - boolean inTest; - String expectedMethod; + volatile boolean inTest; + volatile String expectedMethod; final String targetURL; RedirMethodChgeHandler(String targetURL) { @@ -272,11 +273,14 @@ public synchronized void handle(HttpTestExchange he) throws IOException { Throwable ex = new RuntimeException("Unexpected newtest:" + newtest + ", inTest:" + inTest + ", for " + he.getRequestURI()); ex.printStackTrace(); + inTest = false; // next request should be new test he.sendResponseHeaders(500, 0); return; } if (newtest) { + // set inTest before sending responses + inTest = true; HttpTestRequestHeaders hdrs = he.getRequestHeaders(); String value = hdrs.firstValue("X-Redirect-Code").get(); int redirectCode = Integer.parseInt(value); @@ -286,8 +290,9 @@ public synchronized void handle(HttpTestExchange he) throws IOException { HttpTestResponseHeaders headersbuilder = he.getResponseHeaders(); headersbuilder.addHeader("Location", targetURL); he.sendResponseHeaders(redirectCode, 0); - inTest = true; } else { + // set inTest before sending responses + inTest = false; // should be the redirect if (!he.getRequestURI().getPath().endsWith("/redirect/rmt")) { Throwable ex = new RuntimeException("Unexpected redirected request, got:" @@ -307,7 +312,6 @@ public synchronized void handle(HttpTestExchange he) throws IOException { os.write(RESPONSE.getBytes(US_ASCII)); } } - inTest = false; } } } diff --git a/test/jdk/java/net/httpclient/ShortRequestBody.java b/test/jdk/java/net/httpclient/ShortRequestBody.java index 0bdb395003958..ffebdeec5ce01 100644 --- a/test/jdk/java/net/httpclient/ShortRequestBody.java +++ b/test/jdk/java/net/httpclient/ShortRequestBody.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, 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 @@ -176,6 +176,23 @@ static void success(Supplier clientSupplier, "Expected 200, got ", resp.statusCode()); } + static void checkCause(Throwable cause) { + Throwable t = cause; + boolean found = false; + while (t != null && !found) { + check(t instanceof IOException, t, + "Expected cause IOException, but got: ", t); + String msg = t.getMessage(); + found = (msg != null && (msg.contains("Too many") || msg.contains("Too few"))); + t = t.getCause(); + } + if (!found) { + String msg = cause.getMessage(); + check(msg.contains("Too many") || msg.contains("Too few"), + cause, "Expected Too many|Too few, got: ", cause); + } + } + static void failureNonBlocking(Supplier clientSupplier, URI uri, HttpRequest.BodyPublisher publisher) @@ -194,12 +211,7 @@ static void failureNonBlocking(Supplier clientSupplier, throw new RuntimeException("Unexpected timeout", x); } catch (ExecutionException expected) { err.println("Caught expected: " + expected); - Throwable t = expected.getCause(); - check(t instanceof IOException, t, - "Expected cause IOException, but got: ", t); - String msg = t.getMessage(); - check(msg.contains("Too many") || msg.contains("Too few"), - t, "Expected Too many|Too few, got: ", t); + checkCause(expected.getCause()); } } @@ -219,9 +231,7 @@ static void failureBlocking(Supplier clientSupplier, throw new RuntimeException("Unexpected timeout", x); } catch (IOException expected) { err.println("Caught expected: " + expected); - String msg = expected.getMessage(); - check(msg.contains("Too many") || msg.contains("Too few"), - expected,"Expected Too many|Too few, got: ", expected); + checkCause(expected); } } diff --git a/test/jdk/java/net/httpclient/http2/ExpectContinueResetTest.java b/test/jdk/java/net/httpclient/http2/ExpectContinueResetTest.java index 68012208281da..5d09c01b96fc8 100644 --- a/test/jdk/java/net/httpclient/http2/ExpectContinueResetTest.java +++ b/test/jdk/java/net/httpclient/http2/ExpectContinueResetTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, 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 @@ -73,6 +73,7 @@ public class ExpectContinueResetTest { URI warmup, partialResponseResetNoError, partialResponseResetError, fullResponseResetNoError, fullResponseResetError; static PrintStream err = new PrintStream(System.err); + static PrintStream out = System.out; @DataProvider(name = "testData") public Object[][] testData() { @@ -88,17 +89,24 @@ public Object[][] testData() { @Test(dataProvider = "testData") public void test(URI uri) { + out.printf("\nTesting with Version: %s, URI: %s\n", HTTP_2, uri.toASCIIString()); err.printf("\nTesting with Version: %s, URI: %s\n", HTTP_2, uri.toASCIIString()); Iterable iterable = EndlessDataChunks::new; HttpRequest.BodyPublisher testPub = HttpRequest.BodyPublishers.ofByteArrays(iterable); - Throwable testThrowable = null; + Exception expectedException = null; try { performRequest(testPub, uri); + throw new AssertionError("Expected exception not raised for " + uri); } catch (Exception e) { - testThrowable = e.getCause(); + expectedException = e; } - assertNotNull(testThrowable, "Request should have completed exceptionally but testThrowable is null"); - assertEquals(testThrowable.getClass(), IOException.class, "Test should have closed with an IOException"); + Throwable testThrowable = expectedException.getCause(); + if (testThrowable == null) { + throw new AssertionError("Unexpected null cause for " + expectedException, + expectedException); + } + assertEquals(testThrowable.getClass(), IOException.class, + "Test should have closed with an IOException"); testThrowable.printStackTrace(); } @@ -177,7 +185,7 @@ static class NoEndStreamOnPartialResponse implements Http2Handler { @Override public void handle(Http2TestExchange exchange) throws IOException { err.println("Sending 100"); - exchange.sendResponseHeaders(100, 0); + exchange.sendResponseHeaders(100, -1); if (exchange instanceof ExpectContinueResetTestExchangeImpl testExchange) { err.println("Sending Reset"); err.println(exchange.getRequestURI().getPath()); @@ -197,8 +205,9 @@ static class NoEndStreamOnFullResponse implements Http2Handler { @Override public void handle(Http2TestExchange exchange) throws IOException { err.println("Sending 100"); - exchange.sendResponseHeaders(100, 0); + exchange.sendResponseHeaders(100, -1); err.println("Sending 200"); + exchange.sendResponseHeaders(200, 0); if (exchange instanceof ExpectContinueResetTestExchangeImpl testExchange) { err.println("Sending Reset"); From 8193ba3de200cb77f778f58c59b8bb2175b53273 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Wed, 15 Jan 2025 14:09:14 +0000 Subject: [PATCH 06/47] 8347562: javac crash due to type vars in permits clause Reviewed-by: vromero --- .../classes/com/sun/tools/javac/comp/Attr.java | 8 ++++++-- .../tools/javac/sealed/SealedCompilationTests.java | 13 +++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index 193794806433b..b0ed2da6cd98a 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -875,7 +875,7 @@ public Object attribLazyConstantValue(Env env, } } - /** Attribute type reference in an `extends' or `implements' clause. + /** Attribute type reference in an `extends', `implements', or 'permits' clause. * Supertypes of anonymous inner classes are usually already attributed. * * @param tree The tree making up the type reference. @@ -5407,6 +5407,10 @@ void attribClass(ClassSymbol c) throws CompletionFailure { Set permittedTypes = new HashSet<>(); boolean sealedInUnnamed = c.packge().modle == syms.unnamedModule || c.packge().modle == syms.noModule; for (Type subType : c.getPermittedSubclasses()) { + if (subType.isErroneous()) { + // the type already caused errors, don't produce more potentially misleading errors + continue; + } boolean isTypeVar = false; if (subType.getTag() == TYPEVAR) { isTypeVar = true; //error recovery diff --git a/test/langtools/tools/javac/sealed/SealedCompilationTests.java b/test/langtools/tools/javac/sealed/SealedCompilationTests.java index dee64fd0865aa..7cf63f5b2d5fd 100644 --- a/test/langtools/tools/javac/sealed/SealedCompilationTests.java +++ b/test/langtools/tools/javac/sealed/SealedCompilationTests.java @@ -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 @@ -25,7 +25,7 @@ * SealedCompilationTests * * @test - * @bug 8246353 8273257 8294550 + * @bug 8246353 8273257 8294550 8347562 * @summary Negative compilation tests, and positive compilation (smoke) tests for sealed classes * @library /lib/combo /tools/lib * @modules @@ -41,6 +41,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Collections; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -61,6 +62,7 @@ import toolbox.Task; import toolbox.Task.OutputKind; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; class SealedCompilationTests extends CompilationTestCase { @@ -560,6 +562,13 @@ sealed class C permits T {} """)) { assertFail("compiler.err.invalid.permits.clause", s); } + assertFail("compiler.err.illegal.forward.ref", _ -> { + assertEquals(Collections.nCopies(2, "compiler.err.illegal.forward.ref"), diags.keys()); + }, + """ + sealed class Permits permits X, Y {} + """ + ); } @Test From 254e840d9a80cfdcb48984a166b326a9c7a0e4b8 Mon Sep 17 00:00:00 2001 From: Sonia Zaldana Calles Date: Wed, 15 Jan 2025 14:09:27 +0000 Subject: [PATCH 07/47] 8340416: Remove ArchiveBuilder::estimate_archive_size() Reviewed-by: iklam, ccheung --- src/hotspot/share/cds/archiveBuilder.cpp | 71 +----------------------- src/hotspot/share/cds/archiveBuilder.hpp | 9 --- src/hotspot/share/cds/dynamicArchive.cpp | 4 -- 3 files changed, 2 insertions(+), 82 deletions(-) diff --git a/src/hotspot/share/cds/archiveBuilder.cpp b/src/hotspot/share/cds/archiveBuilder.cpp index feda5e0e39086..7a2d054820614 100644 --- a/src/hotspot/share/cds/archiveBuilder.cpp +++ b/src/hotspot/share/cds/archiveBuilder.cpp @@ -154,9 +154,7 @@ void ArchiveBuilder::SourceObjList::relocate(int i, ArchiveBuilder* builder) { ArchiveBuilder::ArchiveBuilder() : _current_dump_region(nullptr), _buffer_bottom(nullptr), - _last_verified_top(nullptr), _num_dump_regions_used(0), - _other_region_used_bytes(0), _requested_static_archive_bottom(nullptr), _requested_static_archive_top(nullptr), _requested_dynamic_archive_bottom(nullptr), @@ -173,9 +171,7 @@ ArchiveBuilder::ArchiveBuilder() : _ro_src_objs(), _src_obj_table(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE), _buffered_to_src_table(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE), - _total_heap_region_size(0), - _estimated_metaspaceobj_bytes(0), - _estimated_hashtable_bytes(0) + _total_heap_region_size(0) { _klasses = new (mtClassShared) GrowableArray(4 * K, mtClassShared); _symbols = new (mtClassShared) GrowableArray(256 * K, mtClassShared); @@ -238,10 +234,6 @@ bool ArchiveBuilder::gather_klass_and_symbol(MetaspaceClosure::Ref* ref, bool re assert(klass->is_instance_klass(), "must be"); } } - // See RunTimeClassInfo::get_for(): make sure we have enough space for both maximum - // Klass alignment as well as the RuntimeInfo* pointer we will embed in front of a Klass. - _estimated_metaspaceobj_bytes += align_up(BytesPerWord, CompressedKlassPointers::klass_alignment_in_bytes()) + - align_up(sizeof(void*), SharedSpaceObjectAlignment); } else if (ref->msotype() == MetaspaceObj::SymbolType) { // Make sure the symbol won't be GC'ed while we are dumping the archive. Symbol* sym = (Symbol*)ref->obj(); @@ -249,9 +241,6 @@ bool ArchiveBuilder::gather_klass_and_symbol(MetaspaceClosure::Ref* ref, bool re _symbols->append(sym); } - int bytes = ref->size() * BytesPerWord; - _estimated_metaspaceobj_bytes += align_up(bytes, SharedSpaceObjectAlignment); - return true; // recurse } @@ -294,10 +283,6 @@ void ArchiveBuilder::gather_klasses_and_symbols() { log_info(cds)("Sorting symbols ... "); _symbols->sort(compare_symbols_by_address); sort_klasses(); - - // TODO -- we need a proper estimate for the archived modules, etc, - // but this should be enough for now - _estimated_metaspaceobj_bytes += 200 * 1024 * 1024; } AOTClassLinker::add_candidates(); @@ -321,39 +306,8 @@ void ArchiveBuilder::sort_klasses() { _klasses->sort(compare_klass_by_name); } -size_t ArchiveBuilder::estimate_archive_size() { - // size of the symbol table and two dictionaries, plus the RunTimeClassInfo's - size_t symbol_table_est = SymbolTable::estimate_size_for_archive(); - size_t dictionary_est = SystemDictionaryShared::estimate_size_for_archive(); - _estimated_hashtable_bytes = symbol_table_est + dictionary_est; - - if (CDSConfig::is_dumping_aot_linked_classes()) { - // This is difficult to estimate when dumping the dynamic archive, as the - // AOTLinkedClassTable may need to contain classes in the static archive as well. - // - // Just give a generous estimate for now. We will remove estimate_archive_size() - // in JDK-8340416 - _estimated_hashtable_bytes += 20 * 1024 * 1024; - } - - size_t total = 0; - - total += _estimated_metaspaceobj_bytes; - total += _estimated_hashtable_bytes; - - // allow fragmentation at the end of each dump region - total += _total_dump_regions * MetaspaceShared::core_region_alignment(); - - log_info(cds)("_estimated_hashtable_bytes = " SIZE_FORMAT " + " SIZE_FORMAT " = " SIZE_FORMAT, - symbol_table_est, dictionary_est, _estimated_hashtable_bytes); - log_info(cds)("_estimated_metaspaceobj_bytes = " SIZE_FORMAT, _estimated_metaspaceobj_bytes); - log_info(cds)("total estimate bytes = " SIZE_FORMAT, total); - - return align_up(total, MetaspaceShared::core_region_alignment()); -} - address ArchiveBuilder::reserve_buffer() { - size_t buffer_size = estimate_archive_size(); + size_t buffer_size = LP64_ONLY(CompressedClassSpaceSize) NOT_LP64(256 * M); ReservedSpace rs = MemoryReserver::reserve(buffer_size, MetaspaceShared::core_region_alignment(), os::vm_page_size()); @@ -370,10 +324,8 @@ address ArchiveBuilder::reserve_buffer() { _shared_rs = rs; _buffer_bottom = buffer_bottom; - _last_verified_top = buffer_bottom; _current_dump_region = &_rw_region; _num_dump_regions_used = 1; - _other_region_used_bytes = 0; _current_dump_region->init(&_shared_rs, &_shared_vs); ArchivePtrMarker::initialize(&_ptrmap, &_shared_vs); @@ -592,28 +544,9 @@ ArchiveBuilder::FollowMode ArchiveBuilder::get_follow_mode(MetaspaceClosure::Ref } void ArchiveBuilder::start_dump_region(DumpRegion* next) { - address bottom = _last_verified_top; - address top = (address)(current_dump_region()->top()); - _other_region_used_bytes += size_t(top - bottom); - current_dump_region()->pack(next); _current_dump_region = next; _num_dump_regions_used ++; - - _last_verified_top = (address)(current_dump_region()->top()); -} - -void ArchiveBuilder::verify_estimate_size(size_t estimate, const char* which) { - address bottom = _last_verified_top; - address top = (address)(current_dump_region()->top()); - size_t used = size_t(top - bottom) + _other_region_used_bytes; - int diff = int(estimate) - int(used); - - log_info(cds)("%s estimate = " SIZE_FORMAT " used = " SIZE_FORMAT "; diff = %d bytes", which, estimate, used, diff); - assert(diff >= 0, "Estimate is too small"); - - _last_verified_top = top; - _other_region_used_bytes = 0; } char* ArchiveBuilder::ro_strdup(const char* s) { diff --git a/src/hotspot/share/cds/archiveBuilder.hpp b/src/hotspot/share/cds/archiveBuilder.hpp index 0c5262321d086..e3efedd46f14c 100644 --- a/src/hotspot/share/cds/archiveBuilder.hpp +++ b/src/hotspot/share/cds/archiveBuilder.hpp @@ -96,9 +96,7 @@ class ArchiveBuilder : public StackObj { protected: DumpRegion* _current_dump_region; address _buffer_bottom; // for writing the contents of rw/ro regions - address _last_verified_top; int _num_dump_regions_used; - size_t _other_region_used_bytes; // These are the addresses where we will request the static and dynamic archives to be // mapped at run time. If the request fails (due to ASLR), we will map the archives at @@ -273,16 +271,9 @@ class ArchiveBuilder : public StackObj { protected: virtual void iterate_roots(MetaspaceClosure* it) = 0; - // Conservative estimate for number of bytes needed for: - size_t _estimated_metaspaceobj_bytes; // all archived MetaspaceObj's. - size_t _estimated_hashtable_bytes; // symbol table and dictionaries - static const int _total_dump_regions = 2; - size_t estimate_archive_size(); - void start_dump_region(DumpRegion* next); - void verify_estimate_size(size_t estimate, const char* which); public: address reserve_buffer(); diff --git a/src/hotspot/share/cds/dynamicArchive.cpp b/src/hotspot/share/cds/dynamicArchive.cpp index ab40048b448df..9a570984079fd 100644 --- a/src/hotspot/share/cds/dynamicArchive.cpp +++ b/src/hotspot/share/cds/dynamicArchive.cpp @@ -133,8 +133,6 @@ class DynamicArchiveBuilder : public ArchiveBuilder { dump_ro_metadata(); relocate_metaspaceobj_embedded_pointers(); - verify_estimate_size(_estimated_metaspaceobj_bytes, "MetaspaceObjs"); - sort_methods(); log_info(cds)("Make classes shareable"); @@ -159,8 +157,6 @@ class DynamicArchiveBuilder : public ArchiveBuilder { ArchiveBuilder::serialize_dynamic_archivable_items(&wc); } - verify_estimate_size(_estimated_hashtable_bytes, "Hashtables"); - log_info(cds)("Adjust lambda proxy class dictionary"); SystemDictionaryShared::adjust_lambda_proxy_class_dictionary(); From 63cedaf40e179267d75445a4c71ec15f29979cd3 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Wed, 15 Jan 2025 14:44:35 +0000 Subject: [PATCH 08/47] 8347334: JimageDiffGenerator code clean-ups Reviewed-by: henryjen, mbaesken --- .../runtimelink/JimageDiffGenerator.java | 40 +-- .../runtimeImage/JimageDiffGeneratorTest.java | 327 ++++++++++++++++++ 2 files changed, 340 insertions(+), 27 deletions(-) create mode 100644 test/jdk/tools/jlink/runtimeImage/JimageDiffGeneratorTest.java diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/runtimelink/JimageDiffGenerator.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/runtimelink/JimageDiffGenerator.java index 60014e2bbd763..3deb0ef577c87 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/runtimelink/JimageDiffGenerator.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/runtimelink/JimageDiffGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Red Hat, Inc. + * Copyright (c) 2024, 2025, Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -126,39 +126,25 @@ public List generateDiff(ImageResource base, ImageResource image) private boolean compareStreams(InputStream is1, InputStream is2) { byte[] buf1 = new byte[1024]; byte[] buf2 = new byte[1024]; - int bytesRead1, bytesRead2 = 0; - try { - try (is1; is2) { - while ((bytesRead1 = is1.read(buf1)) != -1 && - (bytesRead2 = is2.read(buf2)) != -1) { - if (bytesRead1 != bytesRead2) { - return false; - } - if (bytesRead1 == buf1.length) { - if (!Arrays.equals(buf1, buf2)) { - return false; - } - } else { - for (int i = 0; i < bytesRead1; i++) { - if (buf1[i] != buf2[i]) { - return false; - } - } - } + int bytesRead1, bytesRead2; + try (is1; is2) { + while (true) { + bytesRead1 = is1.readNBytes(buf1, 0, buf1.length); + bytesRead2 = is2.readNBytes(buf2, 0, buf2.length); + if (!Arrays.equals(buf1, 0, bytesRead1, + buf2, 0, bytesRead2)) { + return false; } - // ensure we read both to the end - if (bytesRead1 == -1) { - bytesRead2 = is2.read(buf2); - if (bytesRead2 != -1) { - return false; - } + if (bytesRead1 == 0) { + // If we reach here, bytesRead2 must be 0 as well, otherwise + // we return false on the !Arrays.equals() check above. + assert bytesRead2 == 0 : "Arrays must have been read to the end"; return true; } } } catch (IOException e) { throw new UncheckedIOException("IO exception when comparing bytes", e); } - return false; } } diff --git a/test/jdk/tools/jlink/runtimeImage/JimageDiffGeneratorTest.java b/test/jdk/tools/jlink/runtimeImage/JimageDiffGeneratorTest.java new file mode 100644 index 0000000000000..0176e6d07a19d --- /dev/null +++ b/test/jdk/tools/jlink/runtimeImage/JimageDiffGeneratorTest.java @@ -0,0 +1,327 @@ +/* + * Copyright (c) 2025, Red Hat, Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.List; + +import org.testng.annotations.Test; + +import jdk.tools.jlink.internal.runtimelink.JimageDiffGenerator; +import jdk.tools.jlink.internal.runtimelink.JimageDiffGenerator.ImageResource; +import jdk.tools.jlink.internal.runtimelink.ResourceDiff; + +/* + * @test + * @summary Unit test the diff generator logic for JEP 493 + * @modules java.base/jdk.internal.jimage + * jdk.jlink/jdk.tools.jlink.internal.runtimelink + * @run testng JimageDiffGeneratorTest + */ +public class JimageDiffGeneratorTest { + + /* + * Expect a resource diff since the "b" item is removed in + * the optimized image. + */ + @Test + public void testItemsRemovedInOpt() throws Exception { + List entriesOpt = List.of("a", "c", "d"); + byte[][] bytesOpt = new byte[][] { + { 0x01, 0x03, 0x03 }, /* a */ + { 0x09, 0x11, 0x11 }, /* c */ + { 0x22, 0x22, 0x30 }, /* d */ + }; + ImageResource opt = new BasicImageResource(entriesOpt, bytesOpt); + List entriesBase = List.of("a", "b", "c", "d"); + byte[][] bytesBase = new byte[][] { + { 0x01, 0x03, 0x03 }, /* a */ + { 0x08, 0x04, 0x04 }, /* b */ + { 0x09, 0x11, 0x11 }, /* c */ + { 0x22, 0x22, 0x30 }, /* d */ + }; + ImageResource base = new BasicImageResource(entriesBase, bytesBase); + JimageDiffGenerator gen = new JimageDiffGenerator(); + List result = gen.generateDiff(base, opt); + assertEquals(result.size(), 1); + assertEquals(result.get(0).getKind(), ResourceDiff.Kind.REMOVED); + assertEquals(result.get(0).getName(), "b"); + assertEquals(result.get(0).getResourceBytes(), bytesBase[1]); + } + + /* + * Expect no difference as streams are the same + */ + @Test + public void testNoDiff() throws Exception { + List entriesBase = List.of("a", "b", "c", "d"); + byte[][] bytesBase = new byte[][] { + { 0x01, 0x03, 0x03 }, /* a */ + { 0x08, 0x04, 0x04 }, /* b */ + { 0x09, 0x11, 0x11 }, /* c */ + { 0x22, 0x22, 0x30 }, /* d */ + }; + ImageResource base = new BasicImageResource(entriesBase, bytesBase); + ImageResource opt = new BasicImageResource(entriesBase, bytesBase); + JimageDiffGenerator gen = new JimageDiffGenerator(); + List result = gen.generateDiff(base, opt); + assertTrue(result.isEmpty()); + } + + /* + * Expect a resource diff since the "b" item has been added in + * the optimized image. + */ + @Test + public void testItemsAddedInOpt() throws Exception { + List entriesBase = List.of("a", "c", "d"); + byte[][] bytesBase = new byte[][] { + { 0x01, 0x03, 0x03 }, /* a */ + { 0x09, 0x11, 0x11 }, /* c */ + { 0x22, 0x22, 0x30 }, /* d */ + }; + ImageResource base = new BasicImageResource(entriesBase, bytesBase); + List entriesOpt = List.of("a", "b", "c", "d"); + byte[][] bytesOpt = new byte[][] { + { 0x01, 0x03, 0x03 }, /* a */ + { 0x08, 0x04, 0x04 }, /* b */ + { 0x09, 0x11, 0x11 }, /* c */ + { 0x22, 0x22, 0x30 }, /* d */ + }; + ImageResource opt = new BasicImageResource(entriesOpt, bytesOpt); + JimageDiffGenerator gen = new JimageDiffGenerator(); + List result = gen.generateDiff(base, opt); + assertEquals(result.size(), 1); + assertEquals(result.get(0).getKind(), ResourceDiff.Kind.ADDED); + assertEquals(result.get(0).getName(), "b"); + assertEquals(result.get(0).getResourceBytes(), null, "Added entries in opt don't have resource bytes"); + } + + /* + * Expect a resource diff since the "d" item has modified bytes in the + * optimized image resource. + */ + @Test + public void testBytesDiffer() throws Exception { + List entriesBase = List.of("a", "b", "c", "d"); + byte[][] bytesBase = new byte[][] { + { 0x01, 0x03, 0x03 }, /* a */ + { 0x08, 0x04, 0x04 }, /* b */ + { 0x09, 0x11, 0x11 }, /* c */ + { 0x11, 0x12, 0x31 }, /* d */ + }; + ImageResource base = new BasicImageResource(entriesBase, bytesBase); + List entriesOpt = List.of("a", "b", "c", "d"); + byte[][] bytesOpt = new byte[][] { + { 0x01, 0x03, 0x03 }, /* a */ + { 0x08, 0x04, 0x04 }, /* b */ + { 0x09, 0x11, 0x11 }, /* c */ + { 0x22, 0x22, 0x30 }, /* d - differs to base! */ + }; + ImageResource opt = new BasicImageResource(entriesOpt, bytesOpt); + JimageDiffGenerator gen = new JimageDiffGenerator(); + List result = gen.generateDiff(base, opt); + assertEquals(result.size(), 1); + assertEquals(result.get(0).getKind(), ResourceDiff.Kind.MODIFIED); + assertEquals(result.get(0).getName(), "d"); + assertEquals(result.get(0).getResourceBytes(), bytesBase[3]); + } + + /* + * Expect a resource diff since an item has modified bytes. Test + * for a resource that has more than 1K bytes (the buffer size used + * internally). + */ + @Test + public void testBytesDifferLarge() throws Exception { + List entriesBase = List.of("a", "b", "c", "d"); + byte[][] bytesBase = new byte[][] { + { 0x01, 0x03, 0x03 }, /* a */ + { 0x08, 0x04, 0x04 }, /* b */ + { }, /* c */ + { 0x11, 0x12, 0x31 }, /* d */ + }; + bytesBase[2] = generateBytes(); + ImageResource base = new BasicImageResource(entriesBase, bytesBase); + List entriesOpt = List.of("a", "b", "c", "d"); + byte[][] bytesOpt = new byte[][] { + { 0x01, 0x03, 0x03 }, /* a */ + { 0x08, 0x04, 0x04 }, /* b */ + { }, /* c */ + { 0x22, 0x22, 0x30 }, /* d */ + }; + bytesOpt[2] = generateBytes(); + // Change the first byte of 'c' in the opt bytes + bytesOpt[2][0] = -1; + // assert pre-condition + assertTrue(bytesOpt[2][0] != bytesBase[2][0]); + + ImageResource opt = new BasicImageResource(entriesOpt, bytesOpt); + JimageDiffGenerator gen = new JimageDiffGenerator(); + List result = gen.generateDiff(base, opt); + assertEquals(result.size(), 2); + // assertions for 'c' differences + assertEquals(result.get(0).getKind(), ResourceDiff.Kind.MODIFIED); + assertEquals(result.get(0).getName(), "c"); + assertEquals(result.get(0).getResourceBytes(), bytesBase[2]); + + // assertion for 'd' differences + assertEquals(result.get(1).getKind(), ResourceDiff.Kind.MODIFIED); + assertEquals(result.get(1).getName(), "d"); + assertEquals(result.get(1).getResourceBytes(), bytesBase[3]); + } + + /* + * Expect a no resource difference since the steams are both empty + */ + @Test + public void testEmptyStreams() throws Exception { + List entriesBase = List.of("a", "b", "c", "d"); + byte[][] bytesBase = new byte[][] { + { }, /* a */ + { }, /* b */ + { }, /* c */ + { }, /* d */ + }; + ImageResource base = new BasicImageResource(entriesBase, bytesBase); + ImageResource opt = new BasicImageResource(entriesBase, bytesBase); + JimageDiffGenerator gen = new JimageDiffGenerator(); + List result = gen.generateDiff(base, opt); + assertTrue(result.isEmpty()); + } + + /* + * Expect a difference since entry 'a' has zero bytes in opt. + */ + @Test + public void testNotEqualLength() throws Exception { + List entriesBase = List.of("a", "b", "c", "d"); + byte[][] bytesBase = new byte[][] { + { 0x01, 0x03, 0x03 }, /* a */ + { 0x08, 0x04, 0x04 }, /* b */ + { 0x09, 0x11, 0x11 }, /* c */ + { 0x11, 0x12, 0x31 }, /* d */ + }; + byte[][] bytesOpt = new byte[][] { + { }, /* a */ + { 0x08, 0x04, 0x04 }, /* b */ + { 0x09, 0x11, 0x11 }, /* c */ + { 0x11, 0x12, 0x31 }, /* d */ + }; + ImageResource base = new BasicImageResource(entriesBase, bytesBase); + ImageResource opt = new BasicImageResource(entriesBase, bytesOpt); + JimageDiffGenerator gen = new JimageDiffGenerator(); + List result = gen.generateDiff(base, opt); + assertEquals(result.size(), 1); + assertEquals(result.get(0).getKind(), ResourceDiff.Kind.MODIFIED); + assertEquals(result.get(0).getName(), "a"); + assertEquals(result.get(0).getResourceBytes(), bytesBase[0]); + } + + /* + * Expect a difference since entry 'a' on the optimized version is + * one byte longer. + */ + @Test + public void testBytesDifferExactBufferSize() throws Exception { + List entriesBase = List.of("a", "b", "c", "d"); + byte[][] bytesBase = new byte[][] { + { }, /* a */ + { 0x08, 0x04, 0x04 }, /* b */ + { 0x09, 0x11, 0x11 }, /* c */ + { 0x11, 0x12, 0x31 }, /* d */ + }; + byte[][] bytesOpt = new byte[][] { + { }, /* a */ + { 0x08, 0x04, 0x04 }, /* b */ + { 0x09, 0x11, 0x11 }, /* c */ + { 0x11, 0x12, 0x31 }, /* d */ + }; + bytesBase[0] = genBytesOfSize(1024); // exact buffer size + bytesOpt[0] = genBytesOfSize(1024 + 1); // buffer size + 1 + + ImageResource base = new BasicImageResource(entriesBase, bytesBase); + ImageResource opt = new BasicImageResource(entriesBase, bytesOpt); + JimageDiffGenerator gen = new JimageDiffGenerator(); + List result = gen.generateDiff(base, opt); + assertEquals(result.size(), 1); + assertEquals(result.get(0).getKind(), ResourceDiff.Kind.MODIFIED); + assertEquals(result.get(0).getName(), "a"); + assertEquals(result.get(0).getResourceBytes(), bytesBase[0]); + } + + private byte[] generateBytes() { + int size = 1024 + 254; + return genBytesOfSize(size); + } + + private byte[] genBytesOfSize(int size) { + byte[] result = new byte[size]; + for (int i = 0; i < size; i++) { + result[i] = (byte)(i % Byte.MAX_VALUE); + } + return result; + } + + // Simple stub ImageResource for test purposes + static class BasicImageResource implements ImageResource { + + private final List entries; + private final byte[][] entryBytes; + + public BasicImageResource(List entries, byte[][] entryBytes) { + this.entries = entries; + this.entryBytes = entryBytes; + } + + @Override + public void close() throws Exception { + // nothing + } + + @Override + public List getEntries() { + return entries; + } + + @Override + public byte[] getResourceBytes(String name) { + for (int i = 0; i < entries.size(); i++) { + if (entries.get(i).equals(name)) { + return entryBytes[i]; + } + } + return null; + } + + @Override + public InputStream getResource(String name) { + byte[] bytes = getResourceBytes(name); + return new ByteArrayInputStream(bytes); + } + + } +} From a0f7982e44deec2cd59379c62b215c3f526fc2c4 Mon Sep 17 00:00:00 2001 From: Mikhail Yankelevich Date: Wed, 15 Jan 2025 15:24:31 +0000 Subject: [PATCH 09/47] 8345134: Test sun/security/tools/jarsigner/ConciseJarsigner.java failed: unable to find valid certification path to requested target Reviewed-by: weijun --- .../security/tools/jarsigner/ConciseJarsigner.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/jdk/sun/security/tools/jarsigner/ConciseJarsigner.java b/test/jdk/sun/security/tools/jarsigner/ConciseJarsigner.java index 69b45ea22930d..e81a25712a6b2 100644 --- a/test/jdk/sun/security/tools/jarsigner/ConciseJarsigner.java +++ b/test/jdk/sun/security/tools/jarsigner/ConciseJarsigner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -43,8 +43,15 @@ public class ConciseJarsigner { static OutputAnalyzer kt(String cmd) throws Exception { // Choose 2048-bit RSA to make sure it runs fine and fast. In // fact, every keyalg/keysize combination is OK for this test. - return SecurityTools.keytool("-storepass changeit -keypass changeit " - + "-keystore ks -keyalg rsa -keysize 2048 " + cmd); + // The start date is set to -1M to prevent the certificate not yet valid during fast enough execution. + // If -startdate is specified in cmd, cmd version will be used. + if (cmd.contains("-startdate")) { + return SecurityTools.keytool("-storepass changeit -keypass changeit " + + "-keystore ks -keyalg rsa -keysize 2048 " + cmd); + } else { + return SecurityTools.keytool("-storepass changeit -keypass changeit " + + "-keystore ks -keyalg rsa -keysize 2048 -startdate -1M " + cmd); + } } static void gencert(String owner, String cmd) throws Exception { From 4257215a9fa02f74ccd4fc62893d4b1a232a8754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gr=C3=B6nlund?= Date: Wed, 15 Jan 2025 16:17:26 +0000 Subject: [PATCH 10/47] 8345493: JFR: JVM.flush hangs intermittently Reviewed-by: egahlin --- .../share/classes/jdk/jfr/internal/PlatformRecorder.java | 4 ++++ .../share/classes/jdk/jfr/internal/periodic/FlushTask.java | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java index 646c53f896134..cc22850bcf9fc 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java @@ -650,4 +650,8 @@ public synchronized void migrate(Path repo) throws IOException { public RepositoryChunk getCurrentChunk() { return currentChunk; } + + public synchronized void flush() { + MetadataRepository.getInstance().flush(); + } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java index 407bdadad4322..739f32bf63489 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java @@ -1,5 +1,5 @@ /* - * 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 @@ -26,6 +26,8 @@ import jdk.jfr.internal.JVM; import jdk.jfr.internal.MetadataRepository; +import jdk.jfr.internal.PlatformRecorder; +import jdk.jfr.internal.PrivateAccess; import jdk.jfr.internal.util.Utils; /** @@ -44,7 +46,8 @@ public FlushTask() { @Override public void execute(long timestamp, PeriodicType periodicType) { - MetadataRepository.getInstance().flush(); + PlatformRecorder recorder = PrivateAccess.getInstance().getPlatformRecorder(); + recorder.flush(); Utils.notifyFlush(); } From a6be9076351b591cbc0860b1ba8f3c56319f4ffe Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 15 Jan 2025 16:40:12 +0000 Subject: [PATCH 11/47] 8347424: Fix and rewrite sun/security/x509/DNSName/LeadingPeriod.java test Reviewed-by: mullan, bperez --- .../security/x509/DNSName/LeadingPeriod.java | 81 +++++-------------- 1 file changed, 19 insertions(+), 62 deletions(-) diff --git a/test/jdk/sun/security/x509/DNSName/LeadingPeriod.java b/test/jdk/sun/security/x509/DNSName/LeadingPeriod.java index a293e5360a9cf..2fa5eb6b8b525 100644 --- a/test/jdk/sun/security/x509/DNSName/LeadingPeriod.java +++ b/test/jdk/sun/security/x509/DNSName/LeadingPeriod.java @@ -1,5 +1,5 @@ /* - * 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 @@ -26,8 +26,7 @@ * @bug 8311546 * @summary Adopt de-facto standards on x509 Name Constraints with leading dot. Certs * can be generated by running generate-certs.sh - * @library /test/lib - * @modules java.base/sun.security.x509 + * @run main LeadingPeriod */ import java.io.*; @@ -38,75 +37,33 @@ public class LeadingPeriod { - private static CertPath makeCertPath(String targetCertStr, - PKIXParameters params) throws CertificateException { - // generate certificate from cert strings - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - ByteArrayInputStream is; - - is = new ByteArrayInputStream(targetCertStr.getBytes()); - Certificate targetCert = cf.generateCertificate(is); - // set validity date so that validation won't fail when cert expires - params.setDate(((X509Certificate)targetCert).getNotBefore()); - - // generate certification path - List list = List.of(targetCert); - - return cf.generateCertPath(list); + public static void main(String[] args) throws Exception { + String certs = System.getProperty("test.src", "./") + "/certs/"; + validate(certs + "withoutLeadingPeriod"); + validate(certs + "withLeadingPeriod"); } - private static PKIXParameters genParams(String caStr) throws Exception { - // generate certificate from cert string - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - ByteArrayInputStream is = new ByteArrayInputStream(caStr.getBytes()); - Certificate selfSignedCert = cf.generateCertificate(is); + public static void validate(String certPath) throws Exception { + byte[] targetCertBytes = Files.readAllBytes(Paths.get(certPath + "/leaf.pem")); + byte[] caCertBytes = Files.readAllBytes(Paths.get(certPath + "/ca.pem")); - // generate a trust anchor - TrustAnchor anchor = new TrustAnchor((X509Certificate) selfSignedCert, null); + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + Certificate caCert = cf.generateCertificate(new ByteArrayInputStream(caCertBytes)); + Certificate targetCert = cf.generateCertificate(new ByteArrayInputStream(targetCertBytes)); - Set anchors = Collections.singleton(anchor); + TrustAnchor anchor = new TrustAnchor((X509Certificate) caCert, null); - PKIXParameters params = new PKIXParameters(anchors); + PKIXParameters params = new PKIXParameters(Collections.singleton(anchor)); - // disable certificate revocation checking + // Disable certificate revocation checking params.setRevocationEnabled(false); - return params; - } + // Set validity date, so that validation won't fail when cert expires + params.setDate(((X509Certificate)targetCert).getNotBefore()); - public static void main(String[] args) throws Exception { + CertPath path = cf.generateCertPath(List.of(targetCert, caCert)); CertPathValidator validator = CertPathValidator.getInstance("PKIX"); - - // Load certs with a NameConstraint where DNS value does not begin with a period - Path targetFromCAWithoutPeriodPath = Paths.get(System.getProperty( - "test.src", "./") + "/certs/withoutLeadingPeriod/leaf.pem"); - String targetFromCAWithoutPeriod = Files.readString(targetFromCAWithoutPeriodPath); - - Path caWithoutLeadingPeriodPath = Paths.get(System.getProperty( - "test.src", "./") + "/certs/withoutLeadingPeriod/ca.pem"); - String caWithoutLeadingPeriod = Files.readString(caWithoutLeadingPeriodPath); - - PKIXParameters paramsForCAWithoutLeadingPeriod = genParams(caWithoutLeadingPeriod); - CertPath pathWithoutLeadingPeriod = makeCertPath( - targetFromCAWithoutPeriod, paramsForCAWithoutLeadingPeriod); - - validator.validate(pathWithoutLeadingPeriod, paramsForCAWithoutLeadingPeriod); - - // Load certificates with a NameConstraint where the DNS value does begin with a period - Path targetFromCAWithPeriodPath = Paths.get(System.getProperty( - "test.src", "./") + "/certs/withLeadingPeriod/leaf.pem"); - String targetFromCAWithPeriod = Files.readString(targetFromCAWithPeriodPath); - - Path caWithLeadingPeriodPath = Paths.get(System.getProperty( - "test.src", "./") + "/certs/withLeadingPeriod/ca.pem"); - String caWithLeadingPeriod = Files.readString(caWithLeadingPeriodPath); - - PKIXParameters paramsForCAWithLeadingPeriod = genParams(caWithLeadingPeriod); - CertPath pathWithLeadingPeriod = makeCertPath(targetFromCAWithPeriod, paramsForCAWithLeadingPeriod); - - validator.validate(pathWithLeadingPeriod, paramsForCAWithLeadingPeriod); + validator.validate(path, params); } } From 983e24fd262b5aa793a249cad39270956e1f8fc4 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 15 Jan 2025 17:11:29 +0000 Subject: [PATCH 12/47] 8347727: Replace SIZE_FORMAT in shared gc Reviewed-by: kbarrett, dholmes, tschatzl --- .../share/gc/shared/adaptiveSizePolicy.cpp | 12 ++--- src/hotspot/share/gc/shared/ageTable.cpp | 2 +- src/hotspot/share/gc/shared/collectedHeap.cpp | 6 +-- .../share/gc/shared/fullGCForwarding.cpp | 4 +- src/hotspot/share/gc/shared/gcArguments.cpp | 8 +-- src/hotspot/share/gc/shared/gcInitLogger.cpp | 10 ++-- src/hotspot/share/gc/shared/gcTraceTime.cpp | 4 +- .../share/gc/shared/gcVMOperations.cpp | 6 +-- src/hotspot/share/gc/shared/genArguments.cpp | 22 ++++---- .../share/gc/shared/jvmFlagConstraintsGC.cpp | 50 +++++++++---------- src/hotspot/share/gc/shared/memAllocator.cpp | 8 +-- src/hotspot/share/gc/shared/oopStorage.cpp | 8 +-- src/hotspot/share/gc/shared/plab.cpp | 4 +- .../share/gc/shared/preservedMarks.cpp | 6 +-- src/hotspot/share/gc/shared/pretouchTask.cpp | 8 +-- .../share/gc/shared/referenceProcessor.cpp | 14 +++--- src/hotspot/share/gc/shared/satbMarkQueue.cpp | 6 +-- src/hotspot/share/gc/shared/taskqueue.cpp | 7 ++- .../gc/shared/threadLocalAllocBuffer.cpp | 14 +++--- .../shared/threadLocalAllocBuffer.inline.hpp | 12 ++--- .../share/gc/shared/workerDataArray.cpp | 8 +-- 21 files changed, 109 insertions(+), 110 deletions(-) diff --git a/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp b/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp index 1454a2b21e94d..fa66a2e454d2b 100644 --- a/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp +++ b/src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -337,11 +337,11 @@ class AdaptiveSizePolicySpaceOverheadTester: public GCOverheadTester { log_trace(gc, ergo)( "AdaptiveSizePolicySpaceOverheadTester::is_exceeded:" - " promo_limit: " SIZE_FORMAT - " total_free_limit: " SIZE_FORMAT - " max_old_gen_size: " SIZE_FORMAT - " max_eden_size: " SIZE_FORMAT - " mem_free_limit: " SIZE_FORMAT, + " promo_limit: %zu" + " total_free_limit: %zu" + " max_old_gen_size: %zu" + " max_eden_size: %zu" + " mem_free_limit: %zu", promo_limit, total_free_limit, _max_old_gen_size, _max_eden_size, (size_t)mem_free_limit); diff --git a/src/hotspot/share/gc/shared/ageTable.cpp b/src/hotspot/share/gc/shared/ageTable.cpp index 17fc19e3b913a..9c22d9955578c 100644 --- a/src/hotspot/share/gc/shared/ageTable.cpp +++ b/src/hotspot/share/gc/shared/ageTable.cpp @@ -131,7 +131,7 @@ void AgeTable::print_on(outputStream* st) { size_t word_size = sizes[age]; total += word_size; if (word_size > 0) { - st->print_cr("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total", + st->print_cr("- age %3u: %10zu bytes, %10zu total", age, word_size * oopSize, total * oopSize); } AgeTableTracer::send_tenuring_distribution_event(age, word_size * oopSize); diff --git a/src/hotspot/share/gc/shared/collectedHeap.cpp b/src/hotspot/share/gc/shared/collectedHeap.cpp index e35748b366900..6eb5a49264038 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.cpp +++ b/src/hotspot/share/gc/shared/collectedHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -405,7 +405,7 @@ MetaWord* CollectedHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loa if ((QueuedAllocationWarningCount > 0) && (loop_count % QueuedAllocationWarningCount == 0)) { log_warning(gc, ergo)("satisfy_failed_metadata_allocation() retries %d times," - " size=" SIZE_FORMAT, loop_count, word_size); + " size=%zu", loop_count, word_size); } } while (true); // Until a GC is done } @@ -481,7 +481,7 @@ CollectedHeap::fill_with_array(HeapWord* start, size_t words, bool zap) const size_t payload_size = words - filler_array_hdr_size(); const size_t len = payload_size * HeapWordSize / sizeof(jint); - assert((int)len >= 0, "size too large " SIZE_FORMAT " becomes %d", words, (int)len); + assert((int)len >= 0, "size too large %zu becomes %d", words, (int)len); ObjArrayAllocator allocator(Universe::fillerArrayKlass(), words, (int)len, /* do_zero */ false); allocator.initialize(start); diff --git a/src/hotspot/share/gc/shared/fullGCForwarding.cpp b/src/hotspot/share/gc/shared/fullGCForwarding.cpp index 4880b08887e56..4ea51b863874e 100644 --- a/src/hotspot/share/gc/shared/fullGCForwarding.cpp +++ b/src/hotspot/share/gc/shared/fullGCForwarding.cpp @@ -34,8 +34,8 @@ void FullGCForwarding::initialize_flags(size_t max_heap_size) { #ifdef _LP64 size_t max_narrow_heap_size = right_n_bits(NumLowBitsNarrow - Shift); if (UseCompactObjectHeaders && max_heap_size > max_narrow_heap_size * HeapWordSize) { - warning("Compact object headers require a java heap size smaller than " SIZE_FORMAT - "%s (given: " SIZE_FORMAT "%s). Disabling compact object headers.", + warning("Compact object headers require a java heap size smaller than %zu" + "%s (given: %zu%s). Disabling compact object headers.", byte_size_in_proper_unit(max_narrow_heap_size * HeapWordSize), proper_unit_for_byte_size(max_narrow_heap_size * HeapWordSize), byte_size_in_proper_unit(max_heap_size), diff --git a/src/hotspot/share/gc/shared/gcArguments.cpp b/src/hotspot/share/gc/shared/gcArguments.cpp index c20c8c4922ef5..ed8607dd61a31 100644 --- a/src/hotspot/share/gc/shared/gcArguments.cpp +++ b/src/hotspot/share/gc/shared/gcArguments.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -99,7 +99,7 @@ void GCArguments::assert_size_info() { #endif // ASSERT void GCArguments::initialize_size_info() { - log_debug(gc, heap)("Minimum heap " SIZE_FORMAT " Initial heap " SIZE_FORMAT " Maximum heap " SIZE_FORMAT, + log_debug(gc, heap)("Minimum heap %zu Initial heap %zu Maximum heap %zu", MinHeapSize, InitialHeapSize, MaxHeapSize); DEBUG_ONLY(assert_size_info();) @@ -109,10 +109,10 @@ void GCArguments::initialize_heap_flags_and_sizes() { assert(SpaceAlignment != 0, "Space alignment not set up properly"); assert(HeapAlignment != 0, "Heap alignment not set up properly"); assert(HeapAlignment >= SpaceAlignment, - "HeapAlignment: " SIZE_FORMAT " less than SpaceAlignment: " SIZE_FORMAT, + "HeapAlignment: %zu less than SpaceAlignment: %zu", HeapAlignment, SpaceAlignment); assert(HeapAlignment % SpaceAlignment == 0, - "HeapAlignment: " SIZE_FORMAT " not aligned by SpaceAlignment: " SIZE_FORMAT, + "HeapAlignment: %zu not aligned by SpaceAlignment: %zu", HeapAlignment, SpaceAlignment); if (FLAG_IS_CMDLINE(MaxHeapSize)) { diff --git a/src/hotspot/share/gc/shared/gcInitLogger.cpp b/src/hotspot/share/gc/shared/gcInitLogger.cpp index 1dfc27c533377..e58fe3ab790c2 100644 --- a/src/hotspot/share/gc/shared/gcInitLogger.cpp +++ b/src/hotspot/share/gc/shared/gcInitLogger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -75,7 +75,7 @@ void GCInitLogger::print_large_pages() { void GCInitLogger::print_numa() { if (UseNUMA) { log_info_p(gc, init)("NUMA Support: Enabled"); - log_info_p(gc, init)("NUMA Nodes: " SIZE_FORMAT, os::numa_get_groups_num()); + log_info_p(gc, init)("NUMA Nodes: %zu", os::numa_get_groups_num()); } else { log_info_p(gc, init)("NUMA Support: Disabled"); } @@ -91,11 +91,11 @@ void GCInitLogger::print_compressed_oops() { } void GCInitLogger::print_heap() { - log_info_p(gc, init)("Heap Min Capacity: " SIZE_FORMAT "%s", + log_info_p(gc, init)("Heap Min Capacity: %zu%s", byte_size_in_exact_unit(MinHeapSize), exact_unit_for_byte_size(MinHeapSize)); - log_info_p(gc, init)("Heap Initial Capacity: " SIZE_FORMAT "%s", + log_info_p(gc, init)("Heap Initial Capacity: %zu%s", byte_size_in_exact_unit(InitialHeapSize), exact_unit_for_byte_size(InitialHeapSize)); - log_info_p(gc, init)("Heap Max Capacity: " SIZE_FORMAT "%s", + log_info_p(gc, init)("Heap Max Capacity: %zu%s", byte_size_in_exact_unit(MaxHeapSize), exact_unit_for_byte_size(MaxHeapSize)); log_info_p(gc, init)("Pre-touch: %s", AlwaysPreTouch ? "Enabled" : "Disabled"); diff --git a/src/hotspot/share/gc/shared/gcTraceTime.cpp b/src/hotspot/share/gc/shared/gcTraceTime.cpp index af375039d12e2..2e4d42c8e167f 100644 --- a/src/hotspot/share/gc/shared/gcTraceTime.cpp +++ b/src/hotspot/share/gc/shared/gcTraceTime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -63,7 +63,7 @@ void GCTraceTimeLoggerImpl::log_end(Ticks end) { size_t used_before_m = _heap_usage_before / M; size_t used_m = heap->used() / M; size_t capacity_m = heap->capacity() / M; - out.print(" " SIZE_FORMAT "M->" SIZE_FORMAT "M(" SIZE_FORMAT "M)", used_before_m, used_m, capacity_m); + out.print(" %zuM->%zuM(%zuM)", used_before_m, used_m, capacity_m); } out.print_cr(" %.3fms", duration_in_ms); diff --git a/src/hotspot/share/gc/shared/gcVMOperations.cpp b/src/hotspot/share/gc/shared/gcVMOperations.cpp index 4cc75f4745991..ebf9146781439 100644 --- a/src/hotspot/share/gc/shared/gcVMOperations.cpp +++ b/src/hotspot/share/gc/shared/gcVMOperations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -110,7 +110,7 @@ bool VM_GC_Operation::doit_prologue() { if (!is_init_completed()) { vm_exit_during_initialization( err_msg("GC triggered before VM initialization completed. Try increasing " - "NewSize, current value " SIZE_FORMAT "%s.", + "NewSize, current value %zu%s.", byte_size_in_proper_unit(NewSize), proper_unit_for_byte_size(NewSize))); } @@ -259,7 +259,7 @@ void VM_CollectForMetadataAllocation::doit() { return; } - log_debug(gc)("After Metaspace GC failed to allocate size " SIZE_FORMAT, _size); + log_debug(gc)("After Metaspace GC failed to allocate size %zu", _size); if (GCLocker::is_active_and_needs_gc()) { set_gc_locked(); diff --git a/src/hotspot/share/gc/shared/genArguments.cpp b/src/hotspot/share/gc/shared/genArguments.cpp index c94ca56722f62..aca6d79499de2 100644 --- a/src/hotspot/share/gc/shared/genArguments.cpp +++ b/src/hotspot/share/gc/shared/genArguments.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -79,13 +79,13 @@ void GenArguments::initialize_heap_flags_and_sizes() { assert(GenAlignment != 0, "Generation alignment not set up properly"); assert(HeapAlignment >= GenAlignment, - "HeapAlignment: " SIZE_FORMAT " less than GenAlignment: " SIZE_FORMAT, + "HeapAlignment: %zu less than GenAlignment: %zu", HeapAlignment, GenAlignment); assert(GenAlignment % SpaceAlignment == 0, - "GenAlignment: " SIZE_FORMAT " not aligned by SpaceAlignment: " SIZE_FORMAT, + "GenAlignment: %zu not aligned by SpaceAlignment: %zu", GenAlignment, SpaceAlignment); assert(HeapAlignment % GenAlignment == 0, - "HeapAlignment: " SIZE_FORMAT " not aligned by GenAlignment: " SIZE_FORMAT, + "HeapAlignment: %zu not aligned by GenAlignment: %zu", HeapAlignment, GenAlignment); // All generational heaps have a young gen; handle those flags here @@ -128,8 +128,8 @@ void GenArguments::initialize_heap_flags_and_sizes() { // Make sure there is room for an old generation size_t smaller_max_new_size = MaxHeapSize - GenAlignment; if (FLAG_IS_CMDLINE(MaxNewSize)) { - log_warning(gc, ergo)("MaxNewSize (" SIZE_FORMAT "k) is equal to or greater than the entire " - "heap (" SIZE_FORMAT "k). A new max generation size of " SIZE_FORMAT "k will be used.", + log_warning(gc, ergo)("MaxNewSize (%zuk) is equal to or greater than the entire " + "heap (%zuk). A new max generation size of %zuk will be used.", MaxNewSize/K, MaxHeapSize/K, smaller_max_new_size/K); } FLAG_SET_ERGO(MaxNewSize, smaller_max_new_size); @@ -147,8 +147,8 @@ void GenArguments::initialize_heap_flags_and_sizes() { // At this point this should only happen if the user specifies a large NewSize and/or // a small (but not too small) MaxNewSize. if (FLAG_IS_CMDLINE(MaxNewSize)) { - log_warning(gc, ergo)("NewSize (" SIZE_FORMAT "k) is greater than the MaxNewSize (" SIZE_FORMAT "k). " - "A new max generation size of " SIZE_FORMAT "k will be used.", + log_warning(gc, ergo)("NewSize (%zuk) is greater than the MaxNewSize (%zuk). " + "A new max generation size of %zuk will be used.", NewSize/K, MaxNewSize/K, NewSize/K); } FLAG_SET_ERGO(MaxNewSize, NewSize); @@ -245,7 +245,7 @@ void GenArguments::initialize_size_info() { } } - log_trace(gc, heap)("1: Minimum young " SIZE_FORMAT " Initial young " SIZE_FORMAT " Maximum young " SIZE_FORMAT, + log_trace(gc, heap)("1: Minimum young %zu Initial young %zu Maximum young %zu", MinNewSize, initial_young_size, max_young_size); // At this point the minimum, initial and maximum sizes @@ -287,7 +287,7 @@ void GenArguments::initialize_size_info() { initial_young_size = desired_young_size; } - log_trace(gc, heap)("2: Minimum young " SIZE_FORMAT " Initial young " SIZE_FORMAT " Maximum young " SIZE_FORMAT, + log_trace(gc, heap)("2: Minimum young %zu Initial young %zu Maximum young %zu", MinNewSize, initial_young_size, max_young_size); } @@ -304,7 +304,7 @@ void GenArguments::initialize_size_info() { OldSize = initial_old_size; } - log_trace(gc, heap)("Minimum old " SIZE_FORMAT " Initial old " SIZE_FORMAT " Maximum old " SIZE_FORMAT, + log_trace(gc, heap)("Minimum old %zu Initial old %zu Maximum old %zu", MinOldSize, OldSize, MaxOldSize); DEBUG_ONLY(assert_size_info();) diff --git a/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp b/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp index 2ab5f330e734c..6148f4408cb70 100644 --- a/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp +++ b/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp @@ -57,8 +57,8 @@ static JVMFlag::Error MinPLABSizeBounds(const char* name, size_t value, bool ver if ((GCConfig::is_gc_selected(CollectedHeap::G1) || GCConfig::is_gc_selected(CollectedHeap::Parallel)) && (value < PLAB::min_size())) { JVMFlag::printError(verbose, - "%s (" SIZE_FORMAT ") must be " - "greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n", + "%s (%zu) must be " + "greater than or equal to ergonomic PLAB minimum size (%zu)\n", name, value, PLAB::min_size()); return JVMFlag::VIOLATES_CONSTRAINT; } @@ -70,8 +70,8 @@ JVMFlag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) { if ((GCConfig::is_gc_selected(CollectedHeap::G1) || GCConfig::is_gc_selected(CollectedHeap::Parallel)) && (value > PLAB::max_size())) { JVMFlag::printError(verbose, - "%s (" SIZE_FORMAT ") must be " - "less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n", + "%s (%zu) must be " + "less than or equal to ergonomic PLAB maximum size (%zu)\n", name, value, PLAB::max_size()); return JVMFlag::VIOLATES_CONSTRAINT; } @@ -124,7 +124,7 @@ static JVMFlag::Error CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(size_t maxHeap, if ((softRef > 0) && ((maxHeap / M) > (max_uintx / softRef))) { JVMFlag::printError(verbose, "Desired lifetime of SoftReferences cannot be expressed correctly. " - "MaxHeapSize (" SIZE_FORMAT ") or SoftRefLRUPolicyMSPerMB " + "MaxHeapSize (%zu) or SoftRefLRUPolicyMSPerMB " "(%zd) is too large\n", maxHeap, softRef); return JVMFlag::VIOLATES_CONSTRAINT; @@ -141,8 +141,8 @@ JVMFlag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose) { // value == 0 is handled by the range constraint. if (value > MarkStackSizeMax) { JVMFlag::printError(verbose, - "MarkStackSize (" SIZE_FORMAT ") must be " - "less than or equal to MarkStackSizeMax (" SIZE_FORMAT ")\n", + "MarkStackSize (%zu) must be " + "less than or equal to MarkStackSizeMax (%zu)\n", value, MarkStackSizeMax); return JVMFlag::VIOLATES_CONSTRAINT; } else { @@ -233,8 +233,8 @@ static JVMFlag::Error MaxSizeForAlignment(const char* name, size_t value, size_t size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1)); if (value > aligned_max) { JVMFlag::printError(verbose, - "%s (" SIZE_FORMAT ") must be " - "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n", + "%s (%zu) must be " + "less than or equal to aligned maximum value (%zu)\n", name, value, aligned_max); return JVMFlag::VIOLATES_CONSTRAINT; } @@ -288,8 +288,8 @@ JVMFlag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) { // Check for this by ensuring that MaxHeapSize plus the requested min base address still fit within max_uintx. if (UseCompressedOops && FLAG_IS_ERGO(MaxHeapSize) && (value > (max_uintx - MaxHeapSize))) { JVMFlag::printError(verbose, - "HeapBaseMinAddress (" SIZE_FORMAT ") or MaxHeapSize (" SIZE_FORMAT ") is too large. " - "Sum of them must be less than or equal to maximum of size_t (" SIZE_FORMAT ")\n", + "HeapBaseMinAddress (%zu) or MaxHeapSize (%zu) is too large. " + "Sum of them must be less than or equal to maximum of size_t (%zu)\n", value, MaxHeapSize, max_uintx); return JVMFlag::VIOLATES_CONSTRAINT; } @@ -312,15 +312,15 @@ JVMFlag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose) { // At least, alignment reserve area is needed. if (value < ThreadLocalAllocBuffer::alignment_reserve_in_bytes()) { JVMFlag::printError(verbose, - "MinTLABSize (" SIZE_FORMAT ") must be " - "greater than or equal to reserved area in TLAB (" SIZE_FORMAT ")\n", + "MinTLABSize (%zu) must be " + "greater than or equal to reserved area in TLAB (%zu)\n", value, ThreadLocalAllocBuffer::alignment_reserve_in_bytes()); return JVMFlag::VIOLATES_CONSTRAINT; } if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) { JVMFlag::printError(verbose, - "MinTLABSize (" SIZE_FORMAT ") must be " - "less than or equal to ergonomic TLAB maximum (" SIZE_FORMAT ")\n", + "MinTLABSize (%zu) must be " + "less than or equal to ergonomic TLAB maximum (%zu)\n", value, ThreadLocalAllocBuffer::max_size() * HeapWordSize); return JVMFlag::VIOLATES_CONSTRAINT; } @@ -332,15 +332,15 @@ JVMFlag::Error TLABSizeConstraintFunc(size_t value, bool verbose) { if (FLAG_IS_CMDLINE(TLABSize)) { if (value < MinTLABSize) { JVMFlag::printError(verbose, - "TLABSize (" SIZE_FORMAT ") must be " - "greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n", + "TLABSize (%zu) must be " + "greater than or equal to MinTLABSize (%zu)\n", value, MinTLABSize); return JVMFlag::VIOLATES_CONSTRAINT; } if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) { JVMFlag::printError(verbose, - "TLABSize (" SIZE_FORMAT ") must be " - "less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n", + "TLABSize (%zu) must be " + "less than or equal to ergonomic TLAB maximum size (%zu)\n", value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize)); return JVMFlag::VIOLATES_CONSTRAINT; } @@ -358,7 +358,7 @@ JVMFlag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) { if (refill_waste_limit > (max_uintx - value)) { JVMFlag::printError(verbose, "TLABWasteIncrement (%zu) must be " - "less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n", + "less than or equal to ergonomic TLAB waste increment maximum size(%zu)\n", value, (max_uintx - refill_waste_limit)); return JVMFlag::VIOLATES_CONSTRAINT; } @@ -371,7 +371,7 @@ JVMFlag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) { (value > (MaxHeapSize / SpaceAlignment))) { JVMFlag::printError(verbose, "SurvivorRatio (%zu) must be " - "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n", + "less than or equal to ergonomic SurvivorRatio maximum (%zu)\n", value, (MaxHeapSize / SpaceAlignment)); return JVMFlag::VIOLATES_CONSTRAINT; @@ -383,8 +383,8 @@ JVMFlag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) { JVMFlag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) { if (value > MaxMetaspaceSize) { JVMFlag::printError(verbose, - "MetaspaceSize (" SIZE_FORMAT ") must be " - "less than or equal to MaxMetaspaceSize (" SIZE_FORMAT ")\n", + "MetaspaceSize (%zu) must be " + "less than or equal to MaxMetaspaceSize (%zu)\n", value, MaxMetaspaceSize); return JVMFlag::VIOLATES_CONSTRAINT; } else { @@ -395,8 +395,8 @@ JVMFlag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) { if (value < MetaspaceSize) { JVMFlag::printError(verbose, - "MaxMetaspaceSize (" SIZE_FORMAT ") must be " - "greater than or equal to MetaspaceSize (" SIZE_FORMAT ")\n", + "MaxMetaspaceSize (%zu) must be " + "greater than or equal to MetaspaceSize (%zu)\n", value, MaxMetaspaceSize); return JVMFlag::VIOLATES_CONSTRAINT; } else { diff --git a/src/hotspot/share/gc/shared/memAllocator.cpp b/src/hotspot/share/gc/shared/memAllocator.cpp index f96ec50e3b0a2..a384e373e79fb 100644 --- a/src/hotspot/share/gc/shared/memAllocator.cpp +++ b/src/hotspot/share/gc/shared/memAllocator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -294,13 +294,13 @@ HeapWord* MemAllocator::mem_allocate_inside_tlab_slow(Allocation& allocation) co mem = Universe::heap()->allocate_new_tlab(min_tlab_size, new_tlab_size, &allocation._allocated_tlab_size); if (mem == nullptr) { assert(allocation._allocated_tlab_size == 0, - "Allocation failed, but actual size was updated. min: " SIZE_FORMAT - ", desired: " SIZE_FORMAT ", actual: " SIZE_FORMAT, + "Allocation failed, but actual size was updated. min: %zu" + ", desired: %zu, actual: %zu", min_tlab_size, new_tlab_size, allocation._allocated_tlab_size); return nullptr; } assert(allocation._allocated_tlab_size != 0, "Allocation succeeded but actual size not updated. mem at: " - PTR_FORMAT " min: " SIZE_FORMAT ", desired: " SIZE_FORMAT, + PTR_FORMAT " min: %zu, desired: %zu", p2i(mem), min_tlab_size, new_tlab_size); // ...and clear or zap just allocated TLAB, if needed. diff --git a/src/hotspot/share/gc/shared/oopStorage.cpp b/src/hotspot/share/gc/shared/oopStorage.cpp index 15ae2cf863254..4854db8bfae6f 100644 --- a/src/hotspot/share/gc/shared/oopStorage.cpp +++ b/src/hotspot/share/gc/shared/oopStorage.cpp @@ -579,7 +579,7 @@ bool OopStorage::expand_active_array() { assert_lock_strong(_allocation_mutex); ActiveArray* old_array = _active_array; size_t new_size = 2 * old_array->size(); - log_debug(oopstorage, blocks)("%s: expand active array " SIZE_FORMAT, + log_debug(oopstorage, blocks)("%s: expand active array %zu", name(), new_size); ActiveArray* new_array = ActiveArray::create(new_size, mem_tag(), @@ -1121,8 +1121,8 @@ bool OopStorage::BasicParState::claim_next_segment(IterationData* data) { bool OopStorage::BasicParState::finish_iteration(const IterationData* data) const { log_info(oopstorage, blocks, stats) - ("Parallel iteration on %s: blocks = " SIZE_FORMAT - ", processed = " SIZE_FORMAT " (%2.f%%)", + ("Parallel iteration on %s: blocks = %zu" + ", processed = %zu (%2.f%%)", _storage->name(), _block_count, data->_processed, percent_of(data->_processed, _block_count)); return false; @@ -1171,7 +1171,7 @@ void OopStorage::print_on(outputStream* st) const { double data_size = section_size * section_count; double alloc_percentage = percent_of((double)allocations, blocks * data_size); - st->print("%s: " SIZE_FORMAT " entries in " SIZE_FORMAT " blocks (%.F%%), " SIZE_FORMAT " bytes", + st->print("%s: %zu entries in %zu blocks (%.F%%), %zu bytes", name(), allocations, blocks, alloc_percentage, total_memory_usage()); if (_concurrent_iteration_count > 0) { st->print(", concurrent iteration active"); diff --git a/src/hotspot/share/gc/shared/plab.cpp b/src/hotspot/share/gc/shared/plab.cpp index ac2025e97a152..b38019b5f645b 100644 --- a/src/hotspot/share/gc/shared/plab.cpp +++ b/src/hotspot/share/gc/shared/plab.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -65,7 +65,7 @@ PLAB::PLAB(size_t desired_plab_sz_) : _end(nullptr), _hard_end(nullptr), _allocated(0), _wasted(0), _undo_wasted(0) { assert(min_size() > CollectedHeap::lab_alignment_reserve(), - "Minimum PLAB size " SIZE_FORMAT " must be larger than alignment reserve " SIZE_FORMAT " " + "Minimum PLAB size %zu must be larger than alignment reserve %zu " "to be able to contain objects", min_size(), CollectedHeap::lab_alignment_reserve()); } diff --git a/src/hotspot/share/gc/shared/preservedMarks.cpp b/src/hotspot/share/gc/shared/preservedMarks.cpp index bc241fb5daf45..e2c4f4d8704c2 100644 --- a/src/hotspot/share/gc/shared/preservedMarks.cpp +++ b/src/hotspot/share/gc/shared/preservedMarks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -67,10 +67,10 @@ void PreservedMarks::restore_and_increment(volatile size_t* const total_size_add #ifndef PRODUCT void PreservedMarks::assert_empty() { - assert(_stack.is_empty(), "stack expected to be empty, size = " SIZE_FORMAT, + assert(_stack.is_empty(), "stack expected to be empty, size = %zu", _stack.size()); assert(_stack.cache_size() == 0, - "stack expected to have no cached segments, cache size = " SIZE_FORMAT, + "stack expected to have no cached segments, cache size = %zu", _stack.cache_size()); } #endif // ndef PRODUCT diff --git a/src/hotspot/share/gc/shared/pretouchTask.cpp b/src/hotspot/share/gc/shared/pretouchTask.cpp index 427d14fd4e7e3..916ec34fa5d73 100644 --- a/src/hotspot/share/gc/shared/pretouchTask.cpp +++ b/src/hotspot/share/gc/shared/pretouchTask.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -43,7 +43,7 @@ PretouchTask::PretouchTask(const char* task_name, _chunk_size(chunk_size) { assert(chunk_size >= page_size, - "Chunk size " SIZE_FORMAT " is smaller than page size " SIZE_FORMAT, + "Chunk size %zu is smaller than page size %zu", chunk_size, page_size); } @@ -79,12 +79,12 @@ void PretouchTask::pretouch(const char* task_name, char* start_address, char* en size_t num_chunks = ((total_bytes - 1) / chunk_size) + 1; uint num_workers = (uint)MIN2(num_chunks, (size_t)pretouch_workers->max_workers()); - log_debug(gc, heap)("Running %s with %u workers for " SIZE_FORMAT " work units pre-touching " SIZE_FORMAT "B.", + log_debug(gc, heap)("Running %s with %u workers for %zu work units pre-touching %zuB.", task.name(), num_workers, num_chunks, total_bytes); pretouch_workers->run_task(&task, num_workers); } else { - log_debug(gc, heap)("Running %s pre-touching " SIZE_FORMAT "B.", + log_debug(gc, heap)("Running %s pre-touching %zuB.", task.name(), total_bytes); task.work(0); } diff --git a/src/hotspot/share/gc/shared/referenceProcessor.cpp b/src/hotspot/share/gc/shared/referenceProcessor.cpp index ff7530f2d32f3..e1df82fc7f460 100644 --- a/src/hotspot/share/gc/shared/referenceProcessor.cpp +++ b/src/hotspot/share/gc/shared/referenceProcessor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -175,7 +175,7 @@ size_t ReferenceProcessor::total_count(DiscoveredList lists[]) const { #ifdef ASSERT void ReferenceProcessor::verify_total_count_zero(DiscoveredList lists[], const char* type) { size_t count = total_count(lists); - assert(count == 0, "%ss must be empty but has " SIZE_FORMAT " elements", type, count); + assert(count == 0, "%ss must be empty but has %zu elements", type, count); } #endif @@ -365,7 +365,7 @@ size_t ReferenceProcessor::process_discovered_list_work(DiscoveredList& refs_ refs_list.clear(); } - log_develop_trace(gc, ref)(" Dropped " SIZE_FORMAT " active Refs out of " SIZE_FORMAT + log_develop_trace(gc, ref)(" Dropped %zu active Refs out of %zu" " Refs in discovered list " PTR_FORMAT, iter.removed(), iter.processed(), p2i(&refs_list)); return iter.removed(); @@ -559,10 +559,10 @@ void ReferenceProcessor::log_reflist(const char* prefix, DiscoveredList list[], LogStream ls(lt); ls.print("%s", prefix); for (uint i = 0; i < num_active_queues; i++) { - ls.print(SIZE_FORMAT " ", list[i].length()); + ls.print("%zu ", list[i].length()); total += list[i].length(); } - ls.print_cr("(" SIZE_FORMAT ")", total); + ls.print_cr("(%zu)", total); } #ifndef PRODUCT @@ -574,7 +574,7 @@ void ReferenceProcessor::log_reflist_counts(DiscoveredList ref_lists[], uint num log_reflist("", ref_lists, num_active_queues); #ifdef ASSERT for (uint i = num_active_queues; i < _max_num_queues; i++) { - assert(ref_lists[i].length() == 0, SIZE_FORMAT " unexpected References in %u", + assert(ref_lists[i].length() == 0, "%zu unexpected References in %u", ref_lists[i].length(), i); } #endif @@ -1095,7 +1095,7 @@ bool ReferenceProcessor::preclean_discovered_reflist(DiscoveredList& refs_lis } if (iter.processed() > 0) { - log_develop_trace(gc, ref)(" Dropped " SIZE_FORMAT " Refs out of " SIZE_FORMAT " Refs in discovered list " PTR_FORMAT, + log_develop_trace(gc, ref)(" Dropped %zu Refs out of %zu Refs in discovered list " PTR_FORMAT, iter.removed(), iter.processed(), p2i(&refs_list)); } return false; diff --git a/src/hotspot/share/gc/shared/satbMarkQueue.cpp b/src/hotspot/share/gc/shared/satbMarkQueue.cpp index a0efcc8e66ae8..32580cc8faff2 100644 --- a/src/hotspot/share/gc/shared/satbMarkQueue.cpp +++ b/src/hotspot/share/gc/shared/satbMarkQueue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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,8 +54,8 @@ static void print_satb_buffer(const char* name, void** buf, size_t index, size_t capacity) { - tty->print_cr(" SATB BUFFER [%s] buf: " PTR_FORMAT " index: " SIZE_FORMAT - " capacity: " SIZE_FORMAT, + tty->print_cr(" SATB BUFFER [%s] buf: " PTR_FORMAT " index: %zu" + " capacity: %zu", name, p2i(buf), index, capacity); } diff --git a/src/hotspot/share/gc/shared/taskqueue.cpp b/src/hotspot/share/gc/shared/taskqueue.cpp index 61e2899b6738d..06b1488ca9f44 100644 --- a/src/hotspot/share/gc/shared/taskqueue.cpp +++ b/src/hotspot/share/gc/shared/taskqueue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -75,10 +75,9 @@ void TaskQueueStats::print_header(unsigned int line, outputStream* const stream, void TaskQueueStats::print(outputStream* stream, unsigned int width) const { - #define FMT SIZE_FORMAT_W(*) - stream->print(FMT, width, _stats[0]); + stream->print("%*zu", width, _stats[0]); for (unsigned int i = 1; i < last_stat_id; ++i) { - stream->print(" " FMT, width, _stats[i]); + stream->print(" %*zu", width, _stats[i]); } #undef FMT } diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp index e967a65555a15..cf9e0f559d453 100644 --- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp +++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -164,7 +164,7 @@ void ThreadLocalAllocBuffer::resize() { size_t aligned_new_size = align_object_size(new_size); log_trace(gc, tlab)("TLAB new size: thread: " PTR_FORMAT " [id: %2d]" - " refills %d alloc: %8.6f desired_size: " SIZE_FORMAT " -> " SIZE_FORMAT, + " refills %d alloc: %8.6f desired_size: %zu -> %zu", p2i(thread()), thread()->osthread()->thread_id(), _target_refills, _allocation_fraction.average(), desired_size(), aligned_new_size); @@ -263,7 +263,7 @@ void ThreadLocalAllocBuffer::startup_initialization() { guarantee(Thread::current()->is_Java_thread(), "tlab initialization thread not Java thread"); Thread::current()->tlab().initialize(); - log_develop_trace(gc, tlab)("TLAB min: " SIZE_FORMAT " initial: " SIZE_FORMAT " max: " SIZE_FORMAT, + log_develop_trace(gc, tlab)("TLAB min: %zu initial: %zu max: %zu", min_size(), Thread::current()->tlab().initial_desired_size(), max_size()); } @@ -299,8 +299,8 @@ void ThreadLocalAllocBuffer::print_stats(const char* tag) { double waste_percent = percent_of(waste, _allocated_size); size_t tlab_used = Universe::heap()->tlab_used(thrd); log.trace("TLAB: %s thread: " PTR_FORMAT " [id: %2d]" - " desired_size: " SIZE_FORMAT "KB" - " slow allocs: %d refill waste: " SIZE_FORMAT "B" + " desired_size: %zuKB" + " slow allocs: %d refill waste: %zuB" " alloc:%8.5f %8.0fKB refills: %d waste %4.1f%% gc: %dB" " slow: %dB", tag, p2i(thrd), thrd->osthread()->thread_id(), @@ -451,8 +451,8 @@ void ThreadLocalAllocStats::publish() { const double waste_percent = percent_of(waste, _total_allocations); log_debug(gc, tlab)("TLAB totals: thrds: %d refills: %d max: %d" " slow allocs: %d max %d waste: %4.1f%%" - " gc: " SIZE_FORMAT "B max: " SIZE_FORMAT "B" - " slow: " SIZE_FORMAT "B max: " SIZE_FORMAT "B", + " gc: %zuB max: %zuB" + " slow: %zuB max: %zuB", _allocating_threads, _total_refills, _max_refills, _total_slow_allocations, _max_slow_allocations, waste_percent, _total_gc_waste * HeapWordSize, _max_gc_waste * HeapWordSize, diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp index 6910d9c186061..32a830a2bb138 100644 --- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp +++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -61,11 +61,11 @@ inline size_t ThreadLocalAllocBuffer::compute_size(size_t obj_size) { // Make sure there's enough room for object and filler int[]. if (new_tlab_size < compute_min_size(obj_size)) { // If there isn't enough room for the allocation, return failure. - log_trace(gc, tlab)("ThreadLocalAllocBuffer::compute_size(" SIZE_FORMAT ") returns failure", + log_trace(gc, tlab)("ThreadLocalAllocBuffer::compute_size(%zu) returns failure", obj_size); return 0; } - log_trace(gc, tlab)("ThreadLocalAllocBuffer::compute_size(" SIZE_FORMAT ") returns " SIZE_FORMAT, + log_trace(gc, tlab)("ThreadLocalAllocBuffer::compute_size(%zu) returns %zu", obj_size, new_tlab_size); return new_tlab_size; } @@ -86,9 +86,9 @@ void ThreadLocalAllocBuffer::record_slow_allocation(size_t obj_size) { _slow_allocations++; log_develop_trace(gc, tlab)("TLAB: %s thread: " PTR_FORMAT " [id: %2d]" - " obj: " SIZE_FORMAT - " free: " SIZE_FORMAT - " waste: " SIZE_FORMAT, + " obj: %zu" + " free: %zu" + " waste: %zu", "slow", p2i(thread()), thread()->osthread()->thread_id(), obj_size, free(), refill_waste_limit()); } diff --git a/src/hotspot/share/gc/shared/workerDataArray.cpp b/src/hotspot/share/gc/shared/workerDataArray.cpp index a16e3219255df..aa1c7623704c6 100644 --- a/src/hotspot/share/gc/shared/workerDataArray.cpp +++ b/src/hotspot/share/gc/shared/workerDataArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, 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 @@ -49,9 +49,9 @@ void WorkerDataArray::WDAPrinter::summary(outputStream* out, double min, template <> void WorkerDataArray::WDAPrinter::summary(outputStream* out, size_t min, double avg, size_t max, size_t diff, size_t sum, bool print_sum) { - out->print(" Min: " SIZE_FORMAT ", Avg: %4.1lf, Max: " SIZE_FORMAT ", Diff: " SIZE_FORMAT, min, avg, max, diff); + out->print(" Min: %zu, Avg: %4.1lf, Max: %zu, Diff: %zu", min, avg, max, diff); if (print_sum) { - out->print(", Sum: " SIZE_FORMAT, sum); + out->print(", Sum: %zu", sum); } } @@ -75,7 +75,7 @@ void WorkerDataArray::WDAPrinter::details(const WorkerDataArray* for (uint i = 0; i < phase->_length; ++i) { size_t value = phase->get(i); if (value != phase->uninitialized()) { - out->print(" " SIZE_FORMAT, phase->get(i)); + out->print(" %zu", phase->get(i)); } else { out->print(" -"); } From cfe70ebcb3a9fadceac5eccdc1f3353d0d74c235 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 15 Jan 2025 17:15:05 +0000 Subject: [PATCH 13/47] 8342550: Log warning for using JDK1.1 compatible time zone IDs for future removal Reviewed-by: jlu, joehw, iris --- .../share/classes/java/util/TimeZone.java | 8 ++- .../cldr/CLDRTimeZoneNameProviderImpl.java | 9 ++-- .../java/util/TimeZone/ThreeLetterZoneID.java | 49 +++++++++++++++++++ 3 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 test/jdk/java/util/TimeZone/ThreeLetterZoneID.java diff --git a/src/java.base/share/classes/java/util/TimeZone.java b/src/java.base/share/classes/java/util/TimeZone.java index f0b122418c9ff..7c7e24814c368 100644 --- a/src/java.base/share/classes/java/util/TimeZone.java +++ b/src/java.base/share/classes/java/util/TimeZone.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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,6 +46,7 @@ import sun.util.calendar.ZoneInfo; import sun.util.calendar.ZoneInfoFile; import sun.util.locale.provider.TimeZoneNameUtility; +import sun.util.logging.PlatformLogger; /** * {@code TimeZone} represents a time zone offset, and also figures out daylight @@ -596,6 +597,11 @@ private ZoneId toZoneId0() { } private static TimeZone getTimeZone(String ID, boolean fallback) { + if (ZoneId.SHORT_IDS.containsKey(ID)) { + PlatformLogger.getLogger(TimeZone.class.getName()) + .warning("Use of the three-letter time zone ID \"%s\" is deprecated and it will be removed in a future release" + .formatted(ID)); + } TimeZone tz = ZoneInfo.getTimeZone(ID); if (tz == null) { tz = parseCustomTimeZone(ID); diff --git a/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java b/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java index 47dacd21aae1f..9ff28e11e51ee 100644 --- a/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java +++ b/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -35,7 +35,8 @@ import java.util.Objects; import java.util.ResourceBundle; import java.util.Set; -import java.util.TimeZone; + +import sun.util.calendar.ZoneInfo; import sun.util.calendar.ZoneInfoFile; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleResources; @@ -93,7 +94,7 @@ protected String[] getDisplayNameArray(String id, Locale locale) { case "": // Fill in empty elements deriveFallbackName(namesSuper, i, locale, - TimeZone.getTimeZone(id).toZoneId().getRules().isFixedOffset()); + ZoneInfo.getTimeZone(id).toZoneId().getRules().isFixedOffset()); break; case NO_INHERITANCE_MARKER: // CLDR's "no inheritance marker" @@ -131,7 +132,7 @@ protected String[][] getZoneStrings(Locale locale) { // Derive fallback time zone name according to LDML's logic private void deriveFallbackNames(String[] names, Locale locale) { - boolean noDST = TimeZone.getTimeZone(names[0]).toZoneId().getRules().isFixedOffset(); + boolean noDST = ZoneInfo.getTimeZone(names[0]).toZoneId().getRules().isFixedOffset(); for (int i = INDEX_STD_LONG; i <= INDEX_GEN_SHORT; i++) { deriveFallbackName(names, i, locale, noDST); diff --git a/test/jdk/java/util/TimeZone/ThreeLetterZoneID.java b/test/jdk/java/util/TimeZone/ThreeLetterZoneID.java new file mode 100644 index 0000000000000..5df3ebe5bf0f1 --- /dev/null +++ b/test/jdk/java/util/TimeZone/ThreeLetterZoneID.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8342550 + * @summary Three-letter time zone IDs should output a deprecated warning + * message. + * @library /test/lib + * @build jdk.test.lib.process.ProcessTools + * @run main ThreeLetterZoneID + */ +import java.util.TimeZone; +import jdk.test.lib.process.ProcessTools; + +public class ThreeLetterZoneID { + public static void main(String... args) throws Exception { + if (args.length > 0) { + TimeZone.getTimeZone("PST"); + } else { + checkWarningMessage(); + } + } + + public static void checkWarningMessage() throws Exception { + ProcessTools.executeTestJava("ThreeLetterZoneID", "dummy") + .shouldContain("Use of the three-letter time zone ID \"PST\" is deprecated and it will be removed in a future release"); + } +} From 764d70b7df18e288582e616c62b0d7078f1ff3aa Mon Sep 17 00:00:00 2001 From: William Kemper Date: Wed, 15 Jan 2025 17:49:38 +0000 Subject: [PATCH 14/47] 8344049: Shenandoah: Eliminate init-update-refs safepoint 8344050: Shenandoah: Retire GC LABs concurrently 8344055: Shenandoah: Make all threads use local gc state Reviewed-by: ysr, kdnilsen --- .../shenandoahBarrierSet.inline.hpp | 11 +- .../shenandoahBarrierSetClone.inline.hpp | 3 +- .../gc/shenandoah/shenandoahConcurrentGC.cpp | 43 ++--- .../share/gc/shenandoah/shenandoahFreeSet.cpp | 2 + .../share/gc/shenandoah/shenandoahHeap.cpp | 149 +++++++++++++----- .../share/gc/shenandoah/shenandoahHeap.hpp | 35 +++- .../gc/shenandoah/shenandoahHeap.inline.hpp | 36 ++--- .../shenandoahHeapRegionCounters.cpp | 4 +- .../shenandoah/shenandoahThreadLocalData.hpp | 10 +- .../gc/shenandoah/shenandoahVMOperations.cpp | 14 +- .../gc/shenandoah/shenandoahVerifier.cpp | 2 +- 11 files changed, 193 insertions(+), 116 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp index f3ce9418d35de..58522871338b7 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp @@ -67,8 +67,7 @@ inline oop ShenandoahBarrierSet::load_reference_barrier_mutator(oop obj, T* load oop fwd = resolve_forwarded_not_null_mutator(obj); if (obj == fwd) { - assert(_heap->is_evacuation_in_progress(), - "evac should be in progress"); + assert(_heap->is_evacuation_in_progress(), "evac should be in progress"); Thread* const t = Thread::current(); ShenandoahEvacOOMScope scope(t); fwd = _heap->evacuate_object(obj, t); @@ -86,8 +85,8 @@ inline oop ShenandoahBarrierSet::load_reference_barrier(oop obj) { if (!ShenandoahLoadRefBarrier) { return obj; } - if (_heap->has_forwarded_objects() && - _heap->in_collection_set(obj)) { // Subsumes null-check + if (_heap->has_forwarded_objects() && _heap->in_collection_set(obj)) { + // Subsumes null-check assert(obj != nullptr, "cset check must have subsumed null-check"); oop fwd = resolve_forwarded_not_null(obj); if (obj == fwd && _heap->is_evacuation_in_progress()) { @@ -381,7 +380,7 @@ void ShenandoahBarrierSet::arraycopy_work(T* src, size_t count) { // this barrier will be called with ENQUEUE=true and HAS_FWD=false, even though the young generation // may have forwarded objects. In this case, the `arraycopy_work` is first called with HAS_FWD=true and // ENQUEUE=false. - assert(HAS_FWD == _heap->has_forwarded_objects() || (_heap->gc_state() & ShenandoahHeap::OLD_MARKING) != 0, + assert(HAS_FWD == _heap->has_forwarded_objects() || _heap->is_concurrent_old_mark_in_progress(), "Forwarded object status is sane"); // This function cannot be called to handle marking and evacuation at the same time (they operate on // different sides of the copy). @@ -418,7 +417,7 @@ void ShenandoahBarrierSet::arraycopy_barrier(T* src, T* dst, size_t count) { return; } - int gc_state = _heap->gc_state(); + char gc_state = ShenandoahThreadLocalData::gc_state(Thread::current()); if ((gc_state & ShenandoahHeap::EVACUATION) != 0) { arraycopy_evacuation(src, count); } else if ((gc_state & ShenandoahHeap::UPDATEREFS) != 0) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetClone.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetClone.inline.hpp index 3b7bf9864deb0..8b83cc6b32cf9 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetClone.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetClone.inline.hpp @@ -95,8 +95,7 @@ void ShenandoahBarrierSet::clone_barrier(oop obj) { assert(ShenandoahCloneBarrier, "only get here with clone barriers enabled"); shenandoah_assert_correct(nullptr, obj); - int gc_state = _heap->gc_state(); - if ((gc_state & ShenandoahHeap::EVACUATION) != 0) { + if (_heap->is_evacuation_in_progress()) { clone_evacuation(obj); } else { clone_update(obj); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp index b1c2e72ef82b6..bd703cdb96f00 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp @@ -192,8 +192,14 @@ bool ShenandoahConcurrentGC::collect(GCCause::Cause cause) { return false; } + // Evacuation is complete, retire gc labs + heap->concurrent_prepare_for_update_refs(); + // Perform update-refs phase. - vmop_entry_init_updaterefs(); + if (ShenandoahVerify || ShenandoahPacing) { + vmop_entry_init_updaterefs(); + } + entry_updaterefs(); if (check_cancellation_and_abort(ShenandoahDegenPoint::_degenerated_updaterefs)) { return false; @@ -748,10 +754,6 @@ void ShenandoahConcurrentGC::op_final_mark() { heap->verifier()->verify_after_concmark(); } } - - if (VerifyAfterGC) { - Universe::verify(); - } } } } @@ -920,8 +922,8 @@ class ShenandoahConcurrentWeakRootsEvacUpdateTask : public WorkerTask { } // If we are going to perform concurrent class unloading later on, we need to - // cleanup the weak oops in CLD and determinate nmethod's unloading state, so that we - // can cleanup immediate garbage sooner. + // clean up the weak oops in CLD and determine nmethod's unloading state, so that we + // can clean up immediate garbage sooner. if (ShenandoahHeap::heap()->unload_classes()) { // Applies ShenandoahIsCLDAlive closure to CLDs, native barrier will either null the // CLD's holder or evacuate it. @@ -947,21 +949,10 @@ void ShenandoahConcurrentGC::op_weak_roots() { ShenandoahHeap* const heap = ShenandoahHeap::heap(); assert(heap->is_concurrent_weak_root_in_progress(), "Only during this phase"); // Concurrent weak root processing - { - ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_roots_work); - ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_roots_work); - ShenandoahConcurrentWeakRootsEvacUpdateTask task(ShenandoahPhaseTimings::conc_weak_roots_work); - heap->workers()->run_task(&task); - } - - // Perform handshake to flush out dead oops - { - ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_roots_rendezvous); - heap->rendezvous_threads("Shenandoah Concurrent Weak Roots"); - } - // We can only toggle concurrent_weak_root_in_progress flag - // at a safepoint, so that mutators see a consistent - // value. The flag will be cleared at the next safepoint. + ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_roots_work); + ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_roots_work); + ShenandoahConcurrentWeakRootsEvacUpdateTask task(ShenandoahPhaseTimings::conc_weak_roots_work); + heap->workers()->run_task(&task); } void ShenandoahConcurrentGC::op_class_unloading() { @@ -1058,10 +1049,6 @@ void ShenandoahConcurrentGC::op_evacuate() { void ShenandoahConcurrentGC::op_init_updaterefs() { ShenandoahHeap* const heap = ShenandoahHeap::heap(); - heap->set_evacuation_in_progress(false); - heap->set_concurrent_weak_root_in_progress(false); - heap->prepare_update_heap_references(true /*concurrent*/); - heap->set_update_refs_in_progress(true); if (ShenandoahVerify) { heap->verifier()->verify_before_updaterefs(); } @@ -1178,6 +1165,10 @@ void ShenandoahConcurrentGC::op_final_roots() { ShenandoahGenerationalHeap::heap()->update_region_ages(_generation->complete_marking_context()); } } + + if (VerifyAfterGC) { + Universe::verify(); + } } void ShenandoahConcurrentGC::op_cleanup_complete() { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp index d23d6fa24c5df..b080002a92987 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp @@ -999,6 +999,8 @@ HeapWord* ShenandoahFreeSet::allocate_aligned_plab(size_t size, ShenandoahAllocR HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, ShenandoahAllocRequest& req, bool& in_new_region) { assert (has_alloc_capacity(r), "Performance: should avoid full regions on this path: " SIZE_FORMAT, r->index()); if (_heap->is_concurrent_weak_root_in_progress() && r->is_trash()) { + // We cannot use this region for allocation when weak roots are in progress because the collector may need + // to reference unmarked oops during concurrent classunloading. return nullptr; } HeapWord* result = nullptr; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index d75a9234a63d2..018540b33b70b 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -102,6 +102,7 @@ #include "runtime/orderAccess.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/stackWatermarkSet.hpp" +#include "runtime/threads.hpp" #include "runtime/vmThread.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/events.hpp" @@ -644,7 +645,6 @@ class ShenandoahInitWorkerGCLABClosure : public ThreadClosure { public: void do_thread(Thread* thread) { assert(thread != nullptr, "Sanity"); - assert(thread->is_Worker_thread(), "Only worker thread expected"); ShenandoahThreadLocalData::initialize_gclab(thread); } }; @@ -663,6 +663,9 @@ void ShenandoahHeap::post_initialize() { // gclab can not be initialized early during VM startup, as it can not determinate its max_size. // Now, we will let WorkerThreads to initialize gclab when new worker is created. _workers->set_initialize_gclab(); + + // Note that the safepoint workers may require gclabs if the threads are used to create a heap dump + // during a concurrent evacuation phase. if (_safepoint_workers != nullptr) { _safepoint_workers->threads_do(&init_gclabs); _safepoint_workers->set_initialize_gclab(); @@ -1190,11 +1193,86 @@ class ShenandoahEvacuationTask : public WorkerTask { } }; +class ShenandoahRetireGCLABClosure : public ThreadClosure { +private: + bool const _resize; +public: + explicit ShenandoahRetireGCLABClosure(bool resize) : _resize(resize) {} + void do_thread(Thread* thread) override { + PLAB* gclab = ShenandoahThreadLocalData::gclab(thread); + assert(gclab != nullptr, "GCLAB should be initialized for %s", thread->name()); + gclab->retire(); + if (_resize && ShenandoahThreadLocalData::gclab_size(thread) > 0) { + ShenandoahThreadLocalData::set_gclab_size(thread, 0); + } + + if (ShenandoahHeap::heap()->mode()->is_generational()) { + PLAB* plab = ShenandoahThreadLocalData::plab(thread); + assert(plab != nullptr, "PLAB should be initialized for %s", thread->name()); + + // There are two reasons to retire all plabs between old-gen evacuation passes. + // 1. We need to make the plab memory parsable by remembered-set scanning. + // 2. We need to establish a trustworthy UpdateWaterMark value within each old-gen heap region + ShenandoahGenerationalHeap::heap()->retire_plab(plab, thread); + if (_resize && ShenandoahThreadLocalData::plab_size(thread) > 0) { + ShenandoahThreadLocalData::set_plab_size(thread, 0); + } + } + } +}; + +class ShenandoahGCStatePropagator : public ThreadClosure { +public: + explicit ShenandoahGCStatePropagator(char gc_state) : _gc_state(gc_state) {} + + void do_thread(Thread* thread) override { + ShenandoahThreadLocalData::set_gc_state(thread, _gc_state); + } +private: + char _gc_state; +}; + +class ShenandoahPrepareForUpdateRefs : public HandshakeClosure { +public: + explicit ShenandoahPrepareForUpdateRefs(char gc_state) : + HandshakeClosure("Shenandoah Prepare for Update Refs"), + _retire(ResizeTLAB), _propagator(gc_state) {} + + void do_thread(Thread* thread) override { + _propagator.do_thread(thread); + if (ShenandoahThreadLocalData::gclab(thread) != nullptr) { + _retire.do_thread(thread); + } + } +private: + ShenandoahRetireGCLABClosure _retire; + ShenandoahGCStatePropagator _propagator; +}; + void ShenandoahHeap::evacuate_collection_set(bool concurrent) { ShenandoahEvacuationTask task(this, _collection_set, concurrent); workers()->run_task(&task); } +void ShenandoahHeap::concurrent_prepare_for_update_refs() { + // It's possible that evacuation succeeded, but we could still be cancelled when we get here. + // A cancellation at this point means the degenerated cycle must resume from update-refs. + set_gc_state_concurrent(EVACUATION, false); + set_gc_state_concurrent(WEAK_ROOTS, false); + set_gc_state_concurrent(UPDATEREFS, true); + + // This will propagate the gc state and retire gclabs and plabs for threads that require it. + ShenandoahPrepareForUpdateRefs prepare_for_update_refs(_gc_state.raw_value()); + + // The handshake won't touch worker threads (or control thread, or VM thread), so do those separately. + Threads::non_java_threads_do(&prepare_for_update_refs); + + // Now retire gclabs and plabs and propagate gc_state for mutator threads + Handshake::execute(&prepare_for_update_refs); + + _update_refs_iterator.reset(); +} + oop ShenandoahHeap::evacuate_object(oop p, Thread* thread) { assert(thread == Thread::current(), "Expected thread parameter to be current thread."); if (ShenandoahThreadLocalData::is_oom_during_evac(thread)) { @@ -1349,34 +1427,6 @@ class ShenandoahCheckCleanGCLABClosure : public ThreadClosure { } }; -class ShenandoahRetireGCLABClosure : public ThreadClosure { -private: - bool const _resize; -public: - ShenandoahRetireGCLABClosure(bool resize) : _resize(resize) {} - void do_thread(Thread* thread) { - PLAB* gclab = ShenandoahThreadLocalData::gclab(thread); - assert(gclab != nullptr, "GCLAB should be initialized for %s", thread->name()); - gclab->retire(); - if (_resize && ShenandoahThreadLocalData::gclab_size(thread) > 0) { - ShenandoahThreadLocalData::set_gclab_size(thread, 0); - } - - if (ShenandoahHeap::heap()->mode()->is_generational()) { - PLAB* plab = ShenandoahThreadLocalData::plab(thread); - assert(plab != nullptr, "PLAB should be initialized for %s", thread->name()); - - // There are two reasons to retire all plabs between old-gen evacuation passes. - // 1. We need to make the plab memory parsable by remembered-set scanning. - // 2. We need to establish a trustworthy UpdateWaterMark value within each old-gen heap region - ShenandoahGenerationalHeap::heap()->retire_plab(plab, thread); - if (_resize && ShenandoahThreadLocalData::plab_size(thread) > 0) { - ShenandoahThreadLocalData::set_plab_size(thread, 0); - } - } - } -}; - void ShenandoahHeap::labs_make_parsable() { assert(UseTLAB, "Only call with UseTLAB"); @@ -1389,6 +1439,10 @@ void ShenandoahHeap::labs_make_parsable() { } workers()->threads_do(&cl); + + if (safepoint_workers() != nullptr) { + safepoint_workers()->threads_do(&cl); + } } void ShenandoahHeap::tlabs_retire(bool resize) { @@ -1424,6 +1478,7 @@ void ShenandoahHeap::gclabs_retire(bool resize) { for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) { cl.do_thread(t); } + workers()->threads_do(&cl); if (safepoint_workers() != nullptr) { @@ -1933,23 +1988,25 @@ void ShenandoahHeap::prepare_update_heap_references(bool concurrent) { _update_refs_iterator.reset(); } -void ShenandoahHeap::propagate_gc_state_to_java_threads() { +void ShenandoahHeap::propagate_gc_state_to_all_threads() { assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at Shenandoah safepoint"); if (_gc_state_changed) { + ShenandoahGCStatePropagator propagator(_gc_state.raw_value()); + Threads::threads_do(&propagator); _gc_state_changed = false; - char state = gc_state(); - for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) { - ShenandoahThreadLocalData::set_gc_state(t, state); - } } } -void ShenandoahHeap::set_gc_state(uint mask, bool value) { +void ShenandoahHeap::set_gc_state_at_safepoint(uint mask, bool value) { assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at Shenandoah safepoint"); _gc_state.set_cond(mask, value); _gc_state_changed = true; } +void ShenandoahHeap::set_gc_state_concurrent(uint mask, bool value) { + _gc_state.set_cond(mask, value); +} + void ShenandoahHeap::set_concurrent_young_mark_in_progress(bool in_progress) { uint mask; assert(!has_forwarded_objects(), "Young marking is not concurrent with evacuation"); @@ -1961,7 +2018,7 @@ void ShenandoahHeap::set_concurrent_young_mark_in_progress(bool in_progress) { } else { mask = MARKING | YOUNG_MARKING; } - set_gc_state(mask, in_progress); + set_gc_state_at_safepoint(mask, in_progress); manage_satb_barrier(in_progress); } @@ -1977,9 +2034,9 @@ void ShenandoahHeap::set_concurrent_old_mark_in_progress(bool in_progress) { if (!in_progress && is_concurrent_young_mark_in_progress()) { // If young-marking is in progress when we turn off OLD_MARKING, leave MARKING (and YOUNG_MARKING) on assert(_gc_state.is_set(MARKING), "concurrent_young_marking_in_progress implies MARKING"); - set_gc_state(OLD_MARKING, in_progress); + set_gc_state_at_safepoint(OLD_MARKING, in_progress); } else { - set_gc_state(MARKING | OLD_MARKING, in_progress); + set_gc_state_at_safepoint(MARKING | OLD_MARKING, in_progress); } manage_satb_barrier(in_progress); } @@ -2006,7 +2063,7 @@ void ShenandoahHeap::manage_satb_barrier(bool active) { void ShenandoahHeap::set_evacuation_in_progress(bool in_progress) { assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Only call this at safepoint"); - set_gc_state(EVACUATION, in_progress); + set_gc_state_at_safepoint(EVACUATION, in_progress); } void ShenandoahHeap::set_concurrent_strong_root_in_progress(bool in_progress) { @@ -2018,7 +2075,7 @@ void ShenandoahHeap::set_concurrent_strong_root_in_progress(bool in_progress) { } void ShenandoahHeap::set_concurrent_weak_root_in_progress(bool cond) { - set_gc_state(WEAK_ROOTS, cond); + set_gc_state_at_safepoint(WEAK_ROOTS, cond); } GCTracer* ShenandoahHeap::tracer() { @@ -2165,7 +2222,7 @@ void ShenandoahHeap::parallel_cleaning(bool full_gc) { } void ShenandoahHeap::set_has_forwarded_objects(bool cond) { - set_gc_state(HAS_FORWARDED, cond); + set_gc_state_at_safepoint(HAS_FORWARDED, cond); } void ShenandoahHeap::set_unload_classes(bool uc) { @@ -2205,7 +2262,7 @@ void ShenandoahHeap::set_full_gc_move_in_progress(bool in_progress) { } void ShenandoahHeap::set_update_refs_in_progress(bool in_progress) { - set_gc_state(UPDATEREFS, in_progress); + set_gc_state_at_safepoint(UPDATEREFS, in_progress); } void ShenandoahHeap::register_nmethod(nmethod* nm) { @@ -2610,6 +2667,14 @@ char ShenandoahHeap::gc_state() const { return _gc_state.raw_value(); } +bool ShenandoahHeap::is_gc_state(GCState state) const { + // If the global gc state has been changed, but hasn't yet been propagated to all threads, then + // the global gc state is the correct value. Once the gc state has been synchronized with all threads, + // _gc_state_changed will be toggled to false and we need to use the thread local state. + return _gc_state_changed ? _gc_state.is_set(state) : ShenandoahThreadLocalData::is_gc_state(state); +} + + ShenandoahLiveData* ShenandoahHeap::get_liveness_cache(uint worker_id) { #ifdef ASSERT assert(_liveness_cache != nullptr, "sanity"); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp index 5beced0544cf6..508f993b3003f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp @@ -363,18 +363,35 @@ class ShenandoahHeap : public CollectedHeap { size_t _gc_no_progress_count; - // This updates the singlular, global gc state. This must happen on a safepoint. - void set_gc_state(uint mask, bool value); + // This updates the singular, global gc state. This call must happen on a safepoint. + void set_gc_state_at_safepoint(uint mask, bool value); + + // This also updates the global gc state, but does not need to be called on a safepoint. + // Critically, this method will _not_ flag that the global gc state has changed and threads + // will continue to use their thread local copy. This is expected to be used in conjunction + // with a handshake operation to propagate the new gc state. + void set_gc_state_concurrent(uint mask, bool value); public: + // This returns the raw value of the singular, global gc state. char gc_state() const; - // This copies the global gc state into a thread local variable for java threads. - // It is primarily intended to support quick access at barriers. - void propagate_gc_state_to_java_threads(); + // Compares the given state against either the global gc state, or the thread local state. + // The global gc state may change on a safepoint and is the correct value to use until + // the global gc state has been propagated to all threads (after which, this method will + // compare against the thread local state). The thread local gc state may also be changed + // by a handshake operation, in which case, this function continues using the updated thread + // local value. + bool is_gc_state(GCState state) const; + + // This copies the global gc state into a thread local variable for all threads. + // The thread local gc state is primarily intended to support quick access at barriers. + // All threads are updated because in some cases the control thread or the vm thread may + // need to execute the load reference barrier. + void propagate_gc_state_to_all_threads(); // This is public to support assertions that the state hasn't been changed off of - // a safepoint and that any changes were propagated to java threads after the safepoint. + // a safepoint and that any changes were propagated to threads after the safepoint. bool has_gc_state_changed() const { return _gc_state_changed; } // Returns true if allocations have occurred in new regions or if regions have been @@ -394,9 +411,7 @@ class ShenandoahHeap : public CollectedHeap { void set_concurrent_strong_root_in_progress(bool cond); void set_concurrent_weak_root_in_progress(bool cond); - inline bool is_stable() const; inline bool is_idle() const; - inline bool is_concurrent_mark_in_progress() const; inline bool is_concurrent_young_mark_in_progress() const; inline bool is_concurrent_old_mark_in_progress() const; @@ -464,6 +479,10 @@ class ShenandoahHeap : public CollectedHeap { void do_class_unloading(); // Reference updating void prepare_update_heap_references(bool concurrent); + + // Retires LABs used for evacuation + void concurrent_prepare_for_update_refs(); + virtual void update_heap_references(bool concurrent); // Final update region states void update_heap_region_states(bool concurrent); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp index 6a38266489e03..f879188431b5e 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp @@ -64,10 +64,6 @@ inline ShenandoahHeapRegion* ShenandoahRegionIterator::next() { return _heap->get_region(new_index - 1); } -inline bool ShenandoahHeap::has_forwarded_objects() const { - return _gc_state.is_set(HAS_FORWARDED); -} - inline WorkerThreads* ShenandoahHeap::workers() const { return _workers; } @@ -450,28 +446,36 @@ inline bool ShenandoahHeap::in_collection_set_loc(void* p) const { return collection_set()->is_in_loc(p); } -inline bool ShenandoahHeap::is_stable() const { - return _gc_state.is_clear(); +inline bool ShenandoahHeap::is_idle() const { + return _gc_state_changed ? _gc_state.is_clear() : ShenandoahThreadLocalData::gc_state(Thread::current()) == 0; } -inline bool ShenandoahHeap::is_idle() const { - return _gc_state.is_unset(MARKING | EVACUATION | UPDATEREFS); +inline bool ShenandoahHeap::has_forwarded_objects() const { + return is_gc_state(HAS_FORWARDED); } inline bool ShenandoahHeap::is_concurrent_mark_in_progress() const { - return _gc_state.is_set(MARKING); + return is_gc_state(MARKING); } inline bool ShenandoahHeap::is_concurrent_young_mark_in_progress() const { - return _gc_state.is_set(YOUNG_MARKING); + return is_gc_state(YOUNG_MARKING); } inline bool ShenandoahHeap::is_concurrent_old_mark_in_progress() const { - return _gc_state.is_set(OLD_MARKING); + return is_gc_state(OLD_MARKING); } inline bool ShenandoahHeap::is_evacuation_in_progress() const { - return _gc_state.is_set(EVACUATION); + return is_gc_state(EVACUATION); +} + +inline bool ShenandoahHeap::is_update_refs_in_progress() const { + return is_gc_state(UPDATEREFS); +} + +inline bool ShenandoahHeap::is_concurrent_weak_root_in_progress() const { + return is_gc_state(WEAK_ROOTS); } inline bool ShenandoahHeap::is_degenerated_gc_in_progress() const { @@ -486,10 +490,6 @@ inline bool ShenandoahHeap::is_full_gc_move_in_progress() const { return _full_gc_move_in_progress.is_set(); } -inline bool ShenandoahHeap::is_update_refs_in_progress() const { - return _gc_state.is_set(UPDATEREFS); -} - inline bool ShenandoahHeap::is_stw_gc_in_progress() const { return is_full_gc_in_progress() || is_degenerated_gc_in_progress(); } @@ -498,10 +498,6 @@ inline bool ShenandoahHeap::is_concurrent_strong_root_in_progress() const { return _concurrent_strong_root_in_progress.is_set(); } -inline bool ShenandoahHeap::is_concurrent_weak_root_in_progress() const { - return _gc_state.is_set(WEAK_ROOTS); -} - template inline void ShenandoahHeap::marked_object_iterate(ShenandoahHeapRegion* region, T* cl) { marked_object_iterate(region, cl, region->top()); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp index 73250cecd6fe5..f04aa7ce8ed1f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp @@ -147,10 +147,10 @@ static int encode_phase(ShenandoahHeap* heap) { if (heap->is_update_refs_in_progress() || heap->is_full_gc_move_in_progress()) { return 3; } - if (heap->is_concurrent_mark_in_progress() || heap->is_full_gc_in_progress()) { + if (heap->is_concurrent_mark_in_progress() || heap->is_concurrent_weak_root_in_progress() || heap->is_full_gc_in_progress()) { return 1; } - assert(heap->is_idle(), "What is it doing?"); + assert(heap->is_idle(), "Unexpected gc_state: %d", heap->gc_state()); return 0; } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp index c226b1ad2545e..9e1777dd82c4f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp @@ -111,12 +111,18 @@ class ShenandoahThreadLocalData { } static char gc_state(Thread* thread) { - assert(thread->is_Java_thread(), "GC state is only synchronized to java threads"); return data(thread)->_gc_state; } + static bool is_gc_state(Thread* thread, ShenandoahHeap::GCState state) { + return (gc_state(thread) & state) != 0; + } + + static bool is_gc_state(ShenandoahHeap::GCState state) { + return is_gc_state(Thread::current(), state); + } + static void initialize_gclab(Thread* thread) { - assert (thread->is_Java_thread() || thread->is_Worker_thread(), "Only Java and GC worker threads are allowed to get GCLABs"); assert(data(thread)->_gclab == nullptr, "Only initialize once"); data(thread)->_gclab = new PLAB(PLAB::min_size()); data(thread)->_gclab_size = 0; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp b/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp index da32601eed7f0..67813be36eeb3 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp @@ -82,47 +82,47 @@ void VM_ShenandoahInitMark::doit() { ShenandoahGCPauseMark mark(_gc_id, "Init Mark", SvcGCMarker::CONCURRENT); set_active_generation(); _gc->entry_init_mark(); - ShenandoahHeap::heap()->propagate_gc_state_to_java_threads(); + ShenandoahHeap::heap()->propagate_gc_state_to_all_threads(); } void VM_ShenandoahFinalMarkStartEvac::doit() { ShenandoahGCPauseMark mark(_gc_id, "Final Mark", SvcGCMarker::CONCURRENT); set_active_generation(); _gc->entry_final_mark(); - ShenandoahHeap::heap()->propagate_gc_state_to_java_threads(); + ShenandoahHeap::heap()->propagate_gc_state_to_all_threads(); } void VM_ShenandoahFullGC::doit() { ShenandoahGCPauseMark mark(_gc_id, "Full GC", SvcGCMarker::FULL); set_active_generation(); _full_gc->entry_full(_gc_cause); - ShenandoahHeap::heap()->propagate_gc_state_to_java_threads(); + ShenandoahHeap::heap()->propagate_gc_state_to_all_threads(); } void VM_ShenandoahDegeneratedGC::doit() { ShenandoahGCPauseMark mark(_gc_id, "Degenerated GC", SvcGCMarker::CONCURRENT); set_active_generation(); _gc->entry_degenerated(); - ShenandoahHeap::heap()->propagate_gc_state_to_java_threads(); + ShenandoahHeap::heap()->propagate_gc_state_to_all_threads(); } void VM_ShenandoahInitUpdateRefs::doit() { ShenandoahGCPauseMark mark(_gc_id, "Init Update Refs", SvcGCMarker::CONCURRENT); set_active_generation(); _gc->entry_init_updaterefs(); - ShenandoahHeap::heap()->propagate_gc_state_to_java_threads(); + ShenandoahHeap::heap()->propagate_gc_state_to_all_threads(); } void VM_ShenandoahFinalUpdateRefs::doit() { ShenandoahGCPauseMark mark(_gc_id, "Final Update Refs", SvcGCMarker::CONCURRENT); set_active_generation(); _gc->entry_final_updaterefs(); - ShenandoahHeap::heap()->propagate_gc_state_to_java_threads(); + ShenandoahHeap::heap()->propagate_gc_state_to_all_threads(); } void VM_ShenandoahFinalRoots::doit() { ShenandoahGCPauseMark mark(_gc_id, "Final Roots", SvcGCMarker::CONCURRENT); set_active_generation(); _gc->entry_final_roots(); - ShenandoahHeap::heap()->propagate_gc_state_to_java_threads(); + ShenandoahHeap::heap()->propagate_gc_state_to_all_threads(); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp index 81f1dd1ae97b0..d8d6d81578feb 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp @@ -797,7 +797,7 @@ void ShenandoahVerifier::verify_at_safepoint(const char* label, guarantee(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "only when nothing else happens"); guarantee(ShenandoahVerify, "only when enabled, and bitmap is initialized in ShenandoahHeap::initialize"); - ShenandoahHeap::heap()->propagate_gc_state_to_java_threads(); + ShenandoahHeap::heap()->propagate_gc_state_to_all_threads(); // Avoid side-effect of changing workers' active thread count, but bypass concurrent/parallel protocol check ShenandoahPushWorkerScope verify_worker_scope(_heap->workers(), _heap->max_workers(), false /*bypass check*/); From bdf6e63eb1439ff0f8777cb7f7d152d3666f18f0 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 15 Jan 2025 22:44:33 +0000 Subject: [PATCH 15/47] 8347431: Update ObjectMonitor comments Reviewed-by: dholmes, pchilanomate --- src/hotspot/share/runtime/objectMonitor.hpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/hotspot/share/runtime/objectMonitor.hpp b/src/hotspot/share/runtime/objectMonitor.hpp index cf364cc012d39..6901ac2c1a3c6 100644 --- a/src/hotspot/share/runtime/objectMonitor.hpp +++ b/src/hotspot/share/runtime/objectMonitor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -84,12 +84,9 @@ class ObjectWaiter : public CHeapObj { // // ObjectMonitor Layout Overview/Highlights/Restrictions: // -// - The _metadata field must be at offset 0 because the displaced header -// from markWord is stored there. We do not want markWord.hpp to include -// ObjectMonitor.hpp to avoid exposing ObjectMonitor everywhere. This -// means that ObjectMonitor cannot inherit from any other class nor can -// it use any virtual member functions. This restriction is critical to -// the proper functioning of the VM. +// - For performance reasons we ensure the _metadata field is located at offset 0, +// which in turn means that ObjectMonitor can't inherit from any other class nor use +// any virtual member functions. // - The _metadata and _owner fields should be separated by enough space // to avoid false sharing due to parallel access by different threads. // This is an advisory recommendation. @@ -117,11 +114,7 @@ class ObjectWaiter : public CHeapObj { // // - See TEST_VM(ObjectMonitor, sanity) gtest for how critical restrictions are // enforced. -// - Adjacent ObjectMonitors should be separated by enough space to avoid -// false sharing. This is handled by the ObjectMonitor allocation code -// in synchronizer.cpp. Also see TEST_VM(SynchronizerTest, sanity) gtest. // -// Futures notes: // - Separating _owner from the by enough space to // avoid false sharing might be profitable. Given that the CAS in // monitorenter will invalidate the line underlying _owner. We want @@ -132,7 +125,7 @@ class ObjectWaiter : public CHeapObj { // would make them immune to CAS-based invalidation from the _owner // field. // -// - The _recursions field should be of type int, or int32_t but not +// - TODO: The _recursions field should be of type int, or int32_t but not // intptr_t. There's no reason to use a 64-bit type for this field // in a 64-bit JVM. @@ -151,7 +144,7 @@ class ObjectMonitor : public CHeapObj { // ParkEvent of unblocker thread. static ParkEvent* _vthread_unparker_ParkEvent; - // The sync code expects the metadata field to be at offset zero (0). + // Because of frequent access, the the metadata field is at offset zero (0). // Enforced by the assert() in metadata_addr(). // * LM_LIGHTWEIGHT with UseObjectMonitorTable: // Contains the _object's hashCode. From 9c430c92257739730155df05f340fe144fd24098 Mon Sep 17 00:00:00 2001 From: Alexander Zuev Date: Thu, 16 Jan 2025 01:10:46 +0000 Subject: [PATCH 16/47] 8336920: ArithmeticException in javax.sound.sampled.AudioInputStream Reviewed-by: azvegint, prr --- .../classes/com/sun/media/sound/SoftLinearResampler2.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/java.desktop/share/classes/com/sun/media/sound/SoftLinearResampler2.java b/src/java.desktop/share/classes/com/sun/media/sound/SoftLinearResampler2.java index 782bcc23d21d8..07108d9a393ed 100644 --- a/src/java.desktop/share/classes/com/sun/media/sound/SoftLinearResampler2.java +++ b/src/java.desktop/share/classes/com/sun/media/sound/SoftLinearResampler2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -58,6 +58,10 @@ public void interpolate(float[] in, float[] in_offset, float in_end, int p_ix = (int) (ix * (1 << 15)); int p_ix_end = (int) (ix_end * (1 << 15)); int p_pitch = (int) (pitch * (1 << 15)); + if (p_pitch == 0) { + // If pitch falls below the minimum assume minimum pitch + p_pitch = 1; + } // Pitch needs to recalculated // to ensure no drift between p_ix and ix. pitch = p_pitch * (1f / (1 << 15)); From d23ad01319ba298cc0ddcc2424abac8071840338 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 16 Jan 2025 10:13:48 +0000 Subject: [PATCH 17/47] 8337978: Verify OopHandles oops on access Reviewed-by: dholmes, coleenp --- src/hotspot/share/oops/oopHandle.inline.hpp | 28 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/oops/oopHandle.inline.hpp b/src/hotspot/share/oops/oopHandle.inline.hpp index 06acd2912745c..be5078704a4dc 100644 --- a/src/hotspot/share/oops/oopHandle.inline.hpp +++ b/src/hotspot/share/oops/oopHandle.inline.hpp @@ -31,11 +31,23 @@ #include "gc/shared/oopStorage.inline.hpp" inline oop OopHandle::resolve() const { - return (_obj == nullptr) ? (oop)nullptr : NativeAccess<>::oop_load(_obj); + if (_obj == nullptr) { + return (oop) nullptr; + } else { + oop oop = NativeAccess<>::oop_load(_obj); + assert(oopDesc::is_oop_or_null(oop), "Should be oop: " PTR_FORMAT, p2i(oop)); + return oop; + } } inline oop OopHandle::peek() const { - return (_obj == nullptr) ? (oop)nullptr : NativeAccess::oop_load(_obj); + if (_obj == nullptr) { + return (oop) nullptr; + } else { + oop obj = NativeAccess::oop_load(_obj); + assert(oopDesc::is_oop_or_null(obj), "Should be oop: " PTR_FORMAT, p2i(obj)); + return obj; + } } inline OopHandle::OopHandle(OopStorage* storage, oop obj) : @@ -44,6 +56,7 @@ inline OopHandle::OopHandle(OopStorage* storage, oop obj) : vm_exit_out_of_memory(sizeof(oop), OOM_MALLOC_ERROR, "Cannot create oop handle"); } + assert(oopDesc::is_oop_or_null(obj), "Should be oop: " PTR_FORMAT, p2i(obj)); NativeAccess<>::oop_store(_obj, obj); } @@ -58,15 +71,22 @@ inline void OopHandle::release(OopStorage* storage) { inline void OopHandle::replace(oop obj) { assert(!is_empty(), "should not use replace"); + assert(oopDesc::is_oop_or_null(obj), "Should be oop: " PTR_FORMAT, p2i(obj)); NativeAccess<>::oop_store(_obj, obj); } inline oop OopHandle::xchg(oop new_value) { - return NativeAccess::oop_atomic_xchg(_obj, new_value); + assert(oopDesc::is_oop_or_null(new_value), "Should be oop: " PTR_FORMAT, p2i(new_value)); + oop obj = NativeAccess::oop_atomic_xchg(_obj, new_value); + assert(oopDesc::is_oop_or_null(obj), "Should be oop: " PTR_FORMAT, p2i(obj)); + return obj; } inline oop OopHandle::cmpxchg(oop old_value, oop new_value) { - return NativeAccess::oop_atomic_cmpxchg(_obj, old_value, new_value); + assert(oopDesc::is_oop_or_null(new_value), "Should be oop: " PTR_FORMAT, p2i(new_value)); + oop obj = NativeAccess::oop_atomic_cmpxchg(_obj, old_value, new_value); + assert(oopDesc::is_oop_or_null(obj), "Should be oop: " PTR_FORMAT, p2i(obj)); + return obj; } #endif // SHARE_OOPS_OOPHANDLE_INLINE_HPP From 24de9dee80738fe6ab1fc726b071546c85bbf79a Mon Sep 17 00:00:00 2001 From: Andrey Turbanov Date: Thu, 16 Jan 2025 11:38:28 +0000 Subject: [PATCH 18/47] 8347370: Unnecessary Hashtable usage in javax.swing.text.html.HTML Reviewed-by: aivanov, azvegint --- .../classes/javax/swing/text/html/HTML.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/java.desktop/share/classes/javax/swing/text/html/HTML.java b/src/java.desktop/share/classes/javax/swing/text/html/HTML.java index 23e3f089b7321..88e12ff8fbc26 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/HTML.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/HTML.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -30,6 +30,7 @@ import java.io.Serial; import java.io.Serializable; import java.util.Hashtable; +import java.util.Map; import javax.swing.text.AttributeSet; import javax.swing.text.StyleConstants; @@ -1169,7 +1170,16 @@ public String toString() { private static final Hashtable tagHashtable = new Hashtable(73); /** Maps from StyleConstant key to HTML.Tag. */ - private static final Hashtable scMapping = new Hashtable(8); + private static final Map scMapping = Map.of( + StyleConstants.Bold, Tag.B, + StyleConstants.Italic, Tag.I, + StyleConstants.Underline, Tag.U, + StyleConstants.StrikeThrough, Tag.STRIKE, + StyleConstants.Superscript, Tag.SUP, + StyleConstants.Subscript, Tag.SUB, + StyleConstants.FontFamily, Tag.FONT, + StyleConstants.FontSize, Tag.FONT + ); static { @@ -1185,14 +1195,6 @@ public String toString() { allAttributes[i]); } StyleContext.registerStaticAttributeKey(HTML.NULL_ATTRIBUTE_VALUE); - scMapping.put(StyleConstants.Bold, Tag.B); - scMapping.put(StyleConstants.Italic, Tag.I); - scMapping.put(StyleConstants.Underline, Tag.U); - scMapping.put(StyleConstants.StrikeThrough, Tag.STRIKE); - scMapping.put(StyleConstants.Superscript, Tag.SUP); - scMapping.put(StyleConstants.Subscript, Tag.SUB); - scMapping.put(StyleConstants.FontFamily, Tag.FONT); - scMapping.put(StyleConstants.FontSize, Tag.FONT); } /** From 4ad5d5514e8fccc17f7be900e008e83f09e34e97 Mon Sep 17 00:00:00 2001 From: Theo Weidmann Date: Thu, 16 Jan 2025 12:16:14 +0000 Subject: [PATCH 19/47] 8325030: PhaseMacroExpand::value_from_mem_phi assert with "unknown node on this path" Reviewed-by: chagedorn, kvn --- src/hotspot/share/opto/macro.cpp | 6 +- .../macronodes/TestTopInMacroElimination.java | 55 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/compiler/macronodes/TestTopInMacroElimination.java diff --git a/src/hotspot/share/opto/macro.cpp b/src/hotspot/share/opto/macro.cpp index 289ea30a633e3..3ddab602c7733 100644 --- a/src/hotspot/share/opto/macro.cpp +++ b/src/hotspot/share/opto/macro.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -430,6 +430,10 @@ Node *PhaseMacroExpand::value_from_mem_phi(Node *mem, BasicType ft, const Type * return nullptr; } values.at_put(j, res); + } else if (val->is_top()) { + // This indicates that this path into the phi is dead. Top will eventually also propagate into the Region. + // IGVN will clean this up later. + values.at_put(j, val); } else { DEBUG_ONLY( val->dump(); ) assert(false, "unknown node on this path"); diff --git a/test/hotspot/jtreg/compiler/macronodes/TestTopInMacroElimination.java b/test/hotspot/jtreg/compiler/macronodes/TestTopInMacroElimination.java new file mode 100644 index 0000000000000..86ff4e9b87410 --- /dev/null +++ b/test/hotspot/jtreg/compiler/macronodes/TestTopInMacroElimination.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8325030 + * @summary Regression test for an assert triggered during allocation elimination because top is found during + * constructing new phis. + * @run main/othervm -XX:-ProfileExceptionHandlers compiler.macronodes.TestTopInMacroElimination + */ + +package compiler.macronodes; + +public class TestTopInMacroElimination { + public static class A { + int a; + } + + public static void main(String[] strArr) { + int i2 = 0; + for (int i = 0; i < 50; ++i) { + try { + synchronized (new A()) { + synchronized (TestTopInMacroElimination.class) { + for (int var19 = 0; var19 < Integer.valueOf(i2);) { + Integer.valueOf(var19); + } + } + } + for (int var8 = 0; var8 < 10000; ++var8) ; + } catch (ArithmeticException a_e) { + } + } + } +} From f64f22b360f68df68ebb875bd0ef08ba61702952 Mon Sep 17 00:00:00 2001 From: Theo Weidmann Date: Thu, 16 Jan 2025 12:17:21 +0000 Subject: [PATCH 20/47] 8346107: Generators: testing utility for random value generation Co-authored-by: Emanuel Peter Reviewed-by: epeter, chagedorn --- .../generators/AnyBitsDoubleGenerator.java | 42 ++ .../lib/generators/AnyBitsFloatGenerator.java | 43 ++ .../lib/generators/BoundGenerator.java | 37 ++ .../generators/EmptyGeneratorException.java | 33 + .../compiler/lib/generators/Generator.java | 34 + .../compiler/lib/generators/Generators.java | 584 +++++++++++++++++ .../lib/generators/MixedGenerator.java | 96 +++ .../generators/RandomElementGenerator.java | 44 ++ .../lib/generators/RandomnessSource.java | 45 ++ .../generators/RandomnessSourceAdapter.java | 68 ++ .../lib/generators/RestrictableGenerator.java | 38 ++ .../RestrictableMixedGenerator.java | 24 + .../RestrictableRandomElementGenerator.java | 47 ++ .../RestrictableSingleValueGenerator.java | 45 ++ .../lib/generators/SingleValueGenerator.java | 40 ++ .../generators/UniformDoubleGenerator.java | 49 ++ .../lib/generators/UniformFloatGenerator.java | 49 ++ .../lib/generators/UniformIntGenerator.java | 49 ++ ...formIntersectionRestrictableGenerator.java | 69 ++ .../lib/generators/UniformLongGenerator.java | 49 ++ .../generators/tests/ExampleTest.java | 81 +++ .../tests/MockRandomnessSource.java | 133 ++++ .../generators/tests/TestGenerators.java | 593 ++++++++++++++++++ 23 files changed, 2292 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/lib/generators/AnyBitsDoubleGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/AnyBitsFloatGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/BoundGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/EmptyGeneratorException.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/Generator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/Generators.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/MixedGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/RandomElementGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/RandomnessSource.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/RandomnessSourceAdapter.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/RestrictableGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/RestrictableMixedGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/RestrictableRandomElementGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/RestrictableSingleValueGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/SingleValueGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/UniformDoubleGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/UniformFloatGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/UniformIntGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/UniformIntersectionRestrictableGenerator.java create mode 100644 test/hotspot/jtreg/compiler/lib/generators/UniformLongGenerator.java create mode 100644 test/hotspot/jtreg/testlibrary_tests/generators/tests/ExampleTest.java create mode 100644 test/hotspot/jtreg/testlibrary_tests/generators/tests/MockRandomnessSource.java create mode 100644 test/hotspot/jtreg/testlibrary_tests/generators/tests/TestGenerators.java diff --git a/test/hotspot/jtreg/compiler/lib/generators/AnyBitsDoubleGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/AnyBitsDoubleGenerator.java new file mode 100644 index 0000000000000..2fcb01d69ffae --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/AnyBitsDoubleGenerator.java @@ -0,0 +1,42 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * Provides an any-bits double distribution random generator, i.e. the bits are uniformly sampled, + * thus creating any possible double value, including the multiple different NaN representations. + */ +final class AnyBitsDoubleGenerator extends BoundGenerator { + /** + * Create a new {@link AnyBitsDoubleGenerator}. + */ + public AnyBitsDoubleGenerator(Generators g) { + super(g); + } + + @Override + public Double next() { + return Double.longBitsToDouble(g.random.nextLong()); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/AnyBitsFloatGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/AnyBitsFloatGenerator.java new file mode 100644 index 0000000000000..f2f0b7462844c --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/AnyBitsFloatGenerator.java @@ -0,0 +1,43 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * Provides an any-bits float distribution random generator, i.e. the bits are uniformly sampled, + * thus creating any possible float value, including the multiple different NaN representations. + */ +final class AnyBitsFloatGenerator extends BoundGenerator { + + /** + * Creates a new {@link AnyBitsFloatGenerator}. + */ + public AnyBitsFloatGenerator(Generators g) { + super(g); + } + + @Override + public Float next() { + return Float.intBitsToFloat(g.random.nextInt()); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/BoundGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/BoundGenerator.java new file mode 100644 index 0000000000000..c4e6e9651e4f6 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/BoundGenerator.java @@ -0,0 +1,37 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * This is a common superclass for all generators that maintain a reference to the Generators object that created them. + * This allows internally creating other generators or using the {@link RandomnessSource} provided in + * {@link Generators#random}. + */ +abstract class BoundGenerator implements Generator { + Generators g; + + BoundGenerator(Generators g) { + this.g = g; + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/EmptyGeneratorException.java b/test/hotspot/jtreg/compiler/lib/generators/EmptyGeneratorException.java new file mode 100644 index 0000000000000..df9c0b47b7196 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/EmptyGeneratorException.java @@ -0,0 +1,33 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * An EmptyGeneratorException is thrown if a generator configuration is requested that would result in an empty + * set of values. For example, bounds such as [1, 0] cause an EmptyGeneratorException. Another example would be + * restricting a uniform integer generator over the range [0, 1] to [10, 11]. + */ +public class EmptyGeneratorException extends RuntimeException { + public EmptyGeneratorException() {} +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/Generator.java b/test/hotspot/jtreg/compiler/lib/generators/Generator.java new file mode 100644 index 0000000000000..e538d4b8925db --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/Generator.java @@ -0,0 +1,34 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * A stream of values according to a specific distribution. + */ +public interface Generator { + /** + * Returns the next value from the stream. + */ + T next(); +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/Generators.java b/test/hotspot/jtreg/compiler/lib/generators/Generators.java new file mode 100644 index 0000000000000..16f1b6be9b17c --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/Generators.java @@ -0,0 +1,584 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.util.*; + +import jdk.test.lib.Utils; + +/** + * The Generators class provides a set of random generator functions for testing. + * The goal is to cover many special cases, such as NaNs in Floats or values + * close to overflow in ints. They should produce values from specific + * "interesting" distributions which might trigger various behaviours in + * optimizations. + *

+ * Normally, clients get the default Generators instance by referring to the static variable {@link #G}. + *

+ * The Generators class offers generators with essential distributions, for example, {@link #uniformInts(int, int)}, + * {@link #uniformLongs(long, long)}, {@link #uniformDoubles(double, double)} or {@link #uniformFloats()}. For floating + * points, you may choose to get random bit patterns uniformly at random, rather than the values they represent. + * The Generators class also offers special generators of interesting values such as {@link #powerOfTwoInts(int)}, + * {@link #powerOfTwoLongs(int)}, which are values close to the powers of 2, or {@link #SPECIAL_DOUBLES} and + * {@link #SPECIAL_FLOATS}, which are values such as infinity, NaN, zero or the maximum and minimum values. + *

+ * Many distributions are restrictable. For example, if you first create a uniform integer generator over [1, 10], + * you can obtain a new generator by further restricting this range to [1, 5]. This is useful in cases where a function + * should be tested with different distributions. For example, a function h(int, int, int) under test might + * be worthwhile to test not only with uniformly sampled integers but might also exhibit interesting behavior if tested + * specifically with powers of two. Suppose further that each argument has a different range of allowed values. We + * can write a test function as below: + * + *


+ * void test(Generator{@literal } g) {
+ *     h(g.restricted(1, 10).next(), g.next(), g.restricted(-10, 100).next());
+ * }
+ * 
+ * + * Then test can be called with different distributions, for example: + * + *

+ * test(G.uniformInts());
+ * test(G.specialInts(0));
+ * 
+ *

+ * If there is a single value that is interesting as an argument to all three parameters, we might even call this + * method with a single generator, ensuring that the single value is within the restriction ranges: + * + *


+ * test(G.single(1));
+ * 
+ * + *

+ * Furthermore, this class offers utility generators, such as {@link #randomElement(Collection)} or + * {@link #orderedRandomElement(Collection)} for sampling from a list of elements; {@link #single(Object)} for a + * generator that only produces a single value; and {@link #mixed(Generator, Generator, int, int)} which combines + * two generators with the provided weights. + *

+ * Thus, the generators provided by this class are composable and therefore extensible. This allows to easily + * create random generators even with types and distributions that are not predefined. For example, to create a + * generator that provides true with 60 percent probably and false with 40 percent probably, one can simply write: + *

G.mixed(G.single(true), G.single(false), 60, 40)
+ *

+ * Generators are by no means limited to work with numbers. Restrictable generators can work with any type that + * implements {@link Comparable} while generators such as {@link #randomElement(Collection)} and {@link #single(Object)} + * work with any type. Note that there are separate restrictable versions of the last two generators + * (namely, {@link #orderedRandomElement(Collection)} and {@link #single(Comparable)}) that work with comparable types. + * For example, you might restrict a generator choosing strings at random: + *

G.orderedRandomElement(List.of("Bob", "Alice", "Carol")).restricted("Al", "Bz")
+ * This returns a new generator which only returns elements greater or equal than "Al" and less than or equal to + * "Bz". Thus, the only two values remaining in the example are "Alice" and "Bob". In general, you should always refer + * to the method that created the generator to learn about the exact semantics of restricting it. + *

+ * For all the generators created by instances of this class, the following rule applies: Integral generators are + * always inclusive of both the lower and upper bound, while floating point generators are always inclusive of the + * lower bound but always exclusive of the upper bound. This also applies to all generators obtained by restricting + * these generators further. + *

+ * Unless you have reasons to pick a specific distribution, you are encouraged to rely on {@link #ints()}, + * {@link #longs()}, {@link #doubles()} and {@link #floats()}, which will randomly pick an interesting distribution. + * This is best practice, because that allows the test to be run under different conditions – maybe only a single + * distribution can trigger a bug. + */ +public final class Generators { + /** + * This is the default Generators instance that should be used by tests normally. + */ + public static final Generators G = new Generators(new RandomnessSourceAdapter(Utils.getRandomInstance())); + + final RandomnessSource random; + + public Generators(RandomnessSource random) { + this.random = random; + } + + /** + * Returns a generator that generates integers in the range [lo, hi] (inclusive of both lo and hi). + */ + public RestrictableGenerator uniformInts(int lo, int hi) { + return new UniformIntGenerator(this, lo, hi); + } + + /** + * Returns a generator that generates integers over the entire range of int. + */ + public RestrictableGenerator uniformInts() { + return uniformInts(Integer.MIN_VALUE, Integer.MAX_VALUE); + } + + /** + * Returns a generator that generates longs in the range [lo, hi] (inclusive of both lo and hi). + */ + public RestrictableGenerator uniformLongs(long lo, long hi) { + return new UniformLongGenerator(this, lo, hi); + } + + /** + * Returns a generator that generates integers over the entire range of int. + */ + public RestrictableGenerator uniformLongs() { + return uniformLongs(Long.MIN_VALUE, Long.MAX_VALUE); + } + + /** + * Generates uniform doubles in the range of [lo, hi) (inclusive of lo, exclusive of hi). + */ + public RestrictableGenerator uniformDoubles(double lo, double hi) { + return new UniformDoubleGenerator(this, lo, hi); + } + + /** + * Generates uniform doubles in the range of [0, 1) (inclusive of 0, exclusive of 1). + */ + public RestrictableGenerator uniformDoubles() { + return uniformDoubles(0, 1); + } + + /** + * Provides an any-bits double distribution random generator, i.e. the bits are uniformly sampled, + * thus creating any possible double value, including the multiple different NaN representations. + */ + public Generator anyBitsDouble() { + return new AnyBitsDoubleGenerator(this); + } + + /** + * Generates uniform doubles in the range of [lo, hi) (inclusive of lo, exclusive of hi). + */ + public RestrictableGenerator uniformFloats(float lo, float hi) { + return new UniformFloatGenerator(this, lo, hi); + } + + /** + * Generates uniform floats in the range of [0, 1) (inclusive of 0, exclusive of 1). + */ + public RestrictableGenerator uniformFloats() { + return uniformFloats(0, 1); + } + + /** + * Provides an any-bits float distribution random generator, i.e. the bits are uniformly sampled, + * thus creating any possible float value, including the multiple different NaN representations. + */ + public Generator anyBitsFloats() { + return new AnyBitsFloatGenerator(this); + } + + /** + * Returns a generator that uniformly randomly samples elements from the provided collection. + * Each element in the collection is treated as a separate, unique value, even if equals might be true. + * The result is an unrestrictable generator. If you want a restrictable generator that selects values from a + * list and are working with Comparable values, use {@link #orderedRandomElement(Collection)}. + */ + public Generator randomElement(Collection list) { + return new RandomElementGenerator<>(this, list); + } + + /** + * Returns a restrictable generator that uniformly randomly samples elements from the provided collection. + * Duplicate elements are discarded from the collection. Restrictions are inclusive of both the uppper and lower + * bound. + */ + public > RestrictableGenerator orderedRandomElement(Collection list) { + NavigableSet set = list instanceof NavigableSet ? (NavigableSet) list : new TreeSet<>(list); + return new RestrictableRandomElementGenerator<>(this, set); + } + + /** + * Returns a generator that always generate the provided value. + */ + public Generator single(T value) { + return new SingleValueGenerator<>(value); + } + + /** + * Returns a restrictable generator that always generate the provided value. + */ + public > RestrictableGenerator single(T value) { + return new RestrictableSingleValueGenerator<>(value); + } + + /** + * Returns a new generator that samples its next element from either generator A or B, with assignable weights. + * An overload for restrictable generators exists. + */ + public Generator mixed(Generator a, Generator b, int weightA, int weightB) { + return new MixedGenerator<>(this, List.of(a, b), List.of(weightA, weightB)); + } + + /** + * Returns a new generator that samples its next element randomly from one of the provided generators with + * assignable weights. + * An overload for restrictable generators exists. + */ + @SafeVarargs + public final Generator mixed(List weights, Generator... generators) { + return new MixedGenerator<>(this, Arrays.asList(generators), weights); + } + + /** + * Returns a new restrictable generator that samples its next element from either generator A or B, with assignable weights. + * Restricting this generator restricts each subgenerator. Generators which become empty by the restriction are + * removed from the new mixed generator. Weights stay their original value if a generator is removed. If the mixed + * generator would become empty by applying a restriction {@link EmptyGeneratorException} is thrown. + */ + public > RestrictableGenerator mixed(RestrictableGenerator a, RestrictableGenerator b, int weightA, int weightB) { + return new RestrictableMixedGenerator<>(this, List.of(a, b), List.of(weightA, weightB)); + } + + /** + * Returns a new restrictable generator that samples its next element randomly from one of the provided restrictable + * generators with assignable weights. + * See {@link #mixed(RestrictableGenerator, RestrictableGenerator, int, int)} for details about restricting this + * generator. + */ + @SafeVarargs + public final > RestrictableGenerator mixed(List weights, RestrictableGenerator... generators) { + return new RestrictableMixedGenerator<>(this, Arrays.asList(generators), weights); + } + + /** + * Randomly pick an int generator. + * + * @return Random int generator. + */ + public RestrictableGenerator ints() { + switch(random.nextInt(0, 6)) { + case 0 -> { return uniformInts(); } + case 1 -> { return powerOfTwoInts(0); } + case 2 -> { return powerOfTwoInts(2); } + case 3 -> { return powerOfTwoInts(16); } + case 4 -> { return uniformIntsMixedWithPowersOfTwo(1, 1, 16); } + case 5 -> { return uniformIntsMixedWithPowersOfTwo(1, 2, 2); } + default -> { throw new RuntimeException("impossible"); } + } + } + + /** + * A generator of special ints. Special ints are powers of two or values close to powers of 2, where a value + * is close to a power of two p if it is in the interval [p - range, p + range]. Note that we also consider negative + * values as powers of two. Note that for range >= 1, the set of values includes {@link Integer#MAX_VALUE} and + * {@link Integer#MIN_VALUE}. + */ + public RestrictableGenerator powerOfTwoInts(int range) { + TreeSet set = new TreeSet<>(); + for (int i = 0; i < 32; i++) { + int pow2 = 1 << i; + for (int j = -range; j <= range; j++) { + set.add(+pow2 + j); + set.add(-pow2 + j); + } + } + return orderedRandomElement(set); + } + + /** + * A convenience helper to mix {@link #powerOfTwoInts(int)} with {@link #uniformInts(int, int)}. + */ + public RestrictableGenerator uniformIntsMixedWithPowersOfTwo(int weightUniform, int weightSpecial, int rangeSpecial) { + return mixed(uniformInts(), powerOfTwoInts(rangeSpecial), weightUniform, weightSpecial); + } + + /** + * Randomly pick a long generator. + * + * @return Random long generator. + */ + public RestrictableGenerator longs() { + switch(random.nextInt(0, 6)) { + case 0 -> { return uniformLongs(); } + case 1 -> { return powerOfTwoLongs(0); } + case 2 -> { return powerOfTwoLongs(2); } + case 3 -> { return powerOfTwoLongs(16); } + case 4 -> { return uniformLongsMixedWithPowerOfTwos(1, 1, 16); } + case 5 -> { return uniformLongsMixedWithPowerOfTwos(1, 2, 2); } + default -> { throw new RuntimeException("impossible"); } + } + } + + /** + * A generator of special longs. Special longs are powers of two or values close to powers of 2, where a value + * is close to a power of two p if it is in the interval [p - range, p + range]. Note that we also consider negative + * values as powers of two. Note that for range >= 1, the set of values includes {@link Long#MAX_VALUE} and + * {@link Long#MIN_VALUE}. + */ + public RestrictableGenerator powerOfTwoLongs(int range) { + TreeSet set = new TreeSet<>(); + for (int i = 0; i < 64; i++) { + long pow2 = 1L << i; + for (int j = -range; j <= range; j++) { + set.add(+pow2 + j); + set.add(-pow2 + j); + } + } + return orderedRandomElement(set); + } + + /** + * A convenience helper to mix {@link #powerOfTwoLongs(int)} with {@link #uniformLongs(long, long)}. + */ + public RestrictableGenerator uniformLongsMixedWithPowerOfTwos(int weightUniform, int weightSpecial, int rangeSpecial) { + return mixed(uniformLongs(), powerOfTwoLongs(rangeSpecial), weightUniform, weightSpecial); + } + + /** + * Randomly pick a float generator. + * + * @return Random float generator. + */ + public Generator floats() { + switch(random.nextInt(0, 5)) { + case 0 -> { return uniformFloats(-1, 1); } + // Well-balanced, so that multiplication reduction never explodes or collapses to zero: + case 1 -> { return uniformFloats(0.999f, 1.001f); } + case 2 -> { return anyBitsFloats(); } + // A tame distribution, mixed in with the occasional special float value: + case 3 -> { return mixedWithSpecialFloats(uniformFloats(0.999f, 1.001f), 10, 1000); } + // Generating any bits, but special values are more frequent. + case 4 -> { return mixedWithSpecialFloats(anyBitsFloats(), 100, 200); } + default -> { throw new RuntimeException("impossible"); } + } + } + + /** + * Randomly pick a double generator. + * + * @return Random double generator. + */ + public Generator doubles() { + switch(random.nextInt(0, 5)) { + case 0 -> { return uniformDoubles(-1, 1); } + // Well-balanced, so that multiplication reduction never explodes or collapses to zero: + case 1 -> { return uniformDoubles(0.999f, 1.001f); } + case 2 -> { return anyBitsDouble(); } + // A tame distribution, mixed in with the occasional special double value: + case 3 -> { return mixedWithSpecialDoubles(uniformDoubles(0.999f, 1.001f), 10, 1000); } + // Generating any bits, but special values are more frequent. + case 4 -> { return mixedWithSpecialDoubles(anyBitsDouble(), 100, 200); } + default -> { throw new RuntimeException("impossible"); } + } + } + + /** + * Generates interesting double values, which often are corner cases such as, 0, 1, -1, NaN, +/- Infinity, Min, + * Max. + */ + public final RestrictableGenerator SPECIAL_DOUBLES = orderedRandomElement(List.of( + 0d, + 1d, + -1d, + Double.POSITIVE_INFINITY, + Double.NEGATIVE_INFINITY, + Double.NaN, + Double.MAX_VALUE, + Double.MIN_NORMAL, + Double.MIN_VALUE + )); + + /** + * Returns a mixed generator that mixes the provided background generator and {@link #SPECIAL_DOUBLES} with the provided + * weights. + */ + public Generator mixedWithSpecialDoubles(Generator background, int weightNormal, int weightSpecial) { + return mixed(background, SPECIAL_DOUBLES, weightNormal, weightSpecial); + } + + /** + * Returns a restrictable mixed generator that mixes the provided background generator and {@link #SPECIAL_DOUBLES} with the provided + * weights. + */ + public RestrictableGenerator mixedWithSpecialDoubles(RestrictableGenerator background, int weightNormal, int weightSpecial) { + return mixed(background, SPECIAL_DOUBLES, weightNormal, weightSpecial); + } + + /** + * Generates interesting double values, which often are corner cases such as, 0, 1, -1, NaN, +/- Infinity, Min, + * Max. + */ + public final RestrictableGenerator SPECIAL_FLOATS = orderedRandomElement(List.of( + 0f, + 1f, + -1f, + Float.POSITIVE_INFINITY, + Float.NEGATIVE_INFINITY, + Float.NaN, + Float.MAX_VALUE, + Float.MIN_NORMAL, + Float.MIN_VALUE + )); + + /** + * Returns a mixed generator that mixes the provided background generator and {@link #SPECIAL_FLOATS} with the provided + * weights. + */ + public Generator mixedWithSpecialFloats(Generator background, int weightNormal, int weightSpecial) { + return mixed(background, SPECIAL_FLOATS, weightNormal, weightSpecial); + } + + /** + * Returns a restrictable mixed generator that mixes the provided background generator and {@link #SPECIAL_FLOATS} with the provided + * weights. + */ + public RestrictableGenerator mixedWithSpecialFloats(RestrictableGenerator background, int weightNormal, int weightSpecial) { + return mixed(background, SPECIAL_FLOATS, weightNormal, weightSpecial); + } + + /** + * Trys to restrict the provided restrictable generator to the provided range. If the restriction fails no + * exception is raised, but instead a uniform int generator for the range is returned. + */ + public RestrictableGenerator safeRestrict(RestrictableGenerator g, int lo, int hi) { + try { + return g.restricted(lo, hi); + } catch (EmptyGeneratorException e) { + return uniformInts(lo, hi); + } + } + + /** + * Trys to restrict the provided restrictable generator to the provided range. If the restriction fails no + * exception is raised, but instead a uniform long generator for the range is returned. + */ + public RestrictableGenerator safeRestrict(RestrictableGenerator g, long lo, long hi) { + try { + return g.restricted(lo, hi); + } catch (EmptyGeneratorException e) { + return uniformLongs(lo, hi); + } + } + + /** + * Trys to restrict the provided restrictable generator to the provided range. If the restriction fails no + * exception is raised, but instead a uniform double generator for the range is returned. + */ + public RestrictableGenerator safeRestrict(RestrictableGenerator g, double lo, double hi) { + try { + return g.restricted(lo, hi); + } catch (EmptyGeneratorException e) { + return uniformDoubles(lo, hi); + } + } + + /** + * Trys to restrict the provided restrictable generator to the provided range. If the restriction fails no + * exception is raised, but instead a uniform float generator for the range is returned. + */ + public RestrictableGenerator safeRestrict(RestrictableGenerator g, float lo, float hi) { + try { + return g.restricted(lo, hi); + } catch (EmptyGeneratorException e) { + return uniformFloats(lo, hi); + } + } + + /** + * Fills the memory segments with doubles obtained by calling next on the generator. + * + * @param generator The generator from which to source the values. + * @param ms Memory segment to be filled with random values. + */ + public void fillDouble(Generator generator, MemorySegment ms) { + var layout = ValueLayout.JAVA_DOUBLE_UNALIGNED; + for (long i = 0; i < ms.byteSize() / layout.byteSize(); i++) { + ms.setAtIndex(layout, i, generator.next()); + } + } + + /** + * Fill the array with doubles using the distribution of nextDouble. + * + * @param a Array to be filled with random values. + */ + public void fill(Generator generator, double[] a) { + fillDouble(generator, MemorySegment.ofArray(a)); + } + + /** + * Fills the memory segments with floats obtained by calling next on the generator. + * + * @param generator The generator from which to source the values. + * @param ms Memory segment to be filled with random values. + */ + public void fillFloat(Generator generator, MemorySegment ms) { + var layout = ValueLayout.JAVA_FLOAT_UNALIGNED; + for (long i = 0; i < ms.byteSize() / layout.byteSize(); i++) { + ms.setAtIndex(layout, i, generator.next()); + } + } + + /** + * Fill the array with floats using the distribution of nextDouble. + * + * @param a Array to be filled with random values. + */ + public void fill(Generator generator, float[] a) { + fillFloat(generator, MemorySegment.ofArray(a)); + } + + /** + * Fills the memory segments with ints obtained by calling next on the generator. + * + * @param generator The generator from which to source the values. + * @param ms Memory segment to be filled with random values. + */ + public void fillInt(Generator generator, MemorySegment ms) { + var layout = ValueLayout.JAVA_INT_UNALIGNED; + for (long i = 0; i < ms.byteSize() / layout.byteSize(); i++) { + ms.setAtIndex(layout, i, generator.next()); + } + } + + /** + * Fill the array with ints using the distribution of nextDouble. + * + * @param a Array to be filled with random values. + */ + public void fill(Generator generator, int[] a) { + fillInt(generator, MemorySegment.ofArray(a)); + } + + /** + * Fills the memory segments with longs obtained by calling next on the generator. + * + * @param generator The generator from which to source the values. + * @param ms Memory segment to be filled with random values. + */ + public void fillLong(Generator generator, MemorySegment ms) { + var layout = ValueLayout.JAVA_LONG_UNALIGNED; + for (long i = 0; i < ms.byteSize() / layout.byteSize(); i++) { + ms.setAtIndex(layout, i, generator.next()); + } + } + + /** + * Fill the array with longs using the distribution of nextDouble. + * + * @param a Array to be filled with random values. + */ + public void fill(Generator generator, long[] a) { + fillLong(generator, MemorySegment.ofArray(a)); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/MixedGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/MixedGenerator.java new file mode 100644 index 0000000000000..4618964d1de02 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/MixedGenerator.java @@ -0,0 +1,96 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +import java.util.List; +import java.util.TreeMap; +import java.util.function.Function; + +/** + * Mixed results between different generators with configurable weights. + */ +class MixedGenerator, T> extends BoundGenerator { + private final TreeMap generators = new TreeMap<>(); + private final int totalWeight; + + /** + * Creates a new {@link MixedGenerator}, which samples from a list of generators at random, + * according to specified weights. + */ + MixedGenerator(Generators g, List generators, List weights) { + super(g); + if (weights.size() != generators.size()) { + throw new IllegalArgumentException("weights and generators must have the same size"); + } + int acc = 0; + for (int i = 0; i < generators.size(); i++) { + int weight = weights.get(i); + if (weight <= 0) { + throw new IllegalArgumentException("weights must be positive"); + } + acc += weight; + this.generators.put(acc, generators.get(i)); + } + this.totalWeight = acc; + } + + /** + * Creates a new mixed generator by mapping each generator of the old generator to a new value or removing it. + * @param other The generator to copy from. + * @param generatorMapper A function that is called for each subgenerator in the old generator. Either return a + * generator that takes the role of the old generator (might be the same) or null to remove + * the generator completely. In this case, the weights of the other generators stay the same. + */ + MixedGenerator(MixedGenerator other, Function generatorMapper) { + super(other.g); + // We could map and create new lists and delegate to the other constructor but that would allocate + // two additional lists, so in the interest of memory efficiency we construct the new TreeMap ourselves. + int acc = 0; + int prevKey = 0; + // entrySet: "The set's iterator returns the entries in ascending key order." (documentation) + // This means we iterate over the generators exactly in the order they were inserted as we insert with ascending + // keys (due to summing positive numbers). + for (var entry : other.generators.entrySet()) { + var gen = generatorMapper.apply(entry.getValue()); + if (gen != null) { + // entry.getKey() is the sum of all generator weights up to this one. + // We compute this generator's weight by taking the difference to the previous key + int weight = entry.getKey() - prevKey; + acc += weight; + this.generators.put(acc, gen); + } + prevKey = entry.getKey(); + } + if (this.generators.isEmpty()) { + throw new EmptyGeneratorException(); + } + this.totalWeight = acc; + } + + @Override + public T next() { + int r = g.random.nextInt(0, totalWeight); + return generators.higherEntry(r).getValue().next(); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/RandomElementGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/RandomElementGenerator.java new file mode 100644 index 0000000000000..398e3f97888c9 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/RandomElementGenerator.java @@ -0,0 +1,44 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +import java.util.ArrayList; +import java.util.Collection; + +class RandomElementGenerator extends BoundGenerator { + private final ArrayList elements; + private final Generator generator; + + RandomElementGenerator(Generators g, Collection elements) { + super(g); + this.elements = new ArrayList<>(elements); + if (this.elements.isEmpty()) throw new EmptyGeneratorException(); + this.generator = g.uniformInts(0, elements.size() - 1); + } + + @Override + public final T next() { + return elements.get(generator.next()); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/RandomnessSource.java b/test/hotspot/jtreg/compiler/lib/generators/RandomnessSource.java new file mode 100644 index 0000000000000..2b09b92cf3d47 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/RandomnessSource.java @@ -0,0 +1,45 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * Defines the underlying randomness source used by the generators. This is essentially a subset of + * {@link java.util.random.RandomGenerator} and the present methods have the same contract. + * This interface greatly benefits testing, as it is much easier to implement than + * {@link java.util.random.RandomGenerator} and thus makes creating test doubles more convenient. + */ +public interface RandomnessSource { + /** Samples the next long value uniformly at random. */ + long nextLong(); + /** Samples the next long value in the half-open interval [lo, hi) uniformly at random. */ + long nextLong(long lo, long hi); + /** Samples the next int value uniformly at random. */ + int nextInt(); + /** Samples the next int value in the half-open interval [lo, hi) uniformly at random. */ + int nextInt(int lo, int hi); + /** Samples the next double value in the half-open interval [lo, hi) uniformly at random. */ + double nextDouble(double lo, double hi); + /** Samples the next float value in the half-open interval [lo, hi) uniformly at random. */ + float nextFloat(float lo, float hi); +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/RandomnessSourceAdapter.java b/test/hotspot/jtreg/compiler/lib/generators/RandomnessSourceAdapter.java new file mode 100644 index 0000000000000..a8e62031cf6a2 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/RandomnessSourceAdapter.java @@ -0,0 +1,68 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +import java.util.random.RandomGenerator; + +/** + * An adapter for using a {@link RandomGenerator} as a {@link RandomnessSource}. + * See RandomnessSource for more information. + */ +public class RandomnessSourceAdapter implements RandomnessSource { + private final RandomGenerator rand; + + RandomnessSourceAdapter(RandomGenerator rand) { + this.rand = rand; + } + + @Override + public long nextLong() { + return rand.nextLong(); + } + + @Override + public long nextLong(long lo, long hi) { + return rand.nextLong(lo, hi); + } + + @Override + public int nextInt() { + return rand.nextInt(); + } + + @Override + public int nextInt(int lo, int hi) { + return rand.nextInt(lo, hi); + } + + @Override + public double nextDouble(double lo, double hi) { + return rand.nextDouble(lo, hi); + } + + @Override + public float nextFloat(float lo, float hi) { + return rand.nextFloat(lo, hi); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/RestrictableGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/RestrictableGenerator.java new file mode 100644 index 0000000000000..c1c9ef751f5f6 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/RestrictableGenerator.java @@ -0,0 +1,38 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * A restrictable generator allows the creation of a new generator by restricting the range of its output values. + * The exact semantics of this restriction depend on the concrete implementation, but it usually means taking the + * intersection of the old range and the newly requested range of values. + */ +public interface RestrictableGenerator extends Generator { + /** + * Returns a new generator where the range of this generator has been restricted to the range of newLo and newHi. + * Whether newHi is inclusive or exclusive depends on the concrete implementation. + * @throws EmptyGeneratorException if this restriction would result in an empty generator. + */ + RestrictableGenerator restricted(T newLo, T newHi); +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/RestrictableMixedGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/RestrictableMixedGenerator.java new file mode 100644 index 0000000000000..066a5747213a0 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/RestrictableMixedGenerator.java @@ -0,0 +1,24 @@ +package compiler.lib.generators; + +import java.util.List; + +final class RestrictableMixedGenerator> extends MixedGenerator, T> implements RestrictableGenerator { + RestrictableMixedGenerator(Generators g, List> generators, List weights) { + super(g, generators, weights); + } + + RestrictableMixedGenerator(RestrictableMixedGenerator other, T newLo, T newHi) { + super(other, (generator) -> { + try { + return generator.restricted(newLo, newHi); + } catch (EmptyGeneratorException e) { + return null; + } + }); + } + + @Override + public RestrictableGenerator restricted(T newLo, T newHi) { + return new RestrictableMixedGenerator<>(this, newLo, newHi); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/RestrictableRandomElementGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/RestrictableRandomElementGenerator.java new file mode 100644 index 0000000000000..4bbd9cdaf5bf4 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/RestrictableRandomElementGenerator.java @@ -0,0 +1,47 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +import java.util.NavigableSet; + +/** + * Selects values from a pre-defined list. + */ +final class RestrictableRandomElementGenerator> extends RandomElementGenerator implements RestrictableGenerator { + /* + * Pre-generated values we can choose from. Maintained for restriction. + */ + private final NavigableSet values; + + public RestrictableRandomElementGenerator(Generators g, NavigableSet values) { + super(g, values); + if (values.isEmpty()) throw new EmptyGeneratorException(); + this.values = values; + } + + @Override + public RestrictableGenerator restricted(T newLo, T newHi) { + return new RestrictableRandomElementGenerator<>(g, values.subSet(newLo, true, newHi, true)); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/RestrictableSingleValueGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/RestrictableSingleValueGenerator.java new file mode 100644 index 0000000000000..4446788a85034 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/RestrictableSingleValueGenerator.java @@ -0,0 +1,45 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +class RestrictableSingleValueGenerator> implements RestrictableGenerator { + private final T value; + + RestrictableSingleValueGenerator(T value) { + this.value = value; + } + + @Override + public RestrictableGenerator restricted(T newLo, T newHi) { + if (newLo.compareTo(value) <= 0 && value.compareTo(newHi) <= 0) { + return this; + } + throw new EmptyGeneratorException(); + } + + @Override + public T next() { + return value; + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/SingleValueGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/SingleValueGenerator.java new file mode 100644 index 0000000000000..909ee806e7a27 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/SingleValueGenerator.java @@ -0,0 +1,40 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * A generator which always returns the same value. + */ +class SingleValueGenerator implements Generator { + private final T value; + + SingleValueGenerator(T value) { + this.value = value; + } + + @Override + public T next() { + return this.value; + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/UniformDoubleGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/UniformDoubleGenerator.java new file mode 100644 index 0000000000000..d160bf319d818 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/UniformDoubleGenerator.java @@ -0,0 +1,49 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * Provides a uniform double distribution random generator, in the provided range [lo, hi). + */ +final class UniformDoubleGenerator extends UniformIntersectionRestrictableGenerator { + /** + * Creates a new {@link UniformFloatGenerator}. + * + * @param lo Lower bound of the range (inclusive). + * @param hi Higher bound of the range (exclusive). + */ + public UniformDoubleGenerator(Generators g, double lo, double hi) { + super(g, lo, hi); + } + + @Override + public Double next() { + return g.random.nextDouble(lo(), hi()); + } + + @Override + protected RestrictableGenerator doRestrictionFromIntersection(Double lo, Double hi) { + return new UniformDoubleGenerator(g, lo, hi); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/UniformFloatGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/UniformFloatGenerator.java new file mode 100644 index 0000000000000..1b72ad5adc952 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/UniformFloatGenerator.java @@ -0,0 +1,49 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * Provides a uniform float distribution random generator, in the provided range [lo, hi). + */ +final class UniformFloatGenerator extends UniformIntersectionRestrictableGenerator { + /** + * Creates a new {@link UniformFloatGenerator}. + * + * @param lo Lower bound of the range (inclusive). + * @param hi Higher bound of the range (exclusive). + */ + public UniformFloatGenerator(Generators g, float lo, float hi) { + super(g, lo, hi); + } + + @Override + public Float next() { + return g.random.nextFloat(lo(), hi()); + } + + @Override + protected RestrictableGenerator doRestrictionFromIntersection(Float lo, Float hi) { + return new UniformFloatGenerator(g, lo, hi); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/UniformIntGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/UniformIntGenerator.java new file mode 100644 index 0000000000000..86eb3224c4fbd --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/UniformIntGenerator.java @@ -0,0 +1,49 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * Provides a uniform int distribution random generator. + */ +final class UniformIntGenerator extends UniformIntersectionRestrictableGenerator { + public UniformIntGenerator(Generators g, int lo, int hi) { + super(g, lo, hi); + } + + @Override + public Integer next() { + if (hi() == Integer.MAX_VALUE) { + if (lo() == Integer.MIN_VALUE) { + return g.random.nextInt(); + } + return g.random.nextInt(lo() - 1, hi()) + 1; + } + return g.random.nextInt(lo(), hi() + 1); + } + + @Override + protected RestrictableGenerator doRestrictionFromIntersection(Integer lo, Integer hi) { + return new UniformIntGenerator(g, lo, hi); + } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/UniformIntersectionRestrictableGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/UniformIntersectionRestrictableGenerator.java new file mode 100644 index 0000000000000..1554f90eb8286 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/UniformIntersectionRestrictableGenerator.java @@ -0,0 +1,69 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * A generators whose outputs are restricted by taking the intersection of the previous interval and the new interval. + */ +abstract class UniformIntersectionRestrictableGenerator> extends BoundGenerator implements RestrictableGenerator { + private final T lo; + private final T hi; + + public UniformIntersectionRestrictableGenerator(Generators g, T lo, T hi) { + super(g); + if (lo.compareTo(hi) > 0) throw new EmptyGeneratorException(); + this.lo = lo; + this.hi = hi; + } + + /** + * Creates a new generator by further restricting the range of values. The range of values will be the + * intersection of the previous values and the values in the provided range. + * The probability of each element occurring in the new generator stay the same relative to each other. + */ + @Override + public RestrictableGenerator restricted(T newLo /*as*/, T newHi /*ae*/) { + if (lo().compareTo(newHi) > 0 || newLo.compareTo(hi()) > 0) { + throw new EmptyGeneratorException(); + } + return doRestrictionFromIntersection(max(newLo, lo()), min(newHi, hi())); + } + + private T max(T a, T b) { + return a.compareTo(b) >= 0 ? a : b; + } + + private T min(T a, T b) { + return a.compareTo(b) < 0 ? a : b; + } + + /** + * Your subclass can just override this method which will receive the computed intersection between the old and + * new interval. It is guaranteed that the interval is non-empty. + */ + protected abstract RestrictableGenerator doRestrictionFromIntersection(T lo, T hi); + + T hi() { return hi; } + T lo() { return lo; } +} diff --git a/test/hotspot/jtreg/compiler/lib/generators/UniformLongGenerator.java b/test/hotspot/jtreg/compiler/lib/generators/UniformLongGenerator.java new file mode 100644 index 0000000000000..1cfd513962fbc --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/generators/UniformLongGenerator.java @@ -0,0 +1,49 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.lib.generators; + +/** + * Provides a uniform long distribution random generator. + */ +final class UniformLongGenerator extends UniformIntersectionRestrictableGenerator { + public UniformLongGenerator(Generators g, Long lo, Long hi) { + super(g, lo, hi); + } + + @Override + public Long next() { + if (hi() == Long.MAX_VALUE) { + if (lo() == Long.MIN_VALUE) { + return g.random.nextLong(); + } + return g.random.nextLong(lo() - 1, hi()) + 1; + } + return g.random.nextLong(lo(), hi() + 1); + } + + @Override + protected RestrictableGenerator doRestrictionFromIntersection(Long lo, Long hi) { + return new UniformLongGenerator(g, lo, hi); + } +} diff --git a/test/hotspot/jtreg/testlibrary_tests/generators/tests/ExampleTest.java b/test/hotspot/jtreg/testlibrary_tests/generators/tests/ExampleTest.java new file mode 100644 index 0000000000000..3609d6e3567cc --- /dev/null +++ b/test/hotspot/jtreg/testlibrary_tests/generators/tests/ExampleTest.java @@ -0,0 +1,81 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary An example test that shows how to use the Generators library. + * @modules java.base/jdk.internal.misc + * @library /test/lib / + * @run driver testlibrary_tests.generators.tests.ExampleTest + */ + +package testlibrary_tests.generators.tests; + +import compiler.lib.generators.Generator; + +import static compiler.lib.generators.Generators.G; + + +public class ExampleTest { + static class FakeException extends RuntimeException {} + + static class UnderTest { + private enum State { STAND_BY, FIRST, SECOND }; + + private State state = State.STAND_BY; + + void doIt(int x) { + state = switch (state) { + case State.STAND_BY -> x == (1 << 10) + 3 ? State.FIRST : State.STAND_BY; + case State.FIRST -> x == (1 << 5) - 2 ? State.SECOND : State.STAND_BY; + case State.SECOND -> { + if (x == (1 << 4)) throw new FakeException(); + yield State.STAND_BY; + } + }; + } + } + + public static void main(String[] args) { + // This test should print "Assertion triggered by special" (see the math below) but almost never + // "Assertion triggered by uniform" as the chance of triggering is about 2^-96. + try { + test(G.uniformInts()); + } catch (FakeException e) { + System.out.println("Assertion triggered by uniform"); + } + try { + // 408 ints => 1/408 * 1/408 * 1/408 => 1/67_917_312 => with 70_000_000 loop iterations we should trigger + test(G.powerOfTwoInts(3)); + } catch (FakeException e) { + System.out.println("Assertion triggered by special"); + } + } + + public static void test(Generator g) { + UnderTest underTest = new UnderTest(); + for (int i = 0; i < 70_000_000 * 3; i++) { + underTest.doIt(g.next()); + } + } +} diff --git a/test/hotspot/jtreg/testlibrary_tests/generators/tests/MockRandomnessSource.java b/test/hotspot/jtreg/testlibrary_tests/generators/tests/MockRandomnessSource.java new file mode 100644 index 0000000000000..c8d5f3257066c --- /dev/null +++ b/test/hotspot/jtreg/testlibrary_tests/generators/tests/MockRandomnessSource.java @@ -0,0 +1,133 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package testlibrary_tests.generators.tests; + +import compiler.lib.generators.RandomnessSource; + +import java.util.ArrayDeque; +import java.util.Queue; + +/** + * This class is a mock for RandomnessSource. For each method defined in {@link RandomnessSource}, it maintains + * a queue. For the methods {@link #nextInt()} and {@link #nextLong()} the queue simply contains ints and longs, + * respectively, and they are dequeue and returned when the methods are called. For the bounded methods, each queue + * element is a value associated with the bounds that are expected for the call. If the actual bounds do not match + * the arguments provided, a RuntimeException is raised. This allows verifying that the correct bounds are passed to + * the randomness source. + * Furthermore, if a method is called and its queue is empty, an exception is raised. + * To ensure all expected methods have been called in a test, you should call {@link #checkEmpty()} in-between tests + * to ensure that queues are empty, that is, all expected methods have been called. + */ +class MockRandomnessSource implements RandomnessSource { + private record Bounded(T lo, T hi, T value) {} + + private final Queue unboundedLongQueue = new ArrayDeque<>(); + private final Queue unboundedIntegerQueue = new ArrayDeque<>(); + private final Queue> boundedLongQueue = new ArrayDeque<>(); + private final Queue> boundedIntegerQueue = new ArrayDeque<>(); + private final Queue> boundedDoubleQueue = new ArrayDeque<>(); + private final Queue> boundedFloatQueue = new ArrayDeque<>(); + + private T dequeueBounded(Queue> queue, T lo, T hi) { + Bounded bounded = queue.remove(); + if (!bounded.lo.equals(lo) || !bounded.hi.equals(hi)) { + throw new RuntimeException("Expected bounds " + bounded.lo + " and " + bounded.hi + " but found " + lo + " and " + hi); + } + return bounded.value; + } + + private void checkQueueEmpty(Queue queue, String name) { + if (!queue.isEmpty()) throw new RuntimeException("Expected empty queue for " + name + " but found " + queue); + } + + public MockRandomnessSource enqueueLong(long value) { + unboundedLongQueue.add(value); + return this; + } + + public MockRandomnessSource enqueueInteger(int value) { + unboundedIntegerQueue.add(value); + return this; + } + + public MockRandomnessSource enqueueLong(long lo, long hi, long value) { + boundedLongQueue.add(new Bounded<>(lo, hi, value)); + return this; + } + + public MockRandomnessSource enqueueInteger(int lo, int hi, int value) { + boundedIntegerQueue.add(new Bounded<>(lo, hi, value)); + return this; + } + + public MockRandomnessSource enqueueDouble(double lo, double hi, double value) { + boundedDoubleQueue.add(new Bounded<>(lo, hi, value)); + return this; + } + + public MockRandomnessSource enqueueFloat(float lo, float hi, float value) { + boundedFloatQueue.add(new Bounded<>(lo, hi, value)); + return this; + } + + public MockRandomnessSource checkEmpty() { + checkQueueEmpty(unboundedLongQueue, "unbounded longs"); + checkQueueEmpty(unboundedIntegerQueue, "unbounded integers"); + checkQueueEmpty(boundedLongQueue, "bounded longs"); + checkQueueEmpty(boundedIntegerQueue, "bounded integers"); + checkQueueEmpty(boundedDoubleQueue, "bounded doubles"); + checkQueueEmpty(boundedFloatQueue, "bounded floats"); + return this; + } + + @Override + public long nextLong() { + return unboundedLongQueue.remove(); + } + + @Override + public long nextLong(long lo, long hi) { + return dequeueBounded(boundedLongQueue, lo, hi); + } + + @Override + public int nextInt() { + return unboundedIntegerQueue.remove(); + } + + @Override + public int nextInt(int lo, int hi) { + return dequeueBounded(boundedIntegerQueue, lo, hi); + } + + @Override + public double nextDouble(double lo, double hi) { + return dequeueBounded(boundedDoubleQueue, lo, hi); + } + + @Override + public float nextFloat(float lo, float hi) { + return dequeueBounded(boundedFloatQueue, lo, hi); + } +} diff --git a/test/hotspot/jtreg/testlibrary_tests/generators/tests/TestGenerators.java b/test/hotspot/jtreg/testlibrary_tests/generators/tests/TestGenerators.java new file mode 100644 index 0000000000000..203256ad7b86c --- /dev/null +++ b/test/hotspot/jtreg/testlibrary_tests/generators/tests/TestGenerators.java @@ -0,0 +1,593 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Test functionality of the Generators library. + * @modules java.base/jdk.internal.misc + * @library /test/lib / + * @build MockRandomnessSource + * @run driver testlibrary_tests.generators.tests.TestGenerators + */ + +package testlibrary_tests.generators.tests; + +import compiler.lib.generators.EmptyGeneratorException; +import compiler.lib.generators.Generator; +import compiler.lib.generators.Generators; +import compiler.lib.generators.RestrictableGenerator; +import jdk.test.lib.Asserts; + +import java.util.*; + +import static compiler.lib.generators.Generators.G; + + +public class TestGenerators { + // As it's hard to write tests with real randomness, we mock the randomness source so we can control which "random" + // values are fed to the generators. Thus, a lot of the tests below are white-box tests, that have knowledge about + // the internals of when randomness is consumed. There are also black-box tests which refer to Generators.G. + // Please also see MockRandomness to learn more about this class. + static MockRandomnessSource mockSource = new MockRandomnessSource(); + static Generators mockGS = new Generators(mockSource); + + public static void main(String[] args) { + testEmptyGenerators(); + testUniformInts(); + testUniformLongs(); + testAnyBits(); + testUniformFloat(); + testUniformDouble(); + testSingle(); + testMixed(); + testRandomElement(); + specialInt(); + specialLong(); + testSpecialFloat(); + testSpecialDouble(); + testSafeRestrict(); + testFill(); + testFuzzy(); + } + + static void testMixed() { + mockSource + .checkEmpty() + .enqueueInteger(0, 10, 7) // MixedGenerator chooses a generator: single + // single was chosen but does not consume randomness + .enqueueInteger(0, 10, 5) // MixedGenerator chooses a generator: uniform ints + .enqueueInteger(0, 31, 4) // uniform ints samples + .enqueueInteger(0, 10, 1) // MixedGenerator chooses a generator: uniform ints + .enqueueInteger(0, 31, 18); // uniform ints samples + var g0 = mockGS.mixed(mockGS.uniformInts(0, 30), mockGS.single(-1), 7, 3); + Asserts.assertEQ(g0.next(), -1); + Asserts.assertEQ(g0.next(), 4); + Asserts.assertEQ(g0.next(), 18); + + mockSource + .checkEmpty() + .enqueueInteger(0, 10, 1) // MixedGenerator chooses a generator: the first uniform ints + .enqueueInteger(0, 31, 24) // uniform ints (1) samples + .enqueueInteger(0, 10, 2) // MixedGenerator chooses a generator: single + // single does not use randomness + .enqueueInteger(0, 10, 7) // MixedGenerator chooses a generator: the second uniform ints + .enqueueInteger(-10, 0, -2) // uniform ints (2) samples + .enqueueInteger(0, 10, 9) // MixedGenerator chooses a generator: the second uniform ints + .enqueueInteger(-10, 0, -4) // uniform ints (2) samples + .enqueueInteger(0, 10, 1) // MixedGenerator chooses a generator: the first uniform ints + .enqueueInteger(0, 31, 29); // uniform ints (1) samples + + var g1 = mockGS.mixed( + List.of(2, 5, 3), + mockGS.uniformInts(0, 30), mockGS.single(-1), mockGS.uniformInts(-10, -1) + ); + Asserts.assertEQ(g1.next(), 24); + Asserts.assertEQ(g1.next(), -1); + Asserts.assertEQ(g1.next(), -2); + Asserts.assertEQ(g1.next(), -4); + Asserts.assertEQ(g1.next(), 29); + + mockSource + .checkEmpty() + .enqueueInteger(0, 10, 7) // MixedGenerator chooses a generator: single + // single was chosen but does not consume randomness + .enqueueInteger(0, 10, 5) // MixedGenerator chooses a generator: uniform ints + .enqueueInteger(0, 21, 18); // uniform ints samples + var g0r0 = g0.restricted(-1, 20); + Asserts.assertEQ(g0r0.next(), -1); + Asserts.assertEQ(g0r0.next(), 18); + + mockSource + .checkEmpty() + .enqueueInteger(0, 7, 6) // MixedGenerator chooses a generator (weight for single will have been removed): uniform ints + .enqueueInteger(4, 21, 9); // MixedGenerator chooses a generator: uniform ints + var g0r1 = g0.restricted(4, 20); + Asserts.assertEQ(g0r1.next(), 9); + + mockSource + .checkEmpty() + .enqueueInteger(0, 10, 1) // MixedGenerator chooses a generator: the first uniform ints + .enqueueInteger(0, 21, 2) // uniform ints (1) samples + .enqueueInteger(0, 10, 2) // MixedGenerator chooses a generator: single + // single does not use randomness + .enqueueInteger(0, 10, 7) // MixedGenerator chooses a generator: the second uniform ints + .enqueueInteger(-1, 0, -1); + var g1r0 = g1.restricted(-1, 20); + Asserts.assertEQ(g1r0.next(), 2); + Asserts.assertEQ(g1r0.next(), -1); + Asserts.assertEQ(g1r0.next(), -1); + + mockSource + .checkEmpty() + .enqueueInteger(0, 10, 1) // MixedGenerator chooses a generator: the first uniform ints + .enqueueInteger(0, 21, 2) // uniform ints (1) samples + .enqueueInteger(0, 10, 2) // MixedGenerator chooses a generator: single + // single does not use randomness + .enqueueInteger(0, 10, 7) // MixedGenerator chooses a generator: the second uniform ints + .enqueueInteger(-1, 0, -1); + var g1r1 = g1.restricted(-1, 20); + Asserts.assertEQ(g1r1.next(), 2); + Asserts.assertEQ(g1r1.next(), -1); + Asserts.assertEQ(g1r1.next(), -1); + } + + static void testSpecialDouble() { + mockSource + .checkEmpty() + .enqueueInteger(0, 10, 3) + .enqueueDouble(0, 1, 3.4d) + .enqueueInteger(0, 10, 6) + .enqueueInteger(0, 9, 1); + var g = mockGS.mixedWithSpecialDoubles(mockGS.uniformDoubles(), 5, 5); + Asserts.assertEQ(g.next(), 3.4d); + Asserts.assertEQ(g.next(), -1d); + } + + static void testSpecialFloat() { + mockSource + .checkEmpty() + .enqueueInteger(0, 10, 3) + .enqueueFloat(0, 1, 3.4f) + .enqueueInteger(0, 10, 6) + .enqueueInteger(0, 9, 1); + var g = mockGS.mixedWithSpecialFloats(mockGS.uniformFloats(), 5, 5); + Asserts.assertEQ(g.next(), 3.4f); + Asserts.assertEQ(g.next(), -1f); + } + + static void testUniformFloat() { + mockSource.checkEmpty().enqueueFloat(-1, 10, 3.14159f); + Asserts.assertEQ(mockGS.uniformFloats(-1, 10).next(), 3.14159f); + mockSource.checkEmpty().enqueueFloat(0, 1, 3.14159f); + Asserts.assertEQ(mockGS.uniformFloats(0, 1).next(), 3.14159f); + } + + static void testUniformDouble() { + mockSource.checkEmpty().enqueueDouble(-1, 10, 3.14159d); + Asserts.assertEQ(mockGS.uniformDoubles(-1, 10).next(), 3.14159d); + mockSource.checkEmpty().enqueueDouble(0, 1, 3.14159d); + Asserts.assertEQ(mockGS.uniformDoubles(0, 1).next(), 3.14159d); + } + + static void testRandomElement() { + mockSource.checkEmpty().enqueueInteger(0, 3, 1).enqueueInteger(0, 3, 0); + var g = mockGS.randomElement(List.of("a", "b", "c")); + Asserts.assertEQ(g.next(), "b"); + Asserts.assertEQ(g.next(), "a"); + + mockSource.checkEmpty().enqueueInteger(0, 8, 1).enqueueInteger(0, 8, 2); + // The list below is intentionally not sorted and is equivalent to: 1, 4, 4, 8, 9, 10, 13, 18, 20 + // It contains 8 distinct values. Note that orderedRandomElement removes duplicates. Therefore the internal + // value list is: 1, 4, 8, 9, 10, 13, 18, 20 + var g1 = mockGS.orderedRandomElement(List.of(10, 4, 1, 8, 9, 4, 20, 18, 13)); + Asserts.assertEQ(g1.next(), 4); + Asserts.assertEQ(g1.next(), 8); + + mockSource.checkEmpty().enqueueInteger(0, 3, 1).enqueueInteger(0, 3, 2); + // Ordered lists can also be restricted. Our new values are 9, 10, 13. + var gr = g1.restricted(9, 13); + Asserts.assertEQ(gr.next(), 10); + Asserts.assertEQ(gr.next(), 13); + + mockSource.checkEmpty().enqueueInteger(0, 2, 1); + var gs = mockGS.orderedRandomElement(List.of("Bob", "Alice", "Carol")).restricted("Al", "Bz"); + Asserts.assertEQ(gs.next(), "Bob"); + } + + static void specialInt() { + mockSource.checkEmpty().enqueueInteger(0, 63, 1).enqueueInteger(0, 63, 32); + var si = mockGS.powerOfTwoInts(0); + Asserts.assertEQ(si.next(), -(1 << 30)); + Asserts.assertEQ(si.next(), 1); + + mockSource.checkEmpty().enqueueInteger(0, 182, 1); + var si1 = mockGS.powerOfTwoInts(1); + Asserts.assertEQ(si1.next(), -(1 << 31) + 1); + } + + static void specialLong() { + mockSource.checkEmpty().enqueueInteger(0, 127, 1).enqueueInteger(0, 127, 64); + var si = mockGS.powerOfTwoLongs(0); + Asserts.assertEQ(si.next(), -(1L << 62)); + Asserts.assertEQ(si.next(), 1L); + + mockSource.checkEmpty().enqueueInteger(0, 374, 1); + var si1 = mockGS.powerOfTwoLongs(1); + Asserts.assertEQ(si1.next(), -(1L << 63) + 1); + } + + static void testSingle() { + mockSource.checkEmpty(); + var g = mockGS.single(30); + Asserts.assertEQ(g.next(), 30); + Asserts.assertEQ(g.next(), 30); + Asserts.assertEQ(g.restricted(10, 50).next(), 30); + var gs = mockGS.single("hello"); + Asserts.assertEQ(gs.next(), "hello"); + Asserts.assertEQ(gs.next(), "hello"); + Asserts.assertEQ(gs.restricted("a", "q").next(), "hello"); + var theObject = new Object(); + var go = mockGS.single(theObject); + Asserts.assertEQ(go.next(), theObject); + Asserts.assertEQ(go.next(), theObject); + } + + static void testUniformInts() { + mockSource.checkEmpty().enqueueInteger(0, 11, 1).enqueueInteger(0, 11, 4); + var g0 = mockGS.uniformInts(0, 10); + Asserts.assertEQ(g0.next(), 1); + Asserts.assertEQ(g0.next(), 4); + + mockSource.checkEmpty().enqueueInteger(0, 1, 0).enqueueInteger(0, 1, 0); + var g1 = mockGS.uniformInts(0, 0); + Asserts.assertEQ(g1.next(), 0); + Asserts.assertEQ(g1.next(), 0); + + mockSource.checkEmpty().enqueueInteger(-1, Integer.MAX_VALUE, 10); + Asserts.assertEQ(mockGS.uniformInts(0, Integer.MAX_VALUE).next(), 11); + + mockSource.checkEmpty().enqueueInteger(Integer.MIN_VALUE, 13, -33); + Asserts.assertEQ(mockGS.uniformInts(Integer.MIN_VALUE, 12).next(), -33); + + mockSource.checkEmpty().enqueueInteger(11); + Asserts.assertEQ(mockGS.uniformInts(Integer.MIN_VALUE, Integer.MAX_VALUE).next(), 11); + + mockSource.checkEmpty().enqueueInteger(10, 29, 17); + Asserts.assertEQ(mockGS.uniformInts(Integer.MIN_VALUE, Integer.MAX_VALUE).restricted(10, 28).next(), 17); + + mockSource.checkEmpty().enqueueInteger(19, 29, 17); + Asserts.assertEQ(mockGS.uniformInts(Integer.MIN_VALUE, Integer.MAX_VALUE).restricted(10, 28).restricted(19, 33).next(), 17); + + // inside interval positive + mockSource.checkEmpty().enqueueInteger(12, 19, 17); + Asserts.assertEQ(mockGS.uniformInts(10, 20).restricted(12, 18).next(), 17); + + // inside interval negative + mockSource.checkEmpty().enqueueInteger(-18, -11, -17); + Asserts.assertEQ(mockGS.uniformInts(-20, -10).restricted(-18, -12).next(), -17); + + // left interval positive + mockSource.checkEmpty().enqueueInteger(10, 13, 11); + Asserts.assertEQ(mockGS.uniformInts(10, 20).restricted(5, 12).next(), 11); + + // left interval negative + mockSource.checkEmpty().enqueueInteger(-12, -9, -11); + Asserts.assertEQ(mockGS.uniformInts(-20, -10).restricted(-12, -5).next(), -11); + + // right interval positive + mockSource.checkEmpty().enqueueInteger(17, 21, 19); + Asserts.assertEQ(mockGS.uniformInts(10, 20).restricted(17, 22).next(), 19); + + // right interval negative + mockSource.checkEmpty().enqueueInteger(-20, -16, -19); + Asserts.assertEQ(mockGS.uniformInts(-20, -10).restricted(-22, -17).next(), -19); + + mockSource.checkEmpty().enqueueInteger(144); + Asserts.assertEQ(mockGS.uniformInts().next(), 144); + + mockSource.checkEmpty(); + } + + static void testUniformLongs() { + mockSource.checkEmpty().enqueueLong(0, 11, 1).enqueueLong(0, 11, 4); + var g0 = mockGS.uniformLongs(0, 10); + Asserts.assertEQ(g0.next(), 1L); + Asserts.assertEQ(g0.next(), 4L); + + mockSource.checkEmpty().enqueueLong(0, 1, 0).enqueueLong(0, 1, 0); + var g1 = mockGS.uniformLongs(0, 0); + Asserts.assertEQ(g1.next(), 0L); + Asserts.assertEQ(g1.next(), 0L); + + mockSource.checkEmpty().enqueueLong(-1, Long.MAX_VALUE, 10); + Asserts.assertEQ(mockGS.uniformLongs(0, Long.MAX_VALUE).next(), 11L); + + mockSource.checkEmpty().enqueueLong(Long.MIN_VALUE, 13, -33); + Asserts.assertEQ(mockGS.uniformLongs(Long.MIN_VALUE, 12).next(), -33L); + + mockSource.checkEmpty().enqueueLong(11); + Asserts.assertEQ(mockGS.uniformLongs(Long.MIN_VALUE, Long.MAX_VALUE).next(), 11L); + + mockSource.checkEmpty().enqueueLong(10, 29, 17); + Asserts.assertEQ(mockGS.uniformLongs(Long.MIN_VALUE, Long.MAX_VALUE).restricted(10L, 28L).next(), 17L); + + mockSource.checkEmpty().enqueueLong(19, 29, 17); + Asserts.assertEQ(mockGS.uniformLongs(Long.MIN_VALUE, Long.MAX_VALUE).restricted(10L, 28L).restricted(19L, 33L).next(), 17L); + + mockSource.checkEmpty().enqueueLong(144); + Asserts.assertEQ(mockGS.uniformLongs().next(), 144L); + + mockSource.checkEmpty(); + } + + static void testAnyBits() { + mockSource.checkEmpty().enqueueInteger(Float.floatToIntBits(3.14159f)); + Asserts.assertEQ(mockGS.anyBitsFloats().next(), 3.14159f); + + mockSource.checkEmpty().enqueueLong(Double.doubleToLongBits(3.14159d)); + Asserts.assertEQ(mockGS.anyBitsDouble().next(), 3.14159d); + } + + static void testEmptyGenerators() { + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.uniformInts(1, 0)); + Asserts.assertNotNull(G.uniformInts(0, 0)); + Asserts.assertNotNull(G.uniformInts(0, 1)); + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.uniformInts(0, 1).restricted(2, 5)); + Asserts.assertNotNull(G.uniformInts(0, 1).restricted(0, 1)); + Asserts.assertNotNull(G.uniformInts(0, 1).restricted(1, 5)); + Asserts.assertNotNull(G.uniformInts(0, 10).restricted(1, 2)); + + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.uniformLongs(1, 0)); + Asserts.assertNotNull(G.uniformLongs(0, 0)); + Asserts.assertNotNull(G.uniformLongs(0, 1)); + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.uniformLongs(0, 1).restricted(2L, 5L)); + Asserts.assertNotNull(G.uniformLongs(0, 1).restricted(0L, 1L)); + Asserts.assertNotNull(G.uniformLongs(0, 1).restricted(1L, 5L)); + Asserts.assertNotNull(G.uniformLongs(0, 10).restricted(1L, 2L)); + + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.uniformDoubles(1, 0)); + Asserts.assertNotNull(G.uniformDoubles(0, 1)); + Asserts.assertNotNull(G.uniformDoubles(0, 0)); + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.uniformDoubles(0, 1).restricted(1.1d, 2.4d)); + Asserts.assertNotNull(G.uniformDoubles(0, 1).restricted(0.9d, 2.4d)); + + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.uniformFloats(1, 0)); + Asserts.assertNotNull(G.uniformFloats(0, 1)); + Asserts.assertNotNull(G.uniformFloats(0, 0)); + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.uniformFloats(0, 1).restricted(1.1f, 2.4f)); + Asserts.assertNotNull(G.uniformFloats(0, 1).restricted(0.9f, 2.4f)); + + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.randomElement(List.of())); + Asserts.assertNotNull(G.randomElement(List.of("a", "b", "c"))); + + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.orderedRandomElement(new ArrayList())); + Asserts.assertNotNull(G.orderedRandomElement(List.of(48, 29, 17))); + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.orderedRandomElement(List.of(48, 29, 17)).restricted(-12, 10)); + + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.single(10).restricted(0, 1)); + Asserts.assertNotNull(G.single(10).restricted(9, 10)); + + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.mixed(G.uniformInts(0, 10), G.uniformInts(15, 20), 5, 5).restricted(30, 34)); + Asserts.assertNotNull(G.mixed(G.uniformInts(0, 10), G.uniformInts(15, 20), 5, 5).restricted(5, 18)); + Asserts.assertNotNull(G.mixed(G.uniformInts(0, 10), G.uniformInts(15, 20), 5, 5).restricted(5, 7)); + Asserts.assertNotNull(G.mixed(G.uniformInts(0, 10), G.uniformInts(15, 20), 5, 5).restricted(16, 18)); + + Asserts.assertThrows(EmptyGeneratorException.class, () -> G.mixed( + List.of(3, 4, 6), + G.uniformInts(0, 10), G.uniformInts(15, 20), G.uniformInts(30, 40) + ).restricted(80, 83)); + Asserts.assertNotNull(G.mixed( + List.of(3, 4, 6), + G.uniformInts(0, 10), G.uniformInts(15, 20), G.uniformInts(30, 40) + ).restricted(10, 35)); + Asserts.assertNotNull(G.mixed( + List.of(3, 4, 6), + G.uniformInts(0, 10), G.uniformInts(15, 20), G.uniformInts(30, 40) + ).restricted(5, 8)); + Asserts.assertNotNull(G.mixed( + List.of(3, 4, 6), + G.uniformInts(0, 10), G.uniformInts(15, 20), G.uniformInts(30, 40) + ).restricted(17, 19)); + Asserts.assertNotNull(G.mixed( + List.of(3, 4, 6), + G.uniformInts(0, 10), G.uniformInts(15, 20), G.uniformInts(30, 40) + ).restricted(31, 38)); + } + + static void testSafeRestrict() { + // normal restrictions + mockSource.checkEmpty().enqueueInteger(4, 6, 4); + var g1 = mockGS.safeRestrict(mockGS.uniformInts(4, 5), 2, 5); + Asserts.assertEQ(g1.next(), 4); + + mockSource.checkEmpty().enqueueLong(4, 6, 4); + var g2 = mockGS.safeRestrict(mockGS.uniformLongs(4, 5), 2, 5); + Asserts.assertEQ(g2.next(), 4L); + + mockSource.checkEmpty().enqueueDouble(4, 5, 4); + var g3 = mockGS.safeRestrict(mockGS.uniformDoubles(4, 5), 2, 5); + Asserts.assertEQ(g3.next(), 4d); + + mockSource.checkEmpty().enqueueFloat(4, 5, 4); + var g4 = mockGS.safeRestrict(mockGS.uniformFloats(4, 5), 2, 5); + Asserts.assertEQ(g4.next(), 4f); + + // fallbacks + mockSource.checkEmpty().enqueueInteger(2, 6, 4); + var f1 = mockGS.safeRestrict(mockGS.uniformInts(0, 1), 2, 5); + Asserts.assertEQ(f1.next(), 4); + + mockSource.checkEmpty().enqueueLong(2, 6, 4); + var f2 = mockGS.safeRestrict(mockGS.uniformLongs(0, 1), 2, 5); + Asserts.assertEQ(f2.next(), 4L); + + mockSource.checkEmpty().enqueueDouble(2, 5, 4); + var f3 = mockGS.safeRestrict(mockGS.uniformDoubles(0, 1), 2, 5); + Asserts.assertEQ(f3.next(), 4d); + + mockSource.checkEmpty().enqueueFloat(2, 5, 4); + var f4 = mockGS.safeRestrict(mockGS.uniformFloats(0, 1), 2, 5); + Asserts.assertEQ(f4.next(), 4f); + } + + static void testFill() { + // All we need to test really is that fill calls the generators sequentially and correctly writes the values + // into the arrays. Since fill with arrays uses memory segments internally, these are also tested. + + Generator doubleGen = new Generator<>() { + private double i = 1; + + @Override + public Double next() { + i /= 2; + return i; + } + }; + + double[] doubles = new double[5]; + mockGS.fill(doubleGen, doubles); + Asserts.assertTrue(Arrays.equals(doubles, (new double[] {0.5, 0.25, 0.125, 0.0625, 0.03125}))); + + Generator floatGen = new Generator<>() { + private float i = 1; + + @Override + public Float next() { + i /= 2; + return i; + } + }; + + float[] floats = new float[5]; + mockGS.fill(floatGen, floats); + Asserts.assertTrue(Arrays.equals(floats, (new float[] {0.5f, 0.25f, 0.125f, 0.0625f, 0.03125f}))); + + Generator longGen = new Generator<>() { + private long i = 1; + + @Override + public Long next() { + return i++; + } + }; + + long[] longs = new long[5]; + mockGS.fill(longGen, longs); + Asserts.assertTrue(Arrays.equals(longs, (new long[] {1, 2, 3, 4, 5}))); + + Generator intGen = new Generator<>() { + private int i = 1; + + @Override + public Integer next() { + return i++; + } + }; + + int[] ints = new int[5]; + mockGS.fill(intGen, ints); + Asserts.assertTrue(Arrays.equals(ints, (new int[] {1, 2, 3, 4, 5}))); + } + + static void testFuzzy() { + var intBoundGen = G.uniformInts(); + for (int j = 0; j < 500; j++) { + int a = intBoundGen.next(), b = intBoundGen.next(); + int lo = Math.min(a, b), hi = Math.max(a, b); + RestrictableGenerator gb; + try { + gb = G.ints().restricted(lo, hi); + } catch (EmptyGeneratorException e) { + continue; + } + for (int i = 0; i < 10_000; i++) { + int x = gb.next(); + Asserts.assertGreaterThanOrEqual(x, lo); + Asserts.assertLessThanOrEqual(x, hi); + } + } + + for (int j = 0; j < 500; j++) { + int a = intBoundGen.next(), b = intBoundGen.next(); + int lo = Math.min(a, b), hi = Math.max(a, b); + var gb = G.uniformInts(lo, hi); + for (int i = 0; i < 10_000; i++) { + int x = gb.next(); + Asserts.assertGreaterThanOrEqual(x, lo); + Asserts.assertLessThanOrEqual(x, hi); + } + } + + var longBoundGen = G.uniformLongs(); + for (int j = 0; j < 500; j++) { + long a = longBoundGen.next(), b = longBoundGen.next(); + long lo = Math.min(a, b), hi = Math.max(a, b); + RestrictableGenerator gb; + try { + gb = G.longs().restricted(lo, hi); + } catch (EmptyGeneratorException e) { + continue; + } + for (int i = 0; i < 10_000; i++) { + long x = gb.next(); + Asserts.assertGreaterThanOrEqual(x, lo); + Asserts.assertLessThanOrEqual(x, hi); + } + } + + for (int j = 0; j < 500; j++) { + long a = longBoundGen.next(), b = longBoundGen.next(); + long lo = Math.min(a, b), hi = Math.max(a, b); + var gb = G.uniformLongs(lo, hi); + for (int i = 0; i < 10_000; i++) { + long x = gb.next(); + Asserts.assertGreaterThanOrEqual(x, lo); + Asserts.assertLessThanOrEqual(x, hi); + } + } + + var floatBoundGen = G.uniformFloats(); + for (int j = 0; j < 500; j++) { + float a = floatBoundGen.next(), b = floatBoundGen.next(); + float lo = Math.min(a, b), hi = Math.max(a, b); + var gb = G.uniformFloats(lo, hi); + for (int i = 0; i < 10_000; i++) { + float x = gb.next(); + Asserts.assertGreaterThanOrEqual(x, lo); + Asserts.assertLessThan(x, hi); + } + } + + var doubleBoundGen = G.uniformDoubles(); + for (int j = 0; j < 500; j++) { + double a = doubleBoundGen.next(), b = doubleBoundGen.next(); + double lo = Math.min(a, b), hi = Math.max(a, b); + var gb = G.uniformDoubles(lo, hi); + for (int i = 0; i < 10_000; i++) { + double x = gb.next(); + Asserts.assertGreaterThanOrEqual(x, lo); + Asserts.assertLessThan(x, hi); + } + } + } +} From cbe2f9654eb7330c2e8cbe74e8abc2db63ec867b Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Thu, 16 Jan 2025 12:46:32 +0000 Subject: [PATCH 21/47] 8347732: Replace SIZE_FORMAT in shenandoah Reviewed-by: wkemper, ysr --- .../shenandoahAdaptiveHeuristics.cpp | 21 ++-- .../shenandoahCompactHeuristics.cpp | 7 +- .../shenandoahGenerationalHeuristics.cpp | 27 ++--- .../heuristics/shenandoahGlobalHeuristics.cpp | 5 +- .../heuristics/shenandoahHeuristics.cpp | 10 +- .../heuristics/shenandoahOldHeuristics.cpp | 29 ++--- .../shenandoahPassiveHeuristics.cpp | 3 +- .../heuristics/shenandoahStaticHeuristics.cpp | 3 +- .../heuristics/shenandoahYoungHeuristics.cpp | 5 +- .../gc/shenandoah/shenandoahAgeCensus.cpp | 12 +- .../gc/shenandoah/shenandoahArguments.cpp | 3 +- .../gc/shenandoah/shenandoahCardStats.cpp | 7 +- .../gc/shenandoah/shenandoahCollectionSet.cpp | 4 +- .../shenandoah/shenandoahCollectorPolicy.cpp | 39 +++---- .../gc/shenandoah/shenandoahConcurrentGC.cpp | 6 +- .../gc/shenandoah/shenandoahController.cpp | 5 +- .../gc/shenandoah/shenandoahEvacTracker.cpp | 5 +- .../share/gc/shenandoah/shenandoahFreeSet.cpp | 107 +++++++++--------- .../share/gc/shenandoah/shenandoahFullGC.cpp | 21 ++-- .../gc/shenandoah/shenandoahGeneration.cpp | 21 ++-- .../shenandoah/shenandoahGenerationSizer.cpp | 9 +- .../shenandoahGenerationalEvacuationTask.cpp | 17 +-- .../shenandoahGenerationalFullGC.cpp | 11 +- .../shenandoah/shenandoahGenerationalHeap.cpp | 17 +-- .../share/gc/shenandoah/shenandoahHeap.cpp | 40 +++---- .../gc/shenandoah/shenandoahHeap.inline.hpp | 3 +- .../gc/shenandoah/shenandoahHeapRegion.cpp | 48 ++++---- .../shenandoahHeapRegion.inline.hpp | 9 +- .../shenandoahHeapRegionClosures.cpp | 5 +- .../shenandoahHeapRegionCounters.cpp | 3 +- .../gc/shenandoah/shenandoahHeapRegionSet.cpp | 3 +- .../gc/shenandoah/shenandoahInitLogger.cpp | 3 +- .../gc/shenandoah/shenandoahMark.inline.hpp | 7 +- .../gc/shenandoah/shenandoahMarkBitMap.cpp | 8 +- .../shenandoah/shenandoahMarkingContext.cpp | 9 +- .../shenandoahMarkingContext.inline.hpp | 11 +- .../gc/shenandoah/shenandoahMemoryPool.cpp | 9 +- .../share/gc/shenandoah/shenandoahMetrics.cpp | 5 +- .../gc/shenandoah/shenandoahNumberSeq.cpp | 5 +- .../gc/shenandoah/shenandoahOldGeneration.cpp | 11 +- .../share/gc/shenandoah/shenandoahPacer.cpp | 17 +-- .../shenandoahReferenceProcessor.cpp | 8 +- .../shenandoah/shenandoahScanRemembered.cpp | 13 ++- .../shenandoahScanRemembered.inline.hpp | 7 +- .../gc/shenandoah/shenandoahVerifier.cpp | 16 +-- 45 files changed, 337 insertions(+), 297 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp index 94c544a7ea36b..823e7245f3125 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -96,8 +97,8 @@ void ShenandoahAdaptiveHeuristics::choose_collection_set_from_regiondata(Shenand size_t free_target = (capacity / 100 * ShenandoahMinFreeThreshold) + max_cset; size_t min_garbage = (free_target > actual_free ? (free_target - actual_free) : 0); - log_info(gc, ergo)("Adaptive CSet Selection. Target Free: " SIZE_FORMAT "%s, Actual Free: " - SIZE_FORMAT "%s, Max Evacuation: " SIZE_FORMAT "%s, Min Garbage: " SIZE_FORMAT "%s", + log_info(gc, ergo)("Adaptive CSet Selection. Target Free: %zu%s, Actual Free: " + "%zu%s, Max Evacuation: %zu%s, Min Garbage: %zu%s", byte_size_in_proper_unit(free_target), proper_unit_for_byte_size(free_target), byte_size_in_proper_unit(actual_free), proper_unit_for_byte_size(actual_free), byte_size_in_proper_unit(max_cset), proper_unit_for_byte_size(max_cset), @@ -142,7 +143,7 @@ void ShenandoahAdaptiveHeuristics::record_success_concurrent() { if (available_sd > 0) { double available_avg = _available.avg(); z_score = (double(available) - available_avg) / available_sd; - log_debug(gc, ergo)("Available: " SIZE_FORMAT " %sB, z-score=%.3f. Average available: %.1f %sB +/- %.1f %sB.", + log_debug(gc, ergo)("Available: %zu %sB, z-score=%.3f. Average available: %.1f %sB +/- %.1f %sB.", byte_size_in_proper_unit(available), proper_unit_for_byte_size(available), z_score, byte_size_in_proper_unit(available_avg), proper_unit_for_byte_size(available_avg), @@ -237,8 +238,8 @@ bool ShenandoahAdaptiveHeuristics::should_start_gc() { size_t available = _space_info->soft_available(); size_t allocated = _space_info->bytes_allocated_since_gc_start(); - log_debug(gc)("should_start_gc? available: " SIZE_FORMAT ", soft_max_capacity: " SIZE_FORMAT - ", allocated: " SIZE_FORMAT, available, capacity, allocated); + log_debug(gc)("should_start_gc? available: %zu, soft_max_capacity: %zu" + ", allocated: %zu", available, capacity, allocated); // Track allocation rate even if we decide to start a cycle for other reasons. double rate = _allocation_rate.sample(allocated); @@ -246,7 +247,7 @@ bool ShenandoahAdaptiveHeuristics::should_start_gc() { size_t min_threshold = min_free_threshold(); if (available < min_threshold) { - log_trigger("Free (" SIZE_FORMAT "%s) is below minimum threshold (" SIZE_FORMAT "%s)", + log_trigger("Free (%zu%s) is below minimum threshold (%zu%s)", byte_size_in_proper_unit(available), proper_unit_for_byte_size(available), byte_size_in_proper_unit(min_threshold), proper_unit_for_byte_size(min_threshold)); return true; @@ -257,7 +258,7 @@ bool ShenandoahAdaptiveHeuristics::should_start_gc() { if (_gc_times_learned < max_learn) { size_t init_threshold = capacity / 100 * ShenandoahInitFreeThreshold; if (available < init_threshold) { - log_trigger("Learning " SIZE_FORMAT " of " SIZE_FORMAT ". Free (" SIZE_FORMAT "%s) is below initial threshold (" SIZE_FORMAT "%s)", + log_trigger("Learning %zu of %zu. Free (%zu%s) is below initial threshold (%zu%s)", _gc_times_learned + 1, max_learn, byte_size_in_proper_unit(available), proper_unit_for_byte_size(available), byte_size_in_proper_unit(init_threshold), proper_unit_for_byte_size(init_threshold)); @@ -282,12 +283,12 @@ bool ShenandoahAdaptiveHeuristics::should_start_gc() { avg_cycle_time * 1000, byte_size_in_proper_unit(avg_alloc_rate), proper_unit_for_byte_size(avg_alloc_rate)); if (avg_cycle_time * avg_alloc_rate > allocation_headroom) { log_trigger("Average GC time (%.2f ms) is above the time for average allocation rate (%.0f %sB/s)" - " to deplete free headroom (" SIZE_FORMAT "%s) (margin of error = %.2f)", + " to deplete free headroom (%zu%s) (margin of error = %.2f)", avg_cycle_time * 1000, byte_size_in_proper_unit(avg_alloc_rate), proper_unit_for_byte_size(avg_alloc_rate), byte_size_in_proper_unit(allocation_headroom), proper_unit_for_byte_size(allocation_headroom), _margin_of_error_sd); - log_info(gc, ergo)("Free headroom: " SIZE_FORMAT "%s (free) - " SIZE_FORMAT "%s (spike) - " SIZE_FORMAT "%s (penalties) = " SIZE_FORMAT "%s", + log_info(gc, ergo)("Free headroom: %zu%s (free) - %zu%s (spike) - %zu%s (penalties) = %zu%s", byte_size_in_proper_unit(available), proper_unit_for_byte_size(available), byte_size_in_proper_unit(spike_headroom), proper_unit_for_byte_size(spike_headroom), byte_size_in_proper_unit(penalties), proper_unit_for_byte_size(penalties), @@ -298,7 +299,7 @@ bool ShenandoahAdaptiveHeuristics::should_start_gc() { bool is_spiking = _allocation_rate.is_spiking(rate, _spike_threshold_sd); if (is_spiking && avg_cycle_time > allocation_headroom / rate) { - log_trigger("Average GC time (%.2f ms) is above the time for instantaneous allocation rate (%.0f %sB/s) to deplete free headroom (" SIZE_FORMAT "%s) (spike threshold = %.2f)", + log_trigger("Average GC time (%.2f ms) is above the time for instantaneous allocation rate (%.0f %sB/s) to deplete free headroom (%zu%s) (spike threshold = %.2f)", avg_cycle_time * 1000, byte_size_in_proper_unit(rate), proper_unit_for_byte_size(rate), byte_size_in_proper_unit(allocation_headroom), proper_unit_for_byte_size(allocation_headroom), diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp index 2c7594e10dc5d..efccfbb9c8398 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 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 @@ -58,7 +59,7 @@ bool ShenandoahCompactHeuristics::should_start_gc() { size_t min_threshold = capacity / 100 * ShenandoahMinFreeThreshold; if (available < min_threshold) { - log_trigger("Free (" SIZE_FORMAT "%s) is below minimum threshold (" SIZE_FORMAT "%s)", + log_trigger("Free (%zu%s) is below minimum threshold (%zu%s)", byte_size_in_proper_unit(available), proper_unit_for_byte_size(available), byte_size_in_proper_unit(min_threshold), proper_unit_for_byte_size(min_threshold)); return true; @@ -66,7 +67,7 @@ bool ShenandoahCompactHeuristics::should_start_gc() { size_t bytes_allocated = _space_info->bytes_allocated_since_gc_start(); if (bytes_allocated > threshold_bytes_allocated) { - log_trigger("Allocated since last cycle (" SIZE_FORMAT "%s) is larger than allocation threshold (" SIZE_FORMAT "%s)", + log_trigger("Allocated since last cycle (%zu%s) is larger than allocation threshold (%zu%s)", byte_size_in_proper_unit(bytes_allocated), proper_unit_for_byte_size(bytes_allocated), byte_size_in_proper_unit(threshold_bytes_allocated), proper_unit_for_byte_size(threshold_bytes_allocated)); return true; @@ -81,7 +82,7 @@ void ShenandoahCompactHeuristics::choose_collection_set_from_regiondata(Shenando // Do not select too large CSet that would overflow the available free space size_t max_cset = actual_free * 3 / 4; - log_info(gc, ergo)("CSet Selection. Actual Free: " SIZE_FORMAT "%s, Max CSet: " SIZE_FORMAT "%s", + log_info(gc, ergo)("CSet Selection. Actual Free: %zu%s, Max CSet: %zu%s", byte_size_in_proper_unit(actual_free), proper_unit_for_byte_size(actual_free), byte_size_in_proper_unit(max_cset), proper_unit_for_byte_size(max_cset)); diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp index 5b6d82d97a4c9..3249df7f29aa0 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -134,7 +135,7 @@ void ShenandoahGenerationalHeuristics::choose_collection_set(ShenandoahCollectio bool reg_live = region->has_live(); bool bm_live = heap->complete_marking_context()->is_marked(cast_to_oop(region->bottom())); assert(reg_live == bm_live, - "Humongous liveness and marks should agree. Region live: %s; Bitmap live: %s; Region Live Words: " SIZE_FORMAT, + "Humongous liveness and marks should agree. Region live: %s; Bitmap live: %s; Region Live Words: %zu", BOOL_TO_STR(reg_live), BOOL_TO_STR(bm_live), region->get_live_data_words()); #endif if (!region->has_live()) { @@ -158,8 +159,8 @@ void ShenandoahGenerationalHeuristics::choose_collection_set(ShenandoahCollectio } heap->old_generation()->set_expected_humongous_region_promotions(humongous_regions_promoted); heap->old_generation()->set_expected_regular_region_promotions(regular_regions_promoted_in_place); - log_info(gc, ergo)("Planning to promote in place " SIZE_FORMAT " humongous regions and " SIZE_FORMAT - " regular regions, spanning a total of " SIZE_FORMAT " used bytes", + log_info(gc, ergo)("Planning to promote in place %zu humongous regions and %zu" + " regular regions, spanning a total of %zu used bytes", humongous_regions_promoted, regular_regions_promoted_in_place, humongous_regions_promoted * ShenandoahHeapRegion::region_size_bytes() + regular_regions_promoted_usage); @@ -168,7 +169,7 @@ void ShenandoahGenerationalHeuristics::choose_collection_set(ShenandoahCollectio // given the amount of immediately reclaimable garbage. If we do, figure out the collection set. assert (immediate_garbage <= total_garbage, - "Cannot have more immediate garbage than total garbage: " SIZE_FORMAT "%s vs " SIZE_FORMAT "%s", + "Cannot have more immediate garbage than total garbage: %zu%s vs %zu%s", byte_size_in_proper_unit(immediate_garbage), proper_unit_for_byte_size(immediate_garbage), byte_size_in_proper_unit(total_garbage), proper_unit_for_byte_size(total_garbage)); @@ -193,9 +194,9 @@ void ShenandoahGenerationalHeuristics::choose_collection_set(ShenandoahCollectio size_t collectable_garbage = collection_set->garbage() + immediate_garbage; size_t collectable_garbage_percent = (total_garbage == 0) ? 0 : (collectable_garbage * 100 / total_garbage); - log_info(gc, ergo)("Collectable Garbage: " SIZE_FORMAT "%s (" SIZE_FORMAT "%%), " - "Immediate: " SIZE_FORMAT "%s (" SIZE_FORMAT "%%), " SIZE_FORMAT " regions, " - "CSet: " SIZE_FORMAT "%s (" SIZE_FORMAT "%%), " SIZE_FORMAT " regions", + log_info(gc, ergo)("Collectable Garbage: %zu%s (%zu%%), " + "Immediate: %zu%s (%zu%%), %zu regions, " + "CSet: %zu%s (%zu%%), %zu regions", byte_size_in_proper_unit(collectable_garbage), proper_unit_for_byte_size(collectable_garbage), @@ -216,10 +217,10 @@ void ShenandoahGenerationalHeuristics::choose_collection_set(ShenandoahCollectio size_t promote_evac_bytes = collection_set->get_young_bytes_to_be_promoted(); size_t old_evac_bytes = collection_set->get_old_bytes_reserved_for_evacuation(); size_t total_evac_bytes = young_evac_bytes + promote_evac_bytes + old_evac_bytes; - log_info(gc, ergo)("Evacuation Targets: YOUNG: " SIZE_FORMAT "%s, " - "PROMOTE: " SIZE_FORMAT "%s, " - "OLD: " SIZE_FORMAT "%s, " - "TOTAL: " SIZE_FORMAT "%s", + log_info(gc, ergo)("Evacuation Targets: YOUNG: %zu%s, " + "PROMOTE: %zu%s, " + "OLD: %zu%s, " + "TOTAL: %zu%s", byte_size_in_proper_unit(young_evac_bytes), proper_unit_for_byte_size(young_evac_bytes), byte_size_in_proper_unit(promote_evac_bytes), proper_unit_for_byte_size(promote_evac_bytes), byte_size_in_proper_unit(old_evac_bytes), proper_unit_for_byte_size(old_evac_bytes), @@ -282,8 +283,8 @@ void ShenandoahGenerationalHeuristics::log_cset_composition(ShenandoahCollection size_t collected_young = cset->get_young_bytes_reserved_for_evacuation(); log_info(gc, ergo)( - "Chosen CSet evacuates young: " SIZE_FORMAT "%s (of which at least: " SIZE_FORMAT "%s are to be promoted), " - "old: " SIZE_FORMAT "%s", + "Chosen CSet evacuates young: %zu%s (of which at least: %zu%s are to be promoted), " + "old: %zu%s", byte_size_in_proper_unit(collected_young), proper_unit_for_byte_size(collected_young), byte_size_in_proper_unit(collected_promoted), proper_unit_for_byte_size(collected_promoted), byte_size_in_proper_unit(collected_old), proper_unit_for_byte_size(collected_old)); diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp index 4c1e6b7bdff1e..aeaf74fffff23 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -92,8 +93,8 @@ void ShenandoahGlobalHeuristics::choose_global_collection_set(ShenandoahCollecti size_t free_target = (capacity * ShenandoahMinFreeThreshold) / 100 + max_young_cset; size_t min_garbage = (free_target > actual_free) ? (free_target - actual_free) : 0; - log_info(gc, ergo)("Adaptive CSet Selection for GLOBAL. Max Young Evacuation: " SIZE_FORMAT - "%s, Max Old Evacuation: " SIZE_FORMAT "%s, Actual Free: " SIZE_FORMAT "%s.", + log_info(gc, ergo)("Adaptive CSet Selection for GLOBAL. Max Young Evacuation: %zu" + "%s, Max Old Evacuation: %zu%s, Actual Free: %zu%s.", byte_size_in_proper_unit(max_young_cset), proper_unit_for_byte_size(max_young_cset), byte_size_in_proper_unit(max_old_cset), proper_unit_for_byte_size(max_old_cset), byte_size_in_proper_unit(actual_free), proper_unit_for_byte_size(actual_free)); diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp index 4aac8263bc54e..783086cd39838 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp @@ -122,7 +122,7 @@ void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collec bool reg_live = region->has_live(); bool bm_live = ctx->is_marked(cast_to_oop(region->bottom())); assert(reg_live == bm_live, - "Humongous liveness and marks should agree. Region live: %s; Bitmap live: %s; Region Live Words: " SIZE_FORMAT, + "Humongous liveness and marks should agree. Region live: %s; Bitmap live: %s; Region Live Words: %zu", BOOL_TO_STR(reg_live), BOOL_TO_STR(bm_live), region->get_live_data_words()); #endif if (!region->has_live()) { @@ -143,7 +143,7 @@ void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collec // given the amount of immediately reclaimable garbage. If we do, figure out the collection set. assert (immediate_garbage <= total_garbage, - "Cannot have more immediate garbage than total garbage: " SIZE_FORMAT "%s vs " SIZE_FORMAT "%s", + "Cannot have more immediate garbage than total garbage: %zu%s vs %zu%s", byte_size_in_proper_unit(immediate_garbage), proper_unit_for_byte_size(immediate_garbage), byte_size_in_proper_unit(total_garbage), proper_unit_for_byte_size(total_garbage)); @@ -157,9 +157,9 @@ void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collec size_t collectable_garbage = collection_set->garbage() + immediate_garbage; size_t collectable_garbage_percent = (total_garbage == 0) ? 0 : (collectable_garbage * 100 / total_garbage); - log_info(gc, ergo)("Collectable Garbage: " SIZE_FORMAT "%s (" SIZE_FORMAT "%%), " - "Immediate: " SIZE_FORMAT "%s (" SIZE_FORMAT "%%), " SIZE_FORMAT " regions, " - "CSet: " SIZE_FORMAT "%s (" SIZE_FORMAT "%%), " SIZE_FORMAT " regions", + log_info(gc, ergo)("Collectable Garbage: %zu%s (%zu%%), " + "Immediate: %zu%s (%zu%%), %zu regions, " + "CSet: %zu%s (%zu%%), %zu regions", byte_size_in_proper_unit(collectable_garbage), proper_unit_for_byte_size(collectable_garbage), diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp index abb2b7b266ad7..052181a8c6115 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahOldHeuristics.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -122,7 +123,7 @@ bool ShenandoahOldHeuristics::prime_collection_set(ShenandoahCollectionSet* coll } size_t remaining_old_evacuation_budget = old_evacuation_budget; - log_debug(gc)("Choose old regions for mixed collection: old evacuation budget: " SIZE_FORMAT "%s, candidates: %u", + log_debug(gc)("Choose old regions for mixed collection: old evacuation budget: %zu%s, candidates: %u", byte_size_in_proper_unit(old_evacuation_budget), proper_unit_for_byte_size(old_evacuation_budget), unprocessed_old_collection_candidates()); @@ -362,7 +363,7 @@ void ShenandoahOldHeuristics::prepare_for_old_collections() { immediate_regions++; immediate_garbage += garbage; size_t region_count = heap->trash_humongous_region_at(region); - log_debug(gc)("Trashed " SIZE_FORMAT " regions for humongous object.", region_count); + log_debug(gc)("Trashed %zu regions for humongous object.", region_count); } } else if (region->is_trash()) { // Count humongous objects made into trash here. @@ -443,7 +444,7 @@ void ShenandoahOldHeuristics::prepare_for_old_collections() { while ((defrag_count < bound_on_additional_regions) && (total_uncollected_old_regions < 7 * span_of_uncollected_regions / 8)) { ShenandoahHeapRegion* r = candidates[_last_old_collection_candidate].get_region(); - assert(r->is_regular() || r->is_regular_pinned(), "Region " SIZE_FORMAT " has wrong state for collection: %s", + assert(r->is_regular() || r->is_regular_pinned(), "Region %zu has wrong state for collection: %s", r->index(), ShenandoahHeapRegion::region_state_to_string(r->state())); const size_t region_garbage = r->garbage(); const size_t region_free = r->free(); @@ -466,12 +467,12 @@ void ShenandoahOldHeuristics::prepare_for_old_collections() { const size_t mixed_evac_live = old_candidates * region_size_bytes - (candidates_garbage + unfragmented); set_unprocessed_old_collection_candidates_live_memory(mixed_evac_live); - log_info(gc, ergo)("Old-Gen Collectable Garbage: " PROPERFMT " consolidated with free: " PROPERFMT ", over " SIZE_FORMAT " regions", + log_info(gc, ergo)("Old-Gen Collectable Garbage: " PROPERFMT " consolidated with free: " PROPERFMT ", over %zu regions", PROPERFMTARGS(collectable_garbage), PROPERFMTARGS(unfragmented), old_candidates); - log_info(gc, ergo)("Old-Gen Immediate Garbage: " PROPERFMT " over " SIZE_FORMAT " regions", + log_info(gc, ergo)("Old-Gen Immediate Garbage: " PROPERFMT " over %zu regions", PROPERFMTARGS(immediate_garbage), immediate_regions); - log_info(gc, ergo)("Old regions selected for defragmentation: " SIZE_FORMAT, defrag_count); - log_info(gc, ergo)("Old regions not selected: " SIZE_FORMAT, total_uncollected_old_regions); + log_info(gc, ergo)("Old regions selected for defragmentation: %zu", defrag_count); + log_info(gc, ergo)("Old regions not selected: %zu", total_uncollected_old_regions); if (unprocessed_old_collection_candidates() > 0) { _old_generation->transition_to(ShenandoahOldGeneration::EVACUATING); @@ -608,7 +609,7 @@ void ShenandoahOldHeuristics::set_trigger_if_old_is_overgrown() { size_t trigger_threshold = _old_gen->usage_trigger_threshold(); // Detects unsigned arithmetic underflow assert(old_used <= _heap->capacity(), - "Old used (" SIZE_FORMAT ", " SIZE_FORMAT") must not be more than heap capacity (" SIZE_FORMAT ")", + "Old used (%zu, %zu) must not be more than heap capacity (%zu)", _old_gen->used(), _old_gen->get_humongous_waste(), _heap->capacity()); if (old_used > trigger_threshold) { _growth_trigger = true; @@ -635,7 +636,7 @@ bool ShenandoahOldHeuristics::should_start_gc() { const size_t old_gen_capacity = _old_generation->max_capacity(); const size_t heap_capacity = heap->capacity(); const double percent = percent_of(old_gen_capacity, heap_capacity); - log_trigger("Expansion failure, current size: " SIZE_FORMAT "%s which is %.1f%% of total heap size", + log_trigger("Expansion failure, current size: %zu%s which is %.1f%% of total heap size", byte_size_in_proper_unit(old_gen_capacity), proper_unit_for_byte_size(old_gen_capacity), percent); return true; } @@ -655,8 +656,8 @@ bool ShenandoahOldHeuristics::should_start_gc() { const size_t fragmented_free = used_regions_size - used; log_trigger("Old has become fragmented: " - SIZE_FORMAT "%s available bytes spread between range spanned from " - SIZE_FORMAT " to " SIZE_FORMAT " (" SIZE_FORMAT "), density: %.1f%%", + "%zu%s available bytes spread between range spanned from " + "%zu to %zu (%zu), density: %.1f%%", byte_size_in_proper_unit(fragmented_free), proper_unit_for_byte_size(fragmented_free), first_old_region, last_old_region, span_of_old_regions, density * 100); return true; @@ -673,8 +674,8 @@ bool ShenandoahOldHeuristics::should_start_gc() { if ((current_usage < ignore_threshold) && ((consecutive_young_cycles = heap->shenandoah_policy()->consecutive_young_gc_count()) < ShenandoahDoNotIgnoreGrowthAfterYoungCycles)) { - log_debug(gc)("Ignoring Trigger: Old has overgrown: usage (" SIZE_FORMAT "%s) is below threshold (" - SIZE_FORMAT "%s) after " SIZE_FORMAT " consecutive completed young GCs", + log_debug(gc)("Ignoring Trigger: Old has overgrown: usage (%zu%s) is below threshold (" + "%zu%s) after %zu consecutive completed young GCs", byte_size_in_proper_unit(current_usage), proper_unit_for_byte_size(current_usage), byte_size_in_proper_unit(ignore_threshold), proper_unit_for_byte_size(ignore_threshold), consecutive_young_cycles); @@ -683,7 +684,7 @@ bool ShenandoahOldHeuristics::should_start_gc() { const size_t live_at_previous_old = _old_generation->get_live_bytes_after_last_mark(); const double percent_growth = percent_of(current_usage - live_at_previous_old, live_at_previous_old); log_trigger("Old has overgrown, live at end of previous OLD marking: " - SIZE_FORMAT "%s, current usage: " SIZE_FORMAT "%s, percent growth: %.1f%%", + "%zu%s, current usage: %zu%s, percent growth: %.1f%%", byte_size_in_proper_unit(live_at_previous_old), proper_unit_for_byte_size(live_at_previous_old), byte_size_in_proper_unit(current_usage), proper_unit_for_byte_size(current_usage), percent_growth); return true; diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp index 7c65482d8c4f8..11de43a40815d 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 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 @@ -60,7 +61,7 @@ void ShenandoahPassiveHeuristics::choose_collection_set_from_regiondata(Shenando size_t available = MAX2(max_capacity / 100 * ShenandoahEvacReserve, actual_free); size_t max_cset = (size_t)(available / ShenandoahEvacWaste); - log_info(gc, ergo)("CSet Selection. Actual Free: " SIZE_FORMAT "%s, Max CSet: " SIZE_FORMAT "%s", + log_info(gc, ergo)("CSet Selection. Actual Free: %zu%s, Max CSet: %zu%s", byte_size_in_proper_unit(actual_free), proper_unit_for_byte_size(actual_free), byte_size_in_proper_unit(max_cset), proper_unit_for_byte_size(max_cset)); diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp index db179d0a80a81..70e732d79d89a 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 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 @@ -52,7 +53,7 @@ bool ShenandoahStaticHeuristics::should_start_gc() { size_t threshold_available = capacity / 100 * ShenandoahMinFreeThreshold; if (available < threshold_available) { - log_trigger("Free (" SIZE_FORMAT "%s) is below minimum threshold (" SIZE_FORMAT "%s)", + log_trigger("Free (%zu%s) is below minimum threshold (%zu%s)", byte_size_in_proper_unit(available), proper_unit_for_byte_size(available), byte_size_in_proper_unit(threshold_available), proper_unit_for_byte_size(threshold_available)); return true; diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp index ced406611b1e0..f2cebd28f95fc 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -82,7 +83,7 @@ void ShenandoahYoungHeuristics::choose_young_collection_set(ShenandoahCollection log_info(gc, ergo)( - "Adaptive CSet Selection for YOUNG. Max Evacuation: " SIZE_FORMAT "%s, Actual Free: " SIZE_FORMAT "%s.", + "Adaptive CSet Selection for YOUNG. Max Evacuation: %zu%s, Actual Free: %zu%s.", byte_size_in_proper_unit(max_cset), proper_unit_for_byte_size(max_cset), byte_size_in_proper_unit(actual_free), proper_unit_for_byte_size(actual_free)); @@ -150,7 +151,7 @@ bool ShenandoahYoungHeuristics::should_start_gc() { // If concurrent weak root processing is in progress, it means the old cycle has chosen mixed collection // candidates, but has not completed. There is no point in trying to start the young cycle before the old // cycle completes. - log_trigger("Expedite mixed evacuation of " SIZE_FORMAT " regions", mixed_candidates); + log_trigger("Expedite mixed evacuation of %zu regions", mixed_candidates); return true; } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.cpp b/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.cpp index a4c78c637d958..dc399bd2af9a3 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahAgeCensus.cpp @@ -33,8 +33,8 @@ ShenandoahAgeCensus::ShenandoahAgeCensus() { assert(ShenandoahHeap::heap()->mode()->is_generational(), "Only in generational mode"); if (ShenandoahGenerationalMinTenuringAge > ShenandoahGenerationalMaxTenuringAge) { vm_exit_during_initialization( - err_msg("ShenandoahGenerationalMinTenuringAge=" SIZE_FORMAT - " should be no more than ShenandoahGenerationalMaxTenuringAge=" SIZE_FORMAT, + err_msg("ShenandoahGenerationalMinTenuringAge=%zu" + " should be no more than ShenandoahGenerationalMaxTenuringAge=%zu", ShenandoahGenerationalMinTenuringAge, ShenandoahGenerationalMaxTenuringAge)); } @@ -327,7 +327,7 @@ double ShenandoahAgeCensus::mortality_rate(size_t prev_pop, size_t cur_pop) { // or increased. if (cur_pop > prev_pop) { log_trace(gc, age) - (" (dark matter) Cohort population " SIZE_FORMAT_W(10) " to " SIZE_FORMAT_W(10), + (" (dark matter) Cohort population %10zu to %10zu", prev_pop*oopSize, cur_pop*oopSize); } return 0.0; @@ -356,7 +356,7 @@ void ShenandoahAgeCensus::print() { // Suppress printing when everything is zero if (prev_pop + cur_pop > 0) { log_info(gc, age) - (" - age %3u: prev " SIZE_FORMAT_W(10) " bytes, curr " SIZE_FORMAT_W(10) " bytes, mortality %.2f ", + (" - age %3u: prev %10zu bytes, curr %10zu bytes, mortality %.2f ", i, prev_pop*oopSize, cur_pop*oopSize, mr); } total += cur_pop; @@ -375,8 +375,8 @@ void ShenandoahNoiseStats::print(size_t total) { float f_aged = (float)aged/(float)total; float f_clamped = (float)clamped/(float)total; float f_young = (float)young/(float)total; - log_info(gc, age)("Skipped: " SIZE_FORMAT_W(10) " (%.2f), R-Aged: " SIZE_FORMAT_W(10) " (%.2f), " - "Clamped: " SIZE_FORMAT_W(10) " (%.2f), R-Young: " SIZE_FORMAT_W(10) " (%.2f)", + log_info(gc, age)("Skipped: %10zu (%.2f), R-Aged: %10zu (%.2f), " + "Clamped: %10zu (%.2f), R-Young: %10zu (%.2f)", skipped*oopSize, f_skipped, aged*oopSize, f_aged, clamped*oopSize, f_clamped, young*oopSize, f_young); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp b/src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp index fa3f9019af425..8723e2632feaf 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2018, 2022, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -60,7 +61,7 @@ void ShenandoahArguments::initialize() { if (UseLargePages) { size_t large_page_size = os::large_page_size(); if ((align_up(MaxHeapSize, large_page_size) / large_page_size) < ShenandoahHeapRegion::MIN_NUM_REGIONS) { - warning("Large pages size (" SIZE_FORMAT "K) is too large to afford page-sized regions, disabling uncommit", + warning("Large pages size (%zuK) is too large to afford page-sized regions, disabling uncommit", os::large_page_size() / K); FLAG_SET_DEFAULT(ShenandoahUncommit, false); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCardStats.cpp b/src/hotspot/share/gc/shenandoah/shenandoahCardStats.cpp index ef2d6e134b2e2..df63f4440de70 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahCardStats.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahCardStats.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * + * Copyright (c) 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 @@ -31,9 +32,9 @@ #ifndef PRODUCT void ShenandoahCardStats::log() const { if (ShenandoahEnableCardStats) { - log_info(gc,remset)("Card stats: dirty " SIZE_FORMAT " (max run: " SIZE_FORMAT ")," - " clean " SIZE_FORMAT " (max run: " SIZE_FORMAT ")," - " dirty scans/objs " SIZE_FORMAT, + log_info(gc,remset)("Card stats: dirty %zu (max run: %zu)," + " clean %zu (max run: %zu)," + " dirty scans/objs %zu", _dirty_card_cnt, _max_dirty_run, _clean_card_cnt, _max_clean_run, _dirty_scan_obj_cnt); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp index 4d521d2e7f071..29818e39b91df 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2023, Red Hat, Inc. All rights reserved. - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -186,7 +186,7 @@ ShenandoahHeapRegion* ShenandoahCollectionSet::next() { void ShenandoahCollectionSet::print_on(outputStream* out) const { out->print_cr("Collection Set: Regions: " - SIZE_FORMAT ", Garbage: " SIZE_FORMAT "%s, Live: " SIZE_FORMAT "%s, Used: " SIZE_FORMAT "%s", count(), + "%zu, Garbage: %zu%s, Live: %zu%s, Used: %zu%s", count(), byte_size_in_proper_unit(garbage()), proper_unit_for_byte_size(garbage()), byte_size_in_proper_unit(live()), proper_unit_for_byte_size(live()), byte_size_in_proper_unit(used()), proper_unit_for_byte_size(used())); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCollectorPolicy.cpp b/src/hotspot/share/gc/shenandoah/shenandoahCollectorPolicy.cpp index 42500ae877892..76f2d5c2529f8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahCollectorPolicy.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahCollectorPolicy.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -179,7 +180,7 @@ void ShenandoahCollectorPolicy::print_gc_stats(outputStream* out) const { out->cr(); size_t completed_gcs = _success_full_gcs + _success_degenerated_gcs + _success_concurrent_gcs + _success_old_gcs; - out->print_cr(SIZE_FORMAT_W(5) " Completed GCs", completed_gcs); + out->print_cr("%5zu Completed GCs", completed_gcs); size_t explicit_requests = 0; size_t implicit_requests = 0; @@ -193,48 +194,48 @@ void ShenandoahCollectorPolicy::print_gc_stats(outputStream* out) const { implicit_requests += cause_count; } const char* desc = GCCause::to_string(cause); - out->print_cr(" " SIZE_FORMAT_W(5) " caused by %s (%.2f%%)", cause_count, desc, percent_of(cause_count, completed_gcs)); + out->print_cr(" %5zu caused by %s (%.2f%%)", cause_count, desc, percent_of(cause_count, completed_gcs)); } } out->cr(); - out->print_cr(SIZE_FORMAT_W(5) " Successful Concurrent GCs (%.2f%%)", _success_concurrent_gcs, percent_of(_success_concurrent_gcs, completed_gcs)); + out->print_cr("%5zu Successful Concurrent GCs (%.2f%%)", _success_concurrent_gcs, percent_of(_success_concurrent_gcs, completed_gcs)); if (ExplicitGCInvokesConcurrent) { - out->print_cr(" " SIZE_FORMAT_W(5) " invoked explicitly (%.2f%%)", explicit_requests, percent_of(explicit_requests, _success_concurrent_gcs)); + out->print_cr(" %5zu invoked explicitly (%.2f%%)", explicit_requests, percent_of(explicit_requests, _success_concurrent_gcs)); } if (ShenandoahImplicitGCInvokesConcurrent) { - out->print_cr(" " SIZE_FORMAT_W(5) " invoked implicitly (%.2f%%)", implicit_requests, percent_of(implicit_requests, _success_concurrent_gcs)); + out->print_cr(" %5zu invoked implicitly (%.2f%%)", implicit_requests, percent_of(implicit_requests, _success_concurrent_gcs)); } - out->print_cr(" " SIZE_FORMAT_W(5) " abbreviated (%.2f%%)", _abbreviated_concurrent_gcs, percent_of(_abbreviated_concurrent_gcs, _success_concurrent_gcs)); + out->print_cr(" %5zu abbreviated (%.2f%%)", _abbreviated_concurrent_gcs, percent_of(_abbreviated_concurrent_gcs, _success_concurrent_gcs)); out->cr(); if (ShenandoahHeap::heap()->mode()->is_generational()) { - out->print_cr(SIZE_FORMAT_W(5) " Completed Old GCs (%.2f%%)", _success_old_gcs, percent_of(_success_old_gcs, completed_gcs)); - out->print_cr(" " SIZE_FORMAT_W(5) " mixed", _mixed_gcs); - out->print_cr(" " SIZE_FORMAT_W(5) " interruptions", _interrupted_old_gcs); + out->print_cr("%5zu Completed Old GCs (%.2f%%)", _success_old_gcs, percent_of(_success_old_gcs, completed_gcs)); + out->print_cr(" %5zu mixed", _mixed_gcs); + out->print_cr(" %5zu interruptions", _interrupted_old_gcs); out->cr(); } size_t degenerated_gcs = _alloc_failure_degenerated_upgrade_to_full + _success_degenerated_gcs; - out->print_cr(SIZE_FORMAT_W(5) " Degenerated GCs (%.2f%%)", degenerated_gcs, percent_of(degenerated_gcs, completed_gcs)); - out->print_cr(" " SIZE_FORMAT_W(5) " upgraded to Full GC (%.2f%%)", _alloc_failure_degenerated_upgrade_to_full, percent_of(_alloc_failure_degenerated_upgrade_to_full, degenerated_gcs)); - out->print_cr(" " SIZE_FORMAT_W(5) " caused by allocation failure (%.2f%%)", _alloc_failure_degenerated, percent_of(_alloc_failure_degenerated, degenerated_gcs)); - out->print_cr(" " SIZE_FORMAT_W(5) " abbreviated (%.2f%%)", _abbreviated_degenerated_gcs, percent_of(_abbreviated_degenerated_gcs, degenerated_gcs)); + out->print_cr("%5zu Degenerated GCs (%.2f%%)", degenerated_gcs, percent_of(degenerated_gcs, completed_gcs)); + out->print_cr(" %5zu upgraded to Full GC (%.2f%%)", _alloc_failure_degenerated_upgrade_to_full, percent_of(_alloc_failure_degenerated_upgrade_to_full, degenerated_gcs)); + out->print_cr(" %5zu caused by allocation failure (%.2f%%)", _alloc_failure_degenerated, percent_of(_alloc_failure_degenerated, degenerated_gcs)); + out->print_cr(" %5zu abbreviated (%.2f%%)", _abbreviated_degenerated_gcs, percent_of(_abbreviated_degenerated_gcs, degenerated_gcs)); for (int c = 0; c < ShenandoahGC::_DEGENERATED_LIMIT; c++) { if (_degen_point_counts[c] > 0) { const char* desc = ShenandoahGC::degen_point_to_string((ShenandoahGC::ShenandoahDegenPoint)c); - out->print_cr(" " SIZE_FORMAT_W(5) " happened at %s", _degen_point_counts[c], desc); + out->print_cr(" %5zu happened at %s", _degen_point_counts[c], desc); } } out->cr(); - out->print_cr(SIZE_FORMAT_W(5) " Full GCs (%.2f%%)", _success_full_gcs, percent_of(_success_full_gcs, completed_gcs)); + out->print_cr("%5zu Full GCs (%.2f%%)", _success_full_gcs, percent_of(_success_full_gcs, completed_gcs)); if (!ExplicitGCInvokesConcurrent) { - out->print_cr(" " SIZE_FORMAT_W(5) " invoked explicitly (%.2f%%)", explicit_requests, percent_of(explicit_requests, _success_concurrent_gcs)); + out->print_cr(" %5zu invoked explicitly (%.2f%%)", explicit_requests, percent_of(explicit_requests, _success_concurrent_gcs)); } if (!ShenandoahImplicitGCInvokesConcurrent) { - out->print_cr(" " SIZE_FORMAT_W(5) " invoked implicitly (%.2f%%)", implicit_requests, percent_of(implicit_requests, _success_concurrent_gcs)); + out->print_cr(" %5zu invoked implicitly (%.2f%%)", implicit_requests, percent_of(implicit_requests, _success_concurrent_gcs)); } - out->print_cr(" " SIZE_FORMAT_W(5) " caused by allocation failure (%.2f%%)", _alloc_failure_full, percent_of(_alloc_failure_full, _success_full_gcs)); - out->print_cr(" " SIZE_FORMAT_W(5) " upgraded from Degenerated GC (%.2f%%)", _alloc_failure_degenerated_upgrade_to_full, percent_of(_alloc_failure_degenerated_upgrade_to_full, _success_full_gcs)); + out->print_cr(" %5zu caused by allocation failure (%.2f%%)", _alloc_failure_full, percent_of(_alloc_failure_full, _success_full_gcs)); + out->print_cr(" %5zu upgraded from Degenerated GC (%.2f%%)", _alloc_failure_degenerated_upgrade_to_full, percent_of(_alloc_failure_degenerated_upgrade_to_full, _success_full_gcs)); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp index bd703cdb96f00..a4c13d24f0460 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.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) 2021, 2022, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -599,7 +599,7 @@ class ShenandoahInitMarkUpdateRegionStateClosure : public ShenandoahHeapRegionCl ShenandoahInitMarkUpdateRegionStateClosure() : _ctx(ShenandoahHeap::heap()->marking_context()) {} void heap_region_do(ShenandoahHeapRegion* r) { - assert(!r->has_live(), "Region " SIZE_FORMAT " should have no live data", r->index()); + assert(!r->has_live(), "Region %zu should have no live data", r->index()); if (r->is_active()) { // Check if region needs updating its TAMS. We have updated it already during concurrent // reset, so it is very likely we don't need to do another write here. Since most regions @@ -609,7 +609,7 @@ class ShenandoahInitMarkUpdateRegionStateClosure : public ShenandoahHeapRegionCl } } else { assert(_ctx->top_at_mark_start(r) == r->top(), - "Region " SIZE_FORMAT " should already have correct TAMS", r->index()); + "Region %zu should already have correct TAMS", r->index()); } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahController.cpp b/src/hotspot/share/gc/shenandoah/shenandoahController.cpp index effa4a8f1fc9c..6fe79f76e0597 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahController.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahController.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -61,7 +62,7 @@ void ShenandoahController::handle_alloc_failure(ShenandoahAllocRequest& req, boo if (try_set_alloc_failure_gc(is_humongous)) { // Only report the first allocation failure - log_info(gc)("Failed to allocate %s, " SIZE_FORMAT "%s", + log_info(gc)("Failed to allocate %s, %zu%s", req.type_string(), byte_size_in_proper_unit(req.size() * HeapWordSize), proper_unit_for_byte_size(req.size() * HeapWordSize)); @@ -84,7 +85,7 @@ void ShenandoahController::handle_alloc_failure_evac(size_t words) { if (try_set_alloc_failure_gc(is_humongous)) { // Only report the first allocation failure - log_info(gc)("Failed to allocate " SIZE_FORMAT "%s for evacuation", + log_info(gc)("Failed to allocate %zu%s for evacuation", byte_size_in_proper_unit(words * HeapWordSize), proper_unit_for_byte_size(words * HeapWordSize)); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahEvacTracker.cpp b/src/hotspot/share/gc/shenandoah/shenandoahEvacTracker.cpp index ededb99b24ecf..4aad55dd368dd 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahEvacTracker.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahEvacTracker.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -84,8 +85,8 @@ void ShenandoahEvacuationStats::print_on(outputStream* st) { #ifndef PRODUCT size_t abandoned_size = _bytes_attempted - _bytes_completed; size_t abandoned_count = _evacuations_attempted - _evacuations_completed; - st->print_cr("Evacuated " SIZE_FORMAT "%s across " SIZE_FORMAT " objects, " - "abandoned " SIZE_FORMAT "%s across " SIZE_FORMAT " objects.", + st->print_cr("Evacuated %zu%s across %zu objects, " + "abandoned %zu%s across %zu objects.", byte_size_in_proper_unit(_bytes_completed), proper_unit_for_byte_size(_bytes_completed), _evacuations_completed, byte_size_in_proper_unit(abandoned_size), proper_unit_for_byte_size(abandoned_size), diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp index b080002a92987..032e478d4c247 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp @@ -273,7 +273,7 @@ void ShenandoahRegionPartitions::increase_used(ShenandoahFreeSetPartitionId whic assert (which_partition < NumPartitions, "Partition must be valid"); _used[int(which_partition)] += bytes; assert (_used[int(which_partition)] <= _capacity[int(which_partition)], - "Must not use (" SIZE_FORMAT ") more than capacity (" SIZE_FORMAT ") after increase by " SIZE_FORMAT, + "Must not use (%zu) more than capacity (%zu) after increase by %zu", _used[int(which_partition)], _capacity[int(which_partition)], bytes); } @@ -338,7 +338,7 @@ void ShenandoahRegionPartitions::retire_range_from_partition( ShenandoahFreeSetPartitionId partition, idx_t low_idx, idx_t high_idx) { // Note: we may remove from free partition even if region is not entirely full, such as when available < PLAB::min_size() - assert ((low_idx < _max) && (high_idx < _max), "Both indices are sane: " SIZE_FORMAT " and " SIZE_FORMAT " < " SIZE_FORMAT, + assert ((low_idx < _max) && (high_idx < _max), "Both indices are sane: %zu and %zu < %zu", low_idx, high_idx, _max); assert (partition < NumPartitions, "Cannot remove from free partitions if not already free"); @@ -353,7 +353,7 @@ void ShenandoahRegionPartitions::retire_range_from_partition( void ShenandoahRegionPartitions::retire_from_partition(ShenandoahFreeSetPartitionId partition, idx_t idx, size_t used_bytes) { // Note: we may remove from free partition even if region is not entirely full, such as when available < PLAB::min_size() - assert (idx < _max, "index is sane: " SIZE_FORMAT " < " SIZE_FORMAT, idx, _max); + assert (idx < _max, "index is sane: %zu < %zu", idx, _max); assert (partition < NumPartitions, "Cannot remove from free partitions if not already free"); assert (in_free_set(partition, idx), "Must be in partition to remove from partition"); @@ -367,7 +367,7 @@ void ShenandoahRegionPartitions::retire_from_partition(ShenandoahFreeSetPartitio } void ShenandoahRegionPartitions::make_free(idx_t idx, ShenandoahFreeSetPartitionId which_partition, size_t available) { - assert (idx < _max, "index is sane: " SIZE_FORMAT " < " SIZE_FORMAT, idx, _max); + assert (idx < _max, "index is sane: %zu < %zu", idx, _max); assert (membership(idx) == ShenandoahFreeSetPartitionId::NotFree, "Cannot make free if already free"); assert (which_partition < NumPartitions, "selected free partition must be valid"); assert (available <= _region_size_bytes, "Available cannot exceed region size"); @@ -399,14 +399,14 @@ bool ShenandoahRegionPartitions::available_implies_empty(size_t available_in_reg void ShenandoahRegionPartitions::move_from_partition_to_partition(idx_t idx, ShenandoahFreeSetPartitionId orig_partition, ShenandoahFreeSetPartitionId new_partition, size_t available) { ShenandoahHeapRegion* r = ShenandoahHeap::heap()->get_region(idx); - assert (idx < _max, "index is sane: " SIZE_FORMAT " < " SIZE_FORMAT, idx, _max); + assert (idx < _max, "index is sane: %zu < %zu", idx, _max); assert (orig_partition < NumPartitions, "Original partition must be valid"); assert (new_partition < NumPartitions, "New partition must be valid"); assert (available <= _region_size_bytes, "Available cannot exceed region size"); assert (_membership[int(orig_partition)].is_set(idx), "Cannot move from partition unless in partition"); assert ((r != nullptr) && ((r->is_trash() && (available == _region_size_bytes)) || (r->used() + available == _region_size_bytes)), - "Used: " SIZE_FORMAT " + available: " SIZE_FORMAT " should equal region size: " SIZE_FORMAT, + "Used: %zu + available: %zu should equal region size: %zu", ShenandoahHeap::heap()->get_region(idx)->used(), available, _region_size_bytes); // Expected transitions: @@ -423,13 +423,13 @@ void ShenandoahRegionPartitions::move_from_partition_to_partition(idx_t idx, She (is_young_collector_partition(orig_partition) && is_mutator_partition(new_partition)) || (is_old_collector_partition(orig_partition) && available_implies_empty(available) && is_mutator_partition(new_partition)), - "Unexpected movement between partitions, available: " SIZE_FORMAT ", _region_size_bytes: " SIZE_FORMAT + "Unexpected movement between partitions, available: %zu, _region_size_bytes: %zu" ", orig_partition: %s, new_partition: %s", available, _region_size_bytes, partition_name(orig_partition), partition_name(new_partition)); size_t used = _region_size_bytes - available; assert (_used[int(orig_partition)] >= used, - "Orig partition used: " SIZE_FORMAT " must exceed moved used: " SIZE_FORMAT " within region %zd", + "Orig partition used: %zu must exceed moved used: %zu within region %zd", _used[int(orig_partition)], used, idx); _membership[int(orig_partition)].clear_bit(idx); @@ -452,7 +452,7 @@ const char* ShenandoahRegionPartitions::partition_membership_name(idx_t idx) con } inline ShenandoahFreeSetPartitionId ShenandoahRegionPartitions::membership(idx_t idx) const { - assert (idx < _max, "index is sane: " SIZE_FORMAT " < " SIZE_FORMAT, idx, _max); + assert (idx < _max, "index is sane: %zu < %zu", idx, _max); ShenandoahFreeSetPartitionId result = ShenandoahFreeSetPartitionId::NotFree; for (uint partition_id = 0; partition_id < UIntNumPartitions; partition_id++) { if (_membership[partition_id].is_set(idx)) { @@ -465,7 +465,7 @@ inline ShenandoahFreeSetPartitionId ShenandoahRegionPartitions::membership(idx_t #ifdef ASSERT inline bool ShenandoahRegionPartitions::partition_id_matches(idx_t idx, ShenandoahFreeSetPartitionId test_partition) const { - assert (idx < _max, "index is sane: " SIZE_FORMAT " < " SIZE_FORMAT, idx, _max); + assert (idx < _max, "index is sane: %zu < %zu", idx, _max); assert (test_partition < ShenandoahFreeSetPartitionId::NotFree, "must be a valid partition"); return membership(idx) == test_partition; @@ -938,7 +938,7 @@ HeapWord* ShenandoahFreeSet::try_allocate_from_mutator(ShenandoahAllocRequest& r } // Region r is entirely empty. If try_allocate_in fails on region r, something else is really wrong. // Don't bother to retry with other regions. - log_debug(gc, free)("Flipped region " SIZE_FORMAT " to gc for request: " PTR_FORMAT, idx, p2i(&req)); + log_debug(gc, free)("Flipped region %zu to gc for request: " PTR_FORMAT, idx, p2i(&req)); return try_allocate_in(r, req, in_new_region); } } @@ -997,7 +997,7 @@ HeapWord* ShenandoahFreeSet::allocate_aligned_plab(size_t size, ShenandoahAllocR } HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, ShenandoahAllocRequest& req, bool& in_new_region) { - assert (has_alloc_capacity(r), "Performance: should avoid full regions on this path: " SIZE_FORMAT, r->index()); + assert (has_alloc_capacity(r), "Performance: should avoid full regions on this path: %zu", r->index()); if (_heap->is_concurrent_weak_root_in_progress() && r->is_trash()) { // We cannot use this region for allocation when weak roots are in progress because the collector may need // to reference unmarked oops during concurrent classunloading. @@ -1008,9 +1008,10 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah in_new_region = r->is_empty(); if (in_new_region) { - log_debug(gc, free)("Using new region (" SIZE_FORMAT ") for %s (" PTR_FORMAT ").", + log_debug(gc, free)("Using new region (%zu) for %s (" PTR_FORMAT ").", r->index(), ShenandoahAllocRequest::alloc_type_to_string(req.type()), p2i(&req)); - assert(!r->is_affiliated(), "New region " SIZE_FORMAT " should be unaffiliated", r->index()); + assert(!r->is_affiliated(), "New region %zu should be unaffiliated", r->index()); + r->set_affiliation(req.affiliation()); if (r->is_old()) { // Any OLD region allocated during concurrent coalesce-and-fill does not need to be coalesced and filled because @@ -1029,10 +1030,10 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah assert(ctx->top_at_mark_start(r) == r->bottom(), "Newly established allocation region starts with TAMS equal to bottom"); assert(ctx->is_bitmap_range_within_region_clear(ctx->top_bitmap(r), r->end()), "Bitmap above top_bitmap() must be clear"); #endif - log_debug(gc, free)("Using new region (" SIZE_FORMAT ") for %s (" PTR_FORMAT ").", + log_debug(gc, free)("Using new region (%zu) for %s (" PTR_FORMAT ").", r->index(), ShenandoahAllocRequest::alloc_type_to_string(req.type()), p2i(&req)); } else { - assert(r->is_affiliated(), "Region " SIZE_FORMAT " that is not new should be affiliated", r->index()); + assert(r->is_affiliated(), "Region %zu that is not new should be affiliated", r->index()); if (r->affiliation() != req.affiliation()) { assert(_heap->mode()->is_generational(), "Request for %s from %s region should only happen in generational mode.", req.affiliation_name(), r->affiliation_name()); @@ -1063,8 +1064,8 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah req.set_actual_size(adjusted_size); } else { // Otherwise, leave result == nullptr because the adjusted size is smaller than min size. - log_trace(gc, free)("Failed to shrink PLAB request (" SIZE_FORMAT ") in region " SIZE_FORMAT " to " SIZE_FORMAT - " because min_size() is " SIZE_FORMAT, req.size(), r->index(), adjusted_size, req.min_size()); + log_trace(gc, free)("Failed to shrink PLAB request (%zu) in region %zu to %zu" + " because min_size() is %zu", req.size(), r->index(), adjusted_size, req.min_size()); } } else { // This is a GCLAB or a TLAB allocation @@ -1075,11 +1076,11 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah } if (adjusted_size >= req.min_size()) { result = r->allocate(adjusted_size, req); - assert (result != nullptr, "Allocation must succeed: free " SIZE_FORMAT ", actual " SIZE_FORMAT, free, adjusted_size); + assert (result != nullptr, "Allocation must succeed: free %zu, actual %zu", free, adjusted_size); req.set_actual_size(adjusted_size); } else { - log_trace(gc, free)("Failed to shrink TLAB or GCLAB request (" SIZE_FORMAT ") in region " SIZE_FORMAT " to " SIZE_FORMAT - " because min_size() is " SIZE_FORMAT, req.size(), r->index(), adjusted_size, req.min_size()); + log_trace(gc, free)("Failed to shrink TLAB or GCLAB request (%zu) in region %zu to %zu" + " because min_size() is %zu", req.size(), r->index(), adjusted_size, req.min_size()); } } } else { @@ -1295,7 +1296,7 @@ void ShenandoahFreeSet::flip_to_old_gc(ShenandoahHeapRegion* r) { _heap->old_generation()->augment_evacuation_reserve(region_capacity); bool transferred = gen_heap->generation_sizer()->transfer_to_old(1); if (!transferred) { - log_warning(gc, free)("Forcing transfer of " SIZE_FORMAT " to old reserve.", idx); + log_warning(gc, free)("Forcing transfer of %zu to old reserve.", idx); gen_heap->generation_sizer()->force_transfer_to_old(1); } // We do not ensure that the region is no longer trash, relying on try_allocate_in(), which always comes next, @@ -1427,24 +1428,25 @@ void ShenandoahFreeSet::find_regions_with_alloc_capacity(size_t &young_cset_regi } } } - log_debug(gc, free)(" At end of prep_to_rebuild, mutator_leftmost: " SIZE_FORMAT - ", mutator_rightmost: " SIZE_FORMAT - ", mutator_leftmost_empty: " SIZE_FORMAT - ", mutator_rightmost_empty: " SIZE_FORMAT - ", mutator_regions: " SIZE_FORMAT - ", mutator_used: " SIZE_FORMAT, + log_debug(gc, free)(" At end of prep_to_rebuild, mutator_leftmost: %zu" + ", mutator_rightmost: %zu" + ", mutator_leftmost_empty: %zu" + ", mutator_rightmost_empty: %zu" + ", mutator_regions: %zu" + ", mutator_used: %zu", mutator_leftmost, mutator_rightmost, mutator_leftmost_empty, mutator_rightmost_empty, mutator_regions, mutator_used); - log_debug(gc, free)(" old_collector_leftmost: " SIZE_FORMAT - ", old_collector_rightmost: " SIZE_FORMAT - ", old_collector_leftmost_empty: " SIZE_FORMAT - ", old_collector_rightmost_empty: " SIZE_FORMAT - ", old_collector_regions: " SIZE_FORMAT - ", old_collector_used: " SIZE_FORMAT, + log_debug(gc, free)(" old_collector_leftmost: %zu" + ", old_collector_rightmost: %zu" + ", old_collector_leftmost_empty: %zu" + ", old_collector_rightmost_empty: %zu" + ", old_collector_regions: %zu" + ", old_collector_used: %zu", old_collector_leftmost, old_collector_rightmost, old_collector_leftmost_empty, old_collector_rightmost_empty, old_collector_regions, old_collector_used); + idx_t rightmost_idx = (mutator_leftmost == max_regions)? -1: (idx_t) mutator_rightmost; idx_t rightmost_empty_idx = (mutator_leftmost_empty == max_regions)? -1: (idx_t) mutator_rightmost_empty; _partitions.establish_mutator_intervals(mutator_leftmost, rightmost_idx, mutator_leftmost_empty, rightmost_empty_idx, @@ -1536,8 +1538,8 @@ void ShenandoahFreeSet::move_regions_from_collector_to_mutator(size_t max_xfer_r } size_t total_xfer = collector_xfer + old_collector_xfer; - log_info(gc, ergo)("At start of update refs, moving " SIZE_FORMAT "%s to Mutator free set from Collector Reserve (" - SIZE_FORMAT "%s) and from Old Collector Reserve (" SIZE_FORMAT "%s)", + log_info(gc, ergo)("At start of update refs, moving %zu%s to Mutator free set from Collector Reserve (" + "%zu%s) and from Old Collector Reserve (%zu%s)", byte_size_in_proper_unit(total_xfer), proper_unit_for_byte_size(total_xfer), byte_size_in_proper_unit(collector_xfer), proper_unit_for_byte_size(collector_xfer), byte_size_in_proper_unit(old_collector_xfer), proper_unit_for_byte_size(old_collector_xfer)); @@ -1573,11 +1575,11 @@ void ShenandoahFreeSet::establish_generation_sizes(size_t young_region_count, si if (new_old_capacity > original_old_capacity) { size_t region_count = (new_old_capacity - original_old_capacity) / region_size_bytes; - log_info(gc, ergo)("Transfer " SIZE_FORMAT " region(s) from %s to %s, yielding increased size: " PROPERFMT, + log_info(gc, ergo)("Transfer %zu region(s) from %s to %s, yielding increased size: " PROPERFMT, region_count, young_gen->name(), old_gen->name(), PROPERFMTARGS(new_old_capacity)); } else if (new_old_capacity < original_old_capacity) { size_t region_count = (original_old_capacity - new_old_capacity) / region_size_bytes; - log_info(gc, ergo)("Transfer " SIZE_FORMAT " region(s) from %s to %s, yielding increased size: " PROPERFMT, + log_info(gc, ergo)("Transfer %zu region(s) from %s to %s, yielding increased size: " PROPERFMT, region_count, old_gen->name(), young_gen->name(), PROPERFMTARGS(new_young_capacity)); } // This balances generations, so clear any pending request to balance. @@ -1655,7 +1657,7 @@ void ShenandoahFreeSet::compute_young_and_old_reserves(size_t young_cset_regions young_reserve_result = young_generation->get_evacuation_reserve(); old_reserve_result = promoted_reserve + old_evac_reserve; assert(old_reserve_result <= old_available, - "Cannot reserve (" SIZE_FORMAT " + " SIZE_FORMAT") more OLD than is available: " SIZE_FORMAT, + "Cannot reserve (%zu + %zu) more OLD than is available: %zu", promoted_reserve, old_evac_reserve, old_available); } else { // We are rebuilding at end of GC, so we set aside budgets specified on command line (or defaults) @@ -1714,13 +1716,14 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old // OLD regions that have available memory are already in the old_collector free set. _partitions.move_from_partition_to_partition(idx, ShenandoahFreeSetPartitionId::Mutator, ShenandoahFreeSetPartitionId::OldCollector, ac); - log_trace(gc, free)(" Shifting region " SIZE_FORMAT " from mutator_free to old_collector_free", idx); + log_trace(gc, free)(" Shifting region %zu from mutator_free to old_collector_free", idx); log_trace(gc, free)(" Shifted Mutator range [%zd, %zd]," " Old Collector range [%zd, %zd]", _partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator), _partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator), _partitions.leftmost(ShenandoahFreeSetPartitionId::OldCollector), _partitions.rightmost(ShenandoahFreeSetPartitionId::OldCollector)); + old_region_count++; continue; } @@ -1737,13 +1740,14 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old // collection set, and they are easily evacuated because they have low density of live objects. _partitions.move_from_partition_to_partition(idx, ShenandoahFreeSetPartitionId::Mutator, ShenandoahFreeSetPartitionId::Collector, ac); - log_trace(gc, free)(" Shifting region " SIZE_FORMAT " from mutator_free to collector_free", idx); + log_trace(gc, free)(" Shifting region %zu from mutator_free to collector_free", idx); log_trace(gc, free)(" Shifted Mutator range [%zd, %zd]," " Collector range [%zd, %zd]", _partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator), _partitions.rightmost(ShenandoahFreeSetPartitionId::Mutator), _partitions.leftmost(ShenandoahFreeSetPartitionId::Collector), _partitions.rightmost(ShenandoahFreeSetPartitionId::Collector)); + } } @@ -1817,6 +1821,7 @@ void ShenandoahFreeSet::log_status() { buffer[i] = '\0'; } + ls.cr(); ls.print_cr("Mutator free range [%zd..%zd] allocating from %s", _partitions.leftmost(ShenandoahFreeSetPartitionId::Mutator), @@ -1917,7 +1922,7 @@ void ShenandoahFreeSet::log_status() { // retired, the sum of used and capacities within regions that are still in the Mutator free partition may not match // my internally tracked values of used() and free(). assert(free == total_free, "Free memory should match"); - ls.print("Free: " SIZE_FORMAT "%s, Max: " SIZE_FORMAT "%s regular, " SIZE_FORMAT "%s humongous, ", + ls.print("Free: %zu%s, Max: %zu%s regular, %zu%s humongous, ", byte_size_in_proper_unit(total_free), proper_unit_for_byte_size(total_free), byte_size_in_proper_unit(max), proper_unit_for_byte_size(max), byte_size_in_proper_unit(max_humongous), proper_unit_for_byte_size(max_humongous) @@ -1930,7 +1935,7 @@ void ShenandoahFreeSet::log_status() { } else { frag_ext = 0; } - ls.print(SIZE_FORMAT "%% external, ", frag_ext); + ls.print("%zu%% external, ", frag_ext); size_t frag_int; if (_partitions.count(ShenandoahFreeSetPartitionId::Mutator) > 0) { @@ -1939,8 +1944,8 @@ void ShenandoahFreeSet::log_status() { } else { frag_int = 0; } - ls.print(SIZE_FORMAT "%% internal; ", frag_int); - ls.print("Used: " SIZE_FORMAT "%s, Mutator Free: " SIZE_FORMAT, + ls.print("%zu%% internal; ", frag_int); + ls.print("Used: %zu%s, Mutator Free: %zu", byte_size_in_proper_unit(total_used), proper_unit_for_byte_size(total_used), _partitions.count(ShenandoahFreeSetPartitionId::Mutator)); } @@ -1960,7 +1965,7 @@ void ShenandoahFreeSet::log_status() { total_used += r->used(); } } - ls.print(" Collector Reserve: " SIZE_FORMAT "%s, Max: " SIZE_FORMAT "%s; Used: " SIZE_FORMAT "%s", + ls.print(" Collector Reserve: %zu%s, Max: %zu%s; Used: %zu%s", byte_size_in_proper_unit(total_free), proper_unit_for_byte_size(total_free), byte_size_in_proper_unit(max), proper_unit_for_byte_size(max), byte_size_in_proper_unit(total_used), proper_unit_for_byte_size(total_used)); @@ -1981,7 +1986,7 @@ void ShenandoahFreeSet::log_status() { total_used += r->used(); } } - ls.print_cr(" Old Collector Reserve: " SIZE_FORMAT "%s, Max: " SIZE_FORMAT "%s; Used: " SIZE_FORMAT "%s", + ls.print_cr(" Old Collector Reserve: %zu%s, Max: %zu%s; Used: %zu%s", byte_size_in_proper_unit(total_free), proper_unit_for_byte_size(total_free), byte_size_in_proper_unit(max), proper_unit_for_byte_size(max), byte_size_in_proper_unit(total_used), proper_unit_for_byte_size(total_used)); @@ -2001,7 +2006,7 @@ HeapWord* ShenandoahFreeSet::allocate(ShenandoahAllocRequest& req, bool& in_new_ case ShenandoahAllocRequest::_alloc_gclab: case ShenandoahAllocRequest::_alloc_tlab: in_new_region = false; - assert(false, "Trying to allocate TLAB in humongous region: " SIZE_FORMAT, req.size()); + assert(false, "Trying to allocate TLAB in humongous region: %zu", req.size()); return nullptr; default: ShouldNotReachHere(); @@ -2013,20 +2018,20 @@ HeapWord* ShenandoahFreeSet::allocate(ShenandoahAllocRequest& req, bool& in_new_ } void ShenandoahFreeSet::print_on(outputStream* out) const { - out->print_cr("Mutator Free Set: " SIZE_FORMAT "", _partitions.count(ShenandoahFreeSetPartitionId::Mutator)); + out->print_cr("Mutator Free Set: %zu", _partitions.count(ShenandoahFreeSetPartitionId::Mutator)); ShenandoahLeftRightIterator mutator(const_cast(&_partitions), ShenandoahFreeSetPartitionId::Mutator); for (idx_t index = mutator.current(); mutator.has_next(); index = mutator.next()) { _heap->get_region(index)->print_on(out); } - out->print_cr("Collector Free Set: " SIZE_FORMAT "", _partitions.count(ShenandoahFreeSetPartitionId::Collector)); + out->print_cr("Collector Free Set: %zu", _partitions.count(ShenandoahFreeSetPartitionId::Collector)); ShenandoahLeftRightIterator collector(const_cast(&_partitions), ShenandoahFreeSetPartitionId::Collector); for (idx_t index = collector.current(); collector.has_next(); index = collector.next()) { _heap->get_region(index)->print_on(out); } if (_heap->mode()->is_generational()) { - out->print_cr("Old Collector Free Set: " SIZE_FORMAT "", _partitions.count(ShenandoahFreeSetPartitionId::OldCollector)); + out->print_cr("Old Collector Free Set: %zu", _partitions.count(ShenandoahFreeSetPartitionId::OldCollector)); for (idx_t index = _partitions.leftmost(ShenandoahFreeSetPartitionId::OldCollector); index <= _partitions.rightmost(ShenandoahFreeSetPartitionId::OldCollector); index++) { if (_partitions.in_free_set(ShenandoahFreeSetPartitionId::OldCollector, index)) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp index 2847d7c78ba18..12249171a00a6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2014, 2021, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -501,7 +502,7 @@ void ShenandoahFullGC::calculate_target_humongous_objects() { size_t to_begin = heap->num_regions(); size_t to_end = heap->num_regions(); - log_debug(gc)("Full GC calculating target humongous objects from end " SIZE_FORMAT, to_end); + log_debug(gc)("Full GC calculating target humongous objects from end %zu", to_end); for (size_t c = heap->num_regions(); c > 0; c--) { ShenandoahHeapRegion *r = heap->get_region(c - 1); if (r->is_humongous_continuation() || (r->new_top() == r->bottom())) { @@ -550,7 +551,7 @@ class ShenandoahEnsureHeapActiveClosure: public ShenandoahHeapRegionClosure { if (r->is_empty_uncommitted()) { r->make_committed_bypass(); } - assert (r->is_committed(), "only committed regions in heap now, see region " SIZE_FORMAT, r->index()); + assert (r->is_committed(), "only committed regions in heap now, see region %zu", r->index()); // Record current region occupancy: this communicates empty regions are free // to the rest of Full GC code. @@ -572,14 +573,14 @@ class ShenandoahTrashImmediateGarbageClosure: public ShenandoahHeapRegionClosure if (r->is_humongous_start()) { oop humongous_obj = cast_to_oop(r->bottom()); if (!_ctx->is_marked(humongous_obj)) { - assert(!r->has_live(), "Region " SIZE_FORMAT " is not marked, should not have live", r->index()); + assert(!r->has_live(), "Region %zu is not marked, should not have live", r->index()); _heap->trash_humongous_region_at(r); } else { - assert(r->has_live(), "Region " SIZE_FORMAT " should have live", r->index()); + assert(r->has_live(), "Region %zu should have live", r->index()); } } else if (r->is_humongous_continuation()) { // If we hit continuation, the non-live humongous starts should have been trashed already - assert(r->humongous_start_region()->has_live(), "Region " SIZE_FORMAT " should have live", r->index()); + assert(r->humongous_start_region()->has_live(), "Region %zu should have live", r->index()); } else if (r->is_regular()) { if (!r->has_live()) { r->make_trash_immediate(); @@ -715,8 +716,8 @@ void ShenandoahFullGC::distribute_slices(ShenandoahHeapRegionSet** worker_slices ShenandoahHeapRegion* r = it.next(); while (r != nullptr) { size_t idx = r->index(); - assert(ShenandoahPrepareForCompactionTask::is_candidate_region(r), "Sanity: " SIZE_FORMAT, idx); - assert(!map.at(idx), "No region distributed twice: " SIZE_FORMAT, idx); + assert(ShenandoahPrepareForCompactionTask::is_candidate_region(r), "Sanity: %zu", idx); + assert(!map.at(idx), "No region distributed twice: %zu", idx); map.at_put(idx, true); r = it.next(); } @@ -725,7 +726,7 @@ void ShenandoahFullGC::distribute_slices(ShenandoahHeapRegionSet** worker_slices for (size_t rid = 0; rid < n_regions; rid++) { bool is_candidate = ShenandoahPrepareForCompactionTask::is_candidate_region(heap->get_region(rid)); bool is_distributed = map.at(rid); - assert(is_distributed || !is_candidate, "All candidates are distributed: " SIZE_FORMAT, rid); + assert(is_distributed || !is_candidate, "All candidates are distributed: %zu", rid); } #endif } @@ -1045,9 +1046,9 @@ void ShenandoahFullGC::compact_humongous_objects() { size_t new_start = heap->heap_region_index_containing(FullGCForwarding::forwardee(old_obj)); size_t new_end = new_start + num_regions - 1; assert(old_start != new_start, "must be real move"); - assert(r->is_stw_move_allowed(), "Region " SIZE_FORMAT " should be movable", r->index()); + assert(r->is_stw_move_allowed(), "Region %zu should be movable", r->index()); - log_debug(gc)("Full GC compaction moves humongous object from region " SIZE_FORMAT " to region " SIZE_FORMAT, old_start, new_start); + log_debug(gc)("Full GC compaction moves humongous object from region %zu to region %zu", old_start, new_start); Copy::aligned_conjoint_words(r->bottom(), heap->get_region(new_start)->bottom(), words_size); ContinuationGCSupport::relativize_stack_chunk(cast_to_oop(r->bottom())); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp index c72940c3c3a75..eb8027a0f7c84 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -419,7 +420,7 @@ void ShenandoahGeneration::adjust_evacuation_budgets(ShenandoahHeap* const heap, if (old_evacuated_committed > old_evacuation_reserve) { // This should only happen due to round-off errors when enforcing ShenandoahOldEvacWaste assert(old_evacuated_committed <= (33 * old_evacuation_reserve) / 32, - "Round-off errors should be less than 3.125%%, committed: " SIZE_FORMAT ", reserved: " SIZE_FORMAT, + "Round-off errors should be less than 3.125%%, committed: %zu, reserved: %zu", old_evacuated_committed, old_evacuation_reserve); old_evacuated_committed = old_evacuation_reserve; // Leave old_evac_reserve as previously configured @@ -449,13 +450,13 @@ void ShenandoahGeneration::adjust_evacuation_budgets(ShenandoahHeap* const heap, // This can happen due to round-off errors when adding the results of truncated integer arithmetic. // We've already truncated old_evacuated_committed. Truncate young_advance_promoted_reserve_used here. assert(young_advance_promoted_reserve_used <= (33 * (old_available - old_evacuated_committed)) / 32, - "Round-off errors should be less than 3.125%%, committed: " SIZE_FORMAT ", reserved: " SIZE_FORMAT, + "Round-off errors should be less than 3.125%%, committed: %zu, reserved: %zu", young_advance_promoted_reserve_used, old_available - old_evacuated_committed); young_advance_promoted_reserve_used = old_available - old_evacuated_committed; old_consumed = old_evacuated_committed + young_advance_promoted_reserve_used; } - assert(old_available >= old_consumed, "Cannot consume (" SIZE_FORMAT ") more than is available (" SIZE_FORMAT ")", + assert(old_available >= old_consumed, "Cannot consume (%zu) more than is available (%zu)", old_consumed, old_available); size_t excess_old = old_available - old_consumed; size_t unaffiliated_old_regions = old_generation->free_unaffiliated_regions(); @@ -494,10 +495,10 @@ void ShenandoahGeneration::adjust_evacuation_budgets(ShenandoahHeap* const heap, if (regions_to_xfer > 0) { bool result = ShenandoahGenerationalHeap::cast(heap)->generation_sizer()->transfer_to_young(regions_to_xfer); assert(excess_old >= regions_to_xfer * region_size_bytes, - "Cannot transfer (" SIZE_FORMAT ", " SIZE_FORMAT ") more than excess old (" SIZE_FORMAT ")", + "Cannot transfer (%zu, %zu) more than excess old (%zu)", regions_to_xfer, region_size_bytes, excess_old); excess_old -= regions_to_xfer * region_size_bytes; - log_debug(gc, ergo)("%s transferred " SIZE_FORMAT " excess regions to young before start of evacuation", + log_debug(gc, ergo)("%s transferred %zu excess regions to young before start of evacuation", result? "Successfully": "Unsuccessfully", regions_to_xfer); } @@ -527,7 +528,7 @@ inline void assert_no_in_place_promotions() { public: void heap_region_do(ShenandoahHeapRegion *r) override { assert(r->get_top_before_promote() == nullptr, - "Region " SIZE_FORMAT " should not be ready for in-place promotion", r->index()); + "Region %zu should not be ready for in-place promotion", r->index()); } } cl; ShenandoahHeap::heap()->heap_region_iterate(&cl); @@ -671,8 +672,8 @@ size_t ShenandoahGeneration::select_aged_regions(size_t old_available) { // We keep going even if one region is excluded from selection because we need to accumulate all eligible // regions that are not preselected into promo_potential } - log_debug(gc)("Preselected " SIZE_FORMAT " regions containing " SIZE_FORMAT " live bytes," - " consuming: " SIZE_FORMAT " of budgeted: " SIZE_FORMAT, + log_debug(gc)("Preselected %zu regions containing %zu live bytes," + " consuming: %zu of budgeted: %zu", selected_regions, selected_live, old_consumed, old_available); } @@ -724,7 +725,7 @@ void ShenandoahGeneration::prepare_regions_and_collection_set(bool concurrent) { // We use integer division so anything up to just less than 2 is considered // reasonable, and the "+1" is to avoid divide-by-zero. assert((total_pop+1)/(total_census+1) == 1, "Extreme divergence: " - SIZE_FORMAT "/" SIZE_FORMAT, total_pop, total_census); + "%zu/%zu", total_pop, total_census); #endif } @@ -941,7 +942,7 @@ void ShenandoahGeneration::increase_humongous_waste(size_t bytes) { void ShenandoahGeneration::decrease_humongous_waste(size_t bytes) { if (bytes > 0) { assert(ShenandoahHeap::heap()->is_full_gc_in_progress() || (_humongous_waste >= bytes), - "Waste (" SIZE_FORMAT ") cannot be negative (after subtracting " SIZE_FORMAT ")", _humongous_waste, bytes); + "Waste (%zu) cannot be negative (after subtracting %zu)", _humongous_waste, bytes); Atomic::sub(&_humongous_waste, bytes); } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationSizer.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationSizer.cpp index dfbc6b673ffab..7ace37c36c1f8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationSizer.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationSizer.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -51,8 +52,8 @@ ShenandoahGenerationSizer::ShenandoahGenerationSizer() if (NewSize > MaxNewSize) { if (FLAG_IS_CMDLINE(MaxNewSize)) { - log_warning(gc, ergo)("NewSize (" SIZE_FORMAT "k) is greater than the MaxNewSize (" SIZE_FORMAT "k). " - "A new max generation size of " SIZE_FORMAT "k will be used.", + log_warning(gc, ergo)("NewSize (%zuk) is greater than the MaxNewSize (%zuk). " + "A new max generation size of %zuk will be used.", NewSize/K, MaxNewSize/K, NewSize/K); } FLAG_SET_ERGO(MaxNewSize, NewSize); @@ -138,7 +139,7 @@ bool ShenandoahGenerationSizer::transfer_regions(ShenandoahGeneration* src, Shen src->decrease_capacity(bytes_to_transfer); dst->increase_capacity(bytes_to_transfer); const size_t new_size = dst->max_capacity(); - log_info(gc, ergo)("Transfer " SIZE_FORMAT " region(s) from %s to %s, yielding increased size: " PROPERFMT, + log_info(gc, ergo)("Transfer %zu region(s) from %s to %s, yielding increased size: " PROPERFMT, regions, src->name(), dst->name(), PROPERFMTARGS(new_size)); return true; } @@ -190,7 +191,7 @@ void ShenandoahGenerationSizer::force_transfer_to_old(size_t regions) const { young_gen->decrease_capacity(bytes_to_transfer); old_gen->increase_capacity(bytes_to_transfer); const size_t new_size = old_gen->max_capacity(); - log_info(gc, ergo)("Forcing transfer of " SIZE_FORMAT " region(s) from %s to %s, yielding increased size: " PROPERFMT, + log_info(gc, ergo)("Forcing transfer of %zu region(s) from %s to %s, yielding increased size: " PROPERFMT, regions, young_gen->name(), old_gen->name(), PROPERFMTARGS(new_size)); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalEvacuationTask.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalEvacuationTask.cpp index 9dcdf002b7e8c..4048eeee56827 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalEvacuationTask.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalEvacuationTask.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 +90,7 @@ void ShenandoahGenerationalEvacuationTask::do_work() { } void log_region(const ShenandoahHeapRegion* r, LogStream* ls) { - ls->print_cr("GenerationalEvacuationTask, looking at %s region " SIZE_FORMAT ", (age: %d) [%s, %s, %s]", + ls->print_cr("GenerationalEvacuationTask, looking at %s region %zu, (age: %d) [%s, %s, %s]", r->is_old()? "old": r->is_young()? "young": "free", r->index(), r->age(), r->is_active()? "active": "inactive", r->is_humongous()? (r->is_humongous_start()? "humongous_start": "humongous_continuation"): "regular", @@ -126,7 +127,7 @@ void ShenandoahGenerationalEvacuationTask::evacuate_and_promote_regions() { } if (r->is_cset()) { - assert(r->has_live(), "Region " SIZE_FORMAT " should have been reclaimed early", r->index()); + assert(r->has_live(), "Region %zu should have been reclaimed early", r->index()); _heap->marked_object_iterate(r, &cl); if (ShenandoahPacing) { _heap->pacer()->report_evac(r->used() >> LogHeapWordSize); @@ -177,11 +178,11 @@ void ShenandoahGenerationalEvacuationTask::promote_in_place(ShenandoahHeapRegion const size_t old_garbage_threshold = (ShenandoahHeapRegion::region_size_bytes() * ShenandoahOldGarbageThreshold) / 100; shenandoah_assert_generations_reconciled(); assert(!_heap->is_concurrent_old_mark_in_progress(), "Cannot promote in place during old marking"); - assert(region->garbage_before_padded_for_promote() < old_garbage_threshold, "Region " SIZE_FORMAT " has too much garbage for promotion", region->index()); + assert(region->garbage_before_padded_for_promote() < old_garbage_threshold, "Region %zu has too much garbage for promotion", region->index()); assert(region->is_young(), "Only young regions can be promoted"); assert(region->is_regular(), "Use different service to promote humongous regions"); assert(region->age() >= _tenuring_threshold, "Only promote regions that are sufficiently aged"); - assert(region->get_top_before_promote() == tams, "Region " SIZE_FORMAT " has been used for allocations before promotion", region->index()); + assert(region->get_top_before_promote() == tams, "Region %zu has been used for allocations before promotion", region->index()); } ShenandoahOldGeneration* const old_gen = _heap->old_generation(); @@ -280,7 +281,7 @@ void ShenandoahGenerationalEvacuationTask::promote_humongous(ShenandoahHeapRegio // We promote humongous objects unconditionally, without checking for availability. We adjust // usage totals, including humongous waste, after evacuation is done. - log_debug(gc)("promoting humongous region " SIZE_FORMAT ", spanning " SIZE_FORMAT, region->index(), spanned_regions); + log_debug(gc)("promoting humongous region %zu, spanning %zu", region->index(), spanned_regions); young_gen->decrease_used(used_bytes); young_gen->decrease_humongous_waste(humongous_waste); @@ -294,7 +295,7 @@ void ShenandoahGenerationalEvacuationTask::promote_humongous(ShenandoahHeapRegio // in the last humongous region that is not spanned by obj is currently not used. for (size_t i = region->index(); i < index_limit; i++) { ShenandoahHeapRegion* r = _heap->get_region(i); - log_debug(gc)("promoting humongous region " SIZE_FORMAT ", from " PTR_FORMAT " to " PTR_FORMAT, + log_debug(gc)("promoting humongous region %zu, from " PTR_FORMAT " to " PTR_FORMAT, r->index(), p2i(r->bottom()), p2i(r->top())); // We mark the entire humongous object's range as dirty after loop terminates, so no need to dirty the range here r->set_affiliation(OLD_GENERATION); @@ -314,11 +315,11 @@ void ShenandoahGenerationalEvacuationTask::promote_humongous(ShenandoahHeapRegio if (obj->is_typeArray()) { // Primitive arrays don't need to be scanned. - log_debug(gc)("Clean cards for promoted humongous object (Region " SIZE_FORMAT ") from " PTR_FORMAT " to " PTR_FORMAT, + log_debug(gc)("Clean cards for promoted humongous object (Region %zu) from " PTR_FORMAT " to " PTR_FORMAT, region->index(), p2i(humongous_bottom), p2i(humongous_bottom + obj->size())); scanner->mark_range_as_clean(humongous_bottom, obj->size()); } else { - log_debug(gc)("Dirty cards for promoted humongous object (Region " SIZE_FORMAT ") from " PTR_FORMAT " to " PTR_FORMAT, + log_debug(gc)("Dirty cards for promoted humongous object (Region %zu) from " PTR_FORMAT " to " PTR_FORMAT, region->index(), p2i(humongous_bottom), p2i(humongous_bottom + obj->size())); scanner->mark_range_as_dirty(humongous_bottom, obj->size()); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalFullGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalFullGC.cpp index fe38c996bd81c..107103997e802 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalFullGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalFullGC.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -219,7 +220,7 @@ ShenandoahPrepareForGenerationalCompactionObjectClosure::ShenandoahPrepareForGen } void ShenandoahPrepareForGenerationalCompactionObjectClosure::set_from_region(ShenandoahHeapRegion* from_region) { - log_debug(gc)("Worker %u compacting %s Region " SIZE_FORMAT " which had used " SIZE_FORMAT " and %s live", + log_debug(gc)("Worker %u compacting %s Region %zu which had used %zu and %s live", _worker_id, from_region->affiliation_name(), from_region->index(), from_region->used(), from_region->has_live()? "has": "does not have"); @@ -248,7 +249,7 @@ void ShenandoahPrepareForGenerationalCompactionObjectClosure::finish() { void ShenandoahPrepareForGenerationalCompactionObjectClosure::finish_old_region() { if (_old_to_region != nullptr) { - log_debug(gc)("Planned compaction into Old Region " SIZE_FORMAT ", used: " SIZE_FORMAT " tabulated by worker %u", + log_debug(gc)("Planned compaction into Old Region %zu, used: %zu tabulated by worker %u", _old_to_region->index(), _old_compact_point - _old_to_region->bottom(), _worker_id); _old_to_region->set_new_top(_old_compact_point); _old_to_region = nullptr; @@ -257,7 +258,7 @@ void ShenandoahPrepareForGenerationalCompactionObjectClosure::finish_old_region( void ShenandoahPrepareForGenerationalCompactionObjectClosure::finish_young_region() { if (_young_to_region != nullptr) { - log_debug(gc)("Worker %u planned compaction into Young Region " SIZE_FORMAT ", used: " SIZE_FORMAT, + log_debug(gc)("Worker %u planned compaction into Young Region %zu, used: %zu", _worker_id, _young_to_region->index(), _young_compact_point - _young_to_region->bottom()); _young_to_region->set_new_top(_young_compact_point); _young_to_region = nullptr; @@ -307,7 +308,7 @@ void ShenandoahPrepareForGenerationalCompactionObjectClosure::do_object(oop p) { if (_old_compact_point + obj_size > _old_to_region->end()) { ShenandoahHeapRegion* new_to_region; - log_debug(gc)("Worker %u finishing old region " SIZE_FORMAT ", compact_point: " PTR_FORMAT ", obj_size: " SIZE_FORMAT + log_debug(gc)("Worker %u finishing old region %zu, compact_point: " PTR_FORMAT ", obj_size: %zu" ", &compact_point[obj_size]: " PTR_FORMAT ", region end: " PTR_FORMAT, _worker_id, _old_to_region->index(), p2i(_old_compact_point), obj_size, p2i(_old_compact_point + obj_size), p2i(_old_to_region->end())); @@ -354,7 +355,7 @@ void ShenandoahPrepareForGenerationalCompactionObjectClosure::do_object(oop p) { if (_young_compact_point + obj_size > _young_to_region->end()) { ShenandoahHeapRegion* new_to_region; - log_debug(gc)("Worker %u finishing young region " SIZE_FORMAT ", compact_point: " PTR_FORMAT ", obj_size: " SIZE_FORMAT + log_debug(gc)("Worker %u finishing young region %zu, compact_point: " PTR_FORMAT ", obj_size: %zu" ", &compact_point[obj_size]: " PTR_FORMAT ", region end: " PTR_FORMAT, _worker_id, _young_to_region->index(), p2i(_young_compact_point), obj_size, p2i(_young_compact_point + obj_size), p2i(_young_to_region->end())); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp index 2ad35fcb288b4..8e803fcc24238 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -460,20 +461,20 @@ HeapWord* ShenandoahGenerationalHeap::allocate_from_plab_slow(Thread* thread, si size_t future_size = MIN2(cur_size * 2, plab_max_size()); // Doubling, starting at a card-multiple, should give us a card-multiple. (Ceiling and floor // are card multiples.) - assert(is_aligned(future_size, CardTable::card_size_in_words()), "Card multiple by construction, future_size: " SIZE_FORMAT - ", card_size: " SIZE_FORMAT ", cur_size: " SIZE_FORMAT ", max: " SIZE_FORMAT, + assert(is_aligned(future_size, CardTable::card_size_in_words()), "Card multiple by construction, future_size: %zu" + ", card_size: %zu, cur_size: %zu, max: %zu", future_size, (size_t) CardTable::card_size_in_words(), cur_size, plab_max_size()); // Record new heuristic value even if we take any shortcut. This captures // the case when moderately-sized objects always take a shortcut. At some point, // heuristics should catch up with them. Note that the requested cur_size may // not be honored, but we remember that this is the preferred size. - log_debug(gc, free)("Set new PLAB size: " SIZE_FORMAT, future_size); + log_debug(gc, free)("Set new PLAB size: %zu", future_size); ShenandoahThreadLocalData::set_plab_size(thread, future_size); if (cur_size < size) { // The PLAB to be allocated is still not large enough to hold the object. Fall back to shared allocation. // This avoids retiring perfectly good PLABs in order to represent a single large object allocation. - log_debug(gc, free)("Current PLAB size (" SIZE_FORMAT ") is too small for " SIZE_FORMAT, cur_size, size); + log_debug(gc, free)("Current PLAB size (%zu) is too small for %zu", cur_size, size); return nullptr; } @@ -570,7 +571,7 @@ void ShenandoahGenerationalHeap::retire_plab(PLAB* plab, Thread* thread) { if (top != nullptr && plab->waste() > original_waste && is_in_old(top)) { // If retiring the plab created a filler object, then we need to register it with our card scanner so it can // safely walk the region backing the plab. - log_debug(gc)("retire_plab() is registering remnant of size " SIZE_FORMAT " at " PTR_FORMAT, + log_debug(gc)("retire_plab() is registering remnant of size %zu at " PTR_FORMAT, plab->waste() - original_waste, p2i(top)); // No lock is necessary because the PLAB memory is aligned on card boundaries. old_generation()->card_scan()->register_object_without_lock(top); @@ -714,7 +715,7 @@ void ShenandoahGenerationalHeap::TransferResult::print_on(const char* when, outp ShenandoahOldGeneration* const old_gen = heap->old_generation(); const size_t young_available = young_gen->available(); const size_t old_available = old_gen->available(); - ss->print_cr("After %s, %s " SIZE_FORMAT " regions to %s to prepare for next gc, old available: " + ss->print_cr("After %s, %s %zu regions to %s to prepare for next gc, old available: " PROPERFMT ", young_available: " PROPERFMT, when, success? "successfully transferred": "failed to transfer", region_count, region_destination, @@ -819,7 +820,7 @@ class ShenandoahGenerationalUpdateHeapRefsTask : public WorkerTask { HeapWord* update_watermark = r->get_update_watermark(); assert(update_watermark >= r->bottom(), "sanity"); - log_debug(gc)("Update refs worker " UINT32_FORMAT ", looking at region " SIZE_FORMAT, worker_id, r->index()); + log_debug(gc)("Update refs worker " UINT32_FORMAT ", looking at region %zu", worker_id, r->index()); bool region_progress = false; if (r->is_active() && !r->is_cset()) { if (r->is_young()) { @@ -845,7 +846,7 @@ class ShenandoahGenerationalUpdateHeapRefsTask : public WorkerTask { // updated. assert(r->get_update_watermark() == r->bottom(), - "%s Region " SIZE_FORMAT " is_active but not recognized as YOUNG or OLD so must be newly transitioned from FREE", + "%s Region %zu is_active but not recognized as YOUNG or OLD so must be newly transitioned from FREE", r->affiliation_name(), r->index()); } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 018540b33b70b..84b77c94bcb9e 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2022, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -146,7 +146,7 @@ class ShenandoahPretouchBitmapTask : public WorkerTask { while (r != nullptr) { size_t start = r->index() * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor(); size_t end = (r->index() + 1) * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor(); - assert (end <= _bitmap_size, "end is sane: " SIZE_FORMAT " < " SIZE_FORMAT, end, _bitmap_size); + assert (end <= _bitmap_size, "end is sane: %zu < %zu", end, _bitmap_size); if (r->is_committed()) { os::pretouch_memory(_bitmap_base + start, _bitmap_base + end, _page_size); @@ -187,7 +187,7 @@ jint ShenandoahHeap::initialize() { _num_regions = ShenandoahHeapRegion::region_count(); assert(_num_regions == (max_byte_size / reg_size_bytes), - "Regions should cover entire heap exactly: " SIZE_FORMAT " != " SIZE_FORMAT "/" SIZE_FORMAT, + "Regions should cover entire heap exactly: %zu != %zu/%zu", _num_regions, max_byte_size, reg_size_bytes); size_t num_committed_regions = init_byte_size / reg_size_bytes; @@ -277,7 +277,7 @@ jint ShenandoahHeap::initialize() { guarantee(bitmap_bytes_per_region != 0, "Bitmap bytes per region should not be zero"); guarantee(is_power_of_2(bitmap_bytes_per_region), - "Bitmap bytes per region should be power of two: " SIZE_FORMAT, bitmap_bytes_per_region); + "Bitmap bytes per region should be power of two: %zu", bitmap_bytes_per_region); if (bitmap_page_size > bitmap_bytes_per_region) { _bitmap_regions_per_slice = bitmap_page_size / bitmap_bytes_per_region; @@ -288,11 +288,11 @@ jint ShenandoahHeap::initialize() { } guarantee(_bitmap_regions_per_slice >= 1, - "Should have at least one region per slice: " SIZE_FORMAT, + "Should have at least one region per slice: %zu", _bitmap_regions_per_slice); guarantee(((_bitmap_bytes_per_slice) % bitmap_page_size) == 0, - "Bitmap slices should be page-granular: bps = " SIZE_FORMAT ", page size = " SIZE_FORMAT, + "Bitmap slices should be page-granular: bps = %zu, page size = %zu", _bitmap_bytes_per_slice, bitmap_page_size); ReservedSpace bitmap = reserve(_bitmap_size, bitmap_page_size); @@ -584,12 +584,12 @@ ShenandoahHeap::ShenandoahHeap(ShenandoahCollectorPolicy* policy) : void ShenandoahHeap::print_on(outputStream* st) const { st->print_cr("Shenandoah Heap"); - st->print_cr(" " SIZE_FORMAT "%s max, " SIZE_FORMAT "%s soft max, " SIZE_FORMAT "%s committed, " SIZE_FORMAT "%s used", + st->print_cr(" %zu%s max, %zu%s soft max, %zu%s committed, %zu%s used", byte_size_in_proper_unit(max_capacity()), proper_unit_for_byte_size(max_capacity()), byte_size_in_proper_unit(soft_max_capacity()), proper_unit_for_byte_size(soft_max_capacity()), byte_size_in_proper_unit(committed()), proper_unit_for_byte_size(committed()), byte_size_in_proper_unit(used()), proper_unit_for_byte_size(used())); - st->print_cr(" " SIZE_FORMAT " x " SIZE_FORMAT"%s regions", + st->print_cr(" %zu x %zu %s regions", num_regions(), byte_size_in_proper_unit(ShenandoahHeapRegion::region_size_bytes()), proper_unit_for_byte_size(ShenandoahHeapRegion::region_size_bytes())); @@ -789,14 +789,14 @@ size_t ShenandoahHeap::max_capacity() const { size_t ShenandoahHeap::soft_max_capacity() const { size_t v = Atomic::load(&_soft_max_size); assert(min_capacity() <= v && v <= max_capacity(), - "Should be in bounds: " SIZE_FORMAT " <= " SIZE_FORMAT " <= " SIZE_FORMAT, + "Should be in bounds: %zu <= %zu <= %zu", min_capacity(), v, max_capacity()); return v; } void ShenandoahHeap::set_soft_max_capacity(size_t v) { assert(min_capacity() <= v && v <= max_capacity(), - "Should be in bounds: " SIZE_FORMAT " <= " SIZE_FORMAT " <= " SIZE_FORMAT, + "Should be in bounds: %zu <= %zu <= %zu", min_capacity(), v, max_capacity()); Atomic::store(&_soft_max_size, v); } @@ -843,7 +843,7 @@ bool ShenandoahHeap::check_soft_max_changed() { new_soft_max = MAX2(min_capacity(), new_soft_max); new_soft_max = MIN2(max_capacity(), new_soft_max); if (new_soft_max != old_soft_max) { - log_info(gc)("Soft Max Heap Size: " SIZE_FORMAT "%s -> " SIZE_FORMAT "%s", + log_info(gc)("Soft Max Heap Size: %zu%s -> %zu%s", byte_size_in_proper_unit(old_soft_max), proper_unit_for_byte_size(old_soft_max), byte_size_in_proper_unit(new_soft_max), proper_unit_for_byte_size(new_soft_max) ); @@ -882,13 +882,13 @@ HeapWord* ShenandoahHeap::allocate_from_gclab_slow(Thread* thread, size_t size) // Record new heuristic value even if we take any shortcut. This captures // the case when moderately-sized objects always take a shortcut. At some point, // heuristics should catch up with them. - log_debug(gc, free)("Set new GCLAB size: " SIZE_FORMAT, new_size); + log_debug(gc, free)("Set new GCLAB size: %zu", new_size); ShenandoahThreadLocalData::set_gclab_size(thread, new_size); if (new_size < size) { // New size still does not fit the object. Fall back to shared allocation. // This avoids retiring perfectly good GCLABs, when we encounter a large object. - log_debug(gc, free)("New gclab size (" SIZE_FORMAT ") is too small for " SIZE_FORMAT, new_size, size); + log_debug(gc, free)("New gclab size (%zu) is too small for %zu", new_size, size); return nullptr; } @@ -997,8 +997,8 @@ HeapWord* ShenandoahHeap::allocate_memory(ShenandoahAllocRequest& req) { } if (log_develop_is_enabled(Debug, gc, alloc)) { ResourceMark rm; - log_debug(gc, alloc)("Thread: %s, Result: " PTR_FORMAT ", Request: %s, Size: " SIZE_FORMAT - ", Original: " SIZE_FORMAT ", Latest: " SIZE_FORMAT, + log_debug(gc, alloc)("Thread: %s, Result: " PTR_FORMAT ", Request: %s, Size: %zu" + ", Original: %zu, Latest: %zu", Thread::current()->name(), p2i(result), req.type_string(), req.size(), original_count, get_gc_no_progress_count()); } @@ -1027,7 +1027,7 @@ HeapWord* ShenandoahHeap::allocate_memory(ShenandoahAllocRequest& req) { size_t actual = req.actual_size(); assert (req.is_lab_alloc() || (requested == actual), - "Only LAB allocations are elastic: %s, requested = " SIZE_FORMAT ", actual = " SIZE_FORMAT, + "Only LAB allocations are elastic: %s, requested = %zu, actual = %zu", ShenandoahAllocRequest::alloc_type_to_string(req.type()), requested, actual); if (req.is_mutator_alloc()) { @@ -1179,7 +1179,7 @@ class ShenandoahEvacuationTask : public WorkerTask { ShenandoahConcurrentEvacuateRegionObjectClosure cl(_sh); ShenandoahHeapRegion* r; while ((r =_cs->claim_next()) != nullptr) { - assert(r->has_live(), "Region " SIZE_FORMAT " should have been reclaimed early", r->index()); + assert(r->has_live(), "Region %zu should have been reclaimed early", r->index()); _sh->marked_object_iterate(r, &cl); if (ShenandoahPacing) { @@ -2280,7 +2280,7 @@ void ShenandoahHeap::pin_object(JavaThread* thr, oop o) { void ShenandoahHeap::unpin_object(JavaThread* thr, oop o) { ShenandoahHeapRegion* r = heap_region_containing(o); assert(r != nullptr, "Sanity"); - assert(r->pin_count() > 0, "Region " SIZE_FORMAT " should have non-zero pins", r->index()); + assert(r->pin_count() > 0, "Region %zu should have non-zero pins", r->index()); r->record_unpin(); } @@ -2312,7 +2312,7 @@ void ShenandoahHeap::assert_pinned_region_status() { shenandoah_assert_generations_reconciled(); if (gc_generation()->contains(r)) { assert((r->is_pinned() && r->pin_count() > 0) || (!r->is_pinned() && r->pin_count() == 0), - "Region " SIZE_FORMAT " pinning status is inconsistent", i); + "Region %zu pinning status is inconsistent", i); } } } @@ -2470,7 +2470,7 @@ void ShenandoahHeap::rebuild_free_set(bool concurrent) { assert((first_old_region > last_old_region) || ((last_old_region + 1 - first_old_region >= old_region_count) && get_region(first_old_region)->is_old() && get_region(last_old_region)->is_old()), - "sanity: old_region_count: " SIZE_FORMAT ", first_old_region: " SIZE_FORMAT ", last_old_region: " SIZE_FORMAT, + "sanity: old_region_count: %zu, first_old_region: %zu, last_old_region: %zu", old_region_count, first_old_region, last_old_region); if (mode()->is_generational()) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp index f879188431b5e..138e4cadd3c5f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2015, 2020, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -378,7 +379,7 @@ inline bool ShenandoahHeap::is_in_active_generation(oop obj) const { // Old regions are in old and global collections, not in young collections return !gen->is_young(); default: - assert(false, "Bad affiliation (%d) for region " SIZE_FORMAT, region_affiliation(index), index); + assert(false, "Bad affiliation (%d) for region %zu", region_affiliation(index), index); return false; } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp index d46b76c937652..6f73c491fd69f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2020, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -242,7 +242,7 @@ void ShenandoahHeapRegion::make_humongous_cont_bypass(ShenandoahAffiliation affi void ShenandoahHeapRegion::make_pinned() { shenandoah_assert_heaplocked(); - assert(pin_count() > 0, "Should have pins: " SIZE_FORMAT, pin_count()); + assert(pin_count() > 0, "Should have pins: %zu", pin_count()); switch (state()) { case _regular: @@ -264,7 +264,7 @@ void ShenandoahHeapRegion::make_pinned() { void ShenandoahHeapRegion::make_unpinned() { shenandoah_assert_heaplocked(); - assert(pin_count() == 0, "Should not have pins: " SIZE_FORMAT, pin_count()); + assert(pin_count() == 0, "Should not have pins: %zu", pin_count()); switch (state()) { case _pinned: @@ -398,7 +398,7 @@ void ShenandoahHeapRegion::set_live_data(size_t s) { void ShenandoahHeapRegion::print_on(outputStream* st) const { st->print("|"); - st->print(SIZE_FORMAT_W(5), this->_index); + st->print("%5zu", this->_index); switch (state()) { case _empty_uncommitted: @@ -445,15 +445,15 @@ void ShenandoahHeapRegion::print_on(outputStream* st) const { p2i(ShenandoahHeap::heap()->marking_context()->top_at_mark_start(const_cast(this)))); st->print("|UWM " SHR_PTR_FORMAT, p2i(_update_watermark)); - st->print("|U " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(used()), proper_unit_for_byte_size(used())); - st->print("|T " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_tlab_allocs()), proper_unit_for_byte_size(get_tlab_allocs())); - st->print("|G " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_gclab_allocs()), proper_unit_for_byte_size(get_gclab_allocs())); + st->print("|U %5zu%1s", byte_size_in_proper_unit(used()), proper_unit_for_byte_size(used())); + st->print("|T %5zu%1s", byte_size_in_proper_unit(get_tlab_allocs()), proper_unit_for_byte_size(get_tlab_allocs())); + st->print("|G %5zu%1s", byte_size_in_proper_unit(get_gclab_allocs()), proper_unit_for_byte_size(get_gclab_allocs())); if (ShenandoahHeap::heap()->mode()->is_generational()) { - st->print("|P " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_plab_allocs()), proper_unit_for_byte_size(get_plab_allocs())); + st->print("|P %5zu%1s", byte_size_in_proper_unit(get_plab_allocs()), proper_unit_for_byte_size(get_plab_allocs())); } - st->print("|S " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_shared_allocs()), proper_unit_for_byte_size(get_shared_allocs())); - st->print("|L " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_live_data_bytes()), proper_unit_for_byte_size(get_live_data_bytes())); - st->print("|CP " SIZE_FORMAT_W(3), pin_count()); + st->print("|S %5zu%1s", byte_size_in_proper_unit(get_shared_allocs()), proper_unit_for_byte_size(get_shared_allocs())); + st->print("|L %5zu%1s", byte_size_in_proper_unit(get_live_data_bytes()), proper_unit_for_byte_size(get_live_data_bytes())); + st->print("|CP %3zu", pin_count()); st->cr(); #undef SHR_PTR_FORMAT @@ -675,33 +675,33 @@ size_t ShenandoahHeapRegion::setup_sizes(size_t max_heap_size) { size_t region_size; if (FLAG_IS_DEFAULT(ShenandoahRegionSize)) { if (ShenandoahMinRegionSize > max_heap_size / MIN_NUM_REGIONS) { - err_msg message("Max heap size (" SIZE_FORMAT "%s) is too low to afford the minimum number " - "of regions (" SIZE_FORMAT ") of minimum region size (" SIZE_FORMAT "%s).", + err_msg message("Max heap size (%zu%s) is too low to afford the minimum number " + "of regions (%zu) of minimum region size (%zu%s).", byte_size_in_proper_unit(max_heap_size), proper_unit_for_byte_size(max_heap_size), MIN_NUM_REGIONS, byte_size_in_proper_unit(ShenandoahMinRegionSize), proper_unit_for_byte_size(ShenandoahMinRegionSize)); vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option", message); } if (ShenandoahMinRegionSize < MIN_REGION_SIZE) { - err_msg message("" SIZE_FORMAT "%s should not be lower than minimum region size (" SIZE_FORMAT "%s).", + err_msg message("%zu%s should not be lower than minimum region size (%zu%s).", byte_size_in_proper_unit(ShenandoahMinRegionSize), proper_unit_for_byte_size(ShenandoahMinRegionSize), byte_size_in_proper_unit(MIN_REGION_SIZE), proper_unit_for_byte_size(MIN_REGION_SIZE)); vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option", message); } if (ShenandoahMinRegionSize < MinTLABSize) { - err_msg message("" SIZE_FORMAT "%s should not be lower than TLAB size size (" SIZE_FORMAT "%s).", + err_msg message("%zu%s should not be lower than TLAB size size (%zu%s).", byte_size_in_proper_unit(ShenandoahMinRegionSize), proper_unit_for_byte_size(ShenandoahMinRegionSize), byte_size_in_proper_unit(MinTLABSize), proper_unit_for_byte_size(MinTLABSize)); vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option", message); } if (ShenandoahMaxRegionSize < MIN_REGION_SIZE) { - err_msg message("" SIZE_FORMAT "%s should not be lower than min region size (" SIZE_FORMAT "%s).", + err_msg message("%zu%s should not be lower than min region size (%zu%s).", byte_size_in_proper_unit(ShenandoahMaxRegionSize), proper_unit_for_byte_size(ShenandoahMaxRegionSize), byte_size_in_proper_unit(MIN_REGION_SIZE), proper_unit_for_byte_size(MIN_REGION_SIZE)); vm_exit_during_initialization("Invalid -XX:ShenandoahMaxRegionSize option", message); } if (ShenandoahMinRegionSize > ShenandoahMaxRegionSize) { - err_msg message("Minimum (" SIZE_FORMAT "%s) should be larger than maximum (" SIZE_FORMAT "%s).", + err_msg message("Minimum (%zu%s) should be larger than maximum (%zu%s).", byte_size_in_proper_unit(ShenandoahMinRegionSize), proper_unit_for_byte_size(ShenandoahMinRegionSize), byte_size_in_proper_unit(ShenandoahMaxRegionSize), proper_unit_for_byte_size(ShenandoahMaxRegionSize)); vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize or -XX:ShenandoahMaxRegionSize", message); @@ -717,21 +717,21 @@ size_t ShenandoahHeapRegion::setup_sizes(size_t max_heap_size) { } else { if (ShenandoahRegionSize > max_heap_size / MIN_NUM_REGIONS) { - err_msg message("Max heap size (" SIZE_FORMAT "%s) is too low to afford the minimum number " - "of regions (" SIZE_FORMAT ") of requested size (" SIZE_FORMAT "%s).", + err_msg message("Max heap size (%zu%s) is too low to afford the minimum number " + "of regions (%zu) of requested size (%zu%s).", byte_size_in_proper_unit(max_heap_size), proper_unit_for_byte_size(max_heap_size), MIN_NUM_REGIONS, byte_size_in_proper_unit(ShenandoahRegionSize), proper_unit_for_byte_size(ShenandoahRegionSize)); vm_exit_during_initialization("Invalid -XX:ShenandoahRegionSize option", message); } if (ShenandoahRegionSize < ShenandoahMinRegionSize) { - err_msg message("Heap region size (" SIZE_FORMAT "%s) should be larger than min region size (" SIZE_FORMAT "%s).", + err_msg message("Heap region size (%zu%s) should be larger than min region size (%zu%s).", byte_size_in_proper_unit(ShenandoahRegionSize), proper_unit_for_byte_size(ShenandoahRegionSize), byte_size_in_proper_unit(ShenandoahMinRegionSize), proper_unit_for_byte_size(ShenandoahMinRegionSize)); vm_exit_during_initialization("Invalid -XX:ShenandoahRegionSize option", message); } if (ShenandoahRegionSize > ShenandoahMaxRegionSize) { - err_msg message("Heap region size (" SIZE_FORMAT "%s) should be lower than max region size (" SIZE_FORMAT "%s).", + err_msg message("Heap region size (%zu%s) should be lower than max region size (%zu%s).", byte_size_in_proper_unit(ShenandoahRegionSize), proper_unit_for_byte_size(ShenandoahRegionSize), byte_size_in_proper_unit(ShenandoahMaxRegionSize), proper_unit_for_byte_size(ShenandoahMaxRegionSize)); vm_exit_during_initialization("Invalid -XX:ShenandoahRegionSize option", message); @@ -843,7 +843,7 @@ void ShenandoahHeapRegion::record_pin() { } void ShenandoahHeapRegion::record_unpin() { - assert(pin_count() > 0, "Region " SIZE_FORMAT " should have non-zero pins", index()); + assert(pin_count() > 0, "Region %zu should have non-zero pins", index()); Atomic::sub(&_critical_pins, (size_t)1); } @@ -857,7 +857,7 @@ void ShenandoahHeapRegion::set_affiliation(ShenandoahAffiliation new_affiliation ShenandoahAffiliation region_affiliation = heap->region_affiliation(this); { ShenandoahMarkingContext* const ctx = heap->complete_marking_context(); - log_debug(gc)("Setting affiliation of Region " SIZE_FORMAT " from %s to %s, top: " PTR_FORMAT ", TAMS: " PTR_FORMAT + log_debug(gc)("Setting affiliation of Region %zu from %s to %s, top: " PTR_FORMAT ", TAMS: " PTR_FORMAT ", watermark: " PTR_FORMAT ", top_bitmap: " PTR_FORMAT, index(), shenandoah_affiliation_name(region_affiliation), shenandoah_affiliation_name(new_affiliation), p2i(top()), p2i(ctx->top_at_mark_start(this)), p2i(_update_watermark), p2i(ctx->top_bitmap(this))); @@ -871,7 +871,7 @@ void ShenandoahHeapRegion::set_affiliation(ShenandoahAffiliation new_affiliation HeapWord* top_bitmap = ctx->top_bitmap(this); assert(ctx->is_bitmap_range_within_region_clear(top_bitmap, _end), - "Region " SIZE_FORMAT ", bitmap should be clear between top_bitmap: " PTR_FORMAT " and end: " PTR_FORMAT, idx, + "Region %zu, bitmap should be clear between top_bitmap: " PTR_FORMAT " and end: " PTR_FORMAT, idx, p2i(top_bitmap), p2i(_end)); } #endif diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp index 382d9ba942ccd..7f29a8628aab5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2015, 2019, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -36,7 +37,7 @@ HeapWord* ShenandoahHeapRegion::allocate_aligned(size_t size, ShenandoahAllocRequest &req, size_t alignment_in_bytes) { shenandoah_assert_heaplocked_or_safepoint(); assert(req.is_lab_alloc(), "allocate_aligned() only applies to LAB allocations"); - assert(is_object_aligned(size), "alloc size breaks alignment: " SIZE_FORMAT, size); + assert(is_object_aligned(size), "alloc size breaks alignment: %zu", size); assert(is_old(), "aligned allocations are only taken from OLD regions to support PLABs"); assert(is_aligned(alignment_in_bytes, HeapWordSize), "Expect heap word alignment"); @@ -88,7 +89,7 @@ HeapWord* ShenandoahHeapRegion::allocate_aligned(size_t size, ShenandoahAllocReq HeapWord* ShenandoahHeapRegion::allocate(size_t size, const ShenandoahAllocRequest& req) { shenandoah_assert_heaplocked_or_safepoint(); - assert(is_object_aligned(size), "alloc size breaks alignment: " SIZE_FORMAT, size); + assert(is_object_aligned(size), "alloc size breaks alignment: %zu", size); HeapWord* obj = top(); if (pointer_delta(end(), obj) >= size) { @@ -160,7 +161,7 @@ inline bool ShenandoahHeapRegion::has_live() const { inline size_t ShenandoahHeapRegion::garbage() const { assert(used() >= get_live_data_bytes(), - "Live Data must be a subset of used() live: " SIZE_FORMAT " used: " SIZE_FORMAT, + "Live Data must be a subset of used() live: %zu used: %zu", get_live_data_bytes(), used()); size_t result = used() - get_live_data_bytes(); @@ -171,7 +172,7 @@ inline size_t ShenandoahHeapRegion::garbage_before_padded_for_promote() const { assert(get_top_before_promote() != nullptr, "top before promote should not equal null"); size_t used_before_promote = byte_size(bottom(), get_top_before_promote()); assert(used_before_promote >= get_live_data_bytes(), - "Live Data must be a subset of used before promotion live: " SIZE_FORMAT " used: " SIZE_FORMAT, + "Live Data must be a subset of used before promotion live: %zu used: %zu", get_live_data_bytes(), used_before_promote); size_t result = used_before_promote - get_live_data_bytes(); return result; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionClosures.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionClosures.cpp index 3d3483a5b694f..f44902d272440 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionClosures.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionClosures.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -82,8 +83,8 @@ void ShenandoahFinalMarkUpdateRegionStateClosure::heap_region_do(ShenandoahHeapR // from-space-refs written from here on. r->set_update_watermark_at_safepoint(r->top()); } else { - assert(!r->has_live(), "Region " SIZE_FORMAT " should have no live data", r->index()); + assert(!r->has_live(), "Region %zu should have no live data", r->index()); assert(_ctx == nullptr || _ctx->top_at_mark_start(r) == r->top(), - "Region " SIZE_FORMAT " should have correct TAMS", r->index()); + "Region %zu should have correct TAMS", r->index()); } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp index f04aa7ce8ed1f..9eb7e7855e357 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2016, 2020, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -91,7 +92,7 @@ void ShenandoahHeapRegionCounters::write_snapshot(PerfLongVariable** regions, ResourceMark rm; LogStream ls(lt); - ls.print_cr(JLONG_FORMAT " " JLONG_FORMAT " " SIZE_FORMAT " " SIZE_FORMAT " " SIZE_FORMAT, + ls.print_cr(JLONG_FORMAT " " JLONG_FORMAT " %zu %zu %zu", ts->get_value(), status->get_value(), num_regions, region_size, protocol_version); if (num_regions > 0) { ls.print(JLONG_FORMAT, regions[0]->get_value()); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp index d18bfb0d62598..91a8082eb2134 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 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 @@ -81,7 +82,7 @@ ShenandoahHeapRegion* ShenandoahHeapRegionSetIterator::next() { } void ShenandoahHeapRegionSet::print_on(outputStream* out) const { - out->print_cr("Region Set : " SIZE_FORMAT "", count()); + out->print_cr("Region Set : %zu", count()); for (size_t index = 0; index < _heap->num_regions(); index++) { if (is_in(index)) { _heap->get_region(index)->print_on(out); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahInitLogger.cpp b/src/hotspot/share/gc/shenandoah/shenandoahInitLogger.cpp index baf95a5bdf7e4..73857520be207 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahInitLogger.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahInitLogger.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2020, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -40,7 +41,7 @@ void ShenandoahInitLogger::print() { void ShenandoahInitLogger::print_heap() { GCInitLogger::print_heap(); - log_info(gc, init)("Heap Region Count: " SIZE_FORMAT, ShenandoahHeapRegion::region_count()); + log_info(gc, init)("Heap Region Count: %zu", ShenandoahHeapRegion::region_count()); log_info(gc, init)("Heap Region Size: " EXACTFMT, EXACTFMTARGS(ShenandoahHeapRegion::region_size_bytes())); log_info(gc, init)("TLAB Size Max: " EXACTFMT, EXACTFMTARGS(ShenandoahHeapRegion::max_tlab_size_bytes())); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp index 0239f961c65f1..2dc0813e51354 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2015, 2022, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -128,7 +129,7 @@ inline void ShenandoahMark::count_liveness(ShenandoahLiveData* live_data, oop ob if (!region->is_humongous_start()) { assert(!region->is_humongous(), "Cannot have continuations here"); - assert(region->is_affiliated(), "Do not count live data within Free Regular Region " SIZE_FORMAT, region_idx); + assert(region->is_affiliated(), "Do not count live data within Free Regular Region %zu", region_idx); ShenandoahLiveData cur = live_data[region_idx]; size_t new_val = size + cur; if (new_val >= SHENANDOAH_LIVEDATA_MAX) { @@ -143,11 +144,11 @@ inline void ShenandoahMark::count_liveness(ShenandoahLiveData* live_data, oop ob shenandoah_assert_in_correct_region(nullptr, obj); size_t num_regions = ShenandoahHeapRegion::required_regions(size * HeapWordSize); - assert(region->is_affiliated(), "Do not count live data within FREE Humongous Start Region " SIZE_FORMAT, region_idx); + assert(region->is_affiliated(), "Do not count live data within FREE Humongous Start Region %zu", region_idx); for (size_t i = region_idx; i < region_idx + num_regions; i++) { ShenandoahHeapRegion* chain_reg = heap->get_region(i); assert(chain_reg->is_humongous(), "Expecting a humongous region"); - assert(chain_reg->is_affiliated(), "Do not count live data within FREE Humongous Continuation Region " SIZE_FORMAT, i); + assert(chain_reg->is_affiliated(), "Do not count live data within FREE Humongous Continuation Region %zu", i); chain_reg->increase_live_data_gc_words(chain_reg->used() >> LogHeapWordSize); } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp index cd0f31ae14ffe..1ef06f2344567 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, Red Hat, Inc. and/or its affiliates. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -154,19 +154,19 @@ void ShenandoahMarkBitMap::check_mark(HeapWord* addr) const { void ShenandoahMarkBitMap::verify_index(idx_t bit) const { assert(bit < _size, - "BitMap index out of bounds: " SIZE_FORMAT " >= " SIZE_FORMAT, + "BitMap index out of bounds: %zu >= %zu", bit, _size); } void ShenandoahMarkBitMap::verify_limit(idx_t bit) const { assert(bit <= _size, - "BitMap limit out of bounds: " SIZE_FORMAT " > " SIZE_FORMAT, + "BitMap limit out of bounds: %zu > %zu", bit, _size); } void ShenandoahMarkBitMap::verify_range(idx_t beg, idx_t end) const { assert(beg <= end, - "BitMap range error: " SIZE_FORMAT " > " SIZE_FORMAT, beg, end); + "BitMap range error: %zu > %zu", beg, end); verify_limit(end); } #endif diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp index ded9fbd97f5b1..250ab508a30bd 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -56,7 +57,7 @@ bool ShenandoahMarkingContext::is_bitmap_range_within_region_clear(const HeapWor size_t start_idx = heap->heap_region_index_containing(start); #ifdef ASSERT size_t end_idx = heap->heap_region_index_containing(end - 1); - assert(start_idx == end_idx, "Expected range to be within same region (" SIZE_FORMAT ", " SIZE_FORMAT ")", start_idx, end_idx); + assert(start_idx == end_idx, "Expected range to be within same region (%zu, %zu)", start_idx, end_idx); #endif ShenandoahHeapRegion* r = heap->get_region(start_idx); if (!heap->is_bitmap_slice_committed(r)) { @@ -73,7 +74,7 @@ void ShenandoahMarkingContext::initialize_top_at_mark_start(ShenandoahHeapRegion _top_at_mark_starts_base[idx] = bottom; _top_bitmaps[idx] = bottom; - log_debug(gc)("SMC:initialize_top_at_mark_start for Region " SIZE_FORMAT ", TAMS: " PTR_FORMAT ", TopOfBitMap: " PTR_FORMAT, + log_debug(gc)("SMC:initialize_top_at_mark_start for Region %zu, TAMS: " PTR_FORMAT ", TopOfBitMap: " PTR_FORMAT, r->index(), p2i(bottom), p2i(r->end())); } @@ -85,7 +86,7 @@ void ShenandoahMarkingContext::clear_bitmap(ShenandoahHeapRegion* r) { HeapWord* bottom = r->bottom(); HeapWord* top_bitmap = _top_bitmaps[r->index()]; - log_debug(gc)("SMC:clear_bitmap for %s Region " SIZE_FORMAT ", top_bitmap: " PTR_FORMAT, + log_debug(gc)("SMC:clear_bitmap for %s Region %zu, top_bitmap: " PTR_FORMAT, r->affiliation_name(), r->index(), p2i(top_bitmap)); if (top_bitmap > bottom) { @@ -94,7 +95,7 @@ void ShenandoahMarkingContext::clear_bitmap(ShenandoahHeapRegion* r) { } assert(is_bitmap_range_within_region_clear(bottom, r->end()), - "Region " SIZE_FORMAT " should have no marks in bitmap", r->index()); + "Region %zu should have no marks in bitmap", r->index()); } bool ShenandoahMarkingContext::is_complete() { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.inline.hpp index 75a16e1554992..d9bddd5fbb6b9 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.inline.hpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -93,16 +94,16 @@ inline void ShenandoahMarkingContext::capture_top_at_mark_start(ShenandoahHeapRe HeapWord* new_tams = r->top(); assert(new_tams >= old_tams, - "Region " SIZE_FORMAT", TAMS updates should be monotonic: " PTR_FORMAT " -> " PTR_FORMAT, + "Region %zu, TAMS updates should be monotonic: " PTR_FORMAT " -> " PTR_FORMAT, idx, p2i(old_tams), p2i(new_tams)); assert((new_tams == r->bottom()) || (old_tams == r->bottom()) || (new_tams >= _top_bitmaps[idx]), - "Region " SIZE_FORMAT", top_bitmaps updates should be monotonic: " PTR_FORMAT " -> " PTR_FORMAT, + "Region %zu, top_bitmaps updates should be monotonic: " PTR_FORMAT " -> " PTR_FORMAT, idx, p2i(_top_bitmaps[idx]), p2i(new_tams)); assert(old_tams == r->bottom() || is_bitmap_range_within_region_clear(old_tams, new_tams), - "Region " SIZE_FORMAT ", bitmap should be clear while adjusting TAMS: " PTR_FORMAT " -> " PTR_FORMAT, + "Region %zu, bitmap should be clear while adjusting TAMS: " PTR_FORMAT " -> " PTR_FORMAT, idx, p2i(old_tams), p2i(new_tams)); - log_debug(gc)("Capturing TAMS for %s Region " SIZE_FORMAT ", was: " PTR_FORMAT ", now: " PTR_FORMAT, + log_debug(gc)("Capturing TAMS for %s Region %zu, was: " PTR_FORMAT ", now: " PTR_FORMAT, r->affiliation_name(), idx, p2i(old_tams), p2i(new_tams)); _top_at_mark_starts_base[idx] = new_tams; @@ -119,7 +120,7 @@ inline HeapWord* ShenandoahMarkingContext::top_at_mark_start(const ShenandoahHea inline void ShenandoahMarkingContext::reset_top_bitmap(ShenandoahHeapRegion* r) { assert(is_bitmap_range_within_region_clear(r->bottom(), r->end()), - "Region " SIZE_FORMAT " should have no marks in bitmap", r->index()); + "Region %zu should have no marks in bitmap", r->index()); _top_bitmaps[r->index()] = r->bottom(); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp index 9350f44585fcf..03c1d920f0df3 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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,15 +55,15 @@ MemoryUsage ShenandoahMemoryPool::get_memory_usage() { size_t committed = _heap->committed(); // These asserts can never fail: max is stable, and all updates to other values never overflow max. - assert(initial <= max, "initial: " SIZE_FORMAT ", max: " SIZE_FORMAT, initial, max); - assert(used <= max, "used: " SIZE_FORMAT ", max: " SIZE_FORMAT, used, max); - assert(committed <= max, "committed: " SIZE_FORMAT ", max: " SIZE_FORMAT, committed, max); + assert(initial <= max, "initial: %zu, max: %zu", initial, max); + assert(used <= max, "used: %zu, max: %zu", used, max); + assert(committed <= max, "committed: %zu, max: %zu", committed, max); // Committed and used are updated concurrently and independently. They can momentarily break // the assert below, which would also fail in downstream code. To avoid that, adjust values // to make sense under the race. See JDK-8207200. committed = MAX2(used, committed); - assert(used <= committed, "used: " SIZE_FORMAT ", committed: " SIZE_FORMAT, used, committed); + assert(used <= committed, "used: %zu, committed: %zu", used, committed); return MemoryUsage(initial, used, committed, max); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp index 8b2412ff9ab05..0f480a929717d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 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 @@ -48,7 +49,7 @@ bool ShenandoahMetricsSnapshot::is_good_progress() { size_t free_actual = _heap->free_set()->available(); size_t free_expected = _heap->max_capacity() / 100 * ShenandoahCriticalFreeThreshold; bool prog_free = free_actual >= free_expected; - log_info(gc, ergo)("%s progress for free space: " SIZE_FORMAT "%s, need " SIZE_FORMAT "%s", + log_info(gc, ergo)("%s progress for free space: %zu%s, need %zu%s", prog_free ? "Good" : "Bad", byte_size_in_proper_unit(free_actual), proper_unit_for_byte_size(free_actual), byte_size_in_proper_unit(free_expected), proper_unit_for_byte_size(free_expected)); @@ -60,7 +61,7 @@ bool ShenandoahMetricsSnapshot::is_good_progress() { size_t progress_actual = (_used_before > _used_after) ? _used_before - _used_after : 0; size_t progress_expected = ShenandoahHeapRegion::region_size_bytes(); bool prog_used = progress_actual >= progress_expected; - log_info(gc, ergo)("%s progress for used space: " SIZE_FORMAT "%s, need " SIZE_FORMAT "%s", + log_info(gc, ergo)("%s progress for used space: %zu%s, need %zu%s", prog_used ? "Good" : "Bad", byte_size_in_proper_unit(progress_actual), proper_unit_for_byte_size(progress_actual), byte_size_in_proper_unit(progress_expected), proper_unit_for_byte_size(progress_expected)); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp b/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp index 3c7ba8e424300..872b9fd26657a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -208,12 +209,12 @@ void BinaryMagnitudeSeq::add(size_t val) { // Defensively saturate for product bits: if (mag < 0) { - assert (false, "bucket index (%d) underflow for value (" SIZE_FORMAT ")", mag, val); + assert (false, "bucket index (%d) underflow for value (%zu)", mag, val); mag = 0; } if (mag >= BitsPerSize_t) { - assert (false, "bucket index (%d) overflow for value (" SIZE_FORMAT ")", mag, val); + assert (false, "bucket index (%d) overflow for value (%zu)", mag, val); mag = BitsPerSize_t - 1; } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp index 36007023d4600..4939a0e355fa3 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 +109,7 @@ class ShenandoahPurgeSATBTask : public WorkerTask { ~ShenandoahPurgeSATBTask() { if (_trashed_oops > 0) { - log_debug(gc)("Purged " SIZE_FORMAT " oops from old generation SATB buffers", _trashed_oops); + log_debug(gc)("Purged %zu oops from old generation SATB buffers", _trashed_oops); } } @@ -653,9 +654,9 @@ void ShenandoahOldGeneration::handle_failed_promotion(Thread* thread, size_t siz const size_t words_remaining = (plab == nullptr)? 0: plab->words_remaining(); const char* promote_enabled = ShenandoahThreadLocalData::allow_plab_promotions(thread)? "enabled": "disabled"; - log_info(gc, ergo)("Promotion failed, size " SIZE_FORMAT ", has plab? %s, PLAB remaining: " SIZE_FORMAT - ", plab promotions %s, promotion reserve: " SIZE_FORMAT ", promotion expended: " SIZE_FORMAT - ", old capacity: " SIZE_FORMAT ", old_used: " SIZE_FORMAT ", old unaffiliated regions: " SIZE_FORMAT, + log_info(gc, ergo)("Promotion failed, size %zu, has plab? %s, PLAB remaining: %zu" + ", plab promotions %s, promotion reserve: %zu, promotion expended: %zu" + ", old capacity: %zu, old_used: %zu, old unaffiliated regions: %zu", size * HeapWordSize, plab == nullptr? "no": "yes", words_remaining * HeapWordSize, promote_enabled, promotion_reserve, promotion_expended, max_capacity(), used(), free_unaffiliated_regions()); @@ -700,7 +701,7 @@ void ShenandoahOldGeneration::abandon_collection_candidates() { void ShenandoahOldGeneration::prepare_for_mixed_collections_after_global_gc() { assert(is_mark_complete(), "Expected old generation mark to be complete after global cycle."); _old_heuristics->prepare_for_old_collections(); - log_info(gc, ergo)("After choosing global collection set, mixed candidates: " UINT32_FORMAT ", coalescing candidates: " SIZE_FORMAT, + log_info(gc, ergo)("After choosing global collection set, mixed candidates: " UINT32_FORMAT ", coalescing candidates: %zu", _old_heuristics->unprocessed_old_collection_candidates(), _old_heuristics->coalesce_and_fill_candidates_count()); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp b/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp index e7d5a2e00c5b2..caee4e1344344 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 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 @@ -73,8 +74,8 @@ void ShenandoahPacer::setup_for_mark() { restart_with(non_taxable, tax); - log_info(gc, ergo)("Pacer for Mark. Expected Live: " SIZE_FORMAT "%s, Free: " SIZE_FORMAT "%s, " - "Non-Taxable: " SIZE_FORMAT "%s, Alloc Tax Rate: %.1fx", + log_info(gc, ergo)("Pacer for Mark. Expected Live: %zu%s, Free: %zu%s, " + "Non-Taxable: %zu%s, Alloc Tax Rate: %.1fx", byte_size_in_proper_unit(live), proper_unit_for_byte_size(live), byte_size_in_proper_unit(free), proper_unit_for_byte_size(free), byte_size_in_proper_unit(non_taxable), proper_unit_for_byte_size(non_taxable), @@ -98,8 +99,8 @@ void ShenandoahPacer::setup_for_evac() { restart_with(non_taxable, tax); - log_info(gc, ergo)("Pacer for Evacuation. Used CSet: " SIZE_FORMAT "%s, Free: " SIZE_FORMAT "%s, " - "Non-Taxable: " SIZE_FORMAT "%s, Alloc Tax Rate: %.1fx", + log_info(gc, ergo)("Pacer for Evacuation. Used CSet: %zu%s, Free: %zu%s, " + "Non-Taxable: %zu%s, Alloc Tax Rate: %.1fx", byte_size_in_proper_unit(used), proper_unit_for_byte_size(used), byte_size_in_proper_unit(free), proper_unit_for_byte_size(free), byte_size_in_proper_unit(non_taxable), proper_unit_for_byte_size(non_taxable), @@ -123,8 +124,8 @@ void ShenandoahPacer::setup_for_updaterefs() { restart_with(non_taxable, tax); - log_info(gc, ergo)("Pacer for Update Refs. Used: " SIZE_FORMAT "%s, Free: " SIZE_FORMAT "%s, " - "Non-Taxable: " SIZE_FORMAT "%s, Alloc Tax Rate: %.1fx", + log_info(gc, ergo)("Pacer for Update Refs. Used: %zu%s, Free: %zu%s, " + "Non-Taxable: %zu%s, Alloc Tax Rate: %.1fx", byte_size_in_proper_unit(used), proper_unit_for_byte_size(used), byte_size_in_proper_unit(free), proper_unit_for_byte_size(free), byte_size_in_proper_unit(non_taxable), proper_unit_for_byte_size(non_taxable), @@ -148,7 +149,7 @@ void ShenandoahPacer::setup_for_idle() { restart_with(initial, tax); - log_info(gc, ergo)("Pacer for Idle. Initial: " SIZE_FORMAT "%s, Alloc Tax Rate: %.1fx", + log_info(gc, ergo)("Pacer for Idle. Initial: %zu%s, Alloc Tax Rate: %.1fx", byte_size_in_proper_unit(initial), proper_unit_for_byte_size(initial), tax); } @@ -164,7 +165,7 @@ void ShenandoahPacer::setup_for_reset() { size_t initial = _heap->max_capacity(); restart_with(initial, 1.0); - log_info(gc, ergo)("Pacer for Reset. Non-Taxable: " SIZE_FORMAT "%s", + log_info(gc, ergo)("Pacer for Reset. Non-Taxable: %zu%s", byte_size_in_proper_unit(initial), proper_unit_for_byte_size(initial)); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp index 07d2fd3c4e342..48e695d1f587d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.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. * Copyright (c) 2020, 2021, Red Hat, Inc. and/or its affiliates. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -673,10 +673,10 @@ void ShenandoahReferenceProcessor::collect_statistics() { discovered[REF_FINAL], discovered[REF_PHANTOM]); - log_info(gc,ref)("Encountered references: Soft: " SIZE_FORMAT ", Weak: " SIZE_FORMAT ", Final: " SIZE_FORMAT ", Phantom: " SIZE_FORMAT, + log_info(gc,ref)("Encountered references: Soft: %zu, Weak: %zu, Final: %zu, Phantom: %zu", encountered[REF_SOFT], encountered[REF_WEAK], encountered[REF_FINAL], encountered[REF_PHANTOM]); - log_info(gc,ref)("Discovered references: Soft: " SIZE_FORMAT ", Weak: " SIZE_FORMAT ", Final: " SIZE_FORMAT ", Phantom: " SIZE_FORMAT, + log_info(gc,ref)("Discovered references: Soft: %zu, Weak: %zu, Final: %zu, Phantom: %zu", discovered[REF_SOFT], discovered[REF_WEAK], discovered[REF_FINAL], discovered[REF_PHANTOM]); - log_info(gc,ref)("Enqueued references: Soft: " SIZE_FORMAT ", Weak: " SIZE_FORMAT ", Final: " SIZE_FORMAT ", Phantom: " SIZE_FORMAT, + log_info(gc,ref)("Enqueued references: Soft: %zu, Weak: %zu, Final: %zu, Phantom: %zu", enqueued[REF_SOFT], enqueued[REF_WEAK], enqueued[REF_FINAL], enqueued[REF_PHANTOM]); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp index 5f09801b92951..f3cc30518c299 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -686,7 +687,7 @@ void ShenandoahScanRememberedTask::do_work(uint worker_id) { while (_work_list->next(&assignment)) { ShenandoahHeapRegion* region = assignment._r; log_debug(gc)("ShenandoahScanRememberedTask::do_work(%u), processing slice of region " - SIZE_FORMAT " at offset " SIZE_FORMAT ", size: " SIZE_FORMAT, + "%zu at offset %zu, size: %zu", worker_id, region->index(), assignment._chunk_offset, assignment._chunk_size); if (region->is_old()) { size_t cluster_size = @@ -856,7 +857,7 @@ ShenandoahRegionChunkIterator::ShenandoahRegionChunkIterator(ShenandoahHeap* hea { #ifdef ASSERT size_t expected_chunk_size_words = _clusters_in_smallest_chunk * CardTable::card_size_in_words() * ShenandoahCardCluster::CardsPerCluster; - assert(smallest_chunk_size_words() == expected_chunk_size_words, "_smallest_chunk_size (" SIZE_FORMAT") is not valid because it does not equal (" SIZE_FORMAT ")", + assert(smallest_chunk_size_words() == expected_chunk_size_words, "_smallest_chunk_size (%zu) is not valid because it does not equal (%zu)", smallest_chunk_size_words(), expected_chunk_size_words); #endif assert(_num_groups <= _maximum_groups, @@ -897,13 +898,13 @@ ShenandoahRegionChunkIterator::ShenandoahRegionChunkIterator(ShenandoahHeap* hea } if (_group_entries[_num_groups-1] < _total_chunks) { assert((_total_chunks - _group_entries[_num_groups-1]) * _group_chunk_size[_num_groups-1] + previous_group_span == - heap->num_regions() * words_in_region, "Total region chunks (" SIZE_FORMAT - ") do not span total heap regions (" SIZE_FORMAT ")", _total_chunks, _heap->num_regions()); + heap->num_regions() * words_in_region, "Total region chunks (%zu" + ") do not span total heap regions (%zu)", _total_chunks, _heap->num_regions()); previous_group_span += (_total_chunks - _group_entries[_num_groups-1]) * _group_chunk_size[_num_groups-1]; _group_entries[_num_groups-1] = _total_chunks; } - assert(previous_group_span == heap->num_regions() * words_in_region, "Total region chunks (" SIZE_FORMAT - ") do not span total heap regions (" SIZE_FORMAT "): " SIZE_FORMAT " does not equal " SIZE_FORMAT, + assert(previous_group_span == heap->num_regions() * words_in_region, "Total region chunks (%zu" + ") do not span total heap regions (%zu): %zu does not equal %zu", _total_chunks, _heap->num_regions(), previous_group_span, heap->num_regions() * words_in_region); // Not necessary, but keeps things tidy diff --git a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp index ec00adc4040b1..b0fc55631e067 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 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 @@ -69,8 +70,8 @@ void ShenandoahScanRemembered::process_clusters(size_t first_cluster, size_t cou const size_t whole_cards = (end_addr - start_addr + CardTable::card_size_in_words() - 1)/CardTable::card_size_in_words(); const size_t end_card_index = start_card_index + whole_cards - 1; - log_debug(gc, remset)("Worker %u: cluster = " SIZE_FORMAT " count = " SIZE_FORMAT " eor = " INTPTR_FORMAT - " start_addr = " INTPTR_FORMAT " end_addr = " INTPTR_FORMAT " cards = " SIZE_FORMAT, + log_debug(gc, remset)("Worker %u: cluster = %zu count = %zu eor = " INTPTR_FORMAT + " start_addr = " INTPTR_FORMAT " end_addr = " INTPTR_FORMAT " cards = %zu", worker_id, first_cluster, count, p2i(end_of_range), p2i(start_addr), p2i(end_addr), whole_cards); // use_write_table states whether we are using the card table that is being @@ -341,7 +342,7 @@ ShenandoahScanRemembered::process_region_slice(ShenandoahHeapRegion *region, siz } } - log_debug(gc)("Remembered set scan processing Region " SIZE_FORMAT ", from " PTR_FORMAT " to " PTR_FORMAT ", using %s table", + log_debug(gc)("Remembered set scan processing Region %zu, from " PTR_FORMAT " to " PTR_FORMAT ", using %s table", region->index(), p2i(start_of_range), p2i(end_of_range), use_write_table? "read/write (updating)": "read (marking)"); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp index d8d6d81578feb..50edea87eba79 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp @@ -384,7 +384,7 @@ class ShenandoahCalculateRegionStatsClosure : public ShenandoahHeapRegionClosure _trashed_regions++; } _regions++; - log_debug(gc)("ShenandoahCalculateRegionStatsClosure: adding " SIZE_FORMAT " for %s Region " SIZE_FORMAT ", yielding: " SIZE_FORMAT, + log_debug(gc)("ShenandoahCalculateRegionStatsClosure: adding %zu for %s Region %zu, yielding: %zu", r->used(), (r->is_humongous() ? "humongous" : "regular"), r->index(), _used); } @@ -423,7 +423,7 @@ class ShenandoahGenerationStatsClosure : public ShenandoahHeapRegionClosure { } static void log_usage(ShenandoahGeneration* generation, ShenandoahCalculateRegionStatsClosure& stats) { - log_debug(gc)("Safepoint verification: %s verified usage: " SIZE_FORMAT "%s, recorded usage: " SIZE_FORMAT "%s", + log_debug(gc)("Safepoint verification: %s verified usage: %zu%s, recorded usage: %zu%s", generation->name(), byte_size_in_proper_unit(generation->used()), proper_unit_for_byte_size(generation->used()), byte_size_in_proper_unit(stats.used()), proper_unit_for_byte_size(stats.used())); @@ -444,12 +444,12 @@ class ShenandoahGenerationStatsClosure : public ShenandoahHeapRegionClosure { label, generation->name(), PROPERFMTARGS(generation_used), PROPERFMTARGS(stats.used())); guarantee(stats.regions() == generation_used_regions, - "%s: generation (%s) used regions (" SIZE_FORMAT ") must equal regions that are in use (" SIZE_FORMAT ")", + "%s: generation (%s) used regions (%zu) must equal regions that are in use (%zu)", label, generation->name(), generation->used_regions(), stats.regions()); size_t generation_capacity = generation->max_capacity(); guarantee(stats.non_trashed_span() <= generation_capacity, - "%s: generation (%s) size spanned by regions (" SIZE_FORMAT ") * region size (" PROPERFMT + "%s: generation (%s) size spanned by regions (%zu) * region size (" PROPERFMT ") must not exceed current capacity (" PROPERFMT ")", label, generation->name(), stats.regions(), PROPERFMTARGS(ShenandoahHeapRegion::region_size_bytes()), PROPERFMTARGS(generation_capacity)); @@ -872,14 +872,14 @@ void ShenandoahVerifier::verify_at_safepoint(const char* label, } if (sizeness != _verify_size_disable) { guarantee(cl.used() == heap_used, - "%s: heap used size must be consistent: heap-used = " SIZE_FORMAT "%s, regions-used = " SIZE_FORMAT "%s", + "%s: heap used size must be consistent: heap-used = %zu%s, regions-used = %zu%s", label, byte_size_in_proper_unit(heap_used), proper_unit_for_byte_size(heap_used), byte_size_in_proper_unit(cl.used()), proper_unit_for_byte_size(cl.used())); } size_t heap_committed = _heap->committed(); guarantee(cl.committed() == heap_committed, - "%s: heap committed size must be consistent: heap-committed = " SIZE_FORMAT "%s, regions-committed = " SIZE_FORMAT "%s", + "%s: heap committed size must be consistent: heap-committed = %zu%s, regions-committed = %zu%s", label, byte_size_in_proper_unit(heap_committed), proper_unit_for_byte_size(heap_committed), byte_size_in_proper_unit(cl.committed()), proper_unit_for_byte_size(cl.committed())); @@ -1026,7 +1026,7 @@ void ShenandoahVerifier::verify_at_safepoint(const char* label, if (reg_live != verf_live) { stringStream ss; r->print_on(&ss); - fatal("%s: Live data should match: region-live = " SIZE_FORMAT ", verifier-live = " UINT32_FORMAT "\n%s", + fatal("%s: Live data should match: region-live = %zu, verifier-live = " UINT32_FORMAT "\n%s", label, reg_live, verf_live, ss.freeze()); } } @@ -1035,7 +1035,7 @@ void ShenandoahVerifier::verify_at_safepoint(const char* label, log_debug(gc)("Safepoint verification finished accumulation of liveness data"); - log_info(gc)("Verify %s, Level %zd (" SIZE_FORMAT " reachable, " SIZE_FORMAT " marked)", + log_info(gc)("Verify %s, Level %zd (%zu reachable, %zu marked)", label, ShenandoahVerifyLevel, count_reachable, count_marked); FREE_C_HEAP_ARRAY(ShenandoahLivenessData, ld); From 8bfa54055013ca92696982c86ed3869627718219 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Thu, 16 Jan 2025 12:48:51 +0000 Subject: [PATCH 22/47] 8347731: Replace SIZE_FORMAT in zgc Reviewed-by: stefank, tschatzl, jsikstro --- src/hotspot/share/gc/z/zAddress.cpp | 4 +-- src/hotspot/share/gc/z/zArguments.cpp | 4 +-- src/hotspot/share/gc/z/zCollectedHeap.cpp | 8 ++--- src/hotspot/share/gc/z/zDirector.cpp | 12 +++---- src/hotspot/share/gc/z/zGeneration.cpp | 8 ++--- src/hotspot/share/gc/z/zHeap.cpp | 8 ++--- .../share/gc/z/zIndexDistributor.inline.hpp | 4 +-- src/hotspot/share/gc/z/zLiveMap.cpp | 4 +-- src/hotspot/share/gc/z/zMark.cpp | 12 +++---- src/hotspot/share/gc/z/zMarkStack.cpp | 4 +-- .../share/gc/z/zMarkStackAllocator.cpp | 8 ++--- src/hotspot/share/gc/z/zNMethodTable.cpp | 8 ++--- src/hotspot/share/gc/z/zPageAllocator.cpp | 16 +++++----- .../share/gc/z/zRelocationSetSelector.cpp | 6 ++-- src/hotspot/share/gc/z/zRememberedSet.cpp | 4 +-- src/hotspot/share/gc/z/zStat.cpp | 32 +++++++++---------- src/hotspot/share/gc/z/zUncommitter.cpp | 4 +-- src/hotspot/share/gc/z/zUnmapper.cpp | 6 ++-- src/hotspot/share/gc/z/zVirtualMemory.cpp | 6 ++-- 19 files changed, 79 insertions(+), 79 deletions(-) diff --git a/src/hotspot/share/gc/z/zAddress.cpp b/src/hotspot/share/gc/z/zAddress.cpp index 1cd33e44a05d1..5cd67736f3a3f 100644 --- a/src/hotspot/share/gc/z/zAddress.cpp +++ b/src/hotspot/share/gc/z/zAddress.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 @@ -106,7 +106,7 @@ void ZGlobalsPointers::initialize() { // Check max supported heap size if (MaxHeapSize > ZAddressOffsetMax) { vm_exit_during_initialization( - err_msg("Java heap too large (max supported heap size is " SIZE_FORMAT "G)", + err_msg("Java heap too large (max supported heap size is %zuG)", ZAddressOffsetMax / G)); } diff --git a/src/hotspot/share/gc/z/zArguments.cpp b/src/hotspot/share/gc/z/zArguments.cpp index 331ca9f7c9423..8d522530d5a04 100644 --- a/src/hotspot/share/gc/z/zArguments.cpp +++ b/src/hotspot/share/gc/z/zArguments.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -180,7 +180,7 @@ void ZArguments::initialize() { // Large page size must match granule size if (!FLAG_IS_DEFAULT(LargePageSizeInBytes) && LargePageSizeInBytes != ZGranuleSize) { vm_exit_during_initialization(err_msg("Incompatible -XX:LargePageSizeInBytes, only " - SIZE_FORMAT "M large pages are supported by ZGC", + "%zuM large pages are supported by ZGC", ZGranuleSize / M)); } diff --git a/src/hotspot/share/gc/z/zCollectedHeap.cpp b/src/hotspot/share/gc/z/zCollectedHeap.cpp index 8afefd5a7cc1c..d9ec2d8c6077a 100644 --- a/src/hotspot/share/gc/z/zCollectedHeap.cpp +++ b/src/hotspot/share/gc/z/zCollectedHeap.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 @@ -363,12 +363,12 @@ void ZCollectedHeap::print_on_error(outputStream* st) const { st->print_cr("ZGC Globals:"); st->print_cr(" Young Collection: %s/%u", ZGeneration::young()->phase_to_string(), ZGeneration::young()->seqnum()); st->print_cr(" Old Collection: %s/%u", ZGeneration::old()->phase_to_string(), ZGeneration::old()->seqnum()); - st->print_cr(" Offset Max: " SIZE_FORMAT "%s (" PTR_FORMAT ")", + st->print_cr(" Offset Max: %zu%s (" PTR_FORMAT ")", byte_size_in_exact_unit(ZAddressOffsetMax), exact_unit_for_byte_size(ZAddressOffsetMax), ZAddressOffsetMax); - st->print_cr(" Page Size Small: " SIZE_FORMAT "M", ZPageSizeSmall / M); - st->print_cr(" Page Size Medium: " SIZE_FORMAT "M", ZPageSizeMedium / M); + st->print_cr(" Page Size Small: %zuM", ZPageSizeSmall / M); + st->print_cr(" Page Size Medium: %zuM", ZPageSizeMedium / M); st->cr(); st->print_cr("ZGC Metadata Bits:"); st->print_cr(" LoadGood: " PTR_FORMAT, ZPointerLoadGoodMask); diff --git a/src/hotspot/share/gc/z/zDirector.cpp b/src/hotspot/share/gc/z/zDirector.cpp index 48e426f068aa6..1b8df139f90ee 100644 --- a/src/hotspot/share/gc/z/zDirector.cpp +++ b/src/hotspot/share/gc/z/zDirector.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 @@ -194,7 +194,7 @@ static ZDriverRequest rule_minor_allocation_rate_dynamic(const ZDirectorStats& s const double time_until_gc = time_until_oom - actual_gc_duration; log_debug(gc, director)("Rule Minor: Allocation Rate (Dynamic GC Workers), " - "MaxAllocRate: %.1fMB/s (+/-%.1f%%), Free: " SIZE_FORMAT "MB, GCCPUTime: %.3f, " + "MaxAllocRate: %.1fMB/s (+/-%.1f%%), Free: %zuMB, GCCPUTime: %.3f, " "GCDuration: %.3fs, TimeUntilOOM: %.3fs, TimeUntilGC: %.3fs, GCWorkers: %u", alloc_rate / M, alloc_rate_sd_percent * 100, @@ -288,7 +288,7 @@ static bool rule_minor_allocation_rate_static(const ZDirectorStats& stats) { // time and end up starting the GC too late in the next interval. const double time_until_gc = time_until_oom - gc_duration; - log_debug(gc, director)("Rule Minor: Allocation Rate (Static GC Workers), MaxAllocRate: %.1fMB/s, Free: " SIZE_FORMAT "MB, GCDuration: %.3fs, TimeUntilGC: %.3fs", + log_debug(gc, director)("Rule Minor: Allocation Rate (Static GC Workers), MaxAllocRate: %.1fMB/s, Free: %zuMB, GCDuration: %.3fs, TimeUntilGC: %.3fs", max_alloc_rate / M, free / M, gc_duration, time_until_gc); return time_until_gc <= 0; @@ -386,7 +386,7 @@ static bool rule_minor_high_usage(const ZDirectorStats& stats) { const double free_percent = percent_of(free, soft_max_capacity); auto print_function = [&](size_t free, double free_percent) { - log_debug(gc, director)("Rule Minor: High Usage, Free: " SIZE_FORMAT "MB(%.1f%%)", + log_debug(gc, director)("Rule Minor: High Usage, Free: %zuMB(%.1f%%)", free / M, free_percent); }; @@ -430,7 +430,7 @@ static bool rule_major_warmup(const ZDirectorStats& stats) { const double used_threshold_percent = (stats._old_stats._cycle._nwarmup_cycles + 1) * 0.1; const size_t used_threshold = (size_t)(soft_max_capacity * used_threshold_percent); - log_debug(gc, director)("Rule Major: Warmup %.0f%%, Used: " SIZE_FORMAT "MB, UsedThreshold: " SIZE_FORMAT "MB", + log_debug(gc, director)("Rule Major: Warmup %.0f%%, Used: %zuMB, UsedThreshold: %zuMB", used_threshold_percent * 100, used / M, used_threshold / M); return used >= used_threshold; @@ -593,7 +593,7 @@ static bool rule_major_proactive(const ZDirectorStats& stats) { const double time_since_last_gc_threshold = 5 * 60; // 5 minutes if (used < used_threshold && time_since_last_gc < time_since_last_gc_threshold) { // Don't even consider doing a proactive GC - log_debug(gc, director)("Rule Major: Proactive, UsedUntilEnabled: " SIZE_FORMAT "MB, TimeUntilEnabled: %.3fs", + log_debug(gc, director)("Rule Major: Proactive, UsedUntilEnabled: %zuMB, TimeUntilEnabled: %.3fs", (used_threshold - used) / M, time_since_last_gc_threshold - time_since_last_gc); return false; diff --git a/src/hotspot/share/gc/z/zGeneration.cpp b/src/hotspot/share/gc/z/zGeneration.cpp index 655f47ba49cd8..9e5e367ce2332 100644 --- a/src/hotspot/share/gc/z/zGeneration.cpp +++ b/src/hotspot/share/gc/z/zGeneration.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 @@ -361,7 +361,7 @@ void ZGeneration::log_phase_switch(Phase from, Phase to) { index += 1; } - assert(index < ARRAY_SIZE(str), "OOB: " SIZE_FORMAT " < " SIZE_FORMAT, index, ARRAY_SIZE(str)); + assert(index < ARRAY_SIZE(str), "OOB: %zu < %zu", index, ARRAY_SIZE(str)); Events::log_zgc_phase_switch("%-21s %4u", str[index], seqnum()); } @@ -796,8 +796,8 @@ uint ZGenerationYoung::compute_tenuring_threshold(ZRelocationSetSelectorStats st // if the GC is finding it hard to keep up with the allocation rate. const double tenuring_threshold_raw = young_life_decay_factor * young_log_residency; - log_trace(gc, reloc)("Young Allocated: " SIZE_FORMAT "M", young_allocated / M); - log_trace(gc, reloc)("Young Garbage: " SIZE_FORMAT "M", young_garbage / M); + log_trace(gc, reloc)("Young Allocated: %zuM", young_allocated / M); + log_trace(gc, reloc)("Young Garbage: %zuM", young_garbage / M); log_debug(gc, reloc)("Allocated To Garbage: %.1f", allocated_garbage_ratio); log_trace(gc, reloc)("Young Log: %.1f", young_log); log_trace(gc, reloc)("Young Residency Reciprocal: %.1f", young_residency_reciprocal); diff --git a/src/hotspot/share/gc/z/zHeap.cpp b/src/hotspot/share/gc/z/zHeap.cpp index d29a5d15795f4..6449aa249fd50 100644 --- a/src/hotspot/share/gc/z/zHeap.cpp +++ b/src/hotspot/share/gc/z/zHeap.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 @@ -75,7 +75,7 @@ ZHeap::ZHeap() // Prime cache if (!_page_allocator.prime_cache(_old.workers(), InitialHeapSize)) { - ZInitialize::error("Failed to allocate initial Java heap (" SIZE_FORMAT "M)", InitialHeapSize / M); + ZInitialize::error("Failed to allocate initial Java heap (%zuM)", InitialHeapSize / M); return; } @@ -238,7 +238,7 @@ void ZHeap::undo_alloc_page(ZPage* page) { assert(page->is_allocating(), "Invalid page state"); ZStatInc(ZCounterUndoPageAllocation); - log_trace(gc)("Undo page allocation, thread: " PTR_FORMAT " (%s), page: " PTR_FORMAT ", size: " SIZE_FORMAT, + log_trace(gc)("Undo page allocation, thread: " PTR_FORMAT " (%s), page: " PTR_FORMAT ", size: %zu", p2i(Thread::current()), ZUtils::thread_name(), p2i(page), page->size()); free_page(page, false /* allow_defragment */); @@ -320,7 +320,7 @@ ZServiceabilityCounters* ZHeap::serviceability_counters() { } void ZHeap::print_on(outputStream* st) const { - st->print_cr(" ZHeap used " SIZE_FORMAT "M, capacity " SIZE_FORMAT "M, max capacity " SIZE_FORMAT "M", + st->print_cr(" ZHeap used %zuM, capacity %zuM, max capacity %zuM", used() / M, capacity() / M, max_capacity() / M); diff --git a/src/hotspot/share/gc/z/zIndexDistributor.inline.hpp b/src/hotspot/share/gc/z/zIndexDistributor.inline.hpp index 26afdef9d052d..c582be8fcee8f 100644 --- a/src/hotspot/share/gc/z/zIndexDistributor.inline.hpp +++ b/src/hotspot/share/gc/z/zIndexDistributor.inline.hpp @@ -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 @@ -274,7 +274,7 @@ class ZIndexDistributorClaimTree : public CHeapObj { assert((levels_size(ClaimLevels - 1) << _last_level_segment_size_shift) == count, "Incorrectly setup"); #if 0 - tty->print_cr("ZIndexDistributorClaimTree count: %d byte size: " SIZE_FORMAT, count, claim_variables_size() + os::vm_page_size()); + tty->print_cr("ZIndexDistributorClaimTree count: %d byte size: %zu", count, claim_variables_size() + os::vm_page_size()); #endif memset(_malloced, 0, claim_variables_size() + os::vm_page_size()); diff --git a/src/hotspot/share/gc/z/zLiveMap.cpp b/src/hotspot/share/gc/z/zLiveMap.cpp index 715ebc6291724..adef9bb5f6cf9 100644 --- a/src/hotspot/share/gc/z/zLiveMap.cpp +++ b/src/hotspot/share/gc/z/zLiveMap.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 @@ -103,7 +103,7 @@ void ZLiveMap::reset_segment(BitMap::idx_t segment) { ZStatInc(ZCounterMarkSegmentResetContention); contention = true; - log_trace(gc)("Mark segment reset contention, thread: " PTR_FORMAT " (%s), map: " PTR_FORMAT ", segment: " SIZE_FORMAT, + log_trace(gc)("Mark segment reset contention, thread: " PTR_FORMAT " (%s), map: " PTR_FORMAT ", segment: %zu", p2i(Thread::current()), ZUtils::thread_name(), p2i(this), segment); } } diff --git a/src/hotspot/share/gc/z/zMark.cpp b/src/hotspot/share/gc/z/zMark.cpp index d33b86c83e57c..9e211a984dda4 100644 --- a/src/hotspot/share/gc/z/zMark.cpp +++ b/src/hotspot/share/gc/z/zMark.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 @@ -135,7 +135,7 @@ void ZMark::start() { for (uint worker_id = 0; worker_id < _nworkers; worker_id++) { const ZMarkStripe* const stripe = _stripes.stripe_for_worker(_nworkers, worker_id); const size_t stripe_id = _stripes.stripe_id(stripe); - log.print(" Worker %u(%u) -> Stripe " SIZE_FORMAT "(" SIZE_FORMAT ")", + log.print(" Worker %u(%u) -> Stripe %zu(%zu)", worker_id, _nworkers, stripe_id, nstripes); } } @@ -194,7 +194,7 @@ void ZMark::push_partial_array(zpointer* addr, size_t length, bool finalizable) const uintptr_t offset = encode_partial_array_offset(addr); const ZMarkStackEntry entry(offset, length, finalizable); - log_develop_trace(gc, marking)("Array push partial: " PTR_FORMAT " (" SIZE_FORMAT "), stripe: " SIZE_FORMAT, + log_develop_trace(gc, marking)("Array push partial: " PTR_FORMAT " (%zu), stripe: %zu", p2i(addr), length, _stripes.stripe_id(stripe)); stacks->push(&_allocator, &_stripes, stripe, &_terminate, entry, false /* publish */); @@ -213,7 +213,7 @@ static void mark_barrier_on_oop_array(volatile zpointer* p, size_t length, bool void ZMark::follow_array_elements_small(zpointer* addr, size_t length, bool finalizable) { assert(length <= ZMarkPartialArrayMinLength, "Too large, should be split"); - log_develop_trace(gc, marking)("Array follow small: " PTR_FORMAT " (" SIZE_FORMAT ")", p2i(addr), length); + log_develop_trace(gc, marking)("Array follow small: " PTR_FORMAT " (%zu)", p2i(addr), length); mark_barrier_on_oop_array(addr, length, finalizable, _generation->is_young()); } @@ -232,8 +232,8 @@ void ZMark::follow_array_elements_large(zpointer* addr, size_t length, bool fina const size_t middle_length = align_down(end - middle_start, ZMarkPartialArrayMinLength); zpointer* const middle_end = middle_start + middle_length; - log_develop_trace(gc, marking)("Array follow large: " PTR_FORMAT "-" PTR_FORMAT" (" SIZE_FORMAT "), " - "middle: " PTR_FORMAT "-" PTR_FORMAT " (" SIZE_FORMAT ")", + log_develop_trace(gc, marking)("Array follow large: " PTR_FORMAT "-" PTR_FORMAT" (%zu), " + "middle: " PTR_FORMAT "-" PTR_FORMAT " (%zu)", p2i(start), p2i(end), length, p2i(middle_start), p2i(middle_end), middle_length); // Push unaligned trailing part diff --git a/src/hotspot/share/gc/z/zMarkStack.cpp b/src/hotspot/share/gc/z/zMarkStack.cpp index c4938af0a5f6d..3b63ab29ae50a 100644 --- a/src/hotspot/share/gc/z/zMarkStack.cpp +++ b/src/hotspot/share/gc/z/zMarkStack.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ void ZMarkStripeSet::set_nstripes(size_t nstripes) { // if they see the old or new values. Atomic::store(&_nstripes_mask, nstripes - 1); - log_debug(gc, marking)("Using " SIZE_FORMAT " mark stripes", nstripes); + log_debug(gc, marking)("Using %zu mark stripes", nstripes); } size_t ZMarkStripeSet::nstripes() const { diff --git a/src/hotspot/share/gc/z/zMarkStackAllocator.cpp b/src/hotspot/share/gc/z/zMarkStackAllocator.cpp index 2bc37a0483a36..1b964949202f4 100644 --- a/src/hotspot/share/gc/z/zMarkStackAllocator.cpp +++ b/src/hotspot/share/gc/z/zMarkStackAllocator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -79,11 +79,11 @@ size_t ZMarkStackSpace::expand_space() { // Expansion limit reached. This is a fatal error since we // currently can't recover from running out of mark stack space. fatal("Mark stack space exhausted. Use -XX:ZMarkStackSpaceLimit= to increase the " - "maximum number of bytes allocated for mark stacks. Current limit is " SIZE_FORMAT "M.", + "maximum number of bytes allocated for mark stacks. Current limit is %zuM.", ZMarkStackSpaceLimit / M); } - log_debug(gc, marking)("Expanding mark stack space: " SIZE_FORMAT "M->" SIZE_FORMAT "M", + log_debug(gc, marking)("Expanding mark stack space: %zuM->%zuM", old_size / M, new_size / M); // Expand @@ -100,7 +100,7 @@ size_t ZMarkStackSpace::shrink_space() { if (shrink_size > 0) { // Shrink - log_debug(gc, marking)("Shrinking mark stack space: " SIZE_FORMAT "M->" SIZE_FORMAT "M", + log_debug(gc, marking)("Shrinking mark stack space: %zuM->%zuM", old_size / M, new_size / M); const uintptr_t shrink_start = _end - shrink_size; diff --git a/src/hotspot/share/gc/z/zNMethodTable.cpp b/src/hotspot/share/gc/z/zNMethodTable.cpp index 9714bee4bd88f..00619f639562f 100644 --- a/src/hotspot/share/gc/z/zNMethodTable.cpp +++ b/src/hotspot/share/gc/z/zNMethodTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -110,9 +110,9 @@ void ZNMethodTable::rebuild(size_t new_size) { assert(is_power_of_2(new_size), "Invalid size"); log_debug(gc, nmethod)("Rebuilding NMethod Table: " - SIZE_FORMAT "->" SIZE_FORMAT " entries, " - SIZE_FORMAT "(%.0f%%->%.0f%%) registered, " - SIZE_FORMAT "(%.0f%%->%.0f%%) unregistered", + "%zu->%zu entries, " + "%zu(%.0f%%->%.0f%%) registered, " + "%zu(%.0f%%->%.0f%%) unregistered", _size, new_size, _nregistered, percent_of(_nregistered, _size), percent_of(_nregistered, new_size), _nunregistered, percent_of(_nunregistered, _size), 0.0); diff --git a/src/hotspot/share/gc/z/zPageAllocator.cpp b/src/hotspot/share/gc/z/zPageAllocator.cpp index ecd9f3e34b9b9..0196ea0f66b06 100644 --- a/src/hotspot/share/gc/z/zPageAllocator.cpp +++ b/src/hotspot/share/gc/z/zPageAllocator.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 @@ -207,12 +207,12 @@ ZPageAllocator::ZPageAllocator(size_t min_capacity, return; } - log_info_p(gc, init)("Min Capacity: " SIZE_FORMAT "M", min_capacity / M); - log_info_p(gc, init)("Initial Capacity: " SIZE_FORMAT "M", initial_capacity / M); - log_info_p(gc, init)("Max Capacity: " SIZE_FORMAT "M", max_capacity / M); - log_info_p(gc, init)("Soft Max Capacity: " SIZE_FORMAT "M", soft_max_capacity / M); + log_info_p(gc, init)("Min Capacity: %zuM", min_capacity / M); + log_info_p(gc, init)("Initial Capacity: %zuM", initial_capacity / M); + log_info_p(gc, init)("Max Capacity: %zuM", max_capacity / M); + log_info_p(gc, init)("Soft Max Capacity: %zuM", soft_max_capacity / M); if (ZPageSizeMedium > 0) { - log_info_p(gc, init)("Medium Page Size: " SIZE_FORMAT "M", ZPageSizeMedium / M); + log_info_p(gc, init)("Medium Page Size: %zuM", ZPageSizeMedium / M); } else { log_info_p(gc, init)("Medium Page Size: N/A"); } @@ -377,7 +377,7 @@ void ZPageAllocator::decrease_capacity(size_t size, bool set_max_capacity) { if (set_max_capacity) { // Adjust current max capacity to avoid further attempts to increase capacity log_error_p(gc)("Forced to lower max Java heap size from " - SIZE_FORMAT "M(%.0f%%) to " SIZE_FORMAT "M(%.0f%%)", + "%zuM(%.0f%%) to %zuM(%.0f%%)", _current_max_capacity / M, percent_of(_current_max_capacity, _max_capacity), _capacity / M, percent_of(_capacity, _max_capacity)); @@ -650,7 +650,7 @@ ZPage* ZPageAllocator::alloc_page_create(ZPageAllocation* allocation) { // Update statistics ZStatInc(ZCounterPageCacheFlush, flushed); - log_debug(gc, heap)("Page Cache Flushed: " SIZE_FORMAT "M", flushed / M); + log_debug(gc, heap)("Page Cache Flushed: %zuM", flushed / M); } // Allocate any remaining physical memory. Capacity and used has diff --git a/src/hotspot/share/gc/z/zRelocationSetSelector.cpp b/src/hotspot/share/gc/z/zRelocationSetSelector.cpp index ec904b914fb0b..482fd8d53cb38 100644 --- a/src/hotspot/share/gc/z/zRelocationSetSelector.cpp +++ b/src/hotspot/share/gc/z/zRelocationSetSelector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -153,7 +153,7 @@ void ZRelocationSetSelectorGroup::select_inner() { } log_trace(gc, reloc)("Candidate Relocation Set (%s Pages): %d->%d, " - "%.1f%% relative defragmentation, " SIZE_FORMAT " forwarding entries, %s, live %d", + "%.1f%% relative defragmentation, %zu forwarding entries, %s, live %d", _name, from, to, diff_reclaimable, from_forwarding_entries, (selected_from == from) ? "Selected" : "Rejected", int(page_live_bytes * 100 / page->size())); @@ -175,7 +175,7 @@ void ZRelocationSetSelectorGroup::select_inner() { _stats[i]._npages_selected = npages_selected[i]; } - log_debug(gc, reloc)("Relocation Set (%s Pages): %d->%d, %d skipped, " SIZE_FORMAT " forwarding entries", + log_debug(gc, reloc)("Relocation Set (%s Pages): %d->%d, %d skipped, %zu forwarding entries", _name, selected_from, selected_to, npages - selected_from, selected_forwarding_entries); } diff --git a/src/hotspot/share/gc/z/zRememberedSet.cpp b/src/hotspot/share/gc/z/zRememberedSet.cpp index f605401648dfb..36f8fef741fdf 100644 --- a/src/hotspot/share/gc/z/zRememberedSet.cpp +++ b/src/hotspot/share/gc/z/zRememberedSet.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 @@ -206,5 +206,5 @@ bool ZRememberedSetContainingInLiveIterator::next(ZRememberedSetContaining* cont } void ZRememberedSetContainingInLiveIterator::print_statistics() const { - _page->log_msg(" (remembered iter count: " SIZE_FORMAT " skipped: " SIZE_FORMAT ")", _count, _count_skipped); + _page->log_msg(" (remembered iter count: %zu skipped: %zu)", _count, _count_skipped); } diff --git a/src/hotspot/share/gc/z/zStat.cpp b/src/hotspot/share/gc/z/zStat.cpp index 96cfa7d3a3718..21619ac7bb91a 100644 --- a/src/hotspot/share/gc/z/zStat.cpp +++ b/src/hotspot/share/gc/z/zStat.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 @@ -48,12 +48,12 @@ #include -#define ZSIZE_FMT SIZE_FORMAT "M(%.0f%%)" +#define ZSIZE_FMT "%zuM(%.0f%%)" #define ZSIZE_ARGS_WITH_MAX(size, max) ((size) / M), (percent_of(size, max)) #define ZSIZE_ARGS(size) ZSIZE_ARGS_WITH_MAX(size, ZStatHeap::max_capacity()) #define ZTABLE_ARGS_NA "%9s", "-" -#define ZTABLE_ARGS(size) SIZE_FORMAT_W(8) "M (%.0f%%)", \ +#define ZTABLE_ARGS(size) "%8zuM (%.0f%%)", \ ((size) / M), (percent_of(size, ZStatHeap::max_capacity())) // @@ -1448,18 +1448,18 @@ void ZStatMark::at_mark_free(size_t mark_stack_usage) { void ZStatMark::print() { log_info(gc, marking)("Mark: " - SIZE_FORMAT " stripe(s), " - SIZE_FORMAT " proactive flush(es), " - SIZE_FORMAT " terminate flush(es), " - SIZE_FORMAT " completion(s), " - SIZE_FORMAT " continuation(s) ", + "%zu stripe(s), " + "%zu proactive flush(es), " + "%zu terminate flush(es), " + "%zu completion(s), " + "%zu continuation(s) ", _nstripes, _nproactiveflush, _nterminateflush, _ntrycomplete, _ncontinue); - log_info(gc, marking)("Mark Stack Usage: " SIZE_FORMAT "M", _mark_stack_usage / M); + log_info(gc, marking)("Mark Stack Usage: %zuM", _mark_stack_usage / M); } // @@ -1544,7 +1544,7 @@ void ZStatRelocation::print_page_summary() { } print_summary("Large", large_summary, 0 /* in_place_count */); - lt.print("Forwarding Usage: " SIZE_FORMAT "M", _forwarding_usage / M); + lt.print("Forwarding Usage: %zuM", _forwarding_usage / M); } void ZStatRelocation::print_age_table() { @@ -1610,13 +1610,13 @@ void ZStatRelocation::print_age_table() { lt.print("%s", create_age_table() .left(ZTABLE_ARGS(total[i] - live[i])) - .left(SIZE_FORMAT_W(7) " / " SIZE_FORMAT, + .left("%7zu / %zu", _selector_stats.small(age).npages_candidates(), _selector_stats.small(age).npages_selected()) - .left(SIZE_FORMAT_W(7) " / " SIZE_FORMAT, + .left("%7zu / %zu", _selector_stats.medium(age).npages_candidates(), _selector_stats.medium(age).npages_selected()) - .left(SIZE_FORMAT_W(7) " / " SIZE_FORMAT, + .left("%7zu / %zu", _selector_stats.large(age).npages_candidates(), _selector_stats.large(age).npages_selected()) .end()); @@ -1627,7 +1627,7 @@ void ZStatRelocation::print_age_table() { // Stat nmethods // void ZStatNMethods::print() { - log_info(gc, nmethod)("NMethods: " SIZE_FORMAT " registered, " SIZE_FORMAT " unregistered", + log_info(gc, nmethod)("NMethods: %zu registered, %zu unregistered", ZNMethodTable::registered_nmethods(), ZNMethodTable::unregistered_nmethods()); } @@ -1638,8 +1638,8 @@ void ZStatNMethods::print() { void ZStatMetaspace::print() { const MetaspaceCombinedStats stats = MetaspaceUtils::get_combined_statistics(); log_info(gc, metaspace)("Metaspace: " - SIZE_FORMAT "M used, " - SIZE_FORMAT "M committed, " SIZE_FORMAT "M reserved", + "%zuM used, " + "%zuM committed, %zuM reserved", stats.used() / M, stats.committed() / M, stats.reserved() / M); diff --git a/src/hotspot/share/gc/z/zUncommitter.cpp b/src/hotspot/share/gc/z/zUncommitter.cpp index a6a455d4a08b4..5e187b819a6e1 100644 --- a/src/hotspot/share/gc/z/zUncommitter.cpp +++ b/src/hotspot/share/gc/z/zUncommitter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, 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 @@ -80,7 +80,7 @@ void ZUncommitter::run_thread() { if (uncommitted > 0) { // Update statistics ZStatInc(ZCounterUncommit, uncommitted); - log_info(gc, heap)("Uncommitted: " SIZE_FORMAT "M(%.0f%%)", + log_info(gc, heap)("Uncommitted: %zuM(%.0f%%)", uncommitted / M, percent_of(uncommitted, ZHeap::heap()->max_capacity())); // Send event diff --git a/src/hotspot/share/gc/z/zUnmapper.cpp b/src/hotspot/share/gc/z/zUnmapper.cpp index b6ef40b6b059f..2b182871e8c04 100644 --- a/src/hotspot/share/gc/z/zUnmapper.cpp +++ b/src/hotspot/share/gc/z/zUnmapper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -70,11 +70,11 @@ bool ZUnmapper::try_enqueue(ZPage* page) { _warned_sync_unmapping = true; log_warning_p(gc)("WARNING: Encountered synchronous unmapping because asynchronous unmapping could not keep up"); } - log_debug(gc, unmap)("Synchronous unmapping " SIZE_FORMAT "M page", page->size() / M); + log_debug(gc, unmap)("Synchronous unmapping %zuM page", page->size() / M); return false; } - log_trace(gc, unmap)("Asynchronous unmapping " SIZE_FORMAT "M page (" SIZE_FORMAT "M / " SIZE_FORMAT "M enqueued)", + log_trace(gc, unmap)("Asynchronous unmapping %zuM page (%zuM / %zuM enqueued)", page->size() / M, _enqueued_bytes / M, queue_capacity() / M); _queue.insert_last(page); diff --git a/src/hotspot/share/gc/z/zVirtualMemory.cpp b/src/hotspot/share/gc/z/zVirtualMemory.cpp index f645eef740840..bef7193f1ad2d 100644 --- a/src/hotspot/share/gc/z/zVirtualMemory.cpp +++ b/src/hotspot/share/gc/z/zVirtualMemory.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 @@ -138,7 +138,7 @@ size_t ZVirtualMemoryManager::reserve_discontiguous(size_t size) { } bool ZVirtualMemoryManager::reserve_contiguous(zoffset start, size_t size) { - assert(is_aligned(size, ZGranuleSize), "Must be granule aligned " SIZE_FORMAT_X, size); + assert(is_aligned(size, ZGranuleSize), "Must be granule aligned 0x%zx", size); // Reserve address views const zaddress_unsafe addr = ZOffset::address_unsafe(start); @@ -201,7 +201,7 @@ bool ZVirtualMemoryManager::reserve(size_t max_capacity) { (contiguous ? "Contiguous" : "Discontiguous"), (limit == ZAddressOffsetMax ? "Unrestricted" : "Restricted"), (reserved == size ? "Complete" : "Degraded")); - log_info_p(gc, init)("Address Space Size: " SIZE_FORMAT "M", reserved / M); + log_info_p(gc, init)("Address Space Size: %zuM", reserved / M); // Record reserved _reserved = reserved; From 3b6e57670cfc8b45b0be228198ebe6033bed3064 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 16 Jan 2025 14:25:52 +0000 Subject: [PATCH 23/47] 8347825: Make IDEA ide support use proper build system mechanisms Reviewed-by: mcimadamore, erikj --- bin/idea.sh | 4 +- make/Main.gmk | 10 +++- .../idea/jdk/{idea.gmk => IdeaGenConfig.gmk} | 55 +++++++++---------- test/make/TestIdea.gmk | 6 +- 4 files changed, 41 insertions(+), 34 deletions(-) rename make/ide/idea/jdk/{idea.gmk => IdeaGenConfig.gmk} (60%) diff --git a/bin/idea.sh b/bin/idea.sh index c85ae294454e5..1ebe9d96c7fa1 100644 --- a/bin/idea.sh +++ b/bin/idea.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 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 @@ -99,7 +99,7 @@ if [ "$VERBOSE" = "true" ] ; then echo "idea template dir: $IDEA_TEMPLATE" fi -cd $TOP ; make -f "$IDEA_MAKE/idea.gmk" -I $MAKE_DIR/.. idea MAKEOVERRIDES= OUT=$IDEA_OUTPUT/env.cfg MODULES="$*" $CONF_ARG || exit 1 +cd $TOP ; make idea-gen-config IDEA_OUTPUT=$IDEA_OUTPUT MODULES="$*" $CONF_ARG || exit 1 cd $SCRIPT_DIR . $IDEA_OUTPUT/env.cfg diff --git a/make/Main.gmk b/make/Main.gmk index 7675fe6fcf718..79b2932439cba 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -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 @@ -356,6 +356,14 @@ $(eval $(call SetupTarget, vscode-project-ccls, \ DEPS := compile-commands, \ )) +################################################################################ +# IDEA IntelliJ projects + +$(eval $(call SetupTarget, idea-gen-config, \ + MAKEFILE := ide/idea/jdk/IdeaGenConfig, \ + ARGS := IDEA_OUTPUT="$(IDEA_OUTPUT)" MODULES="$(MODULES)", \ +)) + ################################################################################ # Build demos targets diff --git a/make/ide/idea/jdk/idea.gmk b/make/ide/idea/jdk/IdeaGenConfig.gmk similarity index 60% rename from make/ide/idea/jdk/idea.gmk rename to make/ide/idea/jdk/IdeaGenConfig.gmk index b27de609c49be..8318463776f94 100644 --- a/make/ide/idea/jdk/idea.gmk +++ b/make/ide/idea/jdk/IdeaGenConfig.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 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 @@ -23,36 +23,35 @@ # questions. # -include Makefile -include make/MainSupport.gmk - -.PHONY: idea - -ifeq ($(SPEC), ) - ifneq ($(words $(SPECS)), 1) - @echo "Error: Multiple build specification files found. Please select one explicitly." - @exit 2 - endif - idea: - @cd $(topdir) - @$(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -j 1 -f $(topdir)/make/ide/idea/jdk/idea.gmk SPEC=$(SPECS) HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) MODULES="$(MODULES)" idea -else #with SPEC - include make/common/Modules.gmk - - ifeq ($(MODULES), ) - SEL_MODULES := $(call FindAllModules) - else - SEL_MODULES := $(MODULES) - endif - - idea: +default: all + +include $(SPEC) +include MakeBase.gmk + +include Modules.gmk + +# MODULES and IDEA_OUTPUT is passed on the command line +ifeq ($(MODULES), ) + override MODULES := $(call FindAllModules) +endif + +ifeq ($(IDEA_OUTPUT), ) + override IDEA_OUTPUT := $(WORKSPACE_ROOT)/.idea +endif + +OUT := $(IDEA_OUTPUT)/env.cfg + +idea: + $(RM) $(OUT) $(ECHO) "SUPPORT=$(SUPPORT_OUTPUTDIR)" >> $(OUT) - $(ECHO) "MODULE_ROOTS=\"$(foreach mod, $(SEL_MODULES), $(call FindModuleSrcDirs, $(mod)))\"" >> $(OUT) - $(ECHO) "MODULE_NAMES=\"$(strip $(foreach mod, $(SEL_MODULES), $(mod)))\"" >> $(OUT) - $(ECHO) "SEL_MODULES=\"$(SEL_MODULES)\"" >> $(OUT) + $(ECHO) "MODULE_ROOTS=\"$(foreach mod, $(MODULES), $(call FindModuleSrcDirs, $(mod)))\"" >> $(OUT) + $(ECHO) "MODULE_NAMES=\"$(strip $(foreach mod, $(MODULES), $(mod)))\"" >> $(OUT) + $(ECHO) "SEL_MODULES=\"$(MODULES)\"" >> $(OUT) $(ECHO) "BOOT_JDK=\"$(BOOT_JDK)\"" >> $(OUT) $(ECHO) "CYGPATH=\"$(PATHTOOL)\"" >> $(OUT) $(ECHO) "SPEC=\"$(SPEC)\"" >> $(OUT) $(ECHO) "JT_HOME=\"$(JT_HOME)\"" >> $(OUT) -endif +all: idea + +.PHONY: default all idea diff --git a/test/make/TestIdea.gmk b/test/make/TestIdea.gmk index fce8769b239cf..e175bbba21b60 100644 --- a/test/make/TestIdea.gmk +++ b/test/make/TestIdea.gmk @@ -33,9 +33,9 @@ clean-idea: verify-idea: $(MKDIR) -p $(IDEA_OUTPUT_DIR) - MAKEFLAGS= MFLAGS= $(BASH) $(TOPDIR)/bin/idea.sh -o $(IDEA_OUTPUT_DIR)/idea1 - MAKEFLAGS= MFLAGS= $(BASH) $(TOPDIR)/bin/idea.sh -o $(IDEA_OUTPUT_DIR)/idea2 java.base - MAKEFLAGS= MFLAGS= $(BASH) $(TOPDIR)/bin/idea.sh -o $(IDEA_OUTPUT_DIR)/idea3 java.base jdk.compiler + cd $(WORKSPACE_ROOT) && HAS_SPEC= MAKEFLAGS= MFLAGS= $(BASH) $(TOPDIR)/bin/idea.sh -o $(IDEA_OUTPUT_DIR)/idea1 + cd $(WORKSPACE_ROOT) && HAS_SPEC= MAKEFLAGS= MFLAGS= $(BASH) $(TOPDIR)/bin/idea.sh -o $(IDEA_OUTPUT_DIR)/idea2 java.base + cd $(WORKSPACE_ROOT) && HAS_SPEC= MAKEFLAGS= MFLAGS= $(BASH) $(TOPDIR)/bin/idea.sh -o $(IDEA_OUTPUT_DIR)/idea3 java.base jdk.compiler TEST_TARGETS += verify-idea From bfa0cb79169ab00b0b600895d7a0f4038e8b8880 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Thu, 16 Jan 2025 14:30:53 +0000 Subject: [PATCH 24/47] 8347730: Replace SIZE_FORMAT in g1 Reviewed-by: kbarrett, tschatzl --- src/hotspot/share/gc/g1/g1AllocRegion.cpp | 8 ++-- src/hotspot/share/gc/g1/g1Allocator.cpp | 4 +- src/hotspot/share/gc/g1/g1BiasedArray.cpp | 8 ++-- src/hotspot/share/gc/g1/g1BiasedArray.hpp | 8 ++-- .../share/gc/g1/g1BlockOffsetTable.cpp | 4 +- .../share/gc/g1/g1BlockOffsetTable.hpp | 4 +- src/hotspot/share/gc/g1/g1CollectedHeap.cpp | 38 +++++++++---------- src/hotspot/share/gc/g1/g1CollectedHeap.hpp | 6 +-- src/hotspot/share/gc/g1/g1CollectionSet.cpp | 4 +- .../share/gc/g1/g1CollectionSetChooser.cpp | 4 +- .../share/gc/g1/g1CommittedRegionMap.cpp | 4 +- src/hotspot/share/gc/g1/g1ConcurrentMark.cpp | 32 ++++++++-------- .../share/gc/g1/g1ConcurrentMark.inline.hpp | 4 +- .../g1/g1ConcurrentMarkObjArrayProcessor.cpp | 4 +- src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp | 4 +- src/hotspot/share/gc/g1/g1FromCardCache.cpp | 6 +-- .../gc/g1/g1FullGCPrepareTask.inline.hpp | 4 +- src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp | 4 +- src/hotspot/share/gc/g1/g1HeapRegion.cpp | 6 +-- .../share/gc/g1/g1HeapRegionRemSet.cpp | 4 +- .../share/gc/g1/g1HeapSizingPolicy.cpp | 14 +++---- src/hotspot/share/gc/g1/g1HeapTransition.cpp | 24 ++++++------ src/hotspot/share/gc/g1/g1IHOPControl.cpp | 12 +++--- src/hotspot/share/gc/g1/g1InitLogger.cpp | 2 +- .../share/gc/g1/g1MonitoringSupport.cpp | 10 ++--- src/hotspot/share/gc/g1/g1NUMA.cpp | 4 +- src/hotspot/share/gc/g1/g1NUMAStats.cpp | 12 +++--- .../share/gc/g1/g1PageBasedVirtualSpace.cpp | 32 ++++++++-------- .../gc/g1/g1ParScanThreadState.inline.hpp | 8 ++-- src/hotspot/share/gc/g1/g1Policy.cpp | 8 ++-- .../share/gc/g1/g1RegionToSpaceMapper.cpp | 6 +-- src/hotspot/share/gc/g1/g1RemSet.cpp | 12 +++--- src/hotspot/share/gc/g1/g1RemSetSummary.cpp | 30 +++++++-------- .../share/gc/g1/g1UncommitRegionTask.cpp | 6 +-- .../gc/g1/g1YoungGCPostEvacuateTasks.cpp | 4 +- src/hotspot/share/gc/g1/g1YoungGenSizer.cpp | 6 +-- .../share/gc/g1/jvmFlagConstraintsG1.cpp | 4 +- 37 files changed, 177 insertions(+), 177 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1AllocRegion.cpp b/src/hotspot/share/gc/g1/g1AllocRegion.cpp index a0a2b31ed6a18..206c0aabf86ef 100644 --- a/src/hotspot/share/gc/g1/g1AllocRegion.cpp +++ b/src/hotspot/share/gc/g1/g1AllocRegion.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 @@ -225,10 +225,10 @@ void G1AllocRegion::trace(const char* str, size_t min_word_size, size_t desired_ if (detailed_info) { if (result != nullptr) { - out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT " actual " SIZE_FORMAT " " PTR_FORMAT, + out->print(" min %zu desired %zu actual %zu " PTR_FORMAT, min_word_size, desired_word_size, actual_word_size, p2i(result)); } else if (min_word_size != 0) { - out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT, min_word_size, desired_word_size); + out->print(" min %zu desired %zu", min_word_size, desired_word_size); } } out->cr(); @@ -319,7 +319,7 @@ G1HeapRegion* MutatorAllocRegion::release() { _wasted_bytes += retire_internal(_retained_alloc_region, false); _retained_alloc_region = nullptr; } - log_debug(gc, alloc, region)("Mutator Allocation stats, regions: %u, wasted size: " SIZE_FORMAT "%s (%4.1f%%)", + log_debug(gc, alloc, region)("Mutator Allocation stats, regions: %u, wasted size: %zu%s (%4.1f%%)", count(), byte_size_in_proper_unit(_wasted_bytes), proper_unit_for_byte_size(_wasted_bytes), diff --git a/src/hotspot/share/gc/g1/g1Allocator.cpp b/src/hotspot/share/gc/g1/g1Allocator.cpp index be8c39ba440b2..0b665592fdf0a 100644 --- a/src/hotspot/share/gc/g1/g1Allocator.cpp +++ b/src/hotspot/share/gc/g1/g1Allocator.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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -218,7 +218,7 @@ HeapWord* G1Allocator::par_allocate_during_gc(G1HeapRegionAttr dest, size_t temp = 0; HeapWord* result = par_allocate_during_gc(dest, word_size, word_size, &temp, node_index); assert(result == nullptr || temp == word_size, - "Requested " SIZE_FORMAT " words, but got " SIZE_FORMAT " at " PTR_FORMAT, + "Requested %zu words, but got %zu at " PTR_FORMAT, word_size, temp, p2i(result)); return result; } diff --git a/src/hotspot/share/gc/g1/g1BiasedArray.cpp b/src/hotspot/share/gc/g1/g1BiasedArray.cpp index 22b07db3d85d6..7e7d8395d6b02 100644 --- a/src/hotspot/share/gc/g1/g1BiasedArray.cpp +++ b/src/hotspot/share/gc/g1/g1BiasedArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, 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 @@ -48,20 +48,20 @@ address G1BiasedMappedArrayBase::create_new_base_array(size_t length, size_t ele #ifndef PRODUCT void G1BiasedMappedArrayBase::verify_index(idx_t index) const { guarantee(_base != nullptr, "Array not initialized"); - guarantee(index < length(), "Index out of bounds index: " SIZE_FORMAT " length: " SIZE_FORMAT, index, length()); + guarantee(index < length(), "Index out of bounds index: %zu length: %zu", index, length()); } void G1BiasedMappedArrayBase::verify_biased_index(idx_t biased_index) const { guarantee(_biased_base != nullptr, "Array not initialized"); guarantee(biased_index >= bias() && biased_index < (bias() + length()), - "Biased index out of bounds, index: " SIZE_FORMAT " bias: " SIZE_FORMAT " length: " SIZE_FORMAT, + "Biased index out of bounds, index: %zu bias: %zu length: %zu", biased_index, bias(), length()); } void G1BiasedMappedArrayBase::verify_biased_index_inclusive_end(idx_t biased_index) const { guarantee(_biased_base != nullptr, "Array not initialized"); guarantee(biased_index >= bias() && biased_index <= (bias() + length()), - "Biased index out of inclusive bounds, index: " SIZE_FORMAT " bias: " SIZE_FORMAT " length: " SIZE_FORMAT, + "Biased index out of inclusive bounds, index: %zu bias: %zu length: %zu", biased_index, bias(), length()); } diff --git a/src/hotspot/share/gc/g1/g1BiasedArray.hpp b/src/hotspot/share/gc/g1/g1BiasedArray.hpp index 67b4c6bbe3084..da99f928ab599 100644 --- a/src/hotspot/share/gc/g1/g1BiasedArray.hpp +++ b/src/hotspot/share/gc/g1/g1BiasedArray.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, 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 @@ -72,12 +72,12 @@ class G1BiasedMappedArrayBase : public CHeapObj { void initialize(HeapWord* bottom, HeapWord* end, size_t target_elem_size_in_bytes, size_t mapping_granularity_in_bytes) { assert(mapping_granularity_in_bytes > 0, "just checking"); assert(is_power_of_2(mapping_granularity_in_bytes), - "mapping granularity must be power of 2, is " SIZE_FORMAT, mapping_granularity_in_bytes); + "mapping granularity must be power of 2, is %zu", mapping_granularity_in_bytes); assert((uintptr_t)bottom % mapping_granularity_in_bytes == 0, - "bottom mapping area address must be a multiple of mapping granularity " SIZE_FORMAT ", is " PTR_FORMAT, + "bottom mapping area address must be a multiple of mapping granularity %zu, is " PTR_FORMAT, mapping_granularity_in_bytes, p2i(bottom)); assert((uintptr_t)end % mapping_granularity_in_bytes == 0, - "end mapping area address must be a multiple of mapping granularity " SIZE_FORMAT ", is " PTR_FORMAT, + "end mapping area address must be a multiple of mapping granularity %zu, is " PTR_FORMAT, mapping_granularity_in_bytes, p2i(end)); size_t num_target_elems = pointer_delta(end, bottom, mapping_granularity_in_bytes); idx_t bias = (uintptr_t)bottom / mapping_granularity_in_bytes; diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp index a8c558743184b..fd8ff9daefff8 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -44,7 +44,7 @@ G1BlockOffsetTable::G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* st _offset_base = ((uint8_t*)bot_reserved.start() - (uintptr_t(_reserved.start()) >> CardTable::card_shift())); log_trace(gc, bot)("G1BlockOffsetTable::G1BlockOffsetTable: "); - log_trace(gc, bot)(" rs.base(): " PTR_FORMAT " rs.size(): " SIZE_FORMAT " rs end(): " PTR_FORMAT, + log_trace(gc, bot)(" rs.base(): " PTR_FORMAT " rs.size(): %zu rs end(): " PTR_FORMAT, p2i(bot_reserved.start()), bot_reserved.byte_size(), p2i(bot_reserved.end())); } diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp index e0454d803f1e4..59d5c4efcef21 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -47,7 +47,7 @@ class G1BlockOffsetTable: public CHeapObj { void check_offset(size_t offset, const char* msg) const { assert(offset < CardTable::card_size_in_words(), - "%s - offset: " SIZE_FORMAT ", N_words: %u", + "%s - offset: %zu, N_words: %u", msg, offset, CardTable::card_size_in_words()); } diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp index 91fc048e982d2..a63123e1d6ff3 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -179,11 +179,11 @@ G1HeapRegion* G1CollectedHeap::new_region(size_t word_size, // safepoint. assert(SafepointSynchronize::is_at_safepoint(), "invariant"); - log_debug(gc, ergo, heap)("Attempt heap expansion (region allocation request failed). Allocation request: " SIZE_FORMAT "B", + log_debug(gc, ergo, heap)("Attempt heap expansion (region allocation request failed). Allocation request: %zuB", word_size * HeapWordSize); assert(word_size * HeapWordSize < G1HeapRegion::GrainBytes, - "This kind of expansion should never be more than one region. Size: " SIZE_FORMAT, + "This kind of expansion should never be more than one region. Size: %zu", word_size * HeapWordSize); if (expand_single_region(node_index)) { // Given that expand_single_region() succeeded in expanding the heap, and we @@ -335,7 +335,7 @@ G1CollectedHeap::humongous_obj_allocate_initialize_regions(G1HeapRegion* first_h } size_t G1CollectedHeap::humongous_obj_size_in_regions(size_t word_size) { - assert(is_humongous(word_size), "Object of size " SIZE_FORMAT " must be humongous here", word_size); + assert(is_humongous(word_size), "Object of size %zu must be humongous here", word_size); return align_up(word_size, G1HeapRegion::GrainWords) / G1HeapRegion::GrainWords; } @@ -358,7 +358,7 @@ HeapWord* G1CollectedHeap::humongous_obj_allocate(size_t word_size) { humongous_start = _hrm.expand_and_allocate_humongous(obj_regions); if (humongous_start != nullptr) { // We managed to find a region by expanding the heap. - log_debug(gc, ergo, heap)("Heap expansion (humongous allocation request). Allocation request: " SIZE_FORMAT "B", + log_debug(gc, ergo, heap)("Heap expansion (humongous allocation request). Allocation request: %zuB", word_size * HeapWordSize); policy()->record_new_heap_size(num_regions()); } else { @@ -444,7 +444,7 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size) { return result; } - log_trace(gc, alloc)("%s: Unsuccessfully scheduled collection allocating " SIZE_FORMAT " words", + log_trace(gc, alloc)("%s: Unsuccessfully scheduled collection allocating %zu words", Thread::current()->name(), word_size); // We can reach here if we were unsuccessful in scheduling a collection (because @@ -462,7 +462,7 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size) { // Give a warning if we seem to be looping forever. if ((QueuedAllocationWarningCount > 0) && (try_count % QueuedAllocationWarningCount == 0)) { - log_warning(gc, alloc)("%s: Retried allocation %u times for " SIZE_FORMAT " words", + log_warning(gc, alloc)("%s: Retried allocation %u times for %zu words", Thread::current()->name(), try_count, word_size); } } @@ -495,8 +495,8 @@ HeapWord* G1CollectedHeap::alloc_archive_region(size_t word_size, HeapWord* pref MemRegion reserved = _hrm.reserved(); if (reserved.word_size() <= word_size) { - log_info(gc, heap)("Unable to allocate regions as archive heap is too large; size requested = " SIZE_FORMAT - " bytes, heap = " SIZE_FORMAT " bytes", word_size, reserved.word_size()); + log_info(gc, heap)("Unable to allocate regions as archive heap is too large; size requested = %zu" + " bytes, heap = %zu bytes", word_size, reserved.word_size()); return nullptr; } @@ -514,7 +514,7 @@ HeapWord* G1CollectedHeap::alloc_archive_region(size_t word_size, HeapWord* pref } increase_used(word_size * HeapWordSize); if (commits != 0) { - log_debug(gc, ergo, heap)("Attempt heap expansion (allocate archive regions). Total size: " SIZE_FORMAT "B", + log_debug(gc, ergo, heap)("Attempt heap expansion (allocate archive regions). Total size: %zuB", G1HeapRegion::GrainWords * HeapWordSize * commits); } @@ -573,7 +573,7 @@ void G1CollectedHeap::dealloc_archive_regions(MemRegion range) { iterate_regions_in_range(range, dealloc_archive_region); if (shrink_count != 0) { - log_debug(gc, ergo, heap)("Attempt heap shrinking (CDS archive regions). Total size: " SIZE_FORMAT "B", + log_debug(gc, ergo, heap)("Attempt heap shrinking (CDS archive regions). Total size: %zuB", G1HeapRegion::GrainWords * HeapWordSize * shrink_count); // Explicit uncommit. uncommit_regions(shrink_count); @@ -673,7 +673,7 @@ HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size) { return result; } - log_trace(gc, alloc)("%s: Unsuccessfully scheduled collection allocating " SIZE_FORMAT "", + log_trace(gc, alloc)("%s: Unsuccessfully scheduled collection allocating %zu", Thread::current()->name(), word_size); // We can reach here if we were unsuccessful in scheduling a collection (because @@ -978,7 +978,7 @@ HeapWord* G1CollectedHeap::expand_and_allocate(size_t word_size) { _verifier->verify_region_sets_optional(); size_t expand_bytes = MAX2(word_size * HeapWordSize, MinHeapDeltaBytes); - log_debug(gc, ergo, heap)("Attempt heap expansion (allocation request failed). Allocation request: " SIZE_FORMAT "B", + log_debug(gc, ergo, heap)("Attempt heap expansion (allocation request failed). Allocation request: %zuB", word_size * HeapWordSize); @@ -995,7 +995,7 @@ bool G1CollectedHeap::expand(size_t expand_bytes, WorkerThreads* pretouch_worker size_t aligned_expand_bytes = os::align_up_vm_page_size(expand_bytes); aligned_expand_bytes = align_up(aligned_expand_bytes, G1HeapRegion::GrainBytes); - log_debug(gc, ergo, heap)("Expand the heap. requested expansion amount: " SIZE_FORMAT "B expansion amount: " SIZE_FORMAT "B", + log_debug(gc, ergo, heap)("Expand the heap. requested expansion amount: %zuB expansion amount: %zuB", expand_bytes, aligned_expand_bytes); if (is_maximal_no_gc()) { @@ -1042,7 +1042,7 @@ void G1CollectedHeap::shrink_helper(size_t shrink_bytes) { uint num_regions_removed = _hrm.shrink_by(num_regions_to_remove); size_t shrunk_bytes = num_regions_removed * G1HeapRegion::GrainBytes; - log_debug(gc, ergo, heap)("Shrink the heap. requested shrinking amount: " SIZE_FORMAT "B aligned shrinking amount: " SIZE_FORMAT "B actual amount shrunk: " SIZE_FORMAT "B", + log_debug(gc, ergo, heap)("Shrink the heap. requested shrinking amount: %zuB aligned shrinking amount: %zuB actual amount shrunk: %zuB", shrink_bytes, aligned_shrink_bytes, shrunk_bytes); if (num_regions_removed > 0) { log_debug(gc, heap)("Uncommittable regions after shrink: %u", num_regions_removed); @@ -2117,12 +2117,12 @@ void G1CollectedHeap::print_on(outputStream* st) const { p2i(_hrm.reserved().start()), p2i(_hrm.reserved().end())); st->cr(); - st->print(" region size " SIZE_FORMAT "K, ", G1HeapRegion::GrainBytes / K); + st->print(" region size %zuK, ", G1HeapRegion::GrainBytes / K); uint young_regions = young_regions_count(); - st->print("%u young (" SIZE_FORMAT "K), ", young_regions, + st->print("%u young (%zuK), ", young_regions, (size_t) young_regions * G1HeapRegion::GrainBytes / K); uint survivor_regions = survivor_regions_count(); - st->print("%u survivors (" SIZE_FORMAT "K)", survivor_regions, + st->print("%u survivors (%zuK)", survivor_regions, (size_t) survivor_regions * G1HeapRegion::GrainBytes / K); st->cr(); if (_numa->is_enabled()) { @@ -2774,7 +2774,7 @@ void G1CollectedHeap::increase_used(size_t bytes) { void G1CollectedHeap::decrease_used(size_t bytes) { assert(_summary_bytes_used >= bytes, - "invariant: _summary_bytes_used: " SIZE_FORMAT " should be >= bytes: " SIZE_FORMAT, + "invariant: _summary_bytes_used: %zu should be >= bytes: %zu", _summary_bytes_used, bytes); _summary_bytes_used -= bytes; } diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp index 1b840392769cd..73dfc85bb1bc0 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -361,8 +361,8 @@ class G1CollectedHeap : public CollectedHeap { do { \ size_t cur_used_bytes = g1h->used(); \ size_t recal_used_bytes = g1h->recalculate_used(); \ - assert(cur_used_bytes == recal_used_bytes, "Used(" SIZE_FORMAT ") is not" \ - " same as recalculated used(" SIZE_FORMAT ").", \ + assert(cur_used_bytes == recal_used_bytes, "Used(%zu) is not" \ + " same as recalculated used(%zu).", \ cur_used_bytes, recal_used_bytes); \ } while (0) #else diff --git a/src/hotspot/share/gc/g1/g1CollectionSet.cpp b/src/hotspot/share/gc/g1/g1CollectionSet.cpp index ec90fd377503d..cedf9fde66ee3 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSet.cpp +++ b/src/hotspot/share/gc/g1/g1CollectionSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -284,7 +284,7 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1Survi size_t pending_cards = _policy->pending_cards_at_gc_start(); - log_trace(gc, ergo, cset)("Start choosing CSet. Pending cards: " SIZE_FORMAT " target pause time: %1.2fms", + log_trace(gc, ergo, cset)("Start choosing CSet. Pending cards: %zu target pause time: %1.2fms", pending_cards, target_pause_time_ms); // The young list is laid with the survivor regions from the previous diff --git a/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp b/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp index 630fb8a7a1122..9438dae691673 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp +++ b/src/hotspot/share/gc/g1/g1CollectionSetChooser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -224,7 +224,7 @@ class G1BuildCandidateRegionsTask : public WorkerTask { num_pruned++; } - log_debug(gc, ergo, cset)("Pruned %u regions out of %u, leaving " SIZE_FORMAT " bytes waste (allowed " SIZE_FORMAT ")", + log_debug(gc, ergo, cset)("Pruned %u regions out of %u, leaving %zu bytes waste (allowed %zu)", num_pruned, num_candidates, wasted_bytes, diff --git a/src/hotspot/share/gc/g1/g1CommittedRegionMap.cpp b/src/hotspot/share/gc/g1/g1CommittedRegionMap.cpp index 6919cc7d0c911..67fd1d8464731 100644 --- a/src/hotspot/share/gc/g1/g1CommittedRegionMap.cpp +++ b/src/hotspot/share/gc/g1/g1CommittedRegionMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, 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 @@ -233,7 +233,7 @@ void G1CommittedRegionMap::verify_free_range(uint start, uint end) const { void G1CommittedRegionMap::verify_no_inactive_regons() const { BitMap::idx_t first_inactive = _inactive.find_first_set_bit(0); - assert(first_inactive == _inactive.size(), "Should be no inactive regions, but was at index: " SIZE_FORMAT, first_inactive); + assert(first_inactive == _inactive.size(), "Should be no inactive regions, but was at index: %zu", first_inactive); } void G1CommittedRegionMap::verify_active_count(uint start, uint end, uint expected) const { diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index d0879e9967cd3..31844ee9ef3bc 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -140,7 +140,7 @@ bool G1CMMarkStack::initialize() { log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (uint)(MarkStackSize / K), (uint)(MarkStackSizeMax / K)); - log_debug(gc)("Initialize mark stack with " SIZE_FORMAT " chunks, maximum " SIZE_FORMAT, + log_debug(gc)("Initialize mark stack with %zu chunks, maximum %zu", initial_num_chunks, max_capacity); return _chunk_allocator.initialize(initial_num_chunks, max_num_chunks); @@ -205,7 +205,7 @@ bool G1CMMarkStack::ChunkAllocator::initialize(size_t initial_capacity, size_t m size_t new_capacity = bucket_size(0); if (!reserve(new_capacity)) { - log_warning(gc)("Failed to reserve memory for new overflow mark stack with " SIZE_FORMAT " chunks and size " SIZE_FORMAT "B.", new_capacity, new_capacity * sizeof(TaskQueueEntryChunk)); + log_warning(gc)("Failed to reserve memory for new overflow mark stack with %zu chunks and size %zuB.", new_capacity, new_capacity * sizeof(TaskQueueEntryChunk)); return false; } return true; @@ -213,7 +213,7 @@ bool G1CMMarkStack::ChunkAllocator::initialize(size_t initial_capacity, size_t m bool G1CMMarkStack::ChunkAllocator::try_expand_to(size_t desired_capacity) { if (_capacity == _max_capacity) { - log_debug(gc)("Can not expand overflow mark stack further, already at maximum capacity of " SIZE_FORMAT " chunks.", _capacity); + log_debug(gc)("Can not expand overflow mark stack further, already at maximum capacity of %zu chunks.", _capacity); return false; } @@ -221,7 +221,7 @@ bool G1CMMarkStack::ChunkAllocator::try_expand_to(size_t desired_capacity) { desired_capacity = MIN2(desired_capacity, _max_capacity); if (reserve(desired_capacity)) { - log_debug(gc)("Expanded the mark stack capacity from " SIZE_FORMAT " to " SIZE_FORMAT " chunks", + log_debug(gc)("Expanded the mark stack capacity from %zu to %zu chunks", old_capacity, desired_capacity); return true; } @@ -249,7 +249,7 @@ G1CMMarkStack::ChunkAllocator::~ChunkAllocator() { } bool G1CMMarkStack::ChunkAllocator::reserve(size_t new_capacity) { - assert(new_capacity <= _max_capacity, "Cannot expand overflow mark stack beyond the max_capacity" SIZE_FORMAT " chunks.", _max_capacity); + assert(new_capacity <= _max_capacity, "Cannot expand overflow mark stack beyond the max_capacity of %zu chunks.", _max_capacity); size_t highest_bucket = get_bucket(new_capacity - 1); size_t i = get_bucket(_capacity); @@ -273,7 +273,7 @@ bool G1CMMarkStack::ChunkAllocator::reserve(size_t new_capacity) { TaskQueueEntryChunk* bucket_base = MmapArrayAllocator::allocate_or_null(bucket_capacity, mtGC); if (bucket_base == nullptr) { - log_warning(gc)("Failed to reserve memory for increasing the overflow mark stack capacity with " SIZE_FORMAT " chunks and size " SIZE_FORMAT "B.", + log_warning(gc)("Failed to reserve memory for increasing the overflow mark stack capacity with %zu chunks and size %zuB.", bucket_capacity, bucket_capacity * sizeof(TaskQueueEntryChunk)); return false; } @@ -384,7 +384,7 @@ void G1CMRootMemRegions::reset() { void G1CMRootMemRegions::add(HeapWord* start, HeapWord* end) { assert_at_safepoint(); size_t idx = Atomic::fetch_then_add(&_num_root_regions, 1u); - assert(idx < _max_regions, "Trying to add more root MemRegions than there is space " SIZE_FORMAT, _max_regions); + assert(idx < _max_regions, "Trying to add more root MemRegions than there is space %zu", _max_regions); assert(start != nullptr && end != nullptr && start <= end, "Start (" PTR_FORMAT ") should be less or equal to " "end (" PTR_FORMAT ")", p2i(start), p2i(end)); _root_regions[idx].set_start(start); @@ -446,7 +446,7 @@ void G1CMRootMemRegions::scan_finished() { if (!_should_abort) { assert(_claimed_root_regions >= num_root_regions(), - "we should have claimed all root regions, claimed " SIZE_FORMAT ", length = %u", + "we should have claimed all root regions, claimed %zu, length = %u", _claimed_root_regions, num_root_regions()); } @@ -790,7 +790,7 @@ void G1ConcurrentMark::clear_bitmap(WorkerThreads* workers, bool may_yield) { G1ClearBitMapTask cl(this, num_workers, may_yield); - log_debug(gc, ergo)("Running %s with %u workers for " SIZE_FORMAT " work units.", cl.name(), num_workers, num_chunks); + log_debug(gc, ergo)("Running %s with %u workers for %zu work units.", cl.name(), num_workers, num_chunks); workers->run_task(&cl, num_workers); guarantee(may_yield || cl.is_complete(), "Must have completed iteration when not yielding."); } @@ -1737,7 +1737,7 @@ void G1ConcurrentMark::weak_refs_work() { // We can not trust g1_is_alive and the contents of the heap if the marking stack // overflowed while processing references. Exit the VM. fatal("Overflow during reference processing, can not continue. Current mark stack depth: " - SIZE_FORMAT ", MarkStackSize: " SIZE_FORMAT ", MarkStackSizeMax: " SIZE_FORMAT ". " + "%zu, MarkStackSize: %zu, MarkStackSizeMax: %zu. " "Please increase MarkStackSize and/or MarkStackSizeMax and restart.", _global_mark_stack.size(), MarkStackSize, MarkStackSizeMax); return; @@ -1882,7 +1882,7 @@ void G1ConcurrentMark::finalize_marking() { SATBMarkQueueSet& satb_mq_set = G1BarrierSet::satb_mark_queue_set(); guarantee(has_overflown() || satb_mq_set.completed_buffers_num() == 0, - "Invariant: has_overflown = %s, num buffers = " SIZE_FORMAT, + "Invariant: has_overflown = %s, num buffers = %zu", BOOL_TO_STR(has_overflown()), satb_mq_set.completed_buffers_num()); @@ -1898,7 +1898,7 @@ void G1ConcurrentMark::flush_all_task_caches() { misses += stats.second; } size_t sum = hits + misses; - log_debug(gc, stats)("Mark stats cache hits " SIZE_FORMAT " misses " SIZE_FORMAT " ratio %1.3lf", + log_debug(gc, stats)("Mark stats cache hits %zu misses %zu ratio %1.3lf", hits, misses, percent_of(hits, sum)); } @@ -2475,7 +2475,7 @@ void G1CMTask::print_stats() { _step_times_ms.sum()); size_t const hits = _mark_stats_cache.hits(); size_t const misses = _mark_stats_cache.misses(); - log_debug(gc, stats)(" Mark Stats Cache: hits " SIZE_FORMAT " misses " SIZE_FORMAT " ratio %.3f", + log_debug(gc, stats)(" Mark Stats Cache: hits %zu misses %zu ratio %.3f", hits, misses, percent_of(hits, hits + misses)); } @@ -2976,7 +2976,7 @@ G1CMTask::G1CMTask(uint worker_id, #define G1PPRL_TYPE_H_FORMAT " %4s" #define G1PPRL_STATE_FORMAT " %-5s" #define G1PPRL_STATE_H_FORMAT " %5s" -#define G1PPRL_BYTE_FORMAT " " SIZE_FORMAT_W(9) +#define G1PPRL_BYTE_FORMAT " %9zu" #define G1PPRL_BYTE_H_FORMAT " %9s" #define G1PPRL_DOUBLE_FORMAT "%14.1f" #define G1PPRL_GCEFF_FORMAT " %14s" @@ -2984,7 +2984,7 @@ G1CMTask::G1CMTask(uint worker_id, // For summary info #define G1PPRL_SUM_ADDR_FORMAT(tag) " " tag ":" G1PPRL_ADDR_BASE_FORMAT -#define G1PPRL_SUM_BYTE_FORMAT(tag) " " tag ": " SIZE_FORMAT +#define G1PPRL_SUM_BYTE_FORMAT(tag) " " tag ": %zu" #define G1PPRL_SUM_MB_FORMAT(tag) " " tag ": %1.2f MB" #define G1PPRL_SUM_MB_PERC_FORMAT(tag) G1PPRL_SUM_MB_FORMAT(tag) " / %1.2f %%" diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp index 039169794c543..c5ad269ae6902 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -92,7 +92,7 @@ inline void G1CMMarkStack::iterate(Fn fn) const { TaskQueueEntryChunk* cur = _chunk_list; while (cur != nullptr) { - guarantee(num_chunks <= _chunks_in_chunk_list, "Found " SIZE_FORMAT " oop chunks which is more than there should be", num_chunks); + guarantee(num_chunks <= _chunks_in_chunk_list, "Found %zu oop chunks which is more than there should be", num_chunks); for (size_t i = 0; i < EntriesPerChunk; ++i) { if (cur->data[i].is_null()) { diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.cpp index ee1b1d6555a36..3708c3d6d8f91 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -48,7 +48,7 @@ size_t G1CMObjArrayProcessor::process_array_slice(objArrayOop obj, HeapWord* sta } size_t G1CMObjArrayProcessor::process_obj(oop obj) { - assert(should_be_sliced(obj), "Must be an array object %d and large " SIZE_FORMAT, obj->is_objArray(), obj->size()); + assert(should_be_sliced(obj), "Must be an array object %d and large %zu", obj->is_objArray(), obj->size()); return process_array_slice(objArrayOop(obj), cast_from_oop(obj), objArrayOop(obj)->size()); } diff --git a/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp b/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp index 96c212bd2ed28..7e2e0d5a14d7b 100644 --- a/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp +++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -174,7 +174,7 @@ void G1DirtyCardQueueSet::verify_num_cards() const { actual += cur->size(); } assert(actual == Atomic::load(&_num_cards), - "Num entries in completed buffers should be " SIZE_FORMAT " but are " SIZE_FORMAT, + "Num entries in completed buffers should be %zu but are %zu", Atomic::load(&_num_cards), actual); } #endif // ASSERT diff --git a/src/hotspot/share/gc/g1/g1FromCardCache.cpp b/src/hotspot/share/gc/g1/g1FromCardCache.cpp index 062130f40ab7f..b4e0d8e9af730 100644 --- a/src/hotspot/share/gc/g1/g1FromCardCache.cpp +++ b/src/hotspot/share/gc/g1/g1FromCardCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -57,7 +57,7 @@ void G1FromCardCache::initialize(uint max_reserved_regions) { void G1FromCardCache::invalidate(uint start_idx, size_t new_num_regions) { guarantee((size_t)start_idx + new_num_regions <= max_uintx, - "Trying to invalidate beyond maximum region, from %u size " SIZE_FORMAT, + "Trying to invalidate beyond maximum region, from %u size %zu", start_idx, new_num_regions); uint end_idx = (start_idx + (uint)new_num_regions); assert(end_idx <= _max_reserved_regions, "Must be within max."); @@ -73,7 +73,7 @@ void G1FromCardCache::invalidate(uint start_idx, size_t new_num_regions) { void G1FromCardCache::print(outputStream* out) { for (uint i = 0; i < num_par_rem_sets(); i++) { for (uint j = 0; j < _max_reserved_regions; j++) { - out->print_cr("_from_card_cache[%u][%u] = " SIZE_FORMAT ".", + out->print_cr("_from_card_cache[%u][%u] = %zu.", i, j, at(i, j)); } } diff --git a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.inline.hpp b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.inline.hpp index 1d2a023ed3a64..f9868bba67893 100644 --- a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.inline.hpp +++ b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -107,7 +107,7 @@ inline bool G1DetermineCompactionQueueClosure::do_heap_region(G1HeapRegion* hr) // Too many live objects in the region; skip compacting it. _collector->update_from_compacting_to_skip_compacting(hr->hrm_index()); - log_trace(gc, phases)("Phase 2: skip compaction region index: %u, live words: " SIZE_FORMAT, + log_trace(gc, phases)("Phase 2: skip compaction region index: %u, live words: %zu", hr->hrm_index(), _collector->live_words(hr->hrm_index())); } diff --git a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp index 4ec708ae09392..a2a0c4d5c9d61 100644 --- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp +++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.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 @@ -405,7 +405,7 @@ void G1GCPhaseTimes::trace_time(const char* name, double value) const { } void G1GCPhaseTimes::trace_count(const char* name, size_t value) const { - log_trace(gc, phases)(" %s: " SIZE_FORMAT, name, value); + log_trace(gc, phases)(" %s: %zu", name, value); } double G1GCPhaseTimes::print_pre_evacuate_collection_set() const { diff --git a/src/hotspot/share/gc/g1/g1HeapRegion.cpp b/src/hotspot/share/gc/g1/g1HeapRegion.cpp index 9cb2650f8208c..6e89ef9a95fef 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegion.cpp +++ b/src/hotspot/share/gc/g1/g1HeapRegion.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -389,7 +389,7 @@ bool G1HeapRegion::verify_code_roots(VerifyOption vo) const { if (is_empty()) { bool has_code_roots = code_roots_length > 0; if (has_code_roots) { - log_error(gc, verify)("region " HR_FORMAT " is empty but has " SIZE_FORMAT " code root entries", + log_error(gc, verify)("region " HR_FORMAT " is empty but has %zu code root entries", HR_FORMAT_PARAMS(this), code_roots_length); } return has_code_roots; @@ -398,7 +398,7 @@ bool G1HeapRegion::verify_code_roots(VerifyOption vo) const { if (is_continues_humongous()) { bool has_code_roots = code_roots_length > 0; if (has_code_roots) { - log_error(gc, verify)("region " HR_FORMAT " is a continuation of a humongous region but has " SIZE_FORMAT " code root entries", + log_error(gc, verify)("region " HR_FORMAT " is a continuation of a humongous region but has %zu code root entries", HR_FORMAT_PARAMS(this), code_roots_length); } return has_code_roots; diff --git a/src/hotspot/share/gc/g1/g1HeapRegionRemSet.cpp b/src/hotspot/share/gc/g1/g1HeapRegionRemSet.cpp index c1343fd7dbffc..7449b0cfedb60 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegionRemSet.cpp +++ b/src/hotspot/share/gc/g1/g1HeapRegionRemSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -98,7 +98,7 @@ G1MonotonicArenaMemoryStats G1HeapRegionRemSet::card_set_memory_stats() const { } void G1HeapRegionRemSet::print_static_mem_size(outputStream* out) { - out->print_cr(" Static structures = " SIZE_FORMAT, G1HeapRegionRemSet::static_mem_size()); + out->print_cr(" Static structures = %zu", G1HeapRegionRemSet::static_mem_size()); } // Code roots support diff --git a/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp b/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp index 553ba53c67fca..755c13bd91b0c 100644 --- a/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp +++ b/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp @@ -74,7 +74,7 @@ static void log_expansion(double short_term_pause_time_ratio, log_debug(gc, ergo, heap)("Heap expansion: " "short term pause time ratio %1.2f%% long term pause time ratio %1.2f%% " "threshold %1.2f%% pause time ratio %1.2f%% fully expanded %s " - "resize by " SIZE_FORMAT "B", + "resize by %zuB", short_term_pause_time_ratio * 100.0, long_term_pause_time_ratio * 100.0, threshold * 100.0, @@ -240,8 +240,8 @@ size_t G1HeapSizingPolicy::full_collection_resize_amount(bool& expand) { // This assert only makes sense here, before we adjust them // with respect to the min and max heap size. assert(minimum_desired_capacity <= maximum_desired_capacity, - "minimum_desired_capacity = " SIZE_FORMAT ", " - "maximum_desired_capacity = " SIZE_FORMAT, + "minimum_desired_capacity = %zu, " + "maximum_desired_capacity = %zu", minimum_desired_capacity, maximum_desired_capacity); // Should not be greater than the heap max size. No need to adjust @@ -258,8 +258,8 @@ size_t G1HeapSizingPolicy::full_collection_resize_amount(bool& expand) { size_t expand_bytes = minimum_desired_capacity - capacity_after_gc; log_debug(gc, ergo, heap)("Attempt heap expansion (capacity lower than min desired capacity). " - "Capacity: " SIZE_FORMAT "B occupancy: " SIZE_FORMAT "B live: " SIZE_FORMAT "B " - "min_desired_capacity: " SIZE_FORMAT "B (%zu %%)", + "Capacity: %zuB occupancy: %zuB live: %zuB " + "min_desired_capacity: %zuB (%zu %%)", capacity_after_gc, used_after_gc, _g1h->used(), minimum_desired_capacity, MinHeapFreeRatio); expand = true; @@ -270,8 +270,8 @@ size_t G1HeapSizingPolicy::full_collection_resize_amount(bool& expand) { size_t shrink_bytes = capacity_after_gc - maximum_desired_capacity; log_debug(gc, ergo, heap)("Attempt heap shrinking (capacity higher than max desired capacity). " - "Capacity: " SIZE_FORMAT "B occupancy: " SIZE_FORMAT "B live: " SIZE_FORMAT "B " - "maximum_desired_capacity: " SIZE_FORMAT "B (%zu %%)", + "Capacity: %zuB occupancy: %zuB live: %zuB " + "maximum_desired_capacity: %zuB (%zu %%)", capacity_after_gc, used_after_gc, _g1h->used(), maximum_desired_capacity, MaxHeapFreeRatio); expand = false; diff --git a/src/hotspot/share/gc/g1/g1HeapTransition.cpp b/src/hotspot/share/gc/g1/g1HeapTransition.cpp index 815b701c4be90..f27553898a383 100644 --- a/src/hotspot/share/gc/g1/g1HeapTransition.cpp +++ b/src/hotspot/share/gc/g1/g1HeapTransition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -96,7 +96,7 @@ class G1HeapTransition::DetailedUsageClosure: public G1HeapRegionClosure { _usage._humongous_used += r->used(); _usage._humongous_region_count++; } else { - assert(r->used() == 0, "Expected used to be 0 but it was " SIZE_FORMAT, r->used()); + assert(r->used() == 0, "Expected used to be 0 but it was %zu", r->used()); } return false; } @@ -109,7 +109,7 @@ static void log_regions(const char* msg, size_t before_length, size_t after_leng if (lt.is_enabled()) { LogStream ls(lt); - ls.print("%s regions: " SIZE_FORMAT "->" SIZE_FORMAT "(" SIZE_FORMAT ")", + ls.print("%s regions: %zu->%zu(%zu)", msg, before_length, after_length, capacity); // Not null only if gc+heap+numa at Debug level is enabled. if (before_per_node_length != nullptr && after_per_node_length != nullptr) { @@ -141,12 +141,12 @@ void G1HeapTransition::print() { DetailedUsageClosure blk; _g1_heap->heap_region_iterate(&blk); usage = blk._usage; - assert(usage._eden_region_count == 0, "Expected no eden regions, but got " SIZE_FORMAT, usage._eden_region_count); - assert(usage._survivor_region_count == after._survivor_length, "Expected survivors to be " SIZE_FORMAT " but was " SIZE_FORMAT, + assert(usage._eden_region_count == 0, "Expected no eden regions, but got %zu", usage._eden_region_count); + assert(usage._survivor_region_count == after._survivor_length, "Expected survivors to be %zu but was %zu", after._survivor_length, usage._survivor_region_count); - assert(usage._old_region_count == after._old_length, "Expected old to be " SIZE_FORMAT " but was " SIZE_FORMAT, + assert(usage._old_region_count == after._old_length, "Expected old to be %zu but was %zu", after._old_length, usage._old_region_count); - assert(usage._humongous_region_count == after._humongous_length, "Expected humongous to be " SIZE_FORMAT " but was " SIZE_FORMAT, + assert(usage._humongous_region_count == after._humongous_length, "Expected humongous to be %zu but was %zu", after._humongous_length, usage._humongous_region_count); } @@ -156,17 +156,17 @@ void G1HeapTransition::print() { log_regions("Survivor", _before._survivor_length, after._survivor_length, survivor_capacity_length_before_gc, _before._survivor_length_per_node, after._survivor_length_per_node); - log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K", + log_trace(gc, heap)(" Used: %zuK, Waste: %zuK", usage._survivor_used / K, ((after._survivor_length * G1HeapRegion::GrainBytes) - usage._survivor_used) / K); - log_info(gc, heap)("Old regions: " SIZE_FORMAT "->" SIZE_FORMAT, + log_info(gc, heap)("Old regions: %zu->%zu", _before._old_length, after._old_length); - log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K", + log_trace(gc, heap)(" Used: %zuK, Waste: %zuK", usage._old_used / K, ((after._old_length * G1HeapRegion::GrainBytes) - usage._old_used) / K); - log_info(gc, heap)("Humongous regions: " SIZE_FORMAT "->" SIZE_FORMAT, + log_info(gc, heap)("Humongous regions: %zu->%zu", _before._humongous_length, after._humongous_length); - log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K", + log_trace(gc, heap)(" Used: %zuK, Waste: %zuK", usage._humongous_used / K, ((after._humongous_length * G1HeapRegion::GrainBytes) - usage._humongous_used) / K); MetaspaceUtils::print_metaspace_change(_before._meta_sizes); diff --git a/src/hotspot/share/gc/g1/g1IHOPControl.cpp b/src/hotspot/share/gc/g1/g1IHOPControl.cpp index db8426d940139..86e916fe0c924 100644 --- a/src/hotspot/share/gc/g1/g1IHOPControl.cpp +++ b/src/hotspot/share/gc/g1/g1IHOPControl.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 @@ -40,7 +40,7 @@ G1IHOPControl::G1IHOPControl(double initial_ihop_percent, } void G1IHOPControl::update_target_occupancy(size_t new_target_occupancy) { - log_debug(gc, ihop)("Target occupancy update: old: " SIZE_FORMAT "B, new: " SIZE_FORMAT "B", + log_debug(gc, ihop)("Target occupancy update: old: %zuB, new: %zuB", _target_occupancy, new_target_occupancy); _target_occupancy = new_target_occupancy; } @@ -54,8 +54,8 @@ void G1IHOPControl::update_allocation_info(double allocation_time_s, size_t addi void G1IHOPControl::print() { assert(_target_occupancy > 0, "Target occupancy still not updated yet."); size_t cur_conc_mark_start_threshold = get_conc_mark_start_threshold(); - log_debug(gc, ihop)("Basic information (value update), threshold: " SIZE_FORMAT "B (%1.2f), target occupancy: " SIZE_FORMAT "B, current occupancy: " SIZE_FORMAT "B, " - "recent allocation size: " SIZE_FORMAT "B, recent allocation duration: %1.2fms, recent old gen allocation rate: %1.2fB/s, recent marking phase length: %1.2fms", + log_debug(gc, ihop)("Basic information (value update), threshold: %zuB (%1.2f), target occupancy: %zuB, current occupancy: %zuB, " + "recent allocation size: %zuB, recent allocation duration: %1.2fms, recent old gen allocation rate: %1.2fB/s, recent marking phase length: %1.2fms", cur_conc_mark_start_threshold, percent_of(cur_conc_mark_start_threshold, _target_occupancy), _target_occupancy, @@ -169,8 +169,8 @@ void G1AdaptiveIHOPControl::update_marking_length(double marking_length_s) { void G1AdaptiveIHOPControl::print() { G1IHOPControl::print(); size_t actual_target = actual_target_threshold(); - log_debug(gc, ihop)("Adaptive IHOP information (value update), threshold: " SIZE_FORMAT "B (%1.2f), internal target occupancy: " SIZE_FORMAT "B, " - "occupancy: " SIZE_FORMAT "B, additional buffer size: " SIZE_FORMAT "B, predicted old gen allocation rate: %1.2fB/s, " + log_debug(gc, ihop)("Adaptive IHOP information (value update), threshold: %zuB (%1.2f), internal target occupancy: %zuB, " + "occupancy: %zuB, additional buffer size: %zuB, predicted old gen allocation rate: %1.2fB/s, " "predicted marking phase length: %1.2fms, prediction active: %s", get_conc_mark_start_threshold(), percent_of(get_conc_mark_start_threshold(), actual_target), diff --git a/src/hotspot/share/gc/g1/g1InitLogger.cpp b/src/hotspot/share/gc/g1/g1InitLogger.cpp index 04e0a9a0f2bc7..3f1cdb376fe58 100644 --- a/src/hotspot/share/gc/g1/g1InitLogger.cpp +++ b/src/hotspot/share/gc/g1/g1InitLogger.cpp @@ -30,7 +30,7 @@ #include "utilities/globalDefinitions.hpp" void G1InitLogger::print_heap() { - log_info_p(gc, init)("Heap Region Size: " SIZE_FORMAT "M", G1HeapRegionSize / M); + log_info_p(gc, init)("Heap Region Size: %zuM", G1HeapRegionSize / M); GCInitLogger::print_heap(); } diff --git a/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp b/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp index 203ef473fa258..0c788f746e13e 100644 --- a/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp +++ b/src/hotspot/share/gc/g1/g1MonitoringSupport.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 @@ -285,12 +285,12 @@ void G1MonitoringSupport::recalculate_sizes() { _eden_space_used = MIN2(_eden_space_used, _eden_space_committed); // _survivor_space_used is calculated during a safepoint and _survivor_space_committed // is calculated from survivor region count * heap region size. - assert(_survivor_space_used <= _survivor_space_committed, "Survivor used bytes(" SIZE_FORMAT - ") should be less than or equal to survivor committed(" SIZE_FORMAT ")", + assert(_survivor_space_used <= _survivor_space_committed, "Survivor used bytes(%zu)" + " should be less than or equal to survivor committed(%zu)", _survivor_space_used, _survivor_space_committed); // _old_gen_committed is calculated in terms of _old_gen_used value. - assert(_old_gen_used <= _old_gen_committed, "Old gen used bytes(" SIZE_FORMAT - ") should be less than or equal to old gen committed(" SIZE_FORMAT ")", + assert(_old_gen_used <= _old_gen_committed, "Old gen used bytes(%zu)" + " should be less than or equal to old gen committed(%zu)", _old_gen_used, _old_gen_committed); } diff --git a/src/hotspot/share/gc/g1/g1NUMA.cpp b/src/hotspot/share/gc/g1/g1NUMA.cpp index 923d3af621d70..66ef0faae0e41 100644 --- a/src/hotspot/share/gc/g1/g1NUMA.cpp +++ b/src/hotspot/share/gc/g1/g1NUMA.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 @@ -215,7 +215,7 @@ void G1NUMA::request_memory_on_node(void* aligned_address, size_t size_in_bytes, uint node_index = preferred_node_index_for_index(region_index); assert(is_aligned(aligned_address, page_size()), "Given address (" PTR_FORMAT ") should be aligned.", p2i(aligned_address)); - assert(is_aligned(size_in_bytes, page_size()), "Given size (" SIZE_FORMAT ") should be aligned.", size_in_bytes); + assert(is_aligned(size_in_bytes, page_size()), "Given size (%zu) should be aligned.", size_in_bytes); log_trace(gc, heap, numa)("Request memory [" PTR_FORMAT ", " PTR_FORMAT ") to be NUMA id (%u)", p2i(aligned_address), p2i((char*)aligned_address + size_in_bytes), _node_ids[node_index]); diff --git a/src/hotspot/share/gc/g1/g1NUMAStats.cpp b/src/hotspot/share/gc/g1/g1NUMAStats.cpp index 089e4c0e8b83a..b26321f4ed80b 100644 --- a/src/hotspot/share/gc/g1/g1NUMAStats.cpp +++ b/src/hotspot/share/gc/g1/g1NUMAStats.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, 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 @@ -162,7 +162,7 @@ static const char* phase_to_explanatory_string(G1NUMAStats::NodeDataItems phase) } } -#define RATE_TOTAL_FORMAT "%0.0f%% " SIZE_FORMAT "/" SIZE_FORMAT +#define RATE_TOTAL_FORMAT "%0.0f%% %zu/%zu" void G1NUMAStats::print_info(G1NUMAStats::NodeDataItems phase) { LogTarget(Info, gc, heap, numa) lt; @@ -206,18 +206,18 @@ void G1NUMAStats::print_mutator_alloc_stat_debug() { for (uint req = 0; req < array_width; req++) { ls.print("%3d ", _node_ids[req]); for (uint alloc = 0; alloc < array_width; alloc++) { - ls.print(SIZE_FORMAT_W(8), _node_data[NewRegionAlloc]->get(req, alloc)); + ls.print("%8zu", _node_data[NewRegionAlloc]->get(req, alloc)); } - ls.print(SIZE_FORMAT_W(8), _node_data[NewRegionAlloc]->sum(req)); + ls.print("%8zu", _node_data[NewRegionAlloc]->sum(req)); ls.print_cr(""); // Add padding to align with the string 'Requested NUMA id'. ls.print(" "); } ls.print("Any "); for (uint alloc = 0; alloc < array_width; alloc++) { - ls.print(SIZE_FORMAT_W(8), _node_data[NewRegionAlloc]->get(array_width, alloc)); + ls.print("%8zu", _node_data[NewRegionAlloc]->get(array_width, alloc)); } - ls.print(SIZE_FORMAT_W(8), _node_data[NewRegionAlloc]->sum(array_width)); + ls.print("%8zu", _node_data[NewRegionAlloc]->sum(array_width)); ls.print_cr(""); } } diff --git a/src/hotspot/share/gc/g1/g1PageBasedVirtualSpace.cpp b/src/hotspot/share/gc/g1/g1PageBasedVirtualSpace.cpp index 41c4fc3a34cec..ea9dd35b64caa 100644 --- a/src/hotspot/share/gc/g1/g1PageBasedVirtualSpace.cpp +++ b/src/hotspot/share/gc/g1/g1PageBasedVirtualSpace.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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,13 +48,13 @@ void G1PageBasedVirtualSpace::initialize_with_page_size(ReservedSpace rs, size_t vmassert(page_size > 0, "Page size must be non-zero."); guarantee(is_aligned(rs.base(), page_size), - "Reserved space base " PTR_FORMAT " is not aligned to requested page size " SIZE_FORMAT, p2i(rs.base()), page_size); + "Reserved space base " PTR_FORMAT " is not aligned to requested page size %zu", p2i(rs.base()), page_size); guarantee(is_aligned(used_size, os::vm_page_size()), - "Given used reserved space size needs to be OS page size aligned (" SIZE_FORMAT " bytes) but is " SIZE_FORMAT, os::vm_page_size(), used_size); + "Given used reserved space size needs to be OS page size aligned (%zu bytes) but is %zu", os::vm_page_size(), used_size); guarantee(used_size <= rs.size(), - "Used size of reserved space " SIZE_FORMAT " bytes is smaller than reservation at " SIZE_FORMAT " bytes", used_size, rs.size()); + "Used size of reserved space %zu bytes is smaller than reservation at %zu bytes", used_size, rs.size()); guarantee(is_aligned(rs.size(), page_size), - "Expected that the virtual space is size aligned, but " SIZE_FORMAT " is not aligned to page size " SIZE_FORMAT, rs.size(), page_size); + "Expected that the virtual space is size aligned, but %zu is not aligned to page size %zu", rs.size(), page_size); _low_boundary = rs.base(); _high_boundary = _low_boundary + used_size; @@ -121,15 +121,15 @@ size_t G1PageBasedVirtualSpace::page_size() const { bool G1PageBasedVirtualSpace::is_after_last_page(size_t index) const { guarantee(index <= _committed.size(), - "Given boundary page " SIZE_FORMAT " is beyond managed page count " SIZE_FORMAT, index, _committed.size()); + "Given boundary page %zu is beyond managed page count %zu", index, _committed.size()); return index == _committed.size(); } void G1PageBasedVirtualSpace::commit_preferred_pages(size_t start, size_t num_pages) { vmassert(num_pages > 0, "No full pages to commit"); vmassert(start + num_pages <= _committed.size(), - "Tried to commit area from page " SIZE_FORMAT " to page " SIZE_FORMAT " " - "that is outside of managed space of " SIZE_FORMAT " pages", + "Tried to commit area from page %zu to page %zu " + "that is outside of managed space of %zu pages", start, start + num_pages, _committed.size()); char* start_addr = page_start(start); @@ -147,9 +147,9 @@ void G1PageBasedVirtualSpace::commit_tail() { void G1PageBasedVirtualSpace::commit_internal(size_t start_page, size_t end_page) { guarantee(start_page < end_page, - "Given start page " SIZE_FORMAT " is larger or equal to end page " SIZE_FORMAT, start_page, end_page); + "Given start page %zu is larger or equal to end page %zu", start_page, end_page); guarantee(end_page <= _committed.size(), - "Given end page " SIZE_FORMAT " is beyond end of managed page amount of " SIZE_FORMAT, end_page, _committed.size()); + "Given end page %zu is beyond end of managed page amount of %zu", end_page, _committed.size()); size_t pages = end_page - start_page; bool need_to_commit_tail = is_after_last_page(end_page) && is_last_page_partial(); @@ -176,7 +176,7 @@ char* G1PageBasedVirtualSpace::bounded_end_addr(size_t end_page) const { bool G1PageBasedVirtualSpace::commit(size_t start_page, size_t size_in_pages) { // We need to make sure to commit all pages covered by the given area. guarantee(is_area_uncommitted(start_page, size_in_pages), - "Specified area is not uncommitted, start page: " SIZE_FORMAT ", page count: " SIZE_FORMAT, + "Specified area is not uncommitted, start page: %zu, page count: %zu", start_page, size_in_pages); bool zero_filled = true; @@ -198,7 +198,7 @@ bool G1PageBasedVirtualSpace::commit(size_t start_page, size_t size_in_pages) { void G1PageBasedVirtualSpace::uncommit_internal(size_t start_page, size_t end_page) { guarantee(start_page < end_page, - "Given start page " SIZE_FORMAT " is larger or equal to end page " SIZE_FORMAT, start_page, end_page); + "Given start page %zu is larger or equal to end page %zu", start_page, end_page); char* start_addr = page_start(start_page); os::uncommit_memory(start_addr, pointer_delta(bounded_end_addr(end_page), start_addr, sizeof(char))); @@ -206,7 +206,7 @@ void G1PageBasedVirtualSpace::uncommit_internal(size_t start_page, size_t end_pa void G1PageBasedVirtualSpace::uncommit(size_t start_page, size_t size_in_pages) { guarantee(is_area_committed(start_page, size_in_pages), - "Specified area is not committed, start page: " SIZE_FORMAT ", page count: " SIZE_FORMAT, + "Specified area is not committed, start page: %zu, page count: %zu", start_page, size_in_pages); size_t end_page = start_page + size_in_pages; @@ -236,9 +236,9 @@ void G1PageBasedVirtualSpace::print_on(outputStream* out) { out->print ("Virtual space:"); if (_special) out->print(" (pinned in memory)"); out->cr(); - out->print_cr(" - committed: " SIZE_FORMAT, committed_size()); - out->print_cr(" - reserved: " SIZE_FORMAT, reserved_size()); - out->print_cr(" - preferred page size: " SIZE_FORMAT, _page_size); + out->print_cr(" - committed: %zu", committed_size()); + out->print_cr(" - reserved: %zu", reserved_size()); + out->print_cr(" - preferred page size: %zu", _page_size); out->print_cr(" - [low_b, high_b]: [" PTR_FORMAT ", " PTR_FORMAT "]", p2i(_low_boundary), p2i(_high_boundary)); } diff --git a/src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp b/src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp index f96a24007390c..148284e7ef7c1 100644 --- a/src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp +++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp @@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,7 @@ inline void G1ParScanThreadState::remember_root_into_optional_region(T* p) { oop o = RawAccess::oop_load(p); uint index = _g1h->heap_region_containing(o)->index_in_opt_cset(); assert(index < _max_num_optional_regions, - "Trying to access optional region idx %u beyond " SIZE_FORMAT, index, _max_num_optional_regions); + "Trying to access optional region idx %u beyond %zu", index, _max_num_optional_regions); _oops_into_optional_regions[index].push_root(p); } @@ -84,14 +84,14 @@ inline void G1ParScanThreadState::remember_reference_into_optional_region(T* p) oop o = RawAccess::oop_load(p); uint index = _g1h->heap_region_containing(o)->index_in_opt_cset(); assert(index < _max_num_optional_regions, - "Trying to access optional region idx %u beyond " SIZE_FORMAT, index, _max_num_optional_regions); + "Trying to access optional region idx %u beyond %zu", index, _max_num_optional_regions); _oops_into_optional_regions[index].push_oop(p); verify_task(p); } G1OopStarChunkedList* G1ParScanThreadState::oops_into_optional_region(const G1HeapRegion* hr) { assert(hr->index_in_opt_cset() < _max_num_optional_regions, - "Trying to access optional region idx %u beyond " SIZE_FORMAT " " HR_FORMAT, + "Trying to access optional region idx %u beyond %zu " HR_FORMAT, hr->index_in_opt_cset(), _max_num_optional_regions, HR_FORMAT_PARAMS(hr)); return &_oops_into_optional_regions[hr->index_in_opt_cset()]; } diff --git a/src/hotspot/share/gc/g1/g1Policy.cpp b/src/hotspot/share/gc/g1/g1Policy.cpp index 1b71901f0fe05..46502fa82abd9 100644 --- a/src/hotspot/share/gc/g1/g1Policy.cpp +++ b/src/hotspot/share/gc/g1/g1Policy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -606,8 +606,8 @@ void G1Policy::record_full_collection_end() { static void log_refinement_stats(const char* kind, const G1ConcurrentRefineStats& stats) { log_debug(gc, refine, stats) - ("%s refinement: %.2fms, refined: " SIZE_FORMAT - ", precleaned: " SIZE_FORMAT ", dirtied: " SIZE_FORMAT, + ("%s refinement: %.2fms, refined: %zu" + ", precleaned: %zu, dirtied: %zu", kind, stats.refinement_time().seconds() * MILLIUNITS, stats.refined_cards(), @@ -757,7 +757,7 @@ bool G1Policy::need_to_start_conc_mark(const char* source, size_t alloc_word_siz bool result = false; if (marking_request_bytes > marking_initiating_used_threshold) { result = collector_state()->in_young_only_phase(); - log_debug(gc, ergo, ihop)("%s occupancy: " SIZE_FORMAT "B allocation request: " SIZE_FORMAT "B threshold: " SIZE_FORMAT "B (%1.2f) source: %s", + log_debug(gc, ergo, ihop)("%s occupancy: %zuB allocation request: %zuB threshold: %zuB (%1.2f) source: %s", result ? "Request concurrent cycle initiation (occupancy higher than threshold)" : "Do not request concurrent cycle initiation (still doing mixed collections)", cur_used_bytes, alloc_byte_size, marking_initiating_used_threshold, (double) marking_initiating_used_threshold / _g1h->capacity() * 100, source); } diff --git a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp index ed43bf94648e2..b0fbdfec94d78 100644 --- a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp +++ b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -91,7 +91,7 @@ class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper { virtual void commit_regions(uint start_idx, size_t num_regions, WorkerThreads* pretouch_workers) { guarantee(is_range_uncommitted(start_idx, num_regions), - "Range not uncommitted, start: %u, num_regions: " SIZE_FORMAT, + "Range not uncommitted, start: %u, num_regions: %zu", start_idx, num_regions); const size_t start_page = (size_t)start_idx * _pages_per_region; @@ -113,7 +113,7 @@ class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper { virtual void uncommit_regions(uint start_idx, size_t num_regions) { guarantee(is_range_committed(start_idx, num_regions), - "Range not committed, start: %u, num_regions: " SIZE_FORMAT, + "Range not committed, start: %u, num_regions: %zu", start_idx, num_regions); _storage.uncommit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region); diff --git a/src/hotspot/share/gc/g1/g1RemSet.cpp b/src/hotspot/share/gc/g1/g1RemSet.cpp index 7ae81de1d074f..abb86993e5d58 100644 --- a/src/hotspot/share/gc/g1/g1RemSet.cpp +++ b/src/hotspot/share/gc/g1/g1RemSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -107,7 +107,7 @@ class G1RemSetScanState : public CHeapObj { // dirty card, i.e. actually needs scanning. bool chunk_needs_scan(uint const region_idx, uint const card_in_region) const { size_t const idx = ((size_t)region_idx << _log_scan_chunks_per_region) + (card_in_region >> _scan_chunks_shift); - assert(idx < _num_total_scan_chunks, "Index " SIZE_FORMAT " out of bounds " SIZE_FORMAT, + assert(idx < _num_total_scan_chunks, "Index %zu out of bounds %zu", idx, _num_total_scan_chunks); return _region_scan_chunks[idx]; } @@ -347,7 +347,7 @@ class G1RemSetScanState : public CHeapObj { void set_chunk_dirty(size_t const card_idx) { assert((card_idx >> _scan_chunks_shift) < _num_total_scan_chunks, - "Trying to access index " SIZE_FORMAT " out of bounds " SIZE_FORMAT, + "Trying to access index %zu out of bounds %zu", card_idx >> _scan_chunks_shift, _num_total_scan_chunks); size_t const chunk_idx = card_idx >> _scan_chunks_shift; _region_scan_chunks[chunk_idx] = true; @@ -1438,7 +1438,7 @@ void G1RemSet::print_merge_heap_roots_stats() { size_t total_old_region_cards = (g1h->num_regions() - (g1h->num_free_regions() - g1h->collection_set()->cur_length())) * G1HeapRegion::CardsPerRegion; - ls.print_cr("Visited cards " SIZE_FORMAT " Total dirty " SIZE_FORMAT " (%.2lf%%) Total old " SIZE_FORMAT " (%.2lf%%)", + ls.print_cr("Visited cards %zu Total dirty %zu (%.2lf%%) Total old %zu (%.2lf%%)", num_visited_cards, total_dirty_region_cards, percent_of(num_visited_cards, total_dirty_region_cards), @@ -1471,7 +1471,7 @@ void G1RemSet::merge_heap_roots(bool initial_evacuation) { { G1MergeHeapRootsTask cl(_scan_state, num_workers, initial_evacuation); - log_debug(gc, ergo)("Running %s using %u workers for " SIZE_FORMAT " regions", + log_debug(gc, ergo)("Running %s using %u workers for %zu regions", cl.name(), num_workers, increment_length); workers->run_task(&cl, num_workers); } @@ -1504,7 +1504,7 @@ inline void check_card_ptr(CardTable::CardValue* card_ptr, G1CardTable* ct) { #ifdef ASSERT G1CollectedHeap* g1h = G1CollectedHeap::heap(); assert(g1h->is_in(ct->addr_for(card_ptr)), - "Card at " PTR_FORMAT " index " SIZE_FORMAT " representing heap at " PTR_FORMAT " (%u) must be in committed heap", + "Card at " PTR_FORMAT " index %zu representing heap at " PTR_FORMAT " (%u) must be in committed heap", p2i(card_ptr), ct->index_for(ct->addr_for(card_ptr)), p2i(ct->addr_for(card_ptr)), diff --git a/src/hotspot/share/gc/g1/g1RemSetSummary.cpp b/src/hotspot/share/gc/g1/g1RemSetSummary.cpp index 5ea3500a7b0f7..ba6f9008f6ae6 100644 --- a/src/hotspot/share/gc/g1/g1RemSetSummary.cpp +++ b/src/hotspot/share/gc/g1/g1RemSetSummary.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 @@ -153,29 +153,29 @@ class RegionTypeCounter { size_t code_root_elems() const { return _code_root_elems; } void print_rs_mem_info_on(outputStream * out, size_t total) { - out->print_cr(" " SIZE_FORMAT_W(8) " (%5.1f%%) by " SIZE_FORMAT " " - "(" SIZE_FORMAT ") %s regions unused " SIZE_FORMAT, + out->print_cr(" %8zu (%5.1f%%) by %zu " + "(%zu) %s regions unused %zu", rs_mem_size(), rs_mem_size_percent_of(total), amount_tracked(), amount(), _name, rs_unused_mem_size()); } void print_cards_occupied_info_on(outputStream * out, size_t total) { - out->print_cr(" " SIZE_FORMAT_W(8) " (%5.1f%%) entries by " SIZE_FORMAT " " - "(" SIZE_FORMAT ") %s regions", + out->print_cr(" %8zu (%5.1f%%) entries by %zu " + "(%zu) %s regions", cards_occupied(), cards_occupied_percent_of(total), amount_tracked(), amount(), _name); } void print_code_root_mem_info_on(outputStream * out, size_t total) { - out->print_cr(" " SIZE_FORMAT_W(8) "%s (%5.1f%%) by " SIZE_FORMAT " %s regions", + out->print_cr(" %8zu%s (%5.1f%%) by %zu %s regions", byte_size_in_proper_unit(code_root_mem_size()), proper_unit_for_byte_size(code_root_mem_size()), code_root_mem_size_percent_of(total), amount(), _name); } void print_code_root_elems_info_on(outputStream * out, size_t total) { - out->print_cr(" " SIZE_FORMAT_W(8) " (%5.1f%%) elements by " SIZE_FORMAT " %s regions", + out->print_cr(" %8zu (%5.1f%%) elements by %zu %s regions", code_root_elems(), code_root_elems_percent_of(total), amount(), _name); } }; @@ -267,8 +267,8 @@ class HRRSStatsIter: public G1HeapRegionClosure { RegionTypeCounter* counters[] = { &_young, &_humongous, &_free, &_old, nullptr }; out->print_cr(" Current rem set statistics"); - out->print_cr(" Total per region rem sets sizes = " SIZE_FORMAT - " Max = " SIZE_FORMAT " unused = " SIZE_FORMAT, + out->print_cr(" Total per region rem sets sizes = %zu" + " Max = %zu unused = %zu", total_rs_mem_sz(), max_rs_mem_sz(), total_rs_unused_mem_sz()); @@ -276,7 +276,7 @@ class HRRSStatsIter: public G1HeapRegionClosure { (*current)->print_rs_mem_info_on(out, total_rs_mem_sz()); } - out->print_cr(" " SIZE_FORMAT " occupied cards represented.", + out->print_cr(" %zu occupied cards represented.", total_cards_occupied()); for (RegionTypeCounter** current = &counters[0]; *current != nullptr; current++) { (*current)->print_cards_occupied_info_on(out, total_cards_occupied()); @@ -285,7 +285,7 @@ class HRRSStatsIter: public G1HeapRegionClosure { // Largest sized rem set region statistics G1HeapRegionRemSet* rem_set = max_rs_mem_sz_region()->rem_set(); out->print_cr(" Region with largest rem set = " HR_FORMAT ", " - "size = " SIZE_FORMAT " occupied = " SIZE_FORMAT, + "size = %zu occupied = %zu", HR_FORMAT_PARAMS(max_rs_mem_sz_region()), rem_set->mem_size(), rem_set->occupied()); @@ -296,8 +296,8 @@ class HRRSStatsIter: public G1HeapRegionClosure { // Code root statistics G1HeapRegionRemSet* max_code_root_rem_set = max_code_root_mem_sz_region()->rem_set(); - out->print_cr(" Total heap region code root sets sizes = " SIZE_FORMAT "%s." - " Max = " SIZE_FORMAT "%s.", + out->print_cr(" Total heap region code root sets sizes = %zu%s." + " Max = %zu%s.", byte_size_in_proper_unit(total_code_root_mem_sz()), proper_unit_for_byte_size(total_code_root_mem_sz()), byte_size_in_proper_unit(max_code_root_rem_set->code_roots_mem_size()), @@ -306,14 +306,14 @@ class HRRSStatsIter: public G1HeapRegionClosure { (*current)->print_code_root_mem_info_on(out, total_code_root_mem_sz()); } - out->print_cr(" " SIZE_FORMAT " code roots represented.", + out->print_cr(" %zu code roots represented.", total_code_root_elems()); for (RegionTypeCounter** current = &counters[0]; *current != nullptr; current++) { (*current)->print_code_root_elems_info_on(out, total_code_root_elems()); } out->print_cr(" Region with largest amount of code roots = " HR_FORMAT ", " - "size = " SIZE_FORMAT "%s, num_slots = " SIZE_FORMAT ".", + "size = %zu%s, num_slots = %zu.", HR_FORMAT_PARAMS(max_code_root_mem_sz_region()), byte_size_in_proper_unit(max_code_root_rem_set->code_roots_mem_size()), proper_unit_for_byte_size(max_code_root_rem_set->code_roots_mem_size()), diff --git a/src/hotspot/share/gc/g1/g1UncommitRegionTask.cpp b/src/hotspot/share/gc/g1/g1UncommitRegionTask.cpp index 31ca32d9ea2f5..c82441fc06805 100644 --- a/src/hotspot/share/gc/g1/g1UncommitRegionTask.cpp +++ b/src/hotspot/share/gc/g1/g1UncommitRegionTask.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -82,7 +82,7 @@ void G1UncommitRegionTask::report_execution(Tickspan time, uint regions) { _summary_region_count += regions; _summary_duration += time; - log_trace(gc, heap)("Concurrent Uncommit: " SIZE_FORMAT "%s, %u regions, %1.3fms", + log_trace(gc, heap)("Concurrent Uncommit: %zu%s, %u regions, %1.3fms", byte_size_in_proper_unit(regions * G1HeapRegion::GrainBytes), proper_unit_for_byte_size(regions * G1HeapRegion::GrainBytes), regions, @@ -90,7 +90,7 @@ void G1UncommitRegionTask::report_execution(Tickspan time, uint regions) { } void G1UncommitRegionTask::report_summary() { - log_debug(gc, heap)("Concurrent Uncommit Summary: " SIZE_FORMAT "%s, %u regions, %1.3fms", + log_debug(gc, heap)("Concurrent Uncommit Summary: %zu%s, %u regions, %1.3fms", byte_size_in_proper_unit(_summary_region_count * G1HeapRegion::GrainBytes), proper_unit_for_byte_size(_summary_region_count * G1HeapRegion::GrainBytes), _summary_region_count, diff --git a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp index c72dcc9661821..6df637ce68f1a 100644 --- a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp +++ b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.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 @@ -394,7 +394,7 @@ class G1FreeHumongousRegionClosure : public G1HeapRegionIndexClosure { "Only eagerly reclaiming type arrays is supported, but the object " PTR_FORMAT " is not.", p2i(r->bottom())); - log_debug(gc, humongous)("Reclaimed humongous region %u (object size " SIZE_FORMAT " @ " PTR_FORMAT ")", + log_debug(gc, humongous)("Reclaimed humongous region %u (object size %zu @ " PTR_FORMAT ")", region_index, obj->size() * HeapWordSize, p2i(r->bottom()) diff --git a/src/hotspot/share/gc/g1/g1YoungGenSizer.cpp b/src/hotspot/share/gc/g1/g1YoungGenSizer.cpp index 0c4b0b90df0aa..9224fec3cad7d 100644 --- a/src/hotspot/share/gc/g1/g1YoungGenSizer.cpp +++ b/src/hotspot/share/gc/g1/g1YoungGenSizer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -44,8 +44,8 @@ G1YoungGenSizer::G1YoungGenSizer() : _sizer_kind(SizerDefaults), if (NewSize > MaxNewSize) { if (FLAG_IS_CMDLINE(MaxNewSize)) { - log_warning(gc, ergo)("NewSize (" SIZE_FORMAT "k) is greater than the MaxNewSize (" SIZE_FORMAT "k). " - "A new max generation size of " SIZE_FORMAT "k will be used.", + log_warning(gc, ergo)("NewSize (%zuk) is greater than the MaxNewSize (%zuk). " + "A new max generation size of %zuk will be used.", NewSize/K, MaxNewSize/K, NewSize/K); } FLAG_SET_ERGO(MaxNewSize, NewSize); diff --git a/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp b/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp index 0442cac470c52..ad1e3a769966b 100644 --- a/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp +++ b/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp @@ -83,7 +83,7 @@ JVMFlag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) { // Default value of G1HeapRegionSize=0 means will be set ergonomically. if (FLAG_IS_CMDLINE(G1HeapRegionSize) && (value < G1HeapRegionBounds::min_size())) { JVMFlag::printError(verbose, - "G1HeapRegionSize (" SIZE_FORMAT ") must be " + "G1HeapRegionSize (%zu) must be " "greater than or equal to ergonomic heap region minimum size\n", value); return JVMFlag::VIOLATES_CONSTRAINT; @@ -171,7 +171,7 @@ JVMFlag::Error NewSizeConstraintFuncG1(size_t value, bool verbose) { // So maximum of NewSize should be 'max_juint * 1M' if (UseG1GC && (value > (max_juint * 1 * M))) { JVMFlag::printError(verbose, - "NewSize (" SIZE_FORMAT ") must be less than ergonomic maximum value\n", + "NewSize (%zu) must be less than ergonomic maximum value\n", value); return JVMFlag::VIOLATES_CONSTRAINT; } From 788f04990aaf284da2067972bd62cc02d50166b6 Mon Sep 17 00:00:00 2001 From: Theo Weidmann Date: Thu, 16 Jan 2025 14:38:02 +0000 Subject: [PATCH 25/47] 8346607: IGV: Support drag-and-drop for opening graph files Reviewed-by: rcastanedalo, chagedorn, dfenacci, thartmann --- .../igv/coordinator/OutlineTopComponent.java | 113 ++++++++++++++++-- .../igv/view/PlaceholderTopComponent.java | 47 ++++++++ 2 files changed, 150 insertions(+), 10 deletions(-) create mode 100644 src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/PlaceholderTopComponent.java diff --git a/src/utils/IdealGraphVisualizer/Coordinator/src/main/java/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java b/src/utils/IdealGraphVisualizer/Coordinator/src/main/java/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java index 9508a5dfbca52..f000f279d5f2e 100644 --- a/src/utils/IdealGraphVisualizer/Coordinator/src/main/java/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java +++ b/src/utils/IdealGraphVisualizer/Coordinator/src/main/java/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -37,8 +37,18 @@ import com.sun.hotspot.igv.settings.Settings; import com.sun.hotspot.igv.util.LookupHistory; import com.sun.hotspot.igv.view.EditorTopComponent; +import com.sun.hotspot.igv.view.PlaceholderTopComponent; import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.HeadlessException; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; import java.io.*; import java.nio.channels.FileChannel; import java.nio.file.*; @@ -92,6 +102,9 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM private GraphNode[] selectedGraphs = new GraphNode[0]; private Path documentPath = null; + private final DropTargetListener fileDropListener = new FileDropListener(); + private final PlaceholderTopComponent editorPlaceholder = new PlaceholderTopComponent(fileDropListener); + private OutlineTopComponent() { initComponents(); @@ -100,6 +113,17 @@ private OutlineTopComponent() { initListView(); initToolbar(); server.startServer(); + + showEditorPlaceholder(); + + WindowManager.getDefault().invokeWhenUIReady(() -> { + new DropTarget(WindowManager.getDefault().getMainWindow(), fileDropListener); + }); + } + + private void showEditorPlaceholder() { + editorPlaceholder.open(); + editorPlaceholder.requestActive(); } public static GraphDocument getDocument() { @@ -236,6 +260,11 @@ private void documentChanged() { saveAction.setEnabled(enableButton); saveAsAction.setEnabled(enableButton); removeAllAction.setEnabled(enableButton); + if (document.getElements().isEmpty()) { + showEditorPlaceholder(); + } else { + editorPlaceholder.close(); + } } @Override @@ -372,15 +401,20 @@ public void openFile() { JFileChooser fc = new JFileChooser(Settings.get().get(Settings.DIRECTORY, Settings.DIRECTORY_DEFAULT)); fc.setFileFilter(graphFileFilter); if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { - clearWorkspace(); - String path = fc.getSelectedFile().getAbsolutePath(); - Settings.get().put(Settings.DIRECTORY, path); - setDocumentPath(path); - try { - loadGraphDocument(path, true); - } catch (IOException e) { - throw new RuntimeException(e); - } + handleOpen(fc.getSelectedFile()); + } + } + + private void handleOpen(File file) { + clearWorkspace(); + editorPlaceholder.close(); + String path = file.getAbsolutePath(); + Settings.get().put(Settings.DIRECTORY, path); + setDocumentPath(path); + try { + loadGraphDocument(path, true); + } catch (IOException e) { + throw new RuntimeException(e); } } @@ -590,6 +624,65 @@ public void setState(String state) { handle.finish(); } + private class FileDropListener implements DropTargetListener { + @Override + public void dragEnter(DropTargetDragEvent dtde) { + if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { + dtde.acceptDrag(DnDConstants.ACTION_COPY); + } else { + dtde.rejectDrag(); + } + } + + @Override + public void dragOver(DropTargetDragEvent dtde) { + dragEnter(dtde); + } + + @Override + public void dropActionChanged(DropTargetDragEvent dtde) {} + + @Override + public void dragExit(DropTargetEvent dte) {} + + @Override + public void drop(DropTargetDropEvent dtde) { + try { + if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + + List droppedFiles = (List) dtde.getTransferable() + .getTransferData(DataFlavor.javaFileListFlavor); + + if (droppedFiles.isEmpty()) return; + if (droppedFiles.size() > 1) { + JOptionPane.showMessageDialog(null, + "Please only drag and drop one file as only one file can be open at a time.", + "Multiple Files Dropped", JOptionPane.WARNING_MESSAGE); + return; + } + + File file = droppedFiles.get(0); + + if (file.getName().endsWith(".xml") || file.getName().endsWith(".igv")) { + handleOpen(file); + } else { + JOptionPane.showMessageDialog(null, + "Unsupported file type: " + file.getName(), + "Unsupported File", JOptionPane.WARNING_MESSAGE); + } + + dtde.dropComplete(true); + } else { + dtde.rejectDrop(); + } + } catch (HeadlessException | UnsupportedFlavorException | IOException ex) { + ex.printStackTrace(); + dtde.dropComplete(false); + } + } + } + /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is diff --git a/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/PlaceholderTopComponent.java b/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/PlaceholderTopComponent.java new file mode 100644 index 0000000000000..285ecbceece93 --- /dev/null +++ b/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/PlaceholderTopComponent.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.view; + +import java.awt.BorderLayout; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetListener; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import org.openide.windows.TopComponent; + +/** + * This TopComponent is displayed in the editor location if no graphs have been loaded + * and allows the user to easily drag and drop graph files to be opened. + */ +public class PlaceholderTopComponent extends TopComponent { + public PlaceholderTopComponent(DropTargetListener fileDropListener) { + setLayout(new BorderLayout()); + JPanel container = new JPanel(new BorderLayout()); + container.add(new JLabel("Drop file here to open", SwingConstants.CENTER), BorderLayout.CENTER); + container.setDropTarget(new DropTarget(container, fileDropListener)); + add(container, BorderLayout.CENTER); + setName("Welcome"); + } +} From e7795ccdd9066804a8c93e8af0aa45e49bd20846 Mon Sep 17 00:00:00 2001 From: SendaoYan Date: Thu, 16 Jan 2025 15:40:21 +0000 Subject: [PATCH 26/47] 8347347: Build fails undefined symbol: __asan_init by clang17 Reviewed-by: erikj, jwaters --- make/autoconf/jdk-options.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index c09f581688ca0..b90f04a89e255 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -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 @@ -446,6 +446,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER], fi if test "x$TOOLCHAIN_TYPE" = "xclang"; then ASAN_CFLAGS="$ASAN_CFLAGS -fsanitize-address-use-after-return=never" + ASAN_LDFLAGS="$ASAN_LDFLAGS -shared-libasan" fi elif test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then # -Oy- is equivalent to -fno-omit-frame-pointer in GCC/Clang. From d218b54086762d920bba0fc2ced47ea9148a3787 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Thu, 16 Jan 2025 16:09:04 +0000 Subject: [PATCH 27/47] 8347609: Replace SIZE_FORMAT in os/os_cpu/cpu directories Reviewed-by: matsaave, dholmes --- .../cpu/aarch64/gc/z/zAddress_aarch64.cpp | 4 +- src/hotspot/cpu/arm/arm.ad | 6 +-- src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp | 4 +- src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp | 4 +- .../cpu/s390/macroAssembler_s390.inline.hpp | 4 +- .../cpu/x86/gc/z/zAddress_x86.inline.hpp | 4 +- src/hotspot/os/aix/loadlib_aix.cpp | 6 +-- src/hotspot/os/aix/os_aix.cpp | 37 ++++++++------- .../bsd/gc/z/zPhysicalMemoryBacking_bsd.cpp | 6 +-- src/hotspot/os/bsd/os_bsd.cpp | 6 +-- .../gc/z/zPhysicalMemoryBacking_linux.cpp | 22 ++++----- src/hotspot/os/linux/hugepages.cpp | 6 +-- src/hotspot/os/linux/os_linux.cpp | 45 +++++++++---------- src/hotspot/os/posix/os_posix.cpp | 2 +- src/hotspot/os/posix/perfMemory_posix.cpp | 6 +-- .../os/windows/gc/z/zMapper_windows.cpp | 6 +-- .../gc/z/zPhysicalMemoryBacking_windows.cpp | 16 +++---- src/hotspot/os/windows/os_windows.cpp | 30 ++++++------- src/hotspot/os/windows/perfMemory_windows.cpp | 6 +-- 19 files changed, 108 insertions(+), 112 deletions(-) diff --git a/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp index c656736aa6473..2a661ab9cbbfb 100644 --- a/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -85,7 +85,7 @@ static size_t probe_valid_max_address_bit() { munmap(result_addr, page_size); } } - log_info_p(gc, init)("Probing address space for the highest valid bit: " SIZE_FORMAT, max_address_bit); + log_info_p(gc, init)("Probing address space for the highest valid bit: %zu", max_address_bit); return MAX2(max_address_bit, MINIMUM_MAX_ADDRESS_BIT); #else // LINUX return DEFAULT_MAX_ADDRESS_BIT; diff --git a/src/hotspot/cpu/arm/arm.ad b/src/hotspot/cpu/arm/arm.ad index a3db5c0619ced..617745dee20ab 100644 --- a/src/hotspot/cpu/arm/arm.ad +++ b/src/hotspot/cpu/arm/arm.ad @@ -1,5 +1,5 @@ // -// Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2008, 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 @@ -283,7 +283,7 @@ void MachPrologNode::format( PhaseRegAlloc *ra_, outputStream *st ) const { } st->print_cr("PUSH R_FP|R_LR_LR"); st->print("\t"); if (framesize != 0) { - st->print ("SUB R_SP, R_SP, " SIZE_FORMAT,framesize); + st->print ("SUB R_SP, R_SP, %zu", framesize); } if (C->stub_function() == nullptr && BarrierSet::barrier_set()->barrier_set_nmethod() != nullptr) { @@ -362,7 +362,7 @@ void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream *st ) const { framesize -= 2*wordSize; if (framesize != 0) { - st->print("ADD R_SP, R_SP, " SIZE_FORMAT "\n\t",framesize); + st->print("ADD R_SP, R_SP, %zu\n\t",framesize); } st->print("POP R_FP|R_LR_LR"); diff --git a/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp b/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp index 5891d50f715ee..e495606d399c8 100644 --- a/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -82,7 +82,7 @@ static size_t probe_valid_max_address_bit() { munmap(result_addr, page_size); } } - log_info_p(gc, init)("Probing address space for the highest valid bit: " SIZE_FORMAT, max_address_bit); + log_info_p(gc, init)("Probing address space for the highest valid bit: %zu", max_address_bit); return MAX2(max_address_bit, MINIMUM_MAX_ADDRESS_BIT); #else // LINUX return DEFAULT_MAX_ADDRESS_BIT; diff --git a/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp b/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp index 715f0d8aff7cb..9e91ea0ce2bdb 100644 --- a/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -84,7 +84,7 @@ static size_t probe_valid_max_address_bit() { munmap(result_addr, page_size); } } - log_info_p(gc, init)("Probing address space for the highest valid bit: " SIZE_FORMAT, max_address_bit); + log_info_p(gc, init)("Probing address space for the highest valid bit: %zu", max_address_bit); return MAX2(max_address_bit, MINIMUM_MAX_ADDRESS_BIT); #else // LINUX return DEFAULT_MAX_ADDRESS_BIT; diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.inline.hpp b/src/hotspot/cpu/s390/macroAssembler_s390.inline.hpp index d81562d9e9af0..72724fb66d110 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.inline.hpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -75,7 +75,7 @@ inline void MacroAssembler::load_address(Register d, const Address &a) { } else if (Displacement::is_validDisp(a.disp())) { z_lay(d, a.disp(), a.indexOrR0(), a.baseOrR0()); } else { - guarantee(false, "displacement = " SIZE_FORMAT_X ", out of range for LA/LAY", a.disp()); + guarantee(false, "displacement = 0x%zx, out of range for LA/LAY", a.disp()); } } diff --git a/src/hotspot/cpu/x86/gc/z/zAddress_x86.inline.hpp b/src/hotspot/cpu/x86/gc/z/zAddress_x86.inline.hpp index e0be06395946a..d0816aee74f76 100644 --- a/src/hotspot/cpu/x86/gc/z/zAddress_x86.inline.hpp +++ b/src/hotspot/cpu/x86/gc/z/zAddress_x86.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, 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 @@ -32,7 +32,7 @@ inline uintptr_t ZPointer::remap_bits(uintptr_t colored) { inline constexpr int ZPointer::load_shift_lookup(uintptr_t value) { const size_t index = load_shift_lookup_index(value); - assert(index == 0 || is_power_of_2(index), "Incorrect load shift: " SIZE_FORMAT, index); + assert(index == 0 || is_power_of_2(index), "Incorrect load shift: %zu", index); return ZPointerLoadShiftTable[index]; } diff --git a/src/hotspot/os/aix/loadlib_aix.cpp b/src/hotspot/os/aix/loadlib_aix.cpp index bc21aef383698..2c38e1b637ca7 100644 --- a/src/hotspot/os/aix/loadlib_aix.cpp +++ b/src/hotspot/os/aix/loadlib_aix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2024 SAP SE. All rights reserved. * Copyright (c) 2022, IBM Corp. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -203,7 +203,7 @@ static bool reload_table() { } } - trcVerbose("loadquery buffer size is " SIZE_FORMAT ".", buflen); + trcVerbose("loadquery buffer size is %zu.", buflen); // Iterate over the loadquery result. For details see sys/ldr.h on AIX. ldi = (struct ld_info*) buffer; @@ -262,7 +262,7 @@ static bool reload_table() { lm->is_in_vm = true; } - trcVerbose("entry: %p " SIZE_FORMAT ", %p " SIZE_FORMAT ", %s %s %s, %d", + trcVerbose("entry: %p %zu, %p %zu, %s %s %s, %d", lm->text, lm->text_len, lm->data, lm->data_len, lm->path, lm->shortname, diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index 555c09cda49d0..ec1bf83ffcdf1 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -450,7 +450,7 @@ static void query_multipage_support() { if (p != (void*) -1) { const size_t real_pagesize = os::Aix::query_pagesize(p); if (real_pagesize != pagesize) { - log_warning(pagesize)("real page size (" SIZE_FORMAT_X ") differs.", real_pagesize); + log_warning(pagesize)("real page size (0x%zx) differs.", real_pagesize); } else { can_use = true; } @@ -632,7 +632,7 @@ static void *thread_native_entry(Thread *thread) { address low_address = thread->stack_end(); address high_address = thread->stack_base(); lt.print("Thread is alive (tid: %zu, kernel thread id: %zu" - ", stack [" PTR_FORMAT " - " PTR_FORMAT " (" SIZE_FORMAT "k using %luk pages)).", + ", stack [" PTR_FORMAT " - " PTR_FORMAT " (%zuk using %luk pages)).", os::current_thread_id(), (uintx) kernel_thread_id, p2i(low_address), p2i(high_address), (high_address - low_address) / K, os::Aix::query_pagesize(low_address) / K); } @@ -733,7 +733,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, // guard pages might not fit on the tiny stack created. int ret = pthread_attr_setstacksize(&attr, stack_size); if (ret != 0) { - log_warning(os, thread)("The %sthread stack size specified is invalid: " SIZE_FORMAT "k", + log_warning(os, thread)("The %sthread stack size specified is invalid: %zuk", (thr_type == compiler_thread) ? "compiler " : ((thr_type == java_thread) ? "" : "VM "), stack_size / K); thread->set_osthread(nullptr); @@ -769,7 +769,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, thread->name(), ret, os::errno_name(ret), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); // Log some OS information which might explain why creating the thread failed. log_warning(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads()); - log_warning(os, thread)("Checking JVM parameter MaxExpectedDataSegmentSize (currently " SIZE_FORMAT "k) might be helpful", MaxExpectedDataSegmentSize/K); + log_warning(os, thread)("Checking JVM parameter MaxExpectedDataSegmentSize (currently %zuk) might be helpful", MaxExpectedDataSegmentSize/K); LogStream st(Log(os, thread)::info()); os::Posix::print_rlimit_info(&st); os::print_memory_info(&st); @@ -840,7 +840,7 @@ bool os::create_attached_thread(JavaThread* thread) { PosixSignals::hotspot_sigmask(thread); log_info(os, thread)("Thread attached (tid: %zu, kernel thread id: %zu" - ", stack: " PTR_FORMAT " - " PTR_FORMAT " (" SIZE_FORMAT "K) ).", + ", stack: " PTR_FORMAT " - " PTR_FORMAT " (%zuK) ).", os::current_thread_id(), (uintx) kernel_thread_id, p2i(thread->stack_base()), p2i(thread->stack_end()), thread->stack_size() / K); @@ -1194,10 +1194,10 @@ void os::print_memory_info(outputStream* st) { os::Aix::meminfo_t mi; if (os::Aix::get_meminfo(&mi)) { - st->print_cr("physical total : " SIZE_FORMAT, mi.real_total); - st->print_cr("physical free : " SIZE_FORMAT, mi.real_free); - st->print_cr("swap total : " SIZE_FORMAT, mi.pgsp_total); - st->print_cr("swap free : " SIZE_FORMAT, mi.pgsp_free); + st->print_cr("physical total : %zu", mi.real_total); + st->print_cr("physical free : %zu", mi.real_free); + st->print_cr("swap total : %zu", mi.pgsp_total); + st->print_cr("swap free : %zu", mi.pgsp_free); } st->cr(); @@ -1205,10 +1205,10 @@ void os::print_memory_info(outputStream* st) { st->print_cr("Program break at VM startup: " PTR_FORMAT ".", p2i(g_brk_at_startup)); address brk_now = (address)::sbrk(0); if (brk_now != (address)-1) { - st->print_cr("Program break now : " PTR_FORMAT " (distance: " SIZE_FORMAT "k).", + st->print_cr("Program break now : " PTR_FORMAT " (distance: %zuk).", p2i(brk_now), (size_t)((brk_now - g_brk_at_startup) / K)); } - st->print_cr("MaxExpectedDataSegmentSize : " SIZE_FORMAT "k.", MaxExpectedDataSegmentSize / K); + st->print_cr("MaxExpectedDataSegmentSize : %zuk.", MaxExpectedDataSegmentSize / K); st->cr(); // Print segments allocated with os::reserve_memory. @@ -1533,7 +1533,7 @@ static char* reserve_shmated_memory (size_t bytes, char* requested_addr) { // work (see above), the system may have given us something other then 4K (LDR_CNTRL). const size_t real_pagesize = os::Aix::query_pagesize(addr); if (real_pagesize != (size_t)shmbuf.shm_pagesize) { - log_trace(os, map)("pagesize is, surprisingly, " SIZE_FORMAT, + log_trace(os, map)("pagesize is, surprisingly, %zu", real_pagesize); } @@ -1759,9 +1759,8 @@ static bool uncommit_mmaped_memory(char* addr, size_t size) { #ifdef PRODUCT static void warn_fail_commit_memory(char* addr, size_t size, bool exec, int err) { - warning("INFO: os::commit_memory(" PTR_FORMAT ", " SIZE_FORMAT - ", %d) failed; error='%s' (errno=%d)", p2i(addr), size, exec, - os::errno_name(err), err); + warning("INFO: os::commit_memory(" PTR_FORMAT ", %zu, %d) failed; error='%s' (errno=%d)", + p2i(addr), size, exec, os::errno_name(err), err); } #endif @@ -1778,10 +1777,10 @@ void os::pd_commit_memory_or_exit(char* addr, size_t size, bool exec, bool os::pd_commit_memory(char* addr, size_t size, bool exec) { assert(is_aligned_to(addr, os::vm_page_size()), - "addr " PTR_FORMAT " not aligned to vm_page_size (" SIZE_FORMAT ")", + "addr " PTR_FORMAT " not aligned to vm_page_size (%zu)", p2i(addr), os::vm_page_size()); assert(is_aligned_to(size, os::vm_page_size()), - "size " PTR_FORMAT " not aligned to vm_page_size (" SIZE_FORMAT ")", + "size " PTR_FORMAT " not aligned to vm_page_size (%zu)", size, os::vm_page_size()); vmembk_t* const vmi = vmembk_find(addr); @@ -1813,10 +1812,10 @@ void os::pd_commit_memory_or_exit(char* addr, size_t size, bool os::pd_uncommit_memory(char* addr, size_t size, bool exec) { assert(is_aligned_to(addr, os::vm_page_size()), - "addr " PTR_FORMAT " not aligned to vm_page_size (" SIZE_FORMAT ")", + "addr " PTR_FORMAT " not aligned to vm_page_size (%zu)", p2i(addr), os::vm_page_size()); assert(is_aligned_to(size, os::vm_page_size()), - "size " PTR_FORMAT " not aligned to vm_page_size (" SIZE_FORMAT ")", + "size " PTR_FORMAT " not aligned to vm_page_size (%zu)", size, os::vm_page_size()); // Dynamically do different things for mmap/shmat. diff --git a/src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.cpp b/src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.cpp index 16835c8303931..e2b142461eab1 100644 --- a/src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.cpp +++ b/src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.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 @@ -102,7 +102,7 @@ bool ZPhysicalMemoryBacking::commit_inner(zoffset offset, size_t length) const { assert(is_aligned(untype(offset), os::vm_page_size()), "Invalid offset"); assert(is_aligned(length, os::vm_page_size()), "Invalid length"); - log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", + log_trace(gc, heap)("Committing memory: %zuM-%zuM (%zuM)", untype(offset) / M, untype(to_zoffset_end(offset, length)) / M, length / M); const uintptr_t addr = _base + untype(offset); @@ -149,7 +149,7 @@ size_t ZPhysicalMemoryBacking::uncommit(zoffset offset, size_t length) const { assert(is_aligned(untype(offset), os::vm_page_size()), "Invalid offset"); assert(is_aligned(length, os::vm_page_size()), "Invalid length"); - log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", + log_trace(gc, heap)("Uncommitting memory: %zuM-%zuM (%zuM)", untype(offset) / M, untype(to_zoffset_end(offset, length)) / M, length / M); const uintptr_t start = _base + untype(offset); diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index c724bef8b99a4..9818cdf7bab72 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -745,7 +745,7 @@ bool os::create_attached_thread(JavaThread* thread) { PosixSignals::hotspot_sigmask(thread); log_info(os, thread)("Thread attached (tid: %zu, pthread id: %zu" - ", stack: " PTR_FORMAT " - " PTR_FORMAT " (" SIZE_FORMAT "K) ).", + ", stack: " PTR_FORMAT " - " PTR_FORMAT " (%zuK) ).", os::current_thread_id(), (uintx) pthread_self(), p2i(thread->stack_base()), p2i(thread->stack_end()), thread->stack_size() / K); return true; @@ -1459,7 +1459,7 @@ void os::print_memory_info(outputStream* st) { size_t size = sizeof(swap_usage); st->print("Memory:"); - st->print(" " SIZE_FORMAT "k page", os::vm_page_size()>>10); + st->print(" %zuk page", os::vm_page_size()>>10); st->print(", physical " UINT64_FORMAT "k", os::physical_memory() >> 10); @@ -1586,7 +1586,7 @@ void os::jvm_path(char *buf, jint buflen) { static void warn_fail_commit_memory(char* addr, size_t size, bool exec, int err) { - warning("INFO: os::commit_memory(" INTPTR_FORMAT ", " SIZE_FORMAT + warning("INFO: os::commit_memory(" INTPTR_FORMAT ", %zu" ", %d) failed; error='%s' (errno=%d)", (intptr_t)addr, size, exec, os::errno_name(err), err); } diff --git a/src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp b/src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp index b648876ac602c..be680f8430bec 100644 --- a/src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp +++ b/src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.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,13 +185,13 @@ ZPhysicalMemoryBacking::ZPhysicalMemoryBacking(size_t max_capacity) // Make sure the filesystem block size is compatible if (ZGranuleSize % _block_size != 0) { - ZInitialize::error("Filesystem backing the heap has incompatible block size (" SIZE_FORMAT ")", + ZInitialize::error("Filesystem backing the heap has incompatible block size (%zu)", _block_size); return; } if (is_hugetlbfs() && _block_size != ZGranuleSize) { - ZInitialize::error("%s filesystem has unexpected block size " SIZE_FORMAT " (expected " SIZE_FORMAT ")", + ZInitialize::error("%s filesystem has unexpected block size %zu (expected %zu)", ZFILESYSTEM_HUGETLBFS, _block_size, ZGranuleSize); return; } @@ -316,7 +316,7 @@ void ZPhysicalMemoryBacking::warn_available_space(size_t max_capacity) const { return; } - log_info_p(gc, init)("Available space on backing filesystem: " SIZE_FORMAT "M", _available / M); + log_info_p(gc, init)("Available space on backing filesystem: %zuM", _available / M); // Warn if the filesystem doesn't currently have enough space available to hold // the max heap size. The max heap size will be capped if we later hit this limit @@ -324,9 +324,9 @@ void ZPhysicalMemoryBacking::warn_available_space(size_t max_capacity) const { if (_available < max_capacity) { log_warning_p(gc)("***** WARNING! INCORRECT SYSTEM CONFIGURATION DETECTED! *****"); log_warning_p(gc)("Not enough space available on the backing filesystem to hold the current max Java heap"); - log_warning_p(gc)("size (" SIZE_FORMAT "M). Please adjust the size of the backing filesystem accordingly " + log_warning_p(gc)("size (%zuM). Please adjust the size of the backing filesystem accordingly " "(available", max_capacity / M); - log_warning_p(gc)("space is currently " SIZE_FORMAT "M). Continuing execution with the current filesystem " + log_warning_p(gc)("space is currently %zuM). Continuing execution with the current filesystem " "size could", _available / M); log_warning_p(gc)("lead to a premature OutOfMemoryError being thrown, due to failure to commit memory."); } @@ -342,7 +342,7 @@ void ZPhysicalMemoryBacking::warn_max_map_count(size_t max_capacity) const { } size_t actual_max_map_count = 0; - const int result = fscanf(file, SIZE_FORMAT, &actual_max_map_count); + const int result = fscanf(file, "%zu", &actual_max_map_count); fclose(file); if (result != 1) { // Failed to read file, skip check @@ -359,9 +359,9 @@ void ZPhysicalMemoryBacking::warn_max_map_count(size_t max_capacity) const { if (actual_max_map_count < required_max_map_count) { log_warning_p(gc)("***** WARNING! INCORRECT SYSTEM CONFIGURATION DETECTED! *****"); log_warning_p(gc)("The system limit on number of memory mappings per process might be too low for the given"); - log_warning_p(gc)("max Java heap size (" SIZE_FORMAT "M). Please adjust %s to allow for at", + log_warning_p(gc)("max Java heap size (%zuM). Please adjust %s to allow for at", max_capacity / M, filename); - log_warning_p(gc)("least " SIZE_FORMAT " mappings (current limit is " SIZE_FORMAT "). Continuing execution " + log_warning_p(gc)("least %zu mappings (current limit is %zu). Continuing execution " "with the current", required_max_map_count, actual_max_map_count); log_warning_p(gc)("limit could lead to a premature OutOfMemoryError being thrown, due to failure to map memory."); } @@ -598,7 +598,7 @@ ZErrno ZPhysicalMemoryBacking::fallocate(bool punch_hole, zoffset offset, size_t } bool ZPhysicalMemoryBacking::commit_inner(zoffset offset, size_t length) const { - log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", + log_trace(gc, heap)("Committing memory: %zuM-%zuM (%zuM)", untype(offset) / M, untype(to_zoffset_end(offset, length)) / M, length / M); retry: @@ -698,7 +698,7 @@ size_t ZPhysicalMemoryBacking::commit(zoffset offset, size_t length) const { } size_t ZPhysicalMemoryBacking::uncommit(zoffset offset, size_t length) const { - log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", + log_trace(gc, heap)("Uncommitting memory: %zuM-%zuM (%zuM)", untype(offset) / M, untype(to_zoffset_end(offset, length)) / M, length / M); const ZErrno err = fallocate(true /* punch_hole */, offset, length); diff --git a/src/hotspot/os/linux/hugepages.cpp b/src/hotspot/os/linux/hugepages.cpp index c04ff7a4ca0e3..58c28e496838f 100644 --- a/src/hotspot/os/linux/hugepages.cpp +++ b/src/hotspot/os/linux/hugepages.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -95,7 +95,7 @@ static bool read_number_file(const char* file, size_t* out) { bool rc = false; if (f != nullptr) { uint64_t i = 0; - if (::fscanf(f, SIZE_FORMAT, out) == 1) { + if (::fscanf(f, "%zu", out) == 1) { rc = true; } ::fclose(f); @@ -155,7 +155,7 @@ void ExplicitHugePageSupport::scan_os() { // that only exposes /proc/meminfo but not /sys/kernel/mm/hugepages. In that case, we are not // sure about the state of hugepage support by the kernel, so we won't use explicit hugepages. if (!_pagesizes.contains(_default_hugepage_size)) { - log_info(pagesize)("Unexpected configuration: default pagesize (" SIZE_FORMAT ") " + log_info(pagesize)("Unexpected configuration: default pagesize (%zu) " "has no associated directory in /sys/kernel/mm/hugepages..", _default_hugepage_size); _inconsistent = true; } diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 67c29913c86f8..1d01549fae597 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -925,7 +925,7 @@ static size_t get_static_tls_area_size(const pthread_attr_t *attr) { } } - log_info(os, thread)("Stack size adjustment for TLS is " SIZE_FORMAT, + log_info(os, thread)("Stack size adjustment for TLS is %zu", tls_size); return tls_size; } @@ -1032,7 +1032,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, // pthread_attr_setstacksize() function can fail // if the stack size exceeds a system-imposed limit. assert_status(status == EINVAL, status, "pthread_attr_setstacksize"); - log_warning(os, thread)("The %sthread stack size specified is invalid: " SIZE_FORMAT "k", + log_warning(os, thread)("The %sthread stack size specified is invalid: %zuk", (thr_type == compiler_thread) ? "compiler " : ((thr_type == java_thread) ? "" : "VM "), stack_size / K); thread->set_osthread(nullptr); @@ -1171,7 +1171,7 @@ bool os::create_attached_thread(JavaThread* thread) { PosixSignals::hotspot_sigmask(thread); log_info(os, thread)("Thread attached (tid: %zu, pthread id: %zu" - ", stack: " PTR_FORMAT " - " PTR_FORMAT " (" SIZE_FORMAT "K) ).", + ", stack: " PTR_FORMAT " - " PTR_FORMAT " (%zuK) ).", os::current_thread_id(), (uintx) pthread_self(), p2i(thread->stack_base()), p2i(thread->stack_end()), thread->stack_size() / K); @@ -1457,8 +1457,8 @@ void os::Linux::capture_initial_stack(size_t max_size) { bool primordial = uintptr_t(&rlim) > uintptr_t(_initial_thread_stack_bottom) && uintptr_t(&rlim) < stack_top; - log_info(os, thread)("Capturing initial stack in %s thread: req. size: " SIZE_FORMAT "K, actual size: " - SIZE_FORMAT "K, top=" INTPTR_FORMAT ", bottom=" INTPTR_FORMAT, + log_info(os, thread)("Capturing initial stack in %s thread: req. size: %zuK, actual size: " + "%zuK, top=" INTPTR_FORMAT ", bottom=" INTPTR_FORMAT, primordial ? "primordial" : "user", max_size / K, _initial_thread_stack_size / K, stack_top, intptr_t(_initial_thread_stack_bottom)); } @@ -2390,7 +2390,7 @@ void os::Linux::print_process_memory_info(outputStream* st) { // If legacy mallinfo(), we can still print the values if we are sure they cannot have wrapped. might_have_wrapped = might_have_wrapped && (info.vmsize * K) > UINT_MAX; #endif - st->print_cr("C-Heap outstanding allocations: " SIZE_FORMAT "K, retained: " SIZE_FORMAT "K%s", + st->print_cr("C-Heap outstanding allocations: %zuK, retained: %zuK%s", total_allocated / K, free_retained / K, might_have_wrapped ? " (may have wrapped)" : ""); // Tunables @@ -2518,7 +2518,7 @@ void os::Linux::print_steal_info(outputStream* st) { void os::print_memory_info(outputStream* st) { st->print("Memory:"); - st->print(" " SIZE_FORMAT "k page", os::vm_page_size()>>10); + st->print(" %zuk page", os::vm_page_size()>>10); // values in struct sysinfo are "unsigned long" struct sysinfo si; @@ -2883,17 +2883,15 @@ static bool recoverable_mmap_error(int err) { static void warn_fail_commit_memory(char* addr, size_t size, bool exec, int err) { - warning("INFO: os::commit_memory(" PTR_FORMAT ", " SIZE_FORMAT - ", %d) failed; error='%s' (errno=%d)", p2i(addr), size, exec, - os::strerror(err), err); + warning("INFO: os::commit_memory(" PTR_FORMAT ", %zu, %d) failed; error='%s' (errno=%d)", + p2i(addr), size, exec, os::strerror(err), err); } static void warn_fail_commit_memory(char* addr, size_t size, size_t alignment_hint, bool exec, int err) { - warning("INFO: os::commit_memory(" PTR_FORMAT ", " SIZE_FORMAT - ", " SIZE_FORMAT ", %d) failed; error='%s' (errno=%d)", p2i(addr), size, - alignment_hint, exec, os::strerror(err), err); + warning("INFO: os::commit_memory(" PTR_FORMAT ", %zu, %zu, %d) failed; error='%s' (errno=%d)", + p2i(addr), size, alignment_hint, exec, os::strerror(err), err); } // NOTE: Linux kernel does not really reserve the pages for us. @@ -3043,7 +3041,7 @@ size_t os::pd_pretouch_memory(void* first, void* last, size_t page_size) { // OS will initially always use small pages. return os::vm_page_size(); } else if (err != 0) { - log_info(gc, os)("::madvise(" PTR_FORMAT ", " SIZE_FORMAT ", %d) failed; " + log_info(gc, os)("::madvise(" PTR_FORMAT ", %zu, %d) failed; " "error='%s' (errno=%d)", p2i(first), len, MADV_POPULATE_WRITE, os::strerror(err), err); } @@ -3760,7 +3758,7 @@ static bool hugetlbfs_sanity_check(size_t page_size) { munmap(p, page_size); return true; } else { - log_info(pagesize)("Large page size (" SIZE_FORMAT "%s) failed sanity check, " + log_info(pagesize)("Large page size (%zu%s) failed sanity check, " "checking if smaller large page sizes are usable", byte_size_in_exact_unit(page_size), exact_unit_for_byte_size(page_size)); @@ -3772,7 +3770,7 @@ static bool hugetlbfs_sanity_check(size_t page_size) { if (p != MAP_FAILED) { // Mapping succeeded, sanity check passed. munmap(p, page_size_); - log_info(pagesize)("Large page size (" SIZE_FORMAT "%s) passed sanity check", + log_info(pagesize)("Large page size (%zu%s) passed sanity check", byte_size_in_exact_unit(page_size_), exact_unit_for_byte_size(page_size_)); return true; @@ -3971,22 +3969,22 @@ void os::Linux::large_page_init() { LargePageSizeInBytes == 0 || LargePageSizeInBytes == default_large_page_size) { large_page_size = default_large_page_size; - log_info(pagesize)("Using the default large page size: " SIZE_FORMAT "%s", + log_info(pagesize)("Using the default large page size: %zu%s", byte_size_in_exact_unit(large_page_size), exact_unit_for_byte_size(large_page_size)); } else { if (all_large_pages.contains(LargePageSizeInBytes)) { large_page_size = LargePageSizeInBytes; - log_info(pagesize)("Overriding default large page size (" SIZE_FORMAT "%s) " - "using LargePageSizeInBytes: " SIZE_FORMAT "%s", + log_info(pagesize)("Overriding default large page size (%zu%s) " + "using LargePageSizeInBytes: %zu%s", byte_size_in_exact_unit(default_large_page_size), exact_unit_for_byte_size(default_large_page_size), byte_size_in_exact_unit(large_page_size), exact_unit_for_byte_size(large_page_size)); } else { large_page_size = default_large_page_size; - log_info(pagesize)("LargePageSizeInBytes is not a valid large page size (" SIZE_FORMAT "%s) " - "using the default large page size: " SIZE_FORMAT "%s", + log_info(pagesize)("LargePageSizeInBytes is not a valid large page size (%zu%s) " + "using the default large page size: %zu%s", byte_size_in_exact_unit(LargePageSizeInBytes), exact_unit_for_byte_size(LargePageSizeInBytes), byte_size_in_exact_unit(large_page_size), @@ -4031,7 +4029,7 @@ static void log_on_commit_special_failure(char* req_addr, size_t bytes, assert(error == ENOMEM, "Only expect to fail if no memory is available"); log_info(pagesize)("Failed to reserve and commit memory with given page size. req_addr: " PTR_FORMAT - " size: " SIZE_FORMAT "%s, page size: " SIZE_FORMAT "%s, (errno = %d)", + " size: %zu%s, page size: %zu%s, (errno = %d)", p2i(req_addr), byte_size_in_exact_unit(bytes), exact_unit_for_byte_size(bytes), byte_size_in_exact_unit(page_size), exact_unit_for_byte_size(page_size), error); } @@ -4060,8 +4058,7 @@ static bool commit_memory_special(size_t bytes, return false; } - log_debug(pagesize)("Commit special mapping: " PTR_FORMAT ", size=" SIZE_FORMAT "%s, page size=" - SIZE_FORMAT "%s", + log_debug(pagesize)("Commit special mapping: " PTR_FORMAT ", size=%zu%s, page size=%zu%s", p2i(addr), byte_size_in_exact_unit(bytes), exact_unit_for_byte_size(bytes), byte_size_in_exact_unit(page_size), diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 61214a4296998..6f756fbf64831 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -972,7 +972,7 @@ char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_a // Work around glibc stack guard issue, see os::create_thread() in os_linux.cpp. LINUX_ONLY(if (os::Linux::adjustStackSizeForGuardPages()) stack_size -= guard_size;) pthread_attr_getdetachstate(attr, &detachstate); - jio_snprintf(buf, buflen, "stacksize: " SIZE_FORMAT "k, guardsize: " SIZE_FORMAT "k, %s", + jio_snprintf(buf, buflen, "stacksize: %zuk, guardsize: %zuk, %s", stack_size / K, guard_size / K, (detachstate == PTHREAD_CREATE_DETACHED ? "detached" : "joinable")); return buf; diff --git a/src/hotspot/os/posix/perfMemory_posix.cpp b/src/hotspot/os/posix/perfMemory_posix.cpp index 5fbd5e76c5aca..fdeb0b990d625 100644 --- a/src/hotspot/os/posix/perfMemory_posix.cpp +++ b/src/hotspot/os/posix/perfMemory_posix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1095,7 +1095,7 @@ static void unmap_shared(char* addr, size_t bytes) { res = ::munmap(addr, bytes); } if (res != 0) { - log_info(os)("os::release_memory failed (" PTR_FORMAT ", " SIZE_FORMAT ")", p2i(addr), bytes); + log_info(os)("os::release_memory failed (" PTR_FORMAT ", %zu)", p2i(addr), bytes); } } @@ -1227,7 +1227,7 @@ static void mmap_attach_shared(int vmid, char** addr, size_t* sizep, TRAPS) { *addr = mapAddress; *sizep = size; - log_debug(perf, memops)("mapped " SIZE_FORMAT " bytes for vmid %d at " + log_debug(perf, memops)("mapped %zu bytes for vmid %d at " INTPTR_FORMAT, size, vmid, p2i((void*)mapAddress)); } diff --git a/src/hotspot/os/windows/gc/z/zMapper_windows.cpp b/src/hotspot/os/windows/gc/z/zMapper_windows.cpp index b2923a300e4bc..c716368a7957c 100644 --- a/src/hotspot/os/windows/gc/z/zMapper_windows.cpp +++ b/src/hotspot/os/windows/gc/z/zMapper_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, 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 @@ -57,7 +57,7 @@ // they will be split before being used. #define fatal_error(msg, addr, size) \ - fatal(msg ": " PTR_FORMAT " " SIZE_FORMAT "M (%d)", \ + fatal(msg ": " PTR_FORMAT " %zuM (%d)", \ (addr), (size) / M, GetLastError()) zaddress_unsafe ZMapper::reserve(zaddress_unsafe addr, size_t size) { @@ -251,7 +251,7 @@ void ZMapper::unreserve_for_shared_awe(zaddress_unsafe addr, size_t size) { ); if (!res) { - fatal("Failed to unreserve memory: " PTR_FORMAT " " SIZE_FORMAT "M (%d)", + fatal("Failed to unreserve memory: " PTR_FORMAT " %zuM (%d)", untype(addr), size / M, GetLastError()); } } diff --git a/src/hotspot/os/windows/gc/z/zPhysicalMemoryBacking_windows.cpp b/src/hotspot/os/windows/gc/z/zPhysicalMemoryBacking_windows.cpp index 0a66f04d31c30..70cdc6e6e223c 100644 --- a/src/hotspot/os/windows/gc/z/zPhysicalMemoryBacking_windows.cpp +++ b/src/hotspot/os/windows/gc/z/zPhysicalMemoryBacking_windows.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 @@ -157,10 +157,10 @@ class ZPhysicalMemoryBackingLargePages : public ZPhysicalMemoryBackingImpl { size_t npages_res = npages; const bool res = AllocateUserPhysicalPages(ZAWESection, &npages_res, &_page_array[index]); if (!res) { - fatal("Failed to allocate physical memory " SIZE_FORMAT "M @ " PTR_FORMAT " (%d)", + fatal("Failed to allocate physical memory %zuM @ " PTR_FORMAT " (%d)", size / M, untype(offset), GetLastError()); } else { - log_debug(gc)("Allocated physical memory: " SIZE_FORMAT "M @ " PTR_FORMAT, size / M, untype(offset)); + log_debug(gc)("Allocated physical memory: %zuM @ " PTR_FORMAT, size / M, untype(offset)); } // AllocateUserPhysicalPages might not be able to allocate the requested amount of memory. @@ -175,7 +175,7 @@ class ZPhysicalMemoryBackingLargePages : public ZPhysicalMemoryBackingImpl { size_t npages_res = npages; const bool res = FreeUserPhysicalPages(ZAWESection, &npages_res, &_page_array[index]); if (!res) { - fatal("Failed to uncommit physical memory " SIZE_FORMAT "M @ " PTR_FORMAT " (%d)", + fatal("Failed to uncommit physical memory %zuM @ " PTR_FORMAT " (%d)", size, untype(offset), GetLastError()); } @@ -188,7 +188,7 @@ class ZPhysicalMemoryBackingLargePages : public ZPhysicalMemoryBackingImpl { const bool res = MapUserPhysicalPages((char*)untype(addr), npages, &_page_array[index]); if (!res) { - fatal("Failed to map view " PTR_FORMAT " " SIZE_FORMAT "M @ " PTR_FORMAT " (%d)", + fatal("Failed to map view " PTR_FORMAT " %zuM @ " PTR_FORMAT " (%d)", untype(addr), size / M, untype(offset), GetLastError()); } } @@ -198,7 +198,7 @@ class ZPhysicalMemoryBackingLargePages : public ZPhysicalMemoryBackingImpl { const bool res = MapUserPhysicalPages((char*)untype(addr), npages, nullptr); if (!res) { - fatal("Failed to unmap view " PTR_FORMAT " " SIZE_FORMAT "M (%d)", + fatal("Failed to unmap view " PTR_FORMAT " %zuM (%d)", addr, size / M, GetLastError()); } } @@ -224,14 +224,14 @@ void ZPhysicalMemoryBacking::warn_commit_limits(size_t max_capacity) const { } size_t ZPhysicalMemoryBacking::commit(zoffset offset, size_t length) { - log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", + log_trace(gc, heap)("Committing memory: %zuM-%zuM (%zuM)", untype(offset) / M, untype(to_zoffset_end(offset, length)) / M, length / M); return _impl->commit(offset, length); } size_t ZPhysicalMemoryBacking::uncommit(zoffset offset, size_t length) { - log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", + log_trace(gc, heap)("Uncommitting memory: %zuM-%zuM (%zuM)", untype(offset) / M, untype(to_zoffset_end(offset, length)) / M, length / M); return _impl->uncommit(offset, length); diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 51bc015442ce0..130356dbc7fe1 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -198,12 +198,12 @@ struct PreserveLastError { static LPVOID virtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) { LPVOID result = ::VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect); if (result != nullptr) { - log_trace(os)("VirtualAlloc(" PTR_FORMAT ", " SIZE_FORMAT ", %x, %x) returned " PTR_FORMAT "%s.", + log_trace(os)("VirtualAlloc(" PTR_FORMAT ", %zu, %x, %x) returned " PTR_FORMAT "%s.", p2i(lpAddress), dwSize, flAllocationType, flProtect, p2i(result), ((lpAddress != nullptr && result != lpAddress) ? " " : "")); } else { PreserveLastError ple; - log_info(os)("VirtualAlloc(" PTR_FORMAT ", " SIZE_FORMAT ", %x, %x) failed (%u).", + log_info(os)("VirtualAlloc(" PTR_FORMAT ", %zu, %x, %x) failed (%u).", p2i(lpAddress), dwSize, flAllocationType, flProtect, ple.v); } return result; @@ -213,11 +213,11 @@ static LPVOID virtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationTy static BOOL virtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType) { BOOL result = ::VirtualFree(lpAddress, dwSize, dwFreeType); if (result != FALSE) { - log_trace(os)("VirtualFree(" PTR_FORMAT ", " SIZE_FORMAT ", %x) succeeded", + log_trace(os)("VirtualFree(" PTR_FORMAT ", %zu, %x) succeeded", p2i(lpAddress), dwSize, dwFreeType); } else { PreserveLastError ple; - log_info(os)("VirtualFree(" PTR_FORMAT ", " SIZE_FORMAT ", %x) failed (%u).", + log_info(os)("VirtualFree(" PTR_FORMAT ", %zu, %x) failed (%u).", p2i(lpAddress), dwSize, dwFreeType, ple.v); } return result; @@ -228,12 +228,12 @@ static LPVOID virtualAllocExNuma(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSiz DWORD flProtect, DWORD nndPreferred) { LPVOID result = ::VirtualAllocExNuma(hProcess, lpAddress, dwSize, flAllocationType, flProtect, nndPreferred); if (result != nullptr) { - log_trace(os)("VirtualAllocExNuma(" PTR_FORMAT ", " SIZE_FORMAT ", %x, %x, %x) returned " PTR_FORMAT "%s.", + log_trace(os)("VirtualAllocExNuma(" PTR_FORMAT ", %zu, %x, %x, %x) returned " PTR_FORMAT "%s.", p2i(lpAddress), dwSize, flAllocationType, flProtect, nndPreferred, p2i(result), ((lpAddress != nullptr && result != lpAddress) ? " " : "")); } else { PreserveLastError ple; - log_info(os)("VirtualAllocExNuma(" PTR_FORMAT ", " SIZE_FORMAT ", %x, %x, %x) failed (%u).", + log_info(os)("VirtualAllocExNuma(" PTR_FORMAT ", %zu, %x, %x, %x) failed (%u).", p2i(lpAddress), dwSize, flAllocationType, flProtect, nndPreferred, ple.v); } return result; @@ -245,12 +245,12 @@ static LPVOID mapViewOfFileEx(HANDLE hFileMappingObject, DWORD dwDesiredAccess, LPVOID result = ::MapViewOfFileEx(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap, lpBaseAddress); if (result != nullptr) { - log_trace(os)("MapViewOfFileEx(" PTR_FORMAT ", " SIZE_FORMAT ") returned " PTR_FORMAT "%s.", + log_trace(os)("MapViewOfFileEx(" PTR_FORMAT ", %zu) returned " PTR_FORMAT "%s.", p2i(lpBaseAddress), dwNumberOfBytesToMap, p2i(result), ((lpBaseAddress != nullptr && result != lpBaseAddress) ? " " : "")); } else { PreserveLastError ple; - log_info(os)("MapViewOfFileEx(" PTR_FORMAT ", " SIZE_FORMAT ") failed (%u).", + log_info(os)("MapViewOfFileEx(" PTR_FORMAT ", %zu) failed (%u).", p2i(lpBaseAddress), dwNumberOfBytesToMap, ple.v); } return result; @@ -544,7 +544,7 @@ static unsigned thread_native_entry(void* t) { res = 20115; // java thread } - log_info(os, thread)("Thread is alive (tid: %zu, stacksize: " SIZE_FORMAT "k).", os::current_thread_id(), thread->stack_size() / K); + log_info(os, thread)("Thread is alive (tid: %zu, stacksize: %zuk).", os::current_thread_id(), thread->stack_size() / K); #ifdef USE_VECTORED_EXCEPTION_HANDLING // Any exception is caught by the Vectored Exception Handler, so VM can @@ -630,7 +630,7 @@ bool os::create_attached_thread(JavaThread* thread) { thread->set_osthread(osthread); log_info(os, thread)("Thread attached (tid: %zu, stack: " - PTR_FORMAT " - " PTR_FORMAT " (" SIZE_FORMAT "K) ).", + PTR_FORMAT " - " PTR_FORMAT " (%zuK) ).", os::current_thread_id(), p2i(thread->stack_base()), p2i(thread->stack_end()), thread->stack_size() / K); @@ -663,7 +663,7 @@ static char* describe_beginthreadex_attributes(char* buf, size_t buflen, if (stacksize == 0) { ss.print("stacksize: default, "); } else { - ss.print("stacksize: " SIZE_FORMAT "k, ", stacksize / K); + ss.print("stacksize: %zuk, ", stacksize / K); } ss.print("flags: "); #define PRINT_FLAG(f) if (initflag & f) ss.print( #f " "); @@ -2083,7 +2083,7 @@ void os::get_summary_cpu_info(char* buf, size_t buflen) { void os::print_memory_info(outputStream* st) { st->print("Memory:"); - st->print(" " SIZE_FORMAT "k page", os::vm_page_size()>>10); + st->print(" %zuk page", os::vm_page_size()>>10); // Use GlobalMemoryStatusEx() because GlobalMemoryStatus() may return incorrect // value if total memory is larger than 4GB @@ -3433,7 +3433,7 @@ static char* find_aligned_address(size_t size, size_t alignment) { } static char* reserve_large_pages_aligned(size_t size, size_t alignment, bool exec) { - log_debug(pagesize)("Reserving large pages at an aligned address, alignment=" SIZE_FORMAT "%s", + log_debug(pagesize)("Reserving large pages at an aligned address, alignment=%zu%s", byte_size_in_exact_unit(alignment), exact_unit_for_byte_size(alignment)); // Will try to find a suitable address at most 20 times. The reason we need to try @@ -3495,7 +3495,7 @@ static void warn_fail_commit_memory(char* addr, size_t bytes, bool exec) { int err = os::get_last_error(); char buf[256]; size_t buf_len = os::lasterror(buf, sizeof(buf)); - warning("INFO: os::commit_memory(" PTR_FORMAT ", " SIZE_FORMAT + warning("INFO: os::commit_memory(" PTR_FORMAT ", %zu" ", %d) failed; error='%s' (DOS error/errno=%d)", addr, bytes, exec, buf_len != 0 ? buf : "", err); } @@ -3725,7 +3725,7 @@ bool os::protect_memory(char* addr, size_t bytes, ProtType prot, int err = os::get_last_error(); char buf[256]; size_t buf_len = os::lasterror(buf, sizeof(buf)); - warning("INFO: os::protect_memory(" PTR_FORMAT ", " SIZE_FORMAT + warning("INFO: os::protect_memory(" PTR_FORMAT ", %zu" ") failed; error='%s' (DOS error/errno=%d)", addr, bytes, buf_len != 0 ? buf : "", err); } diff --git a/src/hotspot/os/windows/perfMemory_windows.cpp b/src/hotspot/os/windows/perfMemory_windows.cpp index 06b057315cbdd..84c4d840a996b 100644 --- a/src/hotspot/os/windows/perfMemory_windows.cpp +++ b/src/hotspot/os/windows/perfMemory_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -1561,7 +1561,7 @@ static size_t sharedmem_filesize(const char* filename, TRAPS) { if ((statbuf.st_size == 0) || (statbuf.st_size % os::vm_page_size() != 0)) { if (PrintMiscellaneous && Verbose) { - warning("unexpected file size: size = " SIZE_FORMAT "\n", + warning("unexpected file size: size = %zu\n", statbuf.st_size); } THROW_MSG_0(vmSymbols::java_io_IOException(), @@ -1660,7 +1660,7 @@ static void open_file_mapping(int vmid, char** addrp, size_t* sizep, TRAPS) { // invalidating the mapped view of the file CloseHandle(fmh); - log_debug(perf, memops)("mapped " SIZE_FORMAT " bytes for vmid %d at " + log_debug(perf, memops)("mapped %zu bytes for vmid %d at " INTPTR_FORMAT, size, vmid, mapAddress); } From 07a0dcbabcb1216211c1da75f6dd2582da194df9 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 16 Jan 2025 16:30:32 +0000 Subject: [PATCH 28/47] 8347576: Error output in libjsound has non matching format strings Reviewed-by: mdoerr, serb, clanger --- .../share/native/libjsound/MidiInDevice.c | 4 ++-- .../share/native/libjsound/MidiOutDevice.c | 4 ++-- .../native/libjsound/PLATFORM_API_WinOS_MidiIn.cpp | 12 +++++++----- .../native/libjsound/PLATFORM_API_WinOS_Ports.c | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/java.desktop/share/native/libjsound/MidiInDevice.c b/src/java.desktop/share/native/libjsound/MidiInDevice.c index fe320a59a874f..fb27602f39915 100644 --- a/src/java.desktop/share/native/libjsound/MidiInDevice.c +++ b/src/java.desktop/share/native/libjsound/MidiInDevice.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -137,7 +137,7 @@ Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp(JNIEnv* e, jobject thisObj, /* Handle error codes. */ if (ret < -1) { - ERROR1("Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp: MIDI_IN_GetTimeStamp returned %lld\n", ret); + ERROR1("Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp: MIDI_IN_GetTimeStamp returned %lld\n", (long long int) ret); ret = -1; } return ret; diff --git a/src/java.desktop/share/native/libjsound/MidiOutDevice.c b/src/java.desktop/share/native/libjsound/MidiOutDevice.c index 29ef140b89d91..2f351bb1720f9 100644 --- a/src/java.desktop/share/native/libjsound/MidiOutDevice.c +++ b/src/java.desktop/share/native/libjsound/MidiOutDevice.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -94,7 +94,7 @@ Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp(JNIEnv* e, jobject thisObj, /* Handle error codes. */ if (ret < -1) { - ERROR1("Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp: MIDI_IN_GetTimeStamp returned %lld\n", ret); + ERROR1("Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp: MIDI_IN_GetTimeStamp returned %lld\n", (long long int) ret); ret = -1; } return ret; diff --git a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiIn.cpp b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiIn.cpp index 12cfa82fda8ac..2ea03b4c36971 100644 --- a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiIn.cpp +++ b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_MidiIn.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -47,6 +47,8 @@ extern "C" { #define MIDIIN_CHECK_ERROR #endif +#include + /* * Callback from the MIDI device for all messages. */ @@ -55,8 +57,8 @@ void CALLBACK MIDI_IN_PutMessage( HMIDIIN hMidiIn, UINT wMsg, UINT_PTR dwInstanc MidiDeviceHandle* handle = (MidiDeviceHandle*) dwInstance; - TRACE3("> MIDI_IN_PutMessage, hMidiIn: %x, wMsg: %x, dwInstance: %x\n", hMidiIn, wMsg, dwInstance); - TRACE2(" dwParam1: %x, dwParam2: %x\n", dwParam1, dwParam2); + TRACE3("> MIDI_IN_PutMessage, hMidiIn: 0x%" PRIxPTR ", wMsg: %x, dwInstance: 0x%" PRIxPTR "\n", (uintptr_t)hMidiIn, wMsg, (uintptr_t)dwInstance); + TRACE2(" dwParam1: 0x%" PRIxPTR ", dwParam2: 0x%" PRIxPTR "\n", (uintptr_t)dwParam1, (uintptr_t)dwParam2); switch(wMsg) { @@ -70,8 +72,8 @@ void CALLBACK MIDI_IN_PutMessage( HMIDIIN hMidiIn, UINT wMsg, UINT_PTR dwInstanc case MIM_MOREDATA: case MIM_DATA: - TRACE3(" MIDI_IN_PutMessage: MIM_MOREDATA or MIM_DATA. status=%x data1=%x data2=%x\n", - dwParam1 & 0xFF, (dwParam1 & 0xFF00)>>8, (dwParam1 & 0xFF0000)>>16); + TRACE3(" MIDI_IN_PutMessage: MIM_MOREDATA or MIM_DATA. status=%x data1=%x data2=%x\n", + (int)(dwParam1 & 0xFF), (int)((dwParam1 & 0xFF00)>>8), (int)((dwParam1 & 0xFF0000)>>16)); if (handle!=NULL && handle->queue!=NULL && handle->platformData) { MIDI_QueueAddShort(handle->queue, // queue stores packedMsg in big endian diff --git a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_Ports.c b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_Ports.c index 55dcb6e28827a..237aa89c12502 100644 --- a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_Ports.c +++ b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_Ports.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -251,7 +251,7 @@ void printInfo(PortInfo* info) { TRACE5(" PortInfo %p: handle=%p, mixerIndex=%d, dstLineCount=%d, dstLines=%p, ", info, (void*) info->handle, info->mixerIndex, info->dstLineCount, info->dstLines); TRACE5("srcLineCount=%d, srcLines=%p, targetPortCount=%d, sourcePortCount=%d, ports=%p, ", info->srcLineCount, info->srcLines, info->targetPortCount, info->sourcePortCount, info->ports); TRACE3("maxControlCount=%d, usedControlIDs=%d, controlIDs=%p \n", info->maxControlCount, info->usedControlIDs, info->controlIDs); - TRACE2("usedMuxData=%d, muxData=%p, controlIDs=%p \n", info->usedMuxData, info->muxData); + TRACE3("usedMuxData=%d, muxData=%p, controlIDs=%p \n", info->usedMuxData, info->muxData, info->controlIDs); } #endif // USE_TRACE From 0330ca4221ba7bacb0eaeed1a8cdc3d5c3653a83 Mon Sep 17 00:00:00 2001 From: William Kemper Date: Thu, 16 Jan 2025 20:53:17 +0000 Subject: [PATCH 29/47] 8347617: Shenandoah: Use consistent name for update references phase Reviewed-by: ysr --- .../shenandoahBarrierSet.inline.hpp | 2 +- .../gc/shenandoah/shenandoahConcurrentGC.cpp | 38 +++++++++---------- .../gc/shenandoah/shenandoahConcurrentGC.hpp | 16 ++++---- .../gc/shenandoah/shenandoahDegeneratedGC.cpp | 16 ++++---- .../gc/shenandoah/shenandoahDegeneratedGC.hpp | 4 +- .../share/gc/shenandoah/shenandoahGC.cpp | 2 +- .../share/gc/shenandoah/shenandoahGC.hpp | 2 +- .../shenandoah/shenandoahGenerationalHeap.cpp | 6 +-- .../share/gc/shenandoah/shenandoahHeap.cpp | 12 +++--- .../share/gc/shenandoah/shenandoahHeap.hpp | 4 +- .../gc/shenandoah/shenandoahHeap.inline.hpp | 2 +- .../share/gc/shenandoah/shenandoahPacer.cpp | 2 +- .../share/gc/shenandoah/shenandoahPacer.hpp | 4 +- .../gc/shenandoah/shenandoahPacer.inline.hpp | 2 +- .../gc/shenandoah/shenandoahPhaseTimings.hpp | 2 +- .../gc/shenandoah/shenandoahVMOperations.cpp | 4 +- .../gc/shenandoah/shenandoahVerifier.cpp | 6 +-- .../gc/shenandoah/shenandoahVerifier.hpp | 4 +- 18 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp index 58522871338b7..5d00688f67119 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp @@ -420,7 +420,7 @@ void ShenandoahBarrierSet::arraycopy_barrier(T* src, T* dst, size_t count) { char gc_state = ShenandoahThreadLocalData::gc_state(Thread::current()); if ((gc_state & ShenandoahHeap::EVACUATION) != 0) { arraycopy_evacuation(src, count); - } else if ((gc_state & ShenandoahHeap::UPDATEREFS) != 0) { + } else if ((gc_state & ShenandoahHeap::UPDATE_REFS) != 0) { arraycopy_update(src, count); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp index a4c13d24f0460..deca23bfb1cce 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp @@ -197,21 +197,21 @@ bool ShenandoahConcurrentGC::collect(GCCause::Cause cause) { // Perform update-refs phase. if (ShenandoahVerify || ShenandoahPacing) { - vmop_entry_init_updaterefs(); + vmop_entry_init_update_refs(); } - entry_updaterefs(); - if (check_cancellation_and_abort(ShenandoahDegenPoint::_degenerated_updaterefs)) { + entry_update_refs(); + if (check_cancellation_and_abort(ShenandoahDegenPoint::_degenerated_update_refs)) { return false; } // Concurrent update thread roots entry_update_thread_roots(); - if (check_cancellation_and_abort(ShenandoahDegenPoint::_degenerated_updaterefs)) { + if (check_cancellation_and_abort(ShenandoahDegenPoint::_degenerated_update_refs)) { return false; } - vmop_entry_final_updaterefs(); + vmop_entry_final_update_refs(); // Update references freed up collection set, kick the cleanup to reclaim the space. entry_cleanup_complete(); @@ -265,7 +265,7 @@ void ShenandoahConcurrentGC::vmop_entry_final_mark() { VMThread::execute(&op); // jump to entry_final_mark under safepoint } -void ShenandoahConcurrentGC::vmop_entry_init_updaterefs() { +void ShenandoahConcurrentGC::vmop_entry_init_update_refs() { ShenandoahHeap* const heap = ShenandoahHeap::heap(); TraceCollectorStats tcs(heap->monitoring_support()->stw_collection_counters()); ShenandoahTimingsTracker timing(ShenandoahPhaseTimings::init_update_refs_gross); @@ -275,7 +275,7 @@ void ShenandoahConcurrentGC::vmop_entry_init_updaterefs() { VMThread::execute(&op); } -void ShenandoahConcurrentGC::vmop_entry_final_updaterefs() { +void ShenandoahConcurrentGC::vmop_entry_final_update_refs() { ShenandoahHeap* const heap = ShenandoahHeap::heap(); TraceCollectorStats tcs(heap->monitoring_support()->stw_collection_counters()); ShenandoahTimingsTracker timing(ShenandoahPhaseTimings::final_update_refs_gross); @@ -320,16 +320,16 @@ void ShenandoahConcurrentGC::entry_final_mark() { op_final_mark(); } -void ShenandoahConcurrentGC::entry_init_updaterefs() { +void ShenandoahConcurrentGC::entry_init_update_refs() { static const char* msg = "Pause Init Update Refs"; ShenandoahPausePhase gc_phase(msg, ShenandoahPhaseTimings::init_update_refs); EventMark em("%s", msg); // No workers used in this phase, no setup required - op_init_updaterefs(); + op_init_update_refs(); } -void ShenandoahConcurrentGC::entry_final_updaterefs() { +void ShenandoahConcurrentGC::entry_final_update_refs() { static const char* msg = "Pause Final Update Refs"; ShenandoahPausePhase gc_phase(msg, ShenandoahPhaseTimings::final_update_refs); EventMark em("%s", msg); @@ -338,7 +338,7 @@ void ShenandoahConcurrentGC::entry_final_updaterefs() { ShenandoahWorkerPolicy::calc_workers_for_final_update_ref(), "final reference update"); - op_final_updaterefs(); + op_final_update_refs(); } void ShenandoahConcurrentGC::entry_final_roots() { @@ -557,7 +557,7 @@ void ShenandoahConcurrentGC::entry_update_thread_roots() { op_update_thread_roots(); } -void ShenandoahConcurrentGC::entry_updaterefs() { +void ShenandoahConcurrentGC::entry_update_refs() { ShenandoahHeap* const heap = ShenandoahHeap::heap(); TraceCollectorStats tcs(heap->monitoring_support()->concurrent_collection_counters()); static const char* msg = "Concurrent update references"; @@ -569,7 +569,7 @@ void ShenandoahConcurrentGC::entry_updaterefs() { "concurrent reference update"); heap->try_inject_alloc_failure(); - op_updaterefs(); + op_update_refs(); } void ShenandoahConcurrentGC::entry_cleanup_complete() { @@ -1047,17 +1047,17 @@ void ShenandoahConcurrentGC::op_evacuate() { ShenandoahHeap::heap()->evacuate_collection_set(true /*concurrent*/); } -void ShenandoahConcurrentGC::op_init_updaterefs() { +void ShenandoahConcurrentGC::op_init_update_refs() { ShenandoahHeap* const heap = ShenandoahHeap::heap(); if (ShenandoahVerify) { - heap->verifier()->verify_before_updaterefs(); + heap->verifier()->verify_before_update_refs(); } if (ShenandoahPacing) { - heap->pacer()->setup_for_updaterefs(); + heap->pacer()->setup_for_update_refs(); } } -void ShenandoahConcurrentGC::op_updaterefs() { +void ShenandoahConcurrentGC::op_update_refs() { ShenandoahHeap::heap()->update_heap_references(true /*concurrent*/); } @@ -1089,7 +1089,7 @@ void ShenandoahConcurrentGC::op_update_thread_roots() { Handshake::execute(&cl); } -void ShenandoahConcurrentGC::op_final_updaterefs() { +void ShenandoahConcurrentGC::op_final_update_refs() { ShenandoahHeap* const heap = ShenandoahHeap::heap(); assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "must be at safepoint"); assert(!heap->_update_refs_iterator.has_next(), "Should have finished update references"); @@ -1137,7 +1137,7 @@ void ShenandoahConcurrentGC::op_final_updaterefs() { } if (ShenandoahVerify) { - heap->verifier()->verify_after_updaterefs(); + heap->verifier()->verify_after_update_refs(); } if (VerifyAfterGC) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.hpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.hpp index a1837068a7cc0..b4c858bb24551 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.hpp @@ -67,16 +67,16 @@ class ShenandoahConcurrentGC : public ShenandoahGC { // call the entry method below void vmop_entry_init_mark(); void vmop_entry_final_mark(); - void vmop_entry_init_updaterefs(); - void vmop_entry_final_updaterefs(); + void vmop_entry_init_update_refs(); + void vmop_entry_final_update_refs(); void vmop_entry_final_roots(); // Entry methods to normally STW GC operations. These set up logging, monitoring // and workers for net VM operation void entry_init_mark(); void entry_final_mark(); - void entry_init_updaterefs(); - void entry_final_updaterefs(); + void entry_init_update_refs(); + void entry_final_update_refs(); void entry_final_roots(); // Entry methods to normally concurrent GC operations. These set up logging, monitoring @@ -93,7 +93,7 @@ class ShenandoahConcurrentGC : public ShenandoahGC { void entry_cleanup_early(); void entry_evacuate(); void entry_update_thread_roots(); - void entry_updaterefs(); + void entry_update_refs(); void entry_cleanup_complete(); // Called when the collection set is empty, but the generational mode has regions to promote in place @@ -112,10 +112,10 @@ class ShenandoahConcurrentGC : public ShenandoahGC { void op_strong_roots(); void op_cleanup_early(); void op_evacuate(); - void op_init_updaterefs(); - void op_updaterefs(); + void op_init_update_refs(); + void op_update_refs(); void op_update_thread_roots(); - void op_final_updaterefs(); + void op_final_update_refs(); void op_final_roots(); void op_cleanup_complete(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp index 7d2690ef5f614..16f1353caa817 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp @@ -264,15 +264,15 @@ void ShenandoahDegenGC::op_degenerated() { // If heuristics thinks we should do the cycle, this flag would be set, // and we need to do update-refs. Otherwise, it would be the shortcut cycle. if (heap->has_forwarded_objects()) { - op_init_updaterefs(); + op_init_update_refs(); assert(!heap->cancelled_gc(), "STW reference update can not OOM"); } else { _abbreviated = true; } - case _degenerated_updaterefs: + case _degenerated_update_refs: if (heap->has_forwarded_objects()) { - op_updaterefs(); + op_update_refs(); op_update_roots(); assert(!heap->cancelled_gc(), "STW reference update can not OOM"); } @@ -387,16 +387,16 @@ void ShenandoahDegenGC::op_evacuate() { ShenandoahHeap::heap()->evacuate_collection_set(false /* concurrent*/); } -void ShenandoahDegenGC::op_init_updaterefs() { +void ShenandoahDegenGC::op_init_update_refs() { // Evacuation has completed ShenandoahHeap* const heap = ShenandoahHeap::heap(); heap->prepare_update_heap_references(false /*concurrent*/); heap->set_update_refs_in_progress(true); } -void ShenandoahDegenGC::op_updaterefs() { +void ShenandoahDegenGC::op_update_refs() { ShenandoahHeap* const heap = ShenandoahHeap::heap(); - ShenandoahGCPhase phase(ShenandoahPhaseTimings::degen_gc_updaterefs); + ShenandoahGCPhase phase(ShenandoahPhaseTimings::degen_gc_update_refs); // Handed over from concurrent update references phase heap->update_heap_references(false /*concurrent*/); @@ -412,7 +412,7 @@ void ShenandoahDegenGC::op_update_roots() { heap->update_heap_region_states(false /*concurrent*/); if (ShenandoahVerify) { - heap->verifier()->verify_after_updaterefs(); + heap->verifier()->verify_after_update_refs(); } if (VerifyAfterGC) { @@ -447,7 +447,7 @@ const char* ShenandoahDegenGC::degen_event_message(ShenandoahDegenPoint point) c SHENANDOAH_RETURN_EVENT_MESSAGE(_generation->type(), "Pause Degenerated GC", " (Mark)"); case _degenerated_evac: SHENANDOAH_RETURN_EVENT_MESSAGE(_generation->type(), "Pause Degenerated GC", " (Evacuation)"); - case _degenerated_updaterefs: + case _degenerated_update_refs: SHENANDOAH_RETURN_EVENT_MESSAGE(_generation->type(), "Pause Degenerated GC", " (Update Refs)"); default: ShouldNotReachHere(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.hpp b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.hpp index 8dc8ecea75fb2..971bd67eb0df8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.hpp @@ -53,8 +53,8 @@ class ShenandoahDegenGC : public ShenandoahGC { void op_cleanup_early(); void op_evacuate(); - void op_init_updaterefs(); - void op_updaterefs(); + void op_init_update_refs(); + void op_update_refs(); void op_update_roots(); void op_cleanup_complete(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp index 99ee88d98d126..bb1f2585b08e1 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp @@ -45,7 +45,7 @@ const char* ShenandoahGC::degen_point_to_string(ShenandoahDegenPoint point) { return "Mark"; case _degenerated_evac: return "Evacuation"; - case _degenerated_updaterefs: + case _degenerated_update_refs: return "Update References"; default: ShouldNotReachHere(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGC.hpp b/src/hotspot/share/gc/shenandoah/shenandoahGC.hpp index 37b228489177c..f10d5eef969da 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGC.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGC.hpp @@ -53,7 +53,7 @@ class ShenandoahGC : public StackObj { _degenerated_roots, _degenerated_mark, _degenerated_evac, - _degenerated_updaterefs, + _degenerated_update_refs, _DEGENERATED_LIMIT }; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp index 8e803fcc24238..0a405b3f77300 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp @@ -852,7 +852,7 @@ class ShenandoahGenerationalUpdateHeapRefsTask : public WorkerTask { } if (region_progress && ShenandoahPacing) { - _heap->pacer()->report_updaterefs(pointer_delta(update_watermark, r->bottom())); + _heap->pacer()->report_update_refs(pointer_delta(update_watermark, r->bottom())); } if (_heap->check_cancelled_gc_and_yield(CONCURRENT)) { @@ -912,7 +912,7 @@ class ShenandoahGenerationalUpdateHeapRefsTask : public WorkerTask { } if (ShenandoahPacing) { - _heap->pacer()->report_updaterefs(pointer_delta(end_of_range, start_of_range)); + _heap->pacer()->report_update_refs(pointer_delta(end_of_range, start_of_range)); } } } @@ -1072,7 +1072,7 @@ void ShenandoahGenerationalHeap::complete_degenerated_cycle() { shenandoah_assert_heaplocked_or_safepoint(); if (is_concurrent_old_mark_in_progress()) { // This is still necessary for degenerated cycles because the degeneration point may occur - // after final mark of the young generation. See ShenandoahConcurrentGC::op_final_updaterefs for + // after final mark of the young generation. See ShenandoahConcurrentGC::op_final_update_refs for // a more detailed explanation. old_generation()->transfer_pointers_from_satb(); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 84b77c94bcb9e..1ab06d8944d12 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -1259,7 +1259,7 @@ void ShenandoahHeap::concurrent_prepare_for_update_refs() { // A cancellation at this point means the degenerated cycle must resume from update-refs. set_gc_state_concurrent(EVACUATION, false); set_gc_state_concurrent(WEAK_ROOTS, false); - set_gc_state_concurrent(UPDATEREFS, true); + set_gc_state_concurrent(UPDATE_REFS, true); // This will propagate the gc state and retire gclabs and plabs for threads that require it. ShenandoahPrepareForUpdateRefs prepare_for_update_refs(_gc_state.raw_value()); @@ -2024,9 +2024,9 @@ void ShenandoahHeap::set_concurrent_young_mark_in_progress(bool in_progress) { void ShenandoahHeap::set_concurrent_old_mark_in_progress(bool in_progress) { #ifdef ASSERT - // has_forwarded_objects() iff UPDATEREFS or EVACUATION + // has_forwarded_objects() iff UPDATE_REFS or EVACUATION bool has_forwarded = has_forwarded_objects(); - bool updating_or_evacuating = _gc_state.is_set(UPDATEREFS | EVACUATION); + bool updating_or_evacuating = _gc_state.is_set(UPDATE_REFS | EVACUATION); bool evacuating = _gc_state.is_set(EVACUATION); assert ((has_forwarded == updating_or_evacuating) || (evacuating && !has_forwarded && collection_set()->is_empty()), "Updating or evacuating iff has forwarded objects, or if evacuation phase is promoting in place without forwarding"); @@ -2178,7 +2178,7 @@ void ShenandoahHeap::stw_unload_classes(bool full_gc) { DEBUG_ONLY(MetaspaceUtils::verify();) } -// Weak roots are either pre-evacuated (final mark) or updated (final updaterefs), +// Weak roots are either pre-evacuated (final mark) or updated (final update refs), // so they should not have forwarded oops. // However, we do need to "null" dead oops in the roots, if can not be done // in concurrent cycles. @@ -2262,7 +2262,7 @@ void ShenandoahHeap::set_full_gc_move_in_progress(bool in_progress) { } void ShenandoahHeap::set_update_refs_in_progress(bool in_progress) { - set_gc_state_at_safepoint(UPDATEREFS, in_progress); + set_gc_state_at_safepoint(UPDATE_REFS, in_progress); } void ShenandoahHeap::register_nmethod(nmethod* nm) { @@ -2408,7 +2408,7 @@ class ShenandoahUpdateHeapRefsTask : public WorkerTask { if (r->is_active() && !r->is_cset()) { _heap->marked_object_oop_iterate(r, &cl, update_watermark); if (ShenandoahPacing) { - _heap->pacer()->report_updaterefs(pointer_delta(update_watermark, r->bottom())); + _heap->pacer()->report_update_refs(pointer_delta(update_watermark, r->bottom())); } } if (_heap->check_cancelled_gc_and_yield(CONCURRENT)) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp index 508f993b3003f..d2c095d1d7993 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp @@ -329,7 +329,7 @@ class ShenandoahHeap : public CollectedHeap { EVACUATION_BITPOS = 2, // Heap is under updating: needs no additional barriers. - UPDATEREFS_BITPOS = 3, + UPDATE_REFS_BITPOS = 3, // Heap is under weak-reference/roots processing: needs weak-LRB barriers. WEAK_ROOTS_BITPOS = 4, @@ -346,7 +346,7 @@ class ShenandoahHeap : public CollectedHeap { HAS_FORWARDED = 1 << HAS_FORWARDED_BITPOS, MARKING = 1 << MARKING_BITPOS, EVACUATION = 1 << EVACUATION_BITPOS, - UPDATEREFS = 1 << UPDATEREFS_BITPOS, + UPDATE_REFS = 1 << UPDATE_REFS_BITPOS, WEAK_ROOTS = 1 << WEAK_ROOTS_BITPOS, YOUNG_MARKING = 1 << YOUNG_MARKING_BITPOS, OLD_MARKING = 1 << OLD_MARKING_BITPOS diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp index 138e4cadd3c5f..461447cf9ba77 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp @@ -472,7 +472,7 @@ inline bool ShenandoahHeap::is_evacuation_in_progress() const { } inline bool ShenandoahHeap::is_update_refs_in_progress() const { - return is_gc_state(UPDATEREFS); + return is_gc_state(UPDATE_REFS); } inline bool ShenandoahHeap::is_concurrent_weak_root_in_progress() const { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp b/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp index caee4e1344344..e923002e091dc 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp @@ -107,7 +107,7 @@ void ShenandoahPacer::setup_for_evac() { tax); } -void ShenandoahPacer::setup_for_updaterefs() { +void ShenandoahPacer::setup_for_update_refs() { assert(ShenandoahPacing, "Only be here when pacing is enabled"); size_t used = _heap->used(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp b/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp index 44ad2700f8704..fd922d5572960 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp @@ -97,13 +97,13 @@ class ShenandoahPacer : public CHeapObj { void setup_for_idle(); void setup_for_mark(); void setup_for_evac(); - void setup_for_updaterefs(); + void setup_for_update_refs(); void setup_for_reset(); inline void report_mark(size_t words); inline void report_evac(size_t words); - inline void report_updaterefs(size_t words); + inline void report_update_refs(size_t words); inline void report_alloc(size_t words); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPacer.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahPacer.inline.hpp index 38ce12437a38d..881b8a9590ac7 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPacer.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPacer.inline.hpp @@ -38,7 +38,7 @@ inline void ShenandoahPacer::report_evac(size_t words) { report_internal(words); } -inline void ShenandoahPacer::report_updaterefs(size_t words) { +inline void ShenandoahPacer::report_update_refs(size_t words) { report_internal(words); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp index 4c8cb8c20570d..7a8fed9f54837 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp @@ -146,7 +146,7 @@ class outputStream; f(degen_gc_final_rebuild_freeset, " Rebuild Free Set") \ f(degen_gc_stw_evac, " Evacuation") \ f(degen_gc_init_update_refs_manage_gclabs, " Manage GCLABs") \ - f(degen_gc_updaterefs, " Update References") \ + f(degen_gc_update_refs, " Update References") \ f(degen_gc_final_update_refs_finish_work, " Finish Work") \ f(degen_gc_final_update_refs_update_region_states," Update Region States") \ f(degen_gc_final_update_refs_trash_cset, " Trash Collection Set") \ diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp b/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp index 67813be36eeb3..aac67d8987066 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp @@ -109,14 +109,14 @@ void VM_ShenandoahDegeneratedGC::doit() { void VM_ShenandoahInitUpdateRefs::doit() { ShenandoahGCPauseMark mark(_gc_id, "Init Update Refs", SvcGCMarker::CONCURRENT); set_active_generation(); - _gc->entry_init_updaterefs(); + _gc->entry_init_update_refs(); ShenandoahHeap::heap()->propagate_gc_state_to_all_threads(); } void VM_ShenandoahFinalUpdateRefs::doit() { ShenandoahGCPauseMark mark(_gc_id, "Final Update Refs", SvcGCMarker::CONCURRENT); set_active_generation(); - _gc->entry_final_updaterefs(); + _gc->entry_final_update_refs(); ShenandoahHeap::heap()->propagate_gc_state_to_all_threads(); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp index 50edea87eba79..d744ff54bf22a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp @@ -818,7 +818,7 @@ void ShenandoahVerifier::verify_at_safepoint(const char* label, break; case _verify_gcstate_updating: enabled = true; - expected = ShenandoahHeap::HAS_FORWARDED | ShenandoahHeap::UPDATEREFS; + expected = ShenandoahHeap::HAS_FORWARDED | ShenandoahHeap::UPDATE_REFS; break; case _verify_gcstate_stable: enabled = true; @@ -1114,7 +1114,7 @@ void ShenandoahVerifier::verify_before_evacuation() { ); } -void ShenandoahVerifier::verify_before_updaterefs() { +void ShenandoahVerifier::verify_before_update_refs() { verify_at_safepoint( "Before Updating References", _verify_remembered_before_updating_references, // verify read-write remembered set @@ -1129,7 +1129,7 @@ void ShenandoahVerifier::verify_before_updaterefs() { } // We have not yet cleanup (reclaimed) the collection set -void ShenandoahVerifier::verify_after_updaterefs() { +void ShenandoahVerifier::verify_after_update_refs() { verify_at_safepoint( "After Updating References", _verify_remembered_disable, // do not verify remembered set diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.hpp b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.hpp index e49b7b43376bc..a6076ed176bc8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.hpp @@ -214,8 +214,8 @@ class ShenandoahVerifier : public CHeapObj { void verify_after_concmark(); void verify_after_concmark_with_promotions(); void verify_before_evacuation(); - void verify_before_updaterefs(); - void verify_after_updaterefs(); + void verify_before_update_refs(); + void verify_after_update_refs(); void verify_before_fullgc(); void verify_after_fullgc(); void verify_after_degenerated(); From 1f365cc6c75d355588b91e356e9f5dac5fb3555d Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 16 Jan 2025 21:46:18 +0000 Subject: [PATCH 30/47] 8346433: Cannot use DllMain in hotspot for static builds Reviewed-by: dholmes, stuefe --- src/hotspot/os/windows/os_windows.cpp | 48 ++++++++++++++++--------- src/hotspot/os/windows/symbolengine.cpp | 4 +-- src/hotspot/os/windows/symbolengine.hpp | 4 +-- src/hotspot/os/windows/windbghelp.cpp | 4 +-- src/hotspot/os/windows/windbghelp.hpp | 4 +-- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 130356dbc7fe1..36feb7e2a7e3e 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.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 @@ -146,26 +146,34 @@ LPTOP_LEVEL_EXCEPTION_FILTER previousUnhandledExceptionFilter = nullptr; HINSTANCE vm_lib_handle; +static void windows_preinit(HINSTANCE hinst) { + vm_lib_handle = hinst; + if (ForceTimeHighResolution) { + timeBeginPeriod(1L); + } + WindowsDbgHelp::pre_initialize(); + SymbolEngine::pre_initialize(); +} + +static void windows_atexit() { + if (ForceTimeHighResolution) { + timeEndPeriod(1L); + } +#if defined(USE_VECTORED_EXCEPTION_HANDLING) + if (topLevelVectoredExceptionHandler != nullptr) { + RemoveVectoredExceptionHandler(topLevelVectoredExceptionHandler); + topLevelVectoredExceptionHandler = nullptr; + } +#endif +} + BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { switch (reason) { case DLL_PROCESS_ATTACH: - vm_lib_handle = hinst; - if (ForceTimeHighResolution) { - timeBeginPeriod(1L); - } - WindowsDbgHelp::pre_initialize(); - SymbolEngine::pre_initialize(); + windows_preinit(hinst); break; case DLL_PROCESS_DETACH: - if (ForceTimeHighResolution) { - timeEndPeriod(1L); - } -#if defined(USE_VECTORED_EXCEPTION_HANDLING) - if (topLevelVectoredExceptionHandler != nullptr) { - RemoveVectoredExceptionHandler(topLevelVectoredExceptionHandler); - topLevelVectoredExceptionHandler = nullptr; - } -#endif + windows_atexit(); break; default: break; @@ -4427,6 +4435,14 @@ bool os::message_box(const char* title, const char* message) { // This is called _before_ the global arguments have been parsed void os::init(void) { + if (is_vm_statically_linked()) { + // Mimick what is done in DllMain for non-static builds + HMODULE hModule = NULL; + GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, &hModule); + windows_preinit(hModule); + atexit(windows_atexit); + } + _initial_pid = _getpid(); win32::initialize_windows_version(); diff --git a/src/hotspot/os/windows/symbolengine.cpp b/src/hotspot/os/windows/symbolengine.cpp index 0d461e671bb34..98e1ead319dd1 100644 --- a/src/hotspot/os/windows/symbolengine.cpp +++ b/src/hotspot/os/windows/symbolengine.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -526,7 +526,7 @@ namespace { // Do not export. }; } -// Called at DLL_PROCESS_ATTACH. +// Called at DLL_PROCESS_ATTACH for dynamic builds, and from os::init() for static builds. void SymbolEngine::pre_initialize() { ::InitializeCriticalSection(&g_cs); } diff --git a/src/hotspot/os/windows/symbolengine.hpp b/src/hotspot/os/windows/symbolengine.hpp index 02d3ba9487d44..6f0f671f982e7 100644 --- a/src/hotspot/os/windows/symbolengine.hpp +++ b/src/hotspot/os/windows/symbolengine.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -58,7 +58,7 @@ namespace SymbolEngine { // missing - if any, and the dbhelp API version) void print_state_on(outputStream* st); - // Call at DLL_PROCESS_ATTACH. + // Called at DLL_PROCESS_ATTACH for dynamic builds, and from os::init() for static builds. void pre_initialize(); }; diff --git a/src/hotspot/os/windows/windbghelp.cpp b/src/hotspot/os/windows/windbghelp.cpp index 92c88d08cfc17..ac0ab9e0052da 100644 --- a/src/hotspot/os/windows/windbghelp.cpp +++ b/src/hotspot/os/windows/windbghelp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -141,7 +141,7 @@ namespace { // Do not export. }; } -// Called at DLL_PROCESS_ATTACH. +// Called at DLL_PROCESS_ATTACH for dynamic builds, and from os::init() for static builds. void WindowsDbgHelp::pre_initialize() { ::InitializeCriticalSection(&g_cs); } diff --git a/src/hotspot/os/windows/windbghelp.hpp b/src/hotspot/os/windows/windbghelp.hpp index e3e3826db29aa..cdfe781c3435a 100644 --- a/src/hotspot/os/windows/windbghelp.hpp +++ b/src/hotspot/os/windows/windbghelp.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -67,7 +67,7 @@ namespace WindowsDbgHelp { // missing - if any, and the dbhelp API version) void print_state_on(outputStream* st); - // Call at DLL_PROCESS_ATTACH. + // Called at DLL_PROCESS_ATTACH for dynamic builds, and from os::init() for static builds. void pre_initialize(); }; From aa21de566d387ab71adebdf798f7710a005c27b1 Mon Sep 17 00:00:00 2001 From: Quan Anh Mai Date: Fri, 17 Jan 2025 02:05:14 +0000 Subject: [PATCH 31/47] 8347481: C2: Remove the control input of some nodes Reviewed-by: dfenacci, vlivanov, kvn --- src/hotspot/share/opto/addnode.cpp | 6 +++--- src/hotspot/share/opto/library_call.cpp | 28 ++++++++++++------------- src/hotspot/share/opto/loopopts.cpp | 8 +++---- src/hotspot/share/opto/movenode.cpp | 22 +++++++++---------- src/hotspot/share/opto/movenode.hpp | 8 +++---- src/hotspot/share/opto/mulnode.hpp | 8 +++---- src/hotspot/share/opto/subnode.cpp | 6 ++---- src/hotspot/share/opto/subnode.hpp | 26 +++++++++++------------ 8 files changed, 55 insertions(+), 57 deletions(-) diff --git a/src/hotspot/share/opto/addnode.cpp b/src/hotspot/share/opto/addnode.cpp index d9b62d2890dd3..d4224dea43ceb 100644 --- a/src/hotspot/share/opto/addnode.cpp +++ b/src/hotspot/share/opto/addnode.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 @@ -1120,7 +1120,7 @@ Node* MaxNode::build_min_max(Node* a, Node* b, bool is_max, bool is_unsigned, co cmp = gvn.transform(CmpNode::make(b, a, bt, is_unsigned)); } Node* bol = gvn.transform(new BoolNode(cmp, BoolTest::lt)); - res = gvn.transform(CMoveNode::make(nullptr, bol, a, b, t)); + res = gvn.transform(CMoveNode::make(bol, a, b, t)); } if (hook != nullptr) { hook->destruct(&gvn); @@ -1149,7 +1149,7 @@ Node* MaxNode::build_min_max_diff_with_zero(Node* a, Node* b, bool is_max, const } Node* sub = gvn.transform(SubNode::make(a, b, bt)); Node* bol = gvn.transform(new BoolNode(cmp, BoolTest::lt)); - Node* res = gvn.transform(CMoveNode::make(nullptr, bol, sub, zero, t)); + Node* res = gvn.transform(CMoveNode::make(bol, sub, zero, t)); if (hook != nullptr) { hook->destruct(&gvn); } diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index dc49cceec2b1a..badf3c7c40d6b 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -2140,18 +2140,18 @@ bool LibraryCallKit::inline_number_methods(vmIntrinsics::ID id) { Node* arg = argument(0); Node* n = nullptr; switch (id) { - case vmIntrinsics::_numberOfLeadingZeros_i: n = new CountLeadingZerosINode( arg); break; - case vmIntrinsics::_numberOfLeadingZeros_l: n = new CountLeadingZerosLNode( arg); break; - case vmIntrinsics::_numberOfTrailingZeros_i: n = new CountTrailingZerosINode(arg); break; - case vmIntrinsics::_numberOfTrailingZeros_l: n = new CountTrailingZerosLNode(arg); break; - case vmIntrinsics::_bitCount_i: n = new PopCountINode( arg); break; - case vmIntrinsics::_bitCount_l: n = new PopCountLNode( arg); break; - case vmIntrinsics::_reverseBytes_c: n = new ReverseBytesUSNode(nullptr, arg); break; - case vmIntrinsics::_reverseBytes_s: n = new ReverseBytesSNode( nullptr, arg); break; - case vmIntrinsics::_reverseBytes_i: n = new ReverseBytesINode( nullptr, arg); break; - case vmIntrinsics::_reverseBytes_l: n = new ReverseBytesLNode( nullptr, arg); break; - case vmIntrinsics::_reverse_i: n = new ReverseINode(nullptr, arg); break; - case vmIntrinsics::_reverse_l: n = new ReverseLNode(nullptr, arg); break; + case vmIntrinsics::_numberOfLeadingZeros_i: n = new CountLeadingZerosINode( arg); break; + case vmIntrinsics::_numberOfLeadingZeros_l: n = new CountLeadingZerosLNode( arg); break; + case vmIntrinsics::_numberOfTrailingZeros_i: n = new CountTrailingZerosINode(arg); break; + case vmIntrinsics::_numberOfTrailingZeros_l: n = new CountTrailingZerosLNode(arg); break; + case vmIntrinsics::_bitCount_i: n = new PopCountINode( arg); break; + case vmIntrinsics::_bitCount_l: n = new PopCountLNode( arg); break; + case vmIntrinsics::_reverseBytes_c: n = new ReverseBytesUSNode( arg); break; + case vmIntrinsics::_reverseBytes_s: n = new ReverseBytesSNode( arg); break; + case vmIntrinsics::_reverseBytes_i: n = new ReverseBytesINode( arg); break; + case vmIntrinsics::_reverseBytes_l: n = new ReverseBytesLNode( arg); break; + case vmIntrinsics::_reverse_i: n = new ReverseINode( arg); break; + case vmIntrinsics::_reverse_l: n = new ReverseLNode( arg); break; default: fatal_unexpected_iid(id); break; } set_result(_gvn.transform(n)); @@ -8271,14 +8271,14 @@ bool LibraryCallKit::inline_fma(vmIntrinsics::ID id) { a = round_double_node(argument(0)); b = round_double_node(argument(2)); c = round_double_node(argument(4)); - result = _gvn.transform(new FmaDNode(control(), a, b, c)); + result = _gvn.transform(new FmaDNode(a, b, c)); break; case vmIntrinsics::_fmaF: assert(callee()->signature()->size() == 3, "fma has 3 parameters of size 1 each."); a = argument(0); b = argument(1); c = argument(2); - result = _gvn.transform(new FmaFNode(control(), a, b, c)); + result = _gvn.transform(new FmaFNode(a, b, c)); break; default: fatal_unexpected_iid(id); break; diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index 90b9bc84def14..a23b490626465 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -857,9 +857,9 @@ Node *PhaseIdealLoop::conditional_move( Node *region ) { } } } - Node *cmov = CMoveNode::make(cmov_ctrl, iff->in(1), phi->in(1+flip), phi->in(2-flip), _igvn.type(phi)); - register_new_node( cmov, cmov_ctrl ); - _igvn.replace_node( phi, cmov ); + Node* cmov = CMoveNode::make(iff->in(1), phi->in(1+flip), phi->in(2-flip), _igvn.type(phi)); + register_new_node(cmov, cmov_ctrl); + _igvn.replace_node(phi, cmov); #ifndef PRODUCT if (TraceLoopOpts) { tty->print("CMOV "); diff --git a/src/hotspot/share/opto/movenode.cpp b/src/hotspot/share/opto/movenode.cpp index dc65afff26f0f..82ac57cf1324b 100644 --- a/src/hotspot/share/opto/movenode.cpp +++ b/src/hotspot/share/opto/movenode.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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,7 @@ Node *CMoveNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Canonicalize the node by moving constants to the right input. if (in(Condition)->is_Bool() && phase->type(in(IfFalse))->singleton() && !phase->type(in(IfTrue))->singleton()) { BoolNode* b = in(Condition)->as_Bool()->negate(phase); - return make(in(Control), phase->transform(b), in(IfTrue), in(IfFalse), _type); + return make(phase->transform(b), in(IfTrue), in(IfFalse), _type); } return nullptr; @@ -186,15 +186,15 @@ const Type* CMoveNode::Value(PhaseGVN* phase) const { //------------------------------make------------------------------------------- // Make a correctly-flavored CMove. Since _type is directly determined // from the inputs we do not need to specify it here. -CMoveNode *CMoveNode::make(Node *c, Node *bol, Node *left, Node *right, const Type *t) { +CMoveNode* CMoveNode::make(Node* bol, Node* left, Node* right, const Type* t) { switch( t->basic_type() ) { - case T_INT: return new CMoveINode( bol, left, right, t->is_int() ); - case T_FLOAT: return new CMoveFNode( bol, left, right, t ); - case T_DOUBLE: return new CMoveDNode( bol, left, right, t ); - case T_LONG: return new CMoveLNode( bol, left, right, t->is_long() ); - case T_OBJECT: return new CMovePNode( c, bol, left, right, t->is_oopptr() ); - case T_ADDRESS: return new CMovePNode( c, bol, left, right, t->is_ptr() ); - case T_NARROWOOP: return new CMoveNNode( c, bol, left, right, t ); + case T_INT: return new CMoveINode(bol, left, right, t->is_int()); + case T_FLOAT: return new CMoveFNode(bol, left, right, t); + case T_DOUBLE: return new CMoveDNode(bol, left, right, t); + case T_LONG: return new CMoveLNode(bol, left, right, t->is_long()); + case T_OBJECT: return new CMovePNode(bol, left, right, t->is_oopptr()); + case T_ADDRESS: return new CMovePNode(bol, left, right, t->is_ptr()); + case T_NARROWOOP: return new CMoveNNode(bol, left, right, t); default: ShouldNotReachHere(); return nullptr; @@ -278,7 +278,7 @@ Node *CMoveINode::Ideal(PhaseGVN *phase, bool can_reshape) { if( in(Condition)->is_Bool() ) { BoolNode* b = in(Condition)->as_Bool(); BoolNode* b2 = b->negate(phase); - return make(in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type); + return make(phase->transform(b2), in(IfTrue), in(IfFalse), _type); } } diff --git a/src/hotspot/share/opto/movenode.hpp b/src/hotspot/share/opto/movenode.hpp index 02db0c73079f8..59974f797029a 100644 --- a/src/hotspot/share/opto/movenode.hpp +++ b/src/hotspot/share/opto/movenode.hpp @@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ class CMoveNode : public TypeNode { virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); virtual const Type* Value(PhaseGVN* phase) const; virtual Node* Identity(PhaseGVN* phase); - static CMoveNode *make(Node *c, Node *bol, Node *left, Node *right, const Type *t); + static CMoveNode* make(Node* bol, Node* left, Node* right, const Type* t); // Helper function to spot cmove graph shapes static Node* is_cmove_id(PhaseTransform* phase, Node* cmp, Node* t, Node* f, BoolNode* b); static Node* Ideal_minmax(PhaseGVN* phase, CMoveNode* cmov); @@ -87,14 +87,14 @@ class CMoveLNode : public CMoveNode { //------------------------------CMovePNode------------------------------------- class CMovePNode : public CMoveNode { public: - CMovePNode( Node *c, Node *bol, Node *left, Node *right, const TypePtr* t ) : CMoveNode(bol,left,right,t) { init_req(Control,c); } + CMovePNode(Node* bol, Node* left, Node* right, const TypePtr* t) : CMoveNode(bol, left, right, t) {} virtual int Opcode() const; }; //------------------------------CMoveNNode------------------------------------- class CMoveNNode : public CMoveNode { public: - CMoveNNode( Node *c, Node *bol, Node *left, Node *right, const Type* t ) : CMoveNode(bol,left,right,t) { init_req(Control,c); } + CMoveNNode(Node* bol, Node* left, Node* right, const Type* t ) : CMoveNode(bol, left, right, t) {} virtual int Opcode() const; }; diff --git a/src/hotspot/share/opto/mulnode.hpp b/src/hotspot/share/opto/mulnode.hpp index c8d168685d9e5..a34f41d2362d9 100644 --- a/src/hotspot/share/opto/mulnode.hpp +++ b/src/hotspot/share/opto/mulnode.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 @@ -388,7 +388,7 @@ inline Node* make_urshift(Node* a, Node* b) { // fused-multiply-add class FmaNode : public Node { public: - FmaNode(Node* c, Node* in1, Node* in2, Node* in3) : Node(c, in1, in2, in3) { + FmaNode(Node* in1, Node* in2, Node* in3) : Node(nullptr, in1, in2, in3) { assert(UseFMA, "Needs FMA instructions support."); } virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); @@ -398,7 +398,7 @@ class FmaNode : public Node { // fused-multiply-add double class FmaDNode : public FmaNode { public: - FmaDNode(Node* c, Node* in1, Node* in2, Node* in3) : FmaNode(c, in1, in2, in3) {} + FmaDNode(Node* in1, Node* in2, Node* in3) : FmaNode(in1, in2, in3) {} virtual int Opcode() const; const Type* bottom_type() const { return Type::DOUBLE; } virtual uint ideal_reg() const { return Op_RegD; } @@ -409,7 +409,7 @@ class FmaDNode : public FmaNode { // fused-multiply-add float class FmaFNode : public FmaNode { public: - FmaFNode(Node* c, Node* in1, Node* in2, Node* in3) : FmaNode(c, in1, in2, in3) {} + FmaFNode(Node* in1, Node* in2, Node* in3) : FmaNode(in1, in2, in3) {} virtual int Opcode() const; const Type* bottom_type() const { return Type::FLOAT; } virtual uint ideal_reg() const { return Op_RegF; } diff --git a/src/hotspot/share/opto/subnode.cpp b/src/hotspot/share/opto/subnode.cpp index 445eb16821443..369b37d836520 100644 --- a/src/hotspot/share/opto/subnode.cpp +++ b/src/hotspot/share/opto/subnode.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 @@ -1416,9 +1416,7 @@ Node* BoolNode::make_predicate(Node* test_value, PhaseGVN* phase) { //--------------------------------as_int_value--------------------------------- Node* BoolNode::as_int_value(PhaseGVN* phase) { // Inverse to make_predicate. The CMove probably boils down to a Conv2B. - Node* cmov = CMoveNode::make(nullptr, this, - phase->intcon(0), phase->intcon(1), - TypeInt::BOOL); + Node* cmov = CMoveNode::make(this, phase->intcon(0), phase->intcon(1), TypeInt::BOOL); return phase->transform(cmov); } diff --git a/src/hotspot/share/opto/subnode.hpp b/src/hotspot/share/opto/subnode.hpp index 6ceaa851739d8..ca21e62867672 100644 --- a/src/hotspot/share/opto/subnode.hpp +++ b/src/hotspot/share/opto/subnode.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 @@ -532,9 +532,9 @@ class SqrtFNode : public Node { // reverse bytes of an integer class ReverseBytesINode : public Node { public: - ReverseBytesINode(Node *c, Node *in1) : Node(c, in1) {} + ReverseBytesINode(Node* in) : Node(nullptr, in) {} virtual int Opcode() const; - const Type *bottom_type() const { return TypeInt::INT; } + const Type* bottom_type() const { return TypeInt::INT; } virtual uint ideal_reg() const { return Op_RegI; } }; @@ -542,9 +542,9 @@ class ReverseBytesINode : public Node { // reverse bytes of a long class ReverseBytesLNode : public Node { public: - ReverseBytesLNode(Node *c, Node *in1) : Node(c, in1) {} + ReverseBytesLNode(Node* in) : Node(nullptr, in) {} virtual int Opcode() const; - const Type *bottom_type() const { return TypeLong::LONG; } + const Type* bottom_type() const { return TypeLong::LONG; } virtual uint ideal_reg() const { return Op_RegL; } }; @@ -552,9 +552,9 @@ class ReverseBytesLNode : public Node { // reverse bytes of an unsigned short / char class ReverseBytesUSNode : public Node { public: - ReverseBytesUSNode(Node *c, Node *in1) : Node(c, in1) {} + ReverseBytesUSNode(Node* in1) : Node(nullptr, in1) {} virtual int Opcode() const; - const Type *bottom_type() const { return TypeInt::CHAR; } + const Type* bottom_type() const { return TypeInt::CHAR; } virtual uint ideal_reg() const { return Op_RegI; } }; @@ -562,9 +562,9 @@ class ReverseBytesUSNode : public Node { // reverse bytes of a short class ReverseBytesSNode : public Node { public: - ReverseBytesSNode(Node *c, Node *in1) : Node(c, in1) {} + ReverseBytesSNode(Node* in) : Node(nullptr, in) {} virtual int Opcode() const; - const Type *bottom_type() const { return TypeInt::SHORT; } + const Type* bottom_type() const { return TypeInt::SHORT; } virtual uint ideal_reg() const { return Op_RegI; } }; @@ -572,9 +572,9 @@ class ReverseBytesSNode : public Node { // reverse bits of an int class ReverseINode : public Node { public: - ReverseINode(Node *c, Node *in1) : Node(c, in1) {} + ReverseINode(Node* in) : Node(nullptr, in) {} virtual int Opcode() const; - const Type *bottom_type() const { return TypeInt::INT; } + const Type* bottom_type() const { return TypeInt::INT; } virtual uint ideal_reg() const { return Op_RegI; } virtual Node* Identity(PhaseGVN* phase); virtual const Type* Value(PhaseGVN* phase) const; @@ -584,9 +584,9 @@ class ReverseINode : public Node { // reverse bits of a long class ReverseLNode : public Node { public: - ReverseLNode(Node *c, Node *in1) : Node(c, in1) {} + ReverseLNode(Node* in) : Node(nullptr, in) {} virtual int Opcode() const; - const Type *bottom_type() const { return TypeLong::LONG; } + const Type* bottom_type() const { return TypeLong::LONG; } virtual uint ideal_reg() const { return Op_RegL; } virtual Node* Identity(PhaseGVN* phase); virtual const Type* Value(PhaseGVN* phase) const; From 398a580518b4e7961bdddf733e0a89ff25bc437a Mon Sep 17 00:00:00 2001 From: Jayathirth D V Date: Fri, 17 Jan 2025 04:02:26 +0000 Subject: [PATCH 32/47] 8347911: Limit the length of inflated text chunks Reviewed-by: azvegint, prr --- .../classes/com/sun/imageio/plugins/png/PNGImageReader.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java b/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java index 34b034709f525..4889160a977d6 100644 --- a/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java +++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, 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 @@ -142,6 +142,7 @@ public class PNGImageReader extends ImageReader { static final int tRNS_TYPE = 0x74524e53; static final int zTXt_TYPE = 0x7a545874; + static final int MAX_INFLATED_TEXT_LENGTH = 262144; static final int PNG_COLOR_GRAY = 0; static final int PNG_COLOR_RGB = 2; static final int PNG_COLOR_PALETTE = 3; @@ -670,7 +671,7 @@ private void parse_tRNS_chunk(int chunkLength) throws IOException { private static byte[] inflate(byte[] b) throws IOException { InputStream bais = new ByteArrayInputStream(b); try (InputStream iis = new InflaterInputStream(bais)) { - return iis.readAllBytes(); + return iis.readNBytes(MAX_INFLATED_TEXT_LENGTH); } } From a3eef6c2416eb0e02fbd154d84c98b12bcb66e97 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 17 Jan 2025 07:58:52 +0000 Subject: [PATCH 33/47] 8346875: Test jdk/jdk/jfr/event/os/TestCPULoad.java fails on macOS Reviewed-by: egahlin --- test/jdk/jdk/jfr/event/os/TestCPULoad.java | 26 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/test/jdk/jdk/jfr/event/os/TestCPULoad.java b/test/jdk/jdk/jfr/event/os/TestCPULoad.java index efc9b39adf50e..1edb163969955 100644 --- a/test/jdk/jdk/jfr/event/os/TestCPULoad.java +++ b/test/jdk/jdk/jfr/event/os/TestCPULoad.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, 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 @@ -30,7 +30,6 @@ import jdk.test.lib.jfr.EventNames; import jdk.test.lib.jfr.Events; - /** * @test * @key jfr @@ -41,13 +40,32 @@ public class TestCPULoad { private final static String EVENT_NAME = EventNames.CPULoad; + public static boolean isPrime(int num) { + if (num <= 1) return false; + for (int i = 2; i <= Math.sqrt(num); i++) { + if (num % i == 0) return false; + } + return true; + } + + public static int burnCpuCycles(int limit) { + int primeCount = 0; + for (int i = 2; i < limit; i++) { + if (isPrime(i)) { + primeCount++; + } + } + return primeCount; + } + public static void main(String[] args) throws Throwable { Recording recording = new Recording(); recording.enable(EVENT_NAME); recording.start(); - // Need to sleep so a time delta can be calculated - Thread.sleep(100); + // burn some cycles to check increase of CPU related counters + int pn = burnCpuCycles(2500000); recording.stop(); + System.out.println("Found " + pn + " primes while burning cycles"); List events = Events.fromRecording(recording); if (events.isEmpty()) { From f5573f5cbdcae5d1303c8b58d2946c168b977326 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Fri, 17 Jan 2025 10:21:15 +0000 Subject: [PATCH 34/47] 8330851: C2: More efficient TypeFunc creation Reviewed-by: vlivanov, dlong --- src/hotspot/share/opto/arraycopynode.cpp | 4 +- src/hotspot/share/opto/arraycopynode.hpp | 14 +- src/hotspot/share/opto/callnode.cpp | 4 +- src/hotspot/share/opto/callnode.hpp | 13 +- src/hotspot/share/opto/library_call.cpp | 2 +- src/hotspot/share/opto/runtime.cpp | 420 +++++++++++--------- src/hotspot/share/opto/runtime.hpp | 469 +++++++++++++++++++---- src/hotspot/share/opto/type.cpp | 7 + 8 files changed, 677 insertions(+), 256 deletions(-) diff --git a/src/hotspot/share/opto/arraycopynode.cpp b/src/hotspot/share/opto/arraycopynode.cpp index 724164d7f4fd6..2330dd7cb703c 100644 --- a/src/hotspot/share/opto/arraycopynode.cpp +++ b/src/hotspot/share/opto/arraycopynode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -33,6 +33,8 @@ #include "utilities/macros.hpp" #include "utilities/powerOfTwo.hpp" +const TypeFunc* ArrayCopyNode::_arraycopy_type_Type = nullptr; + ArrayCopyNode::ArrayCopyNode(Compile* C, bool alloc_tightly_coupled, bool has_negative_length_guard) : CallNode(arraycopy_type(), nullptr, TypePtr::BOTTOM), _kind(None), diff --git a/src/hotspot/share/opto/arraycopynode.hpp b/src/hotspot/share/opto/arraycopynode.hpp index 12004b970bd8d..f792722068fe3 100644 --- a/src/hotspot/share/opto/arraycopynode.hpp +++ b/src/hotspot/share/opto/arraycopynode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -31,6 +31,7 @@ class GraphKit; class ArrayCopyNode : public CallNode { + static const TypeFunc* _arraycopy_type_Type; private: // What kind of arraycopy variant is this? @@ -65,7 +66,15 @@ class ArrayCopyNode : public CallNode { bool _arguments_validated; +public: + static const TypeFunc* arraycopy_type() { + assert(_arraycopy_type_Type != nullptr, "should be initialized"); + return _arraycopy_type_Type; + } + + static void initialize_arraycopy_Type() { + assert(_arraycopy_type_Type == nullptr, "should be"); const Type** fields = TypeTuple::fields(ParmLimit - TypeFunc::Parms); fields[Src] = TypeInstPtr::BOTTOM; fields[SrcPos] = TypeInt::INT; @@ -83,9 +92,10 @@ class ArrayCopyNode : public CallNode { const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); - return TypeFunc::make(domain, range); + _arraycopy_type_Type = TypeFunc::make(domain, range); } +private: ArrayCopyNode(Compile* C, bool alloc_tightly_coupled, bool has_negative_length_guard); intptr_t get_length_if_constant(PhaseGVN *phase) const; diff --git a/src/hotspot/share/opto/callnode.cpp b/src/hotspot/share/opto/callnode.cpp index 83ea2eea1a8aa..3f84acb1c354e 100644 --- a/src/hotspot/share/opto/callnode.cpp +++ b/src/hotspot/share/opto/callnode.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 @@ -1666,6 +1666,8 @@ Node *AllocateArrayNode::make_ideal_length(const TypeOopPtr* oop_type, PhaseValu } //============================================================================= +const TypeFunc* LockNode::_lock_type_Type = nullptr; + uint LockNode::size_of() const { return sizeof(*this); } // Redundant lock elimination diff --git a/src/hotspot/share/opto/callnode.hpp b/src/hotspot/share/opto/callnode.hpp index 2d3835b71ad42..ad5e9daa8f69d 100644 --- a/src/hotspot/share/opto/callnode.hpp +++ b/src/hotspot/share/opto/callnode.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 @@ -1190,9 +1190,16 @@ class AbstractLockNode: public CallNode { // 2 - a FastLockNode // class LockNode : public AbstractLockNode { + static const TypeFunc* _lock_type_Type; public: - static const TypeFunc *lock_type() { + static inline const TypeFunc* lock_type() { + assert(_lock_type_Type != nullptr, "should be initialized"); + return _lock_type_Type; + } + + static void initialize_lock_Type() { + assert(_lock_type_Type == nullptr, "should be called once"); // create input type (domain) const Type **fields = TypeTuple::fields(3); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked @@ -1205,7 +1212,7 @@ class LockNode : public AbstractLockNode { const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); - return TypeFunc::make(domain,range); + _lock_type_Type = TypeFunc::make(domain,range); } virtual int Opcode() const; diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index badf3c7c40d6b..c433f609533f4 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -5137,7 +5137,7 @@ bool LibraryCallKit::inline_unsafe_setMemory() { // Call it. Note that the length argument is not scaled. make_runtime_call(flags, - OptoRuntime::make_setmemory_Type(), + OptoRuntime::unsafe_setmemory_Type(), StubRoutines::unsafe_setmemory(), "unsafe_setmemory", dst_type, diff --git a/src/hotspot/share/opto/runtime.cpp b/src/hotspot/share/opto/runtime.cpp index 3dd94f619fd1a..012a06f42f414 100644 --- a/src/hotspot/share/opto/runtime.cpp +++ b/src/hotspot/share/opto/runtime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -192,6 +192,72 @@ bool OptoRuntime::generate(ciEnv* env) { #undef GEN_C2_JVMTI_STUB // #undef gen +const TypeFunc* OptoRuntime::_new_instance_Type = nullptr; +const TypeFunc* OptoRuntime::_new_array_Type = nullptr; +const TypeFunc* OptoRuntime::_multianewarray2_Type = nullptr; +const TypeFunc* OptoRuntime::_multianewarray3_Type = nullptr; +const TypeFunc* OptoRuntime::_multianewarray4_Type = nullptr; +const TypeFunc* OptoRuntime::_multianewarray5_Type = nullptr; +const TypeFunc* OptoRuntime::_multianewarrayN_Type = nullptr; +const TypeFunc* OptoRuntime::_complete_monitor_enter_Type = nullptr; +const TypeFunc* OptoRuntime::_complete_monitor_exit_Type = nullptr; +const TypeFunc* OptoRuntime::_monitor_notify_Type = nullptr; +const TypeFunc* OptoRuntime::_uncommon_trap_Type = nullptr; +const TypeFunc* OptoRuntime::_athrow_Type = nullptr; +const TypeFunc* OptoRuntime::_rethrow_Type = nullptr; +const TypeFunc* OptoRuntime::_Math_D_D_Type = nullptr; +const TypeFunc* OptoRuntime::_Math_DD_D_Type = nullptr; +const TypeFunc* OptoRuntime::_modf_Type = nullptr; +const TypeFunc* OptoRuntime::_l2f_Type = nullptr; +const TypeFunc* OptoRuntime::_void_long_Type = nullptr; +const TypeFunc* OptoRuntime::_void_void_Type = nullptr; +const TypeFunc* OptoRuntime::_jfr_write_checkpoint_Type = nullptr; +const TypeFunc* OptoRuntime::_flush_windows_Type = nullptr; +const TypeFunc* OptoRuntime::_fast_arraycopy_Type = nullptr; +const TypeFunc* OptoRuntime::_checkcast_arraycopy_Type = nullptr; +const TypeFunc* OptoRuntime::_generic_arraycopy_Type = nullptr; +const TypeFunc* OptoRuntime::_slow_arraycopy_Type = nullptr; +const TypeFunc* OptoRuntime::_unsafe_setmemory_Type = nullptr; +const TypeFunc* OptoRuntime::_array_fill_Type = nullptr; +const TypeFunc* OptoRuntime::_array_sort_Type = nullptr; +const TypeFunc* OptoRuntime::_array_partition_Type = nullptr; +const TypeFunc* OptoRuntime::_aescrypt_block_Type = nullptr; +const TypeFunc* OptoRuntime::_cipherBlockChaining_aescrypt_Type = nullptr; +const TypeFunc* OptoRuntime::_electronicCodeBook_aescrypt_Type = nullptr; +const TypeFunc* OptoRuntime::_counterMode_aescrypt_Type = nullptr; +const TypeFunc* OptoRuntime::_galoisCounterMode_aescrypt_Type = nullptr; +const TypeFunc* OptoRuntime::_digestBase_implCompress_with_sha3_Type = nullptr; +const TypeFunc* OptoRuntime::_digestBase_implCompress_without_sha3_Type = nullptr; +const TypeFunc* OptoRuntime::_digestBase_implCompressMB_with_sha3_Type = nullptr; +const TypeFunc* OptoRuntime::_digestBase_implCompressMB_without_sha3_Type = nullptr; +const TypeFunc* OptoRuntime::_multiplyToLen_Type = nullptr; +const TypeFunc* OptoRuntime::_montgomeryMultiply_Type = nullptr; +const TypeFunc* OptoRuntime::_montgomerySquare_Type = nullptr; +const TypeFunc* OptoRuntime::_squareToLen_Type = nullptr; +const TypeFunc* OptoRuntime::_mulAdd_Type = nullptr; +const TypeFunc* OptoRuntime::_bigIntegerShift_Type = nullptr; +const TypeFunc* OptoRuntime::_vectorizedMismatch_Type = nullptr; +const TypeFunc* OptoRuntime::_ghash_processBlocks_Type = nullptr; +const TypeFunc* OptoRuntime::_chacha20Block_Type = nullptr; +const TypeFunc* OptoRuntime::_base64_encodeBlock_Type = nullptr; +const TypeFunc* OptoRuntime::_base64_decodeBlock_Type = nullptr; +const TypeFunc* OptoRuntime::_string_IndexOf_Type = nullptr; +const TypeFunc* OptoRuntime::_poly1305_processBlocks_Type = nullptr; +const TypeFunc* OptoRuntime::_intpoly_montgomeryMult_P256_Type = nullptr; +const TypeFunc* OptoRuntime::_intpoly_assign_Type = nullptr; +const TypeFunc* OptoRuntime::_updateBytesCRC32_Type = nullptr; +const TypeFunc* OptoRuntime::_updateBytesCRC32C_Type = nullptr; +const TypeFunc* OptoRuntime::_updateBytesAdler32_Type = nullptr; +const TypeFunc* OptoRuntime::_osr_end_Type = nullptr; +const TypeFunc* OptoRuntime::_register_finalizer_Type = nullptr; +#ifdef INCLUDE_JFR +const TypeFunc* OptoRuntime::_class_id_load_barrier_Type = nullptr; +#endif // INCLUDE_JFR +#ifdef INCLUDE_JVMTI +const TypeFunc* OptoRuntime::_notify_jvmti_vthread_Type = nullptr; +#endif // INCLUDE_JVMTI +const TypeFunc* OptoRuntime::_dtrace_method_entry_exit_Type = nullptr; +const TypeFunc* OptoRuntime::_dtrace_object_alloc_Type = nullptr; // Helper method to do generation of RunTimeStub's address OptoRuntime::generate_stub(ciEnv* env, @@ -498,7 +564,7 @@ JRT_BLOCK_ENTRY(void, OptoRuntime::monitor_notifyAll_C(oopDesc* obj, JavaThread* JRT_BLOCK_END; JRT_END -const TypeFunc *OptoRuntime::new_instance_Type() { +static const TypeFunc* make_new_instance_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated @@ -514,7 +580,7 @@ const TypeFunc *OptoRuntime::new_instance_Type() { } #if INCLUDE_JVMTI -const TypeFunc *OptoRuntime::notify_jvmti_vthread_Type() { +static const TypeFunc* make_notify_jvmti_vthread_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // VirtualThread oop @@ -530,7 +596,7 @@ const TypeFunc *OptoRuntime::notify_jvmti_vthread_Type() { } #endif -const TypeFunc *OptoRuntime::athrow_Type() { +static const TypeFunc* make_athrow_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated @@ -544,8 +610,7 @@ const TypeFunc *OptoRuntime::athrow_Type() { return TypeFunc::make(domain, range); } - -const TypeFunc *OptoRuntime::new_array_Type() { +static const TypeFunc* make_new_array_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass @@ -561,11 +626,7 @@ const TypeFunc *OptoRuntime::new_array_Type() { return TypeFunc::make(domain, range); } -const TypeFunc *OptoRuntime::new_array_nozero_Type() { - return new_array_Type(); -} - -const TypeFunc *OptoRuntime::multianewarray_Type(int ndim) { +const TypeFunc* OptoRuntime::multianewarray_Type(int ndim) { // create input type (domain) const int nargs = ndim + 1; const Type **fields = TypeTuple::fields(nargs); @@ -582,23 +643,7 @@ const TypeFunc *OptoRuntime::multianewarray_Type(int ndim) { return TypeFunc::make(domain, range); } -const TypeFunc *OptoRuntime::multianewarray2_Type() { - return multianewarray_Type(2); -} - -const TypeFunc *OptoRuntime::multianewarray3_Type() { - return multianewarray_Type(3); -} - -const TypeFunc *OptoRuntime::multianewarray4_Type() { - return multianewarray_Type(4); -} - -const TypeFunc *OptoRuntime::multianewarray5_Type() { - return multianewarray_Type(5); -} - -const TypeFunc *OptoRuntime::multianewarrayN_Type() { +static const TypeFunc* make_multianewarrayN_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass @@ -613,7 +658,7 @@ const TypeFunc *OptoRuntime::multianewarrayN_Type() { return TypeFunc::make(domain, range); } -const TypeFunc *OptoRuntime::uncommon_trap_Type() { +static const TypeFunc* make_uncommon_trap_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = TypeInt::INT; // trap_reason (deopt reason and action) @@ -628,7 +673,8 @@ const TypeFunc *OptoRuntime::uncommon_trap_Type() { //----------------------------------------------------------------------------- // Monitor Handling -const TypeFunc *OptoRuntime::complete_monitor_enter_Type() { + +static const TypeFunc* make_complete_monitor_enter_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked @@ -643,12 +689,9 @@ const TypeFunc *OptoRuntime::complete_monitor_enter_Type() { return TypeFunc::make(domain,range); } -const TypeFunc *OptoRuntime::complete_monitor_locking_Type() { - return complete_monitor_enter_Type(); -} - //----------------------------------------------------------------------------- -const TypeFunc *OptoRuntime::complete_monitor_exit_Type() { + +static const TypeFunc* make_complete_monitor_exit_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(3); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked @@ -664,7 +707,7 @@ const TypeFunc *OptoRuntime::complete_monitor_exit_Type() { return TypeFunc::make(domain, range); } -const TypeFunc *OptoRuntime::monitor_notify_Type() { +static const TypeFunc* make_monitor_notify_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked @@ -676,11 +719,7 @@ const TypeFunc *OptoRuntime::monitor_notify_Type() { return TypeFunc::make(domain, range); } -const TypeFunc *OptoRuntime::monitor_notifyAll_Type() { - return monitor_notify_Type(); -} - -const TypeFunc* OptoRuntime::flush_windows_Type() { +static const TypeFunc* make_flush_windows_Type() { // create input type (domain) const Type** fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = nullptr; // void @@ -694,7 +733,7 @@ const TypeFunc* OptoRuntime::flush_windows_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::l2f_Type() { +static const TypeFunc* make_l2f_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = TypeLong::LONG; @@ -709,7 +748,7 @@ const TypeFunc* OptoRuntime::l2f_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::modf_Type() { +static const TypeFunc* make_modf_Type() { const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = Type::FLOAT; fields[TypeFunc::Parms+1] = Type::FLOAT; @@ -724,7 +763,7 @@ const TypeFunc* OptoRuntime::modf_Type() { return TypeFunc::make(domain, range); } -const TypeFunc *OptoRuntime::Math_D_D_Type() { +static const TypeFunc* make_Math_D_D_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(2); // Symbol* name of class to be loaded @@ -741,7 +780,7 @@ const TypeFunc *OptoRuntime::Math_D_D_Type() { return TypeFunc::make(domain, range); } -const TypeFunc *OptoRuntime::Math_Vector_Vector_Type(uint num_arg, const TypeVect* in_type, const TypeVect* out_type) { +const TypeFunc* OptoRuntime::Math_Vector_Vector_Type(uint num_arg, const TypeVect* in_type, const TypeVect* out_type) { // create input type (domain) const Type **fields = TypeTuple::fields(num_arg); // Symbol* name of class to be loaded @@ -760,7 +799,7 @@ const TypeFunc *OptoRuntime::Math_Vector_Vector_Type(uint num_arg, const TypeVec return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::Math_DD_D_Type() { +static const TypeFunc* make_Math_DD_D_Type() { const Type **fields = TypeTuple::fields(4); fields[TypeFunc::Parms+0] = Type::DOUBLE; fields[TypeFunc::Parms+1] = Type::HALF; @@ -779,7 +818,7 @@ const TypeFunc* OptoRuntime::Math_DD_D_Type() { //-------------- currentTimeMillis, currentTimeNanos, etc -const TypeFunc* OptoRuntime::void_long_Type() { +static const TypeFunc* make_void_long_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(0); const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields); @@ -793,34 +832,35 @@ const TypeFunc* OptoRuntime::void_long_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::void_void_Type() { - // create input type (domain) - const Type **fields = TypeTuple::fields(0); - const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields); +static const TypeFunc* make_void_void_Type() { + // create input type (domain) + const Type **fields = TypeTuple::fields(0); + const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields); - // create result type (range) - fields = TypeTuple::fields(0); - const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); - return TypeFunc::make(domain, range); - } + // create result type (range) + fields = TypeTuple::fields(0); + const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); + return TypeFunc::make(domain, range); +} - const TypeFunc* OptoRuntime::jfr_write_checkpoint_Type() { - // create input type (domain) - const Type **fields = TypeTuple::fields(0); - const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields); +static const TypeFunc* make_jfr_write_checkpoint_Type() { + // create input type (domain) + const Type **fields = TypeTuple::fields(0); + const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields); - // create result type (range) - fields = TypeTuple::fields(0); - const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); - return TypeFunc::make(domain, range); - } + // create result type (range) + fields = TypeTuple::fields(0); + const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); + return TypeFunc::make(domain, range); +} // Takes as parameters: // void *dest // long size // uchar byte -const TypeFunc* OptoRuntime::make_setmemory_Type() { + +static const TypeFunc* make_setmemory_Type() { // create input type (domain) int argcnt = NOT_LP64(3) LP64_ONLY(4); const Type** fields = TypeTuple::fields(argcnt); @@ -885,29 +925,7 @@ static const TypeFunc* make_arraycopy_Type(ArrayCopyType act) { return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::fast_arraycopy_Type() { - // This signature is simple: Two base pointers and a size_t. - return make_arraycopy_Type(ac_fast); -} - -const TypeFunc* OptoRuntime::checkcast_arraycopy_Type() { - // An extension of fast_arraycopy_Type which adds type checking. - return make_arraycopy_Type(ac_checkcast); -} - -const TypeFunc* OptoRuntime::slow_arraycopy_Type() { - // This signature is exactly the same as System.arraycopy. - // There are no intptr_t (int/long) arguments. - return make_arraycopy_Type(ac_slow); -} - -const TypeFunc* OptoRuntime::generic_arraycopy_Type() { - // This signature is like System.arraycopy, except that it returns status. - return make_arraycopy_Type(ac_generic); -} - - -const TypeFunc* OptoRuntime::array_fill_Type() { +static const TypeFunc* make_array_fill_Type() { const Type** fields; int argp = TypeFunc::Parms; // create input type (domain): pointer, int, size_t @@ -926,7 +944,7 @@ const TypeFunc* OptoRuntime::array_fill_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::array_partition_Type() { +static const TypeFunc* make_array_partition_Type() { // create input type (domain) int num_args = 7; int argcnt = num_args; @@ -949,7 +967,7 @@ const TypeFunc* OptoRuntime::array_partition_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::array_sort_Type() { +static const TypeFunc* make_array_sort_Type() { // create input type (domain) int num_args = 4; int argcnt = num_args; @@ -969,8 +987,7 @@ const TypeFunc* OptoRuntime::array_sort_Type() { return TypeFunc::make(domain, range); } -// for aescrypt encrypt/decrypt operations, just three pointers returning void (length is constant) -const TypeFunc* OptoRuntime::aescrypt_block_Type() { +static const TypeFunc* make_aescrypt_block_Type() { // create input type (domain) int num_args = 3; int argcnt = num_args; @@ -989,10 +1006,7 @@ const TypeFunc* OptoRuntime::aescrypt_block_Type() { return TypeFunc::make(domain, range); } -/** - * int updateBytesCRC32(int crc, byte* b, int len) - */ -const TypeFunc* OptoRuntime::updateBytesCRC32_Type() { +static const TypeFunc* make_updateBytesCRC32_Type() { // create input type (domain) int num_args = 3; int argcnt = num_args; @@ -1011,10 +1025,7 @@ const TypeFunc* OptoRuntime::updateBytesCRC32_Type() { return TypeFunc::make(domain, range); } -/** - * int updateBytesCRC32C(int crc, byte* buf, int len, int* table) - */ -const TypeFunc* OptoRuntime::updateBytesCRC32C_Type() { +static const TypeFunc* make_updateBytesCRC32C_Type() { // create input type (domain) int num_args = 4; int argcnt = num_args; @@ -1034,10 +1045,7 @@ const TypeFunc* OptoRuntime::updateBytesCRC32C_Type() { return TypeFunc::make(domain, range); } -/** -* int updateBytesAdler32(int adler, bytes* b, int off, int len) -*/ -const TypeFunc* OptoRuntime::updateBytesAdler32_Type() { +static const TypeFunc* make_updateBytesAdler32_Type() { // create input type (domain) int num_args = 3; int argcnt = num_args; @@ -1056,8 +1064,7 @@ const TypeFunc* OptoRuntime::updateBytesAdler32_Type() { return TypeFunc::make(domain, range); } -// for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int -const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() { +static const TypeFunc* make_cipherBlockChaining_aescrypt_Type() { // create input type (domain) int num_args = 5; int argcnt = num_args; @@ -1078,8 +1085,7 @@ const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() { return TypeFunc::make(domain, range); } -// for electronicCodeBook calls of aescrypt encrypt/decrypt, three pointers and a length, returning int -const TypeFunc* OptoRuntime::electronicCodeBook_aescrypt_Type() { +static const TypeFunc* make_electronicCodeBook_aescrypt_Type() { // create input type (domain) int num_args = 4; int argcnt = num_args; @@ -1099,8 +1105,7 @@ const TypeFunc* OptoRuntime::electronicCodeBook_aescrypt_Type() { return TypeFunc::make(domain, range); } -//for counterMode calls of aescrypt encrypt/decrypt, four pointers and a length, returning int -const TypeFunc* OptoRuntime::counterMode_aescrypt_Type() { +static const TypeFunc* make_counterMode_aescrypt_Type() { // create input type (domain) int num_args = 7; int argcnt = num_args; @@ -1122,8 +1127,7 @@ const TypeFunc* OptoRuntime::counterMode_aescrypt_Type() { return TypeFunc::make(domain, range); } -//for counterMode calls of aescrypt encrypt/decrypt, four pointers and a length, returning int -const TypeFunc* OptoRuntime::galoisCounterMode_aescrypt_Type() { +static const TypeFunc* make_galoisCounterMode_aescrypt_Type() { // create input type (domain) int num_args = 8; int argcnt = num_args; @@ -1147,10 +1151,7 @@ const TypeFunc* OptoRuntime::galoisCounterMode_aescrypt_Type() { return TypeFunc::make(domain, range); } -/* - * void implCompress(byte[] buf, int ofs) - */ -const TypeFunc* OptoRuntime::digestBase_implCompress_Type(bool is_sha3) { +static const TypeFunc* make_digestBase_implCompress_Type(bool is_sha3) { // create input type (domain) int num_args = is_sha3 ? 3 : 2; int argcnt = num_args; @@ -1169,10 +1170,7 @@ const TypeFunc* OptoRuntime::digestBase_implCompress_Type(bool is_sha3) { return TypeFunc::make(domain, range); } -/* - * int implCompressMultiBlock(byte[] b, int ofs, int limit) - */ -const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type(bool is_sha3) { +static const TypeFunc* make_digestBase_implCompressMB_Type(bool is_sha3) { // create input type (domain) int num_args = is_sha3 ? 5 : 4; int argcnt = num_args; @@ -1193,7 +1191,7 @@ const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type(bool is_sha3) { return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::multiplyToLen_Type() { +static const TypeFunc* make_multiplyToLen_Type() { // create input type (domain) int num_args = 5; int argcnt = num_args; @@ -1214,7 +1212,7 @@ const TypeFunc* OptoRuntime::multiplyToLen_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::squareToLen_Type() { +static const TypeFunc* make_squareToLen_Type() { // create input type (domain) int num_args = 4; int argcnt = num_args; @@ -1234,8 +1232,7 @@ const TypeFunc* OptoRuntime::squareToLen_Type() { return TypeFunc::make(domain, range); } -// for mulAdd calls, 2 pointers and 3 ints, returning int -const TypeFunc* OptoRuntime::mulAdd_Type() { +static const TypeFunc* make_mulAdd_Type() { // create input type (domain) int num_args = 5; int argcnt = num_args; @@ -1256,7 +1253,7 @@ const TypeFunc* OptoRuntime::mulAdd_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::montgomeryMultiply_Type() { +static const TypeFunc* make_montgomeryMultiply_Type() { // create input type (domain) int num_args = 7; int argcnt = num_args; @@ -1280,7 +1277,7 @@ const TypeFunc* OptoRuntime::montgomeryMultiply_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::montgomerySquare_Type() { +static const TypeFunc* make_montgomerySquare_Type() { // create input type (domain) int num_args = 6; int argcnt = num_args; @@ -1303,7 +1300,7 @@ const TypeFunc* OptoRuntime::montgomerySquare_Type() { return TypeFunc::make(domain, range); } -const TypeFunc * OptoRuntime::bigIntegerShift_Type() { +static const TypeFunc* make_bigIntegerShift_Type() { int argcnt = 5; const Type** fields = TypeTuple::fields(argcnt); int argp = TypeFunc::Parms; @@ -1322,7 +1319,7 @@ const TypeFunc * OptoRuntime::bigIntegerShift_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* OptoRuntime::vectorizedMismatch_Type() { +static const TypeFunc* make_vectorizedMismatch_Type() { // create input type (domain) int num_args = 4; int argcnt = num_args; @@ -1342,47 +1339,44 @@ const TypeFunc* OptoRuntime::vectorizedMismatch_Type() { return TypeFunc::make(domain, range); } -// GHASH block processing -const TypeFunc* OptoRuntime::ghash_processBlocks_Type() { - int argcnt = 4; +static const TypeFunc* make_ghash_processBlocks_Type() { + int argcnt = 4; - const Type** fields = TypeTuple::fields(argcnt); - int argp = TypeFunc::Parms; - fields[argp++] = TypePtr::NOTNULL; // state - fields[argp++] = TypePtr::NOTNULL; // subkeyH - fields[argp++] = TypePtr::NOTNULL; // data - fields[argp++] = TypeInt::INT; // blocks - assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); - const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); + const Type** fields = TypeTuple::fields(argcnt); + int argp = TypeFunc::Parms; + fields[argp++] = TypePtr::NOTNULL; // state + fields[argp++] = TypePtr::NOTNULL; // subkeyH + fields[argp++] = TypePtr::NOTNULL; // data + fields[argp++] = TypeInt::INT; // blocks + assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); + const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); - // result type needed - fields = TypeTuple::fields(1); - fields[TypeFunc::Parms+0] = nullptr; // void - const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); - return TypeFunc::make(domain, range); + // result type needed + fields = TypeTuple::fields(1); + fields[TypeFunc::Parms+0] = nullptr; // void + const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); + return TypeFunc::make(domain, range); } -// ChaCha20 Block function -const TypeFunc* OptoRuntime::chacha20Block_Type() { - int argcnt = 2; +static const TypeFunc* make_chacha20Block_Type() { + int argcnt = 2; - const Type** fields = TypeTuple::fields(argcnt); - int argp = TypeFunc::Parms; - fields[argp++] = TypePtr::NOTNULL; // state - fields[argp++] = TypePtr::NOTNULL; // result + const Type** fields = TypeTuple::fields(argcnt); + int argp = TypeFunc::Parms; + fields[argp++] = TypePtr::NOTNULL; // state + fields[argp++] = TypePtr::NOTNULL; // result - assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); - const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields); + assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); + const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields); - // result type needed - fields = TypeTuple::fields(1); - fields[TypeFunc::Parms + 0] = TypeInt::INT; // key stream outlen as int - const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields); - return TypeFunc::make(domain, range); + // result type needed + fields = TypeTuple::fields(1); + fields[TypeFunc::Parms + 0] = TypeInt::INT; // key stream outlen as int + const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields); + return TypeFunc::make(domain, range); } -// Base64 encode function -const TypeFunc* OptoRuntime::base64_encodeBlock_Type() { +static const TypeFunc* make_base64_encodeBlock_Type() { int argcnt = 6; const Type** fields = TypeTuple::fields(argcnt); @@ -1403,8 +1397,7 @@ const TypeFunc* OptoRuntime::base64_encodeBlock_Type() { return TypeFunc::make(domain, range); } -// String IndexOf function -const TypeFunc* OptoRuntime::string_IndexOf_Type() { +static const TypeFunc* make_string_IndexOf_Type() { int argcnt = 4; const Type** fields = TypeTuple::fields(argcnt); @@ -1423,8 +1416,7 @@ const TypeFunc* OptoRuntime::string_IndexOf_Type() { return TypeFunc::make(domain, range); } -// Base64 decode function -const TypeFunc* OptoRuntime::base64_decodeBlock_Type() { +static const TypeFunc* make_base64_decodeBlock_Type() { int argcnt = 7; const Type** fields = TypeTuple::fields(argcnt); @@ -1446,8 +1438,7 @@ const TypeFunc* OptoRuntime::base64_decodeBlock_Type() { return TypeFunc::make(domain, range); } -// Poly1305 processMultipleBlocks function -const TypeFunc* OptoRuntime::poly1305_processBlocks_Type() { +static const TypeFunc* make_poly1305_processBlocks_Type() { int argcnt = 4; const Type** fields = TypeTuple::fields(argcnt); @@ -1466,8 +1457,7 @@ const TypeFunc* OptoRuntime::poly1305_processBlocks_Type() { return TypeFunc::make(domain, range); } -// MontgomeryIntegerPolynomialP256 multiply function -const TypeFunc* OptoRuntime::intpoly_montgomeryMult_P256_Type() { +static const TypeFunc* make_intpoly_montgomeryMult_P256_Type() { int argcnt = 3; const Type** fields = TypeTuple::fields(argcnt); @@ -1485,8 +1475,7 @@ const TypeFunc* OptoRuntime::intpoly_montgomeryMult_P256_Type() { return TypeFunc::make(domain, range); } -// IntegerPolynomial constant time assignment function -const TypeFunc* OptoRuntime::intpoly_assign_Type() { +static const TypeFunc* make_intpoly_assign_Type() { int argcnt = 4; const Type** fields = TypeTuple::fields(argcnt); @@ -1505,8 +1494,8 @@ const TypeFunc* OptoRuntime::intpoly_assign_Type() { return TypeFunc::make(domain, range); } -//------------- Interpreter state access for on stack replacement -const TypeFunc* OptoRuntime::osr_end_Type() { +//------------- Interpreter state for on stack replacement +static const TypeFunc* make_osr_end_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // OSR temp buf @@ -1752,8 +1741,7 @@ address OptoRuntime::rethrow_C(oopDesc* exception, JavaThread* thread, address r return SharedRuntime::raw_exception_handler_for_return_address(thread, ret_pc); } - -const TypeFunc *OptoRuntime::rethrow_Type() { +static const TypeFunc* make_rethrow_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop @@ -1803,8 +1791,7 @@ bool OptoRuntime::is_deoptimized_caller_frame(JavaThread *thread) { return caller_frame.is_deoptimized_frame(); } - -const TypeFunc *OptoRuntime::register_finalizer_Type() { +static const TypeFunc* make_register_finalizer_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // oop; Receiver @@ -1821,7 +1808,7 @@ const TypeFunc *OptoRuntime::register_finalizer_Type() { } #if INCLUDE_JFR -const TypeFunc *OptoRuntime::class_id_load_barrier_Type() { +static const TypeFunc* make_class_id_load_barrier_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = TypeInstPtr::KLASS; @@ -1834,11 +1821,10 @@ const TypeFunc *OptoRuntime::class_id_load_barrier_Type() { return TypeFunc::make(domain,range); } -#endif +#endif // INCLUDE_JFR //----------------------------------------------------------------------------- -// Dtrace support. entry and exit probes have the same signature -const TypeFunc *OptoRuntime::dtrace_method_entry_exit_Type() { +static const TypeFunc* make_dtrace_method_entry_exit_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage @@ -1853,7 +1839,7 @@ const TypeFunc *OptoRuntime::dtrace_method_entry_exit_Type() { return TypeFunc::make(domain,range); } -const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() { +static const TypeFunc* make_dtrace_object_alloc_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage @@ -1869,7 +1855,6 @@ const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() { return TypeFunc::make(domain,range); } - JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer_C(oopDesc* obj, JavaThread* current)) assert(oopDesc::is_oop(obj), "must be a valid oop"); assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise"); @@ -1955,6 +1940,75 @@ NamedCounter* OptoRuntime::new_named_counter(JVMState* youngest_jvms, NamedCount return c; } +void OptoRuntime::initialize_types() { + _new_instance_Type = make_new_instance_Type(); + _new_array_Type = make_new_array_Type(); + _multianewarray2_Type = multianewarray_Type(2); + _multianewarray3_Type = multianewarray_Type(3); + _multianewarray4_Type = multianewarray_Type(4); + _multianewarray5_Type = multianewarray_Type(5); + _multianewarrayN_Type = make_multianewarrayN_Type(); + _complete_monitor_enter_Type = make_complete_monitor_enter_Type(); + _complete_monitor_exit_Type = make_complete_monitor_exit_Type(); + _monitor_notify_Type = make_monitor_notify_Type(); + _uncommon_trap_Type = make_uncommon_trap_Type(); + _athrow_Type = make_athrow_Type(); + _rethrow_Type = make_rethrow_Type(); + _Math_D_D_Type = make_Math_D_D_Type(); + _Math_DD_D_Type = make_Math_DD_D_Type(); + _modf_Type = make_modf_Type(); + _l2f_Type = make_l2f_Type(); + _void_long_Type = make_void_long_Type(); + _void_void_Type = make_void_void_Type(); + _jfr_write_checkpoint_Type = make_jfr_write_checkpoint_Type(); + _flush_windows_Type = make_flush_windows_Type(); + _fast_arraycopy_Type = make_arraycopy_Type(ac_fast); + _checkcast_arraycopy_Type = make_arraycopy_Type(ac_checkcast); + _generic_arraycopy_Type = make_arraycopy_Type(ac_generic); + _slow_arraycopy_Type = make_arraycopy_Type(ac_slow); + _unsafe_setmemory_Type = make_setmemory_Type(); + _array_fill_Type = make_array_fill_Type(); + _array_sort_Type = make_array_sort_Type(); + _array_partition_Type = make_array_partition_Type(); + _aescrypt_block_Type = make_aescrypt_block_Type(); + _cipherBlockChaining_aescrypt_Type = make_cipherBlockChaining_aescrypt_Type(); + _electronicCodeBook_aescrypt_Type = make_electronicCodeBook_aescrypt_Type(); + _counterMode_aescrypt_Type = make_counterMode_aescrypt_Type(); + _galoisCounterMode_aescrypt_Type = make_galoisCounterMode_aescrypt_Type(); + _digestBase_implCompress_with_sha3_Type = make_digestBase_implCompress_Type( /* is_sha3= */ true); + _digestBase_implCompress_without_sha3_Type = make_digestBase_implCompress_Type( /* is_sha3= */ false);; + _digestBase_implCompressMB_with_sha3_Type = make_digestBase_implCompressMB_Type(/* is_sha3= */ true); + _digestBase_implCompressMB_without_sha3_Type = make_digestBase_implCompressMB_Type(/* is_sha3= */ false); + _multiplyToLen_Type = make_multiplyToLen_Type(); + _montgomeryMultiply_Type = make_montgomeryMultiply_Type(); + _montgomerySquare_Type = make_montgomerySquare_Type(); + _squareToLen_Type = make_squareToLen_Type(); + _mulAdd_Type = make_mulAdd_Type(); + _bigIntegerShift_Type = make_bigIntegerShift_Type(); + _vectorizedMismatch_Type = make_vectorizedMismatch_Type(); + _ghash_processBlocks_Type = make_ghash_processBlocks_Type(); + _chacha20Block_Type = make_chacha20Block_Type(); + _base64_encodeBlock_Type = make_base64_encodeBlock_Type(); + _base64_decodeBlock_Type = make_base64_decodeBlock_Type(); + _string_IndexOf_Type = make_string_IndexOf_Type(); + _poly1305_processBlocks_Type = make_poly1305_processBlocks_Type(); + _intpoly_montgomeryMult_P256_Type = make_intpoly_montgomeryMult_P256_Type(); + _intpoly_assign_Type = make_intpoly_assign_Type(); + _updateBytesCRC32_Type = make_updateBytesCRC32_Type(); + _updateBytesCRC32C_Type = make_updateBytesCRC32C_Type(); + _updateBytesAdler32_Type = make_updateBytesAdler32_Type(); + _osr_end_Type = make_osr_end_Type(); + _register_finalizer_Type = make_register_finalizer_Type(); + JFR_ONLY( + _class_id_load_barrier_Type = make_class_id_load_barrier_Type(); + ) +#ifdef INCLUDE_JVMTI + _notify_jvmti_vthread_Type = make_notify_jvmti_vthread_Type(); +#endif // INCLUDE_JVMTI + _dtrace_method_entry_exit_Type = make_dtrace_method_entry_exit_Type(); + _dtrace_object_alloc_Type = make_dtrace_object_alloc_Type(); +} + int trace_exception_counter = 0; static void trace_exception(outputStream* st, oop exception_oop, address exception_pc, const char* msg) { trace_exception_counter++; diff --git a/src/hotspot/share/opto/runtime.hpp b/src/hotspot/share/opto/runtime.hpp index dc608cf746a73..cfc79c8fdcc2e 100644 --- a/src/hotspot/share/opto/runtime.hpp +++ b/src/hotspot/share/opto/runtime.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -131,6 +131,74 @@ class OptoRuntime : public AllStatic { #undef C2_STUB_FIELD_DECLARE #undef C2_JVMTI_STUB_FIELD_DECLARE + // static TypeFunc* data members + static const TypeFunc* _new_instance_Type; + static const TypeFunc* _new_array_Type; + static const TypeFunc* _multianewarray2_Type; + static const TypeFunc* _multianewarray3_Type; + static const TypeFunc* _multianewarray4_Type; + static const TypeFunc* _multianewarray5_Type; + static const TypeFunc* _multianewarrayN_Type; + static const TypeFunc* _complete_monitor_enter_Type; + static const TypeFunc* _complete_monitor_exit_Type; + static const TypeFunc* _monitor_notify_Type; + static const TypeFunc* _uncommon_trap_Type; + static const TypeFunc* _athrow_Type; + static const TypeFunc* _rethrow_Type; + static const TypeFunc* _Math_D_D_Type; + static const TypeFunc* _Math_DD_D_Type; + static const TypeFunc* _modf_Type; + static const TypeFunc* _l2f_Type; + static const TypeFunc* _void_long_Type; + static const TypeFunc* _void_void_Type; + static const TypeFunc* _jfr_write_checkpoint_Type; + static const TypeFunc* _flush_windows_Type; + static const TypeFunc* _fast_arraycopy_Type; + static const TypeFunc* _checkcast_arraycopy_Type; + static const TypeFunc* _generic_arraycopy_Type; + static const TypeFunc* _slow_arraycopy_Type; + static const TypeFunc* _unsafe_setmemory_Type; + static const TypeFunc* _array_fill_Type; + static const TypeFunc* _array_sort_Type; + static const TypeFunc* _array_partition_Type; + static const TypeFunc* _aescrypt_block_Type; + static const TypeFunc* _cipherBlockChaining_aescrypt_Type; + static const TypeFunc* _electronicCodeBook_aescrypt_Type; + static const TypeFunc* _counterMode_aescrypt_Type; + static const TypeFunc* _galoisCounterMode_aescrypt_Type; + static const TypeFunc* _digestBase_implCompress_with_sha3_Type; + static const TypeFunc* _digestBase_implCompress_without_sha3_Type; + static const TypeFunc* _digestBase_implCompressMB_with_sha3_Type; + static const TypeFunc* _digestBase_implCompressMB_without_sha3_Type; + static const TypeFunc* _multiplyToLen_Type; + static const TypeFunc* _montgomeryMultiply_Type; + static const TypeFunc* _montgomerySquare_Type; + static const TypeFunc* _squareToLen_Type; + static const TypeFunc* _mulAdd_Type; + static const TypeFunc* _bigIntegerShift_Type; + static const TypeFunc* _vectorizedMismatch_Type; + static const TypeFunc* _ghash_processBlocks_Type; + static const TypeFunc* _chacha20Block_Type; + static const TypeFunc* _base64_encodeBlock_Type; + static const TypeFunc* _base64_decodeBlock_Type; + static const TypeFunc* _string_IndexOf_Type; + static const TypeFunc* _poly1305_processBlocks_Type; + static const TypeFunc* _intpoly_montgomeryMult_P256_Type; + static const TypeFunc* _intpoly_assign_Type; + static const TypeFunc* _updateBytesCRC32_Type; + static const TypeFunc* _updateBytesCRC32C_Type; + static const TypeFunc* _updateBytesAdler32_Type; + static const TypeFunc* _osr_end_Type; + static const TypeFunc* _register_finalizer_Type; +#ifdef INCLUDE_JFR + static const TypeFunc* _class_id_load_barrier_Type; +#endif // INCLUDE_JFR +#ifdef INCLUDE_JVMTI + static const TypeFunc* _notify_jvmti_vthread_Type; +#endif // INCLUDE_JVMTI + static const TypeFunc* _dtrace_method_entry_exit_Type; + static const TypeFunc* _dtrace_object_alloc_Type; + // Stub names indexed by sharedStubId static const char *_stub_names[]; @@ -242,95 +310,365 @@ class OptoRuntime : public AllStatic { // Type functions // ====================================================== - static const TypeFunc* new_instance_Type(); // object allocation (slow case) - static const TypeFunc* new_array_Type (); // [a]newarray (slow case) - static const TypeFunc* new_array_nozero_Type (); // [a]newarray (slow case) + static inline const TypeFunc* new_instance_Type() { + assert(_new_instance_Type != nullptr, "should be initialized"); + return _new_instance_Type; + } + + static inline const TypeFunc* new_array_Type() { + assert(_new_array_Type != nullptr, "should be initialized"); + return _new_array_Type; + } + + static inline const TypeFunc* new_array_nozero_Type() { + return new_array_Type(); + } + static const TypeFunc* multianewarray_Type(int ndim); // multianewarray - static const TypeFunc* multianewarray2_Type(); // multianewarray - static const TypeFunc* multianewarray3_Type(); // multianewarray - static const TypeFunc* multianewarray4_Type(); // multianewarray - static const TypeFunc* multianewarray5_Type(); // multianewarray - static const TypeFunc* multianewarrayN_Type(); // multianewarray - static const TypeFunc* complete_monitor_enter_Type(); - static const TypeFunc* complete_monitor_locking_Type(); - static const TypeFunc* complete_monitor_exit_Type(); - static const TypeFunc* monitor_notify_Type(); - static const TypeFunc* monitor_notifyAll_Type(); - static const TypeFunc* uncommon_trap_Type(); - static const TypeFunc* athrow_Type(); - static const TypeFunc* rethrow_Type(); - static const TypeFunc* Math_D_D_Type(); // sin,cos & friends - static const TypeFunc* Math_DD_D_Type(); // mod,pow & friends + + static inline const TypeFunc* multianewarray2_Type() { + assert(_multianewarray2_Type != nullptr, "should be initialized"); + return _multianewarray2_Type; + } + + static inline const TypeFunc* multianewarray3_Type() { + assert(_multianewarray3_Type != nullptr, "should be initialized"); + return _multianewarray3_Type; + } + + static inline const TypeFunc* multianewarray4_Type() { + assert(_multianewarray4_Type != nullptr, "should be initialized"); + return _multianewarray4_Type; + } + + static inline const TypeFunc* multianewarray5_Type() { + assert(_multianewarray5_Type != nullptr, "should be initialized"); + return _multianewarray5_Type; + } + + static inline const TypeFunc* multianewarrayN_Type() { + assert(_multianewarrayN_Type != nullptr, "should be initialized"); + return _multianewarrayN_Type; + } + + static inline const TypeFunc* complete_monitor_enter_Type() { + assert(_complete_monitor_enter_Type != nullptr, "should be initialized"); + return _complete_monitor_enter_Type; + } + + static inline const TypeFunc* complete_monitor_locking_Type() { + return complete_monitor_enter_Type(); + } + + static inline const TypeFunc* complete_monitor_exit_Type() { + assert(_complete_monitor_exit_Type != nullptr, "should be initialized"); + return _complete_monitor_exit_Type; + } + + static inline const TypeFunc* monitor_notify_Type() { + assert(_monitor_notify_Type != nullptr, "should be initialized"); + return _monitor_notify_Type; + } + + static inline const TypeFunc* monitor_notifyAll_Type() { + return monitor_notify_Type(); + } + + static inline const TypeFunc* uncommon_trap_Type() { + assert(_uncommon_trap_Type != nullptr, "should be initialized"); + return _uncommon_trap_Type; + } + + static inline const TypeFunc* athrow_Type() { + assert(_athrow_Type != nullptr, "should be initialized"); + return _athrow_Type; + } + + static inline const TypeFunc* rethrow_Type() { + assert(_rethrow_Type != nullptr, "should be initialized"); + return _rethrow_Type; + } + + static inline const TypeFunc* Math_D_D_Type() { + assert(_Math_D_D_Type != nullptr, "should be initialized"); + return _Math_D_D_Type; + } + + static inline const TypeFunc* Math_DD_D_Type() { + assert(_Math_DD_D_Type != nullptr, "should be initialized"); + return _Math_DD_D_Type; + } + static const TypeFunc* Math_Vector_Vector_Type(uint num_arg, const TypeVect* in_type, const TypeVect* out_type); - static const TypeFunc* modf_Type(); - static const TypeFunc* l2f_Type(); - static const TypeFunc* void_long_Type(); - static const TypeFunc* void_void_Type(); - static const TypeFunc* jfr_write_checkpoint_Type(); + static inline const TypeFunc* modf_Type() { + assert(_modf_Type != nullptr, "should be initialized"); + return _modf_Type; + } - static const TypeFunc* flush_windows_Type(); + static inline const TypeFunc* l2f_Type() { + assert(_l2f_Type != nullptr, "should be initialized"); + return _l2f_Type; + } + + static inline const TypeFunc* void_long_Type() { + assert(_void_long_Type != nullptr, "should be initialized"); + return _void_long_Type; + } + + static inline const TypeFunc* void_void_Type() { + assert(_void_void_Type != nullptr, "should be initialized"); + return _void_void_Type; + } + + static const TypeFunc* jfr_write_checkpoint_Type() { + assert(_jfr_write_checkpoint_Type != nullptr, "should be initialized"); + return _jfr_write_checkpoint_Type; + } + + static const TypeFunc* flush_windows_Type() { + assert(_flush_windows_Type != nullptr, "should be initialized"); + return _flush_windows_Type; + } // arraycopy routine types - static const TypeFunc* fast_arraycopy_Type(); // bit-blasters - static const TypeFunc* checkcast_arraycopy_Type(); - static const TypeFunc* generic_arraycopy_Type(); - static const TypeFunc* slow_arraycopy_Type(); // the full routine + static inline const TypeFunc* fast_arraycopy_Type() { + assert(_fast_arraycopy_Type != nullptr, "should be initialized"); + // This signature is simple: Two base pointers and a size_t. + return _fast_arraycopy_Type; + } - static const TypeFunc* make_setmemory_Type(); + static inline const TypeFunc* checkcast_arraycopy_Type() { + assert(_checkcast_arraycopy_Type != nullptr, "should be initialized"); + // An extension of fast_arraycopy_Type which adds type checking. + return _checkcast_arraycopy_Type; + } - static const TypeFunc* array_fill_Type(); + static inline const TypeFunc* generic_arraycopy_Type() { + assert(_generic_arraycopy_Type != nullptr, "should be initialized"); + // This signature is like System.arraycopy, except that it returns status. + return _generic_arraycopy_Type; + } - static const TypeFunc* array_sort_Type(); - static const TypeFunc* array_partition_Type(); - static const TypeFunc* aescrypt_block_Type(); - static const TypeFunc* cipherBlockChaining_aescrypt_Type(); - static const TypeFunc* electronicCodeBook_aescrypt_Type(); - static const TypeFunc* counterMode_aescrypt_Type(); - static const TypeFunc* galoisCounterMode_aescrypt_Type(); + static inline const TypeFunc* slow_arraycopy_Type() { + assert(_slow_arraycopy_Type != nullptr, "should be initialized"); + // This signature is exactly the same as System.arraycopy. + // There are no intptr_t (int/long) arguments. + return _slow_arraycopy_Type; + } // the full routine - static const TypeFunc* digestBase_implCompress_Type(bool is_sha3); - static const TypeFunc* digestBase_implCompressMB_Type(bool is_sha3); + static inline const TypeFunc* unsafe_setmemory_Type() { + assert(_unsafe_setmemory_Type != nullptr, "should be initialized"); + return _unsafe_setmemory_Type; + } - static const TypeFunc* multiplyToLen_Type(); - static const TypeFunc* montgomeryMultiply_Type(); - static const TypeFunc* montgomerySquare_Type(); + static inline const TypeFunc* array_fill_Type() { + assert(_array_fill_Type != nullptr, "should be initialized"); + return _array_fill_Type; + } - static const TypeFunc* squareToLen_Type(); + static inline const TypeFunc* array_sort_Type() { + assert(_array_sort_Type != nullptr, "should be initialized"); + return _array_sort_Type; + } - static const TypeFunc* mulAdd_Type(); + static inline const TypeFunc* array_partition_Type() { + assert(_array_partition_Type != nullptr, "should be initialized"); + return _array_partition_Type; + } - static const TypeFunc* bigIntegerShift_Type(); + // for aescrypt encrypt/decrypt operations, just three pointers returning void (length is constant) + static inline const TypeFunc* aescrypt_block_Type() { + assert(_aescrypt_block_Type != nullptr, "should be initialized"); + return _aescrypt_block_Type; + } + + // for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int + static inline const TypeFunc* cipherBlockChaining_aescrypt_Type() { + assert(_cipherBlockChaining_aescrypt_Type != nullptr, "should be initialized"); + return _cipherBlockChaining_aescrypt_Type; + } + + // for electronicCodeBook calls of aescrypt encrypt/decrypt, three pointers and a length, returning int + static inline const TypeFunc* electronicCodeBook_aescrypt_Type() { + assert(_electronicCodeBook_aescrypt_Type != nullptr, "should be initialized"); + return _electronicCodeBook_aescrypt_Type; + } + + //for counterMode calls of aescrypt encrypt/decrypt, four pointers and a length, returning int + static inline const TypeFunc* counterMode_aescrypt_Type() { + assert(_counterMode_aescrypt_Type != nullptr, "should be initialized"); + return _counterMode_aescrypt_Type; + } + + //for counterMode calls of aescrypt encrypt/decrypt, four pointers and a length, returning int + static inline const TypeFunc* galoisCounterMode_aescrypt_Type() { + assert(_galoisCounterMode_aescrypt_Type != nullptr, "should be initialized"); + return _galoisCounterMode_aescrypt_Type; + } + + /* + * void implCompress(byte[] buf, int ofs) + */ + static inline const TypeFunc* digestBase_implCompress_Type(bool is_sha3) { + assert((_digestBase_implCompress_with_sha3_Type != nullptr) && + (_digestBase_implCompress_without_sha3_Type != nullptr), "should be initialized"); + return is_sha3 ? _digestBase_implCompress_with_sha3_Type : _digestBase_implCompress_without_sha3_Type; + } + + /* + * int implCompressMultiBlock(byte[] b, int ofs, int limit) + */ + static inline const TypeFunc* digestBase_implCompressMB_Type(bool is_sha3) { + assert((_digestBase_implCompressMB_with_sha3_Type != nullptr) && + (_digestBase_implCompressMB_without_sha3_Type != nullptr), "should be initialized"); + return is_sha3 ? _digestBase_implCompressMB_with_sha3_Type : _digestBase_implCompressMB_without_sha3_Type; + } + + static inline const TypeFunc* multiplyToLen_Type() { + assert(_multiplyToLen_Type != nullptr, "should be initialized"); + return _multiplyToLen_Type; + } + + static inline const TypeFunc* montgomeryMultiply_Type() { + assert(_montgomeryMultiply_Type != nullptr, "should be initialized"); + return _montgomeryMultiply_Type; + } + + static inline const TypeFunc* montgomerySquare_Type() { + assert(_montgomerySquare_Type != nullptr, "should be initialized"); + return _montgomerySquare_Type; + } + + static inline const TypeFunc* squareToLen_Type() { + assert(_squareToLen_Type != nullptr, "should be initialized"); + return _squareToLen_Type; + } + + // for mulAdd calls, 2 pointers and 3 ints, returning int + static inline const TypeFunc* mulAdd_Type() { + assert(_mulAdd_Type != nullptr, "should be initialized"); + return _mulAdd_Type; + } + + static inline const TypeFunc* bigIntegerShift_Type() { + assert(_bigIntegerShift_Type != nullptr, "should be initialized"); + return _bigIntegerShift_Type; + } + + static inline const TypeFunc* vectorizedMismatch_Type() { + assert(_vectorizedMismatch_Type != nullptr, "should be initialized"); + return _vectorizedMismatch_Type; + } - static const TypeFunc* vectorizedMismatch_Type(); + // GHASH block processing + static inline const TypeFunc* ghash_processBlocks_Type() { + assert(_ghash_processBlocks_Type != nullptr, "should be initialized"); + return _ghash_processBlocks_Type; + } + + // ChaCha20 Block function + static inline const TypeFunc* chacha20Block_Type() { + assert(_chacha20Block_Type != nullptr, "should be initialized"); + return _chacha20Block_Type; + } + + // Base64 encode function + static inline const TypeFunc* base64_encodeBlock_Type() { + assert(_base64_encodeBlock_Type != nullptr, "should be initialized"); + return _base64_encodeBlock_Type; + } + + // Base64 decode function + static inline const TypeFunc* base64_decodeBlock_Type() { + assert(_base64_decodeBlock_Type != nullptr, "should be initialized"); + return _base64_decodeBlock_Type; + } - static const TypeFunc* ghash_processBlocks_Type(); - static const TypeFunc* chacha20Block_Type(); - static const TypeFunc* base64_encodeBlock_Type(); - static const TypeFunc* base64_decodeBlock_Type(); - static const TypeFunc* string_IndexOf_Type(); - static const TypeFunc* poly1305_processBlocks_Type(); - static const TypeFunc* intpoly_montgomeryMult_P256_Type(); - static const TypeFunc* intpoly_assign_Type(); + // String IndexOf function + static inline const TypeFunc* string_IndexOf_Type() { + assert(_string_IndexOf_Type != nullptr, "should be initialized"); + return _string_IndexOf_Type; + } + + // Poly1305 processMultipleBlocks function + static inline const TypeFunc* poly1305_processBlocks_Type() { + assert(_poly1305_processBlocks_Type != nullptr, "should be initialized"); + return _poly1305_processBlocks_Type; + } - static const TypeFunc* updateBytesCRC32_Type(); - static const TypeFunc* updateBytesCRC32C_Type(); + // MontgomeryIntegerPolynomialP256 multiply function + static inline const TypeFunc* intpoly_montgomeryMult_P256_Type() { + assert(_intpoly_montgomeryMult_P256_Type != nullptr, "should be initialized"); + return _intpoly_montgomeryMult_P256_Type; + } + + // IntegerPolynomial constant time assignment function + static inline const TypeFunc* intpoly_assign_Type() { + assert(_intpoly_assign_Type != nullptr, "should be initialized"); + return _intpoly_assign_Type; + } + + /** + * int updateBytesCRC32(int crc, byte* b, int len) + */ + static inline const TypeFunc* updateBytesCRC32_Type() { + assert(_updateBytesCRC32_Type != nullptr, "should be initialized"); + return _updateBytesCRC32_Type; + } + + /** + * int updateBytesCRC32C(int crc, byte* buf, int len, int* table) + */ + static inline const TypeFunc* updateBytesCRC32C_Type() { + assert(_updateBytesCRC32C_Type != nullptr, "should be initialized"); + return _updateBytesCRC32C_Type; + } + + /** + * int updateBytesAdler32(int adler, bytes* b, int off, int len) + */ + static inline const TypeFunc* updateBytesAdler32_Type() { + assert(_updateBytesAdler32_Type != nullptr, "should be initialized"); + return _updateBytesAdler32_Type; + } - static const TypeFunc* updateBytesAdler32_Type(); // leaf on stack replacement interpreter accessor types - static const TypeFunc* osr_end_Type(); + static inline const TypeFunc* osr_end_Type() { + assert(_osr_end_Type != nullptr, "should be initialized"); + return _osr_end_Type; + } - static const TypeFunc* register_finalizer_Type(); + static inline const TypeFunc* register_finalizer_Type() { + assert(_register_finalizer_Type != nullptr, "should be initialized"); + return _register_finalizer_Type; + } + +#ifdef INCLUDE_JFR + static inline const TypeFunc* class_id_load_barrier_Type() { + assert(_class_id_load_barrier_Type != nullptr, "should be initialized"); + return _class_id_load_barrier_Type; + } +#endif // INCLUDE_JFR - JFR_ONLY(static const TypeFunc* class_id_load_barrier_Type();) #if INCLUDE_JVMTI - static const TypeFunc* notify_jvmti_vthread_Type(); + static inline const TypeFunc* notify_jvmti_vthread_Type() { + assert(_notify_jvmti_vthread_Type != nullptr, "should be initialized"); + return _notify_jvmti_vthread_Type; + } #endif - // Dtrace support - static const TypeFunc* dtrace_method_entry_exit_Type(); - static const TypeFunc* dtrace_object_alloc_Type(); + // Dtrace support. entry and exit probes have the same signature + static inline const TypeFunc* dtrace_method_entry_exit_Type() { + assert(_dtrace_method_entry_exit_Type != nullptr, "should be initialized"); + return _dtrace_method_entry_exit_Type; + } + + static inline const TypeFunc* dtrace_object_alloc_Type() { + assert(_dtrace_object_alloc_Type != nullptr, "should be initialized"); + return _dtrace_object_alloc_Type; + } private: static NamedCounter * volatile _named_counters; @@ -343,6 +681,7 @@ class OptoRuntime : public AllStatic { // dumps all the named counters static void print_named_counters(); + static void initialize_types(); }; #endif // SHARE_OPTO_RUNTIME_HPP diff --git a/src/hotspot/share/opto/type.cpp b/src/hotspot/share/opto/type.cpp index 2424daf81e3e7..ff39a58c81217 100644 --- a/src/hotspot/share/opto/type.cpp +++ b/src/hotspot/share/opto/type.cpp @@ -35,9 +35,12 @@ #include "oops/instanceMirrorKlass.hpp" #include "oops/objArrayKlass.hpp" #include "oops/typeArrayKlass.hpp" +#include "opto/callnode.hpp" +#include "opto/arraycopynode.hpp" #include "opto/matcher.hpp" #include "opto/node.hpp" #include "opto/opcodes.hpp" +#include "opto/runtime.hpp" #include "opto/type.hpp" #include "utilities/checkedCast.hpp" #include "utilities/powerOfTwo.hpp" @@ -711,6 +714,10 @@ void Type::Initialize_shared(Compile* current) { mreg2type[Op_VecY] = TypeVect::VECTY; mreg2type[Op_VecZ] = TypeVect::VECTZ; + LockNode::initialize_lock_Type(); + ArrayCopyNode::initialize_arraycopy_Type(); + OptoRuntime::initialize_types(); + // Restore working type arena. current->set_type_arena(save); current->set_type_dict(nullptr); From 8460072f9ddcec5d1f86e3c4de3d1457771b805c Mon Sep 17 00:00:00 2001 From: Gui Cao Date: Fri, 17 Jan 2025 11:31:48 +0000 Subject: [PATCH 35/47] 8342881: RISC-V: secondary_super_cache does not scale well: C1 and interpreter Reviewed-by: fyang, fjiang --- src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp | 8 +- .../cpu/riscv/macroAssembler_riscv.cpp | 275 +++++++++++++++--- .../cpu/riscv/macroAssembler_riscv.hpp | 58 +++- src/hotspot/cpu/riscv/riscv.ad | 56 ++-- src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 28 +- 5 files changed, 351 insertions(+), 74 deletions(-) diff --git a/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp b/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp index 717f10ca30d57..9142772f3bd5e 100644 --- a/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp @@ -883,7 +883,13 @@ OopMapSet* Runtime1::generate_code_for(C1StubId id, StubAssembler* sasm) { __ ld(x10, Address(sp, (sup_k_off) * VMRegImpl::stack_slot_size)); // super klass Label miss; - __ check_klass_subtype_slow_path(x14, x10, x12, x15, nullptr, &miss); + __ check_klass_subtype_slow_path(x14, /*sub_klass*/ + x10, /*super_klass*/ + x12, /*tmp1_reg*/ + x15, /*tmp2_reg*/ + nullptr, /*L_success*/ + &miss /*L_failure*/); + // Need extras for table lookup: x7, x11, x13 // fallthrough on success: __ mv(t0, 1); diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 24504472509d1..40b7573aaca68 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -2869,6 +2869,24 @@ void MacroAssembler::revb(Register Rd, Register Rs, Register tmp1, Register tmp2 orr(Rd, tmp1, Rd); } +// rotate right with shift bits +void MacroAssembler::ror(Register dst, Register src, Register shift, Register tmp) +{ + if (UseZbb) { + rorr(dst, src, shift); + return; + } + + assert_different_registers(dst, tmp); + assert_different_registers(src, tmp); + + mv(tmp, 64); + sub(tmp, tmp, shift); + sll(tmp, src, tmp); + srl(dst, src, shift); + orr(dst, dst, tmp); +} + // rotate right with shift bits void MacroAssembler::ror(Register dst, Register src, uint32_t shift, Register tmp) { @@ -4067,12 +4085,10 @@ void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, Label* L_failure, Label* L_slow_path, Register super_check_offset) { - assert_different_registers(sub_klass, super_klass, tmp_reg); - bool must_load_sco = (super_check_offset == noreg); + assert_different_registers(sub_klass, super_klass, tmp_reg, super_check_offset); + bool must_load_sco = !super_check_offset->is_valid(); if (must_load_sco) { assert(tmp_reg != noreg, "supply either a temp or a register offset"); - } else { - assert_different_registers(sub_klass, super_klass, super_check_offset); } Label L_fallthrough; @@ -4108,6 +4124,7 @@ void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, add(t0, sub_klass, super_check_offset); Address super_check_addr(t0); ld(t0, super_check_addr); // load displayed supertype + beq(super_klass, t0, *L_success); // This check has worked decisively for primary supers. // Secondary supers are sought in the super_cache ('super_cache_addr'). @@ -4120,7 +4137,6 @@ void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, // So if it was a primary super, we can just fail immediately. // Otherwise, it's the slow path for us (no success at this point). - beq(super_klass, t0, *L_success); mv(t1, sc_offset); if (L_failure == &L_fallthrough) { beq(super_check_offset, t1, *L_slow_path); @@ -4149,12 +4165,13 @@ void MacroAssembler::repne_scan(Register addr, Register value, Register count, bind(Lexit); } -void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass, - Register super_klass, - Register tmp1_reg, - Register tmp2_reg, - Label* L_success, - Label* L_failure) { +void MacroAssembler::check_klass_subtype_slow_path_linear(Register sub_klass, + Register super_klass, + Register tmp1_reg, + Register tmp2_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes) { assert_different_registers(sub_klass, super_klass, tmp1_reg); if (tmp2_reg != noreg) { assert_different_registers(sub_klass, super_klass, tmp1_reg, tmp2_reg, t0); @@ -4228,7 +4245,9 @@ void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass, bne(t1, t0, *L_failure); // Success. Cache the super we found an proceed in triumph. - sd(super_klass, super_cache_addr); + if (UseSecondarySupersCache) { + sd(super_klass, super_cache_addr); + } if (L_success != &L_fallthrough) { j(*L_success); @@ -4269,6 +4288,103 @@ void MacroAssembler::population_count(Register dst, Register src, } } +// If Register r is invalid, remove a new register from +// available_regs, and add new register to regs_to_push. +Register MacroAssembler::allocate_if_noreg(Register r, + RegSetIterator &available_regs, + RegSet ®s_to_push) { + if (!r->is_valid()) { + r = *available_regs++; + regs_to_push += r; + } + return r; +} + +// check_klass_subtype_slow_path_table() looks for super_klass in the +// hash table belonging to super_klass, branching to L_success or +// L_failure as appropriate. This is essentially a shim which +// allocates registers as necessary then calls +// lookup_secondary_supers_table() to do the work. Any of the tmp +// regs may be noreg, in which case this logic will chooses some +// registers push and pop them from the stack. +void MacroAssembler::check_klass_subtype_slow_path_table(Register sub_klass, + Register super_klass, + Register tmp1_reg, + Register tmp2_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes) { + RegSet tmps = RegSet::of(tmp1_reg, tmp2_reg); + + assert_different_registers(sub_klass, super_klass, tmp1_reg, tmp2_reg); + + Label L_fallthrough; + int label_nulls = 0; + if (L_success == nullptr) { L_success = &L_fallthrough; label_nulls++; } + if (L_failure == nullptr) { L_failure = &L_fallthrough; label_nulls++; } + assert(label_nulls <= 1, "at most one null in the batch"); + + BLOCK_COMMENT("check_klass_subtype_slow_path"); + + RegSet caller_save_regs = RegSet::of(x7) + RegSet::range(x10, x17) + RegSet::range(x28, x31); + RegSetIterator available_regs = (caller_save_regs - tmps - sub_klass - super_klass).begin(); + + RegSet pushed_regs; + + tmp1_reg = allocate_if_noreg(tmp1_reg, available_regs, pushed_regs); + tmp2_reg = allocate_if_noreg(tmp2_reg, available_regs, pushed_regs); + + Register tmp3_reg = noreg, tmp4_reg = noreg, result_reg = noreg; + + tmp3_reg = allocate_if_noreg(tmp3_reg, available_regs, pushed_regs); + tmp4_reg = allocate_if_noreg(tmp4_reg, available_regs, pushed_regs); + result_reg = allocate_if_noreg(result_reg, available_regs, pushed_regs); + + push_reg(pushed_regs, sp); + + lookup_secondary_supers_table_var(sub_klass, + super_klass, + result_reg, + tmp1_reg, tmp2_reg, tmp3_reg, + tmp4_reg, nullptr); + + // Move the result to t1 as we are about to unspill the tmp registers. + mv(t1, result_reg); + + // Unspill the tmp. registers: + pop_reg(pushed_regs, sp); + + // NB! Callers may assume that, when set_cond_codes is true, this + // code sets tmp2_reg to a nonzero value. + if (set_cond_codes) { + mv(tmp2_reg, 1); + } + + bnez(t1, *L_failure); + + if (L_success != &L_fallthrough) { + j(*L_success); + } + + bind(L_fallthrough); +} + +void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass, + Register super_klass, + Register tmp1_reg, + Register tmp2_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes) { + if (UseSecondarySupersTable) { + check_klass_subtype_slow_path_table + (sub_klass, super_klass, tmp1_reg, tmp2_reg, L_success, L_failure, set_cond_codes); + } else { + check_klass_subtype_slow_path_linear + (sub_klass, super_klass, tmp1_reg, tmp2_reg, L_success, L_failure, set_cond_codes); + } +} + // Ensure that the inline code and the stub are using the same registers // as we need to call the stub from inline code when there is a collision // in the hashed lookup in the secondary supers array. @@ -4284,17 +4400,16 @@ do { (r_bitmap == x16 || r_bitmap == noreg), "registers must match riscv.ad"); \ } while(0) -// Return true: we succeeded in generating this code -bool MacroAssembler::lookup_secondary_supers_table(Register r_sub_klass, - Register r_super_klass, - Register result, - Register tmp1, - Register tmp2, - Register tmp3, - Register tmp4, - u1 super_klass_slot, - bool stub_is_near) { - assert_different_registers(r_sub_klass, r_super_klass, result, tmp1, tmp2, tmp3, tmp4, t0); +bool MacroAssembler::lookup_secondary_supers_table_const(Register r_sub_klass, + Register r_super_klass, + Register result, + Register tmp1, + Register tmp2, + Register tmp3, + Register tmp4, + u1 super_klass_slot, + bool stub_is_near) { + assert_different_registers(r_sub_klass, r_super_klass, result, tmp1, tmp2, tmp3, tmp4, t0, t1); Label L_fallthrough; @@ -4369,6 +4484,98 @@ bool MacroAssembler::lookup_secondary_supers_table(Register r_sub_klass, return true; } +// At runtime, return 0 in result if r_super_klass is a superclass of +// r_sub_klass, otherwise return nonzero. Use this version of +// lookup_secondary_supers_table() if you don't know ahead of time +// which superclass will be searched for. Used by interpreter and +// runtime stubs. It is larger and has somewhat greater latency than +// the version above, which takes a constant super_klass_slot. +void MacroAssembler::lookup_secondary_supers_table_var(Register r_sub_klass, + Register r_super_klass, + Register result, + Register tmp1, + Register tmp2, + Register tmp3, + Register tmp4, + Label *L_success) { + assert_different_registers(r_sub_klass, r_super_klass, result, tmp1, tmp2, tmp3, tmp4, t0, t1); + + Label L_fallthrough; + + BLOCK_COMMENT("lookup_secondary_supers_table {"); + + const Register + r_array_index = tmp3, + r_bitmap = tmp4, + slot = t1; + + lbu(slot, Address(r_super_klass, Klass::hash_slot_offset())); + + // Make sure that result is nonzero if the test below misses. + mv(result, 1); + + ld(r_bitmap, Address(r_sub_klass, Klass::secondary_supers_bitmap_offset())); + + // First check the bitmap to see if super_klass might be present. If + // the bit is zero, we are certain that super_klass is not one of + // the secondary supers. + + // This next instruction is equivalent to: + // mv(tmp_reg, (u1)(Klass::SECONDARY_SUPERS_TABLE_SIZE - 1)); + // sub(r_array_index, slot, tmp_reg); + xori(r_array_index, slot, (u1)(Klass::SECONDARY_SUPERS_TABLE_SIZE - 1)); + sll(r_array_index, r_bitmap, r_array_index); + test_bit(t0, r_array_index, Klass::SECONDARY_SUPERS_TABLE_SIZE - 1); + beqz(t0, L_fallthrough); + + // Get the first array index that can contain super_klass into r_array_index. + population_count(r_array_index, r_array_index, tmp1, tmp2); + + // NB! r_array_index is off by 1. It is compensated by keeping r_array_base off by 1 word. + + const Register + r_array_base = tmp1, + r_array_length = tmp2; + + // The value i in r_array_index is >= 1, so even though r_array_base + // points to the length, we don't need to adjust it to point to the data. + assert(Array::base_offset_in_bytes() == wordSize, "Adjust this code"); + assert(Array::length_offset_in_bytes() == 0, "Adjust this code"); + + // We will consult the secondary-super array. + ld(r_array_base, Address(r_sub_klass, in_bytes(Klass::secondary_supers_offset()))); + + shadd(result, r_array_index, r_array_base, result, LogBytesPerWord); + ld(result, Address(result)); + xorr(result, result, r_super_klass); + beqz(result, L_success ? *L_success : L_fallthrough); // Found a match + + // Is there another entry to check? Consult the bitmap. + ror(r_bitmap, r_bitmap, slot); + test_bit(t0, r_bitmap, 1); + beqz(t0, L_fallthrough); + + // The slot we just inspected is at secondary_supers[r_array_index - 1]. + // The next slot to be inspected, by the logic we're about to call, + // is secondary_supers[r_array_index]. Bits 0 and 1 in the bitmap + // have been checked. + lookup_secondary_supers_table_slow_path(r_super_klass, r_array_base, r_array_index, + r_bitmap, result, r_array_length, false /*is_stub*/); + + BLOCK_COMMENT("} lookup_secondary_supers_table"); + + bind(L_fallthrough); + + if (VerifySecondarySupers) { + verify_secondary_supers_table(r_sub_klass, r_super_klass, + result, tmp1, tmp2, tmp3); + } + + if (L_success) { + beqz(result, *L_success); + } +} + // Called by code generated by check_klass_subtype_slow_path // above. This is called when there is a collision in the hashed // lookup in the secondary supers array. @@ -4377,15 +4584,18 @@ void MacroAssembler::lookup_secondary_supers_table_slow_path(Register r_super_kl Register r_array_index, Register r_bitmap, Register result, - Register tmp1) { - assert_different_registers(r_super_klass, r_array_base, r_array_index, r_bitmap, tmp1, result, t0); + Register tmp, + bool is_stub) { + assert_different_registers(r_super_klass, r_array_base, r_array_index, r_bitmap, tmp, result, t0); const Register - r_array_length = tmp1, + r_array_length = tmp, r_sub_klass = noreg; // unused - LOOKUP_SECONDARY_SUPERS_TABLE_REGISTERS(r_super_klass, r_array_base, r_array_length, - r_array_index, r_sub_klass, result, r_bitmap); + if (is_stub) { + LOOKUP_SECONDARY_SUPERS_TABLE_REGISTERS(r_super_klass, r_array_base, r_array_length, + r_array_index, r_sub_klass, result, r_bitmap); + } Label L_matched, L_fallthrough, L_bitmap_full; @@ -4412,8 +4622,10 @@ void MacroAssembler::lookup_secondary_supers_table_slow_path(Register r_super_kl { // This is conventional linear probing, but instead of terminating // when a null entry is found in the table, we maintain a bitmap // in which a 0 indicates missing entries. - // The check above guarantees there are 0s in the bitmap, so the loop - // eventually terminates. + // As long as the bitmap is not completely full, + // array_length == popcount(bitmap). The array_length check above + // guarantees there are 0s in the bitmap, so the loop eventually + // terminates. Label L_loop; bind(L_loop); @@ -4465,9 +4677,6 @@ void MacroAssembler::verify_secondary_supers_table(Register r_sub_klass, r_array_index = noreg, // unused r_bitmap = noreg; // unused - LOOKUP_SECONDARY_SUPERS_TABLE_REGISTERS(r_super_klass, r_array_base, r_array_length, - r_array_index, r_sub_klass, result, r_bitmap); - BLOCK_COMMENT("verify_secondary_supers_table {"); // We will consult the secondary-super array. diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 04b95ba355b1e..06aa5537cc1fc 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -323,21 +323,55 @@ class MacroAssembler: public Assembler { Register tmp1_reg, Register tmp2_reg, Label* L_success, - Label* L_failure); + Label* L_failure, + bool set_cond_codes = false); + + void check_klass_subtype_slow_path_linear(Register sub_klass, + Register super_klass, + Register tmp1_reg, + Register tmp2_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes = false); + + void check_klass_subtype_slow_path_table(Register sub_klass, + Register super_klass, + Register tmp1_reg, + Register tmp2_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes = false); + + // If r is valid, return r. + // If r is invalid, remove a register r2 from available_regs, add r2 + // to regs_to_push, then return r2. + Register allocate_if_noreg(const Register r, + RegSetIterator &available_regs, + RegSet ®s_to_push); + + // Secondary subtype checking + void lookup_secondary_supers_table_var(Register sub_klass, + Register r_super_klass, + Register result, + Register tmp1, + Register tmp2, + Register tmp3, + Register tmp4, + Label *L_success); void population_count(Register dst, Register src, Register tmp1, Register tmp2); // As above, but with a constant super_klass. // The result is in Register result, not the condition codes. - bool lookup_secondary_supers_table(Register r_sub_klass, - Register r_super_klass, - Register result, - Register tmp1, - Register tmp2, - Register tmp3, - Register tmp4, - u1 super_klass_slot, - bool stub_is_near = false); + bool lookup_secondary_supers_table_const(Register r_sub_klass, + Register r_super_klass, + Register result, + Register tmp1, + Register tmp2, + Register tmp3, + Register tmp4, + u1 super_klass_slot, + bool stub_is_near = false); void verify_secondary_supers_table(Register r_sub_klass, Register r_super_klass, @@ -351,7 +385,8 @@ class MacroAssembler: public Assembler { Register r_array_index, Register r_bitmap, Register result, - Register tmp1); + Register tmp, + bool is_stub = true); void check_klass_subtype(Register sub_klass, Register super_klass, @@ -926,6 +961,7 @@ class MacroAssembler: public Assembler { void revbw(Register Rd, Register Rs, Register tmp1 = t0, Register tmp2= t1); // reverse bytes in lower word, sign-extend void revb(Register Rd, Register Rs, Register tmp1 = t0, Register tmp2 = t1); // reverse bytes in doubleword + void ror(Register dst, Register src, Register shift, Register tmp = t0); void ror(Register dst, Register src, uint32_t shift, Register tmp = t0); void rolw(Register dst, Register src, uint32_t shift, Register tmp = t0); diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index a9b48fd18c406..5d50fe55cd604 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -2364,7 +2364,7 @@ encode %{ Label miss; Label done; __ check_klass_subtype_slow_path(sub_reg, super_reg, temp_reg, result_reg, - nullptr, &miss); + nullptr, &miss, /*set_cond_codes*/ true); if ($primary) { __ mv(result_reg, zr); } else { @@ -10019,10 +10019,11 @@ instruct CallLeafNoFPDirect(method meth) instruct partialSubtypeCheck(iRegP_R15 result, iRegP_R14 sub, iRegP_R10 super, iRegP_R12 tmp, rFlagsReg cr) %{ + predicate(!UseSecondarySupersTable); match(Set result (PartialSubtypeCheck sub super)); effect(KILL tmp, KILL cr); - ins_cost(11 * DEFAULT_COST); + ins_cost(20 * DEFAULT_COST); format %{ "partialSubtypeCheck $result, $sub, $super\t#@partialSubtypeCheck" %} ins_encode(riscv_enc_partial_subtype_check(sub, super, tmp, result)); @@ -10032,6 +10033,33 @@ instruct partialSubtypeCheck(iRegP_R15 result, iRegP_R14 sub, iRegP_R10 super, i ins_pipe(pipe_class_memory); %} +// Two versions of partialSubtypeCheck, both used when we need to +// search for a super class in the secondary supers array. The first +// is used when we don't know _a priori_ the class being searched +// for. The second, far more common, is used when we do know: this is +// used for instanceof, checkcast, and any case where C2 can determine +// it by constant propagation. + +instruct partialSubtypeCheckVarSuper(iRegP_R14 sub, iRegP_R10 super, iRegP_R15 result, + iRegP_R11 tmpR11, iRegP_R12 tmpR12, iRegP_R13 tmpR13, + iRegP_R16 tmpR16, rFlagsReg cr) +%{ + predicate(UseSecondarySupersTable); + match(Set result (PartialSubtypeCheck sub super)); + effect(TEMP tmpR11, TEMP tmpR12, TEMP tmpR13, TEMP tmpR16, KILL cr); + + ins_cost(10 * DEFAULT_COST); // slightly larger than the next version + format %{ "partialSubtypeCheck $result, $sub, $super" %} + + ins_encode %{ + __ lookup_secondary_supers_table_var($sub$$Register, $super$$Register, $result$$Register, + $tmpR11$$Register, $tmpR12$$Register, $tmpR13$$Register, + $tmpR16$$Register, nullptr /*L_success*/); + %} + + ins_pipe(pipe_class_memory); +%} + instruct partialSubtypeCheckConstSuper(iRegP_R14 sub, iRegP_R10 super_reg, immP super_con, iRegP_R15 result, iRegP_R11 tmpR11, iRegP_R12 tmpR12, iRegP_R13 tmpR13, iRegP_R16 tmpR16, rFlagsReg cr) %{ @@ -10039,16 +10067,16 @@ instruct partialSubtypeCheckConstSuper(iRegP_R14 sub, iRegP_R10 super_reg, immP match(Set result (PartialSubtypeCheck sub (Binary super_reg super_con))); effect(TEMP tmpR11, TEMP tmpR12, TEMP tmpR13, TEMP tmpR16, KILL cr); - ins_cost(7 * DEFAULT_COST); // needs to be less than competing nodes + ins_cost(5 * DEFAULT_COST); // needs to be less than competing nodes format %{ "partialSubtypeCheck $result, $sub, $super_reg, $super_con" %} ins_encode %{ bool success = false; u1 super_klass_slot = ((Klass*)$super_con$$constant)->hash_slot(); if (InlineSecondarySupersTest) { - success = __ lookup_secondary_supers_table($sub$$Register, $super_reg$$Register, $result$$Register, - $tmpR11$$Register, $tmpR12$$Register, $tmpR13$$Register, - $tmpR16$$Register, super_klass_slot); + success = __ lookup_secondary_supers_table_const($sub$$Register, $super_reg$$Register, $result$$Register, + $tmpR11$$Register, $tmpR12$$Register, $tmpR13$$Register, + $tmpR16$$Register, super_klass_slot); } else { address call = __ reloc_call(RuntimeAddress(StubRoutines::lookup_secondary_supers_table_stub(super_klass_slot))); success = (call != nullptr); @@ -10062,22 +10090,6 @@ instruct partialSubtypeCheckConstSuper(iRegP_R14 sub, iRegP_R10 super_reg, immP ins_pipe(pipe_class_memory); %} -instruct partialSubtypeCheckVsZero(iRegP_R15 result, iRegP_R14 sub, iRegP_R10 super, iRegP_R12 tmp, - immP0 zero, rFlagsReg cr) -%{ - match(Set cr (CmpP (PartialSubtypeCheck sub super) zero)); - effect(KILL tmp, KILL result); - - ins_cost(11 * DEFAULT_COST); - format %{ "partialSubtypeCheck $result, $sub, $super == 0\t#@partialSubtypeCheckVsZero" %} - - ins_encode(riscv_enc_partial_subtype_check(sub, super, tmp, result)); - - opcode(0x0); // Don't zero result reg on hit - - ins_pipe(pipe_class_memory); -%} - instruct string_compareU(iRegP_R11 str1, iRegI_R12 cnt1, iRegP_R13 str2, iRegI_R14 cnt2, iRegI_R10 result, iRegP_R28 tmp1, iRegL_R29 tmp2, iRegL_R30 tmp3, rFlagsReg cr) %{ diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index 439162f01f105..508706827aba3 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -1454,6 +1454,9 @@ class StubGenerator: public StubCodeGenerator { void generate_type_check(Register sub_klass, Register super_check_offset, Register super_klass, + Register result, + Register tmp1, + Register tmp2, Label& L_success) { assert_different_registers(sub_klass, super_check_offset, super_klass); @@ -1462,7 +1465,7 @@ class StubGenerator: public StubCodeGenerator { Label L_miss; __ check_klass_subtype_fast_path(sub_klass, super_klass, noreg, &L_success, &L_miss, nullptr, super_check_offset); - __ check_klass_subtype_slow_path(sub_klass, super_klass, noreg, noreg, &L_success, nullptr); + __ check_klass_subtype_slow_path(sub_klass, super_klass, tmp1, tmp2, &L_success, nullptr); // Fall through on failure! __ BIND(L_miss); @@ -1591,7 +1594,18 @@ class StubGenerator: public StubCodeGenerator { __ beqz(copied_oop, L_store_element); __ load_klass(r9_klass, copied_oop);// query the object klass - generate_type_check(r9_klass, ckoff, ckval, L_store_element); + + BLOCK_COMMENT("type_check:"); + generate_type_check(r9_klass, /*sub_klass*/ + ckoff, /*super_check_offset*/ + ckval, /*super_klass*/ + x10, /*result*/ + gct1, /*tmp1*/ + gct2, /*tmp2*/ + L_store_element); + + // Fall through on failure! + // ======== end loop ======== // It was a real error; we must depend on the caller to finish the job. @@ -1600,7 +1614,7 @@ class StubGenerator: public StubCodeGenerator { // their number to the caller. __ sub(count, count_save, count); // K = partially copied oop count - __ xori(count, count, -1); // report (-1^K) to caller + __ xori(count, count, -1); // report (-1^K) to caller __ beqz(count, L_done_pop); __ BIND(L_do_card_marks); @@ -1965,7 +1979,7 @@ class StubGenerator: public StubCodeGenerator { __ lwu(sco_temp, Address(dst_klass, sco_offset)); // Smashes t0, t1 - generate_type_check(scratch_src_klass, sco_temp, dst_klass, L_plain_copy); + generate_type_check(scratch_src_klass, sco_temp, dst_klass, noreg, noreg, noreg, L_plain_copy); // Fetch destination element klass from the ObjArrayKlass header. int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset()); @@ -3006,9 +3020,9 @@ class StubGenerator: public StubCodeGenerator { Label L_success; __ enter(); - __ lookup_secondary_supers_table(r_sub_klass, r_super_klass, result, - r_array_base, r_array_length, r_array_index, - r_bitmap, super_klass_index, /*stub_is_near*/true); + __ lookup_secondary_supers_table_const(r_sub_klass, r_super_klass, result, + r_array_base, r_array_length, r_array_index, + r_bitmap, super_klass_index, /*stub_is_near*/ true); __ leave(); __ ret(); From 3ab521e1a1245e578e37d0638c659588e782ec50 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Fri, 17 Jan 2025 12:16:44 +0000 Subject: [PATCH 36/47] 8347924: Replace SIZE_FORMAT in memory and metaspace Reviewed-by: jsjolen, matsaave --- src/hotspot/share/memory/arena.cpp | 5 +-- .../share/memory/classLoaderMetaspace.cpp | 6 +-- src/hotspot/share/memory/guardedMemory.cpp | 4 +- src/hotspot/share/memory/memoryReserver.cpp | 15 ++++---- src/hotspot/share/memory/metaspace.cpp | 38 +++++++++---------- .../share/memory/metaspace/binList.hpp | 6 +-- .../share/memory/metaspace/blockTree.cpp | 4 +- .../share/memory/metaspace/blockTree.hpp | 6 +-- .../share/memory/metaspace/chunkManager.cpp | 8 ++-- .../share/memory/metaspace/chunklevel.cpp | 4 +- .../share/memory/metaspace/commitMask.cpp | 6 +-- .../share/memory/metaspace/freeChunkList.cpp | 4 +- .../share/memory/metaspace/metablock.hpp | 4 +- .../share/memory/metaspace/metachunk.cpp | 12 +++--- .../share/memory/metaspace/metachunk.hpp | 4 +- .../share/memory/metaspace/metaspaceArena.cpp | 20 +++++----- .../memory/metaspace/metaspaceCommon.cpp | 4 +- .../memory/metaspace/metaspaceCommon.hpp | 6 +-- .../memory/metaspace/metaspaceSettings.cpp | 8 ++-- .../memory/metaspace/metaspaceStatistics.cpp | 2 +- .../share/memory/metaspace/testHelpers.cpp | 6 +-- .../memory/metaspace/virtualSpaceList.cpp | 4 +- .../memory/metaspace/virtualSpaceNode.cpp | 14 +++---- src/hotspot/share/memory/resourceArea.hpp | 4 +- src/hotspot/share/memory/universe.cpp | 4 +- src/hotspot/share/memory/virtualspace.cpp | 8 ++-- 26 files changed, 102 insertions(+), 104 deletions(-) diff --git a/src/hotspot/share/memory/arena.cpp b/src/hotspot/share/memory/arena.cpp index 51d7cda9c61ec..22cc36008fc1c 100644 --- a/src/hotspot/share/memory/arena.cpp +++ b/src/hotspot/share/memory/arena.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -142,8 +142,7 @@ Chunk* ChunkPool::allocate_chunk(size_t length, AllocFailType alloc_failmode) { // - the payload size (length) must be aligned to 64-bit, which takes care of 64-bit // aligning (D) - assert(is_aligned(length, ARENA_AMALLOC_ALIGNMENT), "chunk payload length misaligned: " - SIZE_FORMAT ".", length); + assert(is_aligned(length, ARENA_AMALLOC_ALIGNMENT), "chunk payload length misaligned: %zu.", length); // Try to reuse a freed chunk from the pool ChunkPool* pool = ChunkPool::get_pool_for_size(length); Chunk* chunk = nullptr; diff --git a/src/hotspot/share/memory/classLoaderMetaspace.cpp b/src/hotspot/share/memory/classLoaderMetaspace.cpp index 4bcbb862a5a4e..2638720177387 100644 --- a/src/hotspot/share/memory/classLoaderMetaspace.cpp +++ b/src/hotspot/share/memory/classLoaderMetaspace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -148,8 +148,8 @@ MetaWord* ClassLoaderMetaspace::expand_and_allocate(size_t word_size, Metaspace: Metaspace::tracer()->report_gc_threshold(before, after, MetaspaceGCThresholdUpdater::ExpandAndAllocate); // Keeping both for now until I am sure the old variant (gc + metaspace) is not needed anymore - log_trace(gc, metaspace)("Increase capacity to GC from " SIZE_FORMAT " to " SIZE_FORMAT, before, after); - UL2(info, "GC threshold increased: " SIZE_FORMAT "->" SIZE_FORMAT ".", before, after); + log_trace(gc, metaspace)("Increase capacity to GC from %zu to %zu", before, after); + UL2(info, "GC threshold increased: %zu->%zu.", before, after); } return res; diff --git a/src/hotspot/share/memory/guardedMemory.cpp b/src/hotspot/share/memory/guardedMemory.cpp index 12ffde3cc1b94..e089248528901 100644 --- a/src/hotspot/share/memory/guardedMemory.cpp +++ b/src/hotspot/share/memory/guardedMemory.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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ void GuardedMemory::print_on(outputStream* st) const { return; } st->print_cr("GuardedMemory(" PTR_FORMAT ") base_addr=" PTR_FORMAT - " tag=" PTR_FORMAT " user_size=" SIZE_FORMAT " user_data=" PTR_FORMAT, + " tag=" PTR_FORMAT " user_size=%zu user_data=" PTR_FORMAT, p2i(this), p2i(_base_addr), p2i(get_tag()), get_user_size(), p2i(get_user_ptr())); Guard* guard = get_head_guard(); diff --git a/src/hotspot/share/memory/memoryReserver.cpp b/src/hotspot/share/memory/memoryReserver.cpp index 7ae767fa9da0d..1cc3bbf2ae441 100644 --- a/src/hotspot/share/memory/memoryReserver.cpp +++ b/src/hotspot/share/memory/memoryReserver.cpp @@ -68,7 +68,7 @@ static void log_on_large_pages_failure(char* req_addr, size_t bytes) { // JVM style warning that we did not succeed in using large pages. char msg[128]; jio_snprintf(msg, sizeof(msg), "Failed to reserve and commit memory using large pages. " - "req_addr: " PTR_FORMAT " bytes: " SIZE_FORMAT, + "req_addr: " PTR_FORMAT " bytes: %zu", req_addr, bytes); warning("%s", msg); } @@ -89,7 +89,7 @@ static char* reserve_memory_inner(char* requested_address, // important. If the reservation fails, return null. if (requested_address != nullptr) { assert(is_aligned(requested_address, alignment), - "Requested address " PTR_FORMAT " must be aligned to " SIZE_FORMAT, + "Requested address " PTR_FORMAT " must be aligned to %zu", p2i(requested_address), alignment); return os::attempt_reserve_memory_at(requested_address, size, exec, mem_tag); } @@ -131,8 +131,7 @@ ReservedSpace MemoryReserver::reserve_memory_special(char* requested_address, size_t alignment, size_t page_size, bool exec) { - log_trace(pagesize)("Attempt special mapping: size: " SIZE_FORMAT "%s, " - "alignment: " SIZE_FORMAT "%s", + log_trace(pagesize)("Attempt special mapping: size: %zu%s, alignment: %zu%s", byte_size_in_exact_unit(size), exact_unit_for_byte_size(size), byte_size_in_exact_unit(alignment), exact_unit_for_byte_size(alignment)); @@ -141,7 +140,7 @@ ReservedSpace MemoryReserver::reserve_memory_special(char* requested_address, if (base != nullptr) { assert(is_aligned(base, alignment), "reserve_memory_special() returned an unaligned address, " - "base: " PTR_FORMAT " alignment: " SIZE_FORMAT_X, + "base: " PTR_FORMAT " alignment: 0x%zx", p2i(base), alignment); return ReservedSpace(base, size, alignment, page_size, exec, true /* special */); @@ -255,7 +254,7 @@ static char* map_memory_to_file(char* requested_address, // important. If the reservation fails, return null. if (requested_address != nullptr) { assert(is_aligned(requested_address, alignment), - "Requested address " PTR_FORMAT " must be aligned to " SIZE_FORMAT, + "Requested address " PTR_FORMAT " must be aligned to %zu", p2i(requested_address), alignment); return os::attempt_map_memory_to_file_at(requested_address, size, fd, mem_tag); } @@ -401,7 +400,7 @@ ReservedSpace HeapReserver::Instance::try_reserve_memory(size_t size, char* requested_address) { // Try to reserve the memory for the heap. log_trace(gc, heap, coops)("Trying to allocate at address " PTR_FORMAT - " heap of size " SIZE_FORMAT_X, + " heap of size 0x%zx", p2i(requested_address), size); @@ -639,7 +638,7 @@ ReservedHeapSpace HeapReserver::Instance::reserve_compressed_oops_heap(const siz // Last, desperate try without any placement. if (!reserved.is_reserved()) { - log_trace(gc, heap, coops)("Trying to allocate at address null heap of size " SIZE_FORMAT_X, size + noaccess_prefix); + log_trace(gc, heap, coops)("Trying to allocate at address null heap of size 0x%zx", size + noaccess_prefix); assert(alignment >= os::vm_page_size(), "Unexpected"); reserved = reserve_memory(size + noaccess_prefix, alignment, page_size); } diff --git a/src/hotspot/share/memory/metaspace.cpp b/src/hotspot/share/memory/metaspace.cpp index ccfda8257d319..8de704960b1ce 100644 --- a/src/hotspot/share/memory/metaspace.cpp +++ b/src/hotspot/share/memory/metaspace.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. * Copyright (c) 2017, 2021 SAP SE. All rights reserved. * Copyright (c) 2023, 2024, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -218,8 +218,8 @@ void MetaspaceUtils::print_on(outputStream* out) { MetaspaceCombinedStats stats = get_combined_statistics(); out->print_cr(" Metaspace " "used " SIZE_FORMAT "K, " - "committed " SIZE_FORMAT "K, " - "reserved " SIZE_FORMAT "K", + "committed %zuK, " + "reserved %zuK", stats.used()/K, stats.committed()/K, stats.reserved()/K); @@ -227,8 +227,8 @@ void MetaspaceUtils::print_on(outputStream* out) { if (Metaspace::using_class_space()) { out->print_cr(" class space " "used " SIZE_FORMAT "K, " - "committed " SIZE_FORMAT "K, " - "reserved " SIZE_FORMAT "K", + "committed %zuK, " + "reserved %zuK", stats.class_space_stats().used()/K, stats.class_space_stats().committed()/K, stats.class_space_stats().reserved()/K); @@ -386,7 +386,7 @@ bool MetaspaceGC::can_expand(size_t word_size, bool is_class) { if (is_class && Metaspace::using_class_space()) { size_t class_committed = MetaspaceUtils::committed_bytes(Metaspace::ClassType); if (class_committed + word_size * BytesPerWord > CompressedClassSpaceSize) { - log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by " SIZE_FORMAT " words (CompressedClassSpaceSize = " SIZE_FORMAT " words)", + log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by %zu words (CompressedClassSpaceSize = %zu words)", (is_class ? "class" : "non-class"), word_size, CompressedClassSpaceSize / sizeof(MetaWord)); return false; } @@ -395,7 +395,7 @@ bool MetaspaceGC::can_expand(size_t word_size, bool is_class) { // Check if the user has imposed a limit on the metaspace memory. size_t committed_bytes = MetaspaceUtils::committed_bytes(); if (committed_bytes + word_size * BytesPerWord > MaxMetaspaceSize) { - log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by " SIZE_FORMAT " words (MaxMetaspaceSize = " SIZE_FORMAT " words)", + log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by %zu words (MaxMetaspaceSize = %zu words)", (is_class ? "class" : "non-class"), word_size, MaxMetaspaceSize / sizeof(MetaWord)); return false; } @@ -413,8 +413,8 @@ size_t MetaspaceGC::allowed_expansion() { size_t left_until_GC = capacity_until_gc > committed_bytes ? capacity_until_gc - committed_bytes : 0; size_t left_to_commit = MIN2(left_until_GC, left_until_max); - log_trace(gc, metaspace, freelist)("allowed expansion words: " SIZE_FORMAT - " (left_until_max: " SIZE_FORMAT ", left_until_GC: " SIZE_FORMAT ".", + log_trace(gc, metaspace, freelist)("allowed expansion words: %zu" + " (left_until_max: %zu, left_until_GC: %zu.", left_to_commit / BytesPerWord, left_until_max / BytesPerWord, left_until_GC / BytesPerWord); return left_to_commit / BytesPerWord; @@ -478,7 +478,7 @@ void MetaspaceGC::compute_new_size() { // No expansion, now see if we want to shrink // We would never want to shrink more than this assert(capacity_until_GC >= minimum_desired_capacity, - SIZE_FORMAT " >= " SIZE_FORMAT, + "%zu >= %zu", capacity_until_GC, minimum_desired_capacity); size_t max_shrink_bytes = capacity_until_GC - minimum_desired_capacity; @@ -512,7 +512,7 @@ void MetaspaceGC::compute_new_size() { shrink_bytes = align_down(shrink_bytes, Metaspace::commit_alignment()); assert(shrink_bytes <= max_shrink_bytes, - "invalid shrink size " SIZE_FORMAT " not <= " SIZE_FORMAT, + "invalid shrink size %zu not <= %zu", shrink_bytes, max_shrink_bytes); if (current_shrink_factor == 0) { _shrink_factor = 10; @@ -554,7 +554,7 @@ void Metaspace::print_compressed_class_space(outputStream* st) { MetaWord* base = VirtualSpaceList::vslist_class()->base_of_first_node(); size_t size = VirtualSpaceList::vslist_class()->word_size_of_first_node(); MetaWord* top = base + size; - st->print("Compressed class space mapped at: " PTR_FORMAT "-" PTR_FORMAT ", reserved size: " SIZE_FORMAT, + st->print("Compressed class space mapped at: " PTR_FORMAT "-" PTR_FORMAT ", reserved size: %zu", p2i(base), p2i(top), (top - base) * BytesPerWord); st->cr(); } @@ -563,10 +563,10 @@ void Metaspace::print_compressed_class_space(outputStream* st) { // Given a prereserved space, use that to set up the compressed class space list. void Metaspace::initialize_class_space(ReservedSpace rs) { assert(rs.size() >= CompressedClassSpaceSize, - SIZE_FORMAT " != " SIZE_FORMAT, rs.size(), CompressedClassSpaceSize); + "%zu != %zu", rs.size(), CompressedClassSpaceSize); assert(using_class_space(), "Must be using class space"); - assert(rs.size() == CompressedClassSpaceSize, SIZE_FORMAT " != " SIZE_FORMAT, + assert(rs.size() == CompressedClassSpaceSize, SIZE_FORMAT " != %zu", rs.size(), CompressedClassSpaceSize); assert(is_aligned(rs.base(), Metaspace::reserve_alignment()) && is_aligned(rs.size(), Metaspace::reserve_alignment()), @@ -692,7 +692,7 @@ void Metaspace::ergo_initialize() { // Lets just live with that, its not a big deal. if (adjusted_ccs_size != CompressedClassSpaceSize) { FLAG_SET_ERGO(CompressedClassSpaceSize, adjusted_ccs_size); - log_info(metaspace)("Setting CompressedClassSpaceSize to " SIZE_FORMAT ".", + log_info(metaspace)("Setting CompressedClassSpaceSize to %zu.", CompressedClassSpaceSize); } } @@ -761,7 +761,7 @@ void Metaspace::global_initialize() { if (!is_aligned(base, Metaspace::reserve_alignment())) { vm_exit_during_initialization( err_msg("CompressedClassSpaceBaseAddress=" PTR_FORMAT " invalid " - "(must be aligned to " SIZE_FORMAT_X ").", + "(must be aligned to 0x%zx).", CompressedClassSpaceBaseAddress, Metaspace::reserve_alignment())); } @@ -793,7 +793,7 @@ void Metaspace::global_initialize() { // ...failing that, give up. if (!rs.is_reserved()) { vm_exit_during_initialization( - err_msg("Could not allocate compressed class space: " SIZE_FORMAT " bytes", + err_msg("Could not allocate compressed class space: %zu bytes", CompressedClassSpaceSize)); } @@ -859,7 +859,7 @@ size_t Metaspace::max_allocation_word_size() { MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, bool use_class_space) { assert(word_size <= Metaspace::max_allocation_word_size(), - "allocation size too large (" SIZE_FORMAT ")", word_size); + "allocation size too large (%zu)", word_size); assert(loader_data != nullptr, "Should never pass around a null loader_data. " "ClassLoaderData::the_null_class_loader_data() should have been used."); @@ -935,7 +935,7 @@ void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_s { LogMessage(gc, metaspace, freelist, oom) log; if (log.is_info()) { - log.info("Metaspace (%s) allocation failed for size " SIZE_FORMAT, + log.info("Metaspace (%s) allocation failed for size %zu", is_class_space_allocation(mdtype) ? "class" : "data", word_size); ResourceMark rm; if (log.is_debug()) { diff --git a/src/hotspot/share/memory/metaspace/binList.hpp b/src/hotspot/share/memory/metaspace/binList.hpp index 9442ea3cd5200..18e1b2c7fb86d 100644 --- a/src/hotspot/share/memory/metaspace/binList.hpp +++ b/src/hotspot/share/memory/metaspace/binList.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * Copyright (c) 2023 Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -78,7 +78,7 @@ class BinListImpl { Block(Block* next) : _next(next) {} }; -#define BLOCK_FORMAT "Block @" PTR_FORMAT ": size: " SIZE_FORMAT ", next: " PTR_FORMAT +#define BLOCK_FORMAT "Block @" PTR_FORMAT ": size: %zu, next: " PTR_FORMAT #define BLOCK_FORMAT_ARGS(b, sz) p2i(b), (sz), p2i((b)->_next) // Block size must be exactly one word size. @@ -161,7 +161,7 @@ class BinListImpl { // Block may be larger. MetaBlock remove_block(size_t word_size) { assert(word_size >= MinWordSize && - word_size <= MaxWordSize, "bad block size " SIZE_FORMAT ".", word_size); + word_size <= MaxWordSize, "bad block size %zu.", word_size); MetaBlock result; int index = index_for_word_size(word_size); index = index_for_next_non_empty_list(index); diff --git a/src/hotspot/share/memory/metaspace/blockTree.cpp b/src/hotspot/share/memory/metaspace/blockTree.cpp index 85e7750883667..a0ad15905c1a1 100644 --- a/src/hotspot/share/memory/metaspace/blockTree.cpp +++ b/src/hotspot/share/memory/metaspace/blockTree.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2022 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -44,7 +44,7 @@ const size_t BlockTree::MinWordSize; ", left " PTR_FORMAT \ ", right " PTR_FORMAT \ ", next " PTR_FORMAT \ - ", size " SIZE_FORMAT + ", size %zu" #define NODE_FORMAT_ARGS(n) \ p2i(n), \ diff --git a/src/hotspot/share/memory/metaspace/blockTree.hpp b/src/hotspot/share/memory/metaspace/blockTree.hpp index 8bcdd30919ae9..a01f60b166f14 100644 --- a/src/hotspot/share/memory/metaspace/blockTree.hpp +++ b/src/hotspot/share/memory/metaspace/blockTree.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -348,7 +348,7 @@ class BlockTree: public CHeapObj { void add_block(MetaBlock block) { DEBUG_ONLY(zap_block(block);) const size_t word_size = block.word_size(); - assert(word_size >= MinWordSize, "invalid block size " SIZE_FORMAT, word_size); + assert(word_size >= MinWordSize, "invalid block size %zu", word_size); Node* n = new(block.base()) Node(word_size); if (_root == nullptr) { _root = n; @@ -361,7 +361,7 @@ class BlockTree: public CHeapObj { // Given a word_size, search and return the smallest block that is equal or // larger than that size. MetaBlock remove_block(size_t word_size) { - assert(word_size >= MinWordSize, "invalid block size " SIZE_FORMAT, word_size); + assert(word_size >= MinWordSize, "invalid block size %zu", word_size); MetaBlock result; Node* n = find_closest_fit(word_size); diff --git a/src/hotspot/share/memory/metaspace/chunkManager.cpp b/src/hotspot/share/memory/metaspace/chunkManager.cpp index 7b51198bc79a3..f28f7d271b679 100644 --- a/src/hotspot/share/memory/metaspace/chunkManager.cpp +++ b/src/hotspot/share/memory/metaspace/chunkManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -141,7 +141,7 @@ Metachunk* ChunkManager::get_chunk_locked(chunklevel_t preferred_level, chunklev DEBUG_ONLY(chunklevel::check_valid_level(preferred_level);) UL2(debug, "requested chunk: pref_level: " CHKLVL_FORMAT - ", max_level: " CHKLVL_FORMAT ", min committed size: " SIZE_FORMAT ".", + ", max_level: " CHKLVL_FORMAT ", min committed size: %zu.", preferred_level, max_level, min_committed_words); // First, optimistically look for a chunk which is already committed far enough to hold min_word_size. @@ -212,7 +212,7 @@ Metachunk* ChunkManager::get_chunk_locked(chunklevel_t preferred_level, chunklev const size_t to_commit = min_committed_words; if (c->committed_words() < to_commit) { if (c->ensure_committed_locked(to_commit) == false) { - UL2(info, "failed to commit " SIZE_FORMAT " words on chunk " METACHUNK_FORMAT ".", + UL2(info, "failed to commit %zu words on chunk " METACHUNK_FORMAT ".", to_commit, METACHUNK_FORMAT_ARGS(c)); return_chunk_locked(c); c = nullptr; @@ -434,7 +434,7 @@ void ChunkManager::print_on(outputStream* st) const { void ChunkManager::print_on_locked(outputStream* st) const { assert_lock_strong(Metaspace_lock); - st->print_cr("cm %s: %d chunks, total word size: " SIZE_FORMAT ".", _name, + st->print_cr("cm %s: %d chunks, total word size: %zu.", _name, total_num_chunks(), total_word_size()); _chunks.print_on(st); } diff --git a/src/hotspot/share/memory/metaspace/chunklevel.cpp b/src/hotspot/share/memory/metaspace/chunklevel.cpp index c8bb19373d600..6c8b6e82efeb2 100644 --- a/src/hotspot/share/memory/metaspace/chunklevel.cpp +++ b/src/hotspot/share/memory/metaspace/chunklevel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,7 +36,7 @@ using namespace chunklevel; chunklevel_t chunklevel::level_fitting_word_size(size_t word_size) { assert(MAX_CHUNK_WORD_SIZE >= word_size, - SIZE_FORMAT " - too large allocation size.", word_size * BytesPerWord); + "%zu - too large allocation size.", word_size * BytesPerWord); if (word_size <= MIN_CHUNK_WORD_SIZE) { return HIGHEST_CHUNK_LEVEL; } diff --git a/src/hotspot/share/memory/metaspace/commitMask.cpp b/src/hotspot/share/memory/metaspace/commitMask.cpp index a1bc985210bf1..fa7a7ba86f111 100644 --- a/src/hotspot/share/memory/metaspace/commitMask.cpp +++ b/src/hotspot/share/memory/metaspace/commitMask.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -61,7 +61,7 @@ void CommitMask::check_pointer(const MetaWord* p) const { void CommitMask::check_pointer_aligned(const MetaWord* p) const { check_pointer(p); assert(is_aligned(p, _words_per_bit * BytesPerWord), - "Pointer " PTR_FORMAT " should be aligned to commit granule size " SIZE_FORMAT ".", + "Pointer " PTR_FORMAT " should be aligned to commit granule size %zu.", p2i(p), _words_per_bit * BytesPerWord); } // Given a range, check if it points into the range this bitmap covers, @@ -69,7 +69,7 @@ void CommitMask::check_pointer_aligned(const MetaWord* p) const { void CommitMask::check_range(const MetaWord* start, size_t word_size) const { check_pointer_aligned(start); assert(is_aligned(word_size, _words_per_bit), - "Range " SIZE_FORMAT " should be aligned to commit granule size " SIZE_FORMAT ".", + "Range %zu should be aligned to commit granule size %zu.", word_size, _words_per_bit); check_pointer(start + word_size - 1); } diff --git a/src/hotspot/share/memory/metaspace/freeChunkList.cpp b/src/hotspot/share/memory/metaspace/freeChunkList.cpp index 65eace074f933..46008cdfe53fc 100644 --- a/src/hotspot/share/memory/metaspace/freeChunkList.cpp +++ b/src/hotspot/share/memory/metaspace/freeChunkList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2022 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -155,7 +155,7 @@ void FreeChunkListVector::print_on(outputStream* st) const { list_for_level(l)->print_on(st); st->cr(); } - st->print_cr("total chunks: %d, total word size: " SIZE_FORMAT ".", + st->print_cr("total chunks: %d, total word size: %zu.", num_chunks(), word_size()); } diff --git a/src/hotspot/share/memory/metaspace/metablock.hpp b/src/hotspot/share/memory/metaspace/metablock.hpp index 96e27ff8702e8..4b2dfdfe6803e 100644 --- a/src/hotspot/share/memory/metaspace/metablock.hpp +++ b/src/hotspot/share/memory/metaspace/metablock.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2023 Red Hat, Inc. All rights reserved. - * Copyright (c) 2023, 2024, 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 @@ -68,7 +68,7 @@ class MetaBlock { void print_on(outputStream* st) const; }; -#define METABLOCKFORMAT "block (@" PTR_FORMAT " word size " SIZE_FORMAT ")" +#define METABLOCKFORMAT "block (@" PTR_FORMAT " word size %zu)" #define METABLOCKFORMATARGS(__block__) p2i((__block__).base()), (__block__).word_size() } // namespace metaspace diff --git a/src/hotspot/share/memory/metaspace/metachunk.cpp b/src/hotspot/share/memory/metaspace/metachunk.cpp index 0bf7e98f13022..7ae4bd07f36c6 100644 --- a/src/hotspot/share/memory/metaspace/metachunk.cpp +++ b/src/hotspot/share/memory/metaspace/metachunk.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -102,7 +102,7 @@ bool Metachunk::commit_up_to(size_t new_committed_words) { assert(commit_to <= word_size(), "Sanity"); if (commit_to > commit_from) { log_debug(metaspace)("Chunk " METACHUNK_FORMAT ": attempting to move commit line to " - SIZE_FORMAT " words.", METACHUNK_FORMAT_ARGS(this), commit_to); + "%zu words.", METACHUNK_FORMAT_ARGS(this), commit_to); if (!_vsnode->ensure_range_is_committed(base() + commit_from, commit_to - commit_from)) { DEBUG_ONLY(verify();) return false; @@ -271,10 +271,10 @@ void Metachunk::verify() const { assert(base() != nullptr, "No base ptr"); assert(committed_words() >= used_words(), - "mismatch: committed: " SIZE_FORMAT ", used: " SIZE_FORMAT ".", + "mismatch: committed: %zu, used: %zu.", committed_words(), used_words()); assert(word_size() >= committed_words(), - "mismatch: word_size: " SIZE_FORMAT ", committed: " SIZE_FORMAT ".", + "mismatch: word_size: %zu, committed: %zu.", word_size(), committed_words()); // Test base pointer @@ -304,8 +304,8 @@ void Metachunk::verify() const { void Metachunk::print_on(outputStream* st) const { // Note: must also work with invalid/random data. (e.g. do not call word_size()) st->print("Chunk @" PTR_FORMAT ", state %c, base " PTR_FORMAT ", " - "level " CHKLVL_FORMAT " (" SIZE_FORMAT " words), " - "used " SIZE_FORMAT " words, committed " SIZE_FORMAT " words.", + "level " CHKLVL_FORMAT " (%zu words), " + "used %zu words, committed %zu words.", p2i(this), get_state_char(), p2i(base()), level(), (chunklevel::is_valid_level(level()) ? chunklevel::word_size_for_level(level()) : SIZE_MAX), used_words(), committed_words()); diff --git a/src/hotspot/share/memory/metaspace/metachunk.hpp b/src/hotspot/share/memory/metaspace/metachunk.hpp index efd849c6e5a36..c025343231b1c 100644 --- a/src/hotspot/share/memory/metaspace/metachunk.hpp +++ b/src/hotspot/share/memory/metaspace/metachunk.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -362,7 +362,7 @@ class Metachunk { #define METACHUNK_FORMAT "@" PTR_FORMAT ", %c, base " PTR_FORMAT ", level " CHKLVL_FORMAT #define METACHUNK_FORMAT_ARGS(chunk) p2i(chunk), chunk->get_state_char(), p2i(chunk->base()), chunk->level() -#define METACHUNK_FULL_FORMAT "@" PTR_FORMAT ", %c, base " PTR_FORMAT ", level " CHKLVL_FORMAT " (" SIZE_FORMAT "), used: " SIZE_FORMAT ", committed: " SIZE_FORMAT ", committed-free: " SIZE_FORMAT +#define METACHUNK_FULL_FORMAT "@" PTR_FORMAT ", %c, base " PTR_FORMAT ", level " CHKLVL_FORMAT " (%zu), used: %zu, committed: %zu, committed-free: %zu" #define METACHUNK_FULL_FORMAT_ARGS(chunk) p2i(chunk), chunk->get_state_char(), p2i(chunk->base()), chunk->level(), chunk->word_size(), chunk->used_words(), chunk->committed_words(), chunk->free_below_committed_words() } // namespace metaspace diff --git a/src/hotspot/share/memory/metaspace/metaspaceArena.cpp b/src/hotspot/share/memory/metaspace/metaspaceArena.cpp index 33f1bfc46a31d..617079de45d16 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceArena.cpp +++ b/src/hotspot/share/memory/metaspace/metaspaceArena.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -84,7 +84,7 @@ MetaBlock MetaspaceArena::salvage_chunk(Metachunk* c) { Metachunk* MetaspaceArena::allocate_new_chunk(size_t requested_word_size) { // Should this ever happen, we need to increase the maximum possible chunk size. guarantee(requested_word_size <= chunklevel::MAX_CHUNK_WORD_SIZE, - "Requested size too large (" SIZE_FORMAT ") - max allowed size per allocation is " SIZE_FORMAT ".", + "Requested size too large (%zu) - max allowed size per allocation is %zu.", requested_word_size, chunklevel::MAX_CHUNK_WORD_SIZE); const chunklevel_t max_level = chunklevel::level_fitting_word_size(requested_word_size); @@ -150,7 +150,7 @@ MetaspaceArena::~MetaspaceArena() { c = c2; } - UL2(debug, "returned %d chunks, total capacity " SIZE_FORMAT " words.", + UL2(debug, "returned %d chunks, total capacity %zu words.", return_counter.count(), return_counter.total_size()); _total_used_words_counter->decrement_by(return_counter.total_size()); @@ -216,7 +216,7 @@ bool MetaspaceArena::attempt_enlarge_current_chunk(size_t requested_word_size) { // 4) Attempt to get a new chunk and allocate from that chunk. // At any point, if we hit a commit limit, we return null. MetaBlock MetaspaceArena::allocate(size_t requested_word_size, MetaBlock& wastage) { - UL2(trace, "requested " SIZE_FORMAT " words.", requested_word_size); + UL2(trace, "requested %zu words.", requested_word_size); const size_t aligned_word_size = get_raw_word_size_for_requested_word_size(requested_word_size); @@ -234,7 +234,7 @@ MetaBlock MetaspaceArena::allocate(size_t requested_word_size, MetaBlock& wastag wastage = result.split_off_tail(result.word_size() - aligned_word_size); // Stats, logging DEBUG_ONLY(InternalStats::inc_num_allocs_from_deallocated_blocks();) - UL2(trace, "returning " METABLOCKFORMAT " with wastage " METABLOCKFORMAT " - taken from fbl (now: %d, " SIZE_FORMAT ").", + UL2(trace, "returning " METABLOCKFORMAT " with wastage " METABLOCKFORMAT " - taken from fbl (now: %d, %zu).", METABLOCKFORMATARGS(result), METABLOCKFORMATARGS(wastage), _fbl->count(), _fbl->total_size()); // Note: free blocks in freeblock dictionary still count as "used" as far as statistics go; // therefore we don't need to adjust any usage counters (see epilogue of allocate_inner()). @@ -314,7 +314,7 @@ MetaBlock MetaspaceArena::allocate_inner(size_t word_size, MetaBlock& wastage) { // chunk. if (!current_chunk_too_small) { if (!current_chunk()->ensure_committed_additional(word_size_plus_alignment)) { - UL2(info, "commit failure (requested size: " SIZE_FORMAT ")", word_size_plus_alignment); + UL2(info, "commit failure (requested size: %zu)", word_size_plus_alignment); commit_failure = true; } } @@ -339,7 +339,7 @@ MetaBlock MetaspaceArena::allocate_inner(size_t word_size, MetaBlock& wastage) { Metachunk* new_chunk = allocate_new_chunk(word_size); if (new_chunk != nullptr) { - UL2(debug, "allocated new chunk " METACHUNK_FORMAT " for requested word size " SIZE_FORMAT ".", + UL2(debug, "allocated new chunk " METACHUNK_FORMAT " for requested word size %zu.", METACHUNK_FORMAT_ARGS(new_chunk), word_size); assert(new_chunk->free_below_committed_words() >= word_size, "Sanity"); @@ -359,7 +359,7 @@ MetaBlock MetaspaceArena::allocate_inner(size_t word_size, MetaBlock& wastage) { assert(p != nullptr, "Allocation from chunk failed."); result = MetaBlock(p, word_size); } else { - UL2(info, "failed to allocate new chunk for requested word size " SIZE_FORMAT ".", word_size); + UL2(info, "failed to allocate new chunk for requested word size %zu.", word_size); } } @@ -407,7 +407,7 @@ void MetaspaceArena::deallocate(MetaBlock block) { #else add_allocation_to_fbl(block); #endif - UL2(trace, "added to fbl: " METABLOCKFORMAT ", (now: %d, " SIZE_FORMAT ").", + UL2(trace, "added to fbl: " METABLOCKFORMAT ", (now: %d, %zu).", METABLOCKFORMATARGS(block), _fbl->count(), _fbl->total_size()); SOMETIMES(verify();) } @@ -482,7 +482,7 @@ bool MetaspaceArena::contains(MetaBlock bl) const { #endif // ASSERT void MetaspaceArena::print_on(outputStream* st) const { - st->print_cr("sm %s: %d chunks, total word size: " SIZE_FORMAT ", committed word size: " SIZE_FORMAT, _name, + st->print_cr("sm %s: %d chunks, total word size: %zu, committed word size: %zu", _name, _chunks.count(), _chunks.calc_word_size(), _chunks.calc_committed_word_size()); _chunks.print_on(st); st->cr(); diff --git a/src/hotspot/share/memory/metaspace/metaspaceCommon.cpp b/src/hotspot/share/memory/metaspace/metaspaceCommon.cpp index c40bdc6bacf9e..c26075c47b978 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceCommon.cpp +++ b/src/hotspot/share/memory/metaspace/metaspaceCommon.cpp @@ -98,9 +98,9 @@ void print_human_readable_size(outputStream* st, size_t byte_size, size_t scale, if (width == -1) { if (scale == 1) { - st->print(SIZE_FORMAT " bytes", byte_size); + st->print("%zu bytes", byte_size); } else if (scale == BytesPerWord) { - st->print(SIZE_FORMAT " words", byte_size / BytesPerWord); + st->print("%zu words", byte_size / BytesPerWord); } else { const char* display_unit = display_unit_for_scale(scale); float display_value = (float) byte_size / (float)scale; diff --git a/src/hotspot/share/memory/metaspace/metaspaceCommon.hpp b/src/hotspot/share/memory/metaspace/metaspaceCommon.hpp index d296ffd6cd7f0..e9f51d05aa5cb 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceCommon.hpp +++ b/src/hotspot/share/memory/metaspace/metaspaceCommon.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -80,8 +80,8 @@ void print_percentage(outputStream* st, size_t total, size_t part); #ifdef ASSERT #define assert_is_aligned(value, alignment) \ assert(is_aligned((value), (alignment)), \ - SIZE_FORMAT_X " is not aligned to " \ - SIZE_FORMAT_X, (size_t)(uintptr_t)value, (size_t)(alignment)) + "0x%zx is not aligned to 0x%zx", \ + (size_t)(uintptr_t)value, (size_t)(alignment)) #define assert_is_aligned_metaspace_pointer(p) \ assert_is_aligned((p), metaspace::AllocationAlignmentByteSize) #else diff --git a/src/hotspot/share/memory/metaspace/metaspaceSettings.cpp b/src/hotspot/share/memory/metaspace/metaspaceSettings.cpp index b812341a2da34..3f27299284c2b 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceSettings.cpp +++ b/src/hotspot/share/memory/metaspace/metaspaceSettings.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -49,9 +49,9 @@ void Settings::ergo_initialize() { } void Settings::print_on(outputStream* st) { - st->print_cr(" - commit_granule_bytes: " SIZE_FORMAT ".", commit_granule_bytes()); - st->print_cr(" - commit_granule_words: " SIZE_FORMAT ".", commit_granule_words()); - st->print_cr(" - virtual_space_node_default_size: " SIZE_FORMAT ".", virtual_space_node_default_word_size()); + st->print_cr(" - commit_granule_bytes: %zu.", commit_granule_bytes()); + st->print_cr(" - commit_granule_words: %zu.", commit_granule_words()); + st->print_cr(" - virtual_space_node_default_size: %zu.", virtual_space_node_default_word_size()); st->print_cr(" - enlarge_chunks_in_place: %d.", (int)enlarge_chunks_in_place()); } diff --git a/src/hotspot/share/memory/metaspace/metaspaceStatistics.cpp b/src/hotspot/share/memory/metaspace/metaspaceStatistics.cpp index 6461579106b1b..68224b91ef0b1 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceStatistics.cpp +++ b/src/hotspot/share/memory/metaspace/metaspaceStatistics.cpp @@ -128,7 +128,7 @@ void InUseChunkStats::print_on(outputStream* st, size_t scale) const { void InUseChunkStats::verify() const { assert(_word_size >= _committed_words && _committed_words == _used_words + _free_words + _waste_words, - "Sanity: cap " SIZE_FORMAT ", committed " SIZE_FORMAT ", used " SIZE_FORMAT ", free " SIZE_FORMAT ", waste " SIZE_FORMAT ".", + "Sanity: cap %zu, committed %zu, used %zu, free %zu, waste %zu.", _word_size, _committed_words, _used_words, _free_words, _waste_words); } #endif diff --git a/src/hotspot/share/memory/metaspace/testHelpers.cpp b/src/hotspot/share/memory/metaspace/testHelpers.cpp index fdf7bb1ba6084..618ccf83c8f78 100644 --- a/src/hotspot/share/memory/metaspace/testHelpers.cpp +++ b/src/hotspot/share/memory/metaspace/testHelpers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -78,8 +78,8 @@ MetaspaceTestContext::MetaspaceTestContext(const char* name, size_t commit_limit _commit_limiter(commit_limit == 0 ? max_uintx : commit_limit), // commit_limit == 0 -> no limit _rs() { - assert(is_aligned(reserve_limit, Metaspace::reserve_alignment_words()), "reserve_limit (" SIZE_FORMAT ") " - "not aligned to metaspace reserve alignment (" SIZE_FORMAT ")", + assert(is_aligned(reserve_limit, Metaspace::reserve_alignment_words()), "reserve_limit (%zu) " + "not aligned to metaspace reserve alignment (%zu)", reserve_limit, Metaspace::reserve_alignment_words()); if (reserve_limit > 0) { // have reserve limit -> non-expandable context diff --git a/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp b/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp index 32ceeb45c4fb5..5f829300fd485 100644 --- a/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp +++ b/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -150,7 +150,7 @@ void VirtualSpaceList::print_on(outputStream* st) const { vsn = vsn->next(); n++; } - st->print_cr("- total %d nodes, " SIZE_FORMAT " reserved words, " SIZE_FORMAT " committed words.", + st->print_cr("- total %d nodes, %zu reserved words, %zu committed words.", n, reserved_words(), committed_words()); } diff --git a/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp b/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp index 77b943609bccd..44f75a5e63052 100644 --- a/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp +++ b/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -65,7 +65,7 @@ static void check_pointer_is_aligned_to_commit_granule(const MetaWord* p) { } static void check_word_size_is_aligned_to_commit_granule(size_t word_size) { assert(is_aligned(word_size, Settings::commit_granule_words()), - "Not aligned to commit granule size: " SIZE_FORMAT ".", word_size); + "Not aligned to commit granule size: %zu.", word_size); } #endif @@ -95,7 +95,7 @@ bool VirtualSpaceNode::commit_range(MetaWord* p, size_t word_size) { // were we to commit the given address range completely. const size_t commit_increase_words = word_size - committed_words_in_range; - UL2(debug, "committing range " PTR_FORMAT ".." PTR_FORMAT "(" SIZE_FORMAT " words)", + UL2(debug, "committing range " PTR_FORMAT ".." PTR_FORMAT "(%zu words)", p2i(p), p2i(p + word_size), word_size); if (commit_increase_words == 0) { @@ -118,7 +118,7 @@ bool VirtualSpaceNode::commit_range(MetaWord* p, size_t word_size) { os::pretouch_memory(p, p + word_size); } - UL2(debug, "... committed " SIZE_FORMAT " additional words.", commit_increase_words); + UL2(debug, "... committed %zu additional words.", commit_increase_words); // ... tell commit limiter... _commit_limiter->increase_committed(commit_increase_words); @@ -180,7 +180,7 @@ void VirtualSpaceNode::uncommit_range(MetaWord* p, size_t word_size) { const size_t committed_words_in_range = _commit_mask.get_committed_size_in_range(p, word_size); DEBUG_ONLY(check_word_size_is_aligned_to_commit_granule(committed_words_in_range);) - UL2(debug, "uncommitting range " PTR_FORMAT ".." PTR_FORMAT "(" SIZE_FORMAT " words)", + UL2(debug, "uncommitting range " PTR_FORMAT ".." PTR_FORMAT "(%zu words)", p2i(p), p2i(p + word_size), word_size); if (committed_words_in_range == 0) { @@ -194,7 +194,7 @@ void VirtualSpaceNode::uncommit_range(MetaWord* p, size_t word_size) { fatal("Failed to uncommit metaspace."); } - UL2(debug, "... uncommitted " SIZE_FORMAT " words.", committed_words_in_range); + UL2(debug, "... uncommitted %zu words.", committed_words_in_range); // ... tell commit limiter... _commit_limiter->decrease_committed(committed_words_in_range); @@ -231,7 +231,7 @@ VirtualSpaceNode::VirtualSpaceNode(ReservedSpace rs, bool owns_rs, CommitLimiter _total_reserved_words_counter(reserve_counter), _total_committed_words_counter(commit_counter) { - UL2(debug, "born (word_size " SIZE_FORMAT ").", _word_size); + UL2(debug, "born (word_size %zu).", _word_size); // Update reserved counter in vslist _total_reserved_words_counter->increment_by(_word_size); diff --git a/src/hotspot/share/memory/resourceArea.hpp b/src/hotspot/share/memory/resourceArea.hpp index b9a1904b5078c..29dea9ad2f466 100644 --- a/src/hotspot/share/memory/resourceArea.hpp +++ b/src/hotspot/share/memory/resourceArea.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 @@ -107,7 +107,7 @@ class ResourceArea: public Arena { // Reset size before deleting chunks. Otherwise, the total // size could exceed the total chunk size. assert(size_in_bytes() > state._size_in_bytes, - "size: " SIZE_FORMAT ", saved size: " SIZE_FORMAT, + "size: %zu, saved size: %zu", size_in_bytes(), state._size_in_bytes); set_size_in_bytes(state._size_in_bytes); Chunk::next_chop(state._chunk); diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp index bf702640bd421..853de9a616418 100644 --- a/src/hotspot/share/memory/universe.cpp +++ b/src/hotspot/share/memory/universe.cpp @@ -940,7 +940,7 @@ void Universe::initialize_tlab() { ReservedHeapSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { assert(alignment <= Arguments::conservative_max_heap_alignment(), - "actual alignment " SIZE_FORMAT " must be within maximum heap alignment " SIZE_FORMAT, + "actual alignment %zu must be within maximum heap alignment %zu", alignment, Arguments::conservative_max_heap_alignment()); size_t total_reserved = align_up(heap_size, alignment); @@ -985,7 +985,7 @@ ReservedHeapSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { } vm_exit_during_initialization( - err_msg("Could not reserve enough space for " SIZE_FORMAT "KB object heap", + err_msg("Could not reserve enough space for %zuKB object heap", total_reserved/K)); // satisfy compiler diff --git a/src/hotspot/share/memory/virtualspace.cpp b/src/hotspot/share/memory/virtualspace.cpp index 73f74e0b9efcd..f934bfa5c3d62 100644 --- a/src/hotspot/share/memory/virtualspace.cpp +++ b/src/hotspot/share/memory/virtualspace.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 @@ -203,7 +203,7 @@ static bool commit_expanded(char* start, size_t size, size_t alignment, bool pre debug_only(warning( "INFO: os::commit_memory(" PTR_FORMAT ", " PTR_FORMAT - " size=" SIZE_FORMAT ", executable=%d) failed", + " size=%zu, executable=%d) failed", p2i(start), p2i(start + size), size, executable);) return false; @@ -426,8 +426,8 @@ void VirtualSpace::print_on(outputStream* out) const { out->print ("Virtual space:"); if (special()) out->print(" (pinned in memory)"); out->cr(); - out->print_cr(" - committed: " SIZE_FORMAT, committed_size()); - out->print_cr(" - reserved: " SIZE_FORMAT, reserved_size()); + out->print_cr(" - committed: %zu", committed_size()); + out->print_cr(" - reserved: %zu", reserved_size()); out->print_cr(" - [low, high]: [" PTR_FORMAT ", " PTR_FORMAT "]", p2i(low()), p2i(high())); out->print_cr(" - [low_b, high_b]: [" PTR_FORMAT ", " PTR_FORMAT "]", p2i(low_boundary()), p2i(high_boundary())); } From 15e06b61867a65c2b554efa6caf464b39ff8375a Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Fri, 17 Jan 2025 12:54:54 +0000 Subject: [PATCH 37/47] 8345618: javax/swing/text/Caret/8163124/CaretFloatingPointAPITest.java leaves Caret is not complete Reviewed-by: azvegint --- .../text/Caret/8163124/CaretFloatingPointAPITest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/jdk/javax/swing/text/Caret/8163124/CaretFloatingPointAPITest.java b/test/jdk/javax/swing/text/Caret/8163124/CaretFloatingPointAPITest.java index 19d6d6a86079d..c02fcfcfb9073 100644 --- a/test/jdk/javax/swing/text/Caret/8163124/CaretFloatingPointAPITest.java +++ b/test/jdk/javax/swing/text/Caret/8163124/CaretFloatingPointAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -222,11 +222,11 @@ public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.draw(new Line2D.Float(c, cy, c, cy + ch)); - g2d.draw(new Line2D.Float(cx, cy, cx + cw, cy)); - g2d.draw(new Line2D.Float(cx, cy + ch, cx + cw, cy + ch)); } void repaint(Rectangle r) { + r.width += 1; + r.height += 1; component.repaint(r); } @@ -424,6 +424,8 @@ protected void adjustVisibility(Rectangle nloc) { protected synchronized void damage(Rectangle r) { if (r != null && component != null) { + r.width += 1; + r.height += 1; component.repaint(r); } } From 2c41f5adbfcebb057c2ffc8396729bdd1c100079 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Fri, 17 Jan 2025 13:39:22 +0000 Subject: [PATCH 38/47] 8347959: ThreadDumper leaks memory Reviewed-by: amenkov, sspitsyn, shade --- src/hotspot/share/services/heapDumper.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/services/heapDumper.cpp b/src/hotspot/share/services/heapDumper.cpp index 91bcce382f0ee..2cb32d0500cfa 100644 --- a/src/hotspot/share/services/heapDumper.cpp +++ b/src/hotspot/share/services/heapDumper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, Alibaba Group Holding Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1707,6 +1707,12 @@ class ThreadDumper : public CHeapObj { } ThreadDumper(ThreadType thread_type, JavaThread* java_thread, oop thread_oop); + ~ThreadDumper() { + for (int index = 0; index < _frames->length(); index++) { + delete _frames->at(index); + } + delete _frames; + } // affects frame_count void add_oom_frame(Method* oome_constructor) { From 2ca1b4d48da7eb9b5baf0ac213f3ce87f47dd316 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Fri, 17 Jan 2025 15:43:04 +0000 Subject: [PATCH 39/47] 8347840: Fix testlibrary compilation warnings Reviewed-by: dholmes --- make/test/BuildTestLib.gmk | 3 +-- test/lib/jdk/test/lib/Asserts.java | 4 ++-- test/lib/jdk/test/lib/apps/LingeredApp.java | 5 +++-- test/lib/jdk/test/lib/artifacts/ArtifactResolver.java | 4 ++-- .../test/lib/artifacts/ArtifactResolverException.java | 6 +++++- .../jdk/test/lib/artifacts/JibArtifactManager.java | 4 ++-- .../jdk/test/lib/classloader/ClassUnloadCommon.java | 6 +++++- .../test/lib/classloader/GeneratingClassLoader.java | 10 +++++----- .../classloader/GeneratingCompilingClassLoader.java | 4 ++-- test/lib/jdk/test/lib/format/ArrayDiff.java | 4 ++-- test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java | 8 +------- test/lib/jdk/test/lib/hprof/model/JavaStatic.java | 7 +------ test/lib/jdk/test/lib/hprof/model/JavaThing.java | 8 +------- test/lib/jdk/test/lib/hprof/model/Root.java | 8 +------- test/lib/jdk/test/lib/hprof/model/Snapshot.java | 10 +++------- test/lib/jdk/test/lib/hprof/model/StackFrame.java | 8 +------- test/lib/jdk/test/lib/hprof/model/StackTrace.java | 8 +------- .../lib/jdk/test/lib/hprof/parser/FileReadBuffer.java | 4 ++-- .../jdk/test/lib/hprof/parser/MappedReadBuffer.java | 4 ++-- test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java | 3 ++- test/lib/jdk/test/lib/hprof/parser/Reader.java | 4 +++- test/lib/jdk/test/lib/jfr/Events.java | 4 ++-- test/lib/jdk/test/lib/jvmti/DebugeeClass.java | 8 +++++++- .../lib/jdk/test/lib/management/ThreadMXBeanTool.java | 6 +++--- test/lib/jdk/test/lib/net/IPSupport.java | 3 ++- .../jdk/test/lib/os/linux/HugePageConfiguration.java | 3 +-- test/lib/jdk/test/lib/process/ProcessTools.java | 4 ++-- test/lib/jdk/test/lib/thread/VThreadPinner.java | 6 ++++-- test/lib/jdk/test/lib/thread/VThreadRunner.java | 6 ++++-- test/lib/jdk/test/lib/util/FileUtils.java | 11 ++++++----- 30 files changed, 78 insertions(+), 95 deletions(-) diff --git a/make/test/BuildTestLib.gmk b/make/test/BuildTestLib.gmk index 5659423826136..1a13e1914685c 100644 --- a/make/test/BuildTestLib.gmk +++ b/make/test/BuildTestLib.gmk @@ -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 @@ -64,7 +64,6 @@ $(eval $(call SetupJavaCompilation, BUILD_TEST_LIB_JAR, \ BIN := $(TEST_LIB_SUPPORT)/test-lib_classes, \ HEADERS := $(TEST_LIB_SUPPORT)/test-lib_headers, \ JAR := $(TEST_LIB_SUPPORT)/test-lib.jar, \ - DISABLED_WARNINGS := try deprecation rawtypes unchecked serial cast removal preview restricted dangling-doc-comments, \ JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \ diff --git a/test/lib/jdk/test/lib/Asserts.java b/test/lib/jdk/test/lib/Asserts.java index 1f23a64f811ac..e7228ace7be16 100644 --- a/test/lib/jdk/test/lib/Asserts.java +++ b/test/lib/jdk/test/lib/Asserts.java @@ -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 @@ -638,7 +638,7 @@ public static T assertThrows(Class expected, TestMethod testMethod.execute(); } catch (Throwable exc) { if (expected.isInstance(exc)) { - return (T) exc; + return expected.cast(exc); } else { fail(Objects.toString(msg, "An unexpected exception was thrown.") + " Expected " + expected.getName(), exc); diff --git a/test/lib/jdk/test/lib/apps/LingeredApp.java b/test/lib/jdk/test/lib/apps/LingeredApp.java index 73904b81848a3..13008e68c5477 100644 --- a/test/lib/jdk/test/lib/apps/LingeredApp.java +++ b/test/lib/jdk/test/lib/apps/LingeredApp.java @@ -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 @@ -429,7 +429,7 @@ public void stopApp() throws IOException { } } - /** + /* * High level interface for test writers */ @@ -599,6 +599,7 @@ protected static boolean isReady() { * This part is the application itself. First arg is optional "forceCrash". * Following arg is the lock file name. */ + @SuppressWarnings("restricted") public static void main(String args[]) { boolean forceCrash = false; diff --git a/test/lib/jdk/test/lib/artifacts/ArtifactResolver.java b/test/lib/jdk/test/lib/artifacts/ArtifactResolver.java index d8be12d86c2ef..cac371b482b02 100644 --- a/test/lib/jdk/test/lib/artifacts/ArtifactResolver.java +++ b/test/lib/jdk/test/lib/artifacts/ArtifactResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -33,7 +33,7 @@ private static ArtifactManager getManager() throws ArtifactResolverException { try { String managerName = System.getProperty("jdk.test.lib.artifacts.artifactmanager"); if (managerName != null) { - manager = (ArtifactManager) Class.forName(managerName).newInstance(); + manager = (ArtifactManager) Class.forName(managerName).getDeclaredConstructor().newInstance(); } else if (System.getenv().containsKey(JibArtifactManager.JIB_HOME_ENV_NAME)) { manager = JibArtifactManager.newInstance(); } else { diff --git a/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java b/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java index c06f5d7b70fea..6cc010f3b637b 100644 --- a/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java +++ b/test/lib/jdk/test/lib/artifacts/ArtifactResolverException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -23,10 +23,14 @@ package jdk.test.lib.artifacts; +import java.io.Serial; + /** * Thrown by the ArtifactResolver when failing to resolve an Artifact. */ public class ArtifactResolverException extends Exception { + @Serial + private static final long serialVersionUID = 8341884506180926911L; public ArtifactResolverException(String message) { super(message); diff --git a/test/lib/jdk/test/lib/artifacts/JibArtifactManager.java b/test/lib/jdk/test/lib/artifacts/JibArtifactManager.java index a66be9b482629..3d27709ce0306 100644 --- a/test/lib/jdk/test/lib/artifacts/JibArtifactManager.java +++ b/test/lib/jdk/test/lib/artifacts/JibArtifactManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -75,7 +75,7 @@ public static JibArtifactManager newInstance() throws ClassNotFoundException { ClassLoader oldContextLoader = currentThread.getContextClassLoader(); currentThread.setContextClassLoader(classLoader); - Class jibServiceFactory = classLoader.loadClass(JIB_SERVICE_FACTORY); + Class jibServiceFactory = classLoader.loadClass(JIB_SERVICE_FACTORY); try { Object jibArtifactInstaller = jibServiceFactory.getMethod("createJibArtifactInstaller").invoke(null); return new JibArtifactManager(jibArtifactInstaller, classLoader); diff --git a/test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java b/test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java index 11bea44fa33ae..89c1ea9e4ac63 100644 --- a/test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java +++ b/test/lib/jdk/test/lib/classloader/ClassUnloadCommon.java @@ -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 @@ -32,6 +32,7 @@ import jdk.test.whitebox.WhiteBox; import java.io.File; +import java.io.Serial; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; @@ -45,6 +46,9 @@ public class ClassUnloadCommon { public static class TestFailure extends RuntimeException { + @Serial + private static final long serialVersionUID = -8108935949624559549L; + TestFailure(String msg) { super(msg); } diff --git a/test/lib/jdk/test/lib/classloader/GeneratingClassLoader.java b/test/lib/jdk/test/lib/classloader/GeneratingClassLoader.java index ee1089bac4d32..19dd4df959150 100644 --- a/test/lib/jdk/test/lib/classloader/GeneratingClassLoader.java +++ b/test/lib/jdk/test/lib/classloader/GeneratingClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, 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 @@ -38,13 +38,13 @@ class TemplateClass { public class GeneratingClassLoader extends ClassLoader { - public synchronized Class loadClass(String name) throws ClassNotFoundException { + public synchronized Class loadClass(String name) throws ClassNotFoundException { return loadClass(name, false); } - public synchronized Class loadClass(String name, boolean resolve) + public synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { - Class c = findLoadedClass(name); + Class c = findLoadedClass(name); if (c != null) { return c; } @@ -129,7 +129,7 @@ private byte[] getByteCode() throws ClassNotFoundException { throw new RuntimeException("Class name not found in template class file"); } } - return (byte[]) bytecode.clone(); + return bytecode.clone(); } private void readByteCode() throws ClassNotFoundException { diff --git a/test/lib/jdk/test/lib/classloader/GeneratingCompilingClassLoader.java b/test/lib/jdk/test/lib/classloader/GeneratingCompilingClassLoader.java index 34e3a250cdd25..5e040b689f0ea 100644 --- a/test/lib/jdk/test/lib/classloader/GeneratingCompilingClassLoader.java +++ b/test/lib/jdk/test/lib/classloader/GeneratingCompilingClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, 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 @@ -202,7 +202,7 @@ public Class generateClass(int sizeFactor) throws IOException { */ public Class[] getGeneratedClasses(int sizeFactor, int numClasses) throws IOException { GeneratedClass[] gc = getGeneratedClass(sizeFactor, numClasses); - Class[] classes = new Class[numClasses]; + Class[] classes = new Class[numClasses]; for (int i = 0; i < numClasses; ++i) { classes[i] = defineClass(gc[i].name, gc[i].bytes, 0 , gc[i].bytes.length); } diff --git a/test/lib/jdk/test/lib/format/ArrayDiff.java b/test/lib/jdk/test/lib/format/ArrayDiff.java index 1e0aedad94b19..67b75ef3dce67 100644 --- a/test/lib/jdk/test/lib/format/ArrayDiff.java +++ b/test/lib/jdk/test/lib/format/ArrayDiff.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -107,7 +107,7 @@ public static ArrayDiff of(Object first, Object second) { * @throws NullPointerException if at least one of the arrays is null * @return an ArrayDiff instance for the two arrays and formatting parameters provided */ - @SuppressWarnings("rawtypes") + @SuppressWarnings({"rawtypes", "unchecked"}) public static ArrayDiff of(Object first, Object second, int width, int contextBefore) { Objects.requireNonNull(first); Objects.requireNonNull(second); diff --git a/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java b/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java index b50045a7287b1..9841e1b01c573 100644 --- a/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaHeapObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, 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 @@ -35,12 +35,6 @@ import java.util.Map; import jdk.test.lib.hprof.util.Misc; - -/** - * - * @author Bill Foote - */ - /** * Represents an object that's allocated out of the Java heap. It occupies * memory in the VM, and is the sort of thing that in a JDK 1.1 VM had diff --git a/test/lib/jdk/test/lib/hprof/model/JavaStatic.java b/test/lib/jdk/test/lib/hprof/model/JavaStatic.java index 0fa3fbb06dc54..fbb794def56d7 100644 --- a/test/lib/jdk/test/lib/hprof/model/JavaStatic.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaStatic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, 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 @@ -30,11 +30,6 @@ package jdk.test.lib.hprof.model; -/** - * - * @author Bill Foote - */ - /** * Represents the value of a static field of a JavaClass */ diff --git a/test/lib/jdk/test/lib/hprof/model/JavaThing.java b/test/lib/jdk/test/lib/hprof/model/JavaThing.java index a76c9cc3198c5..9674a413d2440 100644 --- a/test/lib/jdk/test/lib/hprof/model/JavaThing.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaThing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, 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 @@ -30,12 +30,6 @@ package jdk.test.lib.hprof.model; -/** - * - * @author Bill Foote - */ - - /** * Represents a java "Thing". A thing is anything that can be the value of * a field. This includes JavaHeapObject, JavaObjectRef, and JavaValue. diff --git a/test/lib/jdk/test/lib/hprof/model/Root.java b/test/lib/jdk/test/lib/hprof/model/Root.java index 3e87eb22a44e7..c3b821be0769d 100644 --- a/test/lib/jdk/test/lib/hprof/model/Root.java +++ b/test/lib/jdk/test/lib/hprof/model/Root.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, 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 @@ -32,12 +32,6 @@ import jdk.test.lib.hprof.util.Misc; -/** - * - * @author Bill Foote - */ - - /** * Represents a member of the rootset, that is, one of the objects that * the GC starts from when marking reachable objects. diff --git a/test/lib/jdk/test/lib/hprof/model/Snapshot.java b/test/lib/jdk/test/lib/hprof/model/Snapshot.java index 3ea77b876fd61..dbb9c7fd1f3e1 100644 --- a/test/lib/jdk/test/lib/hprof/model/Snapshot.java +++ b/test/lib/jdk/test/lib/hprof/model/Snapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, 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 @@ -30,17 +30,13 @@ package jdk.test.lib.hprof.model; +import java.io.IOException; import java.lang.ref.SoftReference; import java.util.*; import jdk.test.lib.hprof.parser.ReadBuffer; import jdk.test.lib.hprof.util.Misc; -/** - * - * @author Bill Foote - */ - /** * Represents a snapshot of the Java objects in the VM at one instant. * This is the top-level "model" object read out of a single .hprof or .bod @@ -637,7 +633,7 @@ private synchronized void initSiteTraces() { } @Override - public void close() throws Exception { + public void close() throws IOException { readBuf.close(); } diff --git a/test/lib/jdk/test/lib/hprof/model/StackFrame.java b/test/lib/jdk/test/lib/hprof/model/StackFrame.java index 0ea2b0e471663..851faffd67cbe 100644 --- a/test/lib/jdk/test/lib/hprof/model/StackFrame.java +++ b/test/lib/jdk/test/lib/hprof/model/StackFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, 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 @@ -30,12 +30,6 @@ package jdk.test.lib.hprof.model; -/** - * - * @author Bill Foote - */ - - /** * Represents a stack frame. */ diff --git a/test/lib/jdk/test/lib/hprof/model/StackTrace.java b/test/lib/jdk/test/lib/hprof/model/StackTrace.java index ecab592e3420f..b4a9c66781259 100644 --- a/test/lib/jdk/test/lib/hprof/model/StackTrace.java +++ b/test/lib/jdk/test/lib/hprof/model/StackTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, 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 @@ -30,12 +30,6 @@ package jdk.test.lib.hprof.model; -/** - * - * @author Bill Foote - */ - - /** * Represents a stack trace, that is, an ordered collection of stack frames. */ diff --git a/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java index eab5cff84c83d..be7672170b69c 100644 --- a/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/FileReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, 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 @@ -86,7 +86,7 @@ public synchronized long getLong(long pos) throws IOException { } @Override - public void close() throws Exception { + public void close() throws IOException { file.close(); } } diff --git a/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java index d91c453a0f698..96da03a4057fd 100644 --- a/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/MappedReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, 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 @@ -127,7 +127,7 @@ public synchronized long getLong(long pos) throws IOException { } @Override - public void close() throws Exception { + public void close() throws IOException { file.close(); } diff --git a/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java b/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java index 4b06b79a53b2f..03c9d5d4a42bb 100644 --- a/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java +++ b/test/lib/jdk/test/lib/hprof/parser/ReadBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, 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 @@ -43,4 +43,5 @@ public interface ReadBuffer extends AutoCloseable { public short getShort(long pos) throws IOException; public int getInt(long pos) throws IOException; public long getLong(long pos) throws IOException; + public void close() throws IOException; } diff --git a/test/lib/jdk/test/lib/hprof/parser/Reader.java b/test/lib/jdk/test/lib/hprof/parser/Reader.java index 447d96e770edd..7732befe50379 100644 --- a/test/lib/jdk/test/lib/hprof/parser/Reader.java +++ b/test/lib/jdk/test/lib/hprof/parser/Reader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, 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 @@ -63,6 +63,7 @@ protected Reader(PositionDataInputStream in) { * @param heapFile The name of a file containing a heap dump * @param callStack If true, read the call stack of allocaation sites */ + @SuppressWarnings("try") public static Snapshot readFile(String heapFile, boolean callStack, int debugLevel) throws IOException { @@ -136,6 +137,7 @@ public static Snapshot readFile(String heapFile, boolean callStack, * * @param heapFile The name of a file containing a heap dump */ + @SuppressWarnings("try") public static String getStack(String heapFile, int debugLevel) throws IOException { int dumpNumber = 1; diff --git a/test/lib/jdk/test/lib/jfr/Events.java b/test/lib/jdk/test/lib/jfr/Events.java index 5a180659f9fcf..5676b7021d621 100644 --- a/test/lib/jdk/test/lib/jfr/Events.java +++ b/test/lib/jdk/test/lib/jfr/Events.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, 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 @@ -233,7 +233,7 @@ public static void assertMissingValue(RecordedEvent event, String name) { private static void assertThread(RecordedThread eventThread, Thread thread) { assertNotNull(eventThread, "Thread in event was null"); - assertEquals(eventThread.getJavaThreadId(), thread.getId(), "Wrong thread id"); + assertEquals(eventThread.getJavaThreadId(), thread.threadId(), "Wrong thread id"); assertEquals(eventThread.getJavaName(), thread.getName(), "Wrong thread name"); ThreadGroup threadGroup = thread.getThreadGroup(); diff --git a/test/lib/jdk/test/lib/jvmti/DebugeeClass.java b/test/lib/jdk/test/lib/jvmti/DebugeeClass.java index c71e25edd9975..9025d5eefe87a 100644 --- a/test/lib/jdk/test/lib/jvmti/DebugeeClass.java +++ b/test/lib/jdk/test/lib/jvmti/DebugeeClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, 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 @@ -23,6 +23,8 @@ package jdk.test.lib.jvmti; +import java.io.Serial; + /** * Base class for debuggee class in JVMTI tests. * @@ -49,6 +51,7 @@ public class DebugeeClass { /** * This method is used to load library with native methods implementation, if needed. */ + @SuppressWarnings("restricted") public static void loadLibrary(String name) { try { System.loadLibrary(name); @@ -70,6 +73,9 @@ public static void safeSleep(long millis) { } public class Failure extends RuntimeException { + @Serial + private static final long serialVersionUID = -4069390356498980839L; + public Failure() { } diff --git a/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java b/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java index eeb4297f5009c..c42d78ad1770f 100644 --- a/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java +++ b/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, 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 @@ -45,7 +45,7 @@ public static void waitUntilBlockingOnObject(Thread thread, Thread.State state, + Integer.toHexString(System.identityHashCode(object)); ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); while (thread.isAlive()) { - ThreadInfo ti = tmx.getThreadInfo(thread.getId()); + ThreadInfo ti = tmx.getThreadInfo(thread.threadId()); if (ti.getThreadState() == state && (want == null || want.equals(ti.getLockName()))) { return; @@ -60,7 +60,7 @@ public static void waitUntilBlockingOnObject(Thread thread, Thread.State state, public static void waitUntilInNative(Thread thread) throws InterruptedException { ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); while (thread.isAlive()) { - ThreadInfo ti = tmx.getThreadInfo(thread.getId()); + ThreadInfo ti = tmx.getThreadInfo(thread.threadId()); if (ti.isInNative()) { return; } diff --git a/test/lib/jdk/test/lib/net/IPSupport.java b/test/lib/jdk/test/lib/net/IPSupport.java index 4c606fe9b4220..31255e20c6a99 100644 --- a/test/lib/jdk/test/lib/net/IPSupport.java +++ b/test/lib/jdk/test/lib/net/IPSupport.java @@ -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 @@ -60,6 +60,7 @@ public class IPSupport { } } + @SuppressWarnings("try") private static boolean isSupported(Class addressType) { ProtocolFamily family = addressType == Inet4Address.class ? StandardProtocolFamily.INET : StandardProtocolFamily.INET6; diff --git a/test/lib/jdk/test/lib/os/linux/HugePageConfiguration.java b/test/lib/jdk/test/lib/os/linux/HugePageConfiguration.java index 0bb6db1602102..0873cb2b5d032 100644 --- a/test/lib/jdk/test/lib/os/linux/HugePageConfiguration.java +++ b/test/lib/jdk/test/lib/os/linux/HugePageConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -160,7 +160,6 @@ private static long readDefaultHugePageSizeFromOS() { while (scanner.hasNextLine()) { Matcher mat = pat.matcher(scanner.nextLine()); if (mat.matches()) { - scanner.close(); return Long.parseLong(mat.group(1)) * 1024; } } diff --git a/test/lib/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java index bfee1d1820dcc..7d03268cac472 100644 --- a/test/lib/jdk/test/lib/process/ProcessTools.java +++ b/test/lib/jdk/test/lib/process/ProcessTools.java @@ -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 @@ -981,7 +981,7 @@ public static void main(String[] args) throws Throwable { String[] classArgs = new String[args.length - 2]; System.arraycopy(args, 2, classArgs, 0, args.length - 2); Class c = Class.forName(className); - Method mainMethod = c.getMethod("main", new Class[] { String[].class }); + Method mainMethod = c.getMethod("main", new Class[] { String[].class }); mainMethod.setAccessible(true); if (testThreadFactoryName.equals("Virtual")) { diff --git a/test/lib/jdk/test/lib/thread/VThreadPinner.java b/test/lib/jdk/test/lib/thread/VThreadPinner.java index f77dba978efa1..c6b332d2791e9 100644 --- a/test/lib/jdk/test/lib/thread/VThreadPinner.java +++ b/test/lib/jdk/test/lib/thread/VThreadPinner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, 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 @@ -114,7 +114,9 @@ public static void runPinned(ThrowingRunnable task) thr throw e; if (ex instanceof Error e) throw e; - throw (X) ex; + @SuppressWarnings("unchecked") + var x = (X) ex; + throw x; } } diff --git a/test/lib/jdk/test/lib/thread/VThreadRunner.java b/test/lib/jdk/test/lib/thread/VThreadRunner.java index 1b09e5e0d1222..3c1a076659a04 100644 --- a/test/lib/jdk/test/lib/thread/VThreadRunner.java +++ b/test/lib/jdk/test/lib/thread/VThreadRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -94,7 +94,9 @@ public static void run(String name, throw e; if (ex instanceof Error e) throw e; - throw (X) ex; + @SuppressWarnings("unchecked") + var x = (X) ex; + throw x; } } diff --git a/test/lib/jdk/test/lib/util/FileUtils.java b/test/lib/jdk/test/lib/util/FileUtils.java index 191cb46f9c243..7b2ab434af2f5 100644 --- a/test/lib/jdk/test/lib/util/FileUtils.java +++ b/test/lib/jdk/test/lib/util/FileUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -266,7 +266,7 @@ public static boolean areMountPointsAccessibleAndUnique() { (new InputStreamReader(proc.getInputStream())); // Skip the first line as it is the "df" output header. if (reader.readLine() != null ) { - Set mountPoints = new HashSet(); + Set mountPoints = new HashSet<>(); String mountPoint = null; while ((mountPoint = reader.readLine()) != null) { if (!mountPoints.add(mountPoint)) { @@ -299,8 +299,8 @@ public static boolean areMountPointsAccessibleAndUnique() { }; }); - final AtomicReference throwableReference = - new AtomicReference(); + final AtomicReference throwableReference = + new AtomicReference<>(); thr.setUncaughtExceptionHandler( new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { @@ -315,7 +315,7 @@ public void uncaughtException(Thread t, Throwable e) { throw new RuntimeException(ie); } - Throwable uncaughtException = (Throwable)throwableReference.get(); + Throwable uncaughtException = throwableReference.get(); if (uncaughtException != null) { throw new RuntimeException(uncaughtException); } @@ -365,6 +365,7 @@ public static void listFileDescriptors(PrintStream ps) { } // Return the current process handle count + @SuppressWarnings("restricted") public static long getProcessHandleCount() { if (IS_WINDOWS) { if (!nativeLibLoaded) { From baca7daa32d553b647bdb33bb74a0eb84542deeb Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Fri, 17 Jan 2025 16:24:47 +0000 Subject: [PATCH 40/47] 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 9bab6042436d5..4fc8072dcd5e0 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 7a2d054820614..5946fc2c435b6 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 65bff94e71c00..e103f83ce3319 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 7c9311fc49a74..845ef960e01bc 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 3530fcff2b3f9..ecc505205580c 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 @@ class ArchivePtrBitmapCleaner: public BitMapClosure { } } 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 9a570984079fd..118159eb3bf02 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 d34e190a48b15..dba6aeb3e47a6 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 be9f2ace64f50..eb90bfb77fc47 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 422cb3b9bfe6c..9bf4d15e514e1 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 c552e48c8b8e9..5724a5fa6ab81 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 1216811aeea6e..3c54cb44c290f 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 a6df19ef91598..6f853b3f0a317 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 650d0a9fa744d..700c6da0f9009 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 2574a3918b19c..897b42b12f697 100644 --- a/src/hotspot/share/classfile/stringTable.cpp +++ b/src/hotspot/share/classfile/stringTable.cpp @@ -311,7 +311,7 @@ class StringTableLookupOop : public StringTableLookup { 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 040ba4795e45a..b08089f13dee4 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 @@ class SymbolTableConfig : public AllStatic { 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 ed8147a95a809..85725116f351b 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 c577f86a3c37d..40b778c198d8b 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 518a53ca26ecf..8581fc235541e 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 3d987d04b8d42..a025c857973ee 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 dfddfff2f05c0..8838871094657 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 783be86586147..78dee5e37920d 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 f5a0ab1bf533a..1b5251ae26620 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 d7e5981aa00c8..7fdf5e6778e71 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 6829db90b4bc1..eb23c4dc9c557 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 a7575c820c5a3..e6617223c16f0 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 0777d5aafc32d..83e7a1b917f61 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 0aa74566f42cb..a3f58dd8218c2 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 d298381f1038f..05db534117429 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 ec4f405f1c9cd..4514df6a182d5 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 25dd8cd6bebe7..12e23080166ec 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 @@ class Array: public MetaspaceObj { 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 @@ class Array: public MetaspaceObj { 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 5532b406b6d4d..688599170ad16 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 fb94f4fac8d6d..b44bcb700c899 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 a90c9284b1a9a..0190d25e002c2 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 9ce953380ba82..3dad778a73a47 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 7319e93b6679c..6d2a35d082c45 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 @@ class StackChunkVerifyOopsClosure : public OopClosure { 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 @@ class StackChunkVerifyBitmapClosure : public BitMapClosure { 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 59b70a162ebf5..4862d0333db09 100644 --- a/src/hotspot/share/prims/jvmtiEnter.xsl +++ b/src/hotspot/share/prims/jvmtiEnter.xsl @@ -1,6 +1,6 @@