cfgnode.cpp revision 899
/*
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
// Portions of code courtesy of Clifford Click
// Optimization - Graph Style
#include "incls/_precompiled.incl"
#include "incls/_cfgnode.cpp.incl"
//=============================================================================
//------------------------------Value------------------------------------------
// Compute the type of the RegionNode.
if( !n ) continue; // Missing inputs are TOP
}
}
//------------------------------Identity---------------------------------------
// Check for Region being Identity.
// Cannot have Region be an identity, even if it has only 1 input.
// Phi users cannot have their Region input folded away for them,
// since they need to select the proper data input
return this;
}
//------------------------------merge_region-----------------------------------
// If a Region flows into a Region, merge into one big happy merge. This is
// hard to do if there is stuff that has to happen
return NULL;
r->in(0) == r && // Not already collapsed?
r != region && // Avoid stupid situations
if( !progress ) { // No progress
return NULL; // Only flatten if no Phi users
// igvn->hash_delete( phi );
}
}
igvn->hash_delete( r );
// Append inputs to 'r' onto 'region'
// Move an input from 'r' to 'region'
// Update phis of 'region'
//for( uint k = 0; k < max; k++ ) {
// Node *phi = region->out(k);
// if( phi->is_Phi() ) {
// phi->add_req(phi->in(i));
// }
//}
rreq++; // One more input to Region
} // Found a region to merge into Region
// Clobber pointer to the now dead 'r'
}
}
return progress;
}
//--------------------------------has_phi--------------------------------------
// Helper function: Return any PhiNode that uses this region or NULL
}
}
return NULL;
}
//-----------------------------has_unique_phi----------------------------------
// Helper function: Return the only PhiNode that uses this region or NULL
// Check that only one use is a Phi
} else {
return NULL; // multiple phis
}
}
}
return only_phi;
}
//------------------------------check_phi_clipping-----------------------------
// Helper function for RegionNode's identification of FP clipping
// Check inputs to the Phi
static bool check_phi_clipping( PhiNode *phi, ConNode * &min, uint &min_idx, ConNode * &max, uint &max_idx, Node * &val, uint &val_idx ) {
min_idx = 0;
max_idx = 0;
val_idx = 0;
if( phi_max == 4 ) {
switch( opcode ) {
case Op_ConI:
{
min_idx = j;
} else {
max_idx = j;
// Swap min and max
}
}
}
break;
default:
{
val = n;
val_idx = j;
}
break;
}
}
}
}
//------------------------------check_if_clipping------------------------------
// Helper function for RegionNode's identification of FP clipping
// Check that inputs to Region come from two IfNodes,
//
// If
// False True
// If |
// False True |
// | | |
// RegionNode_inputs
//
// Check control structure above RegionNode for (if ( if ) )
// Check that all inputs are projections
// Check that #1 and #2 are ifTrue and ifFalse from same If
// Check that control for in10 comes from other branch of IF from in3
// Control pattern checks
}
}
}
}
//------------------------------check_convf2i_clipping-------------------------
// Helper function for RegionNode's identification of FP clipping
// Verify that the value input to the phi comes from "ConvF2I; LShift; RShift"
static bool check_convf2i_clipping( PhiNode *phi, uint idx, ConvF2INode * &convf2i, Node *min, Node *max) {
// Check for the RShiftNode
// Check for the LShiftNode
// Check for the ConvF2INode
// Check that shift amounts are only to get sign bits set after F2I
if( left_shift != right_shift ||
max_post_shift < max_cutoff ||
max_post_shift < -min_cutoff ) {
// Shifts are necessary but current transformation eliminates them
return false;
}
// OK to return the result of ConvF2I without shifting
return true;
}
//------------------------------check_compare_clipping-------------------------
// Helper function for RegionNode's identification of FP clipping
// Test that the float value being compared against
// is equivalent to the int value used as a limit
return true;
}
//------------------------------is_unreachable_region--------------------------
// Find if the Region node is reachable from the root.
// First, cut the simple case of fallthrough region when NONE of
// region's phis references itself directly or through a data node.
uint i;
for (i = 0; i < max; i++) {
continue; // Safe case - no loops
// Skip if only one use is an other Phi or Call or Uncommon trap.
// It is safe to consider this case as fallthrough.
continue;
}
// Check when phi references itself directly or through an other node.
break; // Found possible unsafe data loop.
}
}
if (i >= max)
return false; // An unsafe case was NOT found - don't need graph walk.
// Unsafe case - check if the Region node is reachable from root.
// Mark all control nodes reachable from root outputs
return false; // We reached the Region node - it is not dead.
}
}
}
}
return true; // The Region node is unreachable - it is dead.
}
//------------------------------Ideal------------------------------------------
// Return a node which is more "ideal" than the current node. Must preserve
// the CFG, but we can still strip out dead paths.
// Check for RegionNode with no Phi users and both inputs come from either
// arm of the same IF. If found, then the control-flow split is useless.
bool has_phis = false;
if (can_reshape) { // Need DU info to check for Phi users
if (!has_phis) { // No Phi users? Nothing merging?
if( !if1 ) continue;
// Add the IF Projections to the worklist. They (and the IF itself)
// will be eliminated if dead.
return this; // Record progress
}
}
}
}
}
// Remove TOP or NULL input paths. If only 1 input path remains, this Region
// degrades to a copy.
bool add_to_worklist = false;
int cnt = 0; // Count of values merging
int del_it = 0; // The last input path we delete
// For all inputs...
if( n != NULL ) {
// Remove useless control copy inputs
set_req(i, n->nonnull_req());
i--;
continue;
}
if( n->is_Proj() ) { // Remove useless rethrows
i--;
continue;
}
}
i--;
continue;
}
cnt++; // One more value merging
} else if (can_reshape) { // Else found dead path with DU info
del_req(i); // Yank path from self
del_it = i;
DUIterator j;
bool progress = true;
while(progress) { // Need to establish property over all users
progress = false;
n->del_req(i); // Yank path from Phis
progress = true;
j = refresh_out_pos(j);
}
}
}
}
add_to_worklist = true;
i--;
}
}
// Is it dead loop?
// If it is LoopNopde it had 2 (+1 itself) inputs and
// one of them was cut. The loop is dead if it was EntryContol.
// Yes, the region will be removed during the next step below.
// Cut the backedge input and remove phis since no data paths left.
// We don't cut outputs to other nodes here since we need to put them
// on the worklist.
del_req(1);
cnt = 0;
bool progress = true;
DUIterator j;
while(progress) {
progress = false;
if( n->is_Phi() ) {
// Break dead loop data path.
// Eagerly replace phis with top to avoid phis copies generation.
progress = true;
j = refresh_out_pos(j);
}
}
}
}
add_to_worklist = true;
}
}
if (add_to_worklist) {
}
// No inputs or all inputs are NULL.
return NULL;
} else if (can_reshape) { // Optimization phase - remove the node
if( cnt == 0 ) {
// During IGVN phase such region will be subsumed by TOP node
// so region's phis will have TOP as control node.
// Kill phis here to avoid it. PhiNode::is_copy() will be always false.
// Also set other user's input to top.
} else {
// The fallthrough case since we already checked dead loops above.
}
if (!add_to_worklist)
if( n->is_Phi() ) { // Collapse all Phis
// Eagerly replace phis to avoid copies generation.
if( cnt == 0 ) {
} else {
}
}
else if( n->is_Region() ) { // Update all incoming edges
uint uses_found = 0;
if( n->in(k) == this ) {
n->set_req(k, parent_ctrl);
uses_found++;
}
}
i -= (uses_found - 1);
}
}
else {
n->set_req(0, parent_ctrl);
}
#ifdef ASSERT
}
#endif
}
// Remove the RegionNode itself from DefUse info
igvn->remove_dead_node(this);
return NULL;
}
return this; // Record progress
}
// If a Region flows into a Region, merge into one big happy merge.
if (can_reshape) {
if (m != NULL) return m;
}
// Check if this region is the root of a clipping idiom on floats
// Check that only one use is a Phi and that it simplifies to two constants +
// Check inputs to the Phi
// Control pattern checks, now verify compares
// Only remaining check is that bot_in == top_in == (Phi's val + mods)
// Check for the ConvF2INode
// Matched pattern, including LShiftI; RShiftI, replace with integer compares
// max test
IfNode *iff = (IfNode*)gvn->register_new_node_with_optimizer(new (phase->C, 2) IfNode( top_if->in(0), boo, PROB_UNLIKELY_MAG(5), top_if->_fcnt ));
// min test
iff = (IfNode*)gvn->register_new_node_with_optimizer(new (phase->C, 2) IfNode( ifF, boo, PROB_UNLIKELY_MAG(5), bot_if->_fcnt ));
// update input edges to region node
// remove unnecessary 'LShiftI; RShiftI' idiom
// Return transformed region node
return this;
}
}
}
}
}
}
}
return NULL;
}
}
// Find the one non-null required input. RegionNode only
if( in(i) )
return in(i);
return NULL;
}
//=============================================================================
// note that these functions assume that the _adr_type field is flattened
}
}
static inline
}
//----------------------------make---------------------------------------------
// create a new phi with edges matching r and set (initially) to x
// Fill in all inputs, except those which the region does not yet have
p->init_req(j, x);
}
return p;
}
const Type* t = x->bottom_type();
}
const Type* t = x->bottom_type();
}
//------------------------slice_memory-----------------------------------------
// create a new phi with narrowed memory type
// convert self-loops, or else we get a bad graph
}
mem->verify_adr_type();
return mem;
}
//------------------------split_out_instance-----------------------------------
// Split out an instance type from a bottom phi.
t->is_oopptr()->cast_to_exactness(true)
"bottom or raw memory required");
// Check if an appropriate node already exists.
return phi2;
}
}
}
continue;
i = 0; // will get incremented at top of loop
continue;
}
}
}
}
return nphi;
}
//------------------------verify_adr_type--------------------------------------
#ifdef ASSERT
// recheck constructor invariants:
verify_adr_type(false);
"adr_type must be consistent across phi nest");
// walk around
if (n == NULL) continue;
// ignore top inputs
} else {
"adr_type must be consistent at leaves of phi nest");
}
}
}
// Verify a whole nest of phis rooted at this one.
if (is_error_reported()) return; // muzzle asserts when debugging an error
if (!VerifyAliases) return; // verify thoroughly only if requested
"Phi::adr_type must be pre-normalized");
if (recursive) {
}
}
#endif
//------------------------------Value------------------------------------------
// Compute the type of the PhiNode
if( !r ) // Copy or dead
// Note: During parsing, phis are often transformed before their regions.
// This means we have to use type_or_null to defend against untyped regions.
// Check for trip-counted loop. If so, be smarter.
if( l && l->can_be_counted_loop(phase) &&
// protect against init_trip() or limit() returning NULL
int stride = l->stride_con();
if( stride < 0 ) { // Down-counter loop
}
}
}
}
// Until we have harmony between classes and interfaces in the type
// lattice, we must tread carefully around phis which implicitly
// convert the one to the other.
bool is_intf = false;
if (k->is_loaded() && k->is_interface())
is_intf = true;
}
if (k->is_loaded() && k->is_interface())
is_intf = true;
}
// Default case: merge all inputs
// Reachable control path?
// We assume that each input of an interface-valued Phi is a true
// subtype of that interface. This might not be true of the meet
// of all the input types. The lattice is not distributive in
// such cases. Ward off asserts in type.cpp by refusing to do
// meets between interfaces and proper classes.
if (tiip) {
bool ti_is_intf = false;
if (k->is_loaded() && k->is_interface())
ti_is_intf = true;
if (is_intf != ti_is_intf)
{ t = _type; break; }
}
}
}
// The worst-case type (from ciTypeFlow) should be consistent with "t".
// That is, we expect that "t->higher_equal(_type)" holds true.
// There are various exceptions:
// - Inputs which are phis might in fact be widened unnecessarily.
// For example, an input might be a widened int while the phi is a short.
// - Inputs might be BotPtrs but this phi is dependent on a null check,
// and postCCP has removed the cast which encodes the result of the check.
// - The type of this phi is an interface, and the inputs are classes.
// - Value calls on inputs might produce fuzzy results.
// (Occurrences of this case suggest improvements to Value methods.)
//
// It is not possible to see Type::BOTTOM values as phi inputs,
// because the ciTypeFlow pre-pass produces verifier-quality types.
#ifdef ASSERT
// The following logic has been moved into TypeOopPtr::filter.
// Check for evil case of 't' being a class and '_type' expecting an
// interface. This can happen because the bytecodes do not contain
// enough type info to distinguish a Java-level interface variable
// from a Java-level object variable. If we meet 2 classes which
// both implement interface I, but their meet is at 'j/l/O' which
// doesn't implement I, we have no way to tell if the result should
// be 'I' or 'j/l/O'. Thus we'll pick 'j/l/O'. If this then flows
// into a Phi which "knows" it's an Interface type we'll have to
// uplift the type.
// Otherwise it's something stupid like non-overlapping int ranges
// found on dying counted loops.
else
}
else {
// If we have an interface-typed Phi and we narrow to a class type, the join
// class-typed Phi and an interface flows in, it's possible that the meet &
// join report an interface back out. This isn't possible but happens
// because the type system doesn't interact well with interfaces.
// Happens in a CTW of rt.jar, 320-341, no extra flags
}
}
}
}
}
}
}
#endif //ASSERT
// Deal with conversion problems found in data loops.
return ft;
}
//------------------------------is_diamond_phi---------------------------------
// Does this Phi represent a simple well-shaped diamond merge? Return the
// index of the true path or 0 otherwise.
int PhiNode::is_diamond_phi() const {
// Check for a 2-path merge
if( !region ) return 0;
if( req() != 3 ) return 0;
// Check that both paths come from the same If
if( !b->is_Bool() ) return 0;
// Check for branching opposite expected
return 2;
} else {
return 1;
}
}
//----------------------------check_cmove_id-----------------------------------
// Check for CMove'ing a constant after comparing against the constant.
// Happens all the time now, since if we compare equality vs a constant in
// the parser, we "know" the variable is constant on one path and we force
// it. Thus code like "if( x==0 ) {/*EMPTY*/}" ends up inserting a
// conditional move: "x = (x==0)?0:x;". Yucko. This fix is slightly more
// general in that we don't need constants. Since CMove's are only inserted
// in very special circumstances, we do it here on generic Phi's.
// is_diamond_phi() has guaranteed the correctness of the nodes sequence:
// phi->region->if_proj->ifnode->bool->cmp
return NULL;
// Either value might be a cast that depends on a branch of 'iff'.
// Since the 'id' value will float free of the diamond, either
// decast or return failure.
if (id->is_ConstraintCast()) {
} else {
// Don't know how to disentangle this value.
return NULL;
}
}
return id;
}
//------------------------------Identity---------------------------------------
// Check for Region being Identity.
// Check for no merging going on
// (There used to be special-case code here when this->region->is_Loop.
// It would check for a tributary phi on the backedge that the main phi
// trivially, perhaps with a single cast. The unique_input method
// does all this and more, by reducing such tributaries to 'this'.)
return uin;
}
int true_path = is_diamond_phi();
if (true_path != 0) {
}
return this; // No identity
}
//-----------------------------unique_input------------------------------------
// Find the unique value, discounting top, self-loops, and casts.
// Return top if there are no inputs, and self if there are multiple.
// 1) One unique direct input, or
// 2) some of the inputs have an intervening ConstraintCast and
// the type of input is the same or sharper (more specific)
// than the phi's type.
// 3) an input is a self loop
//
// 1) input or 2) input or 3) input __
// / \ / \ \ / \
// \ / | cast phi cast
// phi \ / / \ /
// phi / --
continue; // ignore unreachable control path
if (n == NULL)
continue;
continue; // ignore if top, or in(i) and "this" are in a data cycle
}
// Check for a unique uncasted input
if (uncasted_input == NULL) {
uncasted_input = un;
} else if (uncasted_input != un) {
}
// Check for a unique direct input
if (direct_input == NULL) {
direct_input = n;
} else if (direct_input != n) {
}
}
if (direct_input == NULL) {
}
if (direct_input != NodeSentinel) {
return direct_input; // one unique direct input
}
if (uncasted_input != NodeSentinel &&
return uncasted_input; // one unique uncasted input
}
// Nothing.
return NULL;
}
//------------------------------is_x2logic-------------------------------------
// Check for simple convert-to-boolean pattern
// If:(C Bool) Region:(IfF IfT) Phi:(Region 0 1)
// Convert Phi to an ConvIB.
// Map 2->0 and 1->1.
// is_diamond_phi() has guaranteed the correctness of the nodes sequence:
// phi->region->if_proj->ifnode->bool->cmp
// Check for compare vs 0
// Allow cmp-vs-1 if the other input is bounded by 0-1
return NULL;
}
} else return NULL;
} else return NULL;
} else return NULL;
// Check for boolean test backwards
} else return NULL;
// Build int->bool conversion
if( flipped )
return n;
}
//------------------------------is_cond_add------------------------------------
// Check for simple conditional add pattern: "(P < Q) ? X+Y : X;"
// To be profitable the control flow has to disappear; there can be no other
// values merging here. We replace the test-and-branch with:
// "(sgn(P-Q))&Y) + X". Basically, convert "(P < Q)" into 0 or -1 by
// moving the carry bit from (P-Q) into a register with 'sbb EAX,EAX'.
// Then convert Y to 0-or-Y and finally add.
// This is a key transform for SpecJava _201_compress.
// is_diamond_phi() has guaranteed the correctness of the nodes sequence:
// phi->region->if_proj->ifnode->bool->cmp
// Make sure only merging this one phi here
// Make sure each arm of the diamond has exactly one output, which we assume
// is the region. Otherwise, the control flow won't disappear.
// Check for "(P < Q)" of type signed int
/*&&op != Op_SubI &&
op != Op_AddP &&
op != Op_XorI &&
op != Op_OrI*/ )
return NULL;
} else return NULL;
// Not so profitable if compare and add are constants
return NULL;
}
//------------------------------is_absolute------------------------------------
// Check for absolute value.
int cmp_zero_idx = 0; // Index of compare input where to look for zero
int phi_x_idx = 0; // Index of phi input where to find naked x
// ABS ends with the merge of 2 control flow paths.
// Find the false path from the true path. With only 2 inputs, 3 - x works nicely.
// is_diamond_phi() has guaranteed the correctness of the nodes sequence:
// phi->region->if_proj->ifnode->bool->cmp
// Check bool sense
default: return NULL; break;
}
// Test is next
default: return NULL;
}
// Find zero input of compare; the other input is being abs'd
bool flip = false;
// The test is inverted, we should invert the result...
flip = true;
} else {
return NULL;
}
// Next get the 2 pieces being selected, one is the original value
// and the other is the negated value.
// Check other phi input for subtract node
// Allow only Sub(0,X) and fail out for all others; Neg is not OK
if (flip) {
}
} else {
if (flip) {
}
}
return x;
}
//------------------------------split_once-------------------------------------
// Helper for split_flow_path
uint j = 1;
n->del_req(i);
}
}
// Register the new node but do not transform it. Cannot transform until the
// Now I can point to the new node.
}
//------------------------------split_flow_path--------------------------------
// Check for merging identical values and split flow paths
return NULL; // Bail out on funny non-value stuff
return NULL; // third unequal input to be worth doing
// Scan for a constant
uint i;
if( !n ) return NULL;
break;
}
return NULL;
if( !n ) return NULL;
hit++;
}
return NULL;
// Now start splitting out the flow paths that merge the same value.
// Split first the RegionNode.
// Now split all other Phis than this one
}
}
// Clean up this guy
}
}
return phi;
}
//=============================================================================
//------------------------------simple_data_loop_check-------------------------
// Returns:
// enum LoopSafety { Safe = 0, Unsafe, UnsafeLoop };
// Safe - safe case when the phi and it's inputs reference only safe data
// nodes;
// Unsafe - the phi and it's inputs reference unsafe data nodes but there
// is no reference back to the phi - need a graph walk
// to determine if it is in a loop;
// UnsafeLoop - unsafe case when the phi references itself directly or through
// unsafe data node.
// GVN transformations. For now it is Con, Proj, Phi, CastPP, CheckCastPP.
// I mark Phi nodes as safe node not only because they can reference itself
// but also to prevent mistaking the fallthrough case inside an outer loop
// as dead loop when the phi references itselfs through an other phi.
// It is unsafe loop if the phi node references itself directly.
return UnsafeLoop; // Unsafe loop
// Unsafe loop if the phi node references itself through an unsafe data node.
// Exclude cases with null inputs or data nodes which could reference
// itself (safe for dead loops).
// Check inputs of phi's inputs also.
// It is much less expensive then full graph walk.
for (; i < cnt; ++i) {
if (m == (Node*)this)
return UnsafeLoop; // Unsafe loop
if (m != NULL && !m->is_dead_loop_safe()) {
// Check the most common case (about 30% of all cases):
return UnsafeLoop; // Unsafe loop
continue; // Safe case
}
// The phi references an unsafe node - need full analysis.
return Unsafe;
}
}
}
return Safe; // Safe case - we can optimize the phi node.
}
//------------------------------is_unsafe_data_reference-----------------------
// If phi can be reached through the data input - it is data loop.
// First, check simple cases when phi references itself directly or
// through an other node.
if (safety == UnsafeLoop)
return true; // phi references itself - unsafe loop
return false; // Safe case - phi could be replaced with the unique input.
// Unsafe case when we should go through data graph to determine
// if the phi references itself.
for (; i < cnt; i++) {
if (m == (Node*)this) {
return true; // Data loop
}
}
}
}
return false; // The phi is not reachable from its inputs
}
//------------------------------Ideal------------------------------------------
// Return a node which is more "ideal" than the current node. Must preserve
// the CFG, but we can still strip out dead paths.
// The next should never happen after 6297035 fix.
if( is_copy() ) // Already degraded to a Copy ?
return NULL; // No change
// Note: During parsing, phis are often transformed before their regions.
// This means we have to use type_or_null to defend against untyped regions.
return NULL; // No change
// The are 2 situations when only one valid phi's input is left
// (in addition to Region input).
// One: region is not loop - replace phi with this input.
// Two: region is loop - replace phi with top since this data path is dead
// and we need to break the dead data loop.
// Check unreachable control paths
if (n != top) { // Not already top?
progress = this; // Record progress
}
}
}
if (can_reshape) // IGVN transformation
return top;
else
return NULL; // Identity will return TOP
// Only one not-NULL unique input path is left.
// Determine if this input is backedge of a loop.
// (Skip new phis which have no uses and dead regions).
// First, take the short cut when we know it is a loop and
// the EntryControl data path is dead.
// Then, check if there is a data loop when phi references itself directly
// or through other data nodes.
// Break this data loop to avoid creation of a dead loop.
if (can_reshape) {
return top;
} else {
// We can't return top if we are in Parse phase - cut inputs only
// let Identity to handle the case.
return NULL;
}
}
}
// One unique input.
// The unique input must eventually be detected by the Identity call.
#ifdef ASSERT
// print this output before failing assert
r->dump(3);
this->dump(3);
ident->dump();
}
#endif
return NULL;
}
int true_path = is_diamond_phi();
if( true_path != 0 ) {
// Check for CMove'ing identity. If it would be unsafe,
// handle it here. In the safe case, let Identity handle it.
// Check for simple convert-to-boolean pattern
// Check for absolute value
// Check for conditional add
// These 4 optimizations could subsume the phi:
// have to check for a dead data loop creation.
// Found dead loop.
if( can_reshape )
return top;
// We can't return top if we are in Parse phase - cut inputs only
// to stop further optimizations for this phi. Identity will return TOP.
return NULL;
} else {
return opt;
}
}
}
// Check for merging identical values and split flow paths
if (can_reshape) {
// This optimization only modifies phi - don't need to check for dead loop.
}
// Split phis through memory merges, so that the memory merges will go away.
// Piggy-back this transformation on the search for a unique input....
// It will be as if the merged memory is the unique value of the phi.
// (Do not attempt this optimization unless parsing is complete.
// It would make the parser's memory-merge logic sick.)
// (MergeMemNode is not dead_loop_safe - need to check for dead loop.)
// see if this phi should be sliced
uint merge_width = 0;
bool saw_self = false;
if (ii->is_MergeMem()) {
}
}
// This restriction is temporarily necessary to ensure termination:
// found at least one non-empty MergeMem
// Patch the existing phi to select an input from the merge:
// Phi:AT1(...MergeMem(m0, m1, m2)...) into
// Phi:AT1(...m1...)
if (ii->is_MergeMem()) {
// compress paths and change unreachable cycles to TOP
// If not, we can update the input infinitely along a MergeMem cycle
// Equivalent code is in MemNode::Ideal_common
if (outcnt() == 0) { // Above transform() may kill us!
break;
}
// If transformed to a MergeMem, get the desired slice
// Otherwise the returned node represents memory for every slice
// Update input if it is progress over what we have now
progress = this;
}
}
}
} else {
// We know that at least one MergeMem->base_memory() == this
// (saw_self == true). If all other inputs also references this phi
// (directly or through data nodes) - it is dead loop.
bool saw_safe_input = false;
continue; // skip known cases
if (!is_unsafe_data_reference(n)) {
saw_safe_input = true; // found safe input
break;
}
}
if (!saw_safe_input)
return top; // all inputs reference back to this phi - dead loop
// Phi(...MergeMem(m0, m1:AT1, m2:AT2)...) into
// MergeMem(Phi(...m0...), Phi:AT1(...m1...), Phi:AT2(...m2...))
// Must eagerly register phis, since they participate in loops.
if (igvn) {
}
if (ii->is_MergeMem()) {
// If we have not seen this slice yet, make a phi for it.
bool made_new_phi = false;
made_new_phi = true;
if (igvn) {
}
}
}
}
}
// Distribute all self-loops.
{ // (Extra braces to hide mms.)
}
}
}
// now transform the new nodes, and return the mergemem
}
if (igvn) { // Unhook.
}
}
// Replace self with the result.
return result;
}
}
//
// Other optimizations on the memory chain
//
progress = this;
}
}
}
#ifdef _LP64
// Push DecodeN down through phi.
// The rest of phi graph will transform by split EncodeP node though phis up.
bool may_push = true;
bool has_decodeN = false;
// Do optimization if a non dead path exist.
has_decodeN = true;
}
may_push = false;
}
}
if (has_decodeN && may_push) {
// Make narrow type for new phi.
if (ii->is_DecodeN()) {
} else {
} else {
}
}
}
}
}
#endif
return progress; // Return any progress
}
//------------------------------is_tripcount-----------------------------------
bool PhiNode::is_tripcount() const {
}
//------------------------------out_RegMask------------------------------------
}
}
#ifndef PRODUCT
if (is_tripcount()) {
}
}
#endif
//=============================================================================
// If the input is reachable, then we are executed.
// If the input is not reachable, then we are not executed.
}
return in(0); // Simple copy of incoming control
}
}
//=============================================================================
}
//=============================================================================
}
//=============================================================================
}
//=============================================================================
}
//------------------------------Value------------------------------------------
// Compute the type of the PCTableNode. If reachable it is a tuple of
// Control, otherwise the table targets are not reachable
return bottom_type();
}
//------------------------------Ideal------------------------------------------
// Return a node which is more "ideal" than the current node. Strip out
// control copies
}
//=============================================================================
}
}
#ifndef PRODUCT
}
#endif
//=============================================================================
//------------------------------Value------------------------------------------
// Check for being unreachable, or for coming from a Rethrow. Rethrow's cannot
// have the default "fall_through_index" path.
// Unreachable? Then so are all paths from here.
// First assume all paths are reachable
// Identify cases that will always throw an exception
// () rethrow call
// () virtual or interface call with NULL receiver
// () call is a check cast with incompatible arguments
// Rethrows always throw exceptions, never return
// Check for null receiver to virtual or interface calls
if( call->is_CallDynamicJava() &&
}
} // End of if not a runtime stub
} // End of if have call above me
} // End of slot 1 is not a projection
}
//=============================================================================
}
}
//------------------------------Identity---------------------------------------
// If only 1 target is possible, choose it if it is the main control
// If my value is control and no other value is, then treat as ID
// also remove any exception table entry. Thus we must know the call
// feeding the Catch will not really throw an exception. This is ok for
// the main fall-thru control (happens when we know a call can never throw
// an exception) or for "rethrow", because a further optimization will
// yank the rethrow (happens when we inline a function that can throw an
// exception and the caller has no handler). Not legal, e.g., for passing
// a NULL receiver to a v-call, or passing bad types to a slow-check-cast.
// These cases MUST throw an exception via the runtime system, so the VM
// will be looking for a table entry.
return this;
// Search for any other path being control
return this;
}
// Only my path is possible; I am identity on control to the jump
}
#ifndef PRODUCT
}
#endif
//=============================================================================
//------------------------------Identity---------------------------------------
// Check for CreateEx being Identity.
// We only come from CatchProj, unless the CatchProj goes away.
// If the CatchProj is optimized away, then we just carry the
// exception oop through.
? this
}
//=============================================================================
//------------------------------Value------------------------------------------
// Check for being unreachable.
return bottom_type();
}
//------------------------------Ideal------------------------------------------
// Check for no longer being part of a loop
// Dead code elimination can sometimes delete this projection so
// if it's not there, there's nothing to do.
}
}
return NULL;
}
#ifndef PRODUCT
}
#endif