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 if (subk->is_same_java_type_as(superk) && !sub_t->maybe_null()) {
47 // The super_t has no subclasses, and sub_t has the same type and is not null,
48 // hence the check should always evaluate to EQ. However, this is an impossible
49 // situation since super_t is also abstract, and hence sub_t cannot have the
50 // same type and be non-null.
51 // Still, if the non-static method of an abstract class without subclasses is
52 // force-compiled, the Param0 has the self/this pointer with NotNull. This
53 // method would now never be called, because of the leaf-type dependency. Hence,
54 // just for consistency with verification, we return EQ.
55 return TypeInt::CC_EQ;
56 }
57 // subk is either a supertype of superk, or null. In either case, superk is a subtype.
58 return TypeInt::CC_GT;
59 }
60 }
61
62 if (subk != nullptr) {
63 switch (Compile::current()->static_subtype_check(superk, subk, false)) {
64 case Compile::SSC_always_false:
65 return TypeInt::CC_GT;
66 case Compile::SSC_always_true:
67 return TypeInt::CC_EQ;
68 case Compile::SSC_easy_test:
69 case Compile::SSC_full_test:
70 break;
71 default:
72 ShouldNotReachHere();
73 }
74 }
75
76 return bottom_type();
77 }
78
79 Node *SubTypeCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
80 Node* obj_or_subklass = in(ObjOrSubKlass);
81 Node* superklass = in(SuperKlass);
106 if (addr != nullptr) {
107 intptr_t con = 0;
108 Node* obj = AddPNode::Ideal_base_and_offset(addr, phase, con);
109 if (con == oopDesc::klass_offset_in_bytes() && obj != nullptr) {
110 assert(is_oop(phase, obj), "only for oop input");
111 set_req_X(ObjOrSubKlass, obj, phase);
112 return this;
113 }
114 }
115
116 // AllocateNode might have more accurate klass input
117 Node* allocated_klass = AllocateNode::Ideal_klass(obj_or_subklass, phase);
118 if (allocated_klass != nullptr) {
119 assert(is_oop(phase, obj_or_subklass), "only for oop input");
120 set_req_X(ObjOrSubKlass, allocated_klass, phase);
121 return this;
122 }
123
124 // Verify that optimizing the subtype check to a simple code pattern
125 // when possible would not constant fold better
126 assert(verify(phase), "missing Value() optimization");
127
128 return nullptr;
129 }
130
131 #ifdef ASSERT
132 bool SubTypeCheckNode::is_oop(PhaseGVN* phase, Node* n) {
133 const Type* t = phase->type(n);
134 if (!t->isa_oopptr() && t != Type::TOP) {
135 n->dump();
136 t->dump(); tty->cr();
137 return false;
138 }
139 return true;
140 }
141
142 static Node* record_for_cleanup(Node* n, PhaseGVN* phase) {
143 if (phase->is_IterGVN()) {
144 phase->is_IterGVN()->_worklist.push(n); // record for cleanup
145 }
146 return n;
239 return subklass;
240 }
241 #endif
242
243 uint SubTypeCheckNode::size_of() const {
244 return sizeof(*this);
245 }
246
247 uint SubTypeCheckNode::hash() const {
248 return NO_HASH;
249 }
250
251 #ifndef PRODUCT
252 void SubTypeCheckNode::dump_spec(outputStream* st) const {
253 if (_method != nullptr) {
254 st->print(" profiled at: ");
255 _method->print_short_name(st);
256 st->print(":%d", _bci);
257 }
258 }
259 #endif
|
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 if (subk->is_same_java_type_as(superk) && !sub_t->maybe_null()) {
47 // The super_t has no subclasses, and sub_t has the same type and is not null,
48 // hence the check should always evaluate to EQ. However, this is an impossible
49 // situation since super_t is also abstract, and hence sub_t cannot have the
50 // same type and be non-null.
51 // Still, if the non-static method of an abstract class without subclasses is
52 // force-compiled, the Param0 has the self/this pointer with NotNull. This
53 // method would now never be called, because of the leaf-type dependency. Hence,
54 // just for consistency with verification, we return EQ.
55 return TypeInt::CC_EQ;
56 }
57 // subk is either a supertype of superk, or null. In either case, superk is a subtype.
58 return TypeInt::CC_GT;
59 }
60 }
61
62 // FIXME: shouldn't this be encoded in helper methods of the type system (maybe_java_subtype_of() etc.?)
63 // Similar to logic in CmpPNode::sub()
64 bool unrelated_classes = false;
65 // Handle inline type arrays
66 if (subk->flat_in_array() && superk->not_flat_in_array()) {
67 // The subtype is in flat arrays and the supertype is not in flat arrays. Must be unrelated.
68 unrelated_classes = true;
69 } else if (subk->is_not_flat() && superk->is_flat()) {
70 // The subtype is a non-flat array and the supertype is a flat array. Must be unrelated.
71 unrelated_classes = true;
72 } else if (subk->is_not_null_free() && superk->is_null_free()) {
73 // The subtype is a nullable array and the supertype is null-free array. Must be unrelated.
74 unrelated_classes = true;
75 }
76 if (unrelated_classes) {
77 TypePtr::PTR jp = sub_t->is_ptr()->join_ptr(super_t->is_ptr()->_ptr);
78 if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
79 return TypeInt::CC_GT;
80 }
81 }
82
83 if (subk != nullptr) {
84 switch (Compile::current()->static_subtype_check(superk, subk, false)) {
85 case Compile::SSC_always_false:
86 return TypeInt::CC_GT;
87 case Compile::SSC_always_true:
88 return TypeInt::CC_EQ;
89 case Compile::SSC_easy_test:
90 case Compile::SSC_full_test:
91 break;
92 default:
93 ShouldNotReachHere();
94 }
95 }
96
97 return bottom_type();
98 }
99
100 Node *SubTypeCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
101 Node* obj_or_subklass = in(ObjOrSubKlass);
102 Node* superklass = in(SuperKlass);
127 if (addr != nullptr) {
128 intptr_t con = 0;
129 Node* obj = AddPNode::Ideal_base_and_offset(addr, phase, con);
130 if (con == oopDesc::klass_offset_in_bytes() && obj != nullptr) {
131 assert(is_oop(phase, obj), "only for oop input");
132 set_req_X(ObjOrSubKlass, obj, phase);
133 return this;
134 }
135 }
136
137 // AllocateNode might have more accurate klass input
138 Node* allocated_klass = AllocateNode::Ideal_klass(obj_or_subklass, phase);
139 if (allocated_klass != nullptr) {
140 assert(is_oop(phase, obj_or_subklass), "only for oop input");
141 set_req_X(ObjOrSubKlass, allocated_klass, phase);
142 return this;
143 }
144
145 // Verify that optimizing the subtype check to a simple code pattern
146 // when possible would not constant fold better
147 // TODO 8325106
148 // assert(verify(phase), "missing Value() optimization");
149
150 return nullptr;
151 }
152
153 #ifdef ASSERT
154 bool SubTypeCheckNode::is_oop(PhaseGVN* phase, Node* n) {
155 const Type* t = phase->type(n);
156 if (!t->isa_oopptr() && t != Type::TOP) {
157 n->dump();
158 t->dump(); tty->cr();
159 return false;
160 }
161 return true;
162 }
163
164 static Node* record_for_cleanup(Node* n, PhaseGVN* phase) {
165 if (phase->is_IterGVN()) {
166 phase->is_IterGVN()->_worklist.push(n); // record for cleanup
167 }
168 return n;
261 return subklass;
262 }
263 #endif
264
265 uint SubTypeCheckNode::size_of() const {
266 return sizeof(*this);
267 }
268
269 uint SubTypeCheckNode::hash() const {
270 return NO_HASH;
271 }
272
273 #ifndef PRODUCT
274 void SubTypeCheckNode::dump_spec(outputStream* st) const {
275 if (_method != nullptr) {
276 st->print(" profiled at: ");
277 _method->print_short_name(st);
278 st->print(":%d", _bci);
279 }
280 }
281 #endif
|