8136596: Remove aarch64: MemBarRelease when final field's allocation is NoEscape or ArgEscape
authorroland
Mon, 21 Sep 2015 10:51:33 +0200
changeset 33077 55f205e96044
parent 33076 f05566b7ed14
child 33078 9452eb89c16d
8136596: Remove aarch64: MemBarRelease when final field's allocation is NoEscape or ArgEscape Summary: elide MemBar when AllocateNode _is_non_escaping Reviewed-by: kvn, roland Contributed-by: hui.shi@linaro.org
hotspot/src/share/vm/opto/callnode.hpp
hotspot/src/share/vm/opto/macro.cpp
hotspot/src/share/vm/opto/memnode.cpp
--- a/hotspot/src/share/vm/opto/callnode.hpp	Tue Sep 22 13:42:09 2015 +0200
+++ b/hotspot/src/share/vm/opto/callnode.hpp	Mon Sep 21 10:51:33 2015 +0200
@@ -907,6 +907,18 @@
 
   // Convenience for initialization->maybe_set_complete(phase)
   bool maybe_set_complete(PhaseGVN* phase);
+
+  // Return true if allocation doesn't escape thread, its escape state
+  // needs be noEscape or ArgEscape. InitializeNode._does_not_escape
+  // is true when its allocation's escape state is noEscape or
+  // ArgEscape. In case allocation's InitializeNode is NULL, check
+  // AlllocateNode._is_non_escaping flag.
+  // AlllocateNode._is_non_escaping is true when its escape state is
+  // noEscape.
+  bool does_not_escape_thread() {
+    InitializeNode* init = NULL;
+    return _is_non_escaping || (((init = initialization()) != NULL) && init->does_not_escape());
+  }
 };
 
 //------------------------------AllocateArray---------------------------------
--- a/hotspot/src/share/vm/opto/macro.cpp	Tue Sep 22 13:42:09 2015 +0200
+++ b/hotspot/src/share/vm/opto/macro.cpp	Mon Sep 21 10:51:33 2015 +0200
@@ -1512,7 +1512,8 @@
     // MemBarStoreStore so that stores that initialize this object
     // can't be reordered with a subsequent store that makes this
     // object accessible by other threads.
-    if (init == NULL || (!init->is_complete_with_arraycopy() && !init->does_not_escape())) {
+    if (!alloc->does_not_escape_thread() &&
+        (init == NULL || !init->is_complete_with_arraycopy())) {
       if (init == NULL || init->req() < InitializeNode::RawStores) {
         // No InitializeNode or no stores captured by zeroing
         // elimination. Simply add the MemBarStoreStore after object
--- a/hotspot/src/share/vm/opto/memnode.cpp	Tue Sep 22 13:42:09 2015 +0200
+++ b/hotspot/src/share/vm/opto/memnode.cpp	Mon Sep 21 10:51:33 2015 +0200
@@ -2945,7 +2945,7 @@
       // Final field stores.
       Node* alloc = AllocateNode::Ideal_allocation(in(MemBarNode::Precedent), phase);
       if ((alloc != NULL) && alloc->is_Allocate() &&
-          alloc->as_Allocate()->_is_non_escaping) {
+          alloc->as_Allocate()->does_not_escape_thread()) {
         // The allocated object does not escape.
         eliminate = true;
       }