[aarch64-port-dev ] RFR: 8144993: Elide redundant memory barrier after AllocationNode

Vladimir Kozlov vladimir.kozlov at oracle.com
Tue Dec 15 02:40:02 UTC 2015


Very interesting!

Please, add short statement to the comment in /macro.cpp for your case.

Changes looks fine to me. One nit could be to delay bytecode analysis 
until macro expansion - it may reduce compilation time. Bytecode 
analysis of each constructor could be expensive.

Thanks,
Vladimir

On 12/10/15 6:48 AM, Hui Shi wrote:
> Hi All,
>
>
> Could some one help comments this change?
>
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8144993
>
> webrev: http://cr.openjdk.java.net/~hshi/8144993/webrev/
>
>
> This patch aims to remove redundant memory barrier after allocation
> node, on AArch64 it removes redundant dmb when creating object. The
> motivation is dmb instructions after commonly used object allocation,
> for example string and boxing objects is redundant with dmb inserted for
> final field write. In following small case:____
>
> __ __
>
> String foo(String s)____
>
> {____
>
>     String copy = new String(s);____
>
>     return copy;____
>
> }____
>
> __ __
>
> There are two dmb instructions in generated code. First one is
> membar_storestore, inserted in PhaseMacroExpand::expand_allocate_common.
> Second one is membar_release, inserted at exit of initializer method as
> final fields write happens. Allocated String doesn't escape in String
> initializer method, membar_release includes membar_storestore semantic.
> So first one can be removed safely.____
>
> __ __
>
>    0x0000007f85bbfa8c: prfm      pstl1keep, [x11,#256]____
>
>    0x0000007f85bbfa90: str       xzr, [x0,#16]____
>
>    0x0000007f85bbfa94: dmb       ishst        // first dmb to remove____
>
>    ....____
>
> ____
>
>    0x0000007fa01d83c0: ldrsb     w10, [x20,#20]____
>
>    0x0000007fa01d83c4: ldr       w12, [x20,#16]____
>
>    0x0000007fa01d83c8: ldr       x11, [sp,#8]____
>
>    0x0000007fa01d83cc: strb      w10, [x11,#20]____
>
>    0x0000007fa01d83d0: str       w12, [x11,#16]____
>
>    0x0000007fa01d83d4: dmb       ish        // second dmb____
>
> __ __
>
>
> Patch targets this pattern and remove redundant memory barrier for
> allocation node.____
>
> 1. When inserting memory barrier for final field write. If final fields'
> object allocation node is available, invoke
> AllocationNode::compute_MemBar_redundancy(initializer method).____
>
> 2. In AllocationNode:____
>
>      2.1 Add a new field _is_allocation_MemBar_redundant flag indicate
> if memory barrier after allocation node is redundant.____
>
>     2.2 Add method compute_MemBar_redundancy, set
>   _is_allocation_MemBar_redundant true if first parameter "this" does
> not escape in initializer method according to BCEscapeAnalyzer.____
>
> 3. skip inserting memory barrier in
> PhaseMacroExpand::expand_allocate_common, when AllocationNode's
> _is_allocation_MemBar_redundant flagis true.
>
>
> Regards
>
> Hui
>


More information about the aarch64-port-dev mailing list