227 class CProjNode : public ProjNode {
228 public:
229 CProjNode( Node *ctrl, uint idx ) : ProjNode(ctrl,idx) {}
230 virtual int Opcode() const;
231 virtual bool is_CFG() const { return true; }
232 virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash
233 virtual const Node *is_block_proj() const { return in(0); }
234 virtual const RegMask &out_RegMask() const;
235 virtual uint ideal_reg() const { return 0; }
236 };
237
238 //---------------------------MultiBranchNode-----------------------------------
239 // This class defines a MultiBranchNode, a MultiNode which yields multiple
240 // control values. These are distinguished from other types of MultiNodes
241 // which yield multiple values, but control is always and only projection #0.
242 class MultiBranchNode : public MultiNode {
243 public:
244 MultiBranchNode( uint required ) : MultiNode(required) {
245 init_class_id(Class_MultiBranch);
246 }
247 };
248
249 //------------------------------IfNode-----------------------------------------
250 // Output selected Control, based on a boolean test
251 class IfNode : public MultiBranchNode {
252 // Size is bigger to hold the probability field. However, _prob does not
253 // change the semantics so it does not appear in the hash & cmp functions.
254 virtual uint size_of() const { return sizeof(*this); }
255 public:
256
257 // Degrees of branch prediction probability by order of magnitude:
258 // PROB_UNLIKELY_1e(N) is a 1 in 1eN chance.
259 // PROB_LIKELY_1e(N) is a 1 - PROB_UNLIKELY_1e(N)
260 #define PROB_UNLIKELY_MAG(N) (1e- ## N ## f)
261 #define PROB_LIKELY_MAG(N) (1.0f-PROB_UNLIKELY_MAG(N))
262
263 // Maximum and minimum branch prediction probabilties
264 // 1 in 1,000,000 (magnitude 6)
265 //
266 // Although PROB_NEVER == PROB_MIN and PROB_ALWAYS == PROB_MAX
316 // likelihood of FP clipping failure
317 // likelihood of catching an exception from a try block
318 // likelihood of null check failure if a null has NOT been seen before
319 //
320 // Magic manifest probabilities such as 0.83, 0.7, ... can be found in
321 // gen_subtype_check() and catch_inline_exceptions().
322
323 float _prob; // Probability of true path being taken.
324 float _fcnt; // Frequency counter
325 IfNode( Node *control, Node *b, float p, float fcnt )
326 : MultiBranchNode(2), _prob(p), _fcnt(fcnt) {
327 init_class_id(Class_If);
328 init_req(0,control);
329 init_req(1,b);
330 }
331 virtual int Opcode() const;
332 virtual bool pinned() const { return true; }
333 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
334 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
335 virtual const Type *Value( PhaseTransform *phase ) const;
336 virtual const RegMask &out_RegMask() const;
337 void dominated_by(Node* prev_dom, PhaseIterGVN* igvn);
338 int is_range_check(Node* &range, Node* &index, jint &offset);
339 Node* fold_compares(PhaseGVN* phase);
340 static Node* up_one_dom(Node* curr, bool linear_only = false);
341
342 // Takes the type of val and filters it through the test represented
343 // by if_proj and returns a more refined type if one is produced.
344 // Returns NULL is it couldn't improve the type.
345 static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
346
347 #ifndef PRODUCT
348 virtual void dump_spec(outputStream *st) const;
349 #endif
350 };
351
352 class IfTrueNode : public CProjNode {
353 public:
354 IfTrueNode( IfNode *ifnode ) : CProjNode(ifnode,1) {
355 init_class_id(Class_IfTrue);
374 // implement switch statements and exception-handling capabilities.
375 // Undefined behavior if passed-in index is not inside the table.
376 class PCTableNode : public MultiBranchNode {
377 virtual uint hash() const; // Target count; table size
378 virtual uint cmp( const Node &n ) const;
379 virtual uint size_of() const { return sizeof(*this); }
380
381 public:
382 const uint _size; // Number of targets
383
384 PCTableNode( Node *ctrl, Node *idx, uint size ) : MultiBranchNode(2), _size(size) {
385 init_class_id(Class_PCTable);
386 init_req(0, ctrl);
387 init_req(1, idx);
388 }
389 virtual int Opcode() const;
390 virtual const Type *Value( PhaseTransform *phase ) const;
391 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
392 virtual const Type *bottom_type() const;
393 virtual bool pinned() const { return true; }
394 };
395
396 //------------------------------JumpNode---------------------------------------
397 // Indirect branch. Uses PCTable above to implement a switch statement.
398 // It emits as a table load and local branch.
399 class JumpNode : public PCTableNode {
400 public:
401 JumpNode( Node* control, Node* switch_val, uint size) : PCTableNode(control, switch_val, size) {
402 init_class_id(Class_Jump);
403 }
404 virtual int Opcode() const;
405 virtual const RegMask& out_RegMask() const;
406 virtual const Node* is_block_proj() const { return this; }
407 };
408
409 class JumpProjNode : public JProjNode {
410 virtual uint hash() const;
411 virtual uint cmp( const Node &n ) const;
412 virtual uint size_of() const { return sizeof(*this); }
413
487 init_req(0, control);
488 init_req(1, i_o);
489 }
490 virtual int Opcode() const;
491 virtual Node *Identity( PhaseTransform *phase );
492 virtual bool pinned() const { return true; }
493 uint match_edge(uint idx) const { return 0; }
494 virtual uint ideal_reg() const { return Op_RegP; }
495 };
496
497 //------------------------------NeverBranchNode-------------------------------
498 // The never-taken branch. Used to give the appearance of exiting infinite
499 // loops to those algorithms that like all paths to be reachable. Encodes
500 // empty.
501 class NeverBranchNode : public MultiBranchNode {
502 public:
503 NeverBranchNode( Node *ctrl ) : MultiBranchNode(1) { init_req(0,ctrl); }
504 virtual int Opcode() const;
505 virtual bool pinned() const { return true; };
506 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
507
508 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { }
509 virtual uint size(PhaseRegAlloc *ra_) const { return 0; }
510 #ifndef PRODUCT
511 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
512 #endif
513 };
|
227 class CProjNode : public ProjNode {
228 public:
229 CProjNode( Node *ctrl, uint idx ) : ProjNode(ctrl,idx) {}
230 virtual int Opcode() const;
231 virtual bool is_CFG() const { return true; }
232 virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash
233 virtual const Node *is_block_proj() const { return in(0); }
234 virtual const RegMask &out_RegMask() const;
235 virtual uint ideal_reg() const { return 0; }
236 };
237
238 //---------------------------MultiBranchNode-----------------------------------
239 // This class defines a MultiBranchNode, a MultiNode which yields multiple
240 // control values. These are distinguished from other types of MultiNodes
241 // which yield multiple values, but control is always and only projection #0.
242 class MultiBranchNode : public MultiNode {
243 public:
244 MultiBranchNode( uint required ) : MultiNode(required) {
245 init_class_id(Class_MultiBranch);
246 }
247 // returns required number of users to be well formed.
248 virtual int required_outcnt() const = 0;
249 };
250
251 //------------------------------IfNode-----------------------------------------
252 // Output selected Control, based on a boolean test
253 class IfNode : public MultiBranchNode {
254 // Size is bigger to hold the probability field. However, _prob does not
255 // change the semantics so it does not appear in the hash & cmp functions.
256 virtual uint size_of() const { return sizeof(*this); }
257 public:
258
259 // Degrees of branch prediction probability by order of magnitude:
260 // PROB_UNLIKELY_1e(N) is a 1 in 1eN chance.
261 // PROB_LIKELY_1e(N) is a 1 - PROB_UNLIKELY_1e(N)
262 #define PROB_UNLIKELY_MAG(N) (1e- ## N ## f)
263 #define PROB_LIKELY_MAG(N) (1.0f-PROB_UNLIKELY_MAG(N))
264
265 // Maximum and minimum branch prediction probabilties
266 // 1 in 1,000,000 (magnitude 6)
267 //
268 // Although PROB_NEVER == PROB_MIN and PROB_ALWAYS == PROB_MAX
318 // likelihood of FP clipping failure
319 // likelihood of catching an exception from a try block
320 // likelihood of null check failure if a null has NOT been seen before
321 //
322 // Magic manifest probabilities such as 0.83, 0.7, ... can be found in
323 // gen_subtype_check() and catch_inline_exceptions().
324
325 float _prob; // Probability of true path being taken.
326 float _fcnt; // Frequency counter
327 IfNode( Node *control, Node *b, float p, float fcnt )
328 : MultiBranchNode(2), _prob(p), _fcnt(fcnt) {
329 init_class_id(Class_If);
330 init_req(0,control);
331 init_req(1,b);
332 }
333 virtual int Opcode() const;
334 virtual bool pinned() const { return true; }
335 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
336 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
337 virtual const Type *Value( PhaseTransform *phase ) const;
338 virtual int required_outcnt() const { return 2; }
339 virtual const RegMask &out_RegMask() const;
340 void dominated_by(Node* prev_dom, PhaseIterGVN* igvn);
341 int is_range_check(Node* &range, Node* &index, jint &offset);
342 Node* fold_compares(PhaseGVN* phase);
343 static Node* up_one_dom(Node* curr, bool linear_only = false);
344
345 // Takes the type of val and filters it through the test represented
346 // by if_proj and returns a more refined type if one is produced.
347 // Returns NULL is it couldn't improve the type.
348 static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
349
350 #ifndef PRODUCT
351 virtual void dump_spec(outputStream *st) const;
352 #endif
353 };
354
355 class IfTrueNode : public CProjNode {
356 public:
357 IfTrueNode( IfNode *ifnode ) : CProjNode(ifnode,1) {
358 init_class_id(Class_IfTrue);
377 // implement switch statements and exception-handling capabilities.
378 // Undefined behavior if passed-in index is not inside the table.
379 class PCTableNode : public MultiBranchNode {
380 virtual uint hash() const; // Target count; table size
381 virtual uint cmp( const Node &n ) const;
382 virtual uint size_of() const { return sizeof(*this); }
383
384 public:
385 const uint _size; // Number of targets
386
387 PCTableNode( Node *ctrl, Node *idx, uint size ) : MultiBranchNode(2), _size(size) {
388 init_class_id(Class_PCTable);
389 init_req(0, ctrl);
390 init_req(1, idx);
391 }
392 virtual int Opcode() const;
393 virtual const Type *Value( PhaseTransform *phase ) const;
394 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
395 virtual const Type *bottom_type() const;
396 virtual bool pinned() const { return true; }
397 virtual int required_outcnt() const { return _size; }
398 };
399
400 //------------------------------JumpNode---------------------------------------
401 // Indirect branch. Uses PCTable above to implement a switch statement.
402 // It emits as a table load and local branch.
403 class JumpNode : public PCTableNode {
404 public:
405 JumpNode( Node* control, Node* switch_val, uint size) : PCTableNode(control, switch_val, size) {
406 init_class_id(Class_Jump);
407 }
408 virtual int Opcode() const;
409 virtual const RegMask& out_RegMask() const;
410 virtual const Node* is_block_proj() const { return this; }
411 };
412
413 class JumpProjNode : public JProjNode {
414 virtual uint hash() const;
415 virtual uint cmp( const Node &n ) const;
416 virtual uint size_of() const { return sizeof(*this); }
417
491 init_req(0, control);
492 init_req(1, i_o);
493 }
494 virtual int Opcode() const;
495 virtual Node *Identity( PhaseTransform *phase );
496 virtual bool pinned() const { return true; }
497 uint match_edge(uint idx) const { return 0; }
498 virtual uint ideal_reg() const { return Op_RegP; }
499 };
500
501 //------------------------------NeverBranchNode-------------------------------
502 // The never-taken branch. Used to give the appearance of exiting infinite
503 // loops to those algorithms that like all paths to be reachable. Encodes
504 // empty.
505 class NeverBranchNode : public MultiBranchNode {
506 public:
507 NeverBranchNode( Node *ctrl ) : MultiBranchNode(1) { init_req(0,ctrl); }
508 virtual int Opcode() const;
509 virtual bool pinned() const { return true; };
510 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
511 virtual const Type *Value( PhaseTransform *phase ) const;
512 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
513 virtual int required_outcnt() const { return 2; }
514 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { }
515 virtual uint size(PhaseRegAlloc *ra_) const { return 0; }
516 #ifndef PRODUCT
517 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
518 #endif
519 };
|