[foreign-memaccess+abi] RFR: Remove mem barriers to allow loop optimizations for vectors accessing off-heap

Vladimir Ivanov vlivanov at openjdk.java.net
Thu Jul 22 18:54:26 UTC 2021


On Thu, 22 Jul 2021 08:23:49 GMT, Radoslaw Smogura <github.com+7535718+rsmogura at openjdk.org> wrote:

> Just for curiosity is this same case like with VarHandle.get / getOpaque?

No, it is different.

`VH.get()` vs `VH.getOpaque()` have slightly different semantics which is currently implemented using memory barriers (but it doesn't have to). (It is`!is_unordered` case in `C2Access::needs_cpu_membar()` which covers non-plain accesses.)  

But even plain accesses (but only unsafe ones) sometimes need to be surrounded by memory barriers to preserve correctness when it is not possible to determine a unique alias category which represents the memory the access operates on. That's the case described in the comment:

    // We will need memory barriers unless we can determine a unique
    // alias category for this reference.  (Note:  If for some reason
    // the barriers get omitted and the unsafe reference begins to "pollute"
    // the alias analysis of the rest of the graph, either Compile::can_alias
    // or Compile::must_alias will throw a diagnostic assert.)

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

PR: https://git.openjdk.java.net/panama-foreign/pull/566


More information about the panama-dev mailing list