[foreign-memaccess+abi] RFR: 8294970: Add linker option for saving thread-locals that the VM can overwrite

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Oct 26 13:36:40 UTC 2022


On Wed, 26 Oct 2022 13:21:38 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/abi/PreservableValues.java line 43:
>> 
>>> 41:     PreservableValues(String valueName, ValueLayout layout, int mask) {
>>> 42:         this.valueName = valueName;
>>> 43:         this.layout = layout.withName(valueName);
>> 
>> Ok, layouts get the name attached - which can be used by developers to generate the correct getter. Another choice, I realize, would have been for the PreserveValue linker option to expose a static getter which takes a name. Then you don't need to expose a layout. Not sure which one is better. The current approach is probably cleaner in that if the layout doesn't have a certain named layout, then you cannot obtain a getter for it.
>
> Besides getting, you'd also need to know the layout in order to allocate the segment to pass to a downcall. So, the layout is needed either way (or at least a byte size). A _static_ getter wouldn't work, since a layout can be different depending on the combination of values saved. An instance getter could be an option, but then I don't think the var handle underneath will be seen as constant.

Good point

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

PR: https://git.openjdk.org/panama-foreign/pull/742


More information about the panama-dev mailing list