< prev index next >

src/hotspot/share/opto/escape.cpp

BarrierSetC2

7  *                                                                                                                                   
8  * This code is distributed in the hope that it will be useful, but WITHOUT                                                          
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or                                                             
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License                                                             
11  * version 2 for more details (a copy is included in the LICENSE file that                                                           
12  * accompanied this code).                                                                                                           
13  *                                                                                                                                   
14  * You should have received a copy of the GNU General Public License version                                                         
15  * 2 along with this work; if not, write to the Free Software Foundation,                                                            
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.                                                                     
17  *                                                                                                                                   
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                           
19  * or visit www.oracle.com if you need additional information or have any                                                            
20  * questions.                                                                                                                        
21  *                                                                                                                                   
22  */                                                                                                                                  
23 
24 #include "precompiled.hpp"                                                                                                           
25 #include "ci/bcEscapeAnalyzer.hpp"                                                                                                   
26 #include "compiler/compileLog.hpp"                                                                                                   
                                                                                                                                     
27 #include "libadt/vectset.hpp"                                                                                                        
28 #include "memory/allocation.hpp"                                                                                                     
29 #include "memory/resourceArea.hpp"                                                                                                   
30 #include "opto/c2compiler.hpp"                                                                                                       
31 #include "opto/arraycopynode.hpp"                                                                                                    
32 #include "opto/callnode.hpp"                                                                                                         
33 #include "opto/cfgnode.hpp"                                                                                                          
34 #include "opto/compile.hpp"                                                                                                          
35 #include "opto/escape.hpp"                                                                                                           
36 #include "opto/phaseX.hpp"                                                                                                           
37 #include "opto/movenode.hpp"                                                                                                         
38 #include "opto/rootnode.hpp"                                                                                                         
39 #if INCLUDE_G1GC                                                                                                                     
40 #include "gc/g1/g1ThreadLocalData.hpp"                                                                                               
41 #endif // INCLUDE_G1GC                                                                                                               
42 
43 ConnectionGraph::ConnectionGraph(Compile * C, PhaseIterGVN *igvn) :                                                                  
44   _nodes(C->comp_arena(), C->unique(), C->unique(), NULL),                                                                           
45   _in_worklist(C->comp_arena()),                                                                                                     

7  *
8  * This code is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * version 2 for more details (a copy is included in the LICENSE file that
12  * accompanied this code).
13  *
14  * You should have received a copy of the GNU General Public License version
15  * 2 along with this work; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.
21  *
22  */
23 
24 #include "precompiled.hpp"
25 #include "ci/bcEscapeAnalyzer.hpp"
26 #include "compiler/compileLog.hpp"
27 #include "gc/shared/c2/barrierSetC2.hpp"
28 #include "libadt/vectset.hpp"
29 #include "memory/allocation.hpp"
30 #include "memory/resourceArea.hpp"
31 #include "opto/c2compiler.hpp"
32 #include "opto/arraycopynode.hpp"
33 #include "opto/callnode.hpp"
34 #include "opto/cfgnode.hpp"
35 #include "opto/compile.hpp"
36 #include "opto/escape.hpp"
37 #include "opto/phaseX.hpp"
38 #include "opto/movenode.hpp"
39 #include "opto/rootnode.hpp"
40 #if INCLUDE_G1GC
41 #include "gc/g1/g1ThreadLocalData.hpp"
42 #endif // INCLUDE_G1GC
43 
44 ConnectionGraph::ConnectionGraph(Compile * C, PhaseIterGVN *igvn) :
45   _nodes(C->comp_arena(), C->unique(), C->unique(), NULL),
46   _in_worklist(C->comp_arena()),

962           assert(aat == Type::TOP || aat == TypePtr::NULL_PTR ||                                                                     
963                  aat->isa_ptr() != NULL, "expecting an Ptr");                                                                        
964           bool arg_has_oops = aat->isa_oopptr() &&                                                                                   
965                               (aat->isa_oopptr()->klass() == NULL || aat->isa_instptr() ||                                           
966                                (aat->isa_aryptr() && aat->isa_aryptr()->klass()->is_obj_array_klass()));                             
967           if (i == TypeFunc::Parms) {                                                                                                
968             src_has_oops = arg_has_oops;                                                                                             
969           }                                                                                                                          
970           //                                                                                                                         
971           // src or dst could be j.l.Object when other is basic type array:                                                          
972           //                                                                                                                         
973           //   arraycopy(char[],0,Object*,0,size);                                                                                   
974           //   arraycopy(Object*,0,char[],0,size);                                                                                   
975           //                                                                                                                         
976           // Don't add edges in such cases.                                                                                          
977           //                                                                                                                         
978           bool arg_is_arraycopy_dest = src_has_oops && is_arraycopy &&                                                               
979                                        arg_has_oops && (i > TypeFunc::Parms);                                                        
980 #ifdef ASSERT                                                                                                                        
981           if (!(is_arraycopy ||                                                                                                      
                                                                                                                                     
982                 (call->as_CallLeaf()->_name != NULL &&                                                                               
983                  (strcmp(call->as_CallLeaf()->_name, "g1_wb_pre")  == 0 ||                                                           
984                   strcmp(call->as_CallLeaf()->_name, "g1_wb_post") == 0 ||                                                           
985                   strcmp(call->as_CallLeaf()->_name, "updateBytesCRC32") == 0 ||                                                     
986                   strcmp(call->as_CallLeaf()->_name, "updateBytesCRC32C") == 0 ||                                                    
987                   strcmp(call->as_CallLeaf()->_name, "updateBytesAdler32") == 0 ||                                                   
988                   strcmp(call->as_CallLeaf()->_name, "aescrypt_encryptBlock") == 0 ||                                                
989                   strcmp(call->as_CallLeaf()->_name, "aescrypt_decryptBlock") == 0 ||                                                
990                   strcmp(call->as_CallLeaf()->_name, "cipherBlockChaining_encryptAESCrypt") == 0 ||                                  
991                   strcmp(call->as_CallLeaf()->_name, "cipherBlockChaining_decryptAESCrypt") == 0 ||                                  
992                   strcmp(call->as_CallLeaf()->_name, "counterMode_AESCrypt") == 0 ||                                                 
993                   strcmp(call->as_CallLeaf()->_name, "ghash_processBlocks") == 0 ||                                                  
994                   strcmp(call->as_CallLeaf()->_name, "sha1_implCompress") == 0 ||                                                    
995                   strcmp(call->as_CallLeaf()->_name, "sha1_implCompressMB") == 0 ||                                                  
996                   strcmp(call->as_CallLeaf()->_name, "sha256_implCompress") == 0 ||                                                  
997                   strcmp(call->as_CallLeaf()->_name, "sha256_implCompressMB") == 0 ||                                                
998                   strcmp(call->as_CallLeaf()->_name, "sha512_implCompress") == 0 ||                                                  
999                   strcmp(call->as_CallLeaf()->_name, "sha512_implCompressMB") == 0 ||                                                
1000                   strcmp(call->as_CallLeaf()->_name, "multiplyToLen") == 0 ||                                                        
1001                   strcmp(call->as_CallLeaf()->_name, "squareToLen") == 0 ||                                                          
1002                   strcmp(call->as_CallLeaf()->_name, "mulAdd") == 0 ||                                                               
1003                   strcmp(call->as_CallLeaf()->_name, "montgomery_multiply") == 0 ||                                                  
1004                   strcmp(call->as_CallLeaf()->_name, "montgomery_square") == 0 ||                                                    

963           assert(aat == Type::TOP || aat == TypePtr::NULL_PTR ||
964                  aat->isa_ptr() != NULL, "expecting an Ptr");
965           bool arg_has_oops = aat->isa_oopptr() &&
966                               (aat->isa_oopptr()->klass() == NULL || aat->isa_instptr() ||
967                                (aat->isa_aryptr() && aat->isa_aryptr()->klass()->is_obj_array_klass()));
968           if (i == TypeFunc::Parms) {
969             src_has_oops = arg_has_oops;
970           }
971           //
972           // src or dst could be j.l.Object when other is basic type array:
973           //
974           //   arraycopy(char[],0,Object*,0,size);
975           //   arraycopy(Object*,0,char[],0,size);
976           //
977           // Don't add edges in such cases.
978           //
979           bool arg_is_arraycopy_dest = src_has_oops && is_arraycopy &&
980                                        arg_has_oops && (i > TypeFunc::Parms);
981 #ifdef ASSERT
982           if (!(is_arraycopy ||
983                 BarrierSet::barrier_set()->barrier_set_c2()->is_gc_barrier_node(call) ||
984                 (call->as_CallLeaf()->_name != NULL &&
985                  (strcmp(call->as_CallLeaf()->_name, "updateBytesCRC32") == 0 ||


986                   strcmp(call->as_CallLeaf()->_name, "updateBytesCRC32C") == 0 ||
987                   strcmp(call->as_CallLeaf()->_name, "updateBytesAdler32") == 0 ||
988                   strcmp(call->as_CallLeaf()->_name, "aescrypt_encryptBlock") == 0 ||
989                   strcmp(call->as_CallLeaf()->_name, "aescrypt_decryptBlock") == 0 ||
990                   strcmp(call->as_CallLeaf()->_name, "cipherBlockChaining_encryptAESCrypt") == 0 ||
991                   strcmp(call->as_CallLeaf()->_name, "cipherBlockChaining_decryptAESCrypt") == 0 ||
992                   strcmp(call->as_CallLeaf()->_name, "counterMode_AESCrypt") == 0 ||
993                   strcmp(call->as_CallLeaf()->_name, "ghash_processBlocks") == 0 ||
994                   strcmp(call->as_CallLeaf()->_name, "sha1_implCompress") == 0 ||
995                   strcmp(call->as_CallLeaf()->_name, "sha1_implCompressMB") == 0 ||
996                   strcmp(call->as_CallLeaf()->_name, "sha256_implCompress") == 0 ||
997                   strcmp(call->as_CallLeaf()->_name, "sha256_implCompressMB") == 0 ||
998                   strcmp(call->as_CallLeaf()->_name, "sha512_implCompress") == 0 ||
999                   strcmp(call->as_CallLeaf()->_name, "sha512_implCompressMB") == 0 ||
1000                   strcmp(call->as_CallLeaf()->_name, "multiplyToLen") == 0 ||
1001                   strcmp(call->as_CallLeaf()->_name, "squareToLen") == 0 ||
1002                   strcmp(call->as_CallLeaf()->_name, "mulAdd") == 0 ||
1003                   strcmp(call->as_CallLeaf()->_name, "montgomery_multiply") == 0 ||
1004                   strcmp(call->as_CallLeaf()->_name, "montgomery_square") == 0 ||

3267       } else if (use->is_MemBar()) {                                                                                                 
3268         if (use->in(TypeFunc::Memory) == n) { // Ignore precedent edge                                                               
3269           memnode_worklist.append_if_missing(use);                                                                                   
3270         }                                                                                                                            
3271 #ifdef ASSERT                                                                                                                        
3272       } else if(use->is_Mem()) {                                                                                                     
3273         assert(use->in(MemNode::Memory) != n, "EA: missing memory path");                                                            
3274       } else if (use->is_MergeMem()) {                                                                                               
3275         assert(_mergemem_worklist.contains(use->as_MergeMem()), "EA: missing MergeMem node in the worklist");                        
3276       } else if (use->Opcode() == Op_EncodeISOArray) {                                                                               
3277         if (use->in(MemNode::Memory) == n || use->in(3) == n) {                                                                      
3278           // EncodeISOArray overwrites destination array                                                                             
3279           memnode_worklist.append_if_missing(use);                                                                                   
3280         }                                                                                                                            
3281       } else {                                                                                                                       
3282         uint op = use->Opcode();                                                                                                     
3283         if ((use->in(MemNode::Memory) == n) &&                                                                                       
3284             (op == Op_StrCompressedCopy || op == Op_StrInflatedCopy)) {                                                              
3285           // They overwrite memory edge corresponding to destination array,                                                          
3286           memnode_worklist.append_if_missing(use);                                                                                   
3287         } else if (!(op == Op_StoreCM ||                                                                                             
3288               (op == Op_CallLeaf && use->as_CallLeaf()->_name != NULL &&                                                             
3289                strcmp(use->as_CallLeaf()->_name, "g1_wb_pre") == 0) ||                                                               
3290               op == Op_AryEq || op == Op_StrComp || op == Op_HasNegatives ||                                                         
3291               op == Op_StrCompressedCopy || op == Op_StrInflatedCopy ||                                                              
3292               op == Op_StrEquals || op == Op_StrIndexOf || op == Op_StrIndexOfChar)) {                                               
3293           n->dump();                                                                                                                 
3294           use->dump();                                                                                                               
3295           assert(false, "EA: missing memory path");                                                                                  
3296         }                                                                                                                            
3297 #endif                                                                                                                               
3298       }                                                                                                                              
3299     }                                                                                                                                
3300   }                                                                                                                                  
3301 
3302   //  Phase 3:  Process MergeMem nodes from mergemem_worklist.                                                                       
3303   //            Walk each memory slice moving the first node encountered of each                                                     
3304   //            instance type to the the input corresponding to its alias index.                                                     
3305   uint length = _mergemem_worklist.length();                                                                                         
3306   for( uint next = 0; next < length; ++next ) {                                                                                      
3307     MergeMemNode* nmm = _mergemem_worklist.at(next);                                                                                 
3308     assert(!visited.test_set(nmm->_idx), "should not be visited before");                                                            

3267       } else if (use->is_MemBar()) {
3268         if (use->in(TypeFunc::Memory) == n) { // Ignore precedent edge
3269           memnode_worklist.append_if_missing(use);
3270         }
3271 #ifdef ASSERT
3272       } else if(use->is_Mem()) {
3273         assert(use->in(MemNode::Memory) != n, "EA: missing memory path");
3274       } else if (use->is_MergeMem()) {
3275         assert(_mergemem_worklist.contains(use->as_MergeMem()), "EA: missing MergeMem node in the worklist");
3276       } else if (use->Opcode() == Op_EncodeISOArray) {
3277         if (use->in(MemNode::Memory) == n || use->in(3) == n) {
3278           // EncodeISOArray overwrites destination array
3279           memnode_worklist.append_if_missing(use);
3280         }
3281       } else {
3282         uint op = use->Opcode();
3283         if ((use->in(MemNode::Memory) == n) &&
3284             (op == Op_StrCompressedCopy || op == Op_StrInflatedCopy)) {
3285           // They overwrite memory edge corresponding to destination array,
3286           memnode_worklist.append_if_missing(use);
3287         } else if (!(BarrierSet::barrier_set()->barrier_set_c2()->is_gc_barrier_node(use) ||


3288               op == Op_AryEq || op == Op_StrComp || op == Op_HasNegatives ||
3289               op == Op_StrCompressedCopy || op == Op_StrInflatedCopy ||
3290               op == Op_StrEquals || op == Op_StrIndexOf || op == Op_StrIndexOfChar)) {
3291           n->dump();
3292           use->dump();
3293           assert(false, "EA: missing memory path");
3294         }
3295 #endif
3296       }
3297     }
3298   }
3299 
3300   //  Phase 3:  Process MergeMem nodes from mergemem_worklist.
3301   //            Walk each memory slice moving the first node encountered of each
3302   //            instance type to the the input corresponding to its alias index.
3303   uint length = _mergemem_worklist.length();
3304   for( uint next = 0; next < length; ++next ) {
3305     MergeMemNode* nmm = _mergemem_worklist.at(next);
3306     assert(!visited.test_set(nmm->_idx), "should not be visited before");
< prev index next >