hotspot/src/share/vm/opto/compile.cpp
changeset 4643 61c659c91c57
parent 4470 1e6edcab3109
child 4906 90640ad2d401
equal deleted inserted replaced
4589:2621c7da5a88 4643:61c659c91c57
   930   // A NULL adr_type hits in the cache right away.  Preload the right answer.
   930   // A NULL adr_type hits in the cache right away.  Preload the right answer.
   931   probe_alias_cache(NULL)->_index = AliasIdxTop;
   931   probe_alias_cache(NULL)->_index = AliasIdxTop;
   932 
   932 
   933   _intrinsics = NULL;
   933   _intrinsics = NULL;
   934   _macro_nodes = new GrowableArray<Node*>(comp_arena(), 8,  0, NULL);
   934   _macro_nodes = new GrowableArray<Node*>(comp_arena(), 8,  0, NULL);
       
   935   _predicate_opaqs = new GrowableArray<Node*>(comp_arena(), 8,  0, NULL);
   935   register_library_intrinsics();
   936   register_library_intrinsics();
   936 }
   937 }
   937 
   938 
   938 //---------------------------init_start----------------------------------------
   939 //---------------------------init_start----------------------------------------
   939 // Install the StartNode on this compile object.
   940 // Install the StartNode on this compile object.
  1551   while ((call = pop_warm_call()) != NULL) {
  1552   while ((call = pop_warm_call()) != NULL) {
  1552     call->make_cold();
  1553     call->make_cold();
  1553   }
  1554   }
  1554 }
  1555 }
  1555 
  1556 
       
  1557 //---------------------cleanup_loop_predicates-----------------------
       
  1558 // Remove the opaque nodes that protect the predicates so that all unused
       
  1559 // checks and uncommon_traps will be eliminated from the ideal graph
       
  1560 void Compile::cleanup_loop_predicates(PhaseIterGVN &igvn) {
       
  1561   if (predicate_count()==0) return;
       
  1562   for (int i = predicate_count(); i > 0; i--) {
       
  1563     Node * n = predicate_opaque1_node(i-1);
       
  1564     assert(n->Opcode() == Op_Opaque1, "must be");
       
  1565     igvn.replace_node(n, n->in(1));
       
  1566   }
       
  1567   assert(predicate_count()==0, "should be clean!");
       
  1568   igvn.optimize();
       
  1569 }
  1556 
  1570 
  1557 //------------------------------Optimize---------------------------------------
  1571 //------------------------------Optimize---------------------------------------
  1558 // Given a graph, optimize it.
  1572 // Given a graph, optimize it.
  1559 void Compile::Optimize() {
  1573 void Compile::Optimize() {
  1560   TracePhase t1("optimizer", &_t_optimizer, true);
  1574   TracePhase t1("optimizer", &_t_optimizer, true);
  1592   // Set loop opts counter
  1606   // Set loop opts counter
  1593   loop_opts_cnt = num_loop_opts();
  1607   loop_opts_cnt = num_loop_opts();
  1594   if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) {
  1608   if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) {
  1595     {
  1609     {
  1596       TracePhase t2("idealLoop", &_t_idealLoop, true);
  1610       TracePhase t2("idealLoop", &_t_idealLoop, true);
  1597       PhaseIdealLoop ideal_loop( igvn, true );
  1611       PhaseIdealLoop ideal_loop( igvn, true, UseLoopPredicate);
  1598       loop_opts_cnt--;
  1612       loop_opts_cnt--;
  1599       if (major_progress()) print_method("PhaseIdealLoop 1", 2);
  1613       if (major_progress()) print_method("PhaseIdealLoop 1", 2);
  1600       if (failing())  return;
  1614       if (failing())  return;
  1601     }
  1615     }
  1602     // Loop opts pass if partial peeling occurred in previous pass
  1616     // Loop opts pass if partial peeling occurred in previous pass
  1603     if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) {
  1617     if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) {
  1604       TracePhase t3("idealLoop", &_t_idealLoop, true);
  1618       TracePhase t3("idealLoop", &_t_idealLoop, true);
  1605       PhaseIdealLoop ideal_loop( igvn, false );
  1619       PhaseIdealLoop ideal_loop( igvn, false, UseLoopPredicate);
  1606       loop_opts_cnt--;
  1620       loop_opts_cnt--;
  1607       if (major_progress()) print_method("PhaseIdealLoop 2", 2);
  1621       if (major_progress()) print_method("PhaseIdealLoop 2", 2);
  1608       if (failing())  return;
  1622       if (failing())  return;
  1609     }
  1623     }
  1610     // Loop opts pass for loop-unrolling before CCP
  1624     // Loop opts pass for loop-unrolling before CCP
  1611     if(major_progress() && (loop_opts_cnt > 0)) {
  1625     if(major_progress() && (loop_opts_cnt > 0)) {
  1612       TracePhase t4("idealLoop", &_t_idealLoop, true);
  1626       TracePhase t4("idealLoop", &_t_idealLoop, true);
  1613       PhaseIdealLoop ideal_loop( igvn, false );
  1627       PhaseIdealLoop ideal_loop( igvn, false, UseLoopPredicate);
  1614       loop_opts_cnt--;
  1628       loop_opts_cnt--;
  1615       if (major_progress()) print_method("PhaseIdealLoop 3", 2);
  1629       if (major_progress()) print_method("PhaseIdealLoop 3", 2);
  1616     }
  1630     }
  1617     if (!failing()) {
  1631     if (!failing()) {
  1618       // Verify that last round of loop opts produced a valid graph
  1632       // Verify that last round of loop opts produced a valid graph
  1646 
  1660 
  1647   // Loop transforms on the ideal graph.  Range Check Elimination,
  1661   // Loop transforms on the ideal graph.  Range Check Elimination,
  1648   // peeling, unrolling, etc.
  1662   // peeling, unrolling, etc.
  1649   if(loop_opts_cnt > 0) {
  1663   if(loop_opts_cnt > 0) {
  1650     debug_only( int cnt = 0; );
  1664     debug_only( int cnt = 0; );
       
  1665     bool loop_predication = UseLoopPredicate;
  1651     while(major_progress() && (loop_opts_cnt > 0)) {
  1666     while(major_progress() && (loop_opts_cnt > 0)) {
  1652       TracePhase t2("idealLoop", &_t_idealLoop, true);
  1667       TracePhase t2("idealLoop", &_t_idealLoop, true);
  1653       assert( cnt++ < 40, "infinite cycle in loop optimization" );
  1668       assert( cnt++ < 40, "infinite cycle in loop optimization" );
  1654       PhaseIdealLoop ideal_loop( igvn, true );
  1669       PhaseIdealLoop ideal_loop( igvn, true, loop_predication);
  1655       loop_opts_cnt--;
  1670       loop_opts_cnt--;
  1656       if (major_progress()) print_method("PhaseIdealLoop iterations", 2);
  1671       if (major_progress()) print_method("PhaseIdealLoop iterations", 2);
  1657       if (failing())  return;
  1672       if (failing())  return;
       
  1673       // Perform loop predication optimization during first iteration after CCP.
       
  1674       // After that switch it off and cleanup unused loop predicates.
       
  1675       if (loop_predication) {
       
  1676         loop_predication = false;
       
  1677         cleanup_loop_predicates(igvn);
       
  1678         if (failing())  return;
       
  1679       }
  1658     }
  1680     }
  1659   }
  1681   }
  1660 
  1682 
  1661   {
  1683   {
  1662     // Verify that all previous optimizations produced a valid graph
  1684     // Verify that all previous optimizations produced a valid graph