< prev index next >

src/hotspot/share/opto/compile.cpp

Print this page




2095     TracePhase tp("incrementalInline_igvn", &timers[_t_incrInline_igvn]);
2096     igvn = PhaseIterGVN(initial_gvn());
2097     igvn.optimize();
2098   }
2099 }
2100 
2101 // Perform incremental inlining until bound on number of live nodes is reached
2102 void Compile::inline_incrementally(PhaseIterGVN& igvn) {
2103   TracePhase tp("incrementalInline", &timers[_t_incrInline]);
2104 
2105   set_inlining_incrementally(true);
2106   uint low_live_nodes = 0;
2107 
2108   while (_late_inlines.length() > 0) {
2109     if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
2110       if (low_live_nodes < (uint)LiveNodeCountInliningCutoff * 8 / 10) {
2111         TracePhase tp("incrementalInline_ideal", &timers[_t_incrInline_ideal]);
2112         // PhaseIdealLoop is expensive so we only try it once we are
2113         // out of live nodes and we only try it again if the previous
2114         // helped got the number of nodes down significantly
2115         PhaseIdealLoop ideal_loop(igvn, LoopOptsNone);
2116         if (failing())  return;
2117         low_live_nodes = live_nodes();
2118         _major_progress = true;
2119       }
2120 
2121       if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
2122         break; // finish
2123       }
2124     }
2125 
2126     for_igvn()->clear();
2127     initial_gvn()->replace_with(&igvn);
2128 
2129     while (inline_incrementally_one()) {
2130       assert(!failing(), "inconsistent");
2131     }
2132 
2133     if (failing())  return;
2134 
2135     inline_incrementally_cleanup(igvn);


2143     for_igvn()->clear();
2144     initial_gvn()->replace_with(&igvn);
2145 
2146     inline_string_calls(false);
2147 
2148     if (failing())  return;
2149 
2150     inline_incrementally_cleanup(igvn);
2151   }
2152 
2153   set_inlining_incrementally(false);
2154 }
2155 
2156 
2157 bool Compile::optimize_loops(PhaseIterGVN& igvn, LoopOptsMode mode) {
2158   if(_loop_opts_cnt > 0) {
2159     debug_only( int cnt = 0; );
2160     while(major_progress() && (_loop_opts_cnt > 0)) {
2161       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2162       assert( cnt++ < 40, "infinite cycle in loop optimization" );
2163       PhaseIdealLoop ideal_loop(igvn, mode);
2164       _loop_opts_cnt--;
2165       if (failing())  return false;
2166       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2);
2167     }
2168   }
2169   return true;
2170 }
2171 
2172 // Remove edges from "root" to each SafePoint at a backward branch.
2173 // They were inserted during parsing (see add_safepoint()) to make
2174 // infinite loops without calls or exceptions visible to root, i.e.,
2175 // useful.
2176 void Compile::remove_root_to_sfpts_edges(PhaseIterGVN& igvn) {
2177   Node *r = root();
2178   if (r != NULL) {
2179     for (uint i = r->req(); i < r->len(); ++i) {
2180       Node *n = r->in(i);
2181       if (n != NULL && n->is_SafePoint()) {
2182         r->rm_prec(i);
2183         if (n->outcnt() == 0) {


2265 
2266   if (!failing() && RenumberLiveNodes && live_nodes() + NodeLimitFudgeFactor < unique()) {
2267     Compile::TracePhase tp("", &timers[_t_renumberLive]);
2268     initial_gvn()->replace_with(&igvn);
2269     for_igvn()->clear();
2270     Unique_Node_List new_worklist(C->comp_arena());
2271     {
2272       ResourceMark rm;
2273       PhaseRenumberLive prl = PhaseRenumberLive(initial_gvn(), for_igvn(), &new_worklist);
2274     }
2275     set_for_igvn(&new_worklist);
2276     igvn = PhaseIterGVN(initial_gvn());
2277     igvn.optimize();
2278   }
2279 
2280   // Perform escape analysis
2281   if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) {
2282     if (has_loops()) {
2283       // Cleanup graph (remove dead nodes).
2284       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2285       PhaseIdealLoop ideal_loop(igvn, LoopOptsNone);
2286       if (major_progress()) print_method(PHASE_PHASEIDEAL_BEFORE_EA, 2);
2287       if (failing())  return;
2288     }
2289     ConnectionGraph::do_analysis(this, &igvn);
2290 
2291     if (failing())  return;
2292 
2293     // Optimize out fields loads from scalar replaceable allocations.
2294     igvn.optimize();
2295     print_method(PHASE_ITER_GVN_AFTER_EA, 2);
2296 
2297     if (failing())  return;
2298 
2299     if (congraph() != NULL && macro_count() > 0) {
2300       TracePhase tp("macroEliminate", &timers[_t_macroEliminate]);
2301       PhaseMacroExpand mexp(igvn);
2302       mexp.eliminate_macro_nodes();
2303       igvn.set_delay_transform(false);
2304 
2305       igvn.optimize();
2306       print_method(PHASE_ITER_GVN_AFTER_ELIMINATION, 2);
2307 
2308       if (failing())  return;
2309     }
2310   }
2311 
2312   // Loop transforms on the ideal graph.  Range Check Elimination,
2313   // peeling, unrolling, etc.
2314 
2315   // Set loop opts counter
2316   if((_loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) {
2317     {
2318       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2319       PhaseIdealLoop ideal_loop(igvn, LoopOptsDefault);
2320       _loop_opts_cnt--;
2321       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP1, 2);
2322       if (failing())  return;
2323     }
2324     // Loop opts pass if partial peeling occurred in previous pass
2325     if(PartialPeelLoop && major_progress() && (_loop_opts_cnt > 0)) {
2326       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2327       PhaseIdealLoop ideal_loop(igvn, LoopOptsSkipSplitIf);
2328       _loop_opts_cnt--;
2329       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP2, 2);
2330       if (failing())  return;
2331     }
2332     // Loop opts pass for loop-unrolling before CCP
2333     if(major_progress() && (_loop_opts_cnt > 0)) {
2334       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2335       PhaseIdealLoop ideal_loop(igvn, LoopOptsSkipSplitIf);
2336       _loop_opts_cnt--;
2337       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP3, 2);
2338     }
2339     if (!failing()) {
2340       // Verify that last round of loop opts produced a valid graph
2341       TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]);
2342       PhaseIdealLoop::verify(igvn);
2343     }
2344   }
2345   if (failing())  return;
2346 
2347   // Conditional Constant Propagation;
2348   PhaseCCP ccp( &igvn );
2349   assert( true, "Break here to ccp.dump_nodes_and_types(_root,999,1)");
2350   {
2351     TracePhase tp("ccp", &timers[_t_ccp]);
2352     ccp.do_transform();
2353   }
2354   print_method(PHASE_CPP1, 2);
2355 




2095     TracePhase tp("incrementalInline_igvn", &timers[_t_incrInline_igvn]);
2096     igvn = PhaseIterGVN(initial_gvn());
2097     igvn.optimize();
2098   }
2099 }
2100 
2101 // Perform incremental inlining until bound on number of live nodes is reached
2102 void Compile::inline_incrementally(PhaseIterGVN& igvn) {
2103   TracePhase tp("incrementalInline", &timers[_t_incrInline]);
2104 
2105   set_inlining_incrementally(true);
2106   uint low_live_nodes = 0;
2107 
2108   while (_late_inlines.length() > 0) {
2109     if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
2110       if (low_live_nodes < (uint)LiveNodeCountInliningCutoff * 8 / 10) {
2111         TracePhase tp("incrementalInline_ideal", &timers[_t_incrInline_ideal]);
2112         // PhaseIdealLoop is expensive so we only try it once we are
2113         // out of live nodes and we only try it again if the previous
2114         // helped got the number of nodes down significantly
2115         PhaseIdealLoop::optimize(igvn, LoopOptsNone);
2116         if (failing())  return;
2117         low_live_nodes = live_nodes();
2118         _major_progress = true;
2119       }
2120 
2121       if (live_nodes() > (uint)LiveNodeCountInliningCutoff) {
2122         break; // finish
2123       }
2124     }
2125 
2126     for_igvn()->clear();
2127     initial_gvn()->replace_with(&igvn);
2128 
2129     while (inline_incrementally_one()) {
2130       assert(!failing(), "inconsistent");
2131     }
2132 
2133     if (failing())  return;
2134 
2135     inline_incrementally_cleanup(igvn);


2143     for_igvn()->clear();
2144     initial_gvn()->replace_with(&igvn);
2145 
2146     inline_string_calls(false);
2147 
2148     if (failing())  return;
2149 
2150     inline_incrementally_cleanup(igvn);
2151   }
2152 
2153   set_inlining_incrementally(false);
2154 }
2155 
2156 
2157 bool Compile::optimize_loops(PhaseIterGVN& igvn, LoopOptsMode mode) {
2158   if(_loop_opts_cnt > 0) {
2159     debug_only( int cnt = 0; );
2160     while(major_progress() && (_loop_opts_cnt > 0)) {
2161       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2162       assert( cnt++ < 40, "infinite cycle in loop optimization" );
2163       PhaseIdealLoop::optimize(igvn, mode);
2164       _loop_opts_cnt--;
2165       if (failing())  return false;
2166       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2);
2167     }
2168   }
2169   return true;
2170 }
2171 
2172 // Remove edges from "root" to each SafePoint at a backward branch.
2173 // They were inserted during parsing (see add_safepoint()) to make
2174 // infinite loops without calls or exceptions visible to root, i.e.,
2175 // useful.
2176 void Compile::remove_root_to_sfpts_edges(PhaseIterGVN& igvn) {
2177   Node *r = root();
2178   if (r != NULL) {
2179     for (uint i = r->req(); i < r->len(); ++i) {
2180       Node *n = r->in(i);
2181       if (n != NULL && n->is_SafePoint()) {
2182         r->rm_prec(i);
2183         if (n->outcnt() == 0) {


2265 
2266   if (!failing() && RenumberLiveNodes && live_nodes() + NodeLimitFudgeFactor < unique()) {
2267     Compile::TracePhase tp("", &timers[_t_renumberLive]);
2268     initial_gvn()->replace_with(&igvn);
2269     for_igvn()->clear();
2270     Unique_Node_List new_worklist(C->comp_arena());
2271     {
2272       ResourceMark rm;
2273       PhaseRenumberLive prl = PhaseRenumberLive(initial_gvn(), for_igvn(), &new_worklist);
2274     }
2275     set_for_igvn(&new_worklist);
2276     igvn = PhaseIterGVN(initial_gvn());
2277     igvn.optimize();
2278   }
2279 
2280   // Perform escape analysis
2281   if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) {
2282     if (has_loops()) {
2283       // Cleanup graph (remove dead nodes).
2284       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2285       PhaseIdealLoop::optimize(igvn, LoopOptsNone);
2286       if (major_progress()) print_method(PHASE_PHASEIDEAL_BEFORE_EA, 2);
2287       if (failing())  return;
2288     }
2289     ConnectionGraph::do_analysis(this, &igvn);
2290 
2291     if (failing())  return;
2292 
2293     // Optimize out fields loads from scalar replaceable allocations.
2294     igvn.optimize();
2295     print_method(PHASE_ITER_GVN_AFTER_EA, 2);
2296 
2297     if (failing())  return;
2298 
2299     if (congraph() != NULL && macro_count() > 0) {
2300       TracePhase tp("macroEliminate", &timers[_t_macroEliminate]);
2301       PhaseMacroExpand mexp(igvn);
2302       mexp.eliminate_macro_nodes();
2303       igvn.set_delay_transform(false);
2304 
2305       igvn.optimize();
2306       print_method(PHASE_ITER_GVN_AFTER_ELIMINATION, 2);
2307 
2308       if (failing())  return;
2309     }
2310   }
2311 
2312   // Loop transforms on the ideal graph.  Range Check Elimination,
2313   // peeling, unrolling, etc.
2314 
2315   // Set loop opts counter
2316   if((_loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) {
2317     {
2318       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2319       PhaseIdealLoop::optimize(igvn, LoopOptsDefault);
2320       _loop_opts_cnt--;
2321       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP1, 2);
2322       if (failing())  return;
2323     }
2324     // Loop opts pass if partial peeling occurred in previous pass
2325     if(PartialPeelLoop && major_progress() && (_loop_opts_cnt > 0)) {
2326       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2327       PhaseIdealLoop::optimize(igvn, LoopOptsSkipSplitIf);
2328       _loop_opts_cnt--;
2329       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP2, 2);
2330       if (failing())  return;
2331     }
2332     // Loop opts pass for loop-unrolling before CCP
2333     if(major_progress() && (_loop_opts_cnt > 0)) {
2334       TracePhase tp("idealLoop", &timers[_t_idealLoop]);
2335       PhaseIdealLoop::optimize(igvn, LoopOptsSkipSplitIf);
2336       _loop_opts_cnt--;
2337       if (major_progress()) print_method(PHASE_PHASEIDEALLOOP3, 2);
2338     }
2339     if (!failing()) {
2340       // Verify that last round of loop opts produced a valid graph
2341       TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]);
2342       PhaseIdealLoop::verify(igvn);
2343     }
2344   }
2345   if (failing())  return;
2346 
2347   // Conditional Constant Propagation;
2348   PhaseCCP ccp( &igvn );
2349   assert( true, "Break here to ccp.dump_nodes_and_types(_root,999,1)");
2350   {
2351     TracePhase tp("ccp", &timers[_t_ccp]);
2352     ccp.do_transform();
2353   }
2354   print_method(PHASE_CPP1, 2);
2355 


< prev index next >