29 #include "opto/phaseX.hpp"
30 #include "opto/rootnode.hpp"
31 #include "opto/subnode.hpp"
32 #include "opto/subtypenode.hpp"
33
34 const Type* SubTypeCheckNode::sub(const Type* sub_t, const Type* super_t) const {
35 const TypeKlassPtr* superk = super_t->isa_klassptr();
36 assert(sub_t != Type::TOP && !TypePtr::NULL_PTR->higher_equal(sub_t), "should be not null");
37 const TypeKlassPtr* subk = sub_t->isa_klassptr() ? sub_t->is_klassptr() : sub_t->is_oopptr()->as_klass_type();
38
39 // Oop can't be a subtype of abstract type that has no subclass.
40 if (sub_t->isa_oopptr() && superk->isa_instklassptr() && superk->klass_is_exact()) {
41 ciKlass* superklass = superk->exact_klass();
42 if (!superklass->is_interface() && superklass->is_abstract() &&
43 !superklass->as_instance_klass()->has_subklass()) {
44 Compile::current()->dependencies()->assert_leaf_type(superklass);
45 return TypeInt::CC_GT;
46 }
47 }
48
49 if (subk != nullptr) {
50 switch (Compile::current()->static_subtype_check(superk, subk, false)) {
51 case Compile::SSC_always_false:
52 return TypeInt::CC_GT;
53 case Compile::SSC_always_true:
54 return TypeInt::CC_EQ;
55 case Compile::SSC_easy_test:
56 case Compile::SSC_full_test:
57 break;
58 default:
59 ShouldNotReachHere();
60 }
61 }
62
63 return bottom_type();
64 }
65
66 Node *SubTypeCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
67 Node* obj_or_subklass = in(ObjOrSubKlass);
68 Node* superklass = in(SuperKlass);
226 return subklass;
227 }
228 #endif
229
230 uint SubTypeCheckNode::size_of() const {
231 return sizeof(*this);
232 }
233
234 uint SubTypeCheckNode::hash() const {
235 return NO_HASH;
236 }
237
238 #ifndef PRODUCT
239 void SubTypeCheckNode::dump_spec(outputStream* st) const {
240 if (_method != nullptr) {
241 st->print(" profiled at:");
242 _method->print_short_name(st);
243 st->print(":%d", _bci);
244 }
245 }
246 #endif
|
29 #include "opto/phaseX.hpp"
30 #include "opto/rootnode.hpp"
31 #include "opto/subnode.hpp"
32 #include "opto/subtypenode.hpp"
33
34 const Type* SubTypeCheckNode::sub(const Type* sub_t, const Type* super_t) const {
35 const TypeKlassPtr* superk = super_t->isa_klassptr();
36 assert(sub_t != Type::TOP && !TypePtr::NULL_PTR->higher_equal(sub_t), "should be not null");
37 const TypeKlassPtr* subk = sub_t->isa_klassptr() ? sub_t->is_klassptr() : sub_t->is_oopptr()->as_klass_type();
38
39 // Oop can't be a subtype of abstract type that has no subclass.
40 if (sub_t->isa_oopptr() && superk->isa_instklassptr() && superk->klass_is_exact()) {
41 ciKlass* superklass = superk->exact_klass();
42 if (!superklass->is_interface() && superklass->is_abstract() &&
43 !superklass->as_instance_klass()->has_subklass()) {
44 Compile::current()->dependencies()->assert_leaf_type(superklass);
45 return TypeInt::CC_GT;
46 }
47 }
48
49 // FIXME: shouldn't this be encoded in helper methods of the type system (maybe_java_subtype_of() etc.?)
50 // Similar to logic in CmpPNode::sub()
51 bool unrelated_classes = false;
52 // Handle inline type arrays
53 if (subk->flat_in_array() && superk->not_flat_in_array()) {
54 // The subtype is in flat arrays and the supertype is not in flat arrays. Must be unrelated.
55 unrelated_classes = true;
56 } else if (subk->is_not_flat() && superk->is_flat()) {
57 // The subtype is a non-flat array and the supertype is a flat array. Must be unrelated.
58 unrelated_classes = true;
59 } else if (subk->is_not_null_free() && superk->is_null_free()) {
60 // The subtype is a nullable array and the supertype is null-free array. Must be unrelated.
61 unrelated_classes = true;
62 }
63 if (unrelated_classes) {
64 TypePtr::PTR jp = sub_t->is_ptr()->join_ptr(super_t->is_ptr()->_ptr);
65 if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
66 return TypeInt::CC_GT;
67 }
68 }
69
70 if (subk != nullptr) {
71 switch (Compile::current()->static_subtype_check(superk, subk, false)) {
72 case Compile::SSC_always_false:
73 return TypeInt::CC_GT;
74 case Compile::SSC_always_true:
75 return TypeInt::CC_EQ;
76 case Compile::SSC_easy_test:
77 case Compile::SSC_full_test:
78 break;
79 default:
80 ShouldNotReachHere();
81 }
82 }
83
84 return bottom_type();
85 }
86
87 Node *SubTypeCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
88 Node* obj_or_subklass = in(ObjOrSubKlass);
89 Node* superklass = in(SuperKlass);
247 return subklass;
248 }
249 #endif
250
251 uint SubTypeCheckNode::size_of() const {
252 return sizeof(*this);
253 }
254
255 uint SubTypeCheckNode::hash() const {
256 return NO_HASH;
257 }
258
259 #ifndef PRODUCT
260 void SubTypeCheckNode::dump_spec(outputStream* st) const {
261 if (_method != nullptr) {
262 st->print(" profiled at:");
263 _method->print_short_name(st);
264 st->print(":%d", _bci);
265 }
266 }
267 #endif
|