246
247 //---------------------------MultiBranchNode-----------------------------------
248 // This class defines a MultiBranchNode, a MultiNode which yields multiple
249 // control values. These are distinguished from other types of MultiNodes
250 // which yield multiple values, but control is always and only projection #0.
251 class MultiBranchNode : public MultiNode {
252 public:
253 MultiBranchNode( uint required ) : MultiNode(required) {
254 init_class_id(Class_MultiBranch);
255 }
256 // returns required number of users to be well formed.
257 virtual int required_outcnt() const = 0;
258 };
259
260 //------------------------------IfNode-----------------------------------------
261 // Output selected Control, based on a boolean test
262 class IfNode : public MultiBranchNode {
263 // Size is bigger to hold the probability field. However, _prob does not
264 // change the semantics so it does not appear in the hash & cmp functions.
265 virtual uint size_of() const { return sizeof(*this); }
266 public:
267
268 // Degrees of branch prediction probability by order of magnitude:
269 // PROB_UNLIKELY_1e(N) is a 1 in 1eN chance.
270 // PROB_LIKELY_1e(N) is a 1 - PROB_UNLIKELY_1e(N)
271 #define PROB_UNLIKELY_MAG(N) (1e- ## N ## f)
272 #define PROB_LIKELY_MAG(N) (1.0f-PROB_UNLIKELY_MAG(N))
273
274 // Maximum and minimum branch prediction probabilties
275 // 1 in 1,000,000 (magnitude 6)
276 //
277 // Although PROB_NEVER == PROB_MIN and PROB_ALWAYS == PROB_MAX
278 // they are used to distinguish different situations:
279 //
280 // The name PROB_MAX (PROB_MIN) is for probabilities which correspond to
281 // very likely (unlikely) but with a concrete possibility of a rare
282 // contrary case. These constants would be used for pinning
283 // measurements, and as measures for assertions that have high
284 // confidence, but some evidence of occasional failure.
285 //
331 // Magic manifest probabilities such as 0.83, 0.7, ... can be found in
332 // gen_subtype_check() and catch_inline_exceptions().
333
334 float _prob; // Probability of true path being taken.
335 float _fcnt; // Frequency counter
336 IfNode( Node *control, Node *b, float p, float fcnt )
337 : MultiBranchNode(2), _prob(p), _fcnt(fcnt) {
338 init_class_id(Class_If);
339 init_req(0,control);
340 init_req(1,b);
341 }
342 virtual int Opcode() const;
343 virtual bool pinned() const { return true; }
344 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
345 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
346 virtual const Type *Value( PhaseTransform *phase ) const;
347 virtual int required_outcnt() const { return 2; }
348 virtual const RegMask &out_RegMask() const;
349 void dominated_by(Node* prev_dom, PhaseIterGVN* igvn);
350 int is_range_check(Node* &range, Node* &index, jint &offset);
351 Node* fold_compares(PhaseGVN* phase);
352 static Node* up_one_dom(Node* curr, bool linear_only = false);
353
354 // Takes the type of val and filters it through the test represented
355 // by if_proj and returns a more refined type if one is produced.
356 // Returns NULL is it couldn't improve the type.
357 static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
358
359 #ifndef PRODUCT
360 virtual void dump_spec(outputStream *st) const;
361 #endif
362 };
363
364 class IfProjNode : public CProjNode {
365 public:
366 IfProjNode(IfNode *ifnode, uint idx) : CProjNode(ifnode,idx) {}
367 virtual Node *Identity(PhaseTransform *phase);
368
369 protected:
370 // Type of If input when this branch is always taken
371 virtual bool always_taken(const TypeTuple* t) const = 0;
|
246
247 //---------------------------MultiBranchNode-----------------------------------
248 // This class defines a MultiBranchNode, a MultiNode which yields multiple
249 // control values. These are distinguished from other types of MultiNodes
250 // which yield multiple values, but control is always and only projection #0.
251 class MultiBranchNode : public MultiNode {
252 public:
253 MultiBranchNode( uint required ) : MultiNode(required) {
254 init_class_id(Class_MultiBranch);
255 }
256 // returns required number of users to be well formed.
257 virtual int required_outcnt() const = 0;
258 };
259
260 //------------------------------IfNode-----------------------------------------
261 // Output selected Control, based on a boolean test
262 class IfNode : public MultiBranchNode {
263 // Size is bigger to hold the probability field. However, _prob does not
264 // change the semantics so it does not appear in the hash & cmp functions.
265 virtual uint size_of() const { return sizeof(*this); }
266
267 private:
268 ProjNode* range_check_trap_proj(int& flip, Node*& l, Node*& r);
269 ProjNode* range_check_trap_proj() {
270 int flip_test = 0;
271 Node* l = NULL;
272 Node* r = NULL;
273 return range_check_trap_proj(flip_test, l, r);
274 }
275
276 // Helper methods for fold_compares
277 bool cmpi_if(PhaseIterGVN* igvn);
278 bool proj_cmpi_with(Node* ctrl, PhaseIterGVN* igvn);
279 bool shared_region(ProjNode* proj, ProjNode*& success, ProjNode*& fail);
280 bool uncommon_traps(ProjNode* proj, ProjNode*& success, ProjNode*& fail, PhaseIterGVN* igvn);
281 static void merge_uncommon_traps(ProjNode* proj, ProjNode* success, PhaseIterGVN* igvn);
282 bool side_effect_free(ProjNode* proj, PhaseIterGVN* igvn);
283 void reroute_side_effect_free_unc(ProjNode* proj, ProjNode* dom_proj, PhaseIterGVN* igvn);
284 ProjNode* uncommon_trap_proj(CallStaticJavaNode*& call) const;
285 bool fold_compares_helper(ProjNode* proj, ProjNode* success, ProjNode* fail, PhaseIterGVN* igvn);
286
287 public:
288
289 // Degrees of branch prediction probability by order of magnitude:
290 // PROB_UNLIKELY_1e(N) is a 1 in 1eN chance.
291 // PROB_LIKELY_1e(N) is a 1 - PROB_UNLIKELY_1e(N)
292 #define PROB_UNLIKELY_MAG(N) (1e- ## N ## f)
293 #define PROB_LIKELY_MAG(N) (1.0f-PROB_UNLIKELY_MAG(N))
294
295 // Maximum and minimum branch prediction probabilties
296 // 1 in 1,000,000 (magnitude 6)
297 //
298 // Although PROB_NEVER == PROB_MIN and PROB_ALWAYS == PROB_MAX
299 // they are used to distinguish different situations:
300 //
301 // The name PROB_MAX (PROB_MIN) is for probabilities which correspond to
302 // very likely (unlikely) but with a concrete possibility of a rare
303 // contrary case. These constants would be used for pinning
304 // measurements, and as measures for assertions that have high
305 // confidence, but some evidence of occasional failure.
306 //
352 // Magic manifest probabilities such as 0.83, 0.7, ... can be found in
353 // gen_subtype_check() and catch_inline_exceptions().
354
355 float _prob; // Probability of true path being taken.
356 float _fcnt; // Frequency counter
357 IfNode( Node *control, Node *b, float p, float fcnt )
358 : MultiBranchNode(2), _prob(p), _fcnt(fcnt) {
359 init_class_id(Class_If);
360 init_req(0,control);
361 init_req(1,b);
362 }
363 virtual int Opcode() const;
364 virtual bool pinned() const { return true; }
365 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
366 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
367 virtual const Type *Value( PhaseTransform *phase ) const;
368 virtual int required_outcnt() const { return 2; }
369 virtual const RegMask &out_RegMask() const;
370 void dominated_by(Node* prev_dom, PhaseIterGVN* igvn);
371 int is_range_check(Node* &range, Node* &index, jint &offset);
372 Node* fold_compares(PhaseIterGVN* phase);
373 static Node* up_one_dom(Node* curr, bool linear_only = false);
374
375 // Takes the type of val and filters it through the test represented
376 // by if_proj and returns a more refined type if one is produced.
377 // Returns NULL is it couldn't improve the type.
378 static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
379
380 #ifndef PRODUCT
381 virtual void dump_spec(outputStream *st) const;
382 #endif
383 };
384
385 class IfProjNode : public CProjNode {
386 public:
387 IfProjNode(IfNode *ifnode, uint idx) : CProjNode(ifnode,idx) {}
388 virtual Node *Identity(PhaseTransform *phase);
389
390 protected:
391 // Type of If input when this branch is always taken
392 virtual bool always_taken(const TypeTuple* t) const = 0;
|