RFR: 8073093: AARCH64: C2 generates poor code for ByteBuffer accesses

Andrew Haley aph at redhat.com
Wed Feb 18 10:10:55 UTC 2015


On 02/18/2015 10:01 AM, Andrew Dinn wrote:
> On 17/02/15 19:21, Vitaly Davidovich wrote:
>> IMO I don't think such barriers should be removed just because EA is able
>> to elide the heap allocation.
> 
> Why not? Are you assuming that the programmer might be relying on a
> memory barrier being implied in interpreted/JITted code by the presence
> in the source of an allocation? If so then I am not sure the Java memory
> model justifies that assumption, especially so in the case EA optimises.

It doesn't.

There are essentially two ways to prevent unsafe publication of
objects with final fields: either emit a barrier at the end of the
constructor or track the reference to the newly-constructed object
until it is stored in memory.  That store to memory can be a releasing
store.  If the object does not escape that releasing store can be
eliminated.

Andrew.



More information about the core-libs-dev mailing list