src/share/vm/opto/cfgnode.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/cfgnode.hpp

Print this page
rev 8006 : 8073480: C2 should optimize explicit range checks
Summary: explicit range checks should be recognized by C2
Reviewed-by:


 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_folds(PhaseIterGVN* igvn);
 278   bool is_ctrl_folds(Node* ctrl, PhaseIterGVN* igvn);
 279   bool has_shared_region(ProjNode* proj, ProjNode*& success, ProjNode*& fail);
 280   bool has_only_uncommon_traps(ProjNode* proj, ProjNode*& success, ProjNode*& fail, PhaseIterGVN* igvn);
 281   static void merge_uncommon_traps(ProjNode* proj, ProjNode* success, ProjNode* fail, PhaseIterGVN* igvn);
 282   static void improve_address_types(Node* l, Node* r, ProjNode* fail, PhaseIterGVN* igvn);
 283   bool is_cmp_with_loadrange(ProjNode* proj);
 284   bool is_null_check(ProjNode* proj, PhaseIterGVN* igvn);
 285   bool is_side_effect_free_test(ProjNode* proj, PhaseIterGVN* igvn);
 286   void reroute_side_effect_free_unc(ProjNode* proj, ProjNode* dom_proj, PhaseIterGVN* igvn);
 287   ProjNode* uncommon_trap_proj(CallStaticJavaNode*& call) const;
 288   bool fold_compares_helper(ProjNode* proj, ProjNode* success, ProjNode* fail, PhaseIterGVN* igvn);
 289 
 290 public:
 291 
 292   // Degrees of branch prediction probability by order of magnitude:
 293   // PROB_UNLIKELY_1e(N) is a 1 in 1eN chance.
 294   // PROB_LIKELY_1e(N) is a 1 - PROB_UNLIKELY_1e(N)
 295 #define PROB_UNLIKELY_MAG(N)    (1e- ## N ## f)
 296 #define PROB_LIKELY_MAG(N)      (1.0f-PROB_UNLIKELY_MAG(N))
 297 
 298   // Maximum and minimum branch prediction probabilties
 299   // 1 in 1,000,000 (magnitude 6)
 300   //
 301   // Although PROB_NEVER == PROB_MIN and PROB_ALWAYS == PROB_MAX
 302   // they are used to distinguish different situations:
 303   //
 304   // The name PROB_MAX (PROB_MIN) is for probabilities which correspond to
 305   // very likely (unlikely) but with a concrete possibility of a rare
 306   // contrary case.  These constants would be used for pinning
 307   // measurements, and as measures for assertions that have high
 308   // confidence, but some evidence of occasional failure.
 309   //


 355   // Magic manifest probabilities such as 0.83, 0.7, ... can be found in
 356   // gen_subtype_check() and catch_inline_exceptions().
 357 
 358   float _prob;                  // Probability of true path being taken.
 359   float _fcnt;                  // Frequency counter
 360   IfNode( Node *control, Node *b, float p, float fcnt )
 361     : MultiBranchNode(2), _prob(p), _fcnt(fcnt) {
 362     init_class_id(Class_If);
 363     init_req(0,control);
 364     init_req(1,b);
 365   }
 366   virtual int Opcode() const;
 367   virtual bool pinned() const { return true; }
 368   virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
 369   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
 370   virtual const Type *Value( PhaseTransform *phase ) const;
 371   virtual int required_outcnt() const { return 2; }
 372   virtual const RegMask &out_RegMask() const;
 373   void dominated_by(Node* prev_dom, PhaseIterGVN* igvn);
 374   int is_range_check(Node* &range, Node* &index, jint &offset);
 375   Node* fold_compares(PhaseIterGVN* phase);
 376   static Node* up_one_dom(Node* curr, bool linear_only = false);
 377 
 378   // Takes the type of val and filters it through the test represented
 379   // by if_proj and returns a more refined type if one is produced.
 380   // Returns NULL is it couldn't improve the type.
 381   static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
 382 
 383 #ifndef PRODUCT
 384   virtual void dump_spec(outputStream *st) const;
 385 #endif
 386 };
 387 
 388 class IfProjNode : public CProjNode {
 389 public:
 390   IfProjNode(IfNode *ifnode, uint idx) : CProjNode(ifnode,idx) {}
 391   virtual Node *Identity(PhaseTransform *phase);
 392 
 393 protected:
 394   // Type of If input when this branch is always taken
 395   virtual bool always_taken(const TypeTuple* t) const = 0;


src/share/vm/opto/cfgnode.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File