[foreign-memaccess+abi] RFR: Prevent maxAlign virtual calls for polluted accesses [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Aug 8 17:41:19 UTC 2022


On Mon, 8 Aug 2022 17:28:13 GMT, Radoslaw Smogura <duke at openjdk.org> wrote:

>> is this the affected code?
>> 
>> // @@@ Smarter alignment checking if accessing heap segment backing non-byte[] array
>>         if (msp.maxAlignMask() > 1) {
>>             throw new IllegalArgumentException();
>>         }
>>  ```
>
> Exactly!

I guess which solution is taken depends on how deep of a problem this is. I suggest writing a benchmark using e.g. bulk copy between segments, and see if the same issue occurs. We do have tests for polluted memory segment access and we have not seen issues with maxAlignMask showing up there, so I'm curious as to why the vector use-site seems to be more problematic. I wonder if part of the issue is the lack of argument type profiling - e.g. profile info based on the type of arguments in a static call. I think Method/VarHandle have that enabled by default (for obvious reasons) and there are hacks in the JVM to allow that for Unsafe as well. But that support is not enabled for this particular vector call, and I wonder if that could lead to the problem you describe.

https://github.com/openjdk/jdk/blob/master/src/hotspot/share/oops/methodData.cpp#L1583

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

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


More information about the panama-dev mailing list