Integrated: 8313023: Return value corrupted when using CCS + isTrivial (mainline)

Jorn Vernee jvernee at openjdk.org
Mon Jul 31 08:05:00 UTC 2023


On Tue, 25 Jul 2023 19:17:38 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> Port of: https://github.com/openjdk/panama-foreign/pull/848 from the panama-foreign repo.
> 
> Copying the PR body here for convenience:
> 
> Due to a bug in the downcall linker stub generation, we don't save the return value when capturing call state for trivial functions, and the return value gets corrupted.
> 
> We try not to save the return register around calls on the return path of a downcall stub, if it is not needed. Currently we don't save the return register when we're using a return buffer, since we write the return value to the return buffer before the calls on the return path, which means it is safe for those calls to overwrite the return register. But, the current logic also says we don't need to save the return register if the function is trivial (_needs_transition == false). The logic behind this was initially that, since we don't have any calls on the return path, we don't need to save the return register. But, after adding support for capturing call state, we now also have a call on the return path for trivial functions that capture call state, and around that call, we might need to save the return register.
> 
> The fix is to simply save the return register when capturing call state, regardless of whether the function is trivial or not. In the case of just a trivial function that doesn't capture call state, we still don't save the return register around the return path calls for the thread state transition (which is not needed), since we don't generate those thread state transitions in the first first place.
> 
> Testing: jdk-tier1, jdk-tier2, jdk-tier5.

This pull request has now been integrated.

Changeset: 6fca2898
Author:    Jorn Vernee <jvernee at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/6fca28988794b52a6aa974bed1ed6f4f07e0994b
Stats:     39 lines in 5 files changed: 12 ins; 0 del; 27 mod

8313023: Return value corrupted when using CCS + isTrivial (mainline)

Reviewed-by: mcimadamore, vlivanov

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

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


More information about the core-libs-dev mailing list