src/hotspot/share/opto/compile.cpp
changeset 52711 f480ad035c73
parent 52471 04d7e790aa2e
child 52925 9c18c9d839d3
equal deleted inserted replaced
52710:70adb0f573a7 52711:f480ad035c73
  1120   set_clear_upper_avx(false);  //false as default for clear upper bits of ymm registers
  1120   set_clear_upper_avx(false);  //false as default for clear upper bits of ymm registers
  1121   Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist));
  1121   Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist));
  1122   set_decompile_count(0);
  1122   set_decompile_count(0);
  1123 
  1123 
  1124   set_do_freq_based_layout(_directive->BlockLayoutByFrequencyOption);
  1124   set_do_freq_based_layout(_directive->BlockLayoutByFrequencyOption);
  1125   set_num_loop_opts(LoopOptsCount);
  1125   _loop_opts_cnt = LoopOptsCount;
  1126   set_do_inlining(Inline);
  1126   set_do_inlining(Inline);
  1127   set_max_inline_size(MaxInlineSize);
  1127   set_max_inline_size(MaxInlineSize);
  1128   set_freq_inline_size(FreqInlineSize);
  1128   set_freq_inline_size(FreqInlineSize);
  1129   set_do_scheduling(OptoScheduling);
  1129   set_do_scheduling(OptoScheduling);
  1130   set_do_count_invocations(false);
  1130   set_do_count_invocations(false);
  2167 
  2167 
  2168   set_inlining_incrementally(false);
  2168   set_inlining_incrementally(false);
  2169 }
  2169 }
  2170 
  2170 
  2171 
  2171 
  2172 bool Compile::optimize_loops(int& loop_opts_cnt, PhaseIterGVN& igvn, LoopOptsMode mode) {
  2172 bool Compile::optimize_loops(PhaseIterGVN& igvn, LoopOptsMode mode) {
  2173   if(loop_opts_cnt > 0) {
  2173   if(_loop_opts_cnt > 0) {
  2174     debug_only( int cnt = 0; );
  2174     debug_only( int cnt = 0; );
  2175     while(major_progress() && (loop_opts_cnt > 0)) {
  2175     while(major_progress() && (_loop_opts_cnt > 0)) {
  2176       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
  2176       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
  2177       assert( cnt++ < 40, "infinite cycle in loop optimization" );
  2177       assert( cnt++ < 40, "infinite cycle in loop optimization" );
  2178       PhaseIdealLoop ideal_loop(igvn, mode);
  2178       PhaseIdealLoop ideal_loop(igvn, mode);
  2179       loop_opts_cnt--;
  2179       _loop_opts_cnt--;
  2180       if (failing())  return false;
  2180       if (failing())  return false;
  2181       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2);
  2181       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2);
  2182     }
  2182     }
  2183   }
  2183   }
  2184   return true;
  2184   return true;
  2200   BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
  2200   BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
  2201   bs->verify_gc_barriers(this, BarrierSetC2::BeforeOptimize);
  2201   bs->verify_gc_barriers(this, BarrierSetC2::BeforeOptimize);
  2202 #endif
  2202 #endif
  2203 
  2203 
  2204   ResourceMark rm;
  2204   ResourceMark rm;
  2205   int          loop_opts_cnt;
       
  2206 
  2205 
  2207   print_inlining_reinit();
  2206   print_inlining_reinit();
  2208 
  2207 
  2209   NOT_PRODUCT( verify_graph_edges(); )
  2208   NOT_PRODUCT( verify_graph_edges(); )
  2210 
  2209 
  2303 
  2302 
  2304   // Loop transforms on the ideal graph.  Range Check Elimination,
  2303   // Loop transforms on the ideal graph.  Range Check Elimination,
  2305   // peeling, unrolling, etc.
  2304   // peeling, unrolling, etc.
  2306 
  2305 
  2307   // Set loop opts counter
  2306   // Set loop opts counter
  2308   loop_opts_cnt = num_loop_opts();
  2307   if((_loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) {
  2309   if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) {
       
  2310     {
  2308     {
  2311       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
  2309       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
  2312       PhaseIdealLoop ideal_loop(igvn, LoopOptsDefault);
  2310       PhaseIdealLoop ideal_loop(igvn, LoopOptsDefault);
  2313       loop_opts_cnt--;
  2311       _loop_opts_cnt--;
  2314       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP1, 2);
  2312       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP1, 2);
  2315       if (failing())  return;
  2313       if (failing())  return;
  2316     }
  2314     }
  2317     // Loop opts pass if partial peeling occurred in previous pass
  2315     // Loop opts pass if partial peeling occurred in previous pass
  2318     if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) {
  2316     if(PartialPeelLoop && major_progress() && (_loop_opts_cnt > 0)) {
  2319       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
  2317       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
  2320       PhaseIdealLoop ideal_loop(igvn, LoopOptsSkipSplitIf);
  2318       PhaseIdealLoop ideal_loop(igvn, LoopOptsSkipSplitIf);
  2321       loop_opts_cnt--;
  2319       _loop_opts_cnt--;
  2322       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP2, 2);
  2320       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP2, 2);
  2323       if (failing())  return;
  2321       if (failing())  return;
  2324     }
  2322     }
  2325     // Loop opts pass for loop-unrolling before CCP
  2323     // Loop opts pass for loop-unrolling before CCP
  2326     if(major_progress() && (loop_opts_cnt > 0)) {
  2324     if(major_progress() && (_loop_opts_cnt > 0)) {
  2327       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
  2325       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
  2328       PhaseIdealLoop ideal_loop(igvn, LoopOptsSkipSplitIf);
  2326       PhaseIdealLoop ideal_loop(igvn, LoopOptsSkipSplitIf);
  2329       loop_opts_cnt--;
  2327       _loop_opts_cnt--;
  2330       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP3, 2);
  2328       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP3, 2);
  2331     }
  2329     }
  2332     if (!failing()) {
  2330     if (!failing()) {
  2333       // Verify that last round of loop opts produced a valid graph
  2331       // Verify that last round of loop opts produced a valid graph
  2334       TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]);
  2332       TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]);
  2359 
  2357 
  2360   if (failing())  return;
  2358   if (failing())  return;
  2361 
  2359 
  2362   // Loop transforms on the ideal graph.  Range Check Elimination,
  2360   // Loop transforms on the ideal graph.  Range Check Elimination,
  2363   // peeling, unrolling, etc.
  2361   // peeling, unrolling, etc.
  2364   if (!optimize_loops(loop_opts_cnt, igvn, LoopOptsDefault)) {
  2362   if (!optimize_loops(igvn, LoopOptsDefault)) {
  2365     return;
  2363     return;
  2366   }
  2364   }
  2367 
  2365 
  2368 #if INCLUDE_ZGC
  2366 #if INCLUDE_ZGC
  2369   if (UseZGC) {
  2367   if (UseZGC) {
  2397   {
  2395   {
  2398     TracePhase tp("macroExpand", &timers[_t_macroExpand]);
  2396     TracePhase tp("macroExpand", &timers[_t_macroExpand]);
  2399     PhaseMacroExpand  mex(igvn);
  2397     PhaseMacroExpand  mex(igvn);
  2400     print_method(PHASE_BEFORE_MACRO_EXPANSION, 2);
  2398     print_method(PHASE_BEFORE_MACRO_EXPANSION, 2);
  2401     if (mex.expand_macro_nodes()) {
  2399     if (mex.expand_macro_nodes()) {
       
  2400       assert(failing(), "must bail out w/ explicit message");
       
  2401       return;
       
  2402     }
       
  2403   }
       
  2404 
       
  2405   {
       
  2406     TracePhase tp("barrierExpand", &timers[_t_barrierExpand]);
       
  2407     print_method(PHASE_BEFORE_BARRIER_EXPAND, 2);
       
  2408     BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
       
  2409     if (bs->expand_barriers(this, igvn)) {
  2402       assert(failing(), "must bail out w/ explicit message");
  2410       assert(failing(), "must bail out w/ explicit message");
  2403       return;
  2411       return;
  2404     }
  2412     }
  2405   }
  2413   }
  2406 
  2414