RFR: 8313023: Return value corrupted when using CCS + isTrivial (mainline)
Jorn Vernee
jvernee at openjdk.org
Tue Jul 25 20:18:10 UTC 2023
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.
-------------
Commit messages:
- 8312473: Return value corrupted when using CCS + isTrivial
Changes: https://git.openjdk.org/jdk/pull/15025/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15025&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8313023
Stats: 39 lines in 5 files changed: 12 ins; 0 del; 27 mod
Patch: https://git.openjdk.org/jdk/pull/15025.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/15025/head:pull/15025
PR: https://git.openjdk.org/jdk/pull/15025
More information about the hotspot-compiler-dev
mailing list