Skip to content

Commit 17244c6

Browse files
author
Serguei Spitsyn
committed
8368159: Significant performance overhead when started with jdwp agent and unattached debugger
Reviewed-by: lmesnik, cjplummer
1 parent 2aafda1 commit 17244c6

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

src/hotspot/share/prims/jvmtiExport.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,6 +1690,23 @@ void JvmtiExport::post_vthread_unmount(jobject vthread) {
16901690
}
16911691
}
16921692

1693+
bool JvmtiExport::has_frame_pops(JavaThread* thread) {
1694+
if (!can_post_frame_pop()) {
1695+
return false;
1696+
}
1697+
JvmtiThreadState *state = get_jvmti_thread_state(thread);
1698+
if (state == nullptr) {
1699+
return false;
1700+
}
1701+
JvmtiEnvThreadStateIterator it(state);
1702+
for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
1703+
if (ets->has_frame_pops()) {
1704+
return true;
1705+
}
1706+
}
1707+
return false;
1708+
}
1709+
16931710
void JvmtiExport::continuation_yield_cleanup(JavaThread* thread, jint continuation_frame_count) {
16941711
if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
16951712
return;

src/hotspot/share/prims/jvmtiExport.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -373,6 +373,7 @@ class JvmtiExport : public AllStatic {
373373
JVMTI_ONLY(return _should_post_class_file_load_hook);
374374
NOT_JVMTI(return false;)
375375
}
376+
static bool has_frame_pops(JavaThread* thread) NOT_JVMTI_RETURN_(false);
376377
static bool is_early_phase() NOT_JVMTI_RETURN_(false);
377378
static bool has_early_class_hook_env() NOT_JVMTI_RETURN_(false);
378379
static bool has_early_vmstart_env() NOT_JVMTI_RETURN_(false);

src/hotspot/share/runtime/continuationFreezeThaw.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,15 +1619,14 @@ static int num_java_frames(ContinuationWrapper& cont) {
16191619
}
16201620

16211621
static void invalidate_jvmti_stack(JavaThread* thread) {
1622-
if (thread->is_interp_only_mode()) {
1623-
JvmtiThreadState *state = thread->jvmti_thread_state();
1624-
if (state != nullptr)
1625-
state->invalidate_cur_stack_depth();
1622+
JvmtiThreadState *state = thread->jvmti_thread_state();
1623+
if (state != nullptr) {
1624+
state->invalidate_cur_stack_depth();
16261625
}
16271626
}
16281627

16291628
static void jvmti_yield_cleanup(JavaThread* thread, ContinuationWrapper& cont) {
1630-
if (JvmtiExport::can_post_frame_pop()) {
1629+
if (JvmtiExport::has_frame_pops(thread)) {
16311630
int num_frames = num_java_frames(cont);
16321631

16331632
ContinuationWrapper::SafepointOp so(Thread::current(), cont);

0 commit comments

Comments
 (0)