[foreign-memaccess+abi] RFR: 8311594: Avoid GlobalSession liveness check [v2]

Jorn Vernee jvernee at openjdk.org
Mon Jul 10 21:28:19 UTC 2023


On Mon, 10 Jul 2023 17:36:06 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> I've also tried another solution which puts an `instanceof` check in the existing `checkValidStateRaw`. This does improve the case with the special `ALL` segment, but it also regresses the polluted case by about just as much it seems.
>> 
>> I think this is a dead end.
>
> IMHO, the only sane way to add support for this is to have a well-known constant - e.g. MemorySegment::allNative (which should be a restricted factory of course). Then special case this constant w.r.t. bound checks and temporal checks (since there's a well-known constant to compare against, I'm confident that pollution will not rear its ugly head). But that brings in a lot of API questions: for instance, if this segment is unbounded, what happens if you slice (of course one possible answer might be to throw). While we *might* add something like that in the future, I don't think we have enough evidence yet that something like this is really required.

I suppose that is not too much different from the instanceof check I tried. The issue I see is that, while when the segment/scope are constant, everything folds away, everybody else now has to do an additional identity check on every access.

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

PR Review Comment: https://git.openjdk.org/panama-foreign/pull/844#discussion_r1258929819


More information about the panama-dev mailing list