58 #include "opto/memnode.hpp" 59 #include "opto/mulnode.hpp" 60 #include "opto/narrowptrnode.hpp" 61 #include "opto/node.hpp" 62 #include "opto/opcodes.hpp" 63 #include "opto/output.hpp" 64 #include "opto/parse.hpp" 65 #include "opto/phaseX.hpp" 66 #include "opto/rootnode.hpp" 67 #include "opto/runtime.hpp" 68 #include "opto/stringopts.hpp" 69 #include "opto/type.hpp" 70 #include "opto/vectornode.hpp" 71 #include "runtime/arguments.hpp" 72 #include "runtime/sharedRuntime.hpp" 73 #include "runtime/signature.hpp" 74 #include "runtime/stubRoutines.hpp" 75 #include "runtime/timer.hpp" 76 #include "utilities/align.hpp" 77 #include "utilities/copy.hpp" 78 #if INCLUDE_G1GC 79 #include "gc/g1/g1ThreadLocalData.hpp" 80 #endif // INCLUDE_G1GC 81 82 83 // -------------------- Compile::mach_constant_base_node ----------------------- 84 // Constant table base node singleton. 85 MachConstantBaseNode* Compile::mach_constant_base_node() { 86 if (_mach_constant_base_node == NULL) { 87 _mach_constant_base_node = new MachConstantBaseNode(); 88 _mach_constant_base_node->add_req(C->root()); 89 } 90 return _mach_constant_base_node; 91 } 92 93 94 /// Support for intrinsics. 95 96 // Return the index at which m must be inserted (or already exists). 97 // The sort order is by the address of the ciMethod, with is_virtual as minor key. 98 class IntrinsicDescPair { 99 private: 100 ciMethod* _m; 2146 igvn.optimize(); 2147 } 2148 } 2149 2150 set_inlining_incrementally(false); 2151 } 2152 2153 2154 //------------------------------Optimize--------------------------------------- 2155 // Given a graph, optimize it. 2156 void Compile::Optimize() { 2157 TracePhase tp("optimizer", &timers[_t_optimizer]); 2158 2159 #ifndef PRODUCT 2160 if (_directive->BreakAtCompileOption) { 2161 BREAKPOINT; 2162 } 2163 2164 #endif 2165 2166 ResourceMark rm; 2167 int loop_opts_cnt; 2168 2169 print_inlining_reinit(); 2170 2171 NOT_PRODUCT( verify_graph_edges(); ) 2172 2173 print_method(PHASE_AFTER_PARSING); 2174 2175 { 2176 // Iterative Global Value Numbering, including ideal transforms 2177 // Initialize IterGVN with types and values from parse-time GVN 2178 PhaseIterGVN igvn(initial_gvn()); 2179 #ifdef ASSERT 2180 _modified_nodes = new (comp_arena()) Unique_Node_List(comp_arena()); 2181 #endif 2182 { 2183 TracePhase tp("iterGVN", &timers[_t_iterGVN]); 2184 igvn.optimize(); 2185 } 2318 } 2319 2320 print_method(PHASE_ITER_GVN2, 2); 2321 2322 if (failing()) return; 2323 2324 // Loop transforms on the ideal graph. Range Check Elimination, 2325 // peeling, unrolling, etc. 2326 if(loop_opts_cnt > 0) { 2327 debug_only( int cnt = 0; ); 2328 while(major_progress() && (loop_opts_cnt > 0)) { 2329 TracePhase tp("idealLoop", &timers[_t_idealLoop]); 2330 assert( cnt++ < 40, "infinite cycle in loop optimization" ); 2331 PhaseIdealLoop ideal_loop( igvn, true); 2332 loop_opts_cnt--; 2333 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2); 2334 if (failing()) return; 2335 } 2336 } 2337 2338 if (failing()) return; 2339 2340 // Ensure that major progress is now clear 2341 C->clear_major_progress(); 2342 2343 { 2344 // Verify that all previous optimizations produced a valid graph 2345 // at least to this point, even if no loop optimizations were done. 2346 TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]); 2347 PhaseIdealLoop::verify(igvn); 2348 } 2349 2350 if (range_check_cast_count() > 0) { 2351 // No more loop optimizations. Remove all range check dependent CastIINodes. 2352 C->remove_range_check_casts(igvn); 2353 igvn.optimize(); 2354 } 2355 2356 #ifdef ASSERT 2357 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); 2358 bs->verify_gc_barriers(false); 2359 #endif 2360 2361 { 2362 TracePhase tp("macroExpand", &timers[_t_macroExpand]); 2363 PhaseMacroExpand mex(igvn); 2364 if (mex.expand_macro_nodes()) { 2365 assert(failing(), "must bail out w/ explicit message"); 2366 return; 2367 } 2368 } 2369 2370 if (opaque4_count() > 0) { 2371 C->remove_opaque4_nodes(igvn); 2372 igvn.optimize(); 2373 } 2374 2375 DEBUG_ONLY( _modified_nodes = NULL; ) 2376 } // (End scope of igvn; run destructor if necessary for asserts.) 2377 2378 process_print_inlining(); 2379 // A method with only infinite loops has no edges entering loops from root 2380 { 2873 case Op_GetAndAddL: 2874 case Op_GetAndSetS: 2875 case Op_GetAndSetB: 2876 case Op_GetAndSetI: 2877 case Op_GetAndSetL: 2878 case Op_GetAndSetP: 2879 case Op_GetAndSetN: 2880 case Op_StoreP: 2881 case Op_StoreN: 2882 case Op_StoreNKlass: 2883 case Op_LoadB: 2884 case Op_LoadUB: 2885 case Op_LoadUS: 2886 case Op_LoadI: 2887 case Op_LoadKlass: 2888 case Op_LoadNKlass: 2889 case Op_LoadL: 2890 case Op_LoadL_unaligned: 2891 case Op_LoadPLocked: 2892 case Op_LoadP: 2893 case Op_LoadN: 2894 case Op_LoadRange: 2895 case Op_LoadS: { 2896 handle_mem: 2897 #ifdef ASSERT 2898 if( VerifyOptoOopOffsets ) { 2899 assert( n->is_Mem(), "" ); 2900 MemNode *mem = (MemNode*)n; 2901 // Check to see if address types have grounded out somehow. 2902 const TypeInstPtr *tp = mem->in(MemNode::Address)->bottom_type()->isa_instptr(); 2903 assert( !tp || oop_offset_is_sane(tp), "" ); 2904 } 2905 #endif 2906 break; 2907 } 2908 2909 case Op_AddP: { // Assert sane base pointers 2910 Node *addp = n->in(AddPNode::Address); 2911 assert( !addp->is_AddP() || 2912 addp->in(AddPNode::Base)->is_top() || // Top OK for allocation | 58 #include "opto/memnode.hpp" 59 #include "opto/mulnode.hpp" 60 #include "opto/narrowptrnode.hpp" 61 #include "opto/node.hpp" 62 #include "opto/opcodes.hpp" 63 #include "opto/output.hpp" 64 #include "opto/parse.hpp" 65 #include "opto/phaseX.hpp" 66 #include "opto/rootnode.hpp" 67 #include "opto/runtime.hpp" 68 #include "opto/stringopts.hpp" 69 #include "opto/type.hpp" 70 #include "opto/vectornode.hpp" 71 #include "runtime/arguments.hpp" 72 #include "runtime/sharedRuntime.hpp" 73 #include "runtime/signature.hpp" 74 #include "runtime/stubRoutines.hpp" 75 #include "runtime/timer.hpp" 76 #include "utilities/align.hpp" 77 #include "utilities/copy.hpp" 78 #include "utilities/macros.hpp" 79 #if INCLUDE_G1GC 80 #include "gc/g1/g1ThreadLocalData.hpp" 81 #endif // INCLUDE_G1GC 82 #if INCLUDE_ZGC 83 #include "gc/z/c2/zBarrierSetC2.hpp" 84 #endif 85 86 87 // -------------------- Compile::mach_constant_base_node ----------------------- 88 // Constant table base node singleton. 89 MachConstantBaseNode* Compile::mach_constant_base_node() { 90 if (_mach_constant_base_node == NULL) { 91 _mach_constant_base_node = new MachConstantBaseNode(); 92 _mach_constant_base_node->add_req(C->root()); 93 } 94 return _mach_constant_base_node; 95 } 96 97 98 /// Support for intrinsics. 99 100 // Return the index at which m must be inserted (or already exists). 101 // The sort order is by the address of the ciMethod, with is_virtual as minor key. 102 class IntrinsicDescPair { 103 private: 104 ciMethod* _m; 2150 igvn.optimize(); 2151 } 2152 } 2153 2154 set_inlining_incrementally(false); 2155 } 2156 2157 2158 //------------------------------Optimize--------------------------------------- 2159 // Given a graph, optimize it. 2160 void Compile::Optimize() { 2161 TracePhase tp("optimizer", &timers[_t_optimizer]); 2162 2163 #ifndef PRODUCT 2164 if (_directive->BreakAtCompileOption) { 2165 BREAKPOINT; 2166 } 2167 2168 #endif 2169 2170 #ifdef ASSERT 2171 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); 2172 bs->verify_gc_barriers(true); 2173 #endif 2174 2175 ResourceMark rm; 2176 int loop_opts_cnt; 2177 2178 print_inlining_reinit(); 2179 2180 NOT_PRODUCT( verify_graph_edges(); ) 2181 2182 print_method(PHASE_AFTER_PARSING); 2183 2184 { 2185 // Iterative Global Value Numbering, including ideal transforms 2186 // Initialize IterGVN with types and values from parse-time GVN 2187 PhaseIterGVN igvn(initial_gvn()); 2188 #ifdef ASSERT 2189 _modified_nodes = new (comp_arena()) Unique_Node_List(comp_arena()); 2190 #endif 2191 { 2192 TracePhase tp("iterGVN", &timers[_t_iterGVN]); 2193 igvn.optimize(); 2194 } 2327 } 2328 2329 print_method(PHASE_ITER_GVN2, 2); 2330 2331 if (failing()) return; 2332 2333 // Loop transforms on the ideal graph. Range Check Elimination, 2334 // peeling, unrolling, etc. 2335 if(loop_opts_cnt > 0) { 2336 debug_only( int cnt = 0; ); 2337 while(major_progress() && (loop_opts_cnt > 0)) { 2338 TracePhase tp("idealLoop", &timers[_t_idealLoop]); 2339 assert( cnt++ < 40, "infinite cycle in loop optimization" ); 2340 PhaseIdealLoop ideal_loop( igvn, true); 2341 loop_opts_cnt--; 2342 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2); 2343 if (failing()) return; 2344 } 2345 } 2346 2347 #if INCLUDE_ZGC 2348 if (UseZGC) { 2349 ZBarrierSetC2::find_dominating_barriers(igvn); 2350 } 2351 #endif 2352 2353 if (failing()) return; 2354 2355 // Ensure that major progress is now clear 2356 C->clear_major_progress(); 2357 2358 { 2359 // Verify that all previous optimizations produced a valid graph 2360 // at least to this point, even if no loop optimizations were done. 2361 TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]); 2362 PhaseIdealLoop::verify(igvn); 2363 } 2364 2365 if (range_check_cast_count() > 0) { 2366 // No more loop optimizations. Remove all range check dependent CastIINodes. 2367 C->remove_range_check_casts(igvn); 2368 igvn.optimize(); 2369 } 2370 2371 #ifdef ASSERT 2372 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); 2373 bs->verify_gc_barriers(false); 2374 #endif 2375 2376 print_method(PHASE_BEFORE_MACRO_EXPANSION, 2); 2377 2378 { 2379 TracePhase tp("macroExpand", &timers[_t_macroExpand]); 2380 PhaseMacroExpand mex(igvn); 2381 if (mex.expand_macro_nodes()) { 2382 assert(failing(), "must bail out w/ explicit message"); 2383 return; 2384 } 2385 } 2386 2387 if (opaque4_count() > 0) { 2388 C->remove_opaque4_nodes(igvn); 2389 igvn.optimize(); 2390 } 2391 2392 DEBUG_ONLY( _modified_nodes = NULL; ) 2393 } // (End scope of igvn; run destructor if necessary for asserts.) 2394 2395 process_print_inlining(); 2396 // A method with only infinite loops has no edges entering loops from root 2397 { 2890 case Op_GetAndAddL: 2891 case Op_GetAndSetS: 2892 case Op_GetAndSetB: 2893 case Op_GetAndSetI: 2894 case Op_GetAndSetL: 2895 case Op_GetAndSetP: 2896 case Op_GetAndSetN: 2897 case Op_StoreP: 2898 case Op_StoreN: 2899 case Op_StoreNKlass: 2900 case Op_LoadB: 2901 case Op_LoadUB: 2902 case Op_LoadUS: 2903 case Op_LoadI: 2904 case Op_LoadKlass: 2905 case Op_LoadNKlass: 2906 case Op_LoadL: 2907 case Op_LoadL_unaligned: 2908 case Op_LoadPLocked: 2909 case Op_LoadP: 2910 #if INCLUDE_ZGC 2911 case Op_LoadBarrierSlowReg: 2912 case Op_LoadBarrierWeakSlowReg: 2913 #endif 2914 case Op_LoadN: 2915 case Op_LoadRange: 2916 case Op_LoadS: { 2917 handle_mem: 2918 #ifdef ASSERT 2919 if( VerifyOptoOopOffsets ) { 2920 assert( n->is_Mem(), "" ); 2921 MemNode *mem = (MemNode*)n; 2922 // Check to see if address types have grounded out somehow. 2923 const TypeInstPtr *tp = mem->in(MemNode::Address)->bottom_type()->isa_instptr(); 2924 assert( !tp || oop_offset_is_sane(tp), "" ); 2925 } 2926 #endif 2927 break; 2928 } 2929 2930 case Op_AddP: { // Assert sane base pointers 2931 Node *addp = n->in(AddPNode::Address); 2932 assert( !addp->is_AddP() || 2933 addp->in(AddPNode::Base)->is_top() || // Top OK for allocation |