[foreign-memaccess+abi] Integrated: 8312473: Return value corrupted when using CCS + isTrivial
Jorn Vernee
jvernee at openjdk.org
Thu Jul 20 21:05:57 UTC 2023
On Thu, 20 Jul 2023 16:20:13 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> 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.
>
> I've updated the capture call state test to also test all the cases in trivial mode.
This pull request has now been integrated.
Changeset: 9dd1c5f0
Author: Jorn Vernee <jvernee at openjdk.org>
URL: https://git.openjdk.org/panama-foreign/commit/9dd1c5f0003330671926e171aba7acd9fc6a27f1
Stats: 39 lines in 5 files changed: 12 ins; 0 del; 27 mod
8312473: Return value corrupted when using CCS + isTrivial
Reviewed-by: mcimadamore
-------------
PR: https://git.openjdk.org/panama-foreign/pull/848
More information about the panama-dev
mailing list