@@ -43,11 +43,20 @@ class ConstraintCastNode: public TypeNode {
43
43
const DependencyType _dependency;
44
44
virtual bool cmp ( const Node &n ) const ;
45
45
virtual uint size_of () const ;
46
+ virtual uint hash () const ; // Check the type
46
47
const Type* widen_type (const PhaseGVN* phase, const Type* res, BasicType bt) const ;
47
48
49
+ private:
50
+ // PhiNode::Ideal() transforms a Phi that merges a single uncasted value into a single cast pinned at the region.
51
+ // The types of cast nodes eliminated as a consequence of this transformation are collected and stored here so the
52
+ // type dependencies carried by the cast are known. The cast can then be eliminated if the type of its input is
53
+ // narrower (or equal) than all the types it carries.
54
+ const TypeTuple* _extra_types;
55
+
48
56
public:
49
- ConstraintCastNode (Node *n, const Type *t, DependencyType dependency)
50
- : TypeNode(t,2 ), _dependency(dependency) {
57
+ ConstraintCastNode (Node* n, const Type* t, ConstraintCastNode::DependencyType dependency,
58
+ const TypeTuple* extra_types)
59
+ : TypeNode(t,2 ), _dependency(dependency), _extra_types(extra_types) {
51
60
init_class_id (Class_ConstraintCast);
52
61
init_req (1 , n);
53
62
}
@@ -59,14 +68,15 @@ class ConstraintCastNode: public TypeNode {
59
68
virtual bool depends_only_on_test () const { return _dependency == RegularDependency; }
60
69
bool carry_dependency () const { return _dependency != RegularDependency; }
61
70
TypeNode* dominating_cast (PhaseGVN* gvn, PhaseTransform* pt) const ;
62
- static Node* make_cast (int opcode, Node* c, Node * n, const Type * t, DependencyType dependency);
71
+ static Node* make_cast (int opcode, Node* c, Node* n, const Type* t, DependencyType dependency, const TypeTuple* extra_types );
63
72
static Node* make (Node* c, Node *n, const Type *t, DependencyType dependency, BasicType bt);
64
73
65
74
#ifndef PRODUCT
66
75
virtual void dump_spec (outputStream *st) const ;
67
76
#endif
68
77
69
- static Node* make_cast_for_type (Node* c, Node* in, const Type* type, DependencyType dependency);
78
+ static Node* make_cast_for_type (Node* c, Node* in, const Type* type, DependencyType dependency,
79
+ const TypeTuple* types);
70
80
71
81
Node* optimize_integer_cast (PhaseGVN* phase, BasicType bt);
72
82
@@ -91,6 +101,16 @@ class ConstraintCastNode: public TypeNode {
91
101
}
92
102
}
93
103
}
104
+
105
+ bool higher_equal_types (PhaseGVN* phase, const Node* other) const ;
106
+
107
+ int extra_types_count () const {
108
+ return _extra_types == nullptr ? 0 : _extra_types->cnt ();
109
+ }
110
+
111
+ const Type* extra_type_at (int i) const {
112
+ return _extra_types->field_at (i);
113
+ }
94
114
};
95
115
96
116
// ------------------------------CastIINode-------------------------------------
@@ -103,12 +123,12 @@ class CastIINode: public ConstraintCastNode {
103
123
virtual uint size_of () const ;
104
124
105
125
public:
106
- CastIINode (Node* n, const Type* t, DependencyType dependency = RegularDependency, bool range_check_dependency = false )
107
- : ConstraintCastNode(n, t, dependency), _range_check_dependency(range_check_dependency) {
126
+ CastIINode (Node* n, const Type* t, DependencyType dependency = RegularDependency, bool range_check_dependency = false , const TypeTuple* types = nullptr )
127
+ : ConstraintCastNode(n, t, dependency, types ), _range_check_dependency(range_check_dependency) {
108
128
init_class_id (Class_CastII);
109
129
}
110
130
CastIINode (Node* ctrl, Node* n, const Type* t, DependencyType dependency = RegularDependency, bool range_check_dependency = false )
111
- : ConstraintCastNode(n, t, dependency), _range_check_dependency(range_check_dependency) {
131
+ : ConstraintCastNode(n, t, dependency, nullptr ), _range_check_dependency(range_check_dependency) {
112
132
init_class_id (Class_CastII);
113
133
init_req (0 , ctrl);
114
134
}
@@ -134,12 +154,12 @@ class CastIINode: public ConstraintCastNode {
134
154
class CastLLNode : public ConstraintCastNode {
135
155
public:
136
156
CastLLNode (Node* ctrl, Node* n, const Type* t, DependencyType dependency = RegularDependency)
137
- : ConstraintCastNode(n, t, dependency) {
157
+ : ConstraintCastNode(n, t, dependency, nullptr ) {
138
158
init_class_id (Class_CastLL);
139
159
init_req (0 , ctrl);
140
160
}
141
- CastLLNode (Node* n, const Type* t, DependencyType dependency = RegularDependency)
142
- : ConstraintCastNode(n, t, dependency) {
161
+ CastLLNode (Node* n, const Type* t, DependencyType dependency = RegularDependency, const TypeTuple* types = nullptr )
162
+ : ConstraintCastNode(n, t, dependency, types) {
143
163
init_class_id (Class_CastLL);
144
164
}
145
165
@@ -151,8 +171,8 @@ class CastLLNode: public ConstraintCastNode {
151
171
152
172
class CastFFNode : public ConstraintCastNode {
153
173
public:
154
- CastFFNode (Node* n, const Type* t, DependencyType dependency = RegularDependency)
155
- : ConstraintCastNode(n, t, dependency) {
174
+ CastFFNode (Node* n, const Type* t, DependencyType dependency = RegularDependency, const TypeTuple* types = nullptr )
175
+ : ConstraintCastNode(n, t, dependency, types) {
156
176
init_class_id (Class_CastFF);
157
177
}
158
178
virtual int Opcode () const ;
@@ -161,8 +181,8 @@ class CastFFNode: public ConstraintCastNode {
161
181
162
182
class CastDDNode : public ConstraintCastNode {
163
183
public:
164
- CastDDNode (Node* n, const Type* t, DependencyType dependency = RegularDependency)
165
- : ConstraintCastNode(n, t, dependency) {
184
+ CastDDNode (Node* n, const Type* t, DependencyType dependency = RegularDependency, const TypeTuple* types = nullptr )
185
+ : ConstraintCastNode(n, t, dependency, types) {
166
186
init_class_id (Class_CastDD);
167
187
}
168
188
virtual int Opcode () const ;
@@ -171,8 +191,8 @@ class CastDDNode: public ConstraintCastNode {
171
191
172
192
class CastVVNode : public ConstraintCastNode {
173
193
public:
174
- CastVVNode (Node* n, const Type* t, DependencyType dependency = RegularDependency)
175
- : ConstraintCastNode(n, t, dependency) {
194
+ CastVVNode (Node* n, const Type* t, DependencyType dependency = RegularDependency, const TypeTuple* types = nullptr )
195
+ : ConstraintCastNode(n, t, dependency, types) {
176
196
init_class_id (Class_CastVV);
177
197
}
178
198
virtual int Opcode () const ;
@@ -184,8 +204,8 @@ class CastVVNode: public ConstraintCastNode {
184
204
// cast pointer to pointer (different type)
185
205
class CastPPNode : public ConstraintCastNode {
186
206
public:
187
- CastPPNode (Node *n, const Type *t, DependencyType dependency = RegularDependency)
188
- : ConstraintCastNode(n, t, dependency) {
207
+ CastPPNode (Node *n, const Type *t, DependencyType dependency = RegularDependency, const TypeTuple* types = nullptr )
208
+ : ConstraintCastNode(n, t, dependency, types ) {
189
209
}
190
210
virtual int Opcode () const ;
191
211
virtual uint ideal_reg () const { return Op_RegP; }
@@ -195,8 +215,8 @@ class CastPPNode: public ConstraintCastNode {
195
215
// for _checkcast, cast pointer to pointer (different type), without JOIN,
196
216
class CheckCastPPNode : public ConstraintCastNode {
197
217
public:
198
- CheckCastPPNode (Node *c, Node *n, const Type *t, DependencyType dependency = RegularDependency)
199
- : ConstraintCastNode(n, t, dependency) {
218
+ CheckCastPPNode (Node *c, Node *n, const Type *t, DependencyType dependency = RegularDependency, const TypeTuple* types = nullptr )
219
+ : ConstraintCastNode(n, t, dependency, types ) {
200
220
init_class_id (Class_CheckCastPP);
201
221
init_req (0 , c);
202
222
}
0 commit comments