RFR: 8303040: linux PPC64le: Implementation of Foreign Function & Memory API (Preview) [v35]
Martin Doerr
mdoerr at openjdk.org
Tue May 23 15:21:11 UTC 2023
On Tue, 23 May 2023 07:46:08 GMT, Richard Reingruber <rrich at openjdk.org> wrote:
>> src/hotspot/cpu/ppc/downcallLinker_ppc.cpp line 163:
>>
>>> 161: // The Parameter Save Area needs to be at least 8 slots for ABIv1.
>>> 162: // ABIv2 allows omitting it when all parameters can get passed in registers. We currently don't optimize this.
>>> 163: // For ABIv2, we only need (_input_registers.length() > 8) ? _input_registers.length() : 0
>>
>> The PSA is also needed if the parameter list is variable in length. Is the expression `(_input_registers.length() > 8) ? _input_registers.length() : 0` correct in that case too?
>> Otherwise: `ABIv2 allows omitting it if the callee's prototype indicates that stack parameters are not expected. We currently don't optimize this.`
>
> Ok, I see now. This is not obvious though. There are a few layers of abstraction at play which hide this. A comment is needed. Maybe like this:
> ```c++
> // With ABIv1 a Parameter Save Area of at least 8 double words is always needed.
> // ABIv2 allows omitting it if the callee's prototype indicates that stack parameters are not expected.
> // We currently don't optimize this (see DowncallStubGenerator in the backend).
> if (reg == null) return stack;
I believe omitting the PSA is wrong for varargs, but we don't have this information in the backend. So, I think we should simply not optimize it. Reserving 64 Byte stack space should be affordable for a downcall even if it's not always needed. The Java side could compute it, but there's no way to pass this information to the backend. I've improved the comments. Please take a look.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/12708#discussion_r1202235085
More information about the core-libs-dev
mailing list