--- old/src/share/vm/opto/addnode.cpp 2014-03-18 16:27:03.000000000 -0400 +++ new/src/share/vm/opto/addnode.cpp 2014-03-18 16:27:03.000000000 -0400 @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "memory/allocation.inline.hpp" #include "opto/addnode.hpp" +#include "opto/castnode.hpp" #include "opto/cfgnode.hpp" #include "opto/connode.hpp" #include "opto/machnode.hpp" --- old/src/share/vm/opto/callGenerator.cpp 2014-03-18 16:27:05.000000000 -0400 +++ new/src/share/vm/opto/callGenerator.cpp 2014-03-18 16:27:04.000000000 -0400 @@ -33,8 +33,8 @@ #include "opto/addnode.hpp" #include "opto/callGenerator.hpp" #include "opto/callnode.hpp" +#include "opto/castnode.hpp" #include "opto/cfgnode.hpp" -#include "opto/connode.hpp" #include "opto/parse.hpp" #include "opto/rootnode.hpp" #include "opto/runtime.hpp" --- old/src/share/vm/opto/callnode.cpp 2014-03-18 16:27:05.000000000 -0400 +++ new/src/share/vm/opto/callnode.cpp 2014-03-18 16:27:05.000000000 -0400 @@ -27,6 +27,7 @@ #include "compiler/oopMap.hpp" #include "opto/callGenerator.hpp" #include "opto/callnode.hpp" +#include "opto/castnode.hpp" #include "opto/escape.hpp" #include "opto/locknode.hpp" #include "opto/machnode.hpp" --- old/src/share/vm/opto/cfgnode.cpp 2014-03-18 16:27:06.000000000 -0400 +++ new/src/share/vm/opto/cfgnode.cpp 2014-03-18 16:27:06.000000000 -0400 @@ -29,8 +29,11 @@ #include "opto/addnode.hpp" #include "opto/cfgnode.hpp" #include "opto/connode.hpp" +#include "opto/convertnode.hpp" #include "opto/loopnode.hpp" #include "opto/machnode.hpp" +#include "opto/movenode.hpp" +#include "opto/narrowptrnode.hpp" #include "opto/mulnode.hpp" #include "opto/phaseX.hpp" #include "opto/regmask.hpp" --- old/src/share/vm/opto/chaitin.cpp 2014-03-18 16:27:07.000000000 -0400 +++ new/src/share/vm/opto/chaitin.cpp 2014-03-18 16:27:07.000000000 -0400 @@ -37,6 +37,7 @@ #include "opto/indexSet.hpp" #include "opto/machnode.hpp" #include "opto/memnode.hpp" +#include "opto/movenode.hpp" #include "opto/opcodes.hpp" #include "opto/rootnode.hpp" --- old/src/share/vm/opto/classes.cpp 2014-03-18 16:27:08.000000000 -0400 +++ new/src/share/vm/opto/classes.cpp 2014-03-18 16:27:08.000000000 -0400 @@ -25,17 +25,24 @@ #include "precompiled.hpp" #include "opto/addnode.hpp" #include "opto/callnode.hpp" +#include "opto/castnode.hpp" #include "opto/cfgnode.hpp" #include "opto/connode.hpp" +#include "opto/convertnode.hpp" +#include "opto/countbitsnode.hpp" #include "opto/divnode.hpp" +#include "opto/intrinsicnode.hpp" #include "opto/locknode.hpp" #include "opto/loopnode.hpp" #include "opto/machnode.hpp" #include "opto/memnode.hpp" #include "opto/mathexactnode.hpp" +#include "opto/movenode.hpp" #include "opto/mulnode.hpp" #include "opto/multnode.hpp" +#include "opto/narrowptrnode.hpp" #include "opto/node.hpp" +#include "opto/opaquenode.hpp" #include "opto/rootnode.hpp" #include "opto/subnode.hpp" #include "opto/vectornode.hpp" --- old/src/share/vm/opto/compile.cpp 2014-03-18 16:27:08.000000000 -0400 +++ new/src/share/vm/opto/compile.cpp 2014-03-18 16:27:08.000000000 -0400 @@ -51,6 +51,7 @@ #include "opto/mathexactnode.hpp" #include "opto/memnode.hpp" #include "opto/mulnode.hpp" +#include "opto/narrowptrnode.hpp" #include "opto/node.hpp" #include "opto/opcodes.hpp" #include "opto/output.hpp" --- old/src/share/vm/opto/connode.cpp 2014-03-18 16:27:10.000000000 -0400 +++ new/src/share/vm/opto/connode.cpp 2014-03-18 16:27:10.000000000 -0400 @@ -107,1272 +107,3 @@ */ -//------------------------------Ideal------------------------------------------ -// Return a node which is more "ideal" than the current node. -// Move constants to the right. -Node *CMoveNode::Ideal(PhaseGVN *phase, bool can_reshape) { - if( in(0) && remove_dead_region(phase, can_reshape) ) return this; - // Don't bother trying to transform a dead node - if( in(0) && in(0)->is_top() ) return NULL; - assert( !phase->eqv(in(Condition), this) && - !phase->eqv(in(IfFalse), this) && - !phase->eqv(in(IfTrue), this), "dead loop in CMoveNode::Ideal" ); - if( phase->type(in(Condition)) == Type::TOP ) - return NULL; // return NULL when Condition is dead - - if( in(IfFalse)->is_Con() && !in(IfTrue)->is_Con() ) { - if( in(Condition)->is_Bool() ) { - BoolNode* b = in(Condition)->as_Bool(); - BoolNode* b2 = b->negate(phase); - return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type ); - } - } - return NULL; -} - -//------------------------------is_cmove_id------------------------------------ -// Helper function to check for CMOVE identity. Shared with PhiNode::Identity -Node *CMoveNode::is_cmove_id( PhaseTransform *phase, Node *cmp, Node *t, Node *f, BoolNode *b ) { - // Check for Cmp'ing and CMove'ing same values - if( (phase->eqv(cmp->in(1),f) && - phase->eqv(cmp->in(2),t)) || - // Swapped Cmp is OK - (phase->eqv(cmp->in(2),f) && - phase->eqv(cmp->in(1),t)) ) { - // Give up this identity check for floating points because it may choose incorrect - // value around 0.0 and -0.0 - if ( cmp->Opcode()==Op_CmpF || cmp->Opcode()==Op_CmpD ) - return NULL; - // Check for "(t==f)?t:f;" and replace with "f" - if( b->_test._test == BoolTest::eq ) - return f; - // Allow the inverted case as well - // Check for "(t!=f)?t:f;" and replace with "t" - if( b->_test._test == BoolTest::ne ) - return t; - } - return NULL; -} - -//------------------------------Identity--------------------------------------- -// Conditional-move is an identity if both inputs are the same, or the test -// true or false. -Node *CMoveNode::Identity( PhaseTransform *phase ) { - if( phase->eqv(in(IfFalse),in(IfTrue)) ) // C-moving identical inputs? - return in(IfFalse); // Then it doesn't matter - if( phase->type(in(Condition)) == TypeInt::ZERO ) - return in(IfFalse); // Always pick left(false) input - if( phase->type(in(Condition)) == TypeInt::ONE ) - return in(IfTrue); // Always pick right(true) input - - // 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. - if( in(Condition)->is_Bool() ) { - BoolNode *b = in(Condition)->as_Bool(); - Node *cmp = b->in(1); - if( cmp->is_Cmp() ) { - Node *id = is_cmove_id( phase, cmp, in(IfTrue), in(IfFalse), b ); - if( id ) return id; - } - } - - return this; -} - -//------------------------------Value------------------------------------------ -// Result is the meet of inputs -const Type *CMoveNode::Value( PhaseTransform *phase ) const { - if( phase->type(in(Condition)) == Type::TOP ) - return Type::TOP; - return phase->type(in(IfFalse))->meet_speculative(phase->type(in(IfTrue))); -} - -//------------------------------make------------------------------------------- -// Make a correctly-flavored CMove. Since _type is directly determined -// from the inputs we do not need to specify it here. -CMoveNode *CMoveNode::make( Compile *C, Node *c, Node *bol, Node *left, Node *right, const Type *t ) { - switch( t->basic_type() ) { - case T_INT: return new (C) CMoveINode( bol, left, right, t->is_int() ); - case T_FLOAT: return new (C) CMoveFNode( bol, left, right, t ); - case T_DOUBLE: return new (C) CMoveDNode( bol, left, right, t ); - case T_LONG: return new (C) CMoveLNode( bol, left, right, t->is_long() ); - case T_OBJECT: return new (C) CMovePNode( c, bol, left, right, t->is_oopptr() ); - case T_ADDRESS: return new (C) CMovePNode( c, bol, left, right, t->is_ptr() ); - case T_NARROWOOP: return new (C) CMoveNNode( c, bol, left, right, t ); - default: - ShouldNotReachHere(); - return NULL; - } -} - -//============================================================================= -//------------------------------Ideal------------------------------------------ -// Return a node which is more "ideal" than the current node. -// Check for conversions to boolean -Node *CMoveINode::Ideal(PhaseGVN *phase, bool can_reshape) { - // Try generic ideal's first - Node *x = CMoveNode::Ideal(phase, can_reshape); - if( x ) return x; - - // If zero is on the left (false-case, no-move-case) it must mean another - // constant is on the right (otherwise the shared CMove::Ideal code would - // have moved the constant to the right). This situation is bad for Intel - // and a don't-care for Sparc. It's bad for Intel because the zero has to - // be manifested in a register with a XOR which kills flags, which are live - // on input to the CMoveI, leading to a situation which causes excessive - // spilling on Intel. For Sparc, if the zero in on the left the Sparc will - // zero a register via G0 and conditionally-move the other constant. If the - // zero is on the right, the Sparc will load the first constant with a - // 13-bit set-lo and conditionally move G0. See bug 4677505. - if( phase->type(in(IfFalse)) == TypeInt::ZERO && !(phase->type(in(IfTrue)) == TypeInt::ZERO) ) { - if( in(Condition)->is_Bool() ) { - BoolNode* b = in(Condition)->as_Bool(); - BoolNode* b2 = b->negate(phase); - return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type ); - } - } - - // Now check for booleans - int flip = 0; - - // Check for picking from zero/one - if( phase->type(in(IfFalse)) == TypeInt::ZERO && phase->type(in(IfTrue)) == TypeInt::ONE ) { - flip = 1 - flip; - } else if( phase->type(in(IfFalse)) == TypeInt::ONE && phase->type(in(IfTrue)) == TypeInt::ZERO ) { - } else return NULL; - - // Check for eq/ne test - if( !in(1)->is_Bool() ) return NULL; - BoolNode *bol = in(1)->as_Bool(); - if( bol->_test._test == BoolTest::eq ) { - } else if( bol->_test._test == BoolTest::ne ) { - flip = 1-flip; - } else return NULL; - - // Check for vs 0 or 1 - if( !bol->in(1)->is_Cmp() ) return NULL; - const CmpNode *cmp = bol->in(1)->as_Cmp(); - if( phase->type(cmp->in(2)) == TypeInt::ZERO ) { - } else if( phase->type(cmp->in(2)) == TypeInt::ONE ) { - // Allow cmp-vs-1 if the other input is bounded by 0-1 - if( phase->type(cmp->in(1)) != TypeInt::BOOL ) - return NULL; - flip = 1 - flip; - } else return NULL; - - // Convert to a bool (flipped) - // Build int->bool conversion -#ifndef PRODUCT - if( PrintOpto ) tty->print_cr("CMOV to I2B"); -#endif - Node *n = new (phase->C) Conv2BNode( cmp->in(1) ); - if( flip ) - n = new (phase->C) XorINode( phase->transform(n), phase->intcon(1) ); - - return n; -} - -//============================================================================= -//------------------------------Ideal------------------------------------------ -// Return a node which is more "ideal" than the current node. -// Check for absolute value -Node *CMoveFNode::Ideal(PhaseGVN *phase, bool can_reshape) { - // Try generic ideal's first - Node *x = CMoveNode::Ideal(phase, can_reshape); - if( x ) return x; - - 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 - - // Find the Bool - if( !in(1)->is_Bool() ) return NULL; - BoolNode *bol = in(1)->as_Bool(); - // Check bool sense - switch( bol->_test._test ) { - case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = IfTrue; break; - case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = IfFalse; break; - case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = IfTrue; break; - case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = IfFalse; break; - default: return NULL; break; - } - - // Find zero input of CmpF; the other input is being abs'd - Node *cmpf = bol->in(1); - if( cmpf->Opcode() != Op_CmpF ) return NULL; - Node *X = NULL; - bool flip = false; - if( phase->type(cmpf->in(cmp_zero_idx)) == TypeF::ZERO ) { - X = cmpf->in(3 - cmp_zero_idx); - } else if (phase->type(cmpf->in(3 - cmp_zero_idx)) == TypeF::ZERO) { - // The test is inverted, we should invert the result... - X = cmpf->in(cmp_zero_idx); - flip = true; - } else { - return NULL; - } - - // If X is found on the appropriate phi input, find the subtract on the other - if( X != in(phi_x_idx) ) return NULL; - int phi_sub_idx = phi_x_idx == IfTrue ? IfFalse : IfTrue; - Node *sub = in(phi_sub_idx); - - // Allow only SubF(0,X) and fail out for all others; NegF is not OK - if( sub->Opcode() != Op_SubF || - sub->in(2) != X || - phase->type(sub->in(1)) != TypeF::ZERO ) return NULL; - - Node *abs = new (phase->C) AbsFNode( X ); - if( flip ) - abs = new (phase->C) SubFNode(sub->in(1), phase->transform(abs)); - - return abs; -} - -//============================================================================= -//------------------------------Ideal------------------------------------------ -// Return a node which is more "ideal" than the current node. -// Check for absolute value -Node *CMoveDNode::Ideal(PhaseGVN *phase, bool can_reshape) { - // Try generic ideal's first - Node *x = CMoveNode::Ideal(phase, can_reshape); - if( x ) return x; - - 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 - - // Find the Bool - if( !in(1)->is_Bool() ) return NULL; - BoolNode *bol = in(1)->as_Bool(); - // Check bool sense - switch( bol->_test._test ) { - case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = IfTrue; break; - case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = IfFalse; break; - case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = IfTrue; break; - case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = IfFalse; break; - default: return NULL; break; - } - - // Find zero input of CmpD; the other input is being abs'd - Node *cmpd = bol->in(1); - if( cmpd->Opcode() != Op_CmpD ) return NULL; - Node *X = NULL; - bool flip = false; - if( phase->type(cmpd->in(cmp_zero_idx)) == TypeD::ZERO ) { - X = cmpd->in(3 - cmp_zero_idx); - } else if (phase->type(cmpd->in(3 - cmp_zero_idx)) == TypeD::ZERO) { - // The test is inverted, we should invert the result... - X = cmpd->in(cmp_zero_idx); - flip = true; - } else { - return NULL; - } - - // If X is found on the appropriate phi input, find the subtract on the other - if( X != in(phi_x_idx) ) return NULL; - int phi_sub_idx = phi_x_idx == IfTrue ? IfFalse : IfTrue; - Node *sub = in(phi_sub_idx); - - // Allow only SubD(0,X) and fail out for all others; NegD is not OK - if( sub->Opcode() != Op_SubD || - sub->in(2) != X || - phase->type(sub->in(1)) != TypeD::ZERO ) return NULL; - - Node *abs = new (phase->C) AbsDNode( X ); - if( flip ) - abs = new (phase->C) SubDNode(sub->in(1), phase->transform(abs)); - - return abs; -} - - -//============================================================================= -// If input is already higher or equal to cast type, then this is an identity. -Node *ConstraintCastNode::Identity( PhaseTransform *phase ) { - return phase->type(in(1))->higher_equal_speculative(_type) ? in(1) : this; -} - -//------------------------------Value------------------------------------------ -// Take 'join' of input and cast-up type -const Type *ConstraintCastNode::Value( PhaseTransform *phase ) const { - if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP; -const Type* ft = phase->type(in(1))->filter_speculative(_type); - -#ifdef ASSERT - // Previous versions of this function had some special case logic, - // which is no longer necessary. Make sure of the required effects. - switch (Opcode()) { - case Op_CastII: - { - const Type* t1 = phase->type(in(1)); - if( t1 == Type::TOP ) assert(ft == Type::TOP, "special case #1"); - const Type* rt = t1->join_speculative(_type); - if (rt->empty()) assert(ft == Type::TOP, "special case #2"); - break; - } - case Op_CastPP: - if (phase->type(in(1)) == TypePtr::NULL_PTR && - _type->isa_ptr() && _type->is_ptr()->_ptr == TypePtr::NotNull) - assert(ft == Type::TOP, "special case #3"); - break; - } -#endif //ASSERT - - return ft; -} - -//------------------------------Ideal------------------------------------------ -// Return a node which is more "ideal" than the current node. Strip out -// control copies -Node *ConstraintCastNode::Ideal(PhaseGVN *phase, bool can_reshape){ - return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; -} - -//------------------------------Ideal_DU_postCCP------------------------------- -// Throw away cast after constant propagation -Node *ConstraintCastNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { - const Type *t = ccp->type(in(1)); - ccp->hash_delete(this); - set_type(t); // Turn into ID function - ccp->hash_insert(this); - return this; -} - - -//============================================================================= - -//------------------------------Ideal_DU_postCCP------------------------------- -// If not converting int->oop, throw away cast after constant propagation -Node *CastPPNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { - const Type *t = ccp->type(in(1)); - if (!t->isa_oop_ptr() || ((in(1)->is_DecodeN()) && Matcher::gen_narrow_oop_implicit_null_checks())) { - return NULL; // do not transform raw pointers or narrow oops - } - return ConstraintCastNode::Ideal_DU_postCCP(ccp); -} - - - -//============================================================================= -//------------------------------Identity--------------------------------------- -// If input is already higher or equal to cast type, then this is an identity. -Node *CheckCastPPNode::Identity( PhaseTransform *phase ) { - // Toned down to rescue meeting at a Phi 3 different oops all implementing - // the same interface. CompileTheWorld starting at 502, kd12rc1.zip. - return (phase->type(in(1)) == phase->type(this)) ? in(1) : this; -} - -//------------------------------Value------------------------------------------ -// Take 'join' of input and cast-up type, unless working with an Interface -const Type *CheckCastPPNode::Value( PhaseTransform *phase ) const { - if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP; - - const Type *inn = phase->type(in(1)); - if( inn == Type::TOP ) return Type::TOP; // No information yet - - const TypePtr *in_type = inn->isa_ptr(); - const TypePtr *my_type = _type->isa_ptr(); - const Type *result = _type; - if( in_type != NULL && my_type != NULL ) { - TypePtr::PTR in_ptr = in_type->ptr(); - if( in_ptr == TypePtr::Null ) { - result = in_type; - } else if( in_ptr == TypePtr::Constant ) { - // Casting a constant oop to an interface? - // (i.e., a String to a Comparable?) - // Then return the interface. - const TypeOopPtr *jptr = my_type->isa_oopptr(); - assert( jptr, "" ); - result = (jptr->klass()->is_interface() || !in_type->higher_equal(_type)) - ? my_type->cast_to_ptr_type( TypePtr::NotNull ) - : in_type; - } else { - result = my_type->cast_to_ptr_type( my_type->join_ptr(in_ptr) ); - } - } - return result; - - // JOIN NOT DONE HERE BECAUSE OF INTERFACE ISSUES. - // FIX THIS (DO THE JOIN) WHEN UNION TYPES APPEAR! - - // - // Remove this code after overnight run indicates no performance - // loss from not performing JOIN at CheckCastPPNode - // - // const TypeInstPtr *in_oop = in->isa_instptr(); - // const TypeInstPtr *my_oop = _type->isa_instptr(); - // // If either input is an 'interface', return destination type - // assert (in_oop == NULL || in_oop->klass() != NULL, ""); - // assert (my_oop == NULL || my_oop->klass() != NULL, ""); - // if( (in_oop && in_oop->klass()->is_interface()) - // ||(my_oop && my_oop->klass()->is_interface()) ) { - // TypePtr::PTR in_ptr = in->isa_ptr() ? in->is_ptr()->_ptr : TypePtr::BotPTR; - // // Preserve cast away nullness for interfaces - // if( in_ptr == TypePtr::NotNull && my_oop && my_oop->_ptr == TypePtr::BotPTR ) { - // return my_oop->cast_to_ptr_type(TypePtr::NotNull); - // } - // return _type; - // } - // - // // Neither the input nor the destination type is an interface, - // - // // history: JOIN used to cause weird corner case bugs - // // return (in == TypeOopPtr::NULL_PTR) ? in : _type; - // // JOIN picks up NotNull in common instance-of/check-cast idioms, both oops. - // // JOIN does not preserve NotNull in other cases, e.g. RawPtr vs InstPtr - // const Type *join = in->join(_type); - // // Check if join preserved NotNull'ness for pointers - // if( join->isa_ptr() && _type->isa_ptr() ) { - // TypePtr::PTR join_ptr = join->is_ptr()->_ptr; - // TypePtr::PTR type_ptr = _type->is_ptr()->_ptr; - // // If there isn't any NotNull'ness to preserve - // // OR if join preserved NotNull'ness then return it - // if( type_ptr == TypePtr::BotPTR || type_ptr == TypePtr::Null || - // join_ptr == TypePtr::NotNull || join_ptr == TypePtr::Constant ) { - // return join; - // } - // // ELSE return same old type as before - // return _type; - // } - // // Not joining two pointers - // return join; -} - -//------------------------------Ideal------------------------------------------ -// Return a node which is more "ideal" than the current node. Strip out -// control copies -Node *CheckCastPPNode::Ideal(PhaseGVN *phase, bool can_reshape){ - return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; -} - - -Node* DecodeNNode::Identity(PhaseTransform* phase) { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return in(1); - - if (in(1)->is_EncodeP()) { - // (DecodeN (EncodeP p)) -> p - return in(1)->in(1); - } - return this; -} - -const Type *DecodeNNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if (t == Type::TOP) return Type::TOP; - if (t == TypeNarrowOop::NULL_PTR) return TypePtr::NULL_PTR; - - assert(t->isa_narrowoop(), "only narrowoop here"); - return t->make_ptr(); -} - -Node* EncodePNode::Identity(PhaseTransform* phase) { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return in(1); - - if (in(1)->is_DecodeN()) { - // (EncodeP (DecodeN p)) -> p - return in(1)->in(1); - } - return this; -} - -const Type *EncodePNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if (t == Type::TOP) return Type::TOP; - if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR; - - assert(t->isa_oop_ptr(), "only oopptr here"); - return t->make_narrowoop(); -} - - -Node *EncodeNarrowPtrNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { - return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1)); -} - -Node* DecodeNKlassNode::Identity(PhaseTransform* phase) { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return in(1); - - if (in(1)->is_EncodePKlass()) { - // (DecodeNKlass (EncodePKlass p)) -> p - return in(1)->in(1); - } - return this; -} - -const Type *DecodeNKlassNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if (t == Type::TOP) return Type::TOP; - assert(t != TypeNarrowKlass::NULL_PTR, "null klass?"); - - assert(t->isa_narrowklass(), "only narrow klass ptr here"); - return t->make_ptr(); -} - -Node* EncodePKlassNode::Identity(PhaseTransform* phase) { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return in(1); - - if (in(1)->is_DecodeNKlass()) { - // (EncodePKlass (DecodeNKlass p)) -> p - return in(1)->in(1); - } - return this; -} - -const Type *EncodePKlassNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if (t == Type::TOP) return Type::TOP; - assert (t != TypePtr::NULL_PTR, "null klass?"); - - assert(UseCompressedClassPointers && t->isa_klassptr(), "only klass ptr here"); - return t->make_narrowklass(); -} - - -//============================================================================= -//------------------------------Identity--------------------------------------- -Node *Conv2BNode::Identity( PhaseTransform *phase ) { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return in(1); - if( t == TypeInt::ZERO ) return in(1); - if( t == TypeInt::ONE ) return in(1); - if( t == TypeInt::BOOL ) return in(1); - return this; -} - -//------------------------------Value------------------------------------------ -const Type *Conv2BNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - if( t == TypeInt::ZERO ) return TypeInt::ZERO; - if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO; - const TypePtr *tp = t->isa_ptr(); - if( tp != NULL ) { - if( tp->ptr() == TypePtr::AnyNull ) return Type::TOP; - if( tp->ptr() == TypePtr::Constant) return TypeInt::ONE; - if (tp->ptr() == TypePtr::NotNull) return TypeInt::ONE; - return TypeInt::BOOL; - } - if (t->base() != Type::Int) return TypeInt::BOOL; - const TypeInt *ti = t->is_int(); - if( ti->_hi < 0 || ti->_lo > 0 ) return TypeInt::ONE; - return TypeInt::BOOL; -} - - -// The conversions operations are all Alpha sorted. Please keep it that way! -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *ConvD2FNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - if( t == Type::DOUBLE ) return Type::FLOAT; - const TypeD *td = t->is_double_constant(); - return TypeF::make( (float)td->getd() ); -} - -//------------------------------Identity--------------------------------------- -// Float's can be converted to doubles with no loss of bits. Hence -// converting a float to a double and back to a float is a NOP. -Node *ConvD2FNode::Identity(PhaseTransform *phase) { - return (in(1)->Opcode() == Op_ConvF2D) ? in(1)->in(1) : this; -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *ConvD2INode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - if( t == Type::DOUBLE ) return TypeInt::INT; - const TypeD *td = t->is_double_constant(); - return TypeInt::make( SharedRuntime::d2i( td->getd() ) ); -} - -//------------------------------Ideal------------------------------------------ -// If converting to an int type, skip any rounding nodes -Node *ConvD2INode::Ideal(PhaseGVN *phase, bool can_reshape) { - if( in(1)->Opcode() == Op_RoundDouble ) - set_req(1,in(1)->in(1)); - return NULL; -} - -//------------------------------Identity--------------------------------------- -// Int's can be converted to doubles with no loss of bits. Hence -// converting an integer to a double and back to an integer is a NOP. -Node *ConvD2INode::Identity(PhaseTransform *phase) { - return (in(1)->Opcode() == Op_ConvI2D) ? in(1)->in(1) : this; -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *ConvD2LNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - if( t == Type::DOUBLE ) return TypeLong::LONG; - const TypeD *td = t->is_double_constant(); - return TypeLong::make( SharedRuntime::d2l( td->getd() ) ); -} - -//------------------------------Identity--------------------------------------- -Node *ConvD2LNode::Identity(PhaseTransform *phase) { - // Remove ConvD2L->ConvL2D->ConvD2L sequences. - if( in(1) ->Opcode() == Op_ConvL2D && - in(1)->in(1)->Opcode() == Op_ConvD2L ) - return in(1)->in(1); - return this; -} - -//------------------------------Ideal------------------------------------------ -// If converting to an int type, skip any rounding nodes -Node *ConvD2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { - if( in(1)->Opcode() == Op_RoundDouble ) - set_req(1,in(1)->in(1)); - return NULL; -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *ConvF2DNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - if( t == Type::FLOAT ) return Type::DOUBLE; - const TypeF *tf = t->is_float_constant(); - return TypeD::make( (double)tf->getf() ); -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *ConvF2INode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - if( t == Type::FLOAT ) return TypeInt::INT; - const TypeF *tf = t->is_float_constant(); - return TypeInt::make( SharedRuntime::f2i( tf->getf() ) ); -} - -//------------------------------Identity--------------------------------------- -Node *ConvF2INode::Identity(PhaseTransform *phase) { - // Remove ConvF2I->ConvI2F->ConvF2I sequences. - if( in(1) ->Opcode() == Op_ConvI2F && - in(1)->in(1)->Opcode() == Op_ConvF2I ) - return in(1)->in(1); - return this; -} - -//------------------------------Ideal------------------------------------------ -// If converting to an int type, skip any rounding nodes -Node *ConvF2INode::Ideal(PhaseGVN *phase, bool can_reshape) { - if( in(1)->Opcode() == Op_RoundFloat ) - set_req(1,in(1)->in(1)); - return NULL; -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *ConvF2LNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - if( t == Type::FLOAT ) return TypeLong::LONG; - const TypeF *tf = t->is_float_constant(); - return TypeLong::make( SharedRuntime::f2l( tf->getf() ) ); -} - -//------------------------------Identity--------------------------------------- -Node *ConvF2LNode::Identity(PhaseTransform *phase) { - // Remove ConvF2L->ConvL2F->ConvF2L sequences. - if( in(1) ->Opcode() == Op_ConvL2F && - in(1)->in(1)->Opcode() == Op_ConvF2L ) - return in(1)->in(1); - return this; -} - -//------------------------------Ideal------------------------------------------ -// If converting to an int type, skip any rounding nodes -Node *ConvF2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { - if( in(1)->Opcode() == Op_RoundFloat ) - set_req(1,in(1)->in(1)); - return NULL; -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *ConvI2DNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - const TypeInt *ti = t->is_int(); - if( ti->is_con() ) return TypeD::make( (double)ti->get_con() ); - return bottom_type(); -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *ConvI2FNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - const TypeInt *ti = t->is_int(); - if( ti->is_con() ) return TypeF::make( (float)ti->get_con() ); - return bottom_type(); -} - -//------------------------------Identity--------------------------------------- -Node *ConvI2FNode::Identity(PhaseTransform *phase) { - // Remove ConvI2F->ConvF2I->ConvI2F sequences. - if( in(1) ->Opcode() == Op_ConvF2I && - in(1)->in(1)->Opcode() == Op_ConvI2F ) - return in(1)->in(1); - return this; -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *ConvI2LNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - const TypeInt *ti = t->is_int(); - const Type* tl = TypeLong::make(ti->_lo, ti->_hi, ti->_widen); - // Join my declared type against my incoming type. - tl = tl->filter(_type); - return tl; -} - -#ifdef _LP64 -static inline bool long_ranges_overlap(jlong lo1, jlong hi1, - jlong lo2, jlong hi2) { - // Two ranges overlap iff one range's low point falls in the other range. - return (lo2 <= lo1 && lo1 <= hi2) || (lo1 <= lo2 && lo2 <= hi1); -} -#endif - -//------------------------------Ideal------------------------------------------ -Node *ConvI2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { - const TypeLong* this_type = this->type()->is_long(); - Node* this_changed = NULL; - - // If _major_progress, then more loop optimizations follow. Do NOT - // remove this node's type assertion until no more loop ops can happen. - // The progress bit is set in the major loop optimizations THEN comes the - // call to IterGVN and any chance of hitting this code. Cf. Opaque1Node. - if (can_reshape && !phase->C->major_progress()) { - const TypeInt* in_type = phase->type(in(1))->isa_int(); - if (in_type != NULL && this_type != NULL && - (in_type->_lo != this_type->_lo || - in_type->_hi != this_type->_hi)) { - // Although this WORSENS the type, it increases GVN opportunities, - // because I2L nodes with the same input will common up, regardless - // of slightly differing type assertions. Such slight differences - // arise routinely as a result of loop unrolling, so this is a - // post-unrolling graph cleanup. Choose a type which depends only - // on my input. (Exception: Keep a range assertion of >=0 or <0.) - jlong lo1 = this_type->_lo; - jlong hi1 = this_type->_hi; - int w1 = this_type->_widen; - if (lo1 != (jint)lo1 || - hi1 != (jint)hi1 || - lo1 > hi1) { - // Overflow leads to wraparound, wraparound leads to range saturation. - lo1 = min_jint; hi1 = max_jint; - } else if (lo1 >= 0) { - // Keep a range assertion of >=0. - lo1 = 0; hi1 = max_jint; - } else if (hi1 < 0) { - // Keep a range assertion of <0. - lo1 = min_jint; hi1 = -1; - } else { - lo1 = min_jint; hi1 = max_jint; - } - const TypeLong* wtype = TypeLong::make(MAX2((jlong)in_type->_lo, lo1), - MIN2((jlong)in_type->_hi, hi1), - MAX2((int)in_type->_widen, w1)); - if (wtype != type()) { - set_type(wtype); - // Note: this_type still has old type value, for the logic below. - this_changed = this; - } - } - } - -#ifdef _LP64 - // Convert ConvI2L(AddI(x, y)) to AddL(ConvI2L(x), ConvI2L(y)) , - // but only if x and y have subranges that cannot cause 32-bit overflow, - // under the assumption that x+y is in my own subrange this->type(). - - // This assumption is based on a constraint (i.e., type assertion) - // established in Parse::array_addressing or perhaps elsewhere. - // This constraint has been adjoined to the "natural" type of - // the incoming argument in(0). We know (because of runtime - // checks) - that the result value I2L(x+y) is in the joined range. - // Hence we can restrict the incoming terms (x, y) to values such - // that their sum also lands in that range. - - // This optimization is useful only on 64-bit systems, where we hope - // the addition will end up subsumed in an addressing mode. - // It is necessary to do this when optimizing an unrolled array - // copy loop such as x[i++] = y[i++]. - - // On 32-bit systems, it's better to perform as much 32-bit math as - // possible before the I2L conversion, because 32-bit math is cheaper. - // There's no common reason to "leak" a constant offset through the I2L. - // Addressing arithmetic will not absorb it as part of a 64-bit AddL. - - Node* z = in(1); - int op = z->Opcode(); - if (op == Op_AddI || op == Op_SubI) { - Node* x = z->in(1); - Node* y = z->in(2); - assert (x != z && y != z, "dead loop in ConvI2LNode::Ideal"); - if (phase->type(x) == Type::TOP) return this_changed; - if (phase->type(y) == Type::TOP) return this_changed; - const TypeInt* tx = phase->type(x)->is_int(); - const TypeInt* ty = phase->type(y)->is_int(); - const TypeLong* tz = this_type; - jlong xlo = tx->_lo; - jlong xhi = tx->_hi; - jlong ylo = ty->_lo; - jlong yhi = ty->_hi; - jlong zlo = tz->_lo; - jlong zhi = tz->_hi; - jlong vbit = CONST64(1) << BitsPerInt; - int widen = MAX2(tx->_widen, ty->_widen); - if (op == Op_SubI) { - jlong ylo0 = ylo; - ylo = -yhi; - yhi = -ylo0; - } - // See if x+y can cause positive overflow into z+2**32 - if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo+vbit, zhi+vbit)) { - return this_changed; - } - // See if x+y can cause negative overflow into z-2**32 - if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo-vbit, zhi-vbit)) { - return this_changed; - } - // Now it's always safe to assume x+y does not overflow. - // This is true even if some pairs x,y might cause overflow, as long - // as that overflow value cannot fall into [zlo,zhi]. - - // Confident that the arithmetic is "as if infinite precision", - // we can now use z's range to put constraints on those of x and y. - // The "natural" range of x [xlo,xhi] can perhaps be narrowed to a - // more "restricted" range by intersecting [xlo,xhi] with the - // range obtained by subtracting y's range from the asserted range - // of the I2L conversion. Here's the interval arithmetic algebra: - // x == z-y == [zlo,zhi]-[ylo,yhi] == [zlo,zhi]+[-yhi,-ylo] - // => x in [zlo-yhi, zhi-ylo] - // => x in [zlo-yhi, zhi-ylo] INTERSECT [xlo,xhi] - // => x in [xlo MAX zlo-yhi, xhi MIN zhi-ylo] - jlong rxlo = MAX2(xlo, zlo - yhi); - jlong rxhi = MIN2(xhi, zhi - ylo); - // And similarly, x changing place with y: - jlong rylo = MAX2(ylo, zlo - xhi); - jlong ryhi = MIN2(yhi, zhi - xlo); - if (rxlo > rxhi || rylo > ryhi) { - return this_changed; // x or y is dying; don't mess w/ it - } - if (op == Op_SubI) { - jlong rylo0 = rylo; - rylo = -ryhi; - ryhi = -rylo0; - } - - Node* cx = phase->transform( new (phase->C) ConvI2LNode(x, TypeLong::make(rxlo, rxhi, widen)) ); - Node* cy = phase->transform( new (phase->C) ConvI2LNode(y, TypeLong::make(rylo, ryhi, widen)) ); - switch (op) { - case Op_AddI: return new (phase->C) AddLNode(cx, cy); - case Op_SubI: return new (phase->C) SubLNode(cx, cy); - default: ShouldNotReachHere(); - } - } -#endif //_LP64 - - return this_changed; -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *ConvL2DNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - const TypeLong *tl = t->is_long(); - if( tl->is_con() ) return TypeD::make( (double)tl->get_con() ); - return bottom_type(); -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *ConvL2FNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - const TypeLong *tl = t->is_long(); - if( tl->is_con() ) return TypeF::make( (float)tl->get_con() ); - return bottom_type(); -} - -//============================================================================= -//----------------------------Identity----------------------------------------- -Node *ConvL2INode::Identity( PhaseTransform *phase ) { - // Convert L2I(I2L(x)) => x - if (in(1)->Opcode() == Op_ConvI2L) return in(1)->in(1); - return this; -} - -//------------------------------Value------------------------------------------ -const Type *ConvL2INode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - const TypeLong *tl = t->is_long(); - if (tl->is_con()) - // Easy case. - return TypeInt::make((jint)tl->get_con()); - return bottom_type(); -} - -//------------------------------Ideal------------------------------------------ -// Return a node which is more "ideal" than the current node. -// Blow off prior masking to int -Node *ConvL2INode::Ideal(PhaseGVN *phase, bool can_reshape) { - Node *andl = in(1); - uint andl_op = andl->Opcode(); - if( andl_op == Op_AndL ) { - // Blow off prior masking to int - if( phase->type(andl->in(2)) == TypeLong::make( 0xFFFFFFFF ) ) { - set_req(1,andl->in(1)); - return this; - } - } - - // Swap with a prior add: convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y)) - // This replaces an 'AddL' with an 'AddI'. - if( andl_op == Op_AddL ) { - // Don't do this for nodes which have more than one user since - // we'll end up computing the long add anyway. - if (andl->outcnt() > 1) return NULL; - - Node* x = andl->in(1); - Node* y = andl->in(2); - assert( x != andl && y != andl, "dead loop in ConvL2INode::Ideal" ); - if (phase->type(x) == Type::TOP) return NULL; - if (phase->type(y) == Type::TOP) return NULL; - Node *add1 = phase->transform(new (phase->C) ConvL2INode(x)); - Node *add2 = phase->transform(new (phase->C) ConvL2INode(y)); - return new (phase->C) AddINode(add1,add2); - } - - // Disable optimization: LoadL->ConvL2I ==> LoadI. - // It causes problems (sizes of Load and Store nodes do not match) - // in objects initialization code and Escape Analysis. - return NULL; -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *CastX2PNode::Value( PhaseTransform *phase ) const { - const Type* t = phase->type(in(1)); - if (t == Type::TOP) return Type::TOP; - if (t->base() == Type_X && t->singleton()) { - uintptr_t bits = (uintptr_t) t->is_intptr_t()->get_con(); - if (bits == 0) return TypePtr::NULL_PTR; - return TypeRawPtr::make((address) bits); - } - return CastX2PNode::bottom_type(); -} - -//------------------------------Idealize--------------------------------------- -static inline bool fits_in_int(const Type* t, bool but_not_min_int = false) { - if (t == Type::TOP) return false; - const TypeX* tl = t->is_intptr_t(); - jint lo = min_jint; - jint hi = max_jint; - if (but_not_min_int) ++lo; // caller wants to negate the value w/o overflow - return (tl->_lo >= lo) && (tl->_hi <= hi); -} - -static inline Node* addP_of_X2P(PhaseGVN *phase, - Node* base, - Node* dispX, - bool negate = false) { - if (negate) { - dispX = new (phase->C) SubXNode(phase->MakeConX(0), phase->transform(dispX)); - } - return new (phase->C) AddPNode(phase->C->top(), - phase->transform(new (phase->C) CastX2PNode(base)), - phase->transform(dispX)); -} - -Node *CastX2PNode::Ideal(PhaseGVN *phase, bool can_reshape) { - // convert CastX2P(AddX(x, y)) to AddP(CastX2P(x), y) if y fits in an int - int op = in(1)->Opcode(); - Node* x; - Node* y; - switch (op) { - case Op_SubX: - x = in(1)->in(1); - // Avoid ideal transformations ping-pong between this and AddP for raw pointers. - if (phase->find_intptr_t_con(x, -1) == 0) - break; - y = in(1)->in(2); - if (fits_in_int(phase->type(y), true)) { - return addP_of_X2P(phase, x, y, true); - } - break; - case Op_AddX: - x = in(1)->in(1); - y = in(1)->in(2); - if (fits_in_int(phase->type(y))) { - return addP_of_X2P(phase, x, y); - } - if (fits_in_int(phase->type(x))) { - return addP_of_X2P(phase, y, x); - } - break; - } - return NULL; -} - -//------------------------------Identity--------------------------------------- -Node *CastX2PNode::Identity( PhaseTransform *phase ) { - if (in(1)->Opcode() == Op_CastP2X) return in(1)->in(1); - return this; -} - -//============================================================================= -//------------------------------Value------------------------------------------ -const Type *CastP2XNode::Value( PhaseTransform *phase ) const { - const Type* t = phase->type(in(1)); - if (t == Type::TOP) return Type::TOP; - if (t->base() == Type::RawPtr && t->singleton()) { - uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con(); - return TypeX::make(bits); - } - return CastP2XNode::bottom_type(); -} - -Node *CastP2XNode::Ideal(PhaseGVN *phase, bool can_reshape) { - return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; -} - -//------------------------------Identity--------------------------------------- -Node *CastP2XNode::Identity( PhaseTransform *phase ) { - if (in(1)->Opcode() == Op_CastX2P) return in(1)->in(1); - return this; -} - - -//============================================================================= -//------------------------------Identity--------------------------------------- -// Remove redundant roundings -Node *RoundFloatNode::Identity( PhaseTransform *phase ) { - assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel"); - // Do not round constants - if (phase->type(in(1))->base() == Type::FloatCon) return in(1); - int op = in(1)->Opcode(); - // Redundant rounding - if( op == Op_RoundFloat ) return in(1); - // Already rounded - if( op == Op_Parm ) return in(1); - if( op == Op_LoadF ) return in(1); - return this; -} - -//------------------------------Value------------------------------------------ -const Type *RoundFloatNode::Value( PhaseTransform *phase ) const { - return phase->type( in(1) ); -} - -//============================================================================= -//------------------------------Identity--------------------------------------- -// Remove redundant roundings. Incoming arguments are already rounded. -Node *RoundDoubleNode::Identity( PhaseTransform *phase ) { - assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel"); - // Do not round constants - if (phase->type(in(1))->base() == Type::DoubleCon) return in(1); - int op = in(1)->Opcode(); - // Redundant rounding - if( op == Op_RoundDouble ) return in(1); - // Already rounded - if( op == Op_Parm ) return in(1); - if( op == Op_LoadD ) return in(1); - if( op == Op_ConvF2D ) return in(1); - if( op == Op_ConvI2D ) return in(1); - return this; -} - -//------------------------------Value------------------------------------------ -const Type *RoundDoubleNode::Value( PhaseTransform *phase ) const { - return phase->type( in(1) ); -} - - -//============================================================================= -// Do not allow value-numbering -uint Opaque1Node::hash() const { return NO_HASH; } -uint Opaque1Node::cmp( const Node &n ) const { - return (&n == this); // Always fail except on self -} - -//------------------------------Identity--------------------------------------- -// If _major_progress, then more loop optimizations follow. Do NOT remove -// the opaque Node until no more loop ops can happen. Note the timing of -// _major_progress; it's set in the major loop optimizations THEN comes the -// call to IterGVN and any chance of hitting this code. Hence there's no -// phase-ordering problem with stripping Opaque1 in IGVN followed by some -// more loop optimizations that require it. -Node *Opaque1Node::Identity( PhaseTransform *phase ) { - return phase->C->major_progress() ? this : in(1); -} - -//============================================================================= -// A node to prevent unwanted optimizations. Allows constant folding. Stops -// value-numbering, most Ideal calls or Identity functions. This Node is -// specifically designed to prevent the pre-increment value of a loop trip -// counter from being live out of the bottom of the loop (hence causing the -// pre- and post-increment values both being live and thus requiring an extra -// temp register and an extra move). If we "accidentally" optimize through -// this kind of a Node, we'll get slightly pessimal, but correct, code. Thus -// it's OK to be slightly sloppy on optimizations here. - -// Do not allow value-numbering -uint Opaque2Node::hash() const { return NO_HASH; } -uint Opaque2Node::cmp( const Node &n ) const { - return (&n == this); // Always fail except on self -} - - -//------------------------------Value------------------------------------------ -const Type *MoveL2DNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - const TypeLong *tl = t->is_long(); - if( !tl->is_con() ) return bottom_type(); - JavaValue v; - v.set_jlong(tl->get_con()); - return TypeD::make( v.get_jdouble() ); -} - -//------------------------------Value------------------------------------------ -const Type *MoveI2FNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - const TypeInt *ti = t->is_int(); - if( !ti->is_con() ) return bottom_type(); - JavaValue v; - v.set_jint(ti->get_con()); - return TypeF::make( v.get_jfloat() ); -} - -//------------------------------Value------------------------------------------ -const Type *MoveF2INode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - if( t == Type::FLOAT ) return TypeInt::INT; - const TypeF *tf = t->is_float_constant(); - JavaValue v; - v.set_jfloat(tf->getf()); - return TypeInt::make( v.get_jint() ); -} - -//------------------------------Value------------------------------------------ -const Type *MoveD2LNode::Value( PhaseTransform *phase ) const { - const Type *t = phase->type( in(1) ); - if( t == Type::TOP ) return Type::TOP; - if( t == Type::DOUBLE ) return TypeLong::LONG; - const TypeD *td = t->is_double_constant(); - JavaValue v; - v.set_jdouble(td->getd()); - return TypeLong::make( v.get_jlong() ); -} - -//------------------------------Value------------------------------------------ -const Type* CountLeadingZerosINode::Value(PhaseTransform* phase) const { - const Type* t = phase->type(in(1)); - if (t == Type::TOP) return Type::TOP; - const TypeInt* ti = t->isa_int(); - if (ti && ti->is_con()) { - jint i = ti->get_con(); - // HD, Figure 5-6 - if (i == 0) - return TypeInt::make(BitsPerInt); - int n = 1; - unsigned int x = i; - if (x >> 16 == 0) { n += 16; x <<= 16; } - if (x >> 24 == 0) { n += 8; x <<= 8; } - if (x >> 28 == 0) { n += 4; x <<= 4; } - if (x >> 30 == 0) { n += 2; x <<= 2; } - n -= x >> 31; - return TypeInt::make(n); - } - return TypeInt::INT; -} - -//------------------------------Value------------------------------------------ -const Type* CountLeadingZerosLNode::Value(PhaseTransform* phase) const { - const Type* t = phase->type(in(1)); - if (t == Type::TOP) return Type::TOP; - const TypeLong* tl = t->isa_long(); - if (tl && tl->is_con()) { - jlong l = tl->get_con(); - // HD, Figure 5-6 - if (l == 0) - return TypeInt::make(BitsPerLong); - int n = 1; - unsigned int x = (((julong) l) >> 32); - if (x == 0) { n += 32; x = (int) l; } - if (x >> 16 == 0) { n += 16; x <<= 16; } - if (x >> 24 == 0) { n += 8; x <<= 8; } - if (x >> 28 == 0) { n += 4; x <<= 4; } - if (x >> 30 == 0) { n += 2; x <<= 2; } - n -= x >> 31; - return TypeInt::make(n); - } - return TypeInt::INT; -} - -//------------------------------Value------------------------------------------ -const Type* CountTrailingZerosINode::Value(PhaseTransform* phase) const { - const Type* t = phase->type(in(1)); - if (t == Type::TOP) return Type::TOP; - const TypeInt* ti = t->isa_int(); - if (ti && ti->is_con()) { - jint i = ti->get_con(); - // HD, Figure 5-14 - int y; - if (i == 0) - return TypeInt::make(BitsPerInt); - int n = 31; - y = i << 16; if (y != 0) { n = n - 16; i = y; } - y = i << 8; if (y != 0) { n = n - 8; i = y; } - y = i << 4; if (y != 0) { n = n - 4; i = y; } - y = i << 2; if (y != 0) { n = n - 2; i = y; } - y = i << 1; if (y != 0) { n = n - 1; } - return TypeInt::make(n); - } - return TypeInt::INT; -} - -//------------------------------Value------------------------------------------ -const Type* CountTrailingZerosLNode::Value(PhaseTransform* phase) const { - const Type* t = phase->type(in(1)); - if (t == Type::TOP) return Type::TOP; - const TypeLong* tl = t->isa_long(); - if (tl && tl->is_con()) { - jlong l = tl->get_con(); - // HD, Figure 5-14 - int x, y; - if (l == 0) - return TypeInt::make(BitsPerLong); - int n = 63; - y = (int) l; if (y != 0) { n = n - 32; x = y; } else x = (((julong) l) >> 32); - y = x << 16; if (y != 0) { n = n - 16; x = y; } - y = x << 8; if (y != 0) { n = n - 8; x = y; } - y = x << 4; if (y != 0) { n = n - 4; x = y; } - y = x << 2; if (y != 0) { n = n - 2; x = y; } - y = x << 1; if (y != 0) { n = n - 1; } - return TypeInt::make(n); - } - return TypeInt::INT; -} --- old/src/share/vm/opto/connode.hpp 2014-03-18 16:27:11.000000000 -0400 +++ new/src/share/vm/opto/connode.hpp 2014-03-18 16:27:11.000000000 -0400 @@ -139,617 +139,16 @@ }; -//------------------------------BinaryNode------------------------------------- -// Place holder for the 2 conditional inputs to a CMove. CMove needs 4 -// inputs: the Bool (for the lt/gt/eq/ne bits), the flags (result of some -// compare), and the 2 values to select between. The Matcher requires a -// binary tree so we break it down like this: -// (CMove (Binary bol cmp) (Binary src1 src2)) -class BinaryNode : public Node { -public: - BinaryNode( Node *n1, Node *n2 ) : Node(0,n1,n2) { } - virtual int Opcode() const; - virtual uint ideal_reg() const { return 0; } -}; - -//------------------------------CMoveNode-------------------------------------- -// Conditional move -class CMoveNode : public TypeNode { -public: - enum { Control, // When is it safe to do this cmove? - Condition, // Condition controlling the cmove - IfFalse, // Value if condition is false - IfTrue }; // Value if condition is true - CMoveNode( Node *bol, Node *left, Node *right, const Type *t ) : TypeNode(t,4) - { - init_class_id(Class_CMove); - // all inputs are nullified in Node::Node(int) - // init_req(Control,NULL); - init_req(Condition,bol); - init_req(IfFalse,left); - init_req(IfTrue,right); - } - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Identity( PhaseTransform *phase ); - static CMoveNode *make( Compile *C, Node *c, Node *bol, Node *left, Node *right, const Type *t ); - // Helper function to spot cmove graph shapes - static Node *is_cmove_id( PhaseTransform *phase, Node *cmp, Node *t, Node *f, BoolNode *b ); -}; - -//------------------------------CMoveDNode------------------------------------- -class CMoveDNode : public CMoveNode { -public: - CMoveDNode( Node *bol, Node *left, Node *right, const Type* t) : CMoveNode(bol,left,right,t){} - virtual int Opcode() const; - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); -}; - -//------------------------------CMoveFNode------------------------------------- -class CMoveFNode : public CMoveNode { -public: - CMoveFNode( Node *bol, Node *left, Node *right, const Type* t ) : CMoveNode(bol,left,right,t) {} - virtual int Opcode() const; - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); -}; - -//------------------------------CMoveINode------------------------------------- -class CMoveINode : public CMoveNode { -public: - CMoveINode( Node *bol, Node *left, Node *right, const TypeInt *ti ) : CMoveNode(bol,left,right,ti){} - virtual int Opcode() const; - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); -}; - -//------------------------------CMoveLNode------------------------------------- -class CMoveLNode : public CMoveNode { -public: - CMoveLNode(Node *bol, Node *left, Node *right, const TypeLong *tl ) : CMoveNode(bol,left,right,tl){} - virtual int Opcode() const; -}; - -//------------------------------CMovePNode------------------------------------- -class CMovePNode : public CMoveNode { -public: - CMovePNode( Node *c, Node *bol, Node *left, Node *right, const TypePtr* t ) : CMoveNode(bol,left,right,t) { init_req(Control,c); } - virtual int Opcode() const; -}; - -//------------------------------CMoveNNode------------------------------------- -class CMoveNNode : public CMoveNode { -public: - CMoveNNode( Node *c, Node *bol, Node *left, Node *right, const Type* t ) : CMoveNode(bol,left,right,t) { init_req(Control,c); } - virtual int Opcode() const; -}; - -//------------------------------ConstraintCastNode----------------------------- -// cast to a different range -class ConstraintCastNode: public TypeNode { -public: - ConstraintCastNode (Node *n, const Type *t ): TypeNode(t,2) { - init_class_id(Class_ConstraintCast); - init_req(1, n); - } - virtual Node *Identity( PhaseTransform *phase ); - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual int Opcode() const; - virtual uint ideal_reg() const = 0; - virtual Node *Ideal_DU_postCCP( PhaseCCP * ); -}; - -//------------------------------CastIINode------------------------------------- -// cast integer to integer (different range) -class CastIINode: public ConstraintCastNode { -public: - CastIINode (Node *n, const Type *t ): ConstraintCastNode(n,t) {} - virtual int Opcode() const; - virtual uint ideal_reg() const { return Op_RegI; } -}; - -//------------------------------CastPPNode------------------------------------- -// cast pointer to pointer (different type) -class CastPPNode: public ConstraintCastNode { -public: - CastPPNode (Node *n, const Type *t ): ConstraintCastNode(n, t) {} - virtual int Opcode() const; - virtual uint ideal_reg() const { return Op_RegP; } - virtual Node *Ideal_DU_postCCP( PhaseCCP * ); -}; - -//------------------------------CheckCastPPNode-------------------------------- -// for _checkcast, cast pointer to pointer (different type), without JOIN, -class CheckCastPPNode: public TypeNode { -public: - CheckCastPPNode( Node *c, Node *n, const Type *t ) : TypeNode(t,2) { - init_class_id(Class_CheckCastPP); - init_req(0, c); - init_req(1, n); - } - - virtual Node *Identity( PhaseTransform *phase ); - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual int Opcode() const; - virtual uint ideal_reg() const { return Op_RegP; } - // No longer remove CheckCast after CCP as it gives me a place to hang - // the proper address type - which is required to compute anti-deps. - //virtual Node *Ideal_DU_postCCP( PhaseCCP * ); -}; - - -//------------------------------EncodeNarrowPtr-------------------------------- -class EncodeNarrowPtrNode : public TypeNode { - protected: - EncodeNarrowPtrNode(Node* value, const Type* type): - TypeNode(type, 2) { - init_class_id(Class_EncodeNarrowPtr); - init_req(0, NULL); - init_req(1, value); - } - public: - virtual uint ideal_reg() const { return Op_RegN; } - virtual Node *Ideal_DU_postCCP( PhaseCCP *ccp ); -}; - -//------------------------------EncodeP-------------------------------- -// Encodes an oop pointers into its compressed form -// Takes an extra argument which is the real heap base as a long which -// may be useful for code generation in the backend. -class EncodePNode : public EncodeNarrowPtrNode { - public: - EncodePNode(Node* value, const Type* type): - EncodeNarrowPtrNode(value, type) { - init_class_id(Class_EncodeP); - } - virtual int Opcode() const; - virtual Node *Identity( PhaseTransform *phase ); - virtual const Type *Value( PhaseTransform *phase ) const; -}; - -//------------------------------EncodePKlass-------------------------------- -// Encodes a klass pointer into its compressed form -// Takes an extra argument which is the real heap base as a long which -// may be useful for code generation in the backend. -class EncodePKlassNode : public EncodeNarrowPtrNode { - public: - EncodePKlassNode(Node* value, const Type* type): - EncodeNarrowPtrNode(value, type) { - init_class_id(Class_EncodePKlass); - } - virtual int Opcode() const; - virtual Node *Identity( PhaseTransform *phase ); - virtual const Type *Value( PhaseTransform *phase ) const; -}; - -//------------------------------DecodeNarrowPtr-------------------------------- -class DecodeNarrowPtrNode : public TypeNode { - protected: - DecodeNarrowPtrNode(Node* value, const Type* type): - TypeNode(type, 2) { - init_class_id(Class_DecodeNarrowPtr); - init_req(0, NULL); - init_req(1, value); - } - public: - virtual uint ideal_reg() const { return Op_RegP; } -}; - -//------------------------------DecodeN-------------------------------- -// Converts a narrow oop into a real oop ptr. -// Takes an extra argument which is the real heap base as a long which -// may be useful for code generation in the backend. -class DecodeNNode : public DecodeNarrowPtrNode { - public: - DecodeNNode(Node* value, const Type* type): - DecodeNarrowPtrNode(value, type) { - init_class_id(Class_DecodeN); - } - virtual int Opcode() const; - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Identity( PhaseTransform *phase ); -}; - -//------------------------------DecodeNKlass-------------------------------- -// Converts a narrow klass pointer into a real klass ptr. -// Takes an extra argument which is the real heap base as a long which -// may be useful for code generation in the backend. -class DecodeNKlassNode : public DecodeNarrowPtrNode { - public: - DecodeNKlassNode(Node* value, const Type* type): - DecodeNarrowPtrNode(value, type) { - init_class_id(Class_DecodeNKlass); - } - virtual int Opcode() const; - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Identity( PhaseTransform *phase ); -}; - -//------------------------------Conv2BNode------------------------------------- -// Convert int/pointer to a Boolean. Map zero to zero, all else to 1. -class Conv2BNode : public Node { -public: - Conv2BNode( Node *i ) : Node(0,i) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeInt::BOOL; } - virtual Node *Identity( PhaseTransform *phase ); - virtual const Type *Value( PhaseTransform *phase ) const; - virtual uint ideal_reg() const { return Op_RegI; } -}; - -// The conversions operations are all Alpha sorted. Please keep it that way! -//------------------------------ConvD2FNode------------------------------------ -// Convert double to float -class ConvD2FNode : public Node { -public: - ConvD2FNode( Node *in1 ) : Node(0,in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return Type::FLOAT; } - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Identity( PhaseTransform *phase ); - virtual uint ideal_reg() const { return Op_RegF; } -}; - -//------------------------------ConvD2INode------------------------------------ -// Convert Double to Integer -class ConvD2INode : public Node { -public: - ConvD2INode( Node *in1 ) : Node(0,in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeInt::INT; } - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Identity( PhaseTransform *phase ); - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual uint ideal_reg() const { return Op_RegI; } -}; - -//------------------------------ConvD2LNode------------------------------------ -// Convert Double to Long -class ConvD2LNode : public Node { -public: - ConvD2LNode( Node *dbl ) : Node(0,dbl) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeLong::LONG; } - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Identity( PhaseTransform *phase ); - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual uint ideal_reg() const { return Op_RegL; } -}; - -//------------------------------ConvF2DNode------------------------------------ -// Convert Float to a Double. -class ConvF2DNode : public Node { -public: - ConvF2DNode( Node *in1 ) : Node(0,in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return Type::DOUBLE; } - virtual const Type *Value( PhaseTransform *phase ) const; - virtual uint ideal_reg() const { return Op_RegD; } -}; - -//------------------------------ConvF2INode------------------------------------ -// Convert float to integer -class ConvF2INode : public Node { -public: - ConvF2INode( Node *in1 ) : Node(0,in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeInt::INT; } - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Identity( PhaseTransform *phase ); - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual uint ideal_reg() const { return Op_RegI; } -}; - -//------------------------------ConvF2LNode------------------------------------ -// Convert float to long -class ConvF2LNode : public Node { -public: - ConvF2LNode( Node *in1 ) : Node(0,in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeLong::LONG; } - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Identity( PhaseTransform *phase ); - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual uint ideal_reg() const { return Op_RegL; } -}; - -//------------------------------ConvI2DNode------------------------------------ -// Convert Integer to Double -class ConvI2DNode : public Node { -public: - ConvI2DNode( Node *in1 ) : Node(0,in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return Type::DOUBLE; } - virtual const Type *Value( PhaseTransform *phase ) const; - virtual uint ideal_reg() const { return Op_RegD; } -}; - -//------------------------------ConvI2FNode------------------------------------ -// Convert Integer to Float -class ConvI2FNode : public Node { -public: - ConvI2FNode( Node *in1 ) : Node(0,in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return Type::FLOAT; } - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Identity( PhaseTransform *phase ); - virtual uint ideal_reg() const { return Op_RegF; } -}; - -//------------------------------ConvI2LNode------------------------------------ -// Convert integer to long -class ConvI2LNode : public TypeNode { -public: - ConvI2LNode(Node *in1, const TypeLong* t = TypeLong::INT) - : TypeNode(t, 2) - { init_req(1, in1); } - virtual int Opcode() const; - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual uint ideal_reg() const { return Op_RegL; } -}; - -//------------------------------ConvL2DNode------------------------------------ -// Convert Long to Double -class ConvL2DNode : public Node { -public: - ConvL2DNode( Node *in1 ) : Node(0,in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return Type::DOUBLE; } - virtual const Type *Value( PhaseTransform *phase ) const; - virtual uint ideal_reg() const { return Op_RegD; } -}; - -//------------------------------ConvL2FNode------------------------------------ -// Convert Long to Float -class ConvL2FNode : public Node { -public: - ConvL2FNode( Node *in1 ) : Node(0,in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return Type::FLOAT; } - virtual const Type *Value( PhaseTransform *phase ) const; - virtual uint ideal_reg() const { return Op_RegF; } -}; - -//------------------------------ConvL2INode------------------------------------ -// Convert long to integer -class ConvL2INode : public Node { -public: - ConvL2INode( Node *in1 ) : Node(0,in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeInt::INT; } - virtual Node *Identity( PhaseTransform *phase ); - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual uint ideal_reg() const { return Op_RegI; } -}; - -//------------------------------CastX2PNode------------------------------------- -// convert a machine-pointer-sized integer to a raw pointer -class CastX2PNode : public Node { -public: - CastX2PNode( Node *n ) : Node(NULL, n) {} - virtual int Opcode() const; - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual Node *Identity( PhaseTransform *phase ); - virtual uint ideal_reg() const { return Op_RegP; } - virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } -}; - -//------------------------------CastP2XNode------------------------------------- -// Used in both 32-bit and 64-bit land. -// Used for card-marks and unsafe pointer math. -class CastP2XNode : public Node { -public: - CastP2XNode( Node *ctrl, Node *n ) : Node(ctrl, n) {} - virtual int Opcode() const; - virtual const Type *Value( PhaseTransform *phase ) const; - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual Node *Identity( PhaseTransform *phase ); - virtual uint ideal_reg() const { return Op_RegX; } - virtual const Type *bottom_type() const { return TypeX_X; } - // Return false to keep node from moving away from an associated card mark. - virtual bool depends_only_on_test() const { return false; } -}; - //------------------------------ThreadLocalNode-------------------------------- // Ideal Node which returns the base of ThreadLocalStorage. class ThreadLocalNode : public Node { public: - ThreadLocalNode( ) : Node((Node*)Compile::current()->root()) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM;} - virtual uint ideal_reg() const { return Op_RegP; } -}; - -//------------------------------LoadReturnPCNode------------------------------- -class LoadReturnPCNode: public Node { -public: - LoadReturnPCNode(Node *c) : Node(c) { } - virtual int Opcode() const; - virtual uint ideal_reg() const { return Op_RegP; } + ThreadLocalNode( ) : Node((Node*)Compile::current()->root()) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM;} + virtual uint ideal_reg() const { return Op_RegP; } }; -//-----------------------------RoundFloatNode---------------------------------- -class RoundFloatNode: public Node { -public: - RoundFloatNode(Node* c, Node *in1): Node(c, in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return Type::FLOAT; } - virtual uint ideal_reg() const { return Op_RegF; } - virtual Node *Identity( PhaseTransform *phase ); - virtual const Type *Value( PhaseTransform *phase ) const; -}; - - -//-----------------------------RoundDoubleNode--------------------------------- -class RoundDoubleNode: public Node { -public: - RoundDoubleNode(Node* c, Node *in1): Node(c, in1) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return Type::DOUBLE; } - virtual uint ideal_reg() const { return Op_RegD; } - virtual Node *Identity( PhaseTransform *phase ); - virtual const Type *Value( PhaseTransform *phase ) const; -}; - -//------------------------------Opaque1Node------------------------------------ -// A node to prevent unwanted optimizations. Allows constant folding. -// Stops value-numbering, Ideal calls or Identity functions. -class Opaque1Node : public Node { - virtual uint hash() const ; // { return NO_HASH; } - virtual uint cmp( const Node &n ) const; -public: - Opaque1Node( Compile* C, Node *n ) : Node(0,n) { - // Put it on the Macro nodes list to removed during macro nodes expansion. - init_flags(Flag_is_macro); - C->add_macro_node(this); - } - // Special version for the pre-loop to hold the original loop limit - // which is consumed by range check elimination. - Opaque1Node( Compile* C, Node *n, Node* orig_limit ) : Node(0,n,orig_limit) { - // Put it on the Macro nodes list to removed during macro nodes expansion. - init_flags(Flag_is_macro); - C->add_macro_node(this); - } - Node* original_loop_limit() { return req()==3 ? in(2) : NULL; } - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeInt::INT; } - virtual Node *Identity( PhaseTransform *phase ); -}; - -//------------------------------Opaque2Node------------------------------------ -// A node to prevent unwanted optimizations. Allows constant folding. Stops -// value-numbering, most Ideal calls or Identity functions. This Node is -// specifically designed to prevent the pre-increment value of a loop trip -// counter from being live out of the bottom of the loop (hence causing the -// pre- and post-increment values both being live and thus requiring an extra -// temp register and an extra move). If we "accidentally" optimize through -// this kind of a Node, we'll get slightly pessimal, but correct, code. Thus -// it's OK to be slightly sloppy on optimizations here. -class Opaque2Node : public Node { - virtual uint hash() const ; // { return NO_HASH; } - virtual uint cmp( const Node &n ) const; -public: - Opaque2Node( Compile* C, Node *n ) : Node(0,n) { - // Put it on the Macro nodes list to removed during macro nodes expansion. - init_flags(Flag_is_macro); - C->add_macro_node(this); - } - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeInt::INT; } -}; - -//----------------------PartialSubtypeCheckNode-------------------------------- -// The 2nd slow-half of a subtype check. Scan the subklass's 2ndary superklass -// array for an instance of the superklass. Set a hidden internal cache on a -// hit (cache is checked with exposed code in gen_subtype_check()). Return -// not zero for a miss or zero for a hit. -class PartialSubtypeCheckNode : public Node { -public: - PartialSubtypeCheckNode(Node* c, Node* sub, Node* super) : Node(c,sub,super) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } - virtual uint ideal_reg() const { return Op_RegP; } -}; - -// -class MoveI2FNode : public Node { - public: - MoveI2FNode( Node *value ) : Node(0,value) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return Type::FLOAT; } - virtual uint ideal_reg() const { return Op_RegF; } - virtual const Type* Value( PhaseTransform *phase ) const; -}; - -class MoveL2DNode : public Node { - public: - MoveL2DNode( Node *value ) : Node(0,value) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return Type::DOUBLE; } - virtual uint ideal_reg() const { return Op_RegD; } - virtual const Type* Value( PhaseTransform *phase ) const; -}; - -class MoveF2INode : public Node { - public: - MoveF2INode( Node *value ) : Node(0,value) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeInt::INT; } - virtual uint ideal_reg() const { return Op_RegI; } - virtual const Type* Value( PhaseTransform *phase ) const; -}; - -class MoveD2LNode : public Node { - public: - MoveD2LNode( Node *value ) : Node(0,value) {} - virtual int Opcode() const; - virtual const Type *bottom_type() const { return TypeLong::LONG; } - virtual uint ideal_reg() const { return Op_RegL; } - virtual const Type* Value( PhaseTransform *phase ) const; -}; - -//---------- CountBitsNode ----------------------------------------------------- -class CountBitsNode : public Node { -public: - CountBitsNode(Node* in1) : Node(0, in1) {} - const Type* bottom_type() const { return TypeInt::INT; } - virtual uint ideal_reg() const { return Op_RegI; } -}; - -//---------- CountLeadingZerosINode -------------------------------------------- -// Count leading zeros (0-bit count starting from MSB) of an integer. -class CountLeadingZerosINode : public CountBitsNode { -public: - CountLeadingZerosINode(Node* in1) : CountBitsNode(in1) {} - virtual int Opcode() const; - virtual const Type* Value(PhaseTransform* phase) const; -}; - -//---------- CountLeadingZerosLNode -------------------------------------------- -// Count leading zeros (0-bit count starting from MSB) of a long. -class CountLeadingZerosLNode : public CountBitsNode { -public: - CountLeadingZerosLNode(Node* in1) : CountBitsNode(in1) {} - virtual int Opcode() const; - virtual const Type* Value(PhaseTransform* phase) const; -}; - -//---------- CountTrailingZerosINode ------------------------------------------- -// Count trailing zeros (0-bit count starting from LSB) of an integer. -class CountTrailingZerosINode : public CountBitsNode { -public: - CountTrailingZerosINode(Node* in1) : CountBitsNode(in1) {} - virtual int Opcode() const; - virtual const Type* Value(PhaseTransform* phase) const; -}; - -//---------- CountTrailingZerosLNode ------------------------------------------- -// Count trailing zeros (0-bit count starting from LSB) of a long. -class CountTrailingZerosLNode : public CountBitsNode { -public: - CountTrailingZerosLNode(Node* in1) : CountBitsNode(in1) {} - virtual int Opcode() const; - virtual const Type* Value(PhaseTransform* phase) const; -}; - -//---------- PopCountINode ----------------------------------------------------- -// Population count (bit count) of an integer. -class PopCountINode : public CountBitsNode { -public: - PopCountINode(Node* in1) : CountBitsNode(in1) {} - virtual int Opcode() const; -}; - -//---------- PopCountLNode ----------------------------------------------------- -// Population count (bit count) of a long. -class PopCountLNode : public CountBitsNode { -public: - PopCountLNode(Node* in1) : CountBitsNode(in1) {} - virtual int Opcode() const; -}; #endif // SHARE_VM_OPTO_CONNODE_HPP --- old/src/share/vm/opto/divnode.cpp 2014-03-18 16:27:11.000000000 -0400 +++ new/src/share/vm/opto/divnode.cpp 2014-03-18 16:27:11.000000000 -0400 @@ -26,8 +26,10 @@ #include "memory/allocation.inline.hpp" #include "opto/addnode.hpp" #include "opto/connode.hpp" +#include "opto/convertnode.hpp" #include "opto/divnode.hpp" #include "opto/machnode.hpp" +#include "opto/movenode.hpp" #include "opto/matcher.hpp" #include "opto/mulnode.hpp" #include "opto/phaseX.hpp" --- old/src/share/vm/opto/doCall.cpp 2014-03-18 16:27:12.000000000 -0400 +++ new/src/share/vm/opto/doCall.cpp 2014-03-18 16:27:12.000000000 -0400 @@ -31,6 +31,7 @@ #include "interpreter/linkResolver.hpp" #include "opto/addnode.hpp" #include "opto/callGenerator.hpp" +#include "opto/castnode.hpp" #include "opto/cfgnode.hpp" #include "opto/mulnode.hpp" #include "opto/parse.hpp" --- old/src/share/vm/opto/escape.cpp 2014-03-18 16:27:13.000000000 -0400 +++ new/src/share/vm/opto/escape.cpp 2014-03-18 16:27:13.000000000 -0400 @@ -33,6 +33,7 @@ #include "opto/compile.hpp" #include "opto/escape.hpp" #include "opto/phaseX.hpp" +#include "opto/movenode.hpp" #include "opto/rootnode.hpp" ConnectionGraph::ConnectionGraph(Compile * C, PhaseIterGVN *igvn) : --- old/src/share/vm/opto/generateOptoStub.cpp 2014-03-18 16:27:14.000000000 -0400 +++ new/src/share/vm/opto/generateOptoStub.cpp 2014-03-18 16:27:14.000000000 -0400 @@ -27,7 +27,7 @@ #include "opto/callnode.hpp" #include "opto/cfgnode.hpp" #include "opto/compile.hpp" -#include "opto/connode.hpp" +#include "opto/convertnode.hpp" #include "opto/locknode.hpp" #include "opto/memnode.hpp" #include "opto/mulnode.hpp" --- old/src/share/vm/opto/graphKit.cpp 2014-03-18 16:27:15.000000000 -0400 +++ new/src/share/vm/opto/graphKit.cpp 2014-03-18 16:27:14.000000000 -0400 @@ -30,13 +30,18 @@ #include "memory/barrierSet.hpp" #include "memory/cardTableModRefBS.hpp" #include "opto/addnode.hpp" +#include "opto/castnode.hpp" +#include "opto/convertnode.hpp" #include "opto/graphKit.hpp" #include "opto/idealKit.hpp" +#include "opto/intrinsicnode.hpp" #include "opto/locknode.hpp" #include "opto/machnode.hpp" +#include "opto/opaquenode.hpp" #include "opto/parse.hpp" #include "opto/rootnode.hpp" #include "opto/runtime.hpp" +#include "opto/threadnode.hpp" #include "runtime/deoptimization.hpp" #include "runtime/sharedRuntime.hpp" --- old/src/share/vm/opto/idealKit.hpp 2014-03-18 16:27:16.000000000 -0400 +++ new/src/share/vm/opto/idealKit.hpp 2014-03-18 16:27:15.000000000 -0400 @@ -27,6 +27,7 @@ #include "opto/addnode.hpp" #include "opto/cfgnode.hpp" +#include "opto/castnode.hpp" #include "opto/connode.hpp" #include "opto/divnode.hpp" #include "opto/graphKit.hpp" --- old/src/share/vm/opto/ifg.cpp 2014-03-18 16:27:16.000000000 -0400 +++ new/src/share/vm/opto/ifg.cpp 2014-03-18 16:27:16.000000000 -0400 @@ -31,7 +31,6 @@ #include "opto/cfgnode.hpp" #include "opto/chaitin.hpp" #include "opto/coalesce.hpp" -#include "opto/connode.hpp" #include "opto/indexSet.hpp" #include "opto/machnode.hpp" #include "opto/memnode.hpp" --- old/src/share/vm/opto/library_call.cpp 2014-03-18 16:27:17.000000000 -0400 +++ new/src/share/vm/opto/library_call.cpp 2014-03-18 16:27:17.000000000 -0400 @@ -30,10 +30,16 @@ #include "oops/objArrayKlass.hpp" #include "opto/addnode.hpp" #include "opto/callGenerator.hpp" +#include "opto/castnode.hpp" #include "opto/cfgnode.hpp" +#include "opto/convertnode.hpp" +#include "opto/countbitsnode.hpp" +#include "opto/intrinsicnode.hpp" #include "opto/idealKit.hpp" #include "opto/mathexactnode.hpp" +#include "opto/movenode.hpp" #include "opto/mulnode.hpp" +#include "opto/narrowptrnode.hpp" #include "opto/parse.hpp" #include "opto/runtime.hpp" #include "opto/subnode.hpp" --- old/src/share/vm/opto/loopPredicate.cpp 2014-03-18 16:27:18.000000000 -0400 +++ new/src/share/vm/opto/loopPredicate.cpp 2014-03-18 16:27:18.000000000 -0400 @@ -27,8 +27,10 @@ #include "opto/addnode.hpp" #include "opto/callnode.hpp" #include "opto/connode.hpp" +#include "opto/convertnode.hpp" #include "opto/loopnode.hpp" #include "opto/mulnode.hpp" +#include "opto/opaquenode.hpp" #include "opto/rootnode.hpp" #include "opto/subnode.hpp" --- old/src/share/vm/opto/loopTransform.cpp 2014-03-18 16:27:19.000000000 -0400 +++ new/src/share/vm/opto/loopTransform.cpp 2014-03-18 16:27:19.000000000 -0400 @@ -28,9 +28,12 @@ #include "opto/addnode.hpp" #include "opto/callnode.hpp" #include "opto/connode.hpp" +#include "opto/convertnode.hpp" #include "opto/divnode.hpp" #include "opto/loopnode.hpp" #include "opto/mulnode.hpp" +#include "opto/movenode.hpp" +#include "opto/opaquenode.hpp" #include "opto/rootnode.hpp" #include "opto/runtime.hpp" #include "opto/subnode.hpp" --- old/src/share/vm/opto/loopUnswitch.cpp 2014-03-18 16:27:20.000000000 -0400 +++ new/src/share/vm/opto/loopUnswitch.cpp 2014-03-18 16:27:19.000000000 -0400 @@ -25,7 +25,9 @@ #include "precompiled.hpp" #include "memory/allocation.inline.hpp" #include "opto/connode.hpp" +#include "opto/convertnode.hpp" #include "opto/loopnode.hpp" +#include "opto/opaquenode.hpp" #include "opto/rootnode.hpp" //================= Loop Unswitching ===================== --- old/src/share/vm/opto/loopnode.cpp 2014-03-18 16:27:20.000000000 -0400 +++ new/src/share/vm/opto/loopnode.cpp 2014-03-18 16:27:20.000000000 -0400 @@ -30,6 +30,7 @@ #include "opto/addnode.hpp" #include "opto/callnode.hpp" #include "opto/connode.hpp" +#include "opto/convertnode.hpp" #include "opto/divnode.hpp" #include "opto/idealGraphPrinter.hpp" #include "opto/loopnode.hpp" --- old/src/share/vm/opto/loopopts.cpp 2014-03-18 16:27:21.000000000 -0400 +++ new/src/share/vm/opto/loopopts.cpp 2014-03-18 16:27:21.000000000 -0400 @@ -30,6 +30,8 @@ #include "opto/loopnode.hpp" #include "opto/matcher.hpp" #include "opto/mulnode.hpp" +#include "opto/movenode.hpp" +#include "opto/opaquenode.hpp" #include "opto/rootnode.hpp" #include "opto/subnode.hpp" --- old/src/share/vm/opto/macro.cpp 2014-03-18 16:27:22.000000000 -0400 +++ new/src/share/vm/opto/macro.cpp 2014-03-18 16:27:22.000000000 -0400 @@ -27,13 +27,15 @@ #include "libadt/vectset.hpp" #include "opto/addnode.hpp" #include "opto/callnode.hpp" +#include "opto/castnode.hpp" #include "opto/cfgnode.hpp" #include "opto/compile.hpp" -#include "opto/connode.hpp" +#include "opto/convertnode.hpp" #include "opto/locknode.hpp" #include "opto/loopnode.hpp" #include "opto/macro.hpp" #include "opto/memnode.hpp" +#include "opto/narrowptrnode.hpp" #include "opto/node.hpp" #include "opto/phaseX.hpp" #include "opto/rootnode.hpp" --- old/src/share/vm/opto/matcher.cpp 2014-03-18 16:27:23.000000000 -0400 +++ new/src/share/vm/opto/matcher.cpp 2014-03-18 16:27:23.000000000 -0400 @@ -26,10 +26,10 @@ #include "memory/allocation.inline.hpp" #include "opto/addnode.hpp" #include "opto/callnode.hpp" -#include "opto/connode.hpp" #include "opto/idealGraphPrinter.hpp" #include "opto/matcher.hpp" #include "opto/memnode.hpp" +#include "opto/movenode.hpp" #include "opto/opcodes.hpp" #include "opto/regmask.hpp" #include "opto/rootnode.hpp" --- old/src/share/vm/opto/memnode.cpp 2014-03-18 16:27:24.000000000 -0400 +++ new/src/share/vm/opto/memnode.cpp 2014-03-18 16:27:23.000000000 -0400 @@ -31,11 +31,13 @@ #include "opto/cfgnode.hpp" #include "opto/compile.hpp" #include "opto/connode.hpp" +#include "opto/convertnode.hpp" #include "opto/loopnode.hpp" #include "opto/machnode.hpp" #include "opto/matcher.hpp" #include "opto/memnode.hpp" #include "opto/mulnode.hpp" +#include "opto/narrowptrnode.hpp" #include "opto/phaseX.hpp" #include "opto/regmask.hpp" @@ -2904,59 +2906,6 @@ } //============================================================================= -// Do not match memory edge. -uint StrIntrinsicNode::match_edge(uint idx) const { - return idx == 2 || idx == 3; -} - -//------------------------------Ideal------------------------------------------ -// Return a node which is more "ideal" than the current node. Strip out -// control copies -Node *StrIntrinsicNode::Ideal(PhaseGVN *phase, bool can_reshape) { - if (remove_dead_region(phase, can_reshape)) return this; - // Don't bother trying to transform a dead node - if (in(0) && in(0)->is_top()) return NULL; - - if (can_reshape) { - Node* mem = phase->transform(in(MemNode::Memory)); - // If transformed to a MergeMem, get the desired slice - uint alias_idx = phase->C->get_alias_index(adr_type()); - mem = mem->is_MergeMem() ? mem->as_MergeMem()->memory_at(alias_idx) : mem; - if (mem != in(MemNode::Memory)) { - set_req(MemNode::Memory, mem); - return this; - } - } - return NULL; -} - -//------------------------------Value------------------------------------------ -const Type *StrIntrinsicNode::Value( PhaseTransform *phase ) const { - if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP; - return bottom_type(); -} - -//============================================================================= -//------------------------------match_edge------------------------------------- -// Do not match memory edge -uint EncodeISOArrayNode::match_edge(uint idx) const { - return idx == 2 || idx == 3; // EncodeISOArray src (Binary dst len) -} - -//------------------------------Ideal------------------------------------------ -// Return a node which is more "ideal" than the current node. Strip out -// control copies -Node *EncodeISOArrayNode::Ideal(PhaseGVN *phase, bool can_reshape) { - return remove_dead_region(phase, can_reshape) ? this : NULL; -} - -//------------------------------Value------------------------------------------ -const Type *EncodeISOArrayNode::Value(PhaseTransform *phase) const { - if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP; - return bottom_type(); -} - -//============================================================================= MemBarNode::MemBarNode(Compile* C, int alias_idx, Node* precedent) : MultiNode(TypeFunc::Parms + (precedent == NULL? 0: 1)), _adr_type(C->get_adr_type(alias_idx)) --- old/src/share/vm/opto/memnode.hpp 2014-03-18 16:27:25.000000000 -0400 +++ new/src/share/vm/opto/memnode.hpp 2014-03-18 16:27:24.000000000 -0400 @@ -866,88 +866,6 @@ static bool step_through(Node** np, uint instance_id, PhaseTransform* phase); }; -//------------------------------StrIntrinsic------------------------------- -// Base class for Ideal nodes used in String instrinsic code. -class StrIntrinsicNode: public Node { -public: - StrIntrinsicNode(Node* control, Node* char_array_mem, - Node* s1, Node* c1, Node* s2, Node* c2): - Node(control, char_array_mem, s1, c1, s2, c2) { - } - - StrIntrinsicNode(Node* control, Node* char_array_mem, - Node* s1, Node* s2, Node* c): - Node(control, char_array_mem, s1, s2, c) { - } - - StrIntrinsicNode(Node* control, Node* char_array_mem, - Node* s1, Node* s2): - Node(control, char_array_mem, s1, s2) { - } - - virtual bool depends_only_on_test() const { return false; } - virtual const TypePtr* adr_type() const { return TypeAryPtr::CHARS; } - virtual uint match_edge(uint idx) const; - virtual uint ideal_reg() const { return Op_RegI; } - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual const Type *Value(PhaseTransform *phase) const; -}; - -//------------------------------StrComp------------------------------------- -class StrCompNode: public StrIntrinsicNode { -public: - StrCompNode(Node* control, Node* char_array_mem, - Node* s1, Node* c1, Node* s2, Node* c2): - StrIntrinsicNode(control, char_array_mem, s1, c1, s2, c2) {}; - virtual int Opcode() const; - virtual const Type* bottom_type() const { return TypeInt::INT; } -}; - -//------------------------------StrEquals------------------------------------- -class StrEqualsNode: public StrIntrinsicNode { -public: - StrEqualsNode(Node* control, Node* char_array_mem, - Node* s1, Node* s2, Node* c): - StrIntrinsicNode(control, char_array_mem, s1, s2, c) {}; - virtual int Opcode() const; - virtual const Type* bottom_type() const { return TypeInt::BOOL; } -}; - -//------------------------------StrIndexOf------------------------------------- -class StrIndexOfNode: public StrIntrinsicNode { -public: - StrIndexOfNode(Node* control, Node* char_array_mem, - Node* s1, Node* c1, Node* s2, Node* c2): - StrIntrinsicNode(control, char_array_mem, s1, c1, s2, c2) {}; - virtual int Opcode() const; - virtual const Type* bottom_type() const { return TypeInt::INT; } -}; - -//------------------------------AryEq--------------------------------------- -class AryEqNode: public StrIntrinsicNode { -public: - AryEqNode(Node* control, Node* char_array_mem, Node* s1, Node* s2): - StrIntrinsicNode(control, char_array_mem, s1, s2) {}; - virtual int Opcode() const; - virtual const Type* bottom_type() const { return TypeInt::BOOL; } -}; - - -//------------------------------EncodeISOArray-------------------------------- -// encode char[] to byte[] in ISO_8859_1 -class EncodeISOArrayNode: public Node { -public: - EncodeISOArrayNode(Node *control, Node* arymem, Node* s1, Node* s2, Node* c): Node(control, arymem, s1, s2, c) {}; - virtual int Opcode() const; - virtual bool depends_only_on_test() const { return false; } - virtual const Type* bottom_type() const { return TypeInt::INT; } - virtual const TypePtr* adr_type() const { return TypePtr::BOTTOM; } - virtual uint match_edge(uint idx) const; - virtual uint ideal_reg() const { return Op_RegI; } - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual const Type *Value(PhaseTransform *phase) const; -}; - //------------------------------MemBar----------------------------------------- // There are different flavors of Memory Barriers to match the Java Memory // Model. Monitor-enter and volatile-load act as Aquires: no following ref --- old/src/share/vm/opto/mulnode.cpp 2014-03-18 16:27:25.000000000 -0400 +++ new/src/share/vm/opto/mulnode.cpp 2014-03-18 16:27:25.000000000 -0400 @@ -26,6 +26,7 @@ #include "memory/allocation.inline.hpp" #include "opto/addnode.hpp" #include "opto/connode.hpp" +#include "opto/convertnode.hpp" #include "opto/memnode.hpp" #include "opto/mulnode.hpp" #include "opto/phaseX.hpp" --- old/src/share/vm/opto/parse1.cpp 2014-03-18 16:27:26.000000000 -0400 +++ new/src/share/vm/opto/parse1.cpp 2014-03-18 16:27:26.000000000 -0400 @@ -27,6 +27,7 @@ #include "interpreter/linkResolver.hpp" #include "oops/method.hpp" #include "opto/addnode.hpp" +#include "opto/castnode.hpp" #include "opto/idealGraphPrinter.hpp" #include "opto/locknode.hpp" #include "opto/memnode.hpp" --- old/src/share/vm/opto/parse2.cpp 2014-03-18 16:27:27.000000000 -0400 +++ new/src/share/vm/opto/parse2.cpp 2014-03-18 16:27:27.000000000 -0400 @@ -30,6 +30,8 @@ #include "interpreter/linkResolver.hpp" #include "memory/universe.inline.hpp" #include "opto/addnode.hpp" +#include "opto/castnode.hpp" +#include "opto/convertnode.hpp" #include "opto/divnode.hpp" #include "opto/idealGraphPrinter.hpp" #include "opto/matcher.hpp" --- old/src/share/vm/opto/parse3.cpp 2014-03-18 16:27:28.000000000 -0400 +++ new/src/share/vm/opto/parse3.cpp 2014-03-18 16:27:28.000000000 -0400 @@ -28,6 +28,7 @@ #include "memory/universe.inline.hpp" #include "oops/objArrayKlass.hpp" #include "opto/addnode.hpp" +#include "opto/castnode.hpp" #include "opto/memnode.hpp" #include "opto/parse.hpp" #include "opto/rootnode.hpp" --- old/src/share/vm/opto/phaseX.cpp 2014-03-18 16:27:28.000000000 -0400 +++ new/src/share/vm/opto/phaseX.cpp 2014-03-18 16:27:28.000000000 -0400 @@ -27,7 +27,6 @@ #include "opto/block.hpp" #include "opto/callnode.hpp" #include "opto/cfgnode.hpp" -#include "opto/connode.hpp" #include "opto/idealGraphPrinter.hpp" #include "opto/loopnode.hpp" #include "opto/machnode.hpp" --- old/src/share/vm/opto/runtime.cpp 2014-03-18 16:27:29.000000000 -0400 +++ new/src/share/vm/opto/runtime.cpp 2014-03-18 16:27:29.000000000 -0400 @@ -48,7 +48,6 @@ #include "opto/addnode.hpp" #include "opto/callnode.hpp" #include "opto/cfgnode.hpp" -#include "opto/connode.hpp" #include "opto/graphKit.hpp" #include "opto/machnode.hpp" #include "opto/matcher.hpp" --- old/src/share/vm/opto/split_if.cpp 2014-03-18 16:27:30.000000000 -0400 +++ new/src/share/vm/opto/split_if.cpp 2014-03-18 16:27:30.000000000 -0400 @@ -25,8 +25,8 @@ #include "precompiled.hpp" #include "memory/allocation.inline.hpp" #include "opto/callnode.hpp" -#include "opto/connode.hpp" #include "opto/loopnode.hpp" +#include "opto/movenode.hpp" //------------------------------split_thru_region------------------------------ --- old/src/share/vm/opto/subnode.cpp 2014-03-18 16:27:31.000000000 -0400 +++ new/src/share/vm/opto/subnode.cpp 2014-03-18 16:27:30.000000000 -0400 @@ -28,9 +28,9 @@ #include "opto/addnode.hpp" #include "opto/callnode.hpp" #include "opto/cfgnode.hpp" -#include "opto/connode.hpp" #include "opto/loopnode.hpp" #include "opto/matcher.hpp" +#include "opto/movenode.hpp" #include "opto/mulnode.hpp" #include "opto/opcodes.hpp" #include "opto/phaseX.hpp" --- old/src/share/vm/opto/superword.cpp 2014-03-18 16:27:31.000000000 -0400 +++ new/src/share/vm/opto/superword.cpp 2014-03-18 16:27:31.000000000 -0400 @@ -27,11 +27,14 @@ #include "memory/allocation.inline.hpp" #include "opto/addnode.hpp" #include "opto/callnode.hpp" +#include "opto/castnode.hpp" +#include "opto/convertnode.hpp" #include "opto/divnode.hpp" #include "opto/matcher.hpp" #include "opto/memnode.hpp" #include "opto/mulnode.hpp" #include "opto/opcodes.hpp" +#include "opto/opaquenode.hpp" #include "opto/superword.hpp" #include "opto/vectornode.hpp" --- old/src/share/vm/opto/superword.hpp 2014-03-18 16:27:32.000000000 -0400 +++ new/src/share/vm/opto/superword.hpp 2014-03-18 16:27:32.000000000 -0400 @@ -24,7 +24,6 @@ #ifndef SHARE_VM_OPTO_SUPERWORD_HPP #define SHARE_VM_OPTO_SUPERWORD_HPP -#include "opto/connode.hpp" #include "opto/loopnode.hpp" #include "opto/node.hpp" #include "opto/phaseX.hpp" --- old/src/share/vm/precompiled/precompiled.hpp 2014-03-18 16:27:33.000000000 -0400 +++ new/src/share/vm/precompiled/precompiled.hpp 2014-03-18 16:27:33.000000000 -0400 @@ -254,18 +254,24 @@ # include "opto/block.hpp" # include "opto/c2_globals.hpp" # include "opto/callnode.hpp" +# include "opto/castnode.hpp" # include "opto/cfgnode.hpp" # include "opto/compile.hpp" # include "opto/connode.hpp" +# include "opto/convertnode.hpp" +# include "opto/countbitsnode.hpp" # include "opto/idealGraphPrinter.hpp" +# include "opto/intrinsicnode.hpp" # include "opto/loopnode.hpp" # include "opto/machnode.hpp" # include "opto/matcher.hpp" # include "opto/memnode.hpp" +# include "opto/movenode.hpp" # include "opto/mulnode.hpp" # include "opto/multnode.hpp" -# include "opto/node.hpp" +# include "opto/narrowptrnode.hpp" # include "opto/opcodes.hpp" +# include "opto/opaquenode.hpp" # include "opto/optoreg.hpp" # include "opto/phase.hpp" # include "opto/phaseX.hpp" --- old/src/share/vm/runtime/vmStructs.cpp 2014-03-18 16:27:33.000000000 -0400 +++ new/src/share/vm/runtime/vmStructs.cpp 2014-03-18 16:27:33.000000000 -0400 @@ -171,20 +171,27 @@ #include "opto/addnode.hpp" #include "opto/block.hpp" #include "opto/callnode.hpp" +#include "opto/castnode.hpp" #include "opto/cfgnode.hpp" #include "opto/chaitin.hpp" +#include "opto/convertnode.hpp" #include "opto/divnode.hpp" +#include "opto/intrinsicnode.hpp" #include "opto/locknode.hpp" #include "opto/loopnode.hpp" #include "opto/machnode.hpp" #include "opto/matcher.hpp" #include "opto/mathexactnode.hpp" #include "opto/mulnode.hpp" +#include "opto/movenode.hpp" +#include "opto/narrowptrnode.hpp" +#include "opto/opaquenode.hpp" #include "opto/phaseX.hpp" #include "opto/parse.hpp" #include "opto/regalloc.hpp" #include "opto/rootnode.hpp" #include "opto/subnode.hpp" +#include "opto/threadnode.hpp" #include "opto/vectornode.hpp" #ifdef TARGET_ARCH_MODEL_x86_32 # include "adfiles/adGlobals_x86_32.hpp" --- /dev/null 2014-03-18 16:27:34.000000000 -0400 +++ new/src/share/vm/opto/castnode.cpp 2014-03-18 16:27:34.000000000 -0400 @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "opto/addnode.hpp" +#include "opto/castnode.hpp" +#include "opto/connode.hpp" +#include "opto/matcher.hpp" +#include "opto/phaseX.hpp" +#include "opto/subnode.hpp" +#include "opto/type.hpp" + +//============================================================================= +// If input is already higher or equal to cast type, then this is an identity. +Node *ConstraintCastNode::Identity( PhaseTransform *phase ) { + return phase->type(in(1))->higher_equal_speculative(_type) ? in(1) : this; +} + +//------------------------------Value------------------------------------------ +// Take 'join' of input and cast-up type +const Type *ConstraintCastNode::Value( PhaseTransform *phase ) const { + if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP; + const Type* ft = phase->type(in(1))->filter_speculative(_type); + +#ifdef ASSERT + // Previous versions of this function had some special case logic, + // which is no longer necessary. Make sure of the required effects. + switch (Opcode()) { + case Op_CastII: + { + const Type* t1 = phase->type(in(1)); + if( t1 == Type::TOP ) assert(ft == Type::TOP, "special case #1"); + const Type* rt = t1->join_speculative(_type); + if (rt->empty()) assert(ft == Type::TOP, "special case #2"); + break; + } + case Op_CastPP: + if (phase->type(in(1)) == TypePtr::NULL_PTR && + _type->isa_ptr() && _type->is_ptr()->_ptr == TypePtr::NotNull) + assert(ft == Type::TOP, "special case #3"); + break; + } +#endif //ASSERT + + return ft; +} + +//------------------------------Ideal------------------------------------------ +// Return a node which is more "ideal" than the current node. Strip out +// control copies +Node *ConstraintCastNode::Ideal(PhaseGVN *phase, bool can_reshape){ + return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; +} + +//------------------------------Ideal_DU_postCCP------------------------------- +// Throw away cast after constant propagation +Node *ConstraintCastNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { + const Type *t = ccp->type(in(1)); + ccp->hash_delete(this); + set_type(t); // Turn into ID function + ccp->hash_insert(this); + return this; +} + + +//============================================================================= + +//------------------------------Ideal_DU_postCCP------------------------------- +// If not converting int->oop, throw away cast after constant propagation +Node *CastPPNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { + const Type *t = ccp->type(in(1)); + if (!t->isa_oop_ptr() || ((in(1)->is_DecodeN()) && Matcher::gen_narrow_oop_implicit_null_checks())) { + return NULL; // do not transform raw pointers or narrow oops + } + return ConstraintCastNode::Ideal_DU_postCCP(ccp); +} + + + +//============================================================================= +//------------------------------Identity--------------------------------------- +// If input is already higher or equal to cast type, then this is an identity. +Node *CheckCastPPNode::Identity( PhaseTransform *phase ) { + // Toned down to rescue meeting at a Phi 3 different oops all implementing + // the same interface. CompileTheWorld starting at 502, kd12rc1.zip. + return (phase->type(in(1)) == phase->type(this)) ? in(1) : this; +} + +//------------------------------Value------------------------------------------ +// Take 'join' of input and cast-up type, unless working with an Interface +const Type *CheckCastPPNode::Value( PhaseTransform *phase ) const { + if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP; + + const Type *inn = phase->type(in(1)); + if( inn == Type::TOP ) return Type::TOP; // No information yet + + const TypePtr *in_type = inn->isa_ptr(); + const TypePtr *my_type = _type->isa_ptr(); + const Type *result = _type; + if( in_type != NULL && my_type != NULL ) { + TypePtr::PTR in_ptr = in_type->ptr(); + if( in_ptr == TypePtr::Null ) { + result = in_type; + } else if( in_ptr == TypePtr::Constant ) { + // Casting a constant oop to an interface? + // (i.e., a String to a Comparable?) + // Then return the interface. + const TypeOopPtr *jptr = my_type->isa_oopptr(); + assert( jptr, "" ); + result = (jptr->klass()->is_interface() || !in_type->higher_equal(_type)) + ? my_type->cast_to_ptr_type( TypePtr::NotNull ) + : in_type; + } else { + result = my_type->cast_to_ptr_type( my_type->join_ptr(in_ptr) ); + } + } + return result; + + // JOIN NOT DONE HERE BECAUSE OF INTERFACE ISSUES. + // FIX THIS (DO THE JOIN) WHEN UNION TYPES APPEAR! + + // + // Remove this code after overnight run indicates no performance + // loss from not performing JOIN at CheckCastPPNode + // + // const TypeInstPtr *in_oop = in->isa_instptr(); + // const TypeInstPtr *my_oop = _type->isa_instptr(); + // // If either input is an 'interface', return destination type + // assert (in_oop == NULL || in_oop->klass() != NULL, ""); + // assert (my_oop == NULL || my_oop->klass() != NULL, ""); + // if( (in_oop && in_oop->klass()->is_interface()) + // ||(my_oop && my_oop->klass()->is_interface()) ) { + // TypePtr::PTR in_ptr = in->isa_ptr() ? in->is_ptr()->_ptr : TypePtr::BotPTR; + // // Preserve cast away nullness for interfaces + // if( in_ptr == TypePtr::NotNull && my_oop && my_oop->_ptr == TypePtr::BotPTR ) { + // return my_oop->cast_to_ptr_type(TypePtr::NotNull); + // } + // return _type; + // } + // + // // Neither the input nor the destination type is an interface, + // + // // history: JOIN used to cause weird corner case bugs + // // return (in == TypeOopPtr::NULL_PTR) ? in : _type; + // // JOIN picks up NotNull in common instance-of/check-cast idioms, both oops. + // // JOIN does not preserve NotNull in other cases, e.g. RawPtr vs InstPtr + // const Type *join = in->join(_type); + // // Check if join preserved NotNull'ness for pointers + // if( join->isa_ptr() && _type->isa_ptr() ) { + // TypePtr::PTR join_ptr = join->is_ptr()->_ptr; + // TypePtr::PTR type_ptr = _type->is_ptr()->_ptr; + // // If there isn't any NotNull'ness to preserve + // // OR if join preserved NotNull'ness then return it + // if( type_ptr == TypePtr::BotPTR || type_ptr == TypePtr::Null || + // join_ptr == TypePtr::NotNull || join_ptr == TypePtr::Constant ) { + // return join; + // } + // // ELSE return same old type as before + // return _type; + // } + // // Not joining two pointers + // return join; +} + +//------------------------------Ideal------------------------------------------ +// Return a node which is more "ideal" than the current node. Strip out +// control copies +Node *CheckCastPPNode::Ideal(PhaseGVN *phase, bool can_reshape){ + return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *CastX2PNode::Value( PhaseTransform *phase ) const { + const Type* t = phase->type(in(1)); + if (t == Type::TOP) return Type::TOP; + if (t->base() == Type_X && t->singleton()) { + uintptr_t bits = (uintptr_t) t->is_intptr_t()->get_con(); + if (bits == 0) return TypePtr::NULL_PTR; + return TypeRawPtr::make((address) bits); + } + return CastX2PNode::bottom_type(); +} + +//------------------------------Idealize--------------------------------------- +static inline bool fits_in_int(const Type* t, bool but_not_min_int = false) { + if (t == Type::TOP) return false; + const TypeX* tl = t->is_intptr_t(); + jint lo = min_jint; + jint hi = max_jint; + if (but_not_min_int) ++lo; // caller wants to negate the value w/o overflow + return (tl->_lo >= lo) && (tl->_hi <= hi); +} + +static inline Node* addP_of_X2P(PhaseGVN *phase, + Node* base, + Node* dispX, + bool negate = false) { + if (negate) { + dispX = new (phase->C) SubXNode(phase->MakeConX(0), phase->transform(dispX)); + } + return new (phase->C) AddPNode(phase->C->top(), + phase->transform(new (phase->C) CastX2PNode(base)), + phase->transform(dispX)); +} + +Node *CastX2PNode::Ideal(PhaseGVN *phase, bool can_reshape) { + // convert CastX2P(AddX(x, y)) to AddP(CastX2P(x), y) if y fits in an int + int op = in(1)->Opcode(); + Node* x; + Node* y; + switch (op) { + case Op_SubX: + x = in(1)->in(1); + // Avoid ideal transformations ping-pong between this and AddP for raw pointers. + if (phase->find_intptr_t_con(x, -1) == 0) + break; + y = in(1)->in(2); + if (fits_in_int(phase->type(y), true)) { + return addP_of_X2P(phase, x, y, true); + } + break; + case Op_AddX: + x = in(1)->in(1); + y = in(1)->in(2); + if (fits_in_int(phase->type(y))) { + return addP_of_X2P(phase, x, y); + } + if (fits_in_int(phase->type(x))) { + return addP_of_X2P(phase, y, x); + } + break; + } + return NULL; +} + +//------------------------------Identity--------------------------------------- +Node *CastX2PNode::Identity( PhaseTransform *phase ) { + if (in(1)->Opcode() == Op_CastP2X) return in(1)->in(1); + return this; +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *CastP2XNode::Value( PhaseTransform *phase ) const { + const Type* t = phase->type(in(1)); + if (t == Type::TOP) return Type::TOP; + if (t->base() == Type::RawPtr && t->singleton()) { + uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con(); + return TypeX::make(bits); + } + return CastP2XNode::bottom_type(); +} + +Node *CastP2XNode::Ideal(PhaseGVN *phase, bool can_reshape) { + return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL; +} + +//------------------------------Identity--------------------------------------- +Node *CastP2XNode::Identity( PhaseTransform *phase ) { + if (in(1)->Opcode() == Op_CastX2P) return in(1)->in(1); + return this; +} --- /dev/null 2014-03-18 16:27:35.000000000 -0400 +++ new/src/share/vm/opto/castnode.hpp 2014-03-18 16:27:35.000000000 -0400 @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_OPTO_CASTNODE_HPP +#define SHARE_VM_OPTO_CASTNODE_HPP + +#include "opto/node.hpp" +#include "opto/opcodes.hpp" + + +//------------------------------ConstraintCastNode----------------------------- +// cast to a different range +class ConstraintCastNode: public TypeNode { + public: + ConstraintCastNode (Node *n, const Type *t ): TypeNode(t,2) { + init_class_id(Class_ConstraintCast); + init_req(1, n); + } + virtual Node *Identity( PhaseTransform *phase ); + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual int Opcode() const; + virtual uint ideal_reg() const = 0; + virtual Node *Ideal_DU_postCCP( PhaseCCP * ); +}; + +//------------------------------CastIINode------------------------------------- +// cast integer to integer (different range) +class CastIINode: public ConstraintCastNode { + public: + CastIINode (Node *n, const Type *t ): ConstraintCastNode(n,t) {} + virtual int Opcode() const; + virtual uint ideal_reg() const { return Op_RegI; } +}; + +//------------------------------CastPPNode------------------------------------- +// cast pointer to pointer (different type) +class CastPPNode: public ConstraintCastNode { + public: + CastPPNode (Node *n, const Type *t ): ConstraintCastNode(n, t) {} + virtual int Opcode() const; + virtual uint ideal_reg() const { return Op_RegP; } + virtual Node *Ideal_DU_postCCP( PhaseCCP * ); +}; + +//------------------------------CheckCastPPNode-------------------------------- +// for _checkcast, cast pointer to pointer (different type), without JOIN, +class CheckCastPPNode: public TypeNode { + public: + CheckCastPPNode( Node *c, Node *n, const Type *t ) : TypeNode(t,2) { + init_class_id(Class_CheckCastPP); + init_req(0, c); + init_req(1, n); + } + + virtual Node *Identity( PhaseTransform *phase ); + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual int Opcode() const; + virtual uint ideal_reg() const { return Op_RegP; } + // No longer remove CheckCast after CCP as it gives me a place to hang + // the proper address type - which is required to compute anti-deps. + //virtual Node *Ideal_DU_postCCP( PhaseCCP * ); +}; + + +//------------------------------CastX2PNode------------------------------------- +// convert a machine-pointer-sized integer to a raw pointer +class CastX2PNode : public Node { + public: + CastX2PNode( Node *n ) : Node(NULL, n) {} + virtual int Opcode() const; + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual Node *Identity( PhaseTransform *phase ); + virtual uint ideal_reg() const { return Op_RegP; } + virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } +}; + +//------------------------------CastP2XNode------------------------------------- +// Used in both 32-bit and 64-bit land. +// Used for card-marks and unsafe pointer math. +class CastP2XNode : public Node { + public: + CastP2XNode( Node *ctrl, Node *n ) : Node(ctrl, n) {} + virtual int Opcode() const; + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual Node *Identity( PhaseTransform *phase ); + virtual uint ideal_reg() const { return Op_RegX; } + virtual const Type *bottom_type() const { return TypeX_X; } + // Return false to keep node from moving away from an associated card mark. + virtual bool depends_only_on_test() const { return false; } +}; + + + +#endif // SHARE_VM_OPTO_CASTNODE_HPP --- /dev/null 2014-03-18 16:27:36.000000000 -0400 +++ new/src/share/vm/opto/convertnode.cpp 2014-03-18 16:27:35.000000000 -0400 @@ -0,0 +1,512 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "opto/addnode.hpp" +#include "opto/convertnode.hpp" +#include "opto/matcher.hpp" +#include "opto/phaseX.hpp" +#include "opto/subnode.hpp" + +//============================================================================= +//------------------------------Identity--------------------------------------- +Node *Conv2BNode::Identity( PhaseTransform *phase ) { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return in(1); + if( t == TypeInt::ZERO ) return in(1); + if( t == TypeInt::ONE ) return in(1); + if( t == TypeInt::BOOL ) return in(1); + return this; +} + +//------------------------------Value------------------------------------------ +const Type *Conv2BNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + if( t == TypeInt::ZERO ) return TypeInt::ZERO; + if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO; + const TypePtr *tp = t->isa_ptr(); + if( tp != NULL ) { + if( tp->ptr() == TypePtr::AnyNull ) return Type::TOP; + if( tp->ptr() == TypePtr::Constant) return TypeInt::ONE; + if (tp->ptr() == TypePtr::NotNull) return TypeInt::ONE; + return TypeInt::BOOL; + } + if (t->base() != Type::Int) return TypeInt::BOOL; + const TypeInt *ti = t->is_int(); + if( ti->_hi < 0 || ti->_lo > 0 ) return TypeInt::ONE; + return TypeInt::BOOL; +} + + +// The conversions operations are all Alpha sorted. Please keep it that way! +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *ConvD2FNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + if( t == Type::DOUBLE ) return Type::FLOAT; + const TypeD *td = t->is_double_constant(); + return TypeF::make( (float)td->getd() ); +} + +//------------------------------Identity--------------------------------------- +// Float's can be converted to doubles with no loss of bits. Hence +// converting a float to a double and back to a float is a NOP. +Node *ConvD2FNode::Identity(PhaseTransform *phase) { + return (in(1)->Opcode() == Op_ConvF2D) ? in(1)->in(1) : this; +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *ConvD2INode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + if( t == Type::DOUBLE ) return TypeInt::INT; + const TypeD *td = t->is_double_constant(); + return TypeInt::make( SharedRuntime::d2i( td->getd() ) ); +} + +//------------------------------Ideal------------------------------------------ +// If converting to an int type, skip any rounding nodes +Node *ConvD2INode::Ideal(PhaseGVN *phase, bool can_reshape) { + if( in(1)->Opcode() == Op_RoundDouble ) + set_req(1,in(1)->in(1)); + return NULL; +} + +//------------------------------Identity--------------------------------------- +// Int's can be converted to doubles with no loss of bits. Hence +// converting an integer to a double and back to an integer is a NOP. +Node *ConvD2INode::Identity(PhaseTransform *phase) { + return (in(1)->Opcode() == Op_ConvI2D) ? in(1)->in(1) : this; +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *ConvD2LNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + if( t == Type::DOUBLE ) return TypeLong::LONG; + const TypeD *td = t->is_double_constant(); + return TypeLong::make( SharedRuntime::d2l( td->getd() ) ); +} + +//------------------------------Identity--------------------------------------- +Node *ConvD2LNode::Identity(PhaseTransform *phase) { + // Remove ConvD2L->ConvL2D->ConvD2L sequences. + if( in(1) ->Opcode() == Op_ConvL2D && + in(1)->in(1)->Opcode() == Op_ConvD2L ) + return in(1)->in(1); + return this; +} + +//------------------------------Ideal------------------------------------------ +// If converting to an int type, skip any rounding nodes +Node *ConvD2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { + if( in(1)->Opcode() == Op_RoundDouble ) + set_req(1,in(1)->in(1)); + return NULL; +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *ConvF2DNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + if( t == Type::FLOAT ) return Type::DOUBLE; + const TypeF *tf = t->is_float_constant(); + return TypeD::make( (double)tf->getf() ); +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *ConvF2INode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + if( t == Type::FLOAT ) return TypeInt::INT; + const TypeF *tf = t->is_float_constant(); + return TypeInt::make( SharedRuntime::f2i( tf->getf() ) ); +} + +//------------------------------Identity--------------------------------------- +Node *ConvF2INode::Identity(PhaseTransform *phase) { + // Remove ConvF2I->ConvI2F->ConvF2I sequences. + if( in(1) ->Opcode() == Op_ConvI2F && + in(1)->in(1)->Opcode() == Op_ConvF2I ) + return in(1)->in(1); + return this; +} + +//------------------------------Ideal------------------------------------------ +// If converting to an int type, skip any rounding nodes +Node *ConvF2INode::Ideal(PhaseGVN *phase, bool can_reshape) { + if( in(1)->Opcode() == Op_RoundFloat ) + set_req(1,in(1)->in(1)); + return NULL; +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *ConvF2LNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + if( t == Type::FLOAT ) return TypeLong::LONG; + const TypeF *tf = t->is_float_constant(); + return TypeLong::make( SharedRuntime::f2l( tf->getf() ) ); +} + +//------------------------------Identity--------------------------------------- +Node *ConvF2LNode::Identity(PhaseTransform *phase) { + // Remove ConvF2L->ConvL2F->ConvF2L sequences. + if( in(1) ->Opcode() == Op_ConvL2F && + in(1)->in(1)->Opcode() == Op_ConvF2L ) + return in(1)->in(1); + return this; +} + +//------------------------------Ideal------------------------------------------ +// If converting to an int type, skip any rounding nodes +Node *ConvF2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { + if( in(1)->Opcode() == Op_RoundFloat ) + set_req(1,in(1)->in(1)); + return NULL; +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *ConvI2DNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + const TypeInt *ti = t->is_int(); + if( ti->is_con() ) return TypeD::make( (double)ti->get_con() ); + return bottom_type(); +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *ConvI2FNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + const TypeInt *ti = t->is_int(); + if( ti->is_con() ) return TypeF::make( (float)ti->get_con() ); + return bottom_type(); +} + +//------------------------------Identity--------------------------------------- +Node *ConvI2FNode::Identity(PhaseTransform *phase) { + // Remove ConvI2F->ConvF2I->ConvI2F sequences. + if( in(1) ->Opcode() == Op_ConvF2I && + in(1)->in(1)->Opcode() == Op_ConvI2F ) + return in(1)->in(1); + return this; +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *ConvI2LNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + const TypeInt *ti = t->is_int(); + const Type* tl = TypeLong::make(ti->_lo, ti->_hi, ti->_widen); + // Join my declared type against my incoming type. + tl = tl->filter(_type); + return tl; +} + +#ifdef _LP64 +static inline bool long_ranges_overlap(jlong lo1, jlong hi1, + jlong lo2, jlong hi2) { + // Two ranges overlap iff one range's low point falls in the other range. + return (lo2 <= lo1 && lo1 <= hi2) || (lo1 <= lo2 && lo2 <= hi1); +} +#endif + +//------------------------------Ideal------------------------------------------ +Node *ConvI2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { + const TypeLong* this_type = this->type()->is_long(); + Node* this_changed = NULL; + + // If _major_progress, then more loop optimizations follow. Do NOT + // remove this node's type assertion until no more loop ops can happen. + // The progress bit is set in the major loop optimizations THEN comes the + // call to IterGVN and any chance of hitting this code. Cf. Opaque1Node. + if (can_reshape && !phase->C->major_progress()) { + const TypeInt* in_type = phase->type(in(1))->isa_int(); + if (in_type != NULL && this_type != NULL && + (in_type->_lo != this_type->_lo || + in_type->_hi != this_type->_hi)) { + // Although this WORSENS the type, it increases GVN opportunities, + // because I2L nodes with the same input will common up, regardless + // of slightly differing type assertions. Such slight differences + // arise routinely as a result of loop unrolling, so this is a + // post-unrolling graph cleanup. Choose a type which depends only + // on my input. (Exception: Keep a range assertion of >=0 or <0.) + jlong lo1 = this_type->_lo; + jlong hi1 = this_type->_hi; + int w1 = this_type->_widen; + if (lo1 != (jint)lo1 || + hi1 != (jint)hi1 || + lo1 > hi1) { + // Overflow leads to wraparound, wraparound leads to range saturation. + lo1 = min_jint; hi1 = max_jint; + } else if (lo1 >= 0) { + // Keep a range assertion of >=0. + lo1 = 0; hi1 = max_jint; + } else if (hi1 < 0) { + // Keep a range assertion of <0. + lo1 = min_jint; hi1 = -1; + } else { + lo1 = min_jint; hi1 = max_jint; + } + const TypeLong* wtype = TypeLong::make(MAX2((jlong)in_type->_lo, lo1), + MIN2((jlong)in_type->_hi, hi1), + MAX2((int)in_type->_widen, w1)); + if (wtype != type()) { + set_type(wtype); + // Note: this_type still has old type value, for the logic below. + this_changed = this; + } + } + } + +#ifdef _LP64 + // Convert ConvI2L(AddI(x, y)) to AddL(ConvI2L(x), ConvI2L(y)) , + // but only if x and y have subranges that cannot cause 32-bit overflow, + // under the assumption that x+y is in my own subrange this->type(). + + // This assumption is based on a constraint (i.e., type assertion) + // established in Parse::array_addressing or perhaps elsewhere. + // This constraint has been adjoined to the "natural" type of + // the incoming argument in(0). We know (because of runtime + // checks) - that the result value I2L(x+y) is in the joined range. + // Hence we can restrict the incoming terms (x, y) to values such + // that their sum also lands in that range. + + // This optimization is useful only on 64-bit systems, where we hope + // the addition will end up subsumed in an addressing mode. + // It is necessary to do this when optimizing an unrolled array + // copy loop such as x[i++] = y[i++]. + + // On 32-bit systems, it's better to perform as much 32-bit math as + // possible before the I2L conversion, because 32-bit math is cheaper. + // There's no common reason to "leak" a constant offset through the I2L. + // Addressing arithmetic will not absorb it as part of a 64-bit AddL. + + Node* z = in(1); + int op = z->Opcode(); + if (op == Op_AddI || op == Op_SubI) { + Node* x = z->in(1); + Node* y = z->in(2); + assert (x != z && y != z, "dead loop in ConvI2LNode::Ideal"); + if (phase->type(x) == Type::TOP) return this_changed; + if (phase->type(y) == Type::TOP) return this_changed; + const TypeInt* tx = phase->type(x)->is_int(); + const TypeInt* ty = phase->type(y)->is_int(); + const TypeLong* tz = this_type; + jlong xlo = tx->_lo; + jlong xhi = tx->_hi; + jlong ylo = ty->_lo; + jlong yhi = ty->_hi; + jlong zlo = tz->_lo; + jlong zhi = tz->_hi; + jlong vbit = CONST64(1) << BitsPerInt; + int widen = MAX2(tx->_widen, ty->_widen); + if (op == Op_SubI) { + jlong ylo0 = ylo; + ylo = -yhi; + yhi = -ylo0; + } + // See if x+y can cause positive overflow into z+2**32 + if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo+vbit, zhi+vbit)) { + return this_changed; + } + // See if x+y can cause negative overflow into z-2**32 + if (long_ranges_overlap(xlo+ylo, xhi+yhi, zlo-vbit, zhi-vbit)) { + return this_changed; + } + // Now it's always safe to assume x+y does not overflow. + // This is true even if some pairs x,y might cause overflow, as long + // as that overflow value cannot fall into [zlo,zhi]. + + // Confident that the arithmetic is "as if infinite precision", + // we can now use z's range to put constraints on those of x and y. + // The "natural" range of x [xlo,xhi] can perhaps be narrowed to a + // more "restricted" range by intersecting [xlo,xhi] with the + // range obtained by subtracting y's range from the asserted range + // of the I2L conversion. Here's the interval arithmetic algebra: + // x == z-y == [zlo,zhi]-[ylo,yhi] == [zlo,zhi]+[-yhi,-ylo] + // => x in [zlo-yhi, zhi-ylo] + // => x in [zlo-yhi, zhi-ylo] INTERSECT [xlo,xhi] + // => x in [xlo MAX zlo-yhi, xhi MIN zhi-ylo] + jlong rxlo = MAX2(xlo, zlo - yhi); + jlong rxhi = MIN2(xhi, zhi - ylo); + // And similarly, x changing place with y: + jlong rylo = MAX2(ylo, zlo - xhi); + jlong ryhi = MIN2(yhi, zhi - xlo); + if (rxlo > rxhi || rylo > ryhi) { + return this_changed; // x or y is dying; don't mess w/ it + } + if (op == Op_SubI) { + jlong rylo0 = rylo; + rylo = -ryhi; + ryhi = -rylo0; + } + + Node* cx = phase->transform( new (phase->C) ConvI2LNode(x, TypeLong::make(rxlo, rxhi, widen)) ); + Node* cy = phase->transform( new (phase->C) ConvI2LNode(y, TypeLong::make(rylo, ryhi, widen)) ); + switch (op) { + case Op_AddI: return new (phase->C) AddLNode(cx, cy); + case Op_SubI: return new (phase->C) SubLNode(cx, cy); + default: ShouldNotReachHere(); + } + } +#endif //_LP64 + + return this_changed; +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *ConvL2DNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + const TypeLong *tl = t->is_long(); + if( tl->is_con() ) return TypeD::make( (double)tl->get_con() ); + return bottom_type(); +} + +//============================================================================= +//------------------------------Value------------------------------------------ +const Type *ConvL2FNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + const TypeLong *tl = t->is_long(); + if( tl->is_con() ) return TypeF::make( (float)tl->get_con() ); + return bottom_type(); +} + +//============================================================================= +//----------------------------Identity----------------------------------------- +Node *ConvL2INode::Identity( PhaseTransform *phase ) { + // Convert L2I(I2L(x)) => x + if (in(1)->Opcode() == Op_ConvI2L) return in(1)->in(1); + return this; +} + +//------------------------------Value------------------------------------------ +const Type *ConvL2INode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + const TypeLong *tl = t->is_long(); + if (tl->is_con()) + // Easy case. + return TypeInt::make((jint)tl->get_con()); + return bottom_type(); +} + +//------------------------------Ideal------------------------------------------ +// Return a node which is more "ideal" than the current node. +// Blow off prior masking to int +Node *ConvL2INode::Ideal(PhaseGVN *phase, bool can_reshape) { + Node *andl = in(1); + uint andl_op = andl->Opcode(); + if( andl_op == Op_AndL ) { + // Blow off prior masking to int + if( phase->type(andl->in(2)) == TypeLong::make( 0xFFFFFFFF ) ) { + set_req(1,andl->in(1)); + return this; + } + } + + // Swap with a prior add: convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y)) + // This replaces an 'AddL' with an 'AddI'. + if( andl_op == Op_AddL ) { + // Don't do this for nodes which have more than one user since + // we'll end up computing the long add anyway. + if (andl->outcnt() > 1) return NULL; + + Node* x = andl->in(1); + Node* y = andl->in(2); + assert( x != andl && y != andl, "dead loop in ConvL2INode::Ideal" ); + if (phase->type(x) == Type::TOP) return NULL; + if (phase->type(y) == Type::TOP) return NULL; + Node *add1 = phase->transform(new (phase->C) ConvL2INode(x)); + Node *add2 = phase->transform(new (phase->C) ConvL2INode(y)); + return new (phase->C) AddINode(add1,add2); + } + + // Disable optimization: LoadL->ConvL2I ==> LoadI. + // It causes problems (sizes of Load and Store nodes do not match) + // in objects initialization code and Escape Analysis. + return NULL; +} + + + +//============================================================================= +//------------------------------Identity--------------------------------------- +// Remove redundant roundings +Node *RoundFloatNode::Identity( PhaseTransform *phase ) { + assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel"); + // Do not round constants + if (phase->type(in(1))->base() == Type::FloatCon) return in(1); + int op = in(1)->Opcode(); + // Redundant rounding + if( op == Op_RoundFloat ) return in(1); + // Already rounded + if( op == Op_Parm ) return in(1); + if( op == Op_LoadF ) return in(1); + return this; +} + +//------------------------------Value------------------------------------------ +const Type *RoundFloatNode::Value( PhaseTransform *phase ) const { + return phase->type( in(1) ); +} + +//============================================================================= +//------------------------------Identity--------------------------------------- +// Remove redundant roundings. Incoming arguments are already rounded. +Node *RoundDoubleNode::Identity( PhaseTransform *phase ) { + assert(Matcher::strict_fp_requires_explicit_rounding, "should only generate for Intel"); + // Do not round constants + if (phase->type(in(1))->base() == Type::DoubleCon) return in(1); + int op = in(1)->Opcode(); + // Redundant rounding + if( op == Op_RoundDouble ) return in(1); + // Already rounded + if( op == Op_Parm ) return in(1); + if( op == Op_LoadD ) return in(1); + if( op == Op_ConvF2D ) return in(1); + if( op == Op_ConvI2D ) return in(1); + return this; +} + +//------------------------------Value------------------------------------------ +const Type *RoundDoubleNode::Value( PhaseTransform *phase ) const { + return phase->type( in(1) ); +} + + --- /dev/null 2014-03-18 16:27:36.000000000 -0400 +++ new/src/share/vm/opto/convertnode.hpp 2014-03-18 16:27:36.000000000 -0400 @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_OPTO_CONVERTNODE_HPP +#define SHARE_VM_OPTO_CONVERTNODE_HPP + +#include "opto/node.hpp" +#include "opto/opcodes.hpp" + + +//------------------------------Conv2BNode------------------------------------- +// Convert int/pointer to a Boolean. Map zero to zero, all else to 1. +class Conv2BNode : public Node { + public: + Conv2BNode( Node *i ) : Node(0,i) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeInt::BOOL; } + virtual Node *Identity( PhaseTransform *phase ); + virtual const Type *Value( PhaseTransform *phase ) const; + virtual uint ideal_reg() const { return Op_RegI; } +}; + +// The conversions operations are all Alpha sorted. Please keep it that way! +//------------------------------ConvD2FNode------------------------------------ +// Convert double to float +class ConvD2FNode : public Node { + public: + ConvD2FNode( Node *in1 ) : Node(0,in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return Type::FLOAT; } + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Identity( PhaseTransform *phase ); + virtual uint ideal_reg() const { return Op_RegF; } +}; + +//------------------------------ConvD2INode------------------------------------ +// Convert Double to Integer +class ConvD2INode : public Node { + public: + ConvD2INode( Node *in1 ) : Node(0,in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeInt::INT; } + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Identity( PhaseTransform *phase ); + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual uint ideal_reg() const { return Op_RegI; } +}; + +//------------------------------ConvD2LNode------------------------------------ +// Convert Double to Long +class ConvD2LNode : public Node { + public: + ConvD2LNode( Node *dbl ) : Node(0,dbl) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeLong::LONG; } + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Identity( PhaseTransform *phase ); + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual uint ideal_reg() const { return Op_RegL; } +}; + +//------------------------------ConvF2DNode------------------------------------ +// Convert Float to a Double. +class ConvF2DNode : public Node { + public: + ConvF2DNode( Node *in1 ) : Node(0,in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return Type::DOUBLE; } + virtual const Type *Value( PhaseTransform *phase ) const; + virtual uint ideal_reg() const { return Op_RegD; } +}; + +//------------------------------ConvF2INode------------------------------------ +// Convert float to integer +class ConvF2INode : public Node { + public: + ConvF2INode( Node *in1 ) : Node(0,in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeInt::INT; } + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Identity( PhaseTransform *phase ); + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual uint ideal_reg() const { return Op_RegI; } +}; + +//------------------------------ConvF2LNode------------------------------------ +// Convert float to long +class ConvF2LNode : public Node { + public: + ConvF2LNode( Node *in1 ) : Node(0,in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeLong::LONG; } + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Identity( PhaseTransform *phase ); + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual uint ideal_reg() const { return Op_RegL; } +}; + +//------------------------------ConvI2DNode------------------------------------ +// Convert Integer to Double +class ConvI2DNode : public Node { + public: + ConvI2DNode( Node *in1 ) : Node(0,in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return Type::DOUBLE; } + virtual const Type *Value( PhaseTransform *phase ) const; + virtual uint ideal_reg() const { return Op_RegD; } +}; + +//------------------------------ConvI2FNode------------------------------------ +// Convert Integer to Float +class ConvI2FNode : public Node { + public: + ConvI2FNode( Node *in1 ) : Node(0,in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return Type::FLOAT; } + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Identity( PhaseTransform *phase ); + virtual uint ideal_reg() const { return Op_RegF; } +}; + +//------------------------------ConvI2LNode------------------------------------ +// Convert integer to long +class ConvI2LNode : public TypeNode { + public: + ConvI2LNode(Node *in1, const TypeLong* t = TypeLong::INT) + : TypeNode(t, 2) + { init_req(1, in1); } + virtual int Opcode() const; + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual uint ideal_reg() const { return Op_RegL; } +}; + +//------------------------------ConvL2DNode------------------------------------ +// Convert Long to Double +class ConvL2DNode : public Node { + public: + ConvL2DNode( Node *in1 ) : Node(0,in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return Type::DOUBLE; } + virtual const Type *Value( PhaseTransform *phase ) const; + virtual uint ideal_reg() const { return Op_RegD; } +}; + +//------------------------------ConvL2FNode------------------------------------ +// Convert Long to Float +class ConvL2FNode : public Node { + public: + ConvL2FNode( Node *in1 ) : Node(0,in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return Type::FLOAT; } + virtual const Type *Value( PhaseTransform *phase ) const; + virtual uint ideal_reg() const { return Op_RegF; } +}; + +//------------------------------ConvL2INode------------------------------------ +// Convert long to integer +class ConvL2INode : public Node { + public: + ConvL2INode( Node *in1 ) : Node(0,in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeInt::INT; } + virtual Node *Identity( PhaseTransform *phase ); + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual uint ideal_reg() const { return Op_RegI; } +}; + +//-----------------------------RoundFloatNode---------------------------------- +class RoundFloatNode: public Node { + public: + RoundFloatNode(Node* c, Node *in1): Node(c, in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return Type::FLOAT; } + virtual uint ideal_reg() const { return Op_RegF; } + virtual Node *Identity( PhaseTransform *phase ); + virtual const Type *Value( PhaseTransform *phase ) const; +}; + + +//-----------------------------RoundDoubleNode--------------------------------- +class RoundDoubleNode: public Node { + public: + RoundDoubleNode(Node* c, Node *in1): Node(c, in1) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return Type::DOUBLE; } + virtual uint ideal_reg() const { return Op_RegD; } + virtual Node *Identity( PhaseTransform *phase ); + virtual const Type *Value( PhaseTransform *phase ) const; +}; + + +#endif // SHARE_VM_OPTO_CONVERTNODE_HPP --- /dev/null 2014-03-18 16:27:37.000000000 -0400 +++ new/src/share/vm/opto/countbitsnode.cpp 2014-03-18 16:27:36.000000000 -0400 @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "opto/countbitsnode.hpp" +#include "opto/opcodes.hpp" +#include "opto/phaseX.hpp" +#include "opto/type.hpp" + +//------------------------------Value------------------------------------------ +const Type* CountLeadingZerosINode::Value(PhaseTransform* phase) const { + const Type* t = phase->type(in(1)); + if (t == Type::TOP) return Type::TOP; + const TypeInt* ti = t->isa_int(); + if (ti && ti->is_con()) { + jint i = ti->get_con(); + // HD, Figure 5-6 + if (i == 0) + return TypeInt::make(BitsPerInt); + int n = 1; + unsigned int x = i; + if (x >> 16 == 0) { n += 16; x <<= 16; } + if (x >> 24 == 0) { n += 8; x <<= 8; } + if (x >> 28 == 0) { n += 4; x <<= 4; } + if (x >> 30 == 0) { n += 2; x <<= 2; } + n -= x >> 31; + return TypeInt::make(n); + } + return TypeInt::INT; +} + +//------------------------------Value------------------------------------------ +const Type* CountLeadingZerosLNode::Value(PhaseTransform* phase) const { + const Type* t = phase->type(in(1)); + if (t == Type::TOP) return Type::TOP; + const TypeLong* tl = t->isa_long(); + if (tl && tl->is_con()) { + jlong l = tl->get_con(); + // HD, Figure 5-6 + if (l == 0) + return TypeInt::make(BitsPerLong); + int n = 1; + unsigned int x = (((julong) l) >> 32); + if (x == 0) { n += 32; x = (int) l; } + if (x >> 16 == 0) { n += 16; x <<= 16; } + if (x >> 24 == 0) { n += 8; x <<= 8; } + if (x >> 28 == 0) { n += 4; x <<= 4; } + if (x >> 30 == 0) { n += 2; x <<= 2; } + n -= x >> 31; + return TypeInt::make(n); + } + return TypeInt::INT; +} + +//------------------------------Value------------------------------------------ +const Type* CountTrailingZerosINode::Value(PhaseTransform* phase) const { + const Type* t = phase->type(in(1)); + if (t == Type::TOP) return Type::TOP; + const TypeInt* ti = t->isa_int(); + if (ti && ti->is_con()) { + jint i = ti->get_con(); + // HD, Figure 5-14 + int y; + if (i == 0) + return TypeInt::make(BitsPerInt); + int n = 31; + y = i << 16; if (y != 0) { n = n - 16; i = y; } + y = i << 8; if (y != 0) { n = n - 8; i = y; } + y = i << 4; if (y != 0) { n = n - 4; i = y; } + y = i << 2; if (y != 0) { n = n - 2; i = y; } + y = i << 1; if (y != 0) { n = n - 1; } + return TypeInt::make(n); + } + return TypeInt::INT; +} + +//------------------------------Value------------------------------------------ +const Type* CountTrailingZerosLNode::Value(PhaseTransform* phase) const { + const Type* t = phase->type(in(1)); + if (t == Type::TOP) return Type::TOP; + const TypeLong* tl = t->isa_long(); + if (tl && tl->is_con()) { + jlong l = tl->get_con(); + // HD, Figure 5-14 + int x, y; + if (l == 0) + return TypeInt::make(BitsPerLong); + int n = 63; + y = (int) l; if (y != 0) { n = n - 32; x = y; } else x = (((julong) l) >> 32); + y = x << 16; if (y != 0) { n = n - 16; x = y; } + y = x << 8; if (y != 0) { n = n - 8; x = y; } + y = x << 4; if (y != 0) { n = n - 4; x = y; } + y = x << 2; if (y != 0) { n = n - 2; x = y; } + y = x << 1; if (y != 0) { n = n - 1; } + return TypeInt::make(n); + } + return TypeInt::INT; +} --- /dev/null 2014-03-18 16:27:37.000000000 -0400 +++ new/src/share/vm/opto/countbitsnode.hpp 2014-03-18 16:27:37.000000000 -0400 @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_OPTO_COUNTBITSNODE_HPP +#define SHARE_VM_OPTO_COUNTBITSNODE_HPP + +#include "opto/node.hpp" +#include "opto/opcodes.hpp" + +class PhaseTransform; + +//---------- CountBitsNode ----------------------------------------------------- +class CountBitsNode : public Node { + public: + CountBitsNode(Node* in1) : Node(0, in1) {} + const Type* bottom_type() const { return TypeInt::INT; } + virtual uint ideal_reg() const { return Op_RegI; } +}; + +//---------- CountLeadingZerosINode -------------------------------------------- +// Count leading zeros (0-bit count starting from MSB) of an integer. +class CountLeadingZerosINode : public CountBitsNode { + public: + CountLeadingZerosINode(Node* in1) : CountBitsNode(in1) {} + virtual int Opcode() const; + virtual const Type* Value(PhaseTransform* phase) const; +}; + +//---------- CountLeadingZerosLNode -------------------------------------------- +// Count leading zeros (0-bit count starting from MSB) of a long. +class CountLeadingZerosLNode : public CountBitsNode { + public: + CountLeadingZerosLNode(Node* in1) : CountBitsNode(in1) {} + virtual int Opcode() const; + virtual const Type* Value(PhaseTransform* phase) const; +}; + +//---------- CountTrailingZerosINode ------------------------------------------- +// Count trailing zeros (0-bit count starting from LSB) of an integer. +class CountTrailingZerosINode : public CountBitsNode { + public: + CountTrailingZerosINode(Node* in1) : CountBitsNode(in1) {} + virtual int Opcode() const; + virtual const Type* Value(PhaseTransform* phase) const; +}; + +//---------- CountTrailingZerosLNode ------------------------------------------- +// Count trailing zeros (0-bit count starting from LSB) of a long. +class CountTrailingZerosLNode : public CountBitsNode { + public: + CountTrailingZerosLNode(Node* in1) : CountBitsNode(in1) {} + virtual int Opcode() const; + virtual const Type* Value(PhaseTransform* phase) const; +}; + +//---------- PopCountINode ----------------------------------------------------- +// Population count (bit count) of an integer. +class PopCountINode : public CountBitsNode { + public: + PopCountINode(Node* in1) : CountBitsNode(in1) {} + virtual int Opcode() const; +}; + +//---------- PopCountLNode ----------------------------------------------------- +// Population count (bit count) of a long. +class PopCountLNode : public CountBitsNode { + public: + PopCountLNode(Node* in1) : CountBitsNode(in1) {} + virtual int Opcode() const; +}; + + +#endif // SHARE_VM_OPTO_COUNTBITSNODE_HPP --- /dev/null 2014-03-18 16:27:38.000000000 -0400 +++ new/src/share/vm/opto/intrinsicnode.cpp 2014-03-18 16:27:38.000000000 -0400 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "opto/intrinsicnode.hpp" +#include "opto/memnode.hpp" +#include "opto/phaseX.hpp" + +//============================================================================= +// Do not match memory edge. +uint StrIntrinsicNode::match_edge(uint idx) const { + return idx == 2 || idx == 3; +} + +//------------------------------Ideal------------------------------------------ +// Return a node which is more "ideal" than the current node. Strip out +// control copies +Node *StrIntrinsicNode::Ideal(PhaseGVN *phase, bool can_reshape) { + if (remove_dead_region(phase, can_reshape)) return this; + // Don't bother trying to transform a dead node + if (in(0) && in(0)->is_top()) return NULL; + + if (can_reshape) { + Node* mem = phase->transform(in(MemNode::Memory)); + // If transformed to a MergeMem, get the desired slice + uint alias_idx = phase->C->get_alias_index(adr_type()); + mem = mem->is_MergeMem() ? mem->as_MergeMem()->memory_at(alias_idx) : mem; + if (mem != in(MemNode::Memory)) { + set_req(MemNode::Memory, mem); + return this; + } + } + return NULL; +} + +//------------------------------Value------------------------------------------ +const Type *StrIntrinsicNode::Value( PhaseTransform *phase ) const { + if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP; + return bottom_type(); +} + +//============================================================================= +//------------------------------match_edge------------------------------------- +// Do not match memory edge +uint EncodeISOArrayNode::match_edge(uint idx) const { + return idx == 2 || idx == 3; // EncodeISOArray src (Binary dst len) +} + +//------------------------------Ideal------------------------------------------ +// Return a node which is more "ideal" than the current node. Strip out +// control copies +Node *EncodeISOArrayNode::Ideal(PhaseGVN *phase, bool can_reshape) { + return remove_dead_region(phase, can_reshape) ? this : NULL; +} + +//------------------------------Value------------------------------------------ +const Type *EncodeISOArrayNode::Value(PhaseTransform *phase) const { + if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP; + return bottom_type(); +} + --- /dev/null 2014-03-18 16:27:38.000000000 -0400 +++ new/src/share/vm/opto/intrinsicnode.hpp 2014-03-18 16:27:38.000000000 -0400 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_OPTO_INTRINSICNODE_HPP +#define SHARE_VM_OPTO_INTRINSICNODE_HPP + +#include "opto/node.hpp" +#include "opto/opcodes.hpp" + + +//----------------------PartialSubtypeCheckNode-------------------------------- +// The 2nd slow-half of a subtype check. Scan the subklass's 2ndary superklass +// array for an instance of the superklass. Set a hidden internal cache on a +// hit (cache is checked with exposed code in gen_subtype_check()). Return +// not zero for a miss or zero for a hit. +class PartialSubtypeCheckNode : public Node { +public: + PartialSubtypeCheckNode(Node* c, Node* sub, Node* super) : Node(c,sub,super) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } + virtual uint ideal_reg() const { return Op_RegP; } +}; + +//------------------------------StrIntrinsic------------------------------- +// Base class for Ideal nodes used in String instrinsic code. +class StrIntrinsicNode: public Node { +public: + StrIntrinsicNode(Node* control, Node* char_array_mem, + Node* s1, Node* c1, Node* s2, Node* c2): + Node(control, char_array_mem, s1, c1, s2, c2) { + } + + StrIntrinsicNode(Node* control, Node* char_array_mem, + Node* s1, Node* s2, Node* c): + Node(control, char_array_mem, s1, s2, c) { + } + + StrIntrinsicNode(Node* control, Node* char_array_mem, + Node* s1, Node* s2): + Node(control, char_array_mem, s1, s2) { + } + + virtual bool depends_only_on_test() const { return false; } + virtual const TypePtr* adr_type() const { return TypeAryPtr::CHARS; } + virtual uint match_edge(uint idx) const; + virtual uint ideal_reg() const { return Op_RegI; } + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual const Type *Value(PhaseTransform *phase) const; +}; + +//------------------------------StrComp------------------------------------- +class StrCompNode: public StrIntrinsicNode { +public: + StrCompNode(Node* control, Node* char_array_mem, + Node* s1, Node* c1, Node* s2, Node* c2): + StrIntrinsicNode(control, char_array_mem, s1, c1, s2, c2) {}; + virtual int Opcode() const; + virtual const Type* bottom_type() const { return TypeInt::INT; } +}; + +//------------------------------StrEquals------------------------------------- +class StrEqualsNode: public StrIntrinsicNode { +public: + StrEqualsNode(Node* control, Node* char_array_mem, + Node* s1, Node* s2, Node* c): + StrIntrinsicNode(control, char_array_mem, s1, s2, c) {}; + virtual int Opcode() const; + virtual const Type* bottom_type() const { return TypeInt::BOOL; } +}; + +//------------------------------StrIndexOf------------------------------------- +class StrIndexOfNode: public StrIntrinsicNode { +public: + StrIndexOfNode(Node* control, Node* char_array_mem, + Node* s1, Node* c1, Node* s2, Node* c2): + StrIntrinsicNode(control, char_array_mem, s1, c1, s2, c2) {}; + virtual int Opcode() const; + virtual const Type* bottom_type() const { return TypeInt::INT; } +}; + +//------------------------------AryEq--------------------------------------- +class AryEqNode: public StrIntrinsicNode { +public: + AryEqNode(Node* control, Node* char_array_mem, Node* s1, Node* s2): + StrIntrinsicNode(control, char_array_mem, s1, s2) {}; + virtual int Opcode() const; + virtual const Type* bottom_type() const { return TypeInt::BOOL; } +}; + + +//------------------------------EncodeISOArray-------------------------------- +// encode char[] to byte[] in ISO_8859_1 +class EncodeISOArrayNode: public Node { +public: + EncodeISOArrayNode(Node *control, Node* arymem, Node* s1, Node* s2, Node* c): Node(control, arymem, s1, s2, c) {}; + virtual int Opcode() const; + virtual bool depends_only_on_test() const { return false; } + virtual const Type* bottom_type() const { return TypeInt::INT; } + virtual const TypePtr* adr_type() const { return TypePtr::BOTTOM; } + virtual uint match_edge(uint idx) const; + virtual uint ideal_reg() const { return Op_RegI; } + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual const Type *Value(PhaseTransform *phase) const; +}; + +#endif // SHARE_VM_OPTO_INTRINSICNODE_HPP --- /dev/null 2014-03-18 16:27:39.000000000 -0400 +++ new/src/share/vm/opto/movenode.cpp 2014-03-18 16:27:39.000000000 -0400 @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "opto/addnode.hpp" +#include "opto/connode.hpp" +#include "opto/convertnode.hpp" +#include "opto/movenode.hpp" +#include "opto/phaseX.hpp" +#include "opto/subnode.hpp" + +//------------------------------Ideal------------------------------------------ +// Return a node which is more "ideal" than the current node. +// Move constants to the right. +Node *CMoveNode::Ideal(PhaseGVN *phase, bool can_reshape) { + if( in(0) && remove_dead_region(phase, can_reshape) ) return this; + // Don't bother trying to transform a dead node + if( in(0) && in(0)->is_top() ) return NULL; + assert( !phase->eqv(in(Condition), this) && + !phase->eqv(in(IfFalse), this) && + !phase->eqv(in(IfTrue), this), "dead loop in CMoveNode::Ideal" ); + if( phase->type(in(Condition)) == Type::TOP ) + return NULL; // return NULL when Condition is dead + + if( in(IfFalse)->is_Con() && !in(IfTrue)->is_Con() ) { + if( in(Condition)->is_Bool() ) { + BoolNode* b = in(Condition)->as_Bool(); + BoolNode* b2 = b->negate(phase); + return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type ); + } + } + return NULL; +} + +//------------------------------is_cmove_id------------------------------------ +// Helper function to check for CMOVE identity. Shared with PhiNode::Identity +Node *CMoveNode::is_cmove_id( PhaseTransform *phase, Node *cmp, Node *t, Node *f, BoolNode *b ) { + // Check for Cmp'ing and CMove'ing same values + if( (phase->eqv(cmp->in(1),f) && + phase->eqv(cmp->in(2),t)) || + // Swapped Cmp is OK + (phase->eqv(cmp->in(2),f) && + phase->eqv(cmp->in(1),t)) ) { + // Give up this identity check for floating points because it may choose incorrect + // value around 0.0 and -0.0 + if ( cmp->Opcode()==Op_CmpF || cmp->Opcode()==Op_CmpD ) + return NULL; + // Check for "(t==f)?t:f;" and replace with "f" + if( b->_test._test == BoolTest::eq ) + return f; + // Allow the inverted case as well + // Check for "(t!=f)?t:f;" and replace with "t" + if( b->_test._test == BoolTest::ne ) + return t; + } + return NULL; +} + +//------------------------------Identity--------------------------------------- +// Conditional-move is an identity if both inputs are the same, or the test +// true or false. +Node *CMoveNode::Identity( PhaseTransform *phase ) { + if( phase->eqv(in(IfFalse),in(IfTrue)) ) // C-moving identical inputs? + return in(IfFalse); // Then it doesn't matter + if( phase->type(in(Condition)) == TypeInt::ZERO ) + return in(IfFalse); // Always pick left(false) input + if( phase->type(in(Condition)) == TypeInt::ONE ) + return in(IfTrue); // Always pick right(true) input + + // 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. + if( in(Condition)->is_Bool() ) { + BoolNode *b = in(Condition)->as_Bool(); + Node *cmp = b->in(1); + if( cmp->is_Cmp() ) { + Node *id = is_cmove_id( phase, cmp, in(IfTrue), in(IfFalse), b ); + if( id ) return id; + } + } + + return this; +} + +//------------------------------Value------------------------------------------ +// Result is the meet of inputs +const Type *CMoveNode::Value( PhaseTransform *phase ) const { + if( phase->type(in(Condition)) == Type::TOP ) + return Type::TOP; + return phase->type(in(IfFalse))->meet_speculative(phase->type(in(IfTrue))); +} + +//------------------------------make------------------------------------------- +// Make a correctly-flavored CMove. Since _type is directly determined +// from the inputs we do not need to specify it here. +CMoveNode *CMoveNode::make( Compile *C, Node *c, Node *bol, Node *left, Node *right, const Type *t ) { + switch( t->basic_type() ) { + case T_INT: return new (C) CMoveINode( bol, left, right, t->is_int() ); + case T_FLOAT: return new (C) CMoveFNode( bol, left, right, t ); + case T_DOUBLE: return new (C) CMoveDNode( bol, left, right, t ); + case T_LONG: return new (C) CMoveLNode( bol, left, right, t->is_long() ); + case T_OBJECT: return new (C) CMovePNode( c, bol, left, right, t->is_oopptr() ); + case T_ADDRESS: return new (C) CMovePNode( c, bol, left, right, t->is_ptr() ); + case T_NARROWOOP: return new (C) CMoveNNode( c, bol, left, right, t ); + default: + ShouldNotReachHere(); + return NULL; + } +} + +//============================================================================= +//------------------------------Ideal------------------------------------------ +// Return a node which is more "ideal" than the current node. +// Check for conversions to boolean +Node *CMoveINode::Ideal(PhaseGVN *phase, bool can_reshape) { + // Try generic ideal's first + Node *x = CMoveNode::Ideal(phase, can_reshape); + if( x ) return x; + + // If zero is on the left (false-case, no-move-case) it must mean another + // constant is on the right (otherwise the shared CMove::Ideal code would + // have moved the constant to the right). This situation is bad for Intel + // and a don't-care for Sparc. It's bad for Intel because the zero has to + // be manifested in a register with a XOR which kills flags, which are live + // on input to the CMoveI, leading to a situation which causes excessive + // spilling on Intel. For Sparc, if the zero in on the left the Sparc will + // zero a register via G0 and conditionally-move the other constant. If the + // zero is on the right, the Sparc will load the first constant with a + // 13-bit set-lo and conditionally move G0. See bug 4677505. + if( phase->type(in(IfFalse)) == TypeInt::ZERO && !(phase->type(in(IfTrue)) == TypeInt::ZERO) ) { + if( in(Condition)->is_Bool() ) { + BoolNode* b = in(Condition)->as_Bool(); + BoolNode* b2 = b->negate(phase); + return make( phase->C, in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type ); + } + } + + // Now check for booleans + int flip = 0; + + // Check for picking from zero/one + if( phase->type(in(IfFalse)) == TypeInt::ZERO && phase->type(in(IfTrue)) == TypeInt::ONE ) { + flip = 1 - flip; + } else if( phase->type(in(IfFalse)) == TypeInt::ONE && phase->type(in(IfTrue)) == TypeInt::ZERO ) { + } else return NULL; + + // Check for eq/ne test + if( !in(1)->is_Bool() ) return NULL; + BoolNode *bol = in(1)->as_Bool(); + if( bol->_test._test == BoolTest::eq ) { + } else if( bol->_test._test == BoolTest::ne ) { + flip = 1-flip; + } else return NULL; + + // Check for vs 0 or 1 + if( !bol->in(1)->is_Cmp() ) return NULL; + const CmpNode *cmp = bol->in(1)->as_Cmp(); + if( phase->type(cmp->in(2)) == TypeInt::ZERO ) { + } else if( phase->type(cmp->in(2)) == TypeInt::ONE ) { + // Allow cmp-vs-1 if the other input is bounded by 0-1 + if( phase->type(cmp->in(1)) != TypeInt::BOOL ) + return NULL; + flip = 1 - flip; + } else return NULL; + + // Convert to a bool (flipped) + // Build int->bool conversion +#ifndef PRODUCT + if( PrintOpto ) tty->print_cr("CMOV to I2B"); +#endif + Node *n = new (phase->C) Conv2BNode( cmp->in(1) ); + if( flip ) + n = new (phase->C) XorINode( phase->transform(n), phase->intcon(1) ); + + return n; +} + +//============================================================================= +//------------------------------Ideal------------------------------------------ +// Return a node which is more "ideal" than the current node. +// Check for absolute value +Node *CMoveFNode::Ideal(PhaseGVN *phase, bool can_reshape) { + // Try generic ideal's first + Node *x = CMoveNode::Ideal(phase, can_reshape); + if( x ) return x; + + 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 + + // Find the Bool + if( !in(1)->is_Bool() ) return NULL; + BoolNode *bol = in(1)->as_Bool(); + // Check bool sense + switch( bol->_test._test ) { + case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = IfTrue; break; + case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = IfFalse; break; + case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = IfTrue; break; + case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = IfFalse; break; + default: return NULL; break; + } + + // Find zero input of CmpF; the other input is being abs'd + Node *cmpf = bol->in(1); + if( cmpf->Opcode() != Op_CmpF ) return NULL; + Node *X = NULL; + bool flip = false; + if( phase->type(cmpf->in(cmp_zero_idx)) == TypeF::ZERO ) { + X = cmpf->in(3 - cmp_zero_idx); + } else if (phase->type(cmpf->in(3 - cmp_zero_idx)) == TypeF::ZERO) { + // The test is inverted, we should invert the result... + X = cmpf->in(cmp_zero_idx); + flip = true; + } else { + return NULL; + } + + // If X is found on the appropriate phi input, find the subtract on the other + if( X != in(phi_x_idx) ) return NULL; + int phi_sub_idx = phi_x_idx == IfTrue ? IfFalse : IfTrue; + Node *sub = in(phi_sub_idx); + + // Allow only SubF(0,X) and fail out for all others; NegF is not OK + if( sub->Opcode() != Op_SubF || + sub->in(2) != X || + phase->type(sub->in(1)) != TypeF::ZERO ) return NULL; + + Node *abs = new (phase->C) AbsFNode( X ); + if( flip ) + abs = new (phase->C) SubFNode(sub->in(1), phase->transform(abs)); + + return abs; +} + +//============================================================================= +//------------------------------Ideal------------------------------------------ +// Return a node which is more "ideal" than the current node. +// Check for absolute value +Node *CMoveDNode::Ideal(PhaseGVN *phase, bool can_reshape) { + // Try generic ideal's first + Node *x = CMoveNode::Ideal(phase, can_reshape); + if( x ) return x; + + 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 + + // Find the Bool + if( !in(1)->is_Bool() ) return NULL; + BoolNode *bol = in(1)->as_Bool(); + // Check bool sense + switch( bol->_test._test ) { + case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = IfTrue; break; + case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = IfFalse; break; + case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = IfTrue; break; + case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = IfFalse; break; + default: return NULL; break; + } + + // Find zero input of CmpD; the other input is being abs'd + Node *cmpd = bol->in(1); + if( cmpd->Opcode() != Op_CmpD ) return NULL; + Node *X = NULL; + bool flip = false; + if( phase->type(cmpd->in(cmp_zero_idx)) == TypeD::ZERO ) { + X = cmpd->in(3 - cmp_zero_idx); + } else if (phase->type(cmpd->in(3 - cmp_zero_idx)) == TypeD::ZERO) { + // The test is inverted, we should invert the result... + X = cmpd->in(cmp_zero_idx); + flip = true; + } else { + return NULL; + } + + // If X is found on the appropriate phi input, find the subtract on the other + if( X != in(phi_x_idx) ) return NULL; + int phi_sub_idx = phi_x_idx == IfTrue ? IfFalse : IfTrue; + Node *sub = in(phi_sub_idx); + + // Allow only SubD(0,X) and fail out for all others; NegD is not OK + if( sub->Opcode() != Op_SubD || + sub->in(2) != X || + phase->type(sub->in(1)) != TypeD::ZERO ) return NULL; + + Node *abs = new (phase->C) AbsDNode( X ); + if( flip ) + abs = new (phase->C) SubDNode(sub->in(1), phase->transform(abs)); + + return abs; +} + +//------------------------------Value------------------------------------------ +const Type *MoveL2DNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + const TypeLong *tl = t->is_long(); + if( !tl->is_con() ) return bottom_type(); + JavaValue v; + v.set_jlong(tl->get_con()); + return TypeD::make( v.get_jdouble() ); +} + +//------------------------------Value------------------------------------------ +const Type *MoveI2FNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + const TypeInt *ti = t->is_int(); + if( !ti->is_con() ) return bottom_type(); + JavaValue v; + v.set_jint(ti->get_con()); + return TypeF::make( v.get_jfloat() ); +} + +//------------------------------Value------------------------------------------ +const Type *MoveF2INode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + if( t == Type::FLOAT ) return TypeInt::INT; + const TypeF *tf = t->is_float_constant(); + JavaValue v; + v.set_jfloat(tf->getf()); + return TypeInt::make( v.get_jint() ); +} + +//------------------------------Value------------------------------------------ +const Type *MoveD2LNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return Type::TOP; + if( t == Type::DOUBLE ) return TypeLong::LONG; + const TypeD *td = t->is_double_constant(); + JavaValue v; + v.set_jdouble(td->getd()); + return TypeLong::make( v.get_jlong() ); +} + --- /dev/null 2014-03-18 16:27:39.000000000 -0400 +++ new/src/share/vm/opto/movenode.hpp 2014-03-18 16:27:39.000000000 -0400 @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_OPTO_MOVENODE_HPP +#define SHARE_VM_OPTO_MOVENODE_HPP + +#include "opto/node.hpp" + +//------------------------------CMoveNode-------------------------------------- +// Conditional move +class CMoveNode : public TypeNode { + public: + enum { Control, // When is it safe to do this cmove? + Condition, // Condition controlling the cmove + IfFalse, // Value if condition is false + IfTrue }; // Value if condition is true + CMoveNode( Node *bol, Node *left, Node *right, const Type *t ) : TypeNode(t,4) + { + init_class_id(Class_CMove); + // all inputs are nullified in Node::Node(int) + // init_req(Control,NULL); + init_req(Condition,bol); + init_req(IfFalse,left); + init_req(IfTrue,right); + } + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Identity( PhaseTransform *phase ); + static CMoveNode *make( Compile *C, Node *c, Node *bol, Node *left, Node *right, const Type *t ); + // Helper function to spot cmove graph shapes + static Node *is_cmove_id( PhaseTransform *phase, Node *cmp, Node *t, Node *f, BoolNode *b ); +}; + +//------------------------------CMoveDNode------------------------------------- +class CMoveDNode : public CMoveNode { + public: + CMoveDNode( Node *bol, Node *left, Node *right, const Type* t) : CMoveNode(bol,left,right,t){} + virtual int Opcode() const; + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); +}; + +//------------------------------CMoveFNode------------------------------------- +class CMoveFNode : public CMoveNode { + public: + CMoveFNode( Node *bol, Node *left, Node *right, const Type* t ) : CMoveNode(bol,left,right,t) {} + virtual int Opcode() const; + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); +}; + +//------------------------------CMoveINode------------------------------------- +class CMoveINode : public CMoveNode { + public: + CMoveINode( Node *bol, Node *left, Node *right, const TypeInt *ti ) : CMoveNode(bol,left,right,ti){} + virtual int Opcode() const; + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); +}; + +//------------------------------CMoveLNode------------------------------------- +class CMoveLNode : public CMoveNode { + public: + CMoveLNode(Node *bol, Node *left, Node *right, const TypeLong *tl ) : CMoveNode(bol,left,right,tl){} + virtual int Opcode() const; +}; + +//------------------------------CMovePNode------------------------------------- +class CMovePNode : public CMoveNode { + public: + CMovePNode( Node *c, Node *bol, Node *left, Node *right, const TypePtr* t ) : CMoveNode(bol,left,right,t) { init_req(Control,c); } + virtual int Opcode() const; +}; + +//------------------------------CMoveNNode------------------------------------- +class CMoveNNode : public CMoveNode { + public: + CMoveNNode( Node *c, Node *bol, Node *left, Node *right, const Type* t ) : CMoveNode(bol,left,right,t) { init_req(Control,c); } + virtual int Opcode() const; +}; + +// +class MoveI2FNode : public Node { + public: + MoveI2FNode( Node *value ) : Node(0,value) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return Type::FLOAT; } + virtual uint ideal_reg() const { return Op_RegF; } + virtual const Type* Value( PhaseTransform *phase ) const; +}; + +class MoveL2DNode : public Node { + public: + MoveL2DNode( Node *value ) : Node(0,value) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return Type::DOUBLE; } + virtual uint ideal_reg() const { return Op_RegD; } + virtual const Type* Value( PhaseTransform *phase ) const; +}; + +class MoveF2INode : public Node { + public: + MoveF2INode( Node *value ) : Node(0,value) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeInt::INT; } + virtual uint ideal_reg() const { return Op_RegI; } + virtual const Type* Value( PhaseTransform *phase ) const; +}; + +class MoveD2LNode : public Node { + public: + MoveD2LNode( Node *value ) : Node(0,value) {} + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeLong::LONG; } + virtual uint ideal_reg() const { return Op_RegL; } + virtual const Type* Value( PhaseTransform *phase ) const; +}; + +//------------------------------BinaryNode------------------------------------- +// Place holder for the 2 conditional inputs to a CMove. CMove needs 4 +// inputs: the Bool (for the lt/gt/eq/ne bits), the flags (result of some +// compare), and the 2 values to select between. The Matcher requires a +// binary tree so we break it down like this: +// (CMove (Binary bol cmp) (Binary src1 src2)) +class BinaryNode : public Node { + public: + BinaryNode( Node *n1, Node *n2 ) : Node(0,n1,n2) { } + virtual int Opcode() const; + virtual uint ideal_reg() const { return 0; } +}; + + +#endif // SHARE_VM_OPTO_MOVENODE_HPP + --- /dev/null 2014-03-18 16:27:40.000000000 -0400 +++ new/src/share/vm/opto/narrowptrnode.cpp 2014-03-18 16:27:40.000000000 -0400 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "opto/narrowptrnode.hpp" +#include "opto/phaseX.hpp" + +Node* DecodeNNode::Identity(PhaseTransform* phase) { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return in(1); + + if (in(1)->is_EncodeP()) { + // (DecodeN (EncodeP p)) -> p + return in(1)->in(1); + } + return this; +} + +const Type *DecodeNNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if (t == Type::TOP) return Type::TOP; + if (t == TypeNarrowOop::NULL_PTR) return TypePtr::NULL_PTR; + + assert(t->isa_narrowoop(), "only narrowoop here"); + return t->make_ptr(); +} + +Node* EncodePNode::Identity(PhaseTransform* phase) { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return in(1); + + if (in(1)->is_DecodeN()) { + // (EncodeP (DecodeN p)) -> p + return in(1)->in(1); + } + return this; +} + +const Type *EncodePNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if (t == Type::TOP) return Type::TOP; + if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR; + + assert(t->isa_oop_ptr(), "only oopptr here"); + return t->make_narrowoop(); +} + + +Node *EncodeNarrowPtrNode::Ideal_DU_postCCP( PhaseCCP *ccp ) { + return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1)); +} + +Node* DecodeNKlassNode::Identity(PhaseTransform* phase) { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return in(1); + + if (in(1)->is_EncodePKlass()) { + // (DecodeNKlass (EncodePKlass p)) -> p + return in(1)->in(1); + } + return this; +} + +const Type *DecodeNKlassNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if (t == Type::TOP) return Type::TOP; + assert(t != TypeNarrowKlass::NULL_PTR, "null klass?"); + + assert(t->isa_narrowklass(), "only narrow klass ptr here"); + return t->make_ptr(); +} + +Node* EncodePKlassNode::Identity(PhaseTransform* phase) { + const Type *t = phase->type( in(1) ); + if( t == Type::TOP ) return in(1); + + if (in(1)->is_DecodeNKlass()) { + // (EncodePKlass (DecodeNKlass p)) -> p + return in(1)->in(1); + } + return this; +} + +const Type *EncodePKlassNode::Value( PhaseTransform *phase ) const { + const Type *t = phase->type( in(1) ); + if (t == Type::TOP) return Type::TOP; + assert (t != TypePtr::NULL_PTR, "null klass?"); + + assert(UseCompressedClassPointers && t->isa_klassptr(), "only klass ptr here"); + return t->make_narrowklass(); +} + --- /dev/null 2014-03-18 16:27:40.000000000 -0400 +++ new/src/share/vm/opto/narrowptrnode.hpp 2014-03-18 16:27:40.000000000 -0400 @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_OPTO_NARROWPTRNODE_HPP +#define SHARE_VM_OPTO_NARROWPTRNODE_HPP + +#include "opto/node.hpp" +#include "opto/opcodes.hpp" + +//------------------------------EncodeNarrowPtr-------------------------------- +class EncodeNarrowPtrNode : public TypeNode { + protected: + EncodeNarrowPtrNode(Node* value, const Type* type): + TypeNode(type, 2) { + init_class_id(Class_EncodeNarrowPtr); + init_req(0, NULL); + init_req(1, value); + } + public: + virtual uint ideal_reg() const { return Op_RegN; } + virtual Node *Ideal_DU_postCCP( PhaseCCP *ccp ); +}; + +//------------------------------EncodeP-------------------------------- +// Encodes an oop pointers into its compressed form +// Takes an extra argument which is the real heap base as a long which +// may be useful for code generation in the backend. +class EncodePNode : public EncodeNarrowPtrNode { + public: + EncodePNode(Node* value, const Type* type): + EncodeNarrowPtrNode(value, type) { + init_class_id(Class_EncodeP); + } + virtual int Opcode() const; + virtual Node *Identity( PhaseTransform *phase ); + virtual const Type *Value( PhaseTransform *phase ) const; +}; + +//------------------------------EncodePKlass-------------------------------- +// Encodes a klass pointer into its compressed form +// Takes an extra argument which is the real heap base as a long which +// may be useful for code generation in the backend. +class EncodePKlassNode : public EncodeNarrowPtrNode { + public: + EncodePKlassNode(Node* value, const Type* type): + EncodeNarrowPtrNode(value, type) { + init_class_id(Class_EncodePKlass); + } + virtual int Opcode() const; + virtual Node *Identity( PhaseTransform *phase ); + virtual const Type *Value( PhaseTransform *phase ) const; +}; + +//------------------------------DecodeNarrowPtr-------------------------------- +class DecodeNarrowPtrNode : public TypeNode { + protected: + DecodeNarrowPtrNode(Node* value, const Type* type): + TypeNode(type, 2) { + init_class_id(Class_DecodeNarrowPtr); + init_req(0, NULL); + init_req(1, value); + } + public: + virtual uint ideal_reg() const { return Op_RegP; } +}; + +//------------------------------DecodeN-------------------------------- +// Converts a narrow oop into a real oop ptr. +// Takes an extra argument which is the real heap base as a long which +// may be useful for code generation in the backend. +class DecodeNNode : public DecodeNarrowPtrNode { + public: + DecodeNNode(Node* value, const Type* type): + DecodeNarrowPtrNode(value, type) { + init_class_id(Class_DecodeN); + } + virtual int Opcode() const; + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Identity( PhaseTransform *phase ); +}; + +//------------------------------DecodeNKlass-------------------------------- +// Converts a narrow klass pointer into a real klass ptr. +// Takes an extra argument which is the real heap base as a long which +// may be useful for code generation in the backend. +class DecodeNKlassNode : public DecodeNarrowPtrNode { + public: + DecodeNKlassNode(Node* value, const Type* type): + DecodeNarrowPtrNode(value, type) { + init_class_id(Class_DecodeNKlass); + } + virtual int Opcode() const; + virtual const Type *Value( PhaseTransform *phase ) const; + virtual Node *Identity( PhaseTransform *phase ); +}; + +#endif // SHARE_VM_OPTO_NARROWPTRNODE_HPP + --- /dev/null 2014-03-18 16:27:41.000000000 -0400 +++ new/src/share/vm/opto/opaquenode.cpp 2014-03-18 16:27:41.000000000 -0400 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "opto/opaquenode.hpp" +#include "opto/phaseX.hpp" + +//============================================================================= +// Do not allow value-numbering +uint Opaque1Node::hash() const { return NO_HASH; } +uint Opaque1Node::cmp( const Node &n ) const { + return (&n == this); // Always fail except on self +} + +//------------------------------Identity--------------------------------------- +// If _major_progress, then more loop optimizations follow. Do NOT remove +// the opaque Node until no more loop ops can happen. Note the timing of +// _major_progress; it's set in the major loop optimizations THEN comes the +// call to IterGVN and any chance of hitting this code. Hence there's no +// phase-ordering problem with stripping Opaque1 in IGVN followed by some +// more loop optimizations that require it. +Node *Opaque1Node::Identity( PhaseTransform *phase ) { + return phase->C->major_progress() ? this : in(1); +} + +//============================================================================= +// A node to prevent unwanted optimizations. Allows constant folding. Stops +// value-numbering, most Ideal calls or Identity functions. This Node is +// specifically designed to prevent the pre-increment value of a loop trip +// counter from being live out of the bottom of the loop (hence causing the +// pre- and post-increment values both being live and thus requiring an extra +// temp register and an extra move). If we "accidentally" optimize through +// this kind of a Node, we'll get slightly pessimal, but correct, code. Thus +// it's OK to be slightly sloppy on optimizations here. + +// Do not allow value-numbering +uint Opaque2Node::hash() const { return NO_HASH; } +uint Opaque2Node::cmp( const Node &n ) const { + return (&n == this); // Always fail except on self +} + + --- /dev/null 2014-03-18 16:27:41.000000000 -0400 +++ new/src/share/vm/opto/opaquenode.hpp 2014-03-18 16:27:41.000000000 -0400 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_OPTO_OPAQUENODE_HPP +#define SHARE_VM_OPTO_OPAQUENODE_HPP + +#include "opto/node.hpp" +#include "opto/opcodes.hpp" + +//------------------------------Opaque1Node------------------------------------ +// A node to prevent unwanted optimizations. Allows constant folding. +// Stops value-numbering, Ideal calls or Identity functions. +class Opaque1Node : public Node { + virtual uint hash() const ; // { return NO_HASH; } + virtual uint cmp( const Node &n ) const; + public: + Opaque1Node( Compile* C, Node *n ) : Node(0,n) { + // Put it on the Macro nodes list to removed during macro nodes expansion. + init_flags(Flag_is_macro); + C->add_macro_node(this); + } + // Special version for the pre-loop to hold the original loop limit + // which is consumed by range check elimination. + Opaque1Node( Compile* C, Node *n, Node* orig_limit ) : Node(0,n,orig_limit) { + // Put it on the Macro nodes list to removed during macro nodes expansion. + init_flags(Flag_is_macro); + C->add_macro_node(this); + } + Node* original_loop_limit() { return req()==3 ? in(2) : NULL; } + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeInt::INT; } + virtual Node *Identity( PhaseTransform *phase ); +}; + +//------------------------------Opaque2Node------------------------------------ +// A node to prevent unwanted optimizations. Allows constant folding. Stops +// value-numbering, most Ideal calls or Identity functions. This Node is +// specifically designed to prevent the pre-increment value of a loop trip +// counter from being live out of the bottom of the loop (hence causing the +// pre- and post-increment values both being live and thus requiring an extra +// temp register and an extra move). If we "accidentally" optimize through +// this kind of a Node, we'll get slightly pessimal, but correct, code. Thus +// it's OK to be slightly sloppy on optimizations here. +class Opaque2Node : public Node { + virtual uint hash() const ; // { return NO_HASH; } + virtual uint cmp( const Node &n ) const; + public: + Opaque2Node( Compile* C, Node *n ) : Node(0,n) { + // Put it on the Macro nodes list to removed during macro nodes expansion. + init_flags(Flag_is_macro); + C->add_macro_node(this); + } + virtual int Opcode() const; + virtual const Type *bottom_type() const { return TypeInt::INT; } +}; + +#endif // SHARE_VM_OPTO_OPAQUENODE_HPP + --- /dev/null 2014-03-18 16:27:42.000000000 -0400 +++ new/src/share/vm/opto/threadnode.hpp 2014-03-18 16:27:42.000000000 -0400 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_OPTO_THREADNODE_HPP +#define SHARE_VM_OPTO_THREADNODE_HPP + +#include "opto/node.hpp" + +#endif // SHARE_VM_OPTO_THREADNODE_HPP