RFR: 8254231: Implementation of Foreign Linker API (Incubator) [v9]

Paul Sandoz psandoz at openjdk.java.net
Thu Oct 22 16:17:21 UTC 2020


On Thu, 22 Oct 2020 14:26:37 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/AbstractNativeScope.java line 120:
>> 
>>> 118:                 }
>>> 119:             }
>>> 120:             throw new AssertionError("Cannot get here!");
>> 
>> This code is a little confusing, effectively using an exception for control flow, within a retry loop. I recommend performing an explicit bounds check to determine if a new segment of `BLOCK_SIZE` is required from which to slice into. It will also be faster than the exceptional case.
>
> I hear you - that said, note that doing the bound check is not as trivial as it seems; you have to take into account the value of `sp` and add required alignment padding, and then perform a bound check against that - all logic which would need to be duplicated across the normal and the exceptional cases. Which is why the code settled the way it is. I'll see what I can do.

Yeah, i would have probably done the same thing initially.

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

PR: https://git.openjdk.java.net/jdk/pull/634



More information about the security-dev mailing list