< prev index next >

src/hotspot/share/opto/subtypenode.cpp

Print this page

 30 #include "opto/phaseX.hpp"
 31 #include "opto/rootnode.hpp"
 32 #include "opto/subnode.hpp"
 33 #include "opto/subtypenode.hpp"
 34 
 35 const Type* SubTypeCheckNode::sub(const Type* sub_t, const Type* super_t) const {
 36   const TypeKlassPtr* superk = super_t->isa_klassptr();
 37   assert(sub_t != Type::TOP && !TypePtr::NULL_PTR->higher_equal(sub_t), "should be not null");
 38   const TypeKlassPtr* subk = sub_t->isa_klassptr() ? sub_t->is_klassptr() : sub_t->is_oopptr()->as_klass_type();
 39 
 40   // Oop can't be a subtype of abstract type that has no subclass.
 41   if (sub_t->isa_oopptr() && superk->isa_instklassptr() && superk->klass_is_exact()) {
 42     ciKlass* superklass = superk->exact_klass();
 43     if (!superklass->is_interface() && superklass->is_abstract() &&
 44         !superklass->as_instance_klass()->has_subklass()) {
 45       Compile::current()->dependencies()->assert_leaf_type(superklass);
 46       return TypeInt::CC_GT;
 47     }
 48   }
 49 





















 50   if (subk != nullptr) {
 51     switch (Compile::current()->static_subtype_check(superk, subk, false)) {
 52       case Compile::SSC_always_false:
 53         return TypeInt::CC_GT;
 54       case Compile::SSC_always_true:
 55         return TypeInt::CC_EQ;
 56       case Compile::SSC_easy_test:
 57       case Compile::SSC_full_test:
 58         break;
 59       default:
 60         ShouldNotReachHere();
 61     }
 62   }
 63 
 64   return bottom_type();
 65 }
 66 
 67 Node *SubTypeCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
 68   Node* obj_or_subklass = in(ObjOrSubKlass);
 69   Node* superklass = in(SuperKlass);

227   return subklass;
228 }
229 #endif
230 
231 uint SubTypeCheckNode::size_of() const {
232   return sizeof(*this);
233 }
234 
235 uint SubTypeCheckNode::hash() const {
236   return NO_HASH;
237 }
238 
239 #ifndef PRODUCT
240 void SubTypeCheckNode::dump_spec(outputStream* st) const {
241   if (_method != nullptr) {
242     st->print(" profiled at:");
243     _method->print_short_name(st);
244     st->print(":%d", _bci);
245   }
246 }
247 #endif

 30 #include "opto/phaseX.hpp"
 31 #include "opto/rootnode.hpp"
 32 #include "opto/subnode.hpp"
 33 #include "opto/subtypenode.hpp"
 34 
 35 const Type* SubTypeCheckNode::sub(const Type* sub_t, const Type* super_t) const {
 36   const TypeKlassPtr* superk = super_t->isa_klassptr();
 37   assert(sub_t != Type::TOP && !TypePtr::NULL_PTR->higher_equal(sub_t), "should be not null");
 38   const TypeKlassPtr* subk = sub_t->isa_klassptr() ? sub_t->is_klassptr() : sub_t->is_oopptr()->as_klass_type();
 39 
 40   // Oop can't be a subtype of abstract type that has no subclass.
 41   if (sub_t->isa_oopptr() && superk->isa_instklassptr() && superk->klass_is_exact()) {
 42     ciKlass* superklass = superk->exact_klass();
 43     if (!superklass->is_interface() && superklass->is_abstract() &&
 44         !superklass->as_instance_klass()->has_subklass()) {
 45       Compile::current()->dependencies()->assert_leaf_type(superklass);
 46       return TypeInt::CC_GT;
 47     }
 48   }
 49 
 50   // FIXME: shouldn't this be encoded in helper methods of the type system (maybe_java_subtype_of() etc.?)
 51   // Similar to logic in CmpPNode::sub()
 52   bool unrelated_classes = false;
 53   // Handle inline type arrays
 54   if (subk->flat_in_array() && superk->not_flat_in_array()) {
 55     // The subtype is in flat arrays and the supertype is not in flat arrays. Must be unrelated.
 56     unrelated_classes = true;
 57   } else if (subk->is_not_flat() && superk->is_flat()) {
 58     // The subtype is a non-flat array and the supertype is a flat array. Must be unrelated.
 59     unrelated_classes = true;
 60   } else if (subk->is_not_null_free() && superk->is_null_free()) {
 61     // The subtype is a nullable array and the supertype is null-free array. Must be unrelated.
 62     unrelated_classes = true;
 63   }
 64   if (unrelated_classes) {
 65     TypePtr::PTR jp = sub_t->is_ptr()->join_ptr(super_t->is_ptr()->_ptr);
 66     if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
 67       return TypeInt::CC_GT;
 68     }
 69   }
 70 
 71   if (subk != nullptr) {
 72     switch (Compile::current()->static_subtype_check(superk, subk, false)) {
 73       case Compile::SSC_always_false:
 74         return TypeInt::CC_GT;
 75       case Compile::SSC_always_true:
 76         return TypeInt::CC_EQ;
 77       case Compile::SSC_easy_test:
 78       case Compile::SSC_full_test:
 79         break;
 80       default:
 81         ShouldNotReachHere();
 82     }
 83   }
 84 
 85   return bottom_type();
 86 }
 87 
 88 Node *SubTypeCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
 89   Node* obj_or_subklass = in(ObjOrSubKlass);
 90   Node* superklass = in(SuperKlass);

248   return subklass;
249 }
250 #endif
251 
252 uint SubTypeCheckNode::size_of() const {
253   return sizeof(*this);
254 }
255 
256 uint SubTypeCheckNode::hash() const {
257   return NO_HASH;
258 }
259 
260 #ifndef PRODUCT
261 void SubTypeCheckNode::dump_spec(outputStream* st) const {
262   if (_method != nullptr) {
263     st->print(" profiled at:");
264     _method->print_short_name(st);
265     st->print(":%d", _bci);
266   }
267 }
268 #endif
< prev index next >