src/share/vm/opto/compile.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6663848 Sdiff src/share/vm/opto

src/share/vm/opto/compile.cpp

Print this page




1964   case Op_LoadL:
1965   case Op_LoadL_unaligned:
1966   case Op_LoadPLocked:
1967   case Op_LoadLLocked:
1968   case Op_LoadP:
1969   case Op_LoadN:
1970   case Op_LoadRange:
1971   case Op_LoadS: {
1972   handle_mem:
1973 #ifdef ASSERT
1974     if( VerifyOptoOopOffsets ) {
1975       assert( n->is_Mem(), "" );
1976       MemNode *mem  = (MemNode*)n;
1977       // Check to see if address types have grounded out somehow.
1978       const TypeInstPtr *tp = mem->in(MemNode::Address)->bottom_type()->isa_instptr();
1979       assert( !tp || oop_offset_is_sane(tp), "" );
1980     }
1981 #endif
1982     break;
1983   }
1984   case Op_If:
1985   case Op_CountedLoopEnd:
1986     fpu._tests.push(n);         // Collect CFG split points
1987     break;
1988 
1989   case Op_AddP: {               // Assert sane base pointers
1990     const Node *addp = n->in(AddPNode::Address);
1991     assert( !addp->is_AddP() ||
1992             addp->in(AddPNode::Base)->is_top() || // Top OK for allocation
1993             addp->in(AddPNode::Base) == n->in(AddPNode::Base),
1994             "Base pointers must match" );
1995     break;
1996   }
1997 
1998   case Op_ModI:
1999     if (UseDivMod) {
2000       // Check if a%b and a/b both exist
2001       Node* d = n->find_similar(Op_DivI);
2002       if (d) {
2003         // Replace them with a fused divmod if supported
2004         Compile* C = Compile::current();
2005         if (Matcher::has_match_rule(Op_DivModI)) {
2006           DivModINode* divmod = DivModINode::make(C, n);
2007           d->replace_by(divmod->div_proj());


2066   case Op_Store2D:
2067     break;
2068 
2069   case Op_PackB:
2070   case Op_PackS:
2071   case Op_PackC:
2072   case Op_PackI:
2073   case Op_PackF:
2074   case Op_PackL:
2075   case Op_PackD:
2076     if (n->req()-1 > 2) {
2077       // Replace many operand PackNodes with a binary tree for matching
2078       PackNode* p = (PackNode*) n;
2079       Node* btp = p->binaryTreePack(Compile::current(), 1, n->req());
2080       n->replace_by(btp);
2081     }
2082     break;
2083   default:
2084     assert( !n->is_Call(), "" );
2085     assert( !n->is_Mem(), "" );
2086     if( n->is_If() || n->is_PCTable() )
2087       fpu._tests.push(n);       // Collect CFG split points
2088     break;
2089   }




2090 }
2091 
2092 //------------------------------final_graph_reshaping_walk---------------------
2093 // Replacing Opaque nodes with their input in final_graph_reshaping_impl(),
2094 // requires that the walk visits a node's inputs before visiting the node.
2095 static void final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &fpu ) {
2096   fpu._visited.set(root->_idx); // first, mark node as visited
2097   uint cnt = root->req();
2098   Node *n = root;
2099   uint  i = 0;
2100   while (true) {
2101     if (i < cnt) {
2102       // Place all non-visited non-null inputs onto stack
2103       Node* m = n->in(i);
2104       ++i;
2105       if (m != NULL && !fpu._visited.test_set(m->_idx)) {
2106         cnt = m->req();
2107         nstack.push(n, i); // put on stack parent and next input's index
2108         n = m;
2109         i = 0;


2148 //     reachable from below or CatchNodes missing some targets.
2149 // (5) Assert for insane oop offsets in debug mode.
2150 
2151 bool Compile::final_graph_reshaping() {
2152   // an infinite loop may have been eliminated by the optimizer,
2153   // in which case the graph will be empty.
2154   if (root()->req() == 1) {
2155     record_method_not_compilable("trivial infinite loop");
2156     return true;
2157   }
2158 
2159   Final_Reshape_Counts fpu;
2160 
2161   // Visit everybody reachable!
2162   // Allocate stack of size C->unique()/2 to avoid frequent realloc
2163   Node_Stack nstack(unique() >> 1);
2164   final_graph_reshaping_walk(nstack, root(), fpu);
2165 
2166   // Check for unreachable (from below) code (i.e., infinite loops).
2167   for( uint i = 0; i < fpu._tests.size(); i++ ) {
2168     Node *n = fpu._tests[i];
2169     assert( n->is_PCTable() || n->is_If(), "either PCTables or IfNodes" );
2170     // Get number of CFG targets; 2 for IfNodes or _size for PCTables.
2171     // Note that PCTables include exception targets after calls.
2172     uint expected_kids = n->is_PCTable() ? n->as_PCTable()->_size : 2;
2173     if (n->outcnt() != expected_kids) {
2174       // Check for a few special cases.  Rethrow Nodes never take the
2175       // 'fall-thru' path, so expected kids is 1 less.
2176       if (n->is_PCTable() && n->in(0) && n->in(0)->in(0)) {
2177         if (n->in(0)->in(0)->is_Call()) {
2178           CallNode *call = n->in(0)->in(0)->as_Call();
2179           if (call->entry_point() == OptoRuntime::rethrow_stub()) {
2180             expected_kids--;      // Rethrow always has 1 less kid
2181           } else if (call->req() > TypeFunc::Parms &&
2182                      call->is_CallDynamicJava()) {
2183             // Check for null receiver. In such case, the optimizer has
2184             // detected that the virtual call will always result in a null
2185             // pointer exception. The fall-through projection of this CatchNode
2186             // will not be populated.
2187             Node *arg0 = call->in(TypeFunc::Parms);
2188             if (arg0->is_Type() &&
2189                 arg0->as_Type()->type()->higher_equal(TypePtr::NULL_PTR)) {
2190               expected_kids--;
2191             }
2192           } else if (call->entry_point() == OptoRuntime::new_array_Java() &&
2193                      call->req() > TypeFunc::Parms+1 &&
2194                      call->is_CallStaticJava()) {
2195             // Check for negative array length. In such case, the optimizer has
2196             // detected that the allocation attempt will always result in an
2197             // exception. There is no fall-through projection of this CatchNode .
2198             Node *arg1 = call->in(TypeFunc::Parms+1);
2199             if (arg1->is_Type() &&
2200                 arg1->as_Type()->type()->join(TypeInt::POS)->empty()) {
2201               expected_kids--;
2202             }
2203           }
2204         }
2205       }
2206       // Recheck with a better notion of 'expected_kids'
2207       if (n->outcnt() != expected_kids) {
2208         record_method_not_compilable("malformed control flow");
2209         return true;            // Not all targets reachable!
2210       }
2211     }
2212     // Check that I actually visited all kids.  Unreached kids
2213     // must be infinite loops.
2214     for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++)
2215       if (!fpu._visited.test(n->fast_out(j)->_idx)) {
2216         record_method_not_compilable("infinite loop");
2217         return true;            // Found unvisited kid; must be unreach
2218       }
2219   }
2220 
2221   // If original bytecodes contained a mixture of floats and doubles
2222   // check if the optimizer has made it homogenous, item (3).
2223   if( Use24BitFPMode && Use24BitFP &&
2224       fpu.get_float_count() > 32 &&
2225       fpu.get_double_count() == 0 &&
2226       (10 * fpu.get_call_count() < fpu.get_float_count()) ) {
2227     set_24_bit_selection_and_mode( false,  true );




1964   case Op_LoadL:
1965   case Op_LoadL_unaligned:
1966   case Op_LoadPLocked:
1967   case Op_LoadLLocked:
1968   case Op_LoadP:
1969   case Op_LoadN:
1970   case Op_LoadRange:
1971   case Op_LoadS: {
1972   handle_mem:
1973 #ifdef ASSERT
1974     if( VerifyOptoOopOffsets ) {
1975       assert( n->is_Mem(), "" );
1976       MemNode *mem  = (MemNode*)n;
1977       // Check to see if address types have grounded out somehow.
1978       const TypeInstPtr *tp = mem->in(MemNode::Address)->bottom_type()->isa_instptr();
1979       assert( !tp || oop_offset_is_sane(tp), "" );
1980     }
1981 #endif
1982     break;
1983   }




1984 
1985   case Op_AddP: {               // Assert sane base pointers
1986     const Node *addp = n->in(AddPNode::Address);
1987     assert( !addp->is_AddP() ||
1988             addp->in(AddPNode::Base)->is_top() || // Top OK for allocation
1989             addp->in(AddPNode::Base) == n->in(AddPNode::Base),
1990             "Base pointers must match" );
1991     break;
1992   }
1993 
1994   case Op_ModI:
1995     if (UseDivMod) {
1996       // Check if a%b and a/b both exist
1997       Node* d = n->find_similar(Op_DivI);
1998       if (d) {
1999         // Replace them with a fused divmod if supported
2000         Compile* C = Compile::current();
2001         if (Matcher::has_match_rule(Op_DivModI)) {
2002           DivModINode* divmod = DivModINode::make(C, n);
2003           d->replace_by(divmod->div_proj());


2062   case Op_Store2D:
2063     break;
2064 
2065   case Op_PackB:
2066   case Op_PackS:
2067   case Op_PackC:
2068   case Op_PackI:
2069   case Op_PackF:
2070   case Op_PackL:
2071   case Op_PackD:
2072     if (n->req()-1 > 2) {
2073       // Replace many operand PackNodes with a binary tree for matching
2074       PackNode* p = (PackNode*) n;
2075       Node* btp = p->binaryTreePack(Compile::current(), 1, n->req());
2076       n->replace_by(btp);
2077     }
2078     break;
2079   default:
2080     assert( !n->is_Call(), "" );
2081     assert( !n->is_Mem(), "" );


2082     break;
2083   }
2084 
2085   // Collect CFG split points
2086   if (n->is_MultiBranch())
2087     fpu._tests.push(n);
2088 }
2089 
2090 //------------------------------final_graph_reshaping_walk---------------------
2091 // Replacing Opaque nodes with their input in final_graph_reshaping_impl(),
2092 // requires that the walk visits a node's inputs before visiting the node.
2093 static void final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &fpu ) {
2094   fpu._visited.set(root->_idx); // first, mark node as visited
2095   uint cnt = root->req();
2096   Node *n = root;
2097   uint  i = 0;
2098   while (true) {
2099     if (i < cnt) {
2100       // Place all non-visited non-null inputs onto stack
2101       Node* m = n->in(i);
2102       ++i;
2103       if (m != NULL && !fpu._visited.test_set(m->_idx)) {
2104         cnt = m->req();
2105         nstack.push(n, i); // put on stack parent and next input's index
2106         n = m;
2107         i = 0;


2146 //     reachable from below or CatchNodes missing some targets.
2147 // (5) Assert for insane oop offsets in debug mode.
2148 
2149 bool Compile::final_graph_reshaping() {
2150   // an infinite loop may have been eliminated by the optimizer,
2151   // in which case the graph will be empty.
2152   if (root()->req() == 1) {
2153     record_method_not_compilable("trivial infinite loop");
2154     return true;
2155   }
2156 
2157   Final_Reshape_Counts fpu;
2158 
2159   // Visit everybody reachable!
2160   // Allocate stack of size C->unique()/2 to avoid frequent realloc
2161   Node_Stack nstack(unique() >> 1);
2162   final_graph_reshaping_walk(nstack, root(), fpu);
2163 
2164   // Check for unreachable (from below) code (i.e., infinite loops).
2165   for( uint i = 0; i < fpu._tests.size(); i++ ) {
2166     MultiBranchNode *n = fpu._tests[i]->as_MultiBranch();
2167     // Get number of CFG targets.

2168     // Note that PCTables include exception targets after calls.
2169     uint required_outcnt = n->required_outcnt();
2170     if (n->outcnt() != required_outcnt) {
2171       // Check for a few special cases.  Rethrow Nodes never take the
2172       // 'fall-thru' path, so expected kids is 1 less.
2173       if (n->is_PCTable() && n->in(0) && n->in(0)->in(0)) {
2174         if (n->in(0)->in(0)->is_Call()) {
2175           CallNode *call = n->in(0)->in(0)->as_Call();
2176           if (call->entry_point() == OptoRuntime::rethrow_stub()) {
2177             required_outcnt--;      // Rethrow always has 1 less kid
2178           } else if (call->req() > TypeFunc::Parms &&
2179                      call->is_CallDynamicJava()) {
2180             // Check for null receiver. In such case, the optimizer has
2181             // detected that the virtual call will always result in a null
2182             // pointer exception. The fall-through projection of this CatchNode
2183             // will not be populated.
2184             Node *arg0 = call->in(TypeFunc::Parms);
2185             if (arg0->is_Type() &&
2186                 arg0->as_Type()->type()->higher_equal(TypePtr::NULL_PTR)) {
2187               required_outcnt--;
2188             }
2189           } else if (call->entry_point() == OptoRuntime::new_array_Java() &&
2190                      call->req() > TypeFunc::Parms+1 &&
2191                      call->is_CallStaticJava()) {
2192             // Check for negative array length. In such case, the optimizer has
2193             // detected that the allocation attempt will always result in an
2194             // exception. There is no fall-through projection of this CatchNode .
2195             Node *arg1 = call->in(TypeFunc::Parms+1);
2196             if (arg1->is_Type() &&
2197                 arg1->as_Type()->type()->join(TypeInt::POS)->empty()) {
2198               required_outcnt--;
2199             }
2200           }
2201         }
2202       }
2203       // Recheck with a better notion of 'required_outcnt'
2204       if (n->outcnt() != required_outcnt) {
2205         record_method_not_compilable("malformed control flow");
2206         return true;            // Not all targets reachable!
2207       }
2208     }
2209     // Check that I actually visited all kids.  Unreached kids
2210     // must be infinite loops.
2211     for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++)
2212       if (!fpu._visited.test(n->fast_out(j)->_idx)) {
2213         record_method_not_compilable("infinite loop");
2214         return true;            // Found unvisited kid; must be unreach
2215       }
2216   }
2217 
2218   // If original bytecodes contained a mixture of floats and doubles
2219   // check if the optimizer has made it homogenous, item (3).
2220   if( Use24BitFPMode && Use24BitFP &&
2221       fpu.get_float_count() > 32 &&
2222       fpu.get_double_count() == 0 &&
2223       (10 * fpu.get_call_count() < fpu.get_float_count()) ) {
2224     set_24_bit_selection_and_mode( false,  true );


src/share/vm/opto/compile.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File