Skip to content

Commit ed067f1

Browse files
committed
[GR-64716] Fix extreme slowdown in debugger after resuming from a breakpoint.
PullRequest: graal/20881
2 parents f5e16b2 + 1649c37 commit ed067f1

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/api/JDWPContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,5 +502,7 @@ public interface JDWPContext {
502502

503503
void steppingInProgress(Thread t, boolean value);
504504

505+
boolean isSteppingInProgress(Thread t);
506+
505507
void replaceController(DebuggerController newController);
506508
}

espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/DebuggerController.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,22 @@ public boolean resume(Object thread) {
510510

511511
fine(() -> "Waking up thread: " + getThreadName(thread));
512512
threadSuspension.removeHardSuspendedThread(thread);
513+
514+
Thread hostThread = context.asHostThread(thread);
515+
if (!context.isSteppingInProgress(hostThread)) {
516+
// We need to notify the Truffle debugger session that this thread is resumed.
517+
// Otherwise, we risk losing an update to the stepping strategy, which causes a
518+
// major slowdown due to frame materialization required for e.g. onReturn
519+
// notifications.
520+
fine(() -> "calling underlying resume method for guestThread: " + getThreadName(thread));
521+
522+
try {
523+
debuggerSession.resume(hostThread);
524+
} catch (IllegalStateException e) {
525+
// debugger session is closed. Safe to ignore
526+
}
527+
}
528+
513529
lock.release();
514530
lock.notifyAll();
515531
return true;

espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/EspressoThreadLocalState.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ public void setSteppingInProgress(boolean value) {
137137
stepInProgress = value;
138138
}
139139

140+
public boolean isSteppingInProgress() {
141+
return stepInProgress;
142+
}
143+
140144
public boolean disableSingleStepping(boolean forceDisable) {
141145
if (forceDisable || stepInProgress) {
142146
singleSteppingDisabledCounter++;

espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/JDWPContextImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,17 @@ public void steppingInProgress(Thread t, boolean value) {
284284
}
285285
}
286286

287+
@Override
288+
public boolean isSteppingInProgress(Thread t) {
289+
Object previous = null;
290+
try {
291+
previous = controller.enterTruffleContext();
292+
return context.getLanguage().getThreadLocalStateFor(t).isSteppingInProgress();
293+
} finally {
294+
controller.leaveTruffleContext(previous);
295+
}
296+
}
297+
287298
@Override
288299
public Object[] getAllGuestThreads() {
289300
StaticObject[] activeThreads = context.getActiveThreads();

0 commit comments

Comments
 (0)