286
287 private:
288 // Helper methods for fold_compares
289 bool cmpi_folds(PhaseIterGVN* igvn);
290 bool is_ctrl_folds(Node* ctrl, PhaseIterGVN* igvn);
291 bool has_shared_region(ProjNode* proj, ProjNode*& success, ProjNode*& fail);
292 bool has_only_uncommon_traps(ProjNode* proj, ProjNode*& success, ProjNode*& fail, PhaseIterGVN* igvn);
293 Node* merge_uncommon_traps(ProjNode* proj, ProjNode* success, ProjNode* fail, PhaseIterGVN* igvn);
294 static void improve_address_types(Node* l, Node* r, ProjNode* fail, PhaseIterGVN* igvn);
295 bool is_cmp_with_loadrange(ProjNode* proj);
296 bool is_null_check(ProjNode* proj, PhaseIterGVN* igvn);
297 bool is_side_effect_free_test(ProjNode* proj, PhaseIterGVN* igvn);
298 void reroute_side_effect_free_unc(ProjNode* proj, ProjNode* dom_proj, PhaseIterGVN* igvn);
299 ProjNode* uncommon_trap_proj(CallStaticJavaNode*& call) const;
300 bool fold_compares_helper(ProjNode* proj, ProjNode* success, ProjNode* fail, PhaseIterGVN* igvn);
301 static bool is_dominator_unc(CallStaticJavaNode* dom_unc, CallStaticJavaNode* unc);
302
303 protected:
304 ProjNode* range_check_trap_proj(int& flip, Node*& l, Node*& r);
305 Node* Ideal_common(PhaseGVN *phase, bool can_reshape);
306 Node* dominated_by(Node* prev_dom, PhaseIterGVN* igvn);
307 Node* search_identical(int dist);
308
309 public:
310
311 // Degrees of branch prediction probability by order of magnitude:
312 // PROB_UNLIKELY_1e(N) is a 1 in 1eN chance.
313 // PROB_LIKELY_1e(N) is a 1 - PROB_UNLIKELY_1e(N)
314 #define PROB_UNLIKELY_MAG(N) (1e- ## N ## f)
315 #define PROB_LIKELY_MAG(N) (1.0f-PROB_UNLIKELY_MAG(N))
316
317 // Maximum and minimum branch prediction probabilties
318 // 1 in 1,000,000 (magnitude 6)
319 //
320 // Although PROB_NEVER == PROB_MIN and PROB_ALWAYS == PROB_MAX
321 // they are used to distinguish different situations:
322 //
323 // The name PROB_MAX (PROB_MIN) is for probabilities which correspond to
324 // very likely (unlikely) but with a concrete possibility of a rare
325 // contrary case. These constants would be used for pinning
326 // measurements, and as measures for assertions that have high
374 // Magic manifest probabilities such as 0.83, 0.7, ... can be found in
375 // gen_subtype_check() and catch_inline_exceptions().
376
377 float _prob; // Probability of true path being taken.
378 float _fcnt; // Frequency counter
379 IfNode( Node *control, Node *b, float p, float fcnt )
380 : MultiBranchNode(2), _prob(p), _fcnt(fcnt) {
381 init_class_id(Class_If);
382 init_req(0,control);
383 init_req(1,b);
384 }
385 virtual int Opcode() const;
386 virtual bool pinned() const { return true; }
387 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
388 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
389 virtual const Type* Value(PhaseGVN* phase) const;
390 virtual int required_outcnt() const { return 2; }
391 virtual const RegMask &out_RegMask() const;
392 Node* fold_compares(PhaseIterGVN* phase);
393 static Node* up_one_dom(Node* curr, bool linear_only = false);
394
395 // Takes the type of val and filters it through the test represented
396 // by if_proj and returns a more refined type if one is produced.
397 // Returns NULL is it couldn't improve the type.
398 static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
399
400 #ifndef PRODUCT
401 virtual void dump_spec(outputStream *st) const;
402 virtual void related(GrowableArray <Node *> *in_rel, GrowableArray <Node *> *out_rel, bool compact) const;
403 #endif
404 };
405
406 class RangeCheckNode : public IfNode {
407 private:
408 int is_range_check(Node* &range, Node* &index, jint &offset);
409
410 public:
411 RangeCheckNode(Node* control, Node *b, float p, float fcnt)
412 : IfNode(control, b, p, fcnt) {
413 init_class_id(Class_RangeCheck);
|
286
287 private:
288 // Helper methods for fold_compares
289 bool cmpi_folds(PhaseIterGVN* igvn);
290 bool is_ctrl_folds(Node* ctrl, PhaseIterGVN* igvn);
291 bool has_shared_region(ProjNode* proj, ProjNode*& success, ProjNode*& fail);
292 bool has_only_uncommon_traps(ProjNode* proj, ProjNode*& success, ProjNode*& fail, PhaseIterGVN* igvn);
293 Node* merge_uncommon_traps(ProjNode* proj, ProjNode* success, ProjNode* fail, PhaseIterGVN* igvn);
294 static void improve_address_types(Node* l, Node* r, ProjNode* fail, PhaseIterGVN* igvn);
295 bool is_cmp_with_loadrange(ProjNode* proj);
296 bool is_null_check(ProjNode* proj, PhaseIterGVN* igvn);
297 bool is_side_effect_free_test(ProjNode* proj, PhaseIterGVN* igvn);
298 void reroute_side_effect_free_unc(ProjNode* proj, ProjNode* dom_proj, PhaseIterGVN* igvn);
299 ProjNode* uncommon_trap_proj(CallStaticJavaNode*& call) const;
300 bool fold_compares_helper(ProjNode* proj, ProjNode* success, ProjNode* fail, PhaseIterGVN* igvn);
301 static bool is_dominator_unc(CallStaticJavaNode* dom_unc, CallStaticJavaNode* unc);
302
303 protected:
304 ProjNode* range_check_trap_proj(int& flip, Node*& l, Node*& r);
305 Node* Ideal_common(PhaseGVN *phase, bool can_reshape);
306 Node* search_identical(int dist);
307
308 public:
309
310 // Degrees of branch prediction probability by order of magnitude:
311 // PROB_UNLIKELY_1e(N) is a 1 in 1eN chance.
312 // PROB_LIKELY_1e(N) is a 1 - PROB_UNLIKELY_1e(N)
313 #define PROB_UNLIKELY_MAG(N) (1e- ## N ## f)
314 #define PROB_LIKELY_MAG(N) (1.0f-PROB_UNLIKELY_MAG(N))
315
316 // Maximum and minimum branch prediction probabilties
317 // 1 in 1,000,000 (magnitude 6)
318 //
319 // Although PROB_NEVER == PROB_MIN and PROB_ALWAYS == PROB_MAX
320 // they are used to distinguish different situations:
321 //
322 // The name PROB_MAX (PROB_MIN) is for probabilities which correspond to
323 // very likely (unlikely) but with a concrete possibility of a rare
324 // contrary case. These constants would be used for pinning
325 // measurements, and as measures for assertions that have high
373 // Magic manifest probabilities such as 0.83, 0.7, ... can be found in
374 // gen_subtype_check() and catch_inline_exceptions().
375
376 float _prob; // Probability of true path being taken.
377 float _fcnt; // Frequency counter
378 IfNode( Node *control, Node *b, float p, float fcnt )
379 : MultiBranchNode(2), _prob(p), _fcnt(fcnt) {
380 init_class_id(Class_If);
381 init_req(0,control);
382 init_req(1,b);
383 }
384 virtual int Opcode() const;
385 virtual bool pinned() const { return true; }
386 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
387 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
388 virtual const Type* Value(PhaseGVN* phase) const;
389 virtual int required_outcnt() const { return 2; }
390 virtual const RegMask &out_RegMask() const;
391 Node* fold_compares(PhaseIterGVN* phase);
392 static Node* up_one_dom(Node* curr, bool linear_only = false);
393 Node* dominated_by(Node* prev_dom, PhaseIterGVN* igvn);
394
395 // Takes the type of val and filters it through the test represented
396 // by if_proj and returns a more refined type if one is produced.
397 // Returns NULL is it couldn't improve the type.
398 static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
399
400 #ifndef PRODUCT
401 virtual void dump_spec(outputStream *st) const;
402 virtual void related(GrowableArray <Node *> *in_rel, GrowableArray <Node *> *out_rel, bool compact) const;
403 #endif
404 };
405
406 class RangeCheckNode : public IfNode {
407 private:
408 int is_range_check(Node* &range, Node* &index, jint &offset);
409
410 public:
411 RangeCheckNode(Node* control, Node *b, float p, float fcnt)
412 : IfNode(control, b, p, fcnt) {
413 init_class_id(Class_RangeCheck);
|