133 }
134
135 //------------------------------Value------------------------------------------
136 const Type *ProjNode::Value( PhaseTransform *phase ) const {
137 if (in(0) == NULL) return Type::TOP;
138 return proj_type(phase->type(in(0)));
139 }
140
141 //------------------------------out_RegMask------------------------------------
142 // Pass the buck uphill
143 const RegMask &ProjNode::out_RegMask() const {
144 return RegMask::Empty;
145 }
146
147 //------------------------------ideal_reg--------------------------------------
148 uint ProjNode::ideal_reg() const {
149 return bottom_type()->ideal_reg();
150 }
151
152 //-------------------------------is_uncommon_trap_proj----------------------------
153 // Return true if proj is the form of "proj->[region->..]call_uct"
154 bool ProjNode::is_uncommon_trap_proj(Deoptimization::DeoptReason reason) {
155 int path_limit = 10;
156 Node* out = this;
157 for (int ct = 0; ct < path_limit; ct++) {
158 out = out->unique_ctrl_out();
159 if (out == NULL)
160 return false;
161 if (out->is_CallStaticJava()) {
162 int req = out->as_CallStaticJava()->uncommon_trap_request();
163 if (req != 0) {
164 Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req);
165 if (trap_reason == reason || reason == Deoptimization::Reason_none) {
166 return true;
167 }
168 }
169 return false; // don't do further after call
170 }
171 if (out->Opcode() != Op_Region)
172 return false;
173 }
174 return false;
175 }
176
177 //-------------------------------is_uncommon_trap_if_pattern-------------------------
178 // Return true for "if(test)-> proj -> ...
179 // |
180 // V
181 // other_proj->[region->..]call_uct"
182 //
183 // "must_reason_predicate" means the uct reason must be Reason_predicate
184 bool ProjNode::is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason) {
185 Node *in0 = in(0);
186 if (!in0->is_If()) return false;
187 // Variation of a dead If node.
188 if (in0->outcnt() < 2) return false;
189 IfNode* iff = in0->as_If();
190
191 // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate
192 if (reason != Deoptimization::Reason_none) {
193 if (iff->in(1)->Opcode() != Op_Conv2B ||
194 iff->in(1)->in(1)->Opcode() != Op_Opaque1) {
195 return false;
196 }
197 }
198
199 ProjNode* other_proj = iff->proj_out(1-_con);
200 if (other_proj == NULL) // Should never happen, but make Parfait happy.
201 return false;
202 if (other_proj->is_uncommon_trap_proj(reason)) {
203 assert(reason == Deoptimization::Reason_none ||
204 Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list");
205 return true;
206 }
207 return false;
208 }
|
133 }
134
135 //------------------------------Value------------------------------------------
136 const Type *ProjNode::Value( PhaseTransform *phase ) const {
137 if (in(0) == NULL) return Type::TOP;
138 return proj_type(phase->type(in(0)));
139 }
140
141 //------------------------------out_RegMask------------------------------------
142 // Pass the buck uphill
143 const RegMask &ProjNode::out_RegMask() const {
144 return RegMask::Empty;
145 }
146
147 //------------------------------ideal_reg--------------------------------------
148 uint ProjNode::ideal_reg() const {
149 return bottom_type()->ideal_reg();
150 }
151
152 //-------------------------------is_uncommon_trap_proj----------------------------
153 // Return uncommon trap call node if proj is for "proj->[region->..]call_uct"
154 // NULL otherwise
155 CallStaticJavaNode* ProjNode::is_uncommon_trap_proj(Deoptimization::DeoptReason reason) {
156 int path_limit = 10;
157 Node* out = this;
158 for (int ct = 0; ct < path_limit; ct++) {
159 out = out->unique_ctrl_out();
160 if (out == NULL)
161 return NULL;
162 if (out->is_CallStaticJava()) {
163 CallStaticJavaNode* call = out->as_CallStaticJava();
164 int req = call->uncommon_trap_request();
165 if (req != 0) {
166 Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req);
167 if (trap_reason == reason || reason == Deoptimization::Reason_none) {
168 return call;
169 }
170 }
171 return NULL; // don't do further after call
172 }
173 if (out->Opcode() != Op_Region)
174 return NULL;
175 }
176 return NULL;
177 }
178
179 //-------------------------------is_uncommon_trap_if_pattern-------------------------
180 // Return uncommon trap call node for "if(test)-> proj -> ...
181 // |
182 // V
183 // other_proj->[region->..]call_uct"
184 // NULL otherwise
185 // "must_reason_predicate" means the uct reason must be Reason_predicate
186 CallStaticJavaNode* ProjNode::is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason) {
187 Node *in0 = in(0);
188 if (!in0->is_If()) return NULL;
189 // Variation of a dead If node.
190 if (in0->outcnt() < 2) return NULL;
191 IfNode* iff = in0->as_If();
192
193 // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate
194 if (reason != Deoptimization::Reason_none) {
195 if (iff->in(1)->Opcode() != Op_Conv2B ||
196 iff->in(1)->in(1)->Opcode() != Op_Opaque1) {
197 return NULL;
198 }
199 }
200
201 ProjNode* other_proj = iff->proj_out(1-_con);
202 if (other_proj == NULL) // Should never happen, but make Parfait happy.
203 return NULL;
204 CallStaticJavaNode* call = other_proj->is_uncommon_trap_proj(reason);
205 if (call != NULL) {
206 assert(reason == Deoptimization::Reason_none ||
207 Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list");
208 return call;
209 }
210 return NULL;
211 }
212
213 ProjNode* ProjNode::other_if_proj() const {
214 assert(_con == 0 || _con == 1, "not an if?");
215 return in(0)->as_If()->proj_out(1-_con);
216 }
|