1 /* 2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_OPTO_CFGNODE_HPP 26 #define SHARE_VM_OPTO_CFGNODE_HPP 27 28 #include "opto/multnode.hpp" 29 #include "opto/node.hpp" 30 #include "opto/opcodes.hpp" 31 #include "opto/type.hpp" 32 33 // Portions of code courtesy of Clifford Click 34 35 // Optimization - Graph Style 36 37 class Matcher; 38 class Node; 39 class RegionNode; 40 class TypeNode; 41 class PhiNode; 42 class GotoNode; 43 class MultiNode; 44 class MultiBranchNode; 45 class IfNode; 46 class PCTableNode; 47 class JumpNode; 48 class CatchNode; 49 class NeverBranchNode; 50 class ProjNode; 51 class CProjNode; 52 class IfTrueNode; 53 class IfFalseNode; 54 class CatchProjNode; 55 class JProjNode; 56 class JumpProjNode; 57 class SCMemProjNode; 58 class PhaseIdealLoop; 59 60 //------------------------------RegionNode------------------------------------- 61 // The class of RegionNodes, which can be mapped to basic blocks in the 62 // program. Their inputs point to Control sources. PhiNodes (described 63 // below) have an input point to a RegionNode. Merged data inputs to PhiNodes 64 // correspond 1-to-1 with RegionNode inputs. The zero input of a PhiNode is 65 // the RegionNode, and the zero input of the RegionNode is itself. 66 class RegionNode : public Node { 67 public: 68 // Node layout (parallels PhiNode): 69 enum { Region, // Generally points to self. 70 Control // Control arcs are [1..len) 71 }; 72 73 RegionNode( uint required ) : Node(required) { 74 init_class_id(Class_Region); 75 init_req(0,this); 76 } 77 78 Node* is_copy() const { 79 const Node* r = _in[Region]; 80 if (r == NULL) 81 return nonnull_req(); 82 return NULL; // not a copy! 83 } 84 PhiNode* has_phi() const; // returns an arbitrary phi user, or NULL 85 PhiNode* has_unique_phi() const; // returns the unique phi user, or NULL 86 // Is this region node unreachable from root? 87 bool is_unreachable_region(PhaseGVN *phase) const; 88 virtual int Opcode() const; 89 virtual bool pinned() const { return (const Node *)in(0) == this; } 90 virtual bool is_CFG () const { return true; } 91 virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash 92 virtual bool depends_only_on_test() const { return false; } 93 virtual const Type *bottom_type() const { return Type::CONTROL; } 94 virtual const Type* Value(PhaseGVN* phase) const; 95 virtual Node* Identity(PhaseGVN* phase); 96 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 97 virtual const RegMask &out_RegMask() const; 98 bool try_clean_mem_phi(PhaseGVN *phase); 99 bool optimize_trichotomy(PhaseIterGVN* igvn); 100 }; 101 102 //------------------------------JProjNode-------------------------------------- 103 // jump projection for node that produces multiple control-flow paths 104 class JProjNode : public ProjNode { 105 public: 106 JProjNode( Node* ctrl, uint idx ) : ProjNode(ctrl,idx) {} 107 virtual int Opcode() const; 108 virtual bool is_CFG() const { return true; } 109 virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash 110 virtual const Node* is_block_proj() const { return in(0); } 111 virtual const RegMask& out_RegMask() const; 112 virtual uint ideal_reg() const { return 0; } 113 }; 114 115 //------------------------------PhiNode---------------------------------------- 116 // PhiNodes merge values from different Control paths. Slot 0 points to the 117 // controlling RegionNode. Other slots map 1-for-1 with incoming control flow 118 // paths to the RegionNode. For speed reasons (to avoid another pass) we 119 // can turn PhiNodes into copys in-place by NULL'ing out their RegionNode 120 // input in slot 0. 121 class PhiNode : public TypeNode { 122 const TypePtr* const _adr_type; // non-null only for Type::MEMORY nodes. 123 // The following fields are only used for data PhiNodes to indicate 124 // that the PhiNode represents the value of a known instance field. 125 int _inst_mem_id; // Instance memory id (node index of the memory Phi) 126 const int _inst_id; // Instance id of the memory slice. 127 const int _inst_index; // Alias index of the instance memory slice. 128 // Array elements references have the same alias_idx but different offset. 129 const int _inst_offset; // Offset of the instance memory slice. 130 // Size is bigger to hold the _adr_type field. 131 virtual uint hash() const; // Check the type 132 virtual uint cmp( const Node &n ) const; 133 virtual uint size_of() const { return sizeof(*this); } 134 135 // Determine if CMoveNode::is_cmove_id can be used at this join point. 136 Node* is_cmove_id(PhaseTransform* phase, int true_path); 137 138 public: 139 // Node layout (parallels RegionNode): 140 enum { Region, // Control input is the Phi's region. 141 Input // Input values are [1..len) 142 }; 143 144 PhiNode( Node *r, const Type *t, const TypePtr* at = NULL, 145 const int imid = -1, 146 const int iid = TypeOopPtr::InstanceTop, 147 const int iidx = Compile::AliasIdxTop, 148 const int ioffs = Type::OffsetTop ) 149 : TypeNode(t,r->req()), 150 _adr_type(at), 151 _inst_mem_id(imid), 152 _inst_id(iid), 153 _inst_index(iidx), 154 _inst_offset(ioffs) 155 { 156 init_class_id(Class_Phi); 157 init_req(0, r); 158 verify_adr_type(); 159 } 160 // create a new phi with in edges matching r and set (initially) to x 161 static PhiNode* make( Node* r, Node* x ); 162 // extra type arguments override the new phi's bottom_type and adr_type 163 static PhiNode* make( Node* r, Node* x, const Type *t, const TypePtr* at = NULL ); 164 // create a new phi with narrowed memory type 165 PhiNode* slice_memory(const TypePtr* adr_type) const; 166 PhiNode* split_out_instance(const TypePtr* at, PhaseIterGVN *igvn) const; 167 // like make(r, x), but does not initialize the in edges to x 168 static PhiNode* make_blank( Node* r, Node* x ); 169 170 // Accessors 171 RegionNode* region() const { Node* r = in(Region); assert(!r || r->is_Region(), ""); return (RegionNode*)r; } 172 173 Node* is_copy() const { 174 // The node is a real phi if _in[0] is a Region node. 175 DEBUG_ONLY(const Node* r = _in[Region];) 176 assert(r != NULL && r->is_Region(), "Not valid control"); 177 return NULL; // not a copy! 178 } 179 180 bool is_tripcount() const; 181 182 // Determine a unique non-trivial input, if any. 183 // Ignore casts if it helps. Return NULL on failure. 184 Node* unique_input(PhaseTransform *phase, bool uncast); 185 Node* unique_input(PhaseTransform *phase) { 186 Node* uin = unique_input(phase, false); 187 if (uin == NULL) { 188 uin = unique_input(phase, true); 189 } 190 return uin; 191 } 192 193 // Check for a simple dead loop. 194 enum LoopSafety { Safe = 0, Unsafe, UnsafeLoop }; 195 LoopSafety simple_data_loop_check(Node *in) const; 196 // Is it unsafe data loop? It becomes a dead loop if this phi node removed. 197 bool is_unsafe_data_reference(Node *in) const; 198 int is_diamond_phi(bool check_control_only = false) const; 199 virtual int Opcode() const; 200 virtual bool pinned() const { return in(0) != 0; } 201 virtual const TypePtr *adr_type() const { verify_adr_type(true); return _adr_type; } 202 203 void set_inst_mem_id(int inst_mem_id) { _inst_mem_id = inst_mem_id; } 204 const int inst_mem_id() const { return _inst_mem_id; } 205 const int inst_id() const { return _inst_id; } 206 const int inst_index() const { return _inst_index; } 207 const int inst_offset() const { return _inst_offset; } 208 bool is_same_inst_field(const Type* tp, int mem_id, int id, int index, int offset) { 209 return type()->basic_type() == tp->basic_type() && 210 inst_mem_id() == mem_id && 211 inst_id() == id && 212 inst_index() == index && 213 inst_offset() == offset && 214 type()->higher_equal(tp); 215 } 216 217 virtual const Type* Value(PhaseGVN* phase) const; 218 virtual Node* Identity(PhaseGVN* phase); 219 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 220 virtual const RegMask &out_RegMask() const; 221 virtual const RegMask &in_RegMask(uint) const; 222 #ifndef PRODUCT 223 virtual void related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const; 224 virtual void dump_spec(outputStream *st) const; 225 #endif 226 #ifdef ASSERT 227 void verify_adr_type(VectorSet& visited, const TypePtr* at) const; 228 void verify_adr_type(bool recursive = false) const; 229 #else //ASSERT 230 void verify_adr_type(bool recursive = false) const {} 231 #endif //ASSERT 232 }; 233 234 //------------------------------GotoNode--------------------------------------- 235 // GotoNodes perform direct branches. 236 class GotoNode : public Node { 237 public: 238 GotoNode( Node *control ) : Node(control) {} 239 virtual int Opcode() const; 240 virtual bool pinned() const { return true; } 241 virtual bool is_CFG() const { return true; } 242 virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash 243 virtual const Node *is_block_proj() const { return this; } 244 virtual bool depends_only_on_test() const { return false; } 245 virtual const Type *bottom_type() const { return Type::CONTROL; } 246 virtual const Type* Value(PhaseGVN* phase) const; 247 virtual Node* Identity(PhaseGVN* phase); 248 virtual const RegMask &out_RegMask() const; 249 250 #ifndef PRODUCT 251 virtual void related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const; 252 #endif 253 }; 254 255 //------------------------------CProjNode-------------------------------------- 256 // control projection for node that produces multiple control-flow paths 257 class CProjNode : public ProjNode { 258 public: 259 CProjNode( Node *ctrl, uint idx ) : ProjNode(ctrl,idx) {} 260 virtual int Opcode() const; 261 virtual bool is_CFG() const { return true; } 262 virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash 263 virtual const Node *is_block_proj() const { return in(0); } 264 virtual const RegMask &out_RegMask() const; 265 virtual uint ideal_reg() const { return 0; } 266 }; 267 268 //---------------------------MultiBranchNode----------------------------------- 269 // This class defines a MultiBranchNode, a MultiNode which yields multiple 270 // control values. These are distinguished from other types of MultiNodes 271 // which yield multiple values, but control is always and only projection #0. 272 class MultiBranchNode : public MultiNode { 273 public: 274 MultiBranchNode( uint required ) : MultiNode(required) { 275 init_class_id(Class_MultiBranch); 276 } 277 // returns required number of users to be well formed. 278 virtual int required_outcnt() const = 0; 279 }; 280 281 //------------------------------IfNode----------------------------------------- 282 // Output selected Control, based on a boolean test 283 class IfNode : public MultiBranchNode { 284 // Size is bigger to hold the probability field. However, _prob does not 285 // change the semantics so it does not appear in the hash & cmp functions. 286 virtual uint size_of() const { return sizeof(*this); } 287 288 private: 289 // Helper methods for fold_compares 290 bool cmpi_folds(PhaseIterGVN* igvn); 291 bool is_ctrl_folds(Node* ctrl, PhaseIterGVN* igvn); 292 bool has_shared_region(ProjNode* proj, ProjNode*& success, ProjNode*& fail); 293 bool has_only_uncommon_traps(ProjNode* proj, ProjNode*& success, ProjNode*& fail, PhaseIterGVN* igvn); 294 Node* merge_uncommon_traps(ProjNode* proj, ProjNode* success, ProjNode* fail, PhaseIterGVN* igvn); 295 static void improve_address_types(Node* l, Node* r, ProjNode* fail, PhaseIterGVN* igvn); 296 bool is_cmp_with_loadrange(ProjNode* proj); 297 bool is_null_check(ProjNode* proj, PhaseIterGVN* igvn); 298 bool is_side_effect_free_test(ProjNode* proj, PhaseIterGVN* igvn); 299 void reroute_side_effect_free_unc(ProjNode* proj, ProjNode* dom_proj, PhaseIterGVN* igvn); 300 ProjNode* uncommon_trap_proj(CallStaticJavaNode*& call) const; 301 bool fold_compares_helper(ProjNode* proj, ProjNode* success, ProjNode* fail, PhaseIterGVN* igvn); 302 static bool is_dominator_unc(CallStaticJavaNode* dom_unc, CallStaticJavaNode* unc); 303 304 protected: 305 ProjNode* range_check_trap_proj(int& flip, Node*& l, Node*& r); 306 Node* Ideal_common(PhaseGVN *phase, bool can_reshape); 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 327 // confidence, but some evidence of occasional failure. 328 // 329 // The name PROB_ALWAYS (PROB_NEVER) is to stand for situations for which 330 // there is no evidence at all that the contrary case has ever occurred. 331 332 #define PROB_NEVER PROB_UNLIKELY_MAG(6) 333 #define PROB_ALWAYS PROB_LIKELY_MAG(6) 334 335 #define PROB_MIN PROB_UNLIKELY_MAG(6) 336 #define PROB_MAX PROB_LIKELY_MAG(6) 337 338 // Static branch prediction probabilities 339 // 1 in 10 (magnitude 1) 340 #define PROB_STATIC_INFREQUENT PROB_UNLIKELY_MAG(1) 341 #define PROB_STATIC_FREQUENT PROB_LIKELY_MAG(1) 342 343 // Fair probability 50/50 344 #define PROB_FAIR (0.5f) 345 346 // Unknown probability sentinel 347 #define PROB_UNKNOWN (-1.0f) 348 349 // Probability "constructors", to distinguish as a probability any manifest 350 // constant without a names 351 #define PROB_LIKELY(x) ((float) (x)) 352 #define PROB_UNLIKELY(x) (1.0f - (float)(x)) 353 354 // Other probabilities in use, but without a unique name, are documented 355 // here for lack of a better place: 356 // 357 // 1 in 1000 probabilities (magnitude 3): 358 // threshold for converting to conditional move 359 // likelihood of null check failure if a null HAS been seen before 360 // likelihood of slow path taken in library calls 361 // 362 // 1 in 10,000 probabilities (magnitude 4): 363 // threshold for making an uncommon trap probability more extreme 364 // threshold for for making a null check implicit 365 // likelihood of needing a gc if eden top moves during an allocation 366 // likelihood of a predicted call failure 367 // 368 // 1 in 100,000 probabilities (magnitude 5): 369 // threshold for ignoring counts when estimating path frequency 370 // likelihood of FP clipping failure 371 // likelihood of catching an exception from a try block 372 // likelihood of null check failure if a null has NOT been seen before 373 // 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 Node* dominated_by(Node* prev_dom, PhaseIterGVN* igvn); 395 396 // Takes the type of val and filters it through the test represented 397 // by if_proj and returns a more refined type if one is produced. 398 // Returns NULL is it couldn't improve the type. 399 static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj); 400 401 #ifndef PRODUCT 402 virtual void dump_spec(outputStream *st) const; 403 virtual void related(GrowableArray <Node *> *in_rel, GrowableArray <Node *> *out_rel, bool compact) const; 404 #endif 405 }; 406 407 class RangeCheckNode : public IfNode { 408 private: 409 int is_range_check(Node* &range, Node* &index, jint &offset); 410 411 public: 412 RangeCheckNode(Node* control, Node *b, float p, float fcnt) 413 : IfNode(control, b, p, fcnt) { 414 init_class_id(Class_RangeCheck); 415 } 416 417 virtual int Opcode() const; 418 virtual Node* Ideal(PhaseGVN *phase, bool can_reshape); 419 }; 420 421 class IfProjNode : public CProjNode { 422 public: 423 IfProjNode(IfNode *ifnode, uint idx) : CProjNode(ifnode,idx) {} 424 virtual Node* Identity(PhaseGVN* phase); 425 426 protected: 427 // Type of If input when this branch is always taken 428 virtual bool always_taken(const TypeTuple* t) const = 0; 429 430 #ifndef PRODUCT 431 public: 432 virtual void related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const; 433 #endif 434 }; 435 436 class IfTrueNode : public IfProjNode { 437 public: 438 IfTrueNode( IfNode *ifnode ) : IfProjNode(ifnode,1) { 439 init_class_id(Class_IfTrue); 440 } 441 virtual int Opcode() const; 442 443 protected: 444 virtual bool always_taken(const TypeTuple* t) const { return t == TypeTuple::IFTRUE; } 445 }; 446 447 class IfFalseNode : public IfProjNode { 448 public: 449 IfFalseNode( IfNode *ifnode ) : IfProjNode(ifnode,0) { 450 init_class_id(Class_IfFalse); 451 } 452 virtual int Opcode() const; 453 454 protected: 455 virtual bool always_taken(const TypeTuple* t) const { return t == TypeTuple::IFFALSE; } 456 }; 457 458 459 //------------------------------PCTableNode------------------------------------ 460 // Build an indirect branch table. Given a control and a table index, 461 // control is passed to the Projection matching the table index. Used to 462 // implement switch statements and exception-handling capabilities. 463 // Undefined behavior if passed-in index is not inside the table. 464 class PCTableNode : public MultiBranchNode { 465 virtual uint hash() const; // Target count; table size 466 virtual uint cmp( const Node &n ) const; 467 virtual uint size_of() const { return sizeof(*this); } 468 469 public: 470 const uint _size; // Number of targets 471 472 PCTableNode( Node *ctrl, Node *idx, uint size ) : MultiBranchNode(2), _size(size) { 473 init_class_id(Class_PCTable); 474 init_req(0, ctrl); 475 init_req(1, idx); 476 } 477 virtual int Opcode() const; 478 virtual const Type* Value(PhaseGVN* phase) const; 479 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 480 virtual const Type *bottom_type() const; 481 virtual bool pinned() const { return true; } 482 virtual int required_outcnt() const { return _size; } 483 }; 484 485 //------------------------------JumpNode--------------------------------------- 486 // Indirect branch. Uses PCTable above to implement a switch statement. 487 // It emits as a table load and local branch. 488 class JumpNode : public PCTableNode { 489 virtual uint size_of() const { return sizeof(*this); } 490 public: 491 float* _probs; // probability of each projection 492 float _fcnt; // total number of times this Jump was executed 493 JumpNode( Node* control, Node* switch_val, uint size, float* probs, float cnt) 494 : PCTableNode(control, switch_val, size), 495 _probs(probs), _fcnt(cnt) { 496 init_class_id(Class_Jump); 497 } 498 virtual int Opcode() const; 499 virtual const RegMask& out_RegMask() const; 500 virtual const Node* is_block_proj() const { return this; } 501 #ifndef PRODUCT 502 virtual void related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const; 503 #endif 504 }; 505 506 class JumpProjNode : public JProjNode { 507 virtual uint hash() const; 508 virtual uint cmp( const Node &n ) const; 509 virtual uint size_of() const { return sizeof(*this); } 510 511 private: 512 const int _dest_bci; 513 const uint _proj_no; 514 const int _switch_val; 515 public: 516 JumpProjNode(Node* jumpnode, uint proj_no, int dest_bci, int switch_val) 517 : JProjNode(jumpnode, proj_no), _dest_bci(dest_bci), _proj_no(proj_no), _switch_val(switch_val) { 518 init_class_id(Class_JumpProj); 519 } 520 521 virtual int Opcode() const; 522 virtual const Type* bottom_type() const { return Type::CONTROL; } 523 int dest_bci() const { return _dest_bci; } 524 int switch_val() const { return _switch_val; } 525 uint proj_no() const { return _proj_no; } 526 #ifndef PRODUCT 527 virtual void dump_spec(outputStream *st) const; 528 virtual void dump_compact_spec(outputStream *st) const; 529 virtual void related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const; 530 #endif 531 }; 532 533 //------------------------------CatchNode-------------------------------------- 534 // Helper node to fork exceptions. "Catch" catches any exceptions thrown by 535 // a just-prior call. Looks like a PCTableNode but emits no code - just the 536 // table. The table lookup and branch is implemented by RethrowNode. 537 class CatchNode : public PCTableNode { 538 public: 539 CatchNode( Node *ctrl, Node *idx, uint size ) : PCTableNode(ctrl,idx,size){ 540 init_class_id(Class_Catch); 541 } 542 virtual int Opcode() const; 543 virtual const Type* Value(PhaseGVN* phase) const; 544 }; 545 546 // CatchProjNode controls which exception handler is targetted after a call. 547 // It is passed in the bci of the target handler, or no_handler_bci in case 548 // the projection doesn't lead to an exception handler. 549 class CatchProjNode : public CProjNode { 550 virtual uint hash() const; 551 virtual uint cmp( const Node &n ) const; 552 virtual uint size_of() const { return sizeof(*this); } 553 554 private: 555 const int _handler_bci; 556 557 public: 558 enum { 559 fall_through_index = 0, // the fall through projection index 560 catch_all_index = 1, // the projection index for catch-alls 561 no_handler_bci = -1 // the bci for fall through or catch-all projs 562 }; 563 564 CatchProjNode(Node* catchnode, uint proj_no, int handler_bci) 565 : CProjNode(catchnode, proj_no), _handler_bci(handler_bci) { 566 init_class_id(Class_CatchProj); 567 assert(proj_no != fall_through_index || handler_bci < 0, "fall through case must have bci < 0"); 568 } 569 570 virtual int Opcode() const; 571 virtual Node* Identity(PhaseGVN* phase); 572 virtual const Type *bottom_type() const { return Type::CONTROL; } 573 int handler_bci() const { return _handler_bci; } 574 bool is_handler_proj() const { return _handler_bci >= 0; } 575 #ifndef PRODUCT 576 virtual void dump_spec(outputStream *st) const; 577 #endif 578 }; 579 580 581 //---------------------------------CreateExNode-------------------------------- 582 // Helper node to create the exception coming back from a call 583 class CreateExNode : public TypeNode { 584 public: 585 CreateExNode(const Type* t, Node* control, Node* i_o) : TypeNode(t, 2) { 586 init_req(0, control); 587 init_req(1, i_o); 588 } 589 virtual int Opcode() const; 590 virtual Node* Identity(PhaseGVN* phase); 591 virtual bool pinned() const { return true; } 592 uint match_edge(uint idx) const { return 0; } 593 virtual uint ideal_reg() const { return Op_RegP; } 594 }; 595 596 //------------------------------NeverBranchNode------------------------------- 597 // The never-taken branch. Used to give the appearance of exiting infinite 598 // loops to those algorithms that like all paths to be reachable. Encodes 599 // empty. 600 class NeverBranchNode : public MultiBranchNode { 601 public: 602 NeverBranchNode( Node *ctrl ) : MultiBranchNode(1) { init_req(0,ctrl); } 603 virtual int Opcode() const; 604 virtual bool pinned() const { return true; }; 605 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; } 606 virtual const Type* Value(PhaseGVN* phase) const; 607 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 608 virtual int required_outcnt() const { return 2; } 609 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { } 610 virtual uint size(PhaseRegAlloc *ra_) const { return 0; } 611 #ifndef PRODUCT 612 virtual void format( PhaseRegAlloc *, outputStream *st ) const; 613 #endif 614 }; 615 616 #endif // SHARE_VM_OPTO_CFGNODE_HPP