< prev index next >

src/hotspot/share/opto/subnode.cpp

Print this page

  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileLog.hpp"
  27 #include "gc/shared/barrierSet.hpp"
  28 #include "gc/shared/c2/barrierSetC2.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "opto/addnode.hpp"
  31 #include "opto/callnode.hpp"
  32 #include "opto/cfgnode.hpp"

  33 #include "opto/loopnode.hpp"
  34 #include "opto/matcher.hpp"
  35 #include "opto/movenode.hpp"
  36 #include "opto/mulnode.hpp"
  37 #include "opto/opcodes.hpp"
  38 #include "opto/phaseX.hpp"
  39 #include "opto/subnode.hpp"
  40 #include "runtime/sharedRuntime.hpp"
  41 
  42 // Portions of code courtesy of Clifford Click
  43 
  44 // Optimization - Graph Style
  45 
  46 #include "math.h"
  47 
  48 //=============================================================================
  49 //------------------------------Identity---------------------------------------
  50 // If right input is a constant 0, return the left input.
  51 Node* SubNode::Identity(PhaseGVN* phase) {
  52   assert(in(1) != this, "Must already have called Value");

 821 
 822 //------------------------------Idealize---------------------------------------
 823 Node *CmpINode::Ideal( PhaseGVN *phase, bool can_reshape ) {
 824   if (phase->type(in(2))->higher_equal(TypeInt::ZERO)) {
 825     switch (in(1)->Opcode()) {
 826     case Op_CmpL3:              // Collapse a CmpL3/CmpI into a CmpL
 827       return new CmpLNode(in(1)->in(1),in(1)->in(2));
 828     case Op_CmpF3:              // Collapse a CmpF3/CmpI into a CmpF
 829       return new CmpFNode(in(1)->in(1),in(1)->in(2));
 830     case Op_CmpD3:              // Collapse a CmpD3/CmpI into a CmpD
 831       return new CmpDNode(in(1)->in(1),in(1)->in(2));
 832     //case Op_SubI:
 833       // If (x - y) cannot overflow, then ((x - y) <?> 0)
 834       // can be turned into (x <?> y).
 835       // This is handled (with more general cases) by Ideal_sub_algebra.
 836     }
 837   }
 838   return NULL;                  // No change
 839 }
 840 
 841 Node *CmpLNode::Ideal( PhaseGVN *phase, bool can_reshape ) {







 842   const TypeLong *t2 = phase->type(in(2))->isa_long();
 843   if (Opcode() == Op_CmpL && in(1)->Opcode() == Op_ConvI2L && t2 && t2->is_con()) {
 844     const jlong con = t2->get_con();
 845     if (con >= min_jint && con <= max_jint) {
 846       return new CmpINode(in(1)->in(1), phase->intcon((jint)con));
 847     }
 848   }
 849   return NULL;
 850 }
 851 

























 852 //=============================================================================
 853 // Simplify a CmpL (compare 2 longs ) node, based on local information.
 854 // If both inputs are constants, compare them.
 855 const Type *CmpLNode::sub( const Type *t1, const Type *t2 ) const {
 856   const TypeLong *r0 = t1->is_long(); // Handy access
 857   const TypeLong *r1 = t2->is_long();
 858 
 859   if( r0->_hi < r1->_lo )       // Range is always low?
 860     return TypeInt::CC_LT;
 861   else if( r0->_lo > r1->_hi )  // Range is always high?
 862     return TypeInt::CC_GT;
 863 
 864   else if( r0->is_con() && r1->is_con() ) { // comparing constants?
 865     assert(r0->get_con() == r1->get_con(), "must be equal");
 866     return TypeInt::CC_EQ;      // Equal results.
 867   } else if( r0->_hi == r1->_lo ) // Range is never high?
 868     return TypeInt::CC_LE;
 869   else if( r0->_lo == r1->_hi ) // Range is never low?
 870     return TypeInt::CC_GE;
 871   return TypeInt::CC;           // else use worst case results

 990         klass1->is_loaded() && !klass1->is_interface() &&
 991         (!klass0->is_obj_array_klass() ||
 992          !klass0->as_obj_array_klass()->base_element_klass()->is_interface()) &&
 993         (!klass1->is_obj_array_klass() ||
 994          !klass1->as_obj_array_klass()->base_element_klass()->is_interface())) {
 995       bool unrelated_classes = false;
 996       // See if neither subclasses the other, or if the class on top
 997       // is precise.  In either of these cases, the compare is known
 998       // to fail if at least one of the pointers is provably not null.
 999       if (klass0->equals(klass1)) {  // if types are unequal but klasses are equal
1000         // Do nothing; we know nothing for imprecise types
1001       } else if (klass0->is_subtype_of(klass1)) {
1002         // If klass1's type is PRECISE, then classes are unrelated.
1003         unrelated_classes = xklass1;
1004       } else if (klass1->is_subtype_of(klass0)) {
1005         // If klass0's type is PRECISE, then classes are unrelated.
1006         unrelated_classes = xklass0;
1007       } else {                  // Neither subtypes the other
1008         unrelated_classes = true;
1009       }
















1010       if (unrelated_classes) {
1011         // The oops classes are known to be unrelated. If the joined PTRs of
1012         // two oops is not Null and not Bottom, then we are sure that one
1013         // of the two oops is non-null, and the comparison will always fail.
1014         TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
1015         if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
1016           return TypeInt::CC_GT;
1017         }
1018       }
1019     }
1020   }
1021 
1022   // Known constants can be compared exactly
1023   // Null can be distinguished from any NotNull pointers
1024   // Unknown inputs makes an unknown result
1025   if( r0->singleton() ) {
1026     intptr_t bits0 = r0->get_con();
1027     if( r1->singleton() )
1028       return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT;
1029     return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC;

1075   if (!mirror_type) return NULL;
1076 
1077   // x.getClass() == int.class can never be true (for all primitive types)
1078   // Return a ConP(NULL) node for this case.
1079   if (mirror_type->is_classless()) {
1080     return phase->makecon(TypePtr::NULL_PTR);
1081   }
1082 
1083   // return the ConP(Foo.klass)
1084   assert(mirror_type->is_klass(), "mirror_type should represent a Klass*");
1085   return phase->makecon(TypeKlassPtr::make(mirror_type->as_klass()));
1086 }
1087 
1088 //------------------------------Ideal------------------------------------------
1089 // Normalize comparisons between Java mirror loads to compare the klass instead.
1090 //
1091 // Also check for the case of comparing an unknown klass loaded from the primary
1092 // super-type array vs a known klass with no subtypes.  This amounts to
1093 // checking to see an unknown klass subtypes a known klass with no subtypes;
1094 // this only happens on an exact match.  We can shorten this test by 1 load.
1095 Node *CmpPNode::Ideal( PhaseGVN *phase, bool can_reshape ) {






1096   // Normalize comparisons between Java mirrors into comparisons of the low-
1097   // level klass, where a dependent load could be shortened.
1098   //
1099   // The new pattern has a nice effect of matching the same pattern used in the
1100   // fast path of instanceof/checkcast/Class.isInstance(), which allows
1101   // redundant exact type check be optimized away by GVN.
1102   // For example, in
1103   //   if (x.getClass() == Foo.class) {
1104   //     Foo foo = (Foo) x;
1105   //     // ... use a ...
1106   //   }
1107   // a CmpPNode could be shared between if_acmpne and checkcast
1108   {
1109     Node* k1 = isa_java_mirror_load(phase, in(1));
1110     Node* k2 = isa_java_mirror_load(phase, in(2));
1111     Node* conk2 = isa_const_java_mirror(phase, in(2));
1112 
1113     if (k1 && (k2 || conk2)) {
1114       Node* lhs = k1;
1115       Node* rhs = (k2 != NULL) ? k2 : conk2;

1147         superklass->is_abstract()) {
1148       // Make it come out always false:
1149       this->set_req(2, phase->makecon(TypePtr::NULL_PTR));
1150       return this;
1151     }
1152   }
1153 
1154   // Check for a LoadKlass from primary supertype array.
1155   // Any nested loadklass from loadklass+con must be from the p.s. array.
1156   if (ldk2->is_DecodeNKlass()) {
1157     // Keep ldk2 as DecodeN since it could be used in CmpP below.
1158     if (ldk2->in(1)->Opcode() != Op_LoadNKlass )
1159       return NULL;
1160   } else if (ldk2->Opcode() != Op_LoadKlass)
1161     return NULL;
1162 
1163   // Verify that we understand the situation
1164   if (con2 != (intptr_t) superklass->super_check_offset())
1165     return NULL;                // Might be element-klass loading from array klass
1166 








1167   // If 'superklass' has no subklasses and is not an interface, then we are
1168   // assured that the only input which will pass the type check is
1169   // 'superklass' itself.
1170   //
1171   // We could be more liberal here, and allow the optimization on interfaces
1172   // which have a single implementor.  This would require us to increase the
1173   // expressiveness of the add_dependency() mechanism.
1174   // %%% Do this after we fix TypeOopPtr:  Deps are expressive enough now.
1175 
1176   // Object arrays must have their base element have no subtypes
1177   while (superklass->is_obj_array_klass()) {
1178     ciType* elem = superklass->as_obj_array_klass()->element_type();
1179     superklass = elem->as_klass();
1180   }
1181   if (superklass->is_instance_klass()) {
1182     ciInstanceKlass* ik = superklass->as_instance_klass();
1183     if (ik->has_subklass() || ik->is_interface())  return NULL;
1184     // Add a dependency if there is a chance that a subclass will be added later.
1185     if (!ik->is_final()) {
1186       phase->C->dependencies()->assert_leaf_type(ik);

1290     if( t2_value_as_double == (double)t2_value_as_float ) {
1291       // Test value can be represented as a float
1292       // Eliminate the conversion to double and create new comparison
1293       Node *new_in1 = in(idx_f2d)->in(1);
1294       Node *new_in2 = phase->makecon( TypeF::make(t2_value_as_float) );
1295       if( idx_f2d != 1 ) {      // Must flip args to match original order
1296         Node *tmp = new_in1;
1297         new_in1 = new_in2;
1298         new_in2 = tmp;
1299       }
1300       CmpFNode *new_cmp = (Opcode() == Op_CmpD3)
1301         ? new CmpF3Node( new_in1, new_in2 )
1302         : new CmpFNode ( new_in1, new_in2 ) ;
1303       return new_cmp;           // Changed to CmpFNode
1304     }
1305     // Testing value required the precision of a double
1306   }
1307   return NULL;                  // No change
1308 }
1309 







































1310 
1311 //=============================================================================
1312 //------------------------------cc2logical-------------------------------------
1313 // Convert a condition code type to a logical type
1314 const Type *BoolTest::cc2logical( const Type *CC ) const {
1315   if( CC == Type::TOP ) return Type::TOP;
1316   if( CC->base() != Type::Int ) return TypeInt::BOOL; // Bottom or worse
1317   const TypeInt *ti = CC->is_int();
1318   if( ti->is_con() ) {          // Only 1 kind of condition codes set?
1319     // Match low order 2 bits
1320     int tmp = ((ti->get_con()&3) == (_test&3)) ? 1 : 0;
1321     if( _test & 4 ) tmp = 1-tmp;     // Optionally complement result
1322     return TypeInt::make(tmp);       // Boolean result
1323   }
1324 
1325   if( CC == TypeInt::CC_GE ) {
1326     if( _test == ge ) return TypeInt::ONE;
1327     if( _test == lt ) return TypeInt::ZERO;
1328   }
1329   if( CC == TypeInt::CC_LE ) {

  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileLog.hpp"
  27 #include "gc/shared/barrierSet.hpp"
  28 #include "gc/shared/c2/barrierSetC2.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "opto/addnode.hpp"
  31 #include "opto/callnode.hpp"
  32 #include "opto/cfgnode.hpp"
  33 #include "opto/inlinetypenode.hpp"
  34 #include "opto/loopnode.hpp"
  35 #include "opto/matcher.hpp"
  36 #include "opto/movenode.hpp"
  37 #include "opto/mulnode.hpp"
  38 #include "opto/opcodes.hpp"
  39 #include "opto/phaseX.hpp"
  40 #include "opto/subnode.hpp"
  41 #include "runtime/sharedRuntime.hpp"
  42 
  43 // Portions of code courtesy of Clifford Click
  44 
  45 // Optimization - Graph Style
  46 
  47 #include "math.h"
  48 
  49 //=============================================================================
  50 //------------------------------Identity---------------------------------------
  51 // If right input is a constant 0, return the left input.
  52 Node* SubNode::Identity(PhaseGVN* phase) {
  53   assert(in(1) != this, "Must already have called Value");

 822 
 823 //------------------------------Idealize---------------------------------------
 824 Node *CmpINode::Ideal( PhaseGVN *phase, bool can_reshape ) {
 825   if (phase->type(in(2))->higher_equal(TypeInt::ZERO)) {
 826     switch (in(1)->Opcode()) {
 827     case Op_CmpL3:              // Collapse a CmpL3/CmpI into a CmpL
 828       return new CmpLNode(in(1)->in(1),in(1)->in(2));
 829     case Op_CmpF3:              // Collapse a CmpF3/CmpI into a CmpF
 830       return new CmpFNode(in(1)->in(1),in(1)->in(2));
 831     case Op_CmpD3:              // Collapse a CmpD3/CmpI into a CmpD
 832       return new CmpDNode(in(1)->in(1),in(1)->in(2));
 833     //case Op_SubI:
 834       // If (x - y) cannot overflow, then ((x - y) <?> 0)
 835       // can be turned into (x <?> y).
 836       // This is handled (with more general cases) by Ideal_sub_algebra.
 837     }
 838   }
 839   return NULL;                  // No change
 840 }
 841 
 842 //------------------------------Ideal------------------------------------------
 843 Node* CmpLNode::Ideal(PhaseGVN* phase, bool can_reshape) {
 844   Node* a = NULL;
 845   Node* b = NULL;
 846   if (is_double_null_check(phase, a, b) && (phase->type(a)->is_zero_type() || phase->type(b)->is_zero_type())) {
 847     // Degraded to a simple null check, use old acmp
 848     return new CmpPNode(a, b);
 849   }
 850   const TypeLong *t2 = phase->type(in(2))->isa_long();
 851   if (Opcode() == Op_CmpL && in(1)->Opcode() == Op_ConvI2L && t2 && t2->is_con()) {
 852     const jlong con = t2->get_con();
 853     if (con >= min_jint && con <= max_jint) {
 854       return new CmpINode(in(1)->in(1), phase->intcon((jint)con));
 855     }
 856   }
 857   return NULL;
 858 }
 859 
 860 // Match double null check emitted by Compile::optimize_acmp()
 861 bool CmpLNode::is_double_null_check(PhaseGVN* phase, Node*& a, Node*& b) const {
 862   if (in(1)->Opcode() == Op_OrL &&
 863       in(1)->in(1)->Opcode() == Op_CastP2X &&
 864       in(1)->in(2)->Opcode() == Op_CastP2X &&
 865       in(2)->bottom_type()->is_zero_type()) {
 866     assert(EnableValhalla, "unexpected double null check");
 867     a = in(1)->in(1)->in(1);
 868     b = in(1)->in(2)->in(1);
 869     return true;
 870   }
 871   return false;
 872 }
 873 
 874 //------------------------------Value------------------------------------------
 875 const Type* CmpLNode::Value(PhaseGVN* phase) const {
 876   Node* a = NULL;
 877   Node* b = NULL;
 878   if (is_double_null_check(phase, a, b) && (!phase->type(a)->maybe_null() || !phase->type(b)->maybe_null())) {
 879     // One operand is never NULL, emit constant false
 880     return TypeInt::CC_GT;
 881   }
 882   return SubNode::Value(phase);
 883 }
 884 
 885 //=============================================================================
 886 // Simplify a CmpL (compare 2 longs ) node, based on local information.
 887 // If both inputs are constants, compare them.
 888 const Type *CmpLNode::sub( const Type *t1, const Type *t2 ) const {
 889   const TypeLong *r0 = t1->is_long(); // Handy access
 890   const TypeLong *r1 = t2->is_long();
 891 
 892   if( r0->_hi < r1->_lo )       // Range is always low?
 893     return TypeInt::CC_LT;
 894   else if( r0->_lo > r1->_hi )  // Range is always high?
 895     return TypeInt::CC_GT;
 896 
 897   else if( r0->is_con() && r1->is_con() ) { // comparing constants?
 898     assert(r0->get_con() == r1->get_con(), "must be equal");
 899     return TypeInt::CC_EQ;      // Equal results.
 900   } else if( r0->_hi == r1->_lo ) // Range is never high?
 901     return TypeInt::CC_LE;
 902   else if( r0->_lo == r1->_hi ) // Range is never low?
 903     return TypeInt::CC_GE;
 904   return TypeInt::CC;           // else use worst case results

1023         klass1->is_loaded() && !klass1->is_interface() &&
1024         (!klass0->is_obj_array_klass() ||
1025          !klass0->as_obj_array_klass()->base_element_klass()->is_interface()) &&
1026         (!klass1->is_obj_array_klass() ||
1027          !klass1->as_obj_array_klass()->base_element_klass()->is_interface())) {
1028       bool unrelated_classes = false;
1029       // See if neither subclasses the other, or if the class on top
1030       // is precise.  In either of these cases, the compare is known
1031       // to fail if at least one of the pointers is provably not null.
1032       if (klass0->equals(klass1)) {  // if types are unequal but klasses are equal
1033         // Do nothing; we know nothing for imprecise types
1034       } else if (klass0->is_subtype_of(klass1)) {
1035         // If klass1's type is PRECISE, then classes are unrelated.
1036         unrelated_classes = xklass1;
1037       } else if (klass1->is_subtype_of(klass0)) {
1038         // If klass0's type is PRECISE, then classes are unrelated.
1039         unrelated_classes = xklass0;
1040       } else {                  // Neither subtypes the other
1041         unrelated_classes = true;
1042       }
1043       if (!unrelated_classes) {
1044         // Handle inline type arrays
1045         if ((r0->flatten_array() && (!r1->can_be_inline_type() || (klass1->is_inlinetype() && !klass1->flatten_array()))) ||
1046             (r1->flatten_array() && (!r0->can_be_inline_type() || (klass0->is_inlinetype() && !klass0->flatten_array())))) {
1047           // One type is flattened in arrays but the other type is not. Must be unrelated.
1048           unrelated_classes = true;
1049         } else if ((r0->is_not_flat() && klass1->is_flat_array_klass()) ||
1050                    (r1->is_not_flat() && klass0->is_flat_array_klass())) {
1051           // One type is a non-flattened array and the other type is a flattened array. Must be unrelated.
1052           unrelated_classes = true;
1053         } else if ((r0->is_not_null_free() && klass1->is_array_klass() && klass1->as_array_klass()->is_elem_null_free()) ||
1054                    (r1->is_not_null_free() && klass0->is_array_klass() && klass0->as_array_klass()->is_elem_null_free())) {
1055           // One type is a non-null-free array and the other type is a null-free array. Must be unrelated.
1056           unrelated_classes = true;
1057         }
1058       }
1059       if (unrelated_classes) {
1060         // The oops classes are known to be unrelated. If the joined PTRs of
1061         // two oops is not Null and not Bottom, then we are sure that one
1062         // of the two oops is non-null, and the comparison will always fail.
1063         TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
1064         if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
1065           return TypeInt::CC_GT;
1066         }
1067       }
1068     }
1069   }
1070 
1071   // Known constants can be compared exactly
1072   // Null can be distinguished from any NotNull pointers
1073   // Unknown inputs makes an unknown result
1074   if( r0->singleton() ) {
1075     intptr_t bits0 = r0->get_con();
1076     if( r1->singleton() )
1077       return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT;
1078     return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC;

1124   if (!mirror_type) return NULL;
1125 
1126   // x.getClass() == int.class can never be true (for all primitive types)
1127   // Return a ConP(NULL) node for this case.
1128   if (mirror_type->is_classless()) {
1129     return phase->makecon(TypePtr::NULL_PTR);
1130   }
1131 
1132   // return the ConP(Foo.klass)
1133   assert(mirror_type->is_klass(), "mirror_type should represent a Klass*");
1134   return phase->makecon(TypeKlassPtr::make(mirror_type->as_klass()));
1135 }
1136 
1137 //------------------------------Ideal------------------------------------------
1138 // Normalize comparisons between Java mirror loads to compare the klass instead.
1139 //
1140 // Also check for the case of comparing an unknown klass loaded from the primary
1141 // super-type array vs a known klass with no subtypes.  This amounts to
1142 // checking to see an unknown klass subtypes a known klass with no subtypes;
1143 // this only happens on an exact match.  We can shorten this test by 1 load.
1144 Node* CmpPNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1145   if (in(1)->is_InlineTypePtr() && phase->type(in(2))->is_zero_type()) {
1146     // Null checking a scalarized but nullable inline type. Check the is_init
1147     // input instead of the oop input to avoid keeping buffer allocations alive.
1148     return new CmpINode(in(1)->as_InlineTypePtr()->get_is_init(), phase->intcon(0));
1149   }
1150 
1151   // Normalize comparisons between Java mirrors into comparisons of the low-
1152   // level klass, where a dependent load could be shortened.
1153   //
1154   // The new pattern has a nice effect of matching the same pattern used in the
1155   // fast path of instanceof/checkcast/Class.isInstance(), which allows
1156   // redundant exact type check be optimized away by GVN.
1157   // For example, in
1158   //   if (x.getClass() == Foo.class) {
1159   //     Foo foo = (Foo) x;
1160   //     // ... use a ...
1161   //   }
1162   // a CmpPNode could be shared between if_acmpne and checkcast
1163   {
1164     Node* k1 = isa_java_mirror_load(phase, in(1));
1165     Node* k2 = isa_java_mirror_load(phase, in(2));
1166     Node* conk2 = isa_const_java_mirror(phase, in(2));
1167 
1168     if (k1 && (k2 || conk2)) {
1169       Node* lhs = k1;
1170       Node* rhs = (k2 != NULL) ? k2 : conk2;

1202         superklass->is_abstract()) {
1203       // Make it come out always false:
1204       this->set_req(2, phase->makecon(TypePtr::NULL_PTR));
1205       return this;
1206     }
1207   }
1208 
1209   // Check for a LoadKlass from primary supertype array.
1210   // Any nested loadklass from loadklass+con must be from the p.s. array.
1211   if (ldk2->is_DecodeNKlass()) {
1212     // Keep ldk2 as DecodeN since it could be used in CmpP below.
1213     if (ldk2->in(1)->Opcode() != Op_LoadNKlass )
1214       return NULL;
1215   } else if (ldk2->Opcode() != Op_LoadKlass)
1216     return NULL;
1217 
1218   // Verify that we understand the situation
1219   if (con2 != (intptr_t) superklass->super_check_offset())
1220     return NULL;                // Might be element-klass loading from array klass
1221 
1222   // Do not fold the subtype check to an array klass pointer comparison for [V? arrays.
1223   // [QMyValue is a subtype of [LMyValue but the klass for [QMyValue is not equal to
1224   // the klass for [LMyValue. Do not bypass the klass load from the primary supertype array.
1225   if (superklass->is_obj_array_klass() && !superklass->as_array_klass()->is_elem_null_free() &&
1226       superklass->as_array_klass()->element_klass()->is_inlinetype()) {
1227     return NULL;
1228   }
1229 
1230   // If 'superklass' has no subklasses and is not an interface, then we are
1231   // assured that the only input which will pass the type check is
1232   // 'superklass' itself.
1233   //
1234   // We could be more liberal here, and allow the optimization on interfaces
1235   // which have a single implementor.  This would require us to increase the
1236   // expressiveness of the add_dependency() mechanism.
1237   // %%% Do this after we fix TypeOopPtr:  Deps are expressive enough now.
1238 
1239   // Object arrays must have their base element have no subtypes
1240   while (superklass->is_obj_array_klass()) {
1241     ciType* elem = superklass->as_obj_array_klass()->element_type();
1242     superklass = elem->as_klass();
1243   }
1244   if (superklass->is_instance_klass()) {
1245     ciInstanceKlass* ik = superklass->as_instance_klass();
1246     if (ik->has_subklass() || ik->is_interface())  return NULL;
1247     // Add a dependency if there is a chance that a subclass will be added later.
1248     if (!ik->is_final()) {
1249       phase->C->dependencies()->assert_leaf_type(ik);

1353     if( t2_value_as_double == (double)t2_value_as_float ) {
1354       // Test value can be represented as a float
1355       // Eliminate the conversion to double and create new comparison
1356       Node *new_in1 = in(idx_f2d)->in(1);
1357       Node *new_in2 = phase->makecon( TypeF::make(t2_value_as_float) );
1358       if( idx_f2d != 1 ) {      // Must flip args to match original order
1359         Node *tmp = new_in1;
1360         new_in1 = new_in2;
1361         new_in2 = tmp;
1362       }
1363       CmpFNode *new_cmp = (Opcode() == Op_CmpD3)
1364         ? new CmpF3Node( new_in1, new_in2 )
1365         : new CmpFNode ( new_in1, new_in2 ) ;
1366       return new_cmp;           // Changed to CmpFNode
1367     }
1368     // Testing value required the precision of a double
1369   }
1370   return NULL;                  // No change
1371 }
1372 
1373 //=============================================================================
1374 //------------------------------Value------------------------------------------
1375 const Type* FlatArrayCheckNode::Value(PhaseGVN* phase) const {
1376   bool all_not_flat = true;
1377   for (uint i = Array; i < req(); ++i) {
1378     Node* array = in(i);
1379     if (!array->is_top()) {
1380       const Type* t = phase->type(array);
1381       if (t == Type::TOP) {
1382         return Type::TOP;
1383       } else if (t->is_aryptr()->is_flat()) {
1384         // One of the input arrays is flat, check always passes
1385         return TypeInt::CC_EQ;
1386       } else if (!t->is_aryptr()->is_not_flat()) {
1387         // One of the input arrays might be flat
1388         all_not_flat = false;
1389       }
1390     }
1391   }
1392   if (all_not_flat) {
1393     // None of the input arrays can be flat, check always fails
1394     return TypeInt::CC_GT;
1395   }
1396   return TypeInt::CC;
1397 }
1398 
1399 //------------------------------Ideal------------------------------------------
1400 Node* FlatArrayCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
1401   bool changed = false;
1402   // Remove array inputs that are known to be non-flat
1403   for (uint i = Array; i < req(); ++i) {
1404     const TypeAryPtr* t = phase->type(in(i))->isa_aryptr();
1405     if (t != NULL && t->is_not_flat()) {
1406       set_req(i, phase->C->top());
1407       changed = true;
1408     }
1409   }
1410   return changed ? this : NULL;
1411 }
1412 
1413 //=============================================================================
1414 //------------------------------cc2logical-------------------------------------
1415 // Convert a condition code type to a logical type
1416 const Type *BoolTest::cc2logical( const Type *CC ) const {
1417   if( CC == Type::TOP ) return Type::TOP;
1418   if( CC->base() != Type::Int ) return TypeInt::BOOL; // Bottom or worse
1419   const TypeInt *ti = CC->is_int();
1420   if( ti->is_con() ) {          // Only 1 kind of condition codes set?
1421     // Match low order 2 bits
1422     int tmp = ((ti->get_con()&3) == (_test&3)) ? 1 : 0;
1423     if( _test & 4 ) tmp = 1-tmp;     // Optionally complement result
1424     return TypeInt::make(tmp);       // Boolean result
1425   }
1426 
1427   if( CC == TypeInt::CC_GE ) {
1428     if( _test == ge ) return TypeInt::ONE;
1429     if( _test == lt ) return TypeInt::ZERO;
1430   }
1431   if( CC == TypeInt::CC_LE ) {
< prev index next >