2163 Node_Stack nstack(unique() >> 1); |
2161 Node_Stack nstack(unique() >> 1); |
2164 final_graph_reshaping_walk(nstack, root(), fpu); |
2162 final_graph_reshaping_walk(nstack, root(), fpu); |
2165 |
2163 |
2166 // Check for unreachable (from below) code (i.e., infinite loops). |
2164 // Check for unreachable (from below) code (i.e., infinite loops). |
2167 for( uint i = 0; i < fpu._tests.size(); i++ ) { |
2165 for( uint i = 0; i < fpu._tests.size(); i++ ) { |
2168 Node *n = fpu._tests[i]; |
2166 MultiBranchNode *n = fpu._tests[i]->as_MultiBranch(); |
2169 assert( n->is_PCTable() || n->is_If(), "either PCTables or IfNodes" ); |
2167 // Get number of CFG targets. |
2170 // Get number of CFG targets; 2 for IfNodes or _size for PCTables. |
|
2171 // Note that PCTables include exception targets after calls. |
2168 // Note that PCTables include exception targets after calls. |
2172 uint expected_kids = n->is_PCTable() ? n->as_PCTable()->_size : 2; |
2169 uint required_outcnt = n->required_outcnt(); |
2173 if (n->outcnt() != expected_kids) { |
2170 if (n->outcnt() != required_outcnt) { |
2174 // Check for a few special cases. Rethrow Nodes never take the |
2171 // Check for a few special cases. Rethrow Nodes never take the |
2175 // 'fall-thru' path, so expected kids is 1 less. |
2172 // 'fall-thru' path, so expected kids is 1 less. |
2176 if (n->is_PCTable() && n->in(0) && n->in(0)->in(0)) { |
2173 if (n->is_PCTable() && n->in(0) && n->in(0)->in(0)) { |
2177 if (n->in(0)->in(0)->is_Call()) { |
2174 if (n->in(0)->in(0)->is_Call()) { |
2178 CallNode *call = n->in(0)->in(0)->as_Call(); |
2175 CallNode *call = n->in(0)->in(0)->as_Call(); |
2179 if (call->entry_point() == OptoRuntime::rethrow_stub()) { |
2176 if (call->entry_point() == OptoRuntime::rethrow_stub()) { |
2180 expected_kids--; // Rethrow always has 1 less kid |
2177 required_outcnt--; // Rethrow always has 1 less kid |
2181 } else if (call->req() > TypeFunc::Parms && |
2178 } else if (call->req() > TypeFunc::Parms && |
2182 call->is_CallDynamicJava()) { |
2179 call->is_CallDynamicJava()) { |
2183 // Check for null receiver. In such case, the optimizer has |
2180 // Check for null receiver. In such case, the optimizer has |
2184 // detected that the virtual call will always result in a null |
2181 // detected that the virtual call will always result in a null |
2185 // pointer exception. The fall-through projection of this CatchNode |
2182 // pointer exception. The fall-through projection of this CatchNode |
2186 // will not be populated. |
2183 // will not be populated. |
2187 Node *arg0 = call->in(TypeFunc::Parms); |
2184 Node *arg0 = call->in(TypeFunc::Parms); |
2188 if (arg0->is_Type() && |
2185 if (arg0->is_Type() && |
2189 arg0->as_Type()->type()->higher_equal(TypePtr::NULL_PTR)) { |
2186 arg0->as_Type()->type()->higher_equal(TypePtr::NULL_PTR)) { |
2190 expected_kids--; |
2187 required_outcnt--; |
2191 } |
2188 } |
2192 } else if (call->entry_point() == OptoRuntime::new_array_Java() && |
2189 } else if (call->entry_point() == OptoRuntime::new_array_Java() && |
2193 call->req() > TypeFunc::Parms+1 && |
2190 call->req() > TypeFunc::Parms+1 && |
2194 call->is_CallStaticJava()) { |
2191 call->is_CallStaticJava()) { |
2195 // Check for negative array length. In such case, the optimizer has |
2192 // Check for negative array length. In such case, the optimizer has |
2196 // detected that the allocation attempt will always result in an |
2193 // detected that the allocation attempt will always result in an |
2197 // exception. There is no fall-through projection of this CatchNode . |
2194 // exception. There is no fall-through projection of this CatchNode . |
2198 Node *arg1 = call->in(TypeFunc::Parms+1); |
2195 Node *arg1 = call->in(TypeFunc::Parms+1); |
2199 if (arg1->is_Type() && |
2196 if (arg1->is_Type() && |
2200 arg1->as_Type()->type()->join(TypeInt::POS)->empty()) { |
2197 arg1->as_Type()->type()->join(TypeInt::POS)->empty()) { |
2201 expected_kids--; |
2198 required_outcnt--; |
2202 } |
2199 } |
2203 } |
2200 } |
2204 } |
2201 } |
2205 } |
2202 } |
2206 // Recheck with a better notion of 'expected_kids' |
2203 // Recheck with a better notion of 'required_outcnt' |
2207 if (n->outcnt() != expected_kids) { |
2204 if (n->outcnt() != required_outcnt) { |
2208 record_method_not_compilable("malformed control flow"); |
2205 record_method_not_compilable("malformed control flow"); |
2209 return true; // Not all targets reachable! |
2206 return true; // Not all targets reachable! |
2210 } |
2207 } |
2211 } |
2208 } |
2212 // Check that I actually visited all kids. Unreached kids |
2209 // Check that I actually visited all kids. Unreached kids |