RFR: 8350106: [PPC] Avoid ticks_unknown_not_Java AsyncGetCallTrace() if JavaFrameAnchor::_last_Java_pc not set

Richard Reingruber rrich at openjdk.org
Tue Feb 25 09:34:26 UTC 2025


This pr changes `JavaThread::pd_get_top_frame_for_profiling` to better address situations where

1. `JavaThread::last_Java_sp()` returns != null
2. `JavaThread::last_Java_pc()` returns null

If the runtime needs to walk the stack of a java thread in that state, e.g. for gc purposes, it finds the last java pc relative to the last java sp (see [frame::setup()](https://github.com/openjdk/jdk/blob/3f0c1370269db978072814c2170fc3987efade85/src/hotspot/cpu/ppc/frame_ppc.inline.hpp#L40)).

This relies on the runtime method being called to store the return pc to its caller's abi which it will do when pushing a new frame for calling another method.

For an asynchronous interrupt to sample the stack this means: if there isn't at least one frame between the last java frame and the frame where the interrupt occurred then we can't be sure that the return pc was already saved and `pd_get_top_frame_for_profiling()` needs to return false indicating failure.

Otherwise we can and should proceed constructing a frame even though `JavaThread::last_Java_pc()` returned null.

Testing:

* DaCapo Tomcat with async-profiler on a fastdebug build.
* Tier 1-4 of hotspot and jdk on the main platforms and also on Linux/PPC64le and AIX.

-------------

Commit messages:
 - Better handle _last_Java_pc == null

Changes: https://git.openjdk.org/jdk/pull/23640/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23640&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8350106
  Stats: 25 lines in 2 files changed: 17 ins; 0 del; 8 mod
  Patch: https://git.openjdk.org/jdk/pull/23640.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23640/head:pull/23640

PR: https://git.openjdk.org/jdk/pull/23640


More information about the hotspot-runtime-dev mailing list