Skip to content

Commit d41aa97

Browse files
authored
Merge pull request #2190 from SAP/pr-jdk-25.0.3+4
Merge to tag jdk-25.0.3+4
2 parents 59e6e96 + 30a962c commit d41aa97

60 files changed

Lines changed: 816 additions & 1165 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,7 @@ void ShenandoahAdaptiveHeuristics::adjust_spike_threshold(double amount) {
349349
}
350350

351351
size_t ShenandoahAdaptiveHeuristics::min_free_threshold() {
352-
// Note that soft_max_capacity() / 100 * min_free_threshold is smaller than max_capacity() / 100 * min_free_threshold.
353-
// We want to behave conservatively here, so use max_capacity(). By returning a larger value, we cause the GC to
354-
// trigger when the remaining amount of free shrinks below the larger threshold.
355-
return _space_info->max_capacity() / 100 * ShenandoahMinFreeThreshold;
352+
return ShenandoahHeap::heap()->soft_max_capacity() / 100 * ShenandoahMinFreeThreshold;
356353
}
357354

358355
ShenandoahAllocationRate::ShenandoahAllocationRate() :

src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void ShenandoahGlobalHeuristics::choose_global_collection_set(ShenandoahCollecti
5353
size_t cur_young_garbage) const {
5454
auto heap = ShenandoahGenerationalHeap::heap();
5555
size_t region_size_bytes = ShenandoahHeapRegion::region_size_bytes();
56-
size_t capacity = heap->young_generation()->max_capacity();
56+
size_t capacity = heap->soft_max_capacity();
5757
size_t garbage_threshold = region_size_bytes * ShenandoahGarbageThreshold / 100;
5858
size_t ignore_threshold = region_size_bytes * ShenandoahIgnoreGarbageThreshold / 100;
5959

src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bool ShenandoahMetricsSnapshot::is_good_progress(ShenandoahGeneration* generatio
6464
// ShenandoahCriticalFreeThreshold is expressed as a percentage. We multiple this percentage by 1/100th
6565
// of the generation capacity to determine whether the available memory within the generation exceeds the
6666
// critical threshold.
67-
size_t free_expected = (generation->max_capacity() / 100) * ShenandoahCriticalFreeThreshold;
67+
size_t free_expected = (ShenandoahHeap::heap()->soft_max_capacity() / 100) * ShenandoahCriticalFreeThreshold;
6868

6969
bool prog_free = free_actual >= free_expected;
7070
log_info(gc, ergo)("%s progress for free space: %zu%s, need %zu%s",

src/hotspot/share/jfr/periodic/sampling/jfrCPUTimeThreadSampler.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ class JfrCPUSamplerThread : public NonJavaThread {
231231
volatile bool _is_async_processing_of_cpu_time_jfr_requests_triggered;
232232
volatile bool _warned_about_timer_creation_failure;
233233
volatile bool _signal_handler_installed;
234-
DEBUG_ONLY(volatile bool _out_of_stack_walking_enabled;)
235-
DEBUG_ONLY(volatile u8 _out_of_stack_walking_iterations;)
234+
DEBUG_ONLY(volatile bool _out_of_stack_walking_enabled = true;)
236235

237236
static const u4 STOP_SIGNAL_BIT = 0x80000000;
238237

@@ -284,10 +283,6 @@ class JfrCPUSamplerThread : public NonJavaThread {
284283
void set_out_of_stack_walking_enabled(bool runnable) {
285284
Atomic::release_store(&_out_of_stack_walking_enabled, runnable);
286285
}
287-
288-
u8 out_of_stack_walking_iterations() const {
289-
return Atomic::load(&_out_of_stack_walking_iterations);
290-
}
291286
#endif
292287
};
293288

@@ -395,7 +390,6 @@ void JfrCPUSamplerThread::run() {
395390
}
396391
DEBUG_ONLY(if (Atomic::load_acquire(&_out_of_stack_walking_enabled)) {)
397392
if (Atomic::cmpxchg(&_is_async_processing_of_cpu_time_jfr_requests_triggered, true, false)) {
398-
DEBUG_ONLY(Atomic::inc(&_out_of_stack_walking_iterations);)
399393
stackwalk_threads_in_native();
400394
}
401395
DEBUG_ONLY(})
@@ -589,18 +583,14 @@ void JfrCPUTimeThreadSampling::handle_timer_signal(siginfo_t* info, void* contex
589583
}
590584

591585
#ifdef ASSERT
592-
void JfrCPUTimeThreadSampling::set_out_of_stack_walking_enabled(bool runnable) {
586+
bool JfrCPUTimeThreadSampling::set_out_of_stack_walking_enabled(bool runnable) {
593587
if (_instance != nullptr && _instance->_sampler != nullptr) {
594588
_instance->_sampler->set_out_of_stack_walking_enabled(runnable);
589+
return true;
590+
} else {
591+
return false;
595592
}
596593
}
597-
598-
u8 JfrCPUTimeThreadSampling::out_of_stack_walking_iterations() {
599-
if (_instance != nullptr && _instance->_sampler != nullptr) {
600-
return _instance->_sampler->out_of_stack_walking_iterations();
601-
}
602-
return 0;
603-
}
604594
#endif
605595

606596
void JfrCPUSamplerThread::sample_thread(JfrSampleRequest& request, void* ucontext, JavaThread* jt, JfrThreadLocal* tl, JfrTicks& now) {
@@ -873,8 +863,9 @@ void JfrCPUTimeThreadSampling::on_javathread_terminate(JavaThread* thread) {
873863
}
874864

875865
#ifdef ASSERT
876-
static void set_out_of_stack_walking_enabled(bool runnable) {
866+
bool JfrCPUTimeThreadSampling::set_out_of_stack_walking_enabled(bool runnable) {
877867
warn();
868+
return false;
878869
}
879870
#endif
880871

src/hotspot/share/jfr/periodic/sampling/jfrCPUTimeThreadSampler.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ class JfrCPUTimeThreadSampling : public JfrCHeapObj {
139139

140140
static void trigger_async_processing_of_cpu_time_jfr_requests();
141141

142-
DEBUG_ONLY(static void set_out_of_stack_walking_enabled(bool runnable);)
143-
144-
DEBUG_ONLY(static u8 out_of_stack_walking_iterations();)
142+
DEBUG_ONLY(static bool set_out_of_stack_walking_enabled(bool runnable);)
145143
};
146144

147145
#else
@@ -162,8 +160,7 @@ class JfrCPUTimeThreadSampling : public JfrCHeapObj {
162160

163161
static void on_javathread_create(JavaThread* thread);
164162
static void on_javathread_terminate(JavaThread* thread);
165-
DEBUG_ONLY(static void set_out_of_stack_walking_enabled(bool runnable));
166-
DEBUG_ONLY(static u8 out_of_stack_walking_iterations();)
163+
DEBUG_ONLY(static bool set_out_of_stack_walking_enabled(bool runnable));
167164
};
168165

169166
#endif // defined(LINUX)

src/hotspot/share/prims/whitebox.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,7 +2696,7 @@ WB_ENTRY(void, WB_WaitUnsafe(JNIEnv* env, jobject wb, jint time))
26962696
os::naked_short_sleep(time);
26972697
WB_END
26982698

2699-
WB_ENTRY(void, WB_BusyWait(JNIEnv* env, jobject wb, jint time))
2699+
WB_ENTRY(void, WB_BusyWaitCPUTime(JNIEnv* env, jobject wb, jint time))
27002700
ThreadToNativeFromVM ttn(thread);
27012701
u8 start = os::current_thread_cpu_time();
27022702
u8 target_duration = time * (u8)1000000;
@@ -2707,21 +2707,12 @@ WB_END
27072707

27082708
WB_ENTRY(jboolean, WB_CPUSamplerSetOutOfStackWalking(JNIEnv* env, jobject wb, jboolean enable))
27092709
#if defined(ASSERT) && INCLUDE_JFR && defined(LINUX)
2710-
JfrCPUTimeThreadSampling::set_out_of_stack_walking_enabled(enable == JNI_TRUE);
2711-
return JNI_TRUE;
2710+
return JfrCPUTimeThreadSampling::set_out_of_stack_walking_enabled(enable == JNI_TRUE) ? JNI_TRUE : JNI_FALSE;
27122711
#else
27132712
return JNI_FALSE;
27142713
#endif
27152714
WB_END
27162715

2717-
WB_ENTRY(jlong, WB_CPUSamplerOutOfStackWalkingIterations(JNIEnv* env, jobject wb))
2718-
#if defined(ASSERT) && INCLUDE_JFR && defined(LINUX)
2719-
return (jlong)JfrCPUTimeThreadSampling::out_of_stack_walking_iterations();
2720-
#else
2721-
return 0;
2722-
#endif
2723-
WB_END
2724-
27252716
WB_ENTRY(jstring, WB_GetLibcName(JNIEnv* env, jobject o))
27262717
ThreadToNativeFromVM ttn(thread);
27272718
jstring info_string = env->NewStringUTF(XSTR(LIBC));
@@ -3072,9 +3063,8 @@ static JNINativeMethod methods[] = {
30723063

30733064
{CC"isJVMTIIncluded", CC"()Z", (void*)&WB_IsJVMTIIncluded},
30743065
{CC"waitUnsafe", CC"(I)V", (void*)&WB_WaitUnsafe},
3075-
{CC"busyWait", CC"(I)V", (void*)&WB_BusyWait},
3066+
{CC"busyWaitCPUTime", CC"(I)V", (void*)&WB_BusyWaitCPUTime},
30763067
{CC"cpuSamplerSetOutOfStackWalking", CC"(Z)Z", (void*)&WB_CPUSamplerSetOutOfStackWalking},
3077-
{CC"cpuSamplerOutOfStackWalkingIterations", CC"()J",(void*)&WB_CPUSamplerOutOfStackWalkingIterations},
30783068
{CC"getLibcName", CC"()Ljava/lang/String;", (void*)&WB_GetLibcName},
30793069

30803070
{CC"pinObject", CC"(Ljava/lang/Object;)V", (void*)&WB_PinObject},

test/hotspot/gtest/runtime/test_os_reserve_between.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ TEST_VM(os, attempt_reserve_memory_randomization_cornercases) {
335335

336336
// Test that, regardless where the hole is in the [min, max) range, if we probe nonrandomly, we will fill that hole
337337
// as long as the range size is smaller than the number of probe attempts
338+
// On AIX, the allocation granularity is too large and not well suited for 'small' holes, so we avoid the test
339+
#if !defined(_AIX)
338340
TEST_VM(os, attempt_reserve_memory_between_small_range_fill_hole) {
339341
const size_t ps = os::vm_page_size();
340342
const size_t ag = allocation_granularity();
@@ -348,3 +350,4 @@ TEST_VM(os, attempt_reserve_memory_between_small_range_fill_hole) {
348350
}
349351
}
350352
}
353+
#endif

test/hotspot/jtreg/runtime/Thread/AsyncExceptionOnMonitorEnter.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ public class AsyncExceptionOnMonitorEnter extends Thread {
4444
public static native int exitRawMonitor();
4545
public static native void destroyRawMonitor();
4646

47+
// Avoid using CountDownLatch or similar objects that require unparking the
48+
// main thread. Otherwise, if the main thread is run as a virtual thread, the
49+
// async exception could be sent while the target is still executing FJP logic.
50+
public volatile boolean started = false;
51+
public volatile boolean gotMonitor = false;
52+
4753
private static Object o1 = new Object();
48-
private static boolean firstWorker = true;
49-
private static Semaphore sem = new Semaphore(0);
5054

5155
@Override
5256
public void run() {
@@ -59,11 +63,9 @@ public void run() {
5963

6064
public void testWithJavaMonitor() {
6165
try {
66+
started = true;
6267
synchronized (o1) {
63-
if (firstWorker) {
64-
firstWorker = false;
65-
sem.release();
66-
}
68+
gotMonitor = true;
6769
Thread.sleep(1000);
6870
}
6971
} catch (ThreadDeath td) {
@@ -74,20 +76,16 @@ public void testWithJavaMonitor() {
7476

7577

7678
public void testWithJVMTIRawMonitor() {
77-
boolean savedFirst = false;
7879
try {
80+
started = true;
7981
int retCode = enterRawMonitor();
80-
if (retCode != 0 && firstWorker) {
82+
if (retCode != 0) {
8183
throw new RuntimeException("error in JVMTI RawMonitorEnter: retCode=" + retCode);
8284
}
83-
if (firstWorker) {
84-
firstWorker = false;
85-
savedFirst = true;
86-
sem.release();
87-
}
88-
Thread.sleep(1000);
85+
gotMonitor = true;
86+
Thread.sleep(500);
8987
retCode = exitRawMonitor();
90-
if (retCode != 0 && savedFirst) {
88+
if (retCode != 0) {
9189
throw new RuntimeException("error in JVMTI RawMonitorExit: retCode=" + retCode);
9290
}
9391
} catch (ThreadDeath td) {
@@ -133,15 +131,18 @@ public static void main(String[] args) {
133131
AsyncExceptionOnMonitorEnter worker2 = new AsyncExceptionOnMonitorEnter();
134132

135133
try {
136-
// Start firstWorker worker and wait until monitor is acquired
137-
firstWorker = true;
134+
// Start first worker and wait until monitor is acquired
138135
worker1.start();
139-
sem.acquire();
136+
while (!worker1.gotMonitor) {
137+
Thread.sleep(1);
138+
}
140139

141140
// Start second worker and allow some time for target to block on monitorenter
142141
// before executing Thread.stop()
143142
worker2.start();
144-
Thread.sleep(300);
143+
while (!worker2.started) {
144+
Thread.sleep(10);
145+
}
145146

146147
while (true) {
147148
JVMTIUtils.stopThread(worker2);
@@ -150,6 +151,8 @@ public static void main(String[] args) {
150151
// not released worker2 will deadlock on enter
151152
JVMTIUtils.stopThread(worker1);
152153
}
154+
// Give time to throw exception
155+
Thread.sleep(10);
153156

154157
if (!worker1.isAlive() && !worker2.isAlive()) {
155158
// Done with Thread.stop() calls since

test/hotspot/jtreg/runtime/Thread/AsyncExceptionTest.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ public class AsyncExceptionTest extends Thread {
4949
private final static int DEF_TIME_MAX = 30; // default max # secs to test
5050
private final static String PROG_NAME = "AsyncExceptionTest";
5151

52-
public CountDownLatch startSyncObj = new CountDownLatch(1);
52+
// Avoid using CountDownLatch or similar objects that require unparking the
53+
// main thread. Otherwise, if the main thread is run as a virtual thread, the
54+
// async exception could be sent while the target is still executing FJP logic.
55+
public volatile boolean started = false;
5356

54-
private boolean firstEntry = true;
5557
private boolean receivedThreadDeathinInternal1 = false;
5658
private boolean receivedThreadDeathinInternal2 = false;
5759
private volatile RuntimeException error = null;
@@ -77,6 +79,7 @@ public void run() {
7779

7880
public void internalRun1() {
7981
try {
82+
started = true;
8083
while (!receivedThreadDeathinInternal2) {
8184
internalRun2();
8285
}
@@ -87,16 +90,10 @@ public void internalRun1() {
8790

8891
public void internalRun2() {
8992
try {
90-
Integer myLocalCount = 1;
91-
Integer myLocalCount2 = 1;
93+
int myLocalCount = 1;
94+
int myLocalCount2 = 1;
9295

93-
if (firstEntry) {
94-
// Tell main thread we have started.
95-
startSyncObj.countDown();
96-
firstEntry = false;
97-
}
98-
99-
while(myLocalCount > 0) {
96+
while (myLocalCount > 0) {
10097
myLocalCount2 = (myLocalCount % 3) / 2;
10198
myLocalCount -= 1;
10299
}
@@ -128,7 +125,9 @@ public static void main(String[] args) {
128125
thread.start();
129126
try {
130127
// Wait for the worker thread to get going.
131-
thread.startSyncObj.await();
128+
while (!thread.started) {
129+
Thread.sleep(1);
130+
}
132131
// Send async exception and wait until it is thrown
133132
JVMTIUtils.stopThread(thread);
134133
thread.join();

test/jdk/ProblemList.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ sun/awt/shell/ShellFolderMemoryLeak.java 8197794 windows-all
250250
sun/java2d/DirectX/OverriddenInsetsTest/OverriddenInsetsTest.java 8196102 generic-all
251251
sun/java2d/DirectX/RenderingToCachedGraphicsTest/RenderingToCachedGraphicsTest.java 8196180 windows-all,macosx-all
252252
sun/java2d/OpenGL/OpaqueDest.java#id1 8367574 macosx-all
253+
sun/java2d/OpenGL/ScaleParamsOOB.java#id0 8377908 linux-all
253254
sun/java2d/SunGraphics2D/EmptyClipRenderingTest.java 8144029 macosx-all,linux-all
254255
sun/java2d/SunGraphics2D/DrawImageBilinear.java 8297175 linux-all
255256
sun/java2d/SunGraphics2D/PolyVertTest.java 6986565 generic-all
@@ -794,7 +795,6 @@ java/awt/event/MouseEvent/SpuriousExitEnter/SpuriousExitEnter_1.java 7131438,802
794795
java/awt/event/MouseEvent/SpuriousExitEnter/SpuriousExitEnter_2.java 7131438,8022539 generic-all
795796
java/awt/Modal/WsDisabledStyle/CloseBlocker/CloseBlocker.java 7187741 linux-all,macosx-all
796797
java/awt/xembed/server/TestXEmbedServerJava.java 8001150,8004031 generic-all
797-
java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java 8068378 generic-all
798798
java/awt/image/VolatileImage/VolatileImageConfigurationTest.java 8171069 macosx-all,linux-all
799799
java/awt/Modal/InvisibleParentTest/InvisibleParentTest.java 8172245 linux-all
800800
java/awt/Frame/FrameStateTest/FrameStateTest.java 8203920 macosx-all,linux-all

0 commit comments

Comments
 (0)