[RFR] Remove MemBarRelease when final field's allocation is NoEscape or ArgEscape

Vladimir Kozlov vladimir.kozlov at oracle.com
Sun Sep 13 17:37:31 UTC 2015


Please keep original AllocateNode check and add new check with ||.
There are cases when there is no InitializeNode associated with 
allocation (when there are no access to object) so we need to keep first 
check.

Thanks,
Vladimir

On 9/8/15 5:41 AM, Hui Shi wrote:
> Hi JIT members,
>
>
> There might be better use of escape analysis result when optimizing
> MemBarRelease node for final field stores. Could anyone help review and
> comments?
>
> Patch in
> http://people.linaro.org/~hui.shi/MemBarRelease_Escape/MemBarEscape.patch
>
> __
>
> In hotspot, there are two different escape information recorded on a node.
>
> 1. AlllocateNode._is_non_escaping, true means allocation node’s escape
> state is noEscape.____
>
> 2. InitializeNode._does_not_escape, true means its allocation node’s
> escape state is noEscape or ArgEscape.____
>
> NoEscape has literal meaning. ArgEscape means allocation node is passed
> to callee but will not escape current thread. So ArgEscape is safe to
> remove MemBarRelase node for final field store in initialization method.____
>
> __ __
>
> Pasted test creates an Integer instance in foo, MemBarRelase node is
> created at the end of initialization method as Integer's value field is
> final. New instance is ArgEscaped because it is passed to bar (disable
> inlining bar). It fails to remove MemBarRelase node now, because
> AlllocateNode._is_non_escaping is used in MemBarNode::Ideal(PhaseGVN
> *phase, bool can_reshape) and this flag is false.____
>
> __ __
>
> public class TestInteger {____
>
>    public static void main(String[] args) {____
>
>       for(int i = 0; i < 1000000; i ++)____
>
>         foo(i);____
>
>    }____
>
> __ __
>
>    static int foo(int i) {____
>
>      Integer newi = new Integer(i);____
>
>      return bar(newi);____
>
>    }____
>
> __ __
>
>    static int bar(Integer i) {____
>
>      return i.intValue() + 2;____
>
>    }____
>
> }____
>
> __ __
>
> This patch deletes MemBarRelease node when its allocation node is
> ArgEscape or NoEscape by checking its InitializeNode._does_not_escape
> flag.____
>
>
> Regards
>
> Shi Hui
>


More information about the hotspot-compiler-dev mailing list